use of org.asqatasun.webapp.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 = getAuditDataService().read(Long.valueOf(auditId));
Act act = getActDataService().getActFromAudit(audit);
switch(act.getScope().getCode()) {
case FILE:
case PAGE:
if (!getContractDataService().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.webapp.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 = getAuditDataService().read(Long.valueOf(auditId));
Act act = getActDataService().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.webapp.entity.contract.Act in project Asqatasun by Asqatasun.
the class AuditScenarioController method deleteScenario.
/**
* Delete a scenario and the associated audits.
* @param scenarioId
*/
private void deleteScenario(Scenario scenario, Contract contract) {
scenarioDataService.delete(scenario.getId());
Collection<Act> actCollection = retrieveActCollection(scenario, contract);
for (Act act : actCollection) {
getAuditDataService().delete(act.getAudit().getId());
act.setStatus(ActStatus.DELETED);
act.setAudit(null);
getActDataService().saveOrUpdate(act);
}
}
use of org.asqatasun.webapp.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 = getActDataService().getNumberOfAct(contract);
int nbMaxActInfo = getMaxAuthorizedNumberOfActByContract(contract);
if (nbMaxActInfo > 0 && nb0fAct > nbMaxActInfo) {
nb0fAct = nbMaxActInfo;
}
detailedContractInfo.setNumberOfAct(nb0fAct);
Collection<Act> lastActSet = getActDataService().getActsByContract(contract, nb0fAct, 2, null, false);
for (Act act : lastActSet) {
detailedContractInfo.addActInfo(ActInfoFactory.getInstance().getActInfo(act));
}
detailedContractInfo.setNumberOfDisplayedAct(lastActSet.size());
detailedContractInfo.setSiteActInfoSet(ActInfoFactory.getInstance().getActInfoSet(getActDataService().getActsByContract(contract, -1, 1, ScopeEnum.DOMAIN, true)));
return detailedContractInfo;
}
use of org.asqatasun.webapp.entity.contract.Act in project Asqatasun by Asqatasun.
the class ActDAOImplTest method testFindLastActsByContract.
/**
* Test of findAllContractsByUser method, of class ContractDAOImpl.
*/
public void testFindLastActsByContract() {
System.out.println("findLastActsByContract");
Contract contract = contractDAO.read((Long.valueOf(1)));
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((Long.valueOf(2)));
assertEquals(0, actDAO.findActsByContract(contract, 1, 2, null, false).size());
}
Aggregations