use of com.ngtesting.platform.entity.TestCasePriority in project ngtesting-platform by aaronchen2k.
the class CasePriorityServiceImpl method save.
@Override
public TestCasePriority save(CasePriorityVo vo, Long orgId) {
if (vo == null) {
return null;
}
TestCasePriority po;
if (vo.getId() != null) {
po = (TestCasePriority) get(TestCasePriority.class, vo.getId());
} else {
po = new TestCasePriority();
}
BeanUtilEx.copyProperties(po, vo);
po.setOrgId(orgId);
if (vo.getId() == null) {
po.setCode(UUID.randomUUID().toString());
String hql = "select max(displayOrder) from TestCasePriority pri where pri.orgId=?";
Integer maxOrder = (Integer) getByHQL(hql, orgId);
po.setDisplayOrder(maxOrder + 10);
}
saveOrUpdate(po);
return po;
}
use of com.ngtesting.platform.entity.TestCasePriority in project ngtesting-platform by aaronchen2k.
the class CasePriorityServiceImpl method setDefaultPers.
@Override
public boolean setDefaultPers(Long id, Long orgId) {
List<TestCasePriority> ls = list(orgId);
for (TestCasePriority priority : ls) {
if (priority.getId().longValue() == id.longValue()) {
priority.setIsDefault(true);
saveOrUpdate(priority);
} else if (priority.getIsDefault() != null && priority.getIsDefault()) {
priority.setIsDefault(false);
saveOrUpdate(priority);
}
}
return true;
}
use of com.ngtesting.platform.entity.TestCasePriority in project ngtesting-platform by aaronchen2k.
the class CasePriorityServiceImpl method changeOrderPers.
@Override
public boolean changeOrderPers(Long id, String act, Long orgId) {
TestCasePriority type = (TestCasePriority) get(TestCasePriority.class, id);
String hql = "from TestCasePriority tp where where tp.orgId=? and tp.deleted = false and tp.disabled = false ";
if ("up".equals(act)) {
hql += "and tp.displayOrder < ? order by displayOrder desc";
} else if ("down".equals(act)) {
hql += "and tp.displayOrder > ? order by displayOrder asc";
} else {
return false;
}
TestCasePriority neighbor = (TestCasePriority) getDao().findFirstByHQL(hql, orgId, type.getDisplayOrder());
Integer order = type.getDisplayOrder();
type.setDisplayOrder(neighbor.getDisplayOrder());
neighbor.setDisplayOrder(order);
saveOrUpdate(type);
saveOrUpdate(neighbor);
return true;
}
Aggregations