This commit is contained in:
coderfengyun 2014-02-24 16:32:40 +08:00
parent e6c3020f78
commit 3e0ad3f1a5
15 changed files with 134 additions and 134 deletions

View File

@ -9,7 +9,7 @@ import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import org.apache.log4j.Logger;
import org.bench4q.master.domain.entity.TestPlanDB;
import org.bench4q.master.domain.entity.TestPlan;
import org.bench4q.master.domain.factory.BusinessModelMapFactory;
import org.bench4q.master.domain.service.TestPlanEngine;
import org.bench4q.master.domain.service.TestPlanScriptResultService;
@ -214,7 +214,7 @@ public class TestPlanController extends BaseController {
if (!this.checkScope(UserService.NORAML_AUTHENTICATION)) {
return buildTestPlanResponseModel(false, "no scope", null);
}
List<TestPlanDB> testPlanDBs = this.testPlanService.loadTestPlans(this
List<TestPlan> testPlanDBs = this.testPlanService.loadTestPlans(this
.getPrincipal());
return testPlanDBs == null ? buildTestPlanResponseModel(false,
"exception", null) : buildTestPlanResponseModel(true, null,
@ -246,12 +246,12 @@ public class TestPlanController extends BaseController {
}
private TestPlanResponseModel buildTestPlanResponseModel(boolean success,
String failCause, List<TestPlanDB> testPlanDBs) {
String failCause, List<TestPlan> testPlanDBs) {
TestPlanResponseModel result = new TestPlanResponseModel();
result.setSuccess(success);
result.setFailCause(failCause);
List<TestPlanDBModel> modelList = new ArrayList<TestPlanDBModel>();
for (TestPlanDB testPlanDB : testPlanDBs) {
for (TestPlan testPlanDB : testPlanDBs) {
modelList.add(this.getBusinessMapFactory().toModel(testPlanDB));
}
result.setTestPlanDBModels(modelList);

View File

@ -15,7 +15,7 @@ public class Monitor {
private int id;
private String hostName;
private int port;
private TestPlanDB testPlanDB;
private TestPlan testPlan;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@ -48,11 +48,11 @@ public class Monitor {
@ManyToOne
@JoinColumn(name = "testPlanId")
public TestPlanDB getTestPlanDB() {
return testPlanDB;
public TestPlan getTestPlan() {
return testPlan;
}
public void setTestPlanDB(TestPlanDB testPlanDB) {
this.testPlanDB = testPlanDB;
public void setTestPlan(TestPlan testPlan) {
this.testPlan = testPlan;
}
}

View File

@ -15,7 +15,7 @@ import javax.persistence.Table;
@Table(name = "MonitorResult")
public class MonitorResult {
private int id;
private TestPlanDB testPlanDB;
private TestPlan testPlanDB;
private String type;
private String content;
private String hostNameUnderMonitor;
@ -34,11 +34,11 @@ public class MonitorResult {
@ManyToOne
@JoinColumn(name = "testPlanRunId", nullable = false)
public TestPlanDB getTestPlanDB() {
public TestPlan getTestPlanDB() {
return testPlanDB;
}
public void setTestPlanDB(TestPlanDB testPlan) {
public void setTestPlanDB(TestPlan testPlan) {
this.testPlanDB = testPlan;
}

View File

@ -19,7 +19,7 @@ import org.bench4q.master.domain.IAggregate;
@Entity
@Table(name = "testplan")
public class TestPlanDB implements IAggregate {
public class TestPlan implements IAggregate {
private int id;
private String name;
private Date createDateTime;
@ -96,7 +96,7 @@ public class TestPlanDB implements IAggregate {
this.failTimes = failTimes;
}
@OneToMany(mappedBy = "testPlanDB", cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.EAGER)
@OneToMany(mappedBy = "testPlan", cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.EAGER)
public Set<TestPlanScript> getTestPlanScripts() {
return testPlanScripts;
}
@ -105,7 +105,7 @@ public class TestPlanDB implements IAggregate {
this.testPlanScripts = testPlanScripts;
}
@OneToMany(mappedBy = "testPlanDB", cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.EAGER)
@OneToMany(mappedBy = "testPlan", cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.EAGER)
public Set<Monitor> getMonitors() {
return monitors;
}

View File

@ -19,7 +19,7 @@ public class TestPlanScript {
private Script script;
private int requireLoad;
private PlanedConfig planedConfig;
private TestPlanDB testPlanDB;
private TestPlan testPlan;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@ -63,12 +63,12 @@ public class TestPlanScript {
@ManyToOne
@JoinColumn(name = "testPlanId")
public TestPlanDB getTestPlanDB() {
return testPlanDB;
public TestPlan getTestPlan() {
return testPlan;
}
public void setTestPlanDB(TestPlanDB testPlanDB) {
this.testPlanDB = testPlanDB;
public void setTestPlan(TestPlan testPlan) {
this.testPlan = testPlan;
}
}

View File

@ -9,7 +9,7 @@ import org.bench4q.master.domain.entity.Agent;
import org.bench4q.master.domain.entity.Monitor;
import org.bench4q.master.domain.entity.Port;
import org.bench4q.master.domain.entity.Script;
import org.bench4q.master.domain.entity.TestPlanDB;
import org.bench4q.master.domain.entity.TestPlan;
import org.bench4q.master.domain.entity.User;
import org.bench4q.master.domain.service.ScriptService;
import org.bench4q.share.models.master.AgentModel;
@ -179,7 +179,7 @@ public class BusinessModelMapFactory {
return ret;
}
public TestPlanDBModel toModel(TestPlanDB testPlanDB) {
public TestPlanDBModel toModel(TestPlan testPlanDB) {
TestPlanDBModel ret = new TestPlanDBModel();
ret.setCreateDateTime(testPlanDB.getCreateDateTime());
ret.setCurrentStatus(testPlanDB.getCurrentStatus());

View File

@ -7,7 +7,7 @@ import java.util.UUID;
import org.bench4q.master.domain.entity.Monitor;
import org.bench4q.master.domain.entity.PlanedConfig;
import org.bench4q.master.domain.entity.TestPlanDB;
import org.bench4q.master.domain.entity.TestPlan;
import org.bench4q.master.domain.entity.TestPlanScript;
import org.bench4q.master.domain.entity.User;
import org.bench4q.master.domain.service.ScriptService;
@ -32,9 +32,9 @@ public class TestPlanFactory {
this.scriptService = scriptService;
}
public TestPlanDB createATestPlanWithoutIdentity(
public TestPlan createATestPlanWithoutIdentity(
TestPlanBusinessModel testPlanBusinessModel, User user, UUID runId) {
TestPlanDB result = new TestPlanDB();
TestPlan result = new TestPlan();
result.setCreateDateTime(new Date());
result.setCurrentStatus(TestPlanStatus.NotStart.name());
result.setFailTimes(0);
@ -56,7 +56,7 @@ public class TestPlanFactory {
.getMonitorModels()) {
Monitor monitorInBusiness = BusinessModelMapFactory
.toBusiness(monitorModel);
monitorInBusiness.setTestPlanDB(result);
monitorInBusiness.setTestPlan(result);
monitors.add(monitorInBusiness);
}
result.setMonitors(monitors);
@ -64,12 +64,12 @@ public class TestPlanFactory {
}
public TestPlanScript createATestPlanScriptWithoutId(int requireLoad,
int scriptId, TestScriptConfig config, TestPlanDB testPlanDB) {
int scriptId, TestScriptConfig config, TestPlan testPlanDB) {
TestPlanScript testPlanScript = new TestPlanScript();
testPlanScript.setRequireLoad(requireLoad);
testPlanScript.setScript(this.getScriptService().getScript(scriptId));
testPlanScript.setPlanedConfig(createAPlanedConfigWithoutId(config));
testPlanScript.setTestPlanDB(testPlanDB);
testPlanScript.setTestPlan(testPlanDB);
return testPlanScript;
}

View File

@ -4,7 +4,7 @@ import java.util.List;
import java.util.UUID;
import org.apache.log4j.Logger;
import org.bench4q.master.domain.entity.TestPlanDB;
import org.bench4q.master.domain.entity.TestPlan;
import org.bench4q.master.domain.entity.User;
import org.bench4q.master.exception.ExceptionLog;
import org.bench4q.master.exception.ExceptionUtils.EntityUniqueAlReadyExistException;
@ -17,7 +17,7 @@ import org.springframework.stereotype.Component;
public class TestPlanRepository extends AbstractRepositoty {
private Logger logger = Logger.getLogger(TestPlanRepository.class);
public boolean attach(TestPlanDB testPlanDBWithoutId) {
public boolean attach(TestPlan testPlanDBWithoutId) {
Session session = this.getSessionHelper().openSession();
Transaction transaction = session.beginTransaction();
try {
@ -48,8 +48,8 @@ public class TestPlanRepository extends AbstractRepositoty {
Session session = this.getSessionHelper().openSession();
Transaction transaction = session.beginTransaction();
try {
TestPlanDB testPlanInDB = (TestPlanDB) session
.createCriteria(TestPlanDB.class)
TestPlan testPlanInDB = (TestPlan) session
.createCriteria(TestPlan.class)
.add(Restrictions.eq("id", id)).uniqueResult();
if (testPlanInDB == null) {
return false;
@ -68,22 +68,22 @@ public class TestPlanRepository extends AbstractRepositoty {
}
}
public TestPlanDB getTestPlanBy(UUID testPlanRunId) {
TestPlanDB result = null;
public TestPlan getTestPlanBy(UUID testPlanRunId) {
TestPlan result = null;
Session session = this.getSessionHelper().openSession();
result = (TestPlanDB) session
.createCriteria(TestPlanDB.class)
result = (TestPlan) session
.createCriteria(TestPlan.class)
.add(Restrictions.eq("testPlanRunId", testPlanRunId.toString()))
.uniqueResult();
releaseSession(session);
return result;
}
public List<TestPlanDB> loadEntities(User user) {
public List<TestPlan> loadEntities(User user) {
Session session = this.getSessionHelper().openSession();
try {
@SuppressWarnings("unchecked")
List<TestPlanDB> ret = session.createCriteria(TestPlanDB.class)
List<TestPlan> ret = session.createCriteria(TestPlan.class)
.add(Restrictions.eq("user", user)).list();
return ret;
} catch (Exception e) {
@ -94,7 +94,7 @@ public class TestPlanRepository extends AbstractRepositoty {
}
}
public boolean updateEntity(TestPlanDB testPlanDB) {
public boolean updateEntity(TestPlan testPlanDB) {
if (testPlanDB == null) {
return false;
}

View File

@ -6,7 +6,7 @@ import java.util.UUID;
import org.apache.log4j.Logger;
import org.bench4q.master.domain.entity.MonitorResult;
import org.bench4q.master.domain.entity.TestPlanDB;
import org.bench4q.master.domain.entity.TestPlan;
import org.bench4q.master.domain.repository.TestPlanRepository;
import org.bench4q.master.exception.ExceptionLog;
import org.bench4q.master.helper.SessionHelper;
@ -75,7 +75,7 @@ public class MonitorResultService {
public boolean saveMonitorResult(UUID testPlanRunId, String type,
String content, Date createDatetime, String hostNameUnderMonitor) {
TestPlanDB testPlanDB = this.getTestPlanRepository().getTestPlanBy(
TestPlan testPlanDB = this.getTestPlanRepository().getTestPlanBy(
testPlanRunId);
if (testPlanDB == null) {
logger.error("when save Monitor result find the testPlan is null with runId:"

View File

@ -12,7 +12,7 @@ import javax.xml.bind.JAXBException;
import org.apache.log4j.Logger;
import org.bench4q.master.domain.RunningScript;
import org.bench4q.master.domain.entity.Script;
import org.bench4q.master.domain.entity.TestPlanDB;
import org.bench4q.master.domain.entity.TestPlan;
import org.bench4q.master.domain.entity.TestPlanScript;
import org.bench4q.master.domain.entity.TestPlanScriptResult;
import org.bench4q.master.domain.repository.TestPlanRepository;
@ -65,7 +65,7 @@ public class TestPlanScriptService implements Observer {
}
public TestPlanScript getTestPlanScript(int scriptId, UUID testPlanRunId) {
TestPlanDB testPlan = this.getTestPlanRepository().getTestPlanBy(
TestPlan testPlan = this.getTestPlanRepository().getTestPlanBy(
testPlanRunId);
return testPlan == null ? null : testPlan.extracSpecifiedScript(this
.getScriptService().getScript(scriptId));
@ -104,8 +104,8 @@ public class TestPlanScriptService implements Observer {
Session session = this.getSessionHelper().openSession();
Transaction transaction = session.beginTransaction();
try {
TestPlanDB testPlanDB = (TestPlanDB) session
.createCriteria(TestPlanDB.class)
TestPlan testPlanDB = (TestPlan) session
.createCriteria(TestPlan.class)
.add(Restrictions.eq("testPlanRunId",
testPlanRunId.toString())).uniqueResult();
if (testPlanDB == null) {

View File

@ -5,7 +5,7 @@ import java.util.List;
import java.util.UUID;
import org.bench4q.master.domain.entity.Monitor;
import org.bench4q.master.domain.entity.TestPlanDB;
import org.bench4q.master.domain.entity.TestPlan;
import org.bench4q.master.domain.entity.TestPlanScript;
import org.bench4q.master.domain.entity.User;
import org.bench4q.master.domain.factory.BusinessModelMapFactory;
@ -62,7 +62,7 @@ public class TestPlanService {
testPlanBusinessModel, user, testPlanRunId));
}
public List<TestPlanDB> loadTestPlans(User user) {
public List<TestPlan> loadTestPlans(User user) {
return this.getTestPlanRepository().loadEntities(user);
}
@ -97,7 +97,7 @@ public class TestPlanService {
private void updateStatus(TestPlanStatus status, UUID testPlanRunID,
int failTimes) {
TestPlanDB testPlanDB = this.getTestPlanRepository().getTestPlanBy(
TestPlan testPlanDB = this.getTestPlanRepository().getTestPlanBy(
testPlanRunID);
testPlanDB.setCurrentStatus(status.name());
testPlanDB.setFailTimes(testPlanDB.getFailTimes() + failTimes);
@ -116,7 +116,7 @@ public class TestPlanService {
public TestPlanResultModel buildResultModel(UUID runId) {
TestPlanResultModel resultModel = new TestPlanResultModel();
TestPlanDB testPlan = this.getTestPlanRepository().getTestPlanBy(runId);
TestPlan testPlan = this.getTestPlanRepository().getTestPlanBy(runId);
resultModel.setCurrentStatus(TestPlanStatus.valueOf(testPlan
.getCurrentStatus()));
resultModel.setTestPlanId(runId);

View File

@ -23,7 +23,7 @@
<mapping class="org.bench4q.master.domain.entity.PlanedConfig" />
<mapping class="org.bench4q.master.domain.entity.Agent" />
<mapping class="org.bench4q.master.domain.entity.Port" />
<mapping class="org.bench4q.master.domain.entity.TestPlanDB" />
<mapping class="org.bench4q.master.domain.entity.TestPlan" />
<mapping class="org.bench4q.master.domain.entity.TestPlanScript" />
<mapping class="org.bench4q.master.domain.entity.TestPlanScriptResult" />
<mapping class="org.bench4q.master.domain.entity.Monitor" />

View File

@ -4,7 +4,7 @@ import static org.junit.Assert.*;
import java.util.UUID;
import org.bench4q.master.domain.entity.TestPlanDB;
import org.bench4q.master.domain.entity.TestPlan;
import org.bench4q.master.test.TestBase_MakeUpTestPlan;
import org.bench4q.share.enums.master.TestPlanStatus;
import org.junit.After;
@ -19,7 +19,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
public class Test_TestPlanRepository extends TestBase_MakeUpTestPlan {
@Test
public void testGetTestPlan() {
TestPlanDB testPlan = this.getTestPlanRepository().getTestPlanBy(
TestPlan testPlan = this.getTestPlanRepository().getTestPlanBy(
getTestPlanRunIdUuid());
assertNotNull(testPlan);
assertEquals(getTestPlanRunIdUuid(),
@ -36,14 +36,14 @@ public class Test_TestPlanRepository extends TestBase_MakeUpTestPlan {
@Test
public void testUpdateEntity() {
TestPlanDB testPlanDB = this.getTestPlanRepository().getTestPlanBy(
TestPlan testPlanDB = this.getTestPlanRepository().getTestPlanBy(
getTestPlanRunIdUuid());
assertNotNull(testPlanDB);
assertEquals(TestPlanStatus.NotStart.name(),
testPlanDB.getCurrentStatus());
testPlanDB.setCurrentStatus(TestPlanStatus.Complete.name());
this.getTestPlanRepository().updateEntity(testPlanDB);
TestPlanDB afterModify = this.getTestPlanRepository().getTestPlanBy(
TestPlan afterModify = this.getTestPlanRepository().getTestPlanBy(
getTestPlanRunIdUuid());
assertEquals(TestPlanStatus.Complete.name(),
afterModify.getCurrentStatus());

View File

@ -5,7 +5,7 @@ import static org.junit.Assert.*;
import java.util.Set;
import java.util.UUID;
import org.bench4q.master.domain.entity.TestPlanDB;
import org.bench4q.master.domain.entity.TestPlan;
import org.bench4q.master.domain.entity.TestPlanScript;
import org.bench4q.master.domain.entity.User;
import org.bench4q.master.test.TestBase_MakeUpTestPlan;
@ -100,7 +100,7 @@ public class Test_TestPlanService extends TestBase_MakeUpTestPlan {
int planCountAfterSubmit = this.getTestPlanRepository()
.loadEntities(user).size();
assertEquals(planCountBeforeSubmit + 1, planCountAfterSubmit);
TestPlanDB testPlan = this.getTestPlanRepository().getTestPlanBy(
TestPlan testPlan = this.getTestPlanRepository().getTestPlanBy(
randomUUID);
Set<TestPlanScript> testPlanScripts = testPlan.getTestPlanScripts();
assertNotNull(testPlanScripts);