add new api to show the current running Testplans
add new api to show the current running Testplans
This commit is contained in:
parent
3c12ea5ec5
commit
87d700e462
|
@ -1,32 +1,38 @@
|
|||
package org.bench4q.master.api;
|
||||
|
||||
import org.bench4q.master.domain.entity.User;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bench4q.master.domain.entity.TestPlan;
|
||||
import org.bench4q.master.domain.service.TestPlanService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
import antlr.collections.List;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/")
|
||||
public class HomeController extends BaseController {
|
||||
private TestPlanService testPlanService;
|
||||
|
||||
private TestPlanService getTestPlanService() {
|
||||
return testPlanService;
|
||||
}
|
||||
|
||||
@Autowired
|
||||
private void setTestPlanService(TestPlanService testPlanService) {
|
||||
this.testPlanService = testPlanService;
|
||||
}
|
||||
|
||||
@RequestMapping(value = { "/" }, method = RequestMethod.GET)
|
||||
@ResponseBody
|
||||
public String index() {
|
||||
User principal = this.getPrincipal();
|
||||
String userName;
|
||||
if (principal == null) {
|
||||
userName = "Anonymous User";
|
||||
} else {
|
||||
userName = principal.getUserName();
|
||||
}
|
||||
return "Hello [" + userName + "]";
|
||||
}
|
||||
|
||||
@RequestMapping(value = { "/tasks" }, method = RequestMethod.GET)
|
||||
@ResponseBody
|
||||
public void currentTasks() {
|
||||
|
||||
List<UUID> tasks = new LinkedList<UUID>();
|
||||
for (TestPlan testPlan : this.getTestPlanService()
|
||||
.loadAllRunningTestPlans()) {
|
||||
tasks.add(UUID.fromString(testPlan.getTestPlanRunId()));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
package org.bench4q.master.domain.repository;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
@ -225,4 +226,8 @@ public class TestPlanRepository extends AbstractRepositoty {
|
|||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public Collection<TestPlan> loadRunningTestPlans() {
|
||||
return this.runningTestPlans.values();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package org.bench4q.master.domain.service;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
@ -86,4 +87,8 @@ public class TestPlanService {
|
|||
"runningInfo : " + MarshalHelper.tryMarshal(resultModel));
|
||||
return resultModel;
|
||||
}
|
||||
|
||||
public Collection<TestPlan> loadAllRunningTestPlans() {
|
||||
return this.getTestPlanRepository().loadRunningTestPlans();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue