use of org.asqatasun.entity.contract.Act in project Asqatasun by Asqatasun.
the class ParameterDAOImpl method findLastActByContract.
private Act findLastActByContract(Long idContract, ScopeEnum scope) {
Query query = entityManager.createQuery("SELECT a FROM " + Act.class.getName() + " a" + " WHERE a.contract.id = :idContract" + " AND (a.status = :completedStatus OR a.status = :errorStatus)" + " AND a.scope.code =:scope " + " ORDER BY a.id DESC");
query.setParameter("idContract", idContract);
query.setParameter("completedStatus", ActStatus.COMPLETED);
query.setParameter("errorStatus", ActStatus.ERROR);
query.setParameter("scope", scope);
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 AuditResultController method displayAuditResultFromContract.
/**
* 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.AUDIT_RESULT_CONTRACT_URL, method = RequestMethod.GET)
@Secured({ TgolKeyStore.ROLE_USER_KEY, TgolKeyStore.ROLE_ADMIN_KEY })
public String displayAuditResultFromContract(@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:
model.addAttribute(TgolKeyStore.WEBRESOURCE_ID_KEY, audit.getSubject().getId());
return TgolKeyStore.RESULT_PAGE_VIEW_REDIRECT_NAME;
case DOMAIN:
case SCENARIO:
model.addAttribute(TgolKeyStore.AUDIT_ID_KEY, auditId);
return TgolKeyStore.SYNTHESIS_SITE_VIEW_REDIRECT_NAME;
case GROUPOFFILES:
case GROUPOFPAGES:
model.addAttribute(TgolKeyStore.AUDIT_ID_KEY, auditId);
model.addAttribute(TgolKeyStore.STATUS_KEY, HttpStatusCodeFamily.f2xx.name());
return TgolKeyStore.PAGE_LIST_XXX_VIEW_REDIRECT_NAME;
default:
throw new ForbiddenPageException();
}
} catch (NumberFormatException nfe) {
throw new ForbiddenPageException();
}
}
use of org.asqatasun.entity.contract.Act in project Asqatasun by Asqatasun.
the class AuditScenarioController method deleteScenario.
/**
* Delete a scenario and the associated audits.
* @param scenario
* @param contract
*/
private void deleteScenario(Scenario scenario, Contract contract) {
scenarioDataService.delete(scenario.getId());
Collection<Act> actCollection = retrieveActCollection(scenario, contract);
for (Act act : actCollection) {
auditDataService.delete(act.getAudit().getId());
act.setStatus(ActStatus.DELETED);
act.setAudit(null);
actDataService.saveOrUpdate(act);
}
}
use of org.asqatasun.entity.contract.Act in project Asqatasun by Asqatasun.
the class DetailedContractInfoFactory method setNLastActInfo.
/**
* Sets the act info of the n last acts launched from this contract
*
* @param contract
* @param detailedContractInfo
* @return
*/
protected DetailedContractInfo setNLastActInfo(Contract contract, DetailedContractInfo detailedContractInfo) {
int nb0fAct = actDataService.getNumberOfAct(contract);
int nbMaxActInfo = getMaxAuthorizedNumberOfActByContract(contract);
if (nbMaxActInfo > 0 && nb0fAct > nbMaxActInfo) {
nb0fAct = nbMaxActInfo;
}
detailedContractInfo.setNumberOfAct(nb0fAct);
Collection<Act> lastActSet = actDataService.getActsByContract(contract, nb0fAct, 2, null, false);
for (Act act : lastActSet) {
detailedContractInfo.addActInfo(actInfoFactory.getActInfo(act));
}
detailedContractInfo.setNumberOfDisplayedAct(lastActSet.size());
detailedContractInfo.setSiteActInfoSet(actInfoFactory.getActInfoSet(actDataService.getActsByContract(contract, -1, 1, ScopeEnum.DOMAIN, true)));
return detailedContractInfo;
}
Aggregations