示例#1
0
  List<Request> getDrafts() throws CvqException {
    Set<Critere> criterias = new HashSet<Critere>();

    Critere criteria = new Critere();
    criteria.setAttribut(Request.SEARCH_BY_STATE);
    criteria.setComparatif(Critere.EQUALS);
    criteria.setValue(RequestState.DRAFT);
    criterias.add(criteria);

    return requestSearchService.get(criterias, null, null, 0, 0, true);
  }
 protected void completeValidateAndDelete(TicketBookingRequest request)
     throws CvqException, IOException {
   // add a document to the request
   ///////////////////////////////
   Document doc = new Document();
   doc.setEcitizenNote("Ma carte d'identité !");
   doc.setDepositOrigin(DepositOrigin.ECITIZEN);
   doc.setDepositType(DepositType.PC);
   doc.setHomeFolderId(request.getHomeFolderId());
   doc.setIndividualId(request.getRequesterId());
   doc.setDocumentType(
       documentTypeService.getDocumentTypeByType(IDocumentTypeService.IDENTITY_RECEIPT_TYPE));
   Long documentId = documentService.create(doc);
   requestDocumentService.addDocument(request.getId(), documentId);
   Set<RequestDocument> documentsSet =
       requestDocumentService.getAssociatedDocuments(request.getId());
   assertEquals(documentsSet.size(), 1);
   // FIXME : test list of pending / in-progress registrations
   Critere testCrit = new Critere();
   testCrit.setAttribut(Request.SEARCH_BY_HOME_FOLDER_ID);
   testCrit.setComparatif(Critere.EQUALS);
   testCrit.setValue(request.getHomeFolderId());
   Set<Critere> testCritSet = new HashSet<Critere>();
   testCritSet.add(testCrit);
   List<Request> allRequests = requestSearchService.get(testCritSet, null, null, -1, 0, false);
   assertNotNull(allRequests);
   // close current session and re-open a new one
   continueWithNewTransaction();
   SecurityContext.setCurrentSite(localAuthorityName, SecurityContext.BACK_OFFICE_CONTEXT);
   SecurityContext.setCurrentAgent(agentNameWithCategoriesRoles);
   requestWorkflowService.updateRequestState(request.getId(), RequestState.COMPLETE, null);
   requestWorkflowService.updateRequestState(request.getId(), RequestState.VALIDATED, null);
   // close current session and re-open a new one
   continueWithNewTransaction();
   byte[] generatedCertificate =
       requestSearchService.getCertificate(request.getId(), RequestState.PENDING);
   if (generatedCertificate == null) fail("No certificate found");
   //     Write tele-service xml data file
   File xmlFile = File.createTempFile("tmp" + request.getId(), ".xml");
   FileOutputStream xmlFos = new FileOutputStream(xmlFile);
   xmlFos.write(requestSearchService.getById(request.getId(), true).modelToXmlString().getBytes());
   File file = File.createTempFile("tmp" + request.getId(), ".pdf");
   FileOutputStream fos = new FileOutputStream(file);
   fos.write(generatedCertificate);
   // close current session and re-open a new one
   continueWithNewTransaction();
   // delete request
   requestWorkflowService.delete(request.getId());
 }
示例#3
0
  Request getDraftById(Long id) throws CvqException {
    Set<Critere> criterias = new HashSet<Critere>();

    Critere criteria = new Critere();
    criteria.setAttribut(Request.SEARCH_BY_STATE);
    criteria.setComparatif(Critere.EQUALS);
    criteria.setValue(RequestState.DRAFT);
    criterias.add(criteria);

    criteria = new Critere();
    criteria.setAttribut(Request.SEARCH_BY_REQUEST_ID);
    criteria.setComparatif(Critere.EQUALS);
    criteria.setValue(id);
    criterias.add(criteria);

    List<Request> reqs = requestSearchService.get(criterias, null, null, 0, 0, false);

    return reqs.get(0);
  }
 public RecreationCenter findByName(final String name) {
   Criteria crit = HibernateUtil.getSession().createCriteria(RecreationCenter.class);
   crit.add(Critere.compose("name", name, Critere.EQUALS));
   return (RecreationCenter) crit.uniqueResult();
 }