use of com.ngtesting.platform.entity.TestProject in project ngtesting-platform by aaronchen2k.
the class ProjectServiceImpl method list.
@Override
public List<TestProject> list(Long orgId, String keywords, String disabled) {
DetachedCriteria dc = DetachedCriteria.forClass(TestProject.class);
dc.add(Restrictions.eq("orgId", orgId));
if (StringUtil.isNotEmpty(disabled)) {
dc.add(Restrictions.eq("disabled", Boolean.valueOf(disabled)));
}
dc.add(Restrictions.eq("type", ProjectType.group));
dc.add(Restrictions.eq("deleted", Boolean.FALSE));
dc.addOrder(Order.asc("id"));
dc.setFetchMode("children", FetchMode.JOIN);
dc.setResultTransformer(CriteriaSpecification.DISTINCT_ROOT_ENTITY);
Filter filter = getDao().getSession().enableFilter("filter_project_deleted");
filter.setParameter("isDeleted", Boolean.valueOf(false));
List<TestProject> pos = findAllByCriteria(dc);
getDao().getSession().disableFilter("filter_project_deleted");
return pos;
}
use of com.ngtesting.platform.entity.TestProject in project ngtesting-platform by aaronchen2k.
the class ProjectServiceImpl method save.
@Override
public TestProject save(TestProjectVo vo, Long orgId, UserVo userVo) {
if (vo == null) {
return null;
}
boolean isNew = vo.getId() == null;
TestProject po = new TestProject();
if (isNew) {
po.setOrgId(orgId);
} else {
po = (TestProject) get(TestProject.class, vo.getId());
}
boolean disableChanged = vo.getDisabled() != po.getDisabled();
po.setParentId(vo.getParentId());
po.setName(vo.getName());
po.setDescr(vo.getDescr());
po.setType(ProjectType.valueOf(vo.getType()));
po.setDisabled(vo.getDisabled());
saveOrUpdate(po);
if (isNew && ProjectType.project.equals(po.getType())) {
projectPrivilegeService.addUserAsProjectRolePers(orgId, po.getId(), "test_leader", userVo.getId());
caseService.createRoot(po.getId(), userVo);
}
if (ProjectType.project.equals(po.getType())) {
historyService.create(po.getId(), userVo, isNew ? Constant.MsgType.create.msg : Constant.MsgType.create.update.msg, TestHistory.TargetType.project, po.getId(), po.getName());
}
if (!disableChanged) {
return po;
}
// 项目被启用
if (!po.getDisabled()) {
if (po.getType().equals(ProjectType.project)) {
// 启用父
TestProject parent = po.getParent();
if (parent.getDisabled()) {
parent.setDisabled(false);
saveOrUpdate(parent);
}
} else {
// 启用子
for (TestProject child : po.getChildren()) {
if (child.getDisabled()) {
child.setDisabled(false);
saveOrUpdate(child);
}
}
}
}
// 项目组被归档,归档子项目
if (po.getDisabled() && po.getType().equals(ProjectType.group)) {
for (TestProject child : po.getChildren()) {
if (!child.getDisabled()) {
child.setDisabled(true);
saveOrUpdate(child);
}
}
}
return po;
}
use of com.ngtesting.platform.entity.TestProject in project ngtesting-platform by aaronchen2k.
the class ProjectServiceImpl method listProjectGroups.
@Override
public List<TestProjectVo> listProjectGroups(Long orgId) {
DetachedCriteria dc = DetachedCriteria.forClass(TestProject.class);
dc.add(Restrictions.eq("orgId", orgId));
dc.add(Restrictions.eq("type", ProjectType.group));
dc.add(Restrictions.eq("disabled", false));
dc.add(Restrictions.eq("deleted", Boolean.FALSE));
dc.addOrder(Order.asc("id"));
List<TestProject> pos = findAllByCriteria(dc);
List<TestProjectVo> vos = this.genGroupVos(pos);
return vos;
}
use of com.ngtesting.platform.entity.TestProject in project ngtesting-platform by aaronchen2k.
the class ProjectServiceImpl method genVos.
@Override
public List<TestProjectVo> genVos(List<TestProject> pos, String keywords, String disabled) {
List<TestProjectVo> voList = new LinkedList<TestProjectVo>();
for (TestProject po : pos) {
TestProjectVo vo = genVo(po);
voList.add(vo);
List<TestProjectVo> voList2 = new LinkedList<TestProjectVo>();
List<TestProject> children = po.getChildren();
for (TestProject child : children) {
if ((StringUtil.IsEmpty(keywords) || child.getName().toLowerCase().indexOf(keywords.toLowerCase()) > -1) && (StringUtil.IsEmpty(disabled) || child.getDisabled() == Boolean.valueOf(disabled))) {
TestProjectVo childVo = genVo(child);
voList2.add(childVo);
}
}
vo.setChildrenNumb(voList2.size());
voList.addAll(voList2);
}
return voList;
}
use of com.ngtesting.platform.entity.TestProject in project ngtesting-platform by aaronchen2k.
the class ProjectServiceImpl method viewPers.
@Override
public TestProjectVo viewPers(Long projectId, UserVo userVo) {
TestProject project = getDetail(projectId);
getHistoryPers(project.getOrgId(), userVo.getId(), projectId, project.getName());
TestUser userPo = (TestUser) get(TestUser.class, userVo.getId());
userPo.setDefaultPrjId(projectId);
saveOrUpdate(userPo);
userVo.setDefaultPrjId(projectId);
userVo.setDefaultPrjName(project.getName());
TestProjectVo vo = genVo(project);
return vo;
}
Aggregations