Conflicts:
	Bench4Q-Web/src/main/webapp/script-edit.jsp
This commit is contained in:
coderfengyun 2014-04-02 09:50:21 +08:00
commit 8d1427dabe
14 changed files with 1406 additions and 719 deletions

View File

@ -1 +1,2 @@
/bin
/ScenarioParameters

View File

@ -1,6 +1,13 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<runScenario>
<definedParams/>
<definedParams>
<definedParam>
<name>param_HBase</name>
<pickOrder>sequencial</pickOrder>
<type>Ppara_Table</type>
<updateStrategy>Once</updateStrategy>
</definedParam>
</definedParams>
<pages>
<page>
<batches>
@ -32,27 +39,15 @@
</behaviorModel>
<behaviorModel>
<id>1</id>
<name>Send</name>
<name>Sleep</name>
<parameters>
<parameter>
<key>beginTime</key>
<value>201309111715001</value>
</parameter>
<parameter>
<key>endTime</key>
<value>201309112215001</value>
</parameter>
<parameter>
<key>beginUser</key>
<value>1001</value>
</parameter>
<parameter>
<key>endUser</key>
<value>1100</value>
<key>time</key>
<value>5000</value>
</parameter>
</parameters>
<type>USERBEHAVIOR</type>
<use>hBase</use>
<type>TIMERBEHAVIOR</type>
<use>timer</use>
</behaviorModel>
<behaviorModel>
<id>2</id>
@ -80,27 +75,15 @@
</behaviorModel>
<behaviorModel>
<id>3</id>
<name>Send</name>
<name>Sleep</name>
<parameters>
<parameter>
<key>beginTime</key>
<value>201309111715001</value>
</parameter>
<parameter>
<key>endTime</key>
<value>201309112215001</value>
</parameter>
<parameter>
<key>beginUser</key>
<value>3001</value>
</parameter>
<parameter>
<key>endUser</key>
<value>3100</value>
<key>time</key>
<value>5000</value>
</parameter>
</parameters>
<type>USERBEHAVIOR</type>
<use>hBase</use>
<type>TIMERBEHAVIOR</type>
<use>timer</use>
</behaviorModel>
<behaviorModel>
<id>4</id>
@ -128,27 +111,15 @@
</behaviorModel>
<behaviorModel>
<id>5</id>
<name>Send</name>
<name>Sleep</name>
<parameters>
<parameter>
<key>beginTime</key>
<value>201309111715001</value>
</parameter>
<parameter>
<key>endTime</key>
<value>201309112215001</value>
</parameter>
<parameter>
<key>beginUser</key>
<value>5001</value>
</parameter>
<parameter>
<key>endUser</key>
<value>5100</value>
<key>time</key>
<value>5000</value>
</parameter>
</parameters>
<type>USERBEHAVIOR</type>
<use>hBase</use>
<type>TIMERBEHAVIOR</type>
<use>timer</use>
</behaviorModel>
<behaviorModel>
<id>6</id>
@ -176,27 +147,15 @@
</behaviorModel>
<behaviorModel>
<id>7</id>
<name>Send</name>
<name>Sleep</name>
<parameters>
<parameter>
<key>beginTime</key>
<value>201309111715001</value>
</parameter>
<parameter>
<key>endTime</key>
<value>201309112215001</value>
</parameter>
<parameter>
<key>beginUser</key>
<value>7001</value>
</parameter>
<parameter>
<key>endUser</key>
<value>7100</value>
<key>time</key>
<value>5000</value>
</parameter>
</parameters>
<type>USERBEHAVIOR</type>
<use>hBase</use>
<type>TIMERBEHAVIOR</type>
<use>timer</use>
</behaviorModel>
<behaviorModel>
<id>8</id>
@ -224,6 +183,18 @@
</behaviorModel>
<behaviorModel>
<id>9</id>
<name>Sleep</name>
<parameters>
<parameter>
<key>time</key>
<value>5000</value>
</parameter>
</parameters>
<type>TIMERBEHAVIOR</type>
<use>timer</use>
</behaviorModel>
<behaviorModel>
<id>10</id>
<name>Send</name>
<parameters>
<parameter>
@ -236,16 +207,172 @@
</parameter>
<parameter>
<key>beginUser</key>
<value>9001</value>
<value>10001</value>
</parameter>
<parameter>
<key>endUser</key>
<value>9100</value>
<value>10100</value>
</parameter>
</parameters>
<type>USERBEHAVIOR</type>
<use>hBase</use>
</behaviorModel>
<behaviorModel>
<id>11</id>
<name>Sleep</name>
<parameters>
<parameter>
<key>time</key>
<value>5000</value>
</parameter>
</parameters>
<type>TIMERBEHAVIOR</type>
<use>timer</use>
</behaviorModel>
<behaviorModel>
<id>12</id>
<name>Send</name>
<parameters>
<parameter>
<key>beginTime</key>
<value>201309111715001</value>
</parameter>
<parameter>
<key>endTime</key>
<value>201309112215001</value>
</parameter>
<parameter>
<key>beginUser</key>
<value>12001</value>
</parameter>
<parameter>
<key>endUser</key>
<value>12100</value>
</parameter>
</parameters>
<type>USERBEHAVIOR</type>
<use>hBase</use>
</behaviorModel>
<behaviorModel>
<id>13</id>
<name>Sleep</name>
<parameters>
<parameter>
<key>time</key>
<value>5000</value>
</parameter>
</parameters>
<type>TIMERBEHAVIOR</type>
<use>timer</use>
</behaviorModel>
<behaviorModel>
<id>14</id>
<name>Send</name>
<parameters>
<parameter>
<key>beginTime</key>
<value>201309111715001</value>
</parameter>
<parameter>
<key>endTime</key>
<value>201309112215001</value>
</parameter>
<parameter>
<key>beginUser</key>
<value>14001</value>
</parameter>
<parameter>
<key>endUser</key>
<value>14100</value>
</parameter>
</parameters>
<type>USERBEHAVIOR</type>
<use>hBase</use>
</behaviorModel>
<behaviorModel>
<id>15</id>
<name>Sleep</name>
<parameters>
<parameter>
<key>time</key>
<value>5000</value>
</parameter>
</parameters>
<type>TIMERBEHAVIOR</type>
<use>timer</use>
</behaviorModel>
<behaviorModel>
<id>16</id>
<name>Send</name>
<parameters>
<parameter>
<key>beginTime</key>
<value>201309111715001</value>
</parameter>
<parameter>
<key>endTime</key>
<value>201309112215001</value>
</parameter>
<parameter>
<key>beginUser</key>
<value>16001</value>
</parameter>
<parameter>
<key>endUser</key>
<value>16100</value>
</parameter>
</parameters>
<type>USERBEHAVIOR</type>
<use>hBase</use>
</behaviorModel>
<behaviorModel>
<id>17</id>
<name>Sleep</name>
<parameters>
<parameter>
<key>time</key>
<value>5000</value>
</parameter>
</parameters>
<type>TIMERBEHAVIOR</type>
<use>timer</use>
</behaviorModel>
<behaviorModel>
<id>18</id>
<name>Send</name>
<parameters>
<parameter>
<key>beginTime</key>
<value>201309111715001</value>
</parameter>
<parameter>
<key>endTime</key>
<value>201309112215001</value>
</parameter>
<parameter>
<key>beginUser</key>
<value>18001</value>
</parameter>
<parameter>
<key>endUser</key>
<value>18100</value>
</parameter>
</parameters>
<type>USERBEHAVIOR</type>
<use>hBase</use>
</behaviorModel>
<behaviorModel>
<id>19</id>
<name>Sleep</name>
<parameters>
<parameter>
<key>time</key>
<value>5000</value>
</parameter>
</parameters>
<type>TIMERBEHAVIOR</type>
<use>timer</use>
</behaviorModel>
</behaviors>
<childId>-1</childId>
<id>0</id>
@ -261,5 +388,10 @@
<name>Hbase</name>
<parameters />
</usePlugin>
<usePlugin>
<id>timer</id>
<name>ConstantTimer</name>
<parameters />
</usePlugin>
</usePlugins>
</runScenario>

View File

@ -14,6 +14,7 @@ import org.apache.commons.io.FileUtils;
import org.bench4q.agent.plugin.basic.hbase.HBasePlugin;
import org.bench4q.share.helper.MarshalHelper;
import org.bench4q.share.helper.TestHelper;
import org.bench4q.share.models.agent.DefinedParameterModel;
import org.bench4q.share.models.agent.ParameterModel;
import org.bench4q.share.models.agent.RunScenarioModel;
import org.bench4q.share.models.agent.scriptrecord.BatchModel;
@ -24,34 +25,53 @@ import org.bench4q.share.models.agent.scriptrecord.UsePluginModel;
public class Test_HBasePlugin {
@Test
public void testBuildScenario() {
RunScenarioModel result = buildScenario(10);
assertEquals(1, result.getUsePlugins().size());
int behaviorSize = 20;
RunScenarioModel result = buildScenario(behaviorSize);
assertEquals(1, result.getDefinedParameters().size());
assertEquals("param_HBase", result.getDefinedParameters().get(0)
.getName());
assertEquals(2, result.getUsePlugins().size());
assertEquals("hBase", result.getUsePlugins().get(0).getId());
assertEquals("Hbase", result.getUsePlugins().get(0).getName());
assertEquals("timer", result.getUsePlugins().get(1).getId());
assertEquals("ConstantTimer", result.getUsePlugins().get(1).getName());
assertEquals(1, result.getPages().size());
assertEquals(1, result.getPages().get(0).getBatches().size());
assertEquals(10, result.getPages().get(0).getBatches().get(0)
assertEquals(behaviorSize, result.getPages().get(0).getBatches().get(0)
.getBehaviors().size());
for (int i = 0; i < 10; i++) {
for (int i = 0; i < behaviorSize; i++) {
BehaviorModel behavior = result.getPages().get(0).getBatches()
.get(0).getBehaviors().get(i);
assertEquals(i, behavior.getId());
if (i % 2 == 0) {
assertEquals("Send", behavior.getName());
assertEquals(4, behavior.getParameters().size());
assertEquals("USERBEHAVIOR", behavior.getType());
assertEquals("hBase", behavior.getUse());
assertEquals("beginTime", behavior.getParameters().get(0).getKey());
assertEquals("beginTime", behavior.getParameters().get(0)
.getKey());
assertEquals("201309111715001", behavior.getParameters().get(0)
.getValue());
assertEquals("endTime", behavior.getParameters().get(1).getKey());
assertEquals("endTime", behavior.getParameters().get(1)
.getKey());
assertEquals("201309112215001", behavior.getParameters().get(1)
.getValue());
assertEquals(1000 * i + 1 + "", behavior.getParameters().get(2)
.getValue());
assertEquals("beginUser", behavior.getParameters().get(2).getKey());
assertEquals(1000 * i + 100 + "", behavior.getParameters().get(3)
.getValue());
assertEquals("endUser", behavior.getParameters().get(3).getKey());
assertEquals("beginUser", behavior.getParameters().get(2)
.getKey());
assertEquals(1000 * i + 100 + "",
behavior.getParameters().get(3).getValue());
assertEquals("endUser", behavior.getParameters().get(3)
.getKey());
} else {
assertEquals("Sleep", behavior.getName());
assertEquals(1, behavior.getParameters().size());
assertEquals("TIMERBEHAVIOR", behavior.getType());
assertEquals("time", behavior.getParameters().get(0).getKey());
assertEquals("5000", behavior.getParameters().get(0).getValue());
}
}
try {
result.setPoolSize(1);
@ -67,13 +87,15 @@ public class Test_HBasePlugin {
public static RunScenarioModel buildScenario(int behaviorSize) {
RunScenarioModel runScenarioModel = new RunScenarioModel();
DefinedParameterModel dp = new DefinedParameterModel("param_HBase",
"Ppara_Table", "sequencial", "Once");
List<DefinedParameterModel> definedParamters = new ArrayList<DefinedParameterModel>();
definedParamters.add(dp);
runScenarioModel.setDefinedParameters(definedParamters);
List<UsePluginModel> usePluginList = new ArrayList<UsePluginModel>();
UsePluginModel plugin = new UsePluginModel();
plugin.setId("hBase");
plugin.setName("Hbase");
plugin.setParameters(Collections.<ParameterModel> emptyList());
usePluginList.add(plugin);
usePluginList.add(buildUpPlugin("hBase", "Hbase"));
usePluginList.add(buildUpPlugin("timer", "ConstantTimer"));
runScenarioModel.setUsePlugins(usePluginList);
List<PageModel> pageList = new ArrayList<PageModel>();
@ -86,7 +108,10 @@ public class Test_HBasePlugin {
List<BehaviorModel> behaviorList = new ArrayList<BehaviorModel>();
for (int i = 0; i < behaviorSize; i++) {
if (i % 2 == 0)
behaviorList.add(createABehavior(i));
else
behaviorList.add(createTimer(i));
}
batch.setBehaviors(behaviorList);
batchModelList.add(batch);
@ -96,6 +121,21 @@ public class Test_HBasePlugin {
return runScenarioModel;
}
private static BehaviorModel createTimer(int i) {
List<ParameterModel> parameters = new ArrayList<ParameterModel>();
parameters.add(ParameterModel.createParameter("time", "5000"));
return BehaviorModel.TimerBehaviorBuilder(i, "Sleep", "timer",
parameters);
}
private static UsePluginModel buildUpPlugin(String id, String name) {
UsePluginModel plugin = new UsePluginModel();
plugin.setId(id);
plugin.setName(name);
plugin.setParameters(Collections.<ParameterModel> emptyList());
return plugin;
}
private static BehaviorModel createABehavior(int i) {
List<ParameterModel> parameters = new ArrayList<ParameterModel>();
parameters.add(ParameterModel.createParameter("beginTime",

View File

@ -0,0 +1,390 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<runScenario>
<definedParams />
<pages>
<page>
<batches>
<batch>
<behaviors>
<behaviorModel>
<id>0</id>
<name>Send</name>
<parameters>
<parameter>
<key>beginTime</key>
<value>201309111715001</value>
</parameter>
<parameter>
<key>endTime</key>
<value>201309112215001</value>
</parameter>
<parameter>
<key>beginUser</key>
<value>1</value>
</parameter>
<parameter>
<key>endUser</key>
<value>100</value>
</parameter>
</parameters>
<type>USERBEHAVIOR</type>
<use>hBase</use>
</behaviorModel>
<behaviorModel>
<id>1</id>
<name>Sleep</name>
<parameters>
<parameter>
<key>time</key>
<value>5000</value>
</parameter>
</parameters>
<type>TIMERBEHAVIOR</type>
<use>timer</use>
</behaviorModel>
<behaviorModel>
<id>2</id>
<name>Send</name>
<parameters>
<parameter>
<key>beginTime</key>
<value>201309111715001</value>
</parameter>
<parameter>
<key>endTime</key>
<value>201309112215001</value>
</parameter>
<parameter>
<key>beginUser</key>
<value>2001</value>
</parameter>
<parameter>
<key>endUser</key>
<value>2100</value>
</parameter>
</parameters>
<type>USERBEHAVIOR</type>
<use>hBase</use>
</behaviorModel>
<behaviorModel>
<id>3</id>
<name>Sleep</name>
<parameters>
<parameter>
<key>time</key>
<value>5000</value>
</parameter>
</parameters>
<type>TIMERBEHAVIOR</type>
<use>timer</use>
</behaviorModel>
<behaviorModel>
<id>4</id>
<name>Send</name>
<parameters>
<parameter>
<key>beginTime</key>
<value>201309111715001</value>
</parameter>
<parameter>
<key>endTime</key>
<value>201309112215001</value>
</parameter>
<parameter>
<key>beginUser</key>
<value>4001</value>
</parameter>
<parameter>
<key>endUser</key>
<value>4100</value>
</parameter>
</parameters>
<type>USERBEHAVIOR</type>
<use>hBase</use>
</behaviorModel>
<behaviorModel>
<id>5</id>
<name>Sleep</name>
<parameters>
<parameter>
<key>time</key>
<value>5000</value>
</parameter>
</parameters>
<type>TIMERBEHAVIOR</type>
<use>timer</use>
</behaviorModel>
<behaviorModel>
<id>6</id>
<name>Send</name>
<parameters>
<parameter>
<key>beginTime</key>
<value>201309111715001</value>
</parameter>
<parameter>
<key>endTime</key>
<value>201309112215001</value>
</parameter>
<parameter>
<key>beginUser</key>
<value>6001</value>
</parameter>
<parameter>
<key>endUser</key>
<value>6100</value>
</parameter>
</parameters>
<type>USERBEHAVIOR</type>
<use>hBase</use>
</behaviorModel>
<behaviorModel>
<id>7</id>
<name>Sleep</name>
<parameters>
<parameter>
<key>time</key>
<value>5000</value>
</parameter>
</parameters>
<type>TIMERBEHAVIOR</type>
<use>timer</use>
</behaviorModel>
<behaviorModel>
<id>8</id>
<name>Send</name>
<parameters>
<parameter>
<key>beginTime</key>
<value>201309111715001</value>
</parameter>
<parameter>
<key>endTime</key>
<value>201309112215001</value>
</parameter>
<parameter>
<key>beginUser</key>
<value>8001</value>
</parameter>
<parameter>
<key>endUser</key>
<value>8100</value>
</parameter>
</parameters>
<type>USERBEHAVIOR</type>
<use>hBase</use>
</behaviorModel>
<behaviorModel>
<id>9</id>
<name>Sleep</name>
<parameters>
<parameter>
<key>time</key>
<value>5000</value>
</parameter>
</parameters>
<type>TIMERBEHAVIOR</type>
<use>timer</use>
</behaviorModel>
<behaviorModel>
<id>10</id>
<name>Send</name>
<parameters>
<parameter>
<key>beginTime</key>
<value>201309111715001</value>
</parameter>
<parameter>
<key>endTime</key>
<value>201309112215001</value>
</parameter>
<parameter>
<key>beginUser</key>
<value>10001</value>
</parameter>
<parameter>
<key>endUser</key>
<value>10100</value>
</parameter>
</parameters>
<type>USERBEHAVIOR</type>
<use>hBase</use>
</behaviorModel>
<behaviorModel>
<id>11</id>
<name>Sleep</name>
<parameters>
<parameter>
<key>time</key>
<value>5000</value>
</parameter>
</parameters>
<type>TIMERBEHAVIOR</type>
<use>timer</use>
</behaviorModel>
<behaviorModel>
<id>12</id>
<name>Send</name>
<parameters>
<parameter>
<key>beginTime</key>
<value>201309111715001</value>
</parameter>
<parameter>
<key>endTime</key>
<value>201309112215001</value>
</parameter>
<parameter>
<key>beginUser</key>
<value>12001</value>
</parameter>
<parameter>
<key>endUser</key>
<value>12100</value>
</parameter>
</parameters>
<type>USERBEHAVIOR</type>
<use>hBase</use>
</behaviorModel>
<behaviorModel>
<id>13</id>
<name>Sleep</name>
<parameters>
<parameter>
<key>time</key>
<value>5000</value>
</parameter>
</parameters>
<type>TIMERBEHAVIOR</type>
<use>timer</use>
</behaviorModel>
<behaviorModel>
<id>14</id>
<name>Send</name>
<parameters>
<parameter>
<key>beginTime</key>
<value>201309111715001</value>
</parameter>
<parameter>
<key>endTime</key>
<value>201309112215001</value>
</parameter>
<parameter>
<key>beginUser</key>
<value>14001</value>
</parameter>
<parameter>
<key>endUser</key>
<value>14100</value>
</parameter>
</parameters>
<type>USERBEHAVIOR</type>
<use>hBase</use>
</behaviorModel>
<behaviorModel>
<id>15</id>
<name>Sleep</name>
<parameters>
<parameter>
<key>time</key>
<value>5000</value>
</parameter>
</parameters>
<type>TIMERBEHAVIOR</type>
<use>timer</use>
</behaviorModel>
<behaviorModel>
<id>16</id>
<name>Send</name>
<parameters>
<parameter>
<key>beginTime</key>
<value>201309111715001</value>
</parameter>
<parameter>
<key>endTime</key>
<value>201309112215001</value>
</parameter>
<parameter>
<key>beginUser</key>
<value>16001</value>
</parameter>
<parameter>
<key>endUser</key>
<value>16100</value>
</parameter>
</parameters>
<type>USERBEHAVIOR</type>
<use>hBase</use>
</behaviorModel>
<behaviorModel>
<id>17</id>
<name>Sleep</name>
<parameters>
<parameter>
<key>time</key>
<value>5000</value>
</parameter>
</parameters>
<type>TIMERBEHAVIOR</type>
<use>timer</use>
</behaviorModel>
<behaviorModel>
<id>18</id>
<name>Send</name>
<parameters>
<parameter>
<key>beginTime</key>
<value>201309111715001</value>
</parameter>
<parameter>
<key>endTime</key>
<value>201309112215001</value>
</parameter>
<parameter>
<key>beginUser</key>
<value>18001</value>
</parameter>
<parameter>
<key>endUser</key>
<value>18100</value>
</parameter>
</parameters>
<type>USERBEHAVIOR</type>
<use>hBase</use>
</behaviorModel>
<behaviorModel>
<id>19</id>
<name>Sleep</name>
<parameters>
<parameter>
<key>time</key>
<value>5000</value>
</parameter>
</parameters>
<type>TIMERBEHAVIOR</type>
<use>timer</use>
</behaviorModel>
</behaviors>
<childId>-1</childId>
<id>0</id>
<parentId>-1</parentId>
</batch>
</batches>
</page>
</pages>
<poolSize>1</poolSize>
<usePlugins>
<usePlugin>
<id>hBase</id>
<name>Hbase</name>
<parameters />
</usePlugin>
<usePlugin>
<id>timer</id>
<name>ConstantTimer</name>
<parameters />
</usePlugin>
</usePlugins>
</runScenario>

View File

@ -2,12 +2,15 @@ package org.bench4q.master.test.service;
import static org.junit.Assert.*;
import java.io.File;
import java.io.IOException;
import java.util.Date;
import java.util.LinkedList;
import java.util.List;
import javax.xml.bind.JAXBException;
import org.apache.commons.io.FileUtils;
import org.bench4q.master.domain.entity.Script;
import org.bench4q.master.domain.entity.User;
import org.bench4q.master.domain.repository.UserRepository;
@ -74,6 +77,17 @@ public class Test_ScriptService {
assertTrue(doSaveAScript(user));
}
@Test
public void testSaveScriptWithDefinedParameters() throws IOException {
User user = this.getUserRepository().getUser("admin");
this.getScriptService().saveScript(
"HBaseScript",
user.getId(),
FileUtils.readFileToString(new File("Scripts"
+ System.getProperty("file.separator")
+ "HBaseScript.xml")));
}
private boolean doSaveAScript(User user) throws JAXBException {
return this.getScriptService().saveScript(
"ad",
@ -156,9 +170,13 @@ public class Test_ScriptService {
@After
public void cleanUp() {
try {
User user = this.getUserRepository().getUser("test1");
assertTrue(this.getScriptService().deleteScript(
getUploadScriptId(user), user.getId()));
int uploadScriptId = getUploadScriptId(user);
assertTrue(this.getScriptService().deleteScript(uploadScriptId,
user.getId()));
this.getUserRepository().detach("test1");
} catch (Exception e) {
}
}
}

View File

@ -40,7 +40,7 @@ public class TestPlanTester extends TestBase_MakeUpTestPlan {
private TestPlanModel testPlanBusinessModel = new TestPlanModel();
private String _url = TestBase.BASE_URL + "/testPlan";
private int scriptSumNum;
public static int SCRIPTID1 = 78;
public static int SCRIPTID1 = 3;
private static int SCRIPTID2 = 2;
private static String Monitor_Host_Name = "133.133.12.3";
private static String monitor_port = "5556";
@ -49,8 +49,7 @@ public class TestPlanTester extends TestBase_MakeUpTestPlan {
return testPlanBusinessModel;
}
public void setTestPlanBusinessModel(
TestPlanModel testPlanBusinessModel) {
public void setTestPlanBusinessModel(TestPlanModel testPlanBusinessModel) {
this.testPlanBusinessModel = testPlanBusinessModel;
}
@ -159,8 +158,7 @@ public class TestPlanTester extends TestBase_MakeUpTestPlan {
return stringWriter.toString();
}
public static TestPlanModel createATestPlanWithZeroMonitor(
int scriptId) {
public static TestPlanModel createATestPlanWithZeroMonitor(int scriptId) {
TestPlanModel testPlanBusinessModel = new TestPlanModel();
testPlanBusinessModel.setMonitorModels(new ArrayList<MonitorModel>());
testPlanBusinessModel
@ -168,8 +166,7 @@ public class TestPlanTester extends TestBase_MakeUpTestPlan {
return testPlanBusinessModel;
}
public static TestPlanModel createATestPlanWithNullMonitorList(
int scriptId) {
public static TestPlanModel createATestPlanWithNullMonitorList(int scriptId) {
TestPlanModel testPlanBusinessModel = new TestPlanModel();
testPlanBusinessModel.setMonitorModels(null);
testPlanBusinessModel

View File

@ -173,3 +173,23 @@ td {
color: #3689BB;
}
.sample_frame {
padding:10px;
margin: 10px 10px 10px 10px;
border: #3689BB solid thin;
}
.sample_sub_frame {
border: #F0ECE0 solid thin;
margin-top: 5px;
margin-bottom: 5px;
margin-left: 10px;
margin-right: 10px;
padding-top:10px;
padding-left:10px;
padding-bottom:10px;
}
p{
color: #4E9BCB;
}

View File

@ -272,8 +272,8 @@ body {
<script src="lib/chrisma/js/theme.js"></script>
<script src="script/base.js"></script>
<script src="script/pluginModel.js"></script>
<!-- <script src="script/plugin.js"></script> -->
<script src="script/plugin-new.js"></script>
<script src="script/behaviorsForm.js"></script>
</fmt:bundle>
</body>
</html>

View File

@ -141,3 +141,61 @@ function loadProperties(){
mode:'map', // 用 Map 的方式使用资源文件中的值
} );
}
function HashMap() {
this.arrKey = new Array();
this.arrValue = new Array();
this.exists = function(strKey) {
strKey = strKey.toUpperCase();
for (var i = 0; i < this.arrKey.length; i++) {
if (this.arrKey[i] == strKey) {
return true;
}
}
return false;
};
this.length = function() {
return this.arrKey.length;
};
this.put = function(strKey, objValue) {
strKey = strKey.toUpperCase();
for (var i = 0; i < this.arrKey.length; i++) {
if (this.arrKey[i] == strKey) {
this.arrValue[i] = objValue;
return;
}
}
this.arrKey[this.arrKey.length] = strKey;
this.arrValue[this.arrValue.length] = objValue;
};
this.get = function(strKey) {
strKey = strKey.toUpperCase();
for (var i = 0; i < this.arrKey.length; i++) {
if (this.arrKey[i] == strKey) {
return this.arrValue[i];
}
}
return null;
};
this.remove = function(strKey) {
strKey = strKey.toUpperCase();
for (var i = 0; i < this.arrKey.length; i++) {
if (this.arrKey[i] == strKey) {
this.arrKey.splice(i, 1);
this.arrValue.splice(i, 1);
return;
}
}
};
this.getKeys = function() {
return this.arrKey;
};
this.getValues = function() {
return this.arrValue;
};
}

View File

@ -0,0 +1,268 @@
function createBehaviorsForm(data, behaviorData, behaviorIndex) {
var methodParams = new Array();
var fieldHTML = "";
for (var i = 0; i < data.length; i++) {
methodParams.push(data[i]);
}
for (var j = 0; j < methodParams.length; j++) {
var methodParamModel = new MethodParamModel(methodParams[j].name,
methodParams[j].lable, methodParams[j].valueSeperator,
methodParams[j].fieldSeperator, methodParams[j].paramType,
methodParams[j].methodParamProperties);
var methodParamProperties = new Array();
for (var q = 0; q < methodParamModel.methodParamProperties.length; q++) {
var methodParamPropertyModel = new MethodParamPropertyModel(
methodParamModel.methodParamProperties[q].key,
methodParamModel.methodParamProperties[q].value);
methodParamProperties.push(methodParamPropertyModel);
}
var type = methodParamModel.paramType;
var size = 0, cols = "", rows = "";
for (var p = 0; p < methodParamProperties.length; p++) {
var methodParamProertyModel = methodParamProperties[p];
if (methodParamProertyModel.key == "size") {
size = methodParamProertyModel.value;
} else if (methodParamProertyModel.key == "cols") {
cols = methodParamProertyModel.value;
} else if (methodParamProertyModel.key == "rows") {
rows = methodParamProertyModel.value;
}
}
if (type == "Field") {
fieldHTML += createField(methodParamModel.lable,
methodParamModel.name, size, behaviorIndex);
} else if (type == "MultiField") {
fieldHTML += createMultiField(methodParamModel.lable,
methodParamModel.name, size, behaviorIndex);
} else if (type == "Table") {
fieldHTML += createTable(methodParamModel, cols, behaviorIndex);
} else if (type == "CheckBox") {
fieldHTML += createCheckBox(methodParamModel, rows, behaviorIndex);
}
}
return fieldHTML;
}
function createField(label, name, size, behaviorIndex) {
if (size == 0) {
size = 20;
}
var divNode = document.createElement("div");
var p = document.createElement("p");
var labelNode = document.createTextNode(label);
var div = document.createElement("div");
var nameNode = document.createTextNode(name);
var input = document.createElement("input");
$(divNode).attr("class", "Field sample_frame");
$(divNode).attr("id", behaviorIndex + "_" + name);
$(div).attr("class", "sample_sub_frame");
$(input).attr("type", "text");
$(input).attr("size", size);
$(input).attr("id", name + "_input");
p.appendChild(labelNode);
div.appendChild(nameNode);
div.appendChild(input);
divNode.appendChild(p);
divNode.appendChild(div);
return divNode.outerHTML;
}
function createMultiField(label, name, size, behaviorIndex) {
if (size == 0) {
size = 20;
}
var divNode = document.createElement("div");
var p = document.createElement("p");
var labelNode = document.createTextNode(name + ":" + label);
var div = document.createElement("div");
var addFieldButton = document.createElement("button");
var addFieldNode = document.createTextNode($.i18n
.prop("plugin_jsp_addField"));
var removeFieldButton = document.createElement("button");
var removeFieldNode = document.createTextNode($.i18n
.prop("plugin_jsp_removeField"));
var br = document.createElement("br");
var table = document.createElement("table");
$(divNode).attr("class", "MultiField sample_frame");
$(divNode).attr("id", behaviorIndex + "_" + name);
$(div).attr("class", "sample_sub_frame");
$(addFieldButton).attr("type", "submit");
$(addFieldButton).attr("class", "btn-large");
$(addFieldButton).attr("onClick",
"addField(" + size + "," + behaviorIndex + ");");
$(removeFieldButton).attr("type", "submit");
$(removeFieldButton).attr("class", "btn-large");
$(removeFieldButton).attr("onClick", "removeField(this)");
$(table).attr("id", "addFieldTable_" + behaviorIndex);
$(table).attr("class", "table-margin");
p.appendChild(labelNode);
addFieldButton.appendChild(addFieldNode);
removeFieldButton.appendChild(removeFieldNode);
div.appendChild(addFieldButton);
div.appendChild(removeFieldButton);
div.appendChild(br);
div.appendChild(table);
divNode.appendChild(p);
divNode.appendChild(div);
return divNode.outerHTML;
}
var field;
function addField(size, addId) {
field = $("#addFieldTable_" + addId).children().length;
var data = "field_" + field + ":";
field = field + 1;
var newTrNode = document.createElement("tr");
var newTdNode1 = document.createElement("td");
var newTdNode2 = document.createElement("td");
newTdNode1.setAttribute("class", data);
var textNode = document.createTextNode(data);
var inputNode = document.createElement("input");
inputNode.setAttribute("type", "text");
inputNode.setAttribute("size", size);
newTdNode1.appendChild(textNode);
newTdNode2.appendChild(inputNode);
newTrNode.appendChild(newTdNode1);
newTrNode.appendChild(newTdNode2);
document.getElementById("addFieldTable_" + addId).appendChild(newTrNode);
}
function removeField(selectedNode) {
var table = selectedNode.nextSibling.nextSibling;
var deletedNode = table.lastChild;
table.removeChild(deletedNode);
}
function createTable(methodParamModel, cols, behaviorIndex) {
var name = methodParamModel.name;
var label = methodParamModel.lable;
var valueSeperator = methodParamModel.valueSeperator;
var table_content = cols.split(valueSeperator);
var tr = document.createElement("tr");
for (var i = 0; i < table_content.length; i++) {
var th = document.createElement("th");
var text = document.createTextNode(table_content[i]);
th.appendChild(text);
tr.appendChild(th);
}
var tr_content = document.createElement("tr");
for (var j = 0; j < table_content.length; j++) {
var td_content = document.createElement("td");
var text_content = document.createElement("input");
text_content.setAttribute("type", "text");
td_content.appendChild(text_content);
tr_content.appendChild(td_content);
}
var divNode = document.createElement("div");
var p = document.createElement("p");
var labelNode = document.createTextNode(label);
var div = document.createElement("div");
var nameNode = document.createTextNode(name);
var br1 = document.createElement("br");
var br2 = document.createElement("br");
var addColButton = document.createElement("button");
var addColNode = document.createTextNode($.i18n.prop("plugin_jsp_addCol"));
var removeColButton = document.createElement("button");
var removeColNode = document.createTextNode($.i18n
.prop("plugin_jsp_removeCol"));
var table = document.createElement("table");
var thead = document.createElement("thead");
var tbody = document.createElement("tbody");
$(divNode).attr("class", "Table sample_frame");
$(divNode).attr("id", behaviorIndex + "_" + name);
$(div).attr("class", "sample_sub_frame");
$(addColButton).attr("type", "submit");
$(addColButton).attr("class", "btn-large");
$(addColButton).attr("onClick", "addCol(this)");
$(removeColButton).attr("type", "submit");
$(removeColButton).attr("class", "btn-large");
$(removeColButton).attr("onClick", "removeCol(this)");
$(table).attr("class", behaviorIndex + "_operateTableCols");
$(table).attr("class", "table-margin");
p.appendChild(labelNode);
addColButton.appendChild(addColNode);
removeColButton.appendChild(removeColNode);
thead.appendChild(tr);
tbody.appendChild(tr_content);
table.appendChild(thead);
table.appendChild(tbody);
div.appendChild(nameNode);
div.appendChild(br1);
div.appendChild(addColButton);
div.appendChild(removeColButton);
div.appendChild(br2);
div.appendChild(table);
divNode.appendChild(p);
divNode.appendChild(div);
return divNode.outerHTML;
}
function addCol(selectedNode) {
var tbody = selectedNode.nextSibling.nextSibling.nextSibling.lastChild;
var length = tbody.previousSibling.firstChild.childNodes.length;
var tr = document.createElement("tr");
for (var i = 0; i < length; i++) {
var td = document.createElement("td");
var input = document.createElement("input");
input.setAttribute("type", "text");
td.appendChild(input);
tr.appendChild(td);
}
tbody.appendChild(tr);
}
function removeCol(selectedNode) {
var tbody = selectedNode.nextSibling.nextSibling.lastChild;
var removeNode = tbody.lastChild;
tbody.removeChild(removeNode);
}
function createCheckBox(methodParamModel, rows, behaviorIndex) {
var name = methodParamModel.name;
var label = methodParamModel.lable;
var valueSeperator = methodParamModel.valueSeperator;
var cb_content = rows.split(valueSeperator);
var result = document.createElement("div");
var divNode = document.createElement("div");
var p = document.createElement("p");
var div = document.createElement("div");
var br = document.createElement("br");
var divInput = document.createElement("div");
var labelNode = document.createTextNode(label);
var nameNode = document.createTextNode(name);
$(divNode).attr("class", "CheckBox sample_frame");
$(divNode).attr("id", "checkbox_" + name + "_" + behaviorIndex);
$(div).attr("class", "sample_sub_frame");
$(divInput).attr("class", "sample_sub_frame");
p.appendChild(labelNode);
for (var i = 0; i < cb_content.length; i++) {
var checkBoxNode = document.createElement("input");
var brInput = document.createElement("br");
checkBoxNode.setAttribute("type", "checkbox");
checkBoxNode.setAttribute("name", "checkbox_" + name + "_"
+ behaviorIndex);
checkBoxNode.setAttribute("value", cb_content[i]);
var checkBoxValue = document.createTextNode(cb_content[i]);
divInput.appendChild(checkBoxNode);
divInput.appendChild(checkBoxValue);
divInput.appendChild(brInput);
}
div.appendChild(nameNode);
div.appendChild(br);
div.appendChild(divInput);
divNode.appendChild(p);
divNode.appendChild(div);
result.appendChild(divNode);
return $(result).html();
}

View File

@ -1,23 +1,122 @@
var rsm;
var pluginNameList = new Array();
var behaviors=new Array();
var parameters=new Array();
var parameters = new HashMap();
var pluginName;
function loadUsePluigns(data) {
for (var i = 0; i < data.usePlugins.length; i++) {
var usePlugin = data.usePlugins[i];
pluginNameList.push(usePlugin.name);
pluginNameList.push(usePlugin.id);
}
var selectNode = document.getElementsByName("usePlugins")[0];
for (var j = 0; j < pluginNameList.length; j++) {
var textNode = document.createTextNode(pluginNameList[j]);
var optionNode = document.createElement("option");
optionNode.setAttribute("selected", "loadBehaviors("+pluginNameList[j]+")");
optionNode.setAttribute("value", pluginNameList[j]);
optionNode.appendChild(textNode);
var selectNode = document.getElementsByName("usePlugins")[0];
selectNode.appendChild(optionNode);
}
}
function loadBehaviors(pluginName){
alert("pluginName="+pluginName);
function choosePlugin() {
var plugin = document.getElementById("usePlugins");
if (plugin.options[plugin.selectedIndex].value != 0) {
pluginName = plugin.options[plugin.selectedIndex].value;
}
loadBehaviors();
}
function chooseBehavior() {
var behaviorMethod = 0;
var behaviors = document.getElementById("behaviors");
if (behaviors.options[behaviors.selectedIndex].value != 0) {
behaviorMethod = behaviors.options[behaviors.selectedIndex].value;
}
var plugin_id = behaviorMethod.split("_")[0];
var behavior_id = behaviorMethod.split("_")[1];
alert("plugin_id=" + plugin_id + ",behavior_id=" + behavior_id);
loadForm(plugin_id, behavior_id);
}
function loadBehaviors() {
$('#behaviors').html("");
var selectNode = document.getElementsByName("behaviors")[0];
var text = document.createTextNode("Please choose one behavior");
var option = document.createElement("option");
option.appendChild(text);
selectNode.appendChild(option);
$.each(modelData.pages, function(i, item) {
$.each(item.batches, function(i, item) {
var id = item.Id;
$.each(item.behaviors, function(i, item) {
if (item.use == pluginName) {
var textNode = document.createTextNode("plugin_id:" + id
+ "----behavior_id:" + item.id);
var optionNode = document.createElement("option");
optionNode.setAttribute("value", id + "_" + item.id);
optionNode.appendChild(textNode);
selectNode.appendChild(optionNode);
}
});
});
});
}
function loadForm(plugin_id, behavior_id) {
alert("loadForm..");
var plugin = "", method = "";
$.each(modelData.pages, function(i, item) {
$.each(item.batches, function(i, item) {
if (item.Id == plugin_id) {
$.each(item.behaviors, function(i, item) {
if (item.id == behavior_id) {
plugin = item.use;
method = item.name;
$.each(item.parameters, function(i, item) {
parameters.put(item.key, item.value);
});
}
});
}
});
});
/*
* for (var i = 0; i < parameters.length(); i++) { alert("key is " +
* parameters.getKeys()[i] + ",value is " + parameters.getValues()[i]); }
*/
loadTypeByPluginAndMethod(plugin, method,plugin_id,behavior_id);
}
function loadTypeByPluginAndMethod(plugin, method,plugin_id,behavior_id) {
alert("loadTypeByPluginAndMethod...");
var behaviorData=plugin+"_"+plugin_id+"."+method+"_"+behavior_id;
var behaviorIndex=plugin_id+"_"+behavior_id;
$.post("loadMethodParameters", {
pluginName : plugin,
methodName : method
}, function(data) {
if (!data.success) {
alert(data.failedMessage);
return;
}
data = data.data;
alert("data.length="+data.length);
var documentHtml = "";
var boxHeader = "";
var fieldHTML=createBehaviorsForm(data,behaviorData, behaviorIndex);
boxHeader = "<div class='box-header well' data-original-title> "
+ "<i class='icon-pencil left'></i>" + "<h2>sample:<i>"
+ behaviorData + "</i></h2></div>";
documentHtml = "<div id='"
+ behaviorIndex
+ "' class=''><p class='hide'>"
+ behaviorData
+ "</p><div class='span10 box' style='margin-left:15px;'>"
+ boxHeader
+ "<div class='box-content'>"
+ fieldHTML
+ "</div></div></div>";
document.getElementById("showPluginMethodForm").innerHTML += documentHtml;
});
}

View File

@ -2,6 +2,7 @@ $(function() {
var scriptId = getvars()['scriptId'];
editor.load(scriptId);
});
var modelData;
function getvars() {
var vars = [], hash;
@ -37,6 +38,7 @@ editor.load = function(scriptId) {
} else {
data = eval('(' + data.data + ')');
}
modelData=data;
editor.originalData = data;
var codeContainer = document.getElementById("codeEditor");
var options = {
@ -49,8 +51,8 @@ editor.load = function(scriptId) {
codeEditor = new jsoneditor.JSONEditor(codeContainer, options);
codeEditor.set(data);
loadUsePluigns(data);
loadBehaviors(data);
/*loadBehaviors(data);*/
//alert(data.pages.length);
}, "json");
var $submit = $("#submit");

View File

@ -226,7 +226,8 @@ function showPluginMethod(plugin, method) {
pluginMethodList[mark] = behaviorData;
} else if (place == "after") {
mark = parseInt(clickPluginMethodNode + 1);
if (clickPluginMethodNode == (length - 1) && clickPluginMethodNode != -1) {
if (clickPluginMethodNode == (length - 1)
&& clickPluginMethodNode != -1) {
pluginMethodList.push(behaviorData);
} else {
for (var j = length - 1; j >= clickPluginMethodNode + 1; j--) {
@ -283,7 +284,8 @@ function removeInsertPluginByClicked() {
createPluginMethodLines();
for (var j = 0; j < length; j++) {
if ($(removeDocumentNode[j]).attr("id") == clickPluginMethodNode) {
document.getElementById("showPluginMethod").removeChild(removeDocumentNode[j]);
document.getElementById("showPluginMethod").removeChild(
removeDocumentNode[j]);
}
}
}
@ -296,83 +298,26 @@ function clearPluginMethodList(){
}
function loadMethodParams(behaviorData, behaviorIndex) {
var methodParams = new Array();
var temp = behaviorData.split('.');
var plugin = temp[0].split('_')[0];
var method = temp[1];
var fieldHTML = "";
var documentHtml = "";
var boxHeader = "";
$
.post(
"loadMethodParameters",
{
$.post("loadMethodParameters", {
pluginName : plugin,
methodName : method
},
function(data) {
}, function(data) {
if (!data.success) {
alert(data.failedMessage);
return;
}
data = data.data;
for (var i = 0; i < data.length; i++) {
methodParams.push(data[i]);
}
for (var j = 0; j < methodParams.length; j++) {
var methodParamModel = new MethodParamModel(
methodParams[j].name,
methodParams[j].lable,
methodParams[j].valueSeperator,
methodParams[j].fieldSeperator,
methodParams[j].paramType,
methodParams[j].methodParamProperties);
var methodParamProperties = new Array();
for (var q = 0; q < methodParamModel.methodParamProperties.length; q++) {
var methodParamPropertyModel = new MethodParamPropertyModel(
methodParamModel.methodParamProperties[q].key,
methodParamModel.methodParamProperties[q].value);
methodParamProperties
.push(methodParamPropertyModel);
}
var type = methodParamModel.paramType;
var size = 0, cols = "", rows = "";
for (var p = 0; p < methodParamProperties.length; p++) {
var methodParamProertyModel = methodParamProperties[p];
if (methodParamProertyModel.key == "size") {
size = methodParamProertyModel.value;
} else if (methodParamProertyModel.key == "cols") {
cols = methodParamProertyModel.value;
} else if (methodParamProertyModel.key == "rows") {
rows = methodParamProertyModel.value;
}
}
if (type == "Field") {
fieldHTML += createField(
methodParamModel.lable,
methodParamModel.name, size,
behaviorIndex);
} else if (type == "MultiField") {
fieldHTML += createMultiField(
methodParamModel.lable,
methodParamModel.name, size,
behaviorIndex);
} else if (type == "Table") {
fieldHTML += createTable(methodParamModel,
cols, behaviorIndex);
} else if (type == "CheckBox") {
fieldHTML += createCheckBox(methodParamModel,
rows, behaviorIndex);
}
}
var documentHtml = "";
var boxHeader = "";
boxHeader = "<div class='box-header well' data-original-title> "
+ "<i class='icon-pencil left'></i>"
+ "<h2>sample:<i>"
+ behaviorData
+ "</i></h2></div>";
+ "<i class='icon-pencil left'></i>" + "<h2>sample:<i>"
+ behaviorData + "</i></h2></div>";
var fieldHTML=createBehaviorsForm(data, behaviorData, behaviorIndex);
documentHtml = "<div id='"
+ behaviorIndex
+ "' class='hide'><p class='hide'>"
@ -385,236 +330,11 @@ function loadMethodParams(behaviorData, behaviorIndex) {
+ $.i18n.prop("plugin_jsp_save")
+ "</button>"
+ "&nbsp;&nbsp;<button class='btn btn-primary btn-width' type='submit' onClick='cancelBehavior(this);'>"
+ $.i18n.prop("plugin_jsp_cancel")
+ "</button></div></div></div>";
+ $.i18n.prop("plugin_jsp_cancel") + "</button></div></div></div>";
document.getElementById("showPluginMethod").innerHTML += documentHtml;
});
}
function createField(label, name, size, behaviorIndex) {
if (size == 0) {
size = 20;
}
var divNode = document.createElement("div");
var p = document.createElement("p");
var labelNode = document.createTextNode(label);
var div = document.createElement("div");
var nameNode = document.createTextNode(name);
var input = document.createElement("input");
$(divNode).attr("class", "Field sample_frame");
$(divNode).attr("id", behaviorIndex + "_" + name);
$(div).attr("class", "sample_sub_frame");
$(input).attr("type", "text");
$(input).attr("size", size);
$(input).attr("id", name + "_input");
p.appendChild(labelNode);
div.appendChild(nameNode);
div.appendChild(input);
divNode.appendChild(p);
divNode.appendChild(div);
return divNode.outerHTML;
}
function createMultiField(label, name, size, behaviorIndex) {
if (size == 0) {
size = 20;
}
var divNode = document.createElement("div");
var p = document.createElement("p");
var labelNode = document.createTextNode(name + ":" + label);
var div = document.createElement("div");
var addFieldButton = document.createElement("button");
var addFieldNode = document.createTextNode($.i18n
.prop("plugin_jsp_addField"));
var removeFieldButton = document.createElement("button");
var removeFieldNode = document.createTextNode($.i18n
.prop("plugin_jsp_removeField"));
var br = document.createElement("br");
var table = document.createElement("table");
$(divNode).attr("class", "MultiField sample_frame");
$(divNode).attr("id", behaviorIndex + "_" + name);
$(div).attr("class", "sample_sub_frame");
$(addFieldButton).attr("type", "submit");
$(addFieldButton).attr("class", "btn-large");
$(addFieldButton).attr("onClick",
"addField(" + size + "," + behaviorIndex + ");");
$(removeFieldButton).attr("type", "submit");
$(removeFieldButton).attr("class", "btn-large");
$(removeFieldButton).attr("onClick", "removeField(this)");
$(table).attr("id", "addFieldTable_" + behaviorIndex);
$(table).attr("class", "table-margin");
p.appendChild(labelNode);
addFieldButton.appendChild(addFieldNode);
removeFieldButton.appendChild(removeFieldNode);
div.appendChild(addFieldButton);
div.appendChild(removeFieldButton);
div.appendChild(br);
div.appendChild(table);
divNode.appendChild(p);
divNode.appendChild(div);
return divNode.outerHTML;
}
var field;
function addField(size, addId) {
field = $("#addFieldTable_" + addId).children().length;
var data = "field_" + field + ":";
field = field + 1;
var newTrNode = document.createElement("tr");
var newTdNode1 = document.createElement("td");
var newTdNode2 = document.createElement("td");
newTdNode1.setAttribute("class", data);
var textNode = document.createTextNode(data);
var inputNode = document.createElement("input");
inputNode.setAttribute("type", "text");
inputNode.setAttribute("size", size);
newTdNode1.appendChild(textNode);
newTdNode2.appendChild(inputNode);
newTrNode.appendChild(newTdNode1);
newTrNode.appendChild(newTdNode2);
document.getElementById("addFieldTable_" + addId).appendChild(newTrNode);
}
function removeField(selectedNode) {
var table = selectedNode.nextSibling.nextSibling;
var deletedNode = table.lastChild;
table.removeChild(deletedNode);
}
function createTable(methodParamModel, cols, behaviorIndex) {
var name = methodParamModel.name;
var label = methodParamModel.lable;
var valueSeperator = methodParamModel.valueSeperator;
var table_content = cols.split(valueSeperator);
var tr = document.createElement("tr");
for (var i = 0; i < table_content.length; i++) {
var th = document.createElement("th");
var text = document.createTextNode(table_content[i]);
th.appendChild(text);
tr.appendChild(th);
}
var tr_content = document.createElement("tr");
for (var j = 0; j < table_content.length; j++) {
var td_content = document.createElement("td");
var text_content = document.createElement("input");
text_content.setAttribute("type", "text");
td_content.appendChild(text_content);
tr_content.appendChild(td_content);
}
var divNode = document.createElement("div");
var p = document.createElement("p");
var labelNode = document.createTextNode(label);
var div = document.createElement("div");
var nameNode = document.createTextNode(name);
var br1 = document.createElement("br");
var br2 = document.createElement("br");
var addColButton = document.createElement("button");
var addColNode = document.createTextNode($.i18n.prop("plugin_jsp_addCol"));
var removeColButton = document.createElement("button");
var removeColNode = document.createTextNode($.i18n
.prop("plugin_jsp_removeCol"));
var table = document.createElement("table");
var thead = document.createElement("thead");
var tbody = document.createElement("tbody");
$(divNode).attr("class", "Table sample_frame");
$(divNode).attr("id", behaviorIndex + "_" + name);
$(div).attr("class", "sample_sub_frame");
$(addColButton).attr("type", "submit");
$(addColButton).attr("class", "btn-large");
$(addColButton).attr("onClick", "addCol(this)");
$(removeColButton).attr("type", "submit");
$(removeColButton).attr("class", "btn-large");
$(removeColButton).attr("onClick", "removeCol(this)");
$(table).attr("class", behaviorIndex + "_operateTableCols");
$(table).attr("class", "table-margin");
p.appendChild(labelNode);
addColButton.appendChild(addColNode);
removeColButton.appendChild(removeColNode);
thead.appendChild(tr);
tbody.appendChild(tr_content);
table.appendChild(thead);
table.appendChild(tbody);
div.appendChild(nameNode);
div.appendChild(br1);
div.appendChild(addColButton);
div.appendChild(removeColButton);
div.appendChild(br2);
div.appendChild(table);
divNode.appendChild(p);
divNode.appendChild(div);
return divNode.outerHTML;
}
function addCol(selectedNode) {
var tbody = selectedNode.nextSibling.nextSibling.nextSibling.lastChild;
var length = tbody.previousSibling.firstChild.childNodes.length;
var tr = document.createElement("tr");
for (var i = 0; i < length; i++) {
var td = document.createElement("td");
var input = document.createElement("input");
input.setAttribute("type", "text");
td.appendChild(input);
tr.appendChild(td);
}
tbody.appendChild(tr);
}
function removeCol(selectedNode) {
var tbody = selectedNode.nextSibling.nextSibling.lastChild;
var removeNode = tbody.lastChild;
tbody.removeChild(removeNode);
}
function createCheckBox(methodParamModel, rows, behaviorIndex) {
var name = methodParamModel.name;
var label = methodParamModel.lable;
var valueSeperator = methodParamModel.valueSeperator;
var cb_content = rows.split(valueSeperator);
var result = document.createElement("div");
var divNode = document.createElement("div");
var p = document.createElement("p");
var div = document.createElement("div");
var br = document.createElement("br");
var divInput = document.createElement("div");
var labelNode = document.createTextNode(label);
var nameNode = document.createTextNode(name);
$(divNode).attr("class", "CheckBox sample_frame");
$(divNode).attr("id", "checkbox_" + name + "_" + behaviorIndex);
$(div).attr("class", "sample_sub_frame");
$(divInput).attr("class", "sample_sub_frame");
p.appendChild(labelNode);
for (var i = 0; i < cb_content.length; i++) {
var checkBoxNode = document.createElement("input");
var brInput = document.createElement("br");
checkBoxNode.setAttribute("type", "checkbox");
checkBoxNode.setAttribute("name", "checkbox_" + name + "_"
+ behaviorIndex);
checkBoxNode.setAttribute("value", cb_content[i]);
var checkBoxValue = document.createTextNode(cb_content[i]);
divInput.appendChild(checkBoxNode);
divInput.appendChild(checkBoxValue);
divInput.appendChild(brInput);
}
div.appendChild(nameNode);
div.appendChild(br);
div.appendChild(divInput);
divNode.appendChild(p);
divNode.appendChild(div);
result.appendChild(divNode);
return $(result).html();
}
function saveBehavior(selectedNode) {
var uploadNode = selectedNode.parentNode.previousSibling;
var div = uploadNode.childNodes;

View File

@ -48,61 +48,3 @@ function UsePluginModel(id, name, parameters) {
this.parameters = parameters;
}
function HashMap() {
this.arrKey = new Array();
this.arrValue = new Array();
this.exists = function(strKey) {
strKey = strKey.toUpperCase();
for (var i = 0; i < this.arrKey.length; i++) {
if (this.arrKey[i] == strKey) {
return true;
}
}
return false;
};
this.length = function() {
return this.arrKey.length;
};
this.put = function(strKey, objValue) {
strKey = strKey.toUpperCase();
for (var i = 0; i < this.arrKey.length; i++) {
if (this.arrKey[i] == strKey) {
this.arrValue[i] = objValue;
return;
}
}
this.arrKey[this.arrKey.length] = strKey;
this.arrValue[this.arrValue.length] = objValue;
};
this.get = function(strKey) {
strKey = strKey.toUpperCase();
for (var i = 0; i < this.arrKey.length; i++) {
if (this.arrKey[i] == strKey) {
return this.arrValue[i];
}
}
return null;
};
this.remove = function(strKey) {
strKey = strKey.toUpperCase();
for (var i = 0; i < this.arrKey.length; i++) {
if (this.arrKey[i] == strKey) {
this.arrKey.splice(i, 1);
this.arrValue.splice(i, 1);
return;
}
}
};
this.getKeys = function() {
return this.arrKey;
};
this.getValues = function() {
return this.arrValue;
};
}