@Test
 public void testWithHomeFolderPojo()
     throws CvqException, CvqObjectNotFoundException, FileNotFoundException, IOException {
   SecurityContext.setCurrentSite(localAuthorityName, SecurityContext.FRONT_OFFICE_CONTEXT);
   // create a vo card request (to create home folder and associates)
   CreationBean cb = gimmeAnHomeFolderWithRequest();
   SecurityContext.setCurrentEcitizen(cb.getLogin());
   // get the home folder id
   HomeFolder homeFolder = homeFolderService.getById(cb.getHomeFolderId());
   assertNotNull(homeFolder);
   Long homeFolderId = homeFolder.getId();
   assertNotNull(homeFolderId);
   // fill and create the request
   //////////////////////////////
   TicketBookingRequest request = fillMeARequest();
   request.setRequesterId(SecurityContext.getCurrentUserId());
   request.setHomeFolderId(homeFolderId);
   TicketBookingRequestFeeder.setSubject(
       request, requestService.getSubjectPolicy(), null, homeFolder);
   Long requestId = requestWorkflowService.create(request);
   TicketBookingRequest requestFromDb =
       (TicketBookingRequest) requestSearchService.getById(requestId, true);
   assertEquals(requestId, requestFromDb.getId());
   assertNotNull(requestFromDb.getRequesterId());
   assertNotNull(requestFromDb.getRequesterLastName());
   if (requestFromDb.getSubjectId() != null) assertNotNull(requestFromDb.getSubjectLastName());
   completeValidateAndDelete(requestFromDb);
   HomeFolder homeFolderAfterDelete = homeFolderService.getById(homeFolderId);
   assertNotNull(homeFolderAfterDelete);
   assertNotNull(homeFolderService.getHomeFolderResponsible(homeFolderAfterDelete.getId()));
 }
Ejemplo n.º 2
0
  public static HomeFolder xmlToModel(fr.cg95.cvq.xml.common.HomeFolderType homeFolderType) {

    HomeFolder homeFolder = new HomeFolder();
    homeFolder.setId(new Long(homeFolderType.getId()));
    homeFolder.setAdress(Address.xmlToModel(homeFolderType.getAddress()));

    IndividualType[] individualsArray = homeFolderType.getIndividualsArray();
    Arrays.asList(individualsArray);
    List<Individual> individualsSet = new ArrayList<Individual>();
    for (int i = 0; i < individualsArray.length; i++) {
      individualsSet.add(Individual.xmlToModel(individualsArray[i]));
    }
    homeFolder.setIndividuals(individualsSet);
    if (homeFolderType.getState() != null)
      homeFolder.setState(ActorState.forString(homeFolderType.getState().toString()));
    if (homeFolderType.getFamilyQuotient() != null)
      homeFolder.setFamilyQuotient(homeFolderType.getFamilyQuotient());

    return homeFolder;
  }