use of org.asqatasun.entity.contract.Act in project Asqatasun by Asqatasun.
the class ParameterDAOImpl method findLastActByContractAndScenario.
private Act findLastActByContractAndScenario(Long idContract, String scenarioName) {
StringBuilder queryString = new StringBuilder();
queryString.append("SELECT a FROM ");
queryString.append(Act.class.getName());
queryString.append(" a");
queryString.append(" left join a.audit.subject w");
queryString.append(" WHERE a.contract.id = :idContract");
queryString.append(" AND (a.status = :completedStatus OR a.status = :errorStatus)");
queryString.append(" AND a.scope.code =:scope ");
queryString.append(" AND w.url=:scenarioName");
queryString.append(" ORDER BY a.id DESC");
Query query = entityManager.createQuery(queryString.toString());
query.setParameter("idContract", idContract);
query.setParameter("completedStatus", ActStatus.COMPLETED);
query.setParameter("errorStatus", ActStatus.ERROR);
query.setParameter("scope", ScopeEnum.SCENARIO);
query.setParameter("scenarioName", scenarioName);
query.setMaxResults(1);
query.setHint(CACHEABLE_OPTION, "true");
try {
return (Act) query.getSingleResult();
} catch (NoResultException nre) {
return null;
}
}
use of org.asqatasun.entity.contract.Act in project Asqatasun by Asqatasun.
the class ManualAuditController method displayManualAuditResultFromContract.
/**
* General router when receive audit-result request. Regarding the scope of
* the audit, the returned page may differ.
*
* @param auditId
* @param request
* @param model
* @return
*/
@RequestMapping(value = TgolKeyStore.MANUAL_AUDIT_RESULT_CONTRACT_URL, method = RequestMethod.GET)
@Secured({ TgolKeyStore.ROLE_USER_KEY, TgolKeyStore.ROLE_ADMIN_KEY })
public String displayManualAuditResultFromContract(@RequestParam(TgolKeyStore.AUDIT_ID_KEY) String auditId, HttpServletRequest request, Model model) {
try {
Audit audit = auditDataService.read(Long.valueOf(auditId));
Act act = actDataService.getActFromAudit(audit);
switch(act.getScope().getCode()) {
case FILE:
case PAGE:
if (!contractDataService.doesContractHaveFunctionality(act.getContract(), manualAuditFunctionalityKey)) {
return TgolKeyStore.ACCESS_DENIED_VIEW_NAME;
}
model.addAttribute(TgolKeyStore.WEBRESOURCE_ID_KEY, audit.getSubject().getId());
return TgolKeyStore.MANUAL_AUDIT_RESULT_VIEW_REDIRECT_NAME;
case DOMAIN:
case SCENARIO:
case GROUPOFFILES:
case GROUPOFPAGES:
default:
throw new ForbiddenPageException();
}
} catch (NumberFormatException nfe) {
throw new ForbiddenPageException();
}
}
use of org.asqatasun.entity.contract.Act in project Asqatasun by Asqatasun.
the class ActDAOTest method testFindLastActsByContract.
/**
* Test of findAllContractsByUser method, of class ContractDAOImpl.
*/
@Test
public void testFindLastActsByContract() {
Contract contract = contractDAO.read((1L));
assertEquals(1, actDAO.findActsByContract(contract, 1, 2, null, false).size());
assertEquals(Long.valueOf(7), actDAO.findActsByContract(contract, 1, 2, null, false).iterator().next().getId());
Collection<Act> actSet = actDAO.findActsByContract(contract, 3, 2, null, false);
Iterator<Act> iter = actSet.iterator();
Date currentDate = null;
while (iter.hasNext()) {
Act act = iter.next();
if (currentDate != null) {
assertTrue(act.getBeginDate().before(currentDate));
}
currentDate = act.getBeginDate();
}
contract = contractDAO.read((2L));
assertEquals(0, actDAO.findActsByContract(contract, 1, 2, null, false).size());
}
use of org.asqatasun.entity.contract.Act in project Asqatasun by Asqatasun.
the class PageListControllerTest method setUpActDataService.
/**
* @param isActSiteScope
*/
private void setUpActDataService(boolean isActSiteScope) {
Scope mockGroupOfPagesScope = new Scope();
mockGroupOfPagesScope.setCode(ScopeEnum.GROUPOFPAGES);
Scope mockSiteScope = new Scope();
mockSiteScope.setCode(ScopeEnum.DOMAIN);
Contract mockContract = new Contract();
Act mockAct = new Act();
if (isActSiteScope) {
mockAct.setScope(mockSiteScope);
} else {
mockAct.setScope(mockGroupOfPagesScope);
}
GregorianCalendar calendar = new GregorianCalendar();
calendar.set(2030, 01, 01);
mockContract.setEndDate(calendar.getTime());
mockContract.setUser(mockUser);
mockContract.setLabel("CONTRACT LABEL");
mockContract.setId(1L);
mockAct.setContract(mockContract);
when(mockActDataService.getActFromAudit(mockAudit)).thenReturn(mockAct);
}
use of org.asqatasun.entity.contract.Act in project Asqatasun by Asqatasun.
the class ActFactory method createAct.
public Act createAct(Date date, Contract contract) {
Act act = create();
act.setBeginDate(date);
act.setContract(contract);
return act;
}
Aggregations