List of usage examples for org.apache.commons.lang BooleanUtils isFalse
public static boolean isFalse(Boolean bool)
Checks if a Boolean
value is false
, handling null
by returning false
.
BooleanUtils.isFalse(Boolean.TRUE) = false BooleanUtils.isFalse(Boolean.FALSE) = true BooleanUtils.isFalse(null) = false
From source file:gov.nih.nci.cabig.caaers.api.impl.DefaultInvestigatorMigratorService.java
/** * This method updates the values of Investigator. It will update the existing Investigators values with the values from the Xml. * @param xmlInvestigator/* www . j a va 2 s . com*/ * @param dbInvestigator */ private void syncInvestigator(Investigator xmlInvestigator, Investigator dbInvestigator) { //do the basic property sync dbInvestigator.setFirstName(xmlInvestigator.getFirstName()); dbInvestigator.setMiddleName(xmlInvestigator.getMiddleName()); dbInvestigator.setLastName(xmlInvestigator.getLastName()); dbInvestigator.setEmailAddress(xmlInvestigator.getEmailAddress()); dbInvestigator.setPhoneNumber(xmlInvestigator.getPhoneNumber()); dbInvestigator.setFaxNumber(xmlInvestigator.getFaxNumber()); dbInvestigator.setNciIdentifier(xmlInvestigator.getNciIdentifier()); if (BooleanUtils.isFalse(dbInvestigator.getAllowedToLogin())) { dbInvestigator.setAllowedToLogin(xmlInvestigator.getAllowedToLogin()); } //do the site research staff sync if (CollectionUtils.isEmpty(xmlInvestigator.getSiteInvestigators())) return; //nothing provided in xml input List<SiteInvestigator> newSiteInvestigators = new ArrayList<SiteInvestigator>(); for (SiteInvestigator xmlSiteInvestigator : xmlInvestigator.getSiteInvestigators()) { SiteInvestigator existing = dbInvestigator.findSiteInvestigator(xmlSiteInvestigator); if (existing != null) { existing.setStartDate(xmlSiteInvestigator.getStartDate()); existing.setEndDate(xmlSiteInvestigator.getEndDate()); existing.setAddress(xmlSiteInvestigator.getAddress()); existing.setPhoneNumber(xmlSiteInvestigator.getPhoneNumber()); existing.setFaxNumber(xmlSiteInvestigator.getFaxNumber()); } else { newSiteInvestigators.add(xmlSiteInvestigator); } } //add the items in new for (SiteInvestigator si : newSiteInvestigators) { dbInvestigator.addSiteInvestigator(si); } }
From source file:com.evolveum.midpoint.model.impl.importer.ObjectImporter.java
private <T extends ObjectType> void importObjectToRepository(PrismObject<T> object, ImportOptionsType options, boolean raw, Task task, OperationResult objectResult) throws ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException, SchemaException, ObjectAlreadyExistsException { OperationResult result = objectResult .createSubresult(ObjectImporter.class.getName() + ".importObjectToRepository"); if (options == null) { options = new ImportOptionsType(); }/* ww w. jav a2s .com*/ if (BooleanUtils.isTrue(options.isKeepOid()) && object.getOid() == null) { // Try to check if there is existing object with the same type and name ObjectQuery query = ObjectQueryUtil.createNameQuery(object); List<PrismObject<T>> foundObjects = repository.searchObjects(object.getCompileTimeClass(), query, null, result); if (foundObjects.size() == 1) { String oid = foundObjects.iterator().next().getOid(); object.setOid(oid); } } try { String oid = addObject(object, BooleanUtils.isTrue(options.isOverwrite()), BooleanUtils.isFalse(options.isEncryptProtectedValues()), raw, task, result); if (object.canRepresent(TaskType.class)) { taskManager.onTaskCreate(oid, result); } result.recordSuccess(); } catch (ObjectAlreadyExistsException e) { if (BooleanUtils.isTrue(options.isOverwrite() && BooleanUtils.isNotTrue(options.isKeepOid()) && object.getOid() == null)) { // This is overwrite, without keep oid, therefore we do not have conflict on OID // this has to be conflict on name. So try to delete the conflicting object and create new one (with a new OID). result.muteLastSubresultError(); ObjectQuery query = ObjectQueryUtil.createNameQuery(object); List<PrismObject<T>> foundObjects = repository.searchObjects(object.getCompileTimeClass(), query, null, result); if (foundObjects.size() == 1) { PrismObject<T> foundObject = foundObjects.iterator().next(); String deletedOid = deleteObject(foundObject, repository, result); if (deletedOid != null) { if (object.canRepresent(TaskType.class)) { taskManager.onTaskDelete(deletedOid, result); } if (BooleanUtils.isTrue(options.isKeepOid())) { object.setOid(deletedOid); } addObject(object, false, BooleanUtils.isFalse(options.isEncryptProtectedValues()), raw, task, result); if (object.canRepresent(TaskType.class)) { taskManager.onTaskCreate(object.getOid(), result); } result.recordSuccess(); } else { // cannot delete, throw original exception result.recordFatalError("Object already exists, cannot overwrite", e); throw e; } } else { // Cannot locate conflicting object String message = "Conflicting object already exists but it was not possible to precisely locate it, " + foundObjects.size() + " objects with same name exist"; result.recordFatalError(message, e); throw new ObjectAlreadyExistsException(message, e); } } else { result.recordFatalError(e); throw e; } } catch (ObjectNotFoundException | ExpressionEvaluationException | CommunicationException | ConfigurationException | PolicyViolationException | SecurityViolationException | SchemaException e) { result.recordFatalError("Cannot import " + object + ": " + e.getMessage(), e); throw e; } catch (RuntimeException ex) { result.recordFatalError("Couldn't import object: " + object + ". Reason: " + ex.getMessage(), ex); throw ex; } }
From source file:com.wineaccess.winery.WineryRepository.java
/** * this method is used to bulk enable/disable the wineries * @param wineryIds which needs to enable or disable * @param status, need to enable or disable * @param isforceDelete, if need to perform the operation on success list * @return//from w w w.jav a 2 s. c o m */ public static BulkDeleteModel<WineryModel> enableDisable(final List<Long> wineryIds, final Boolean status, final Boolean isforceDelete) { GenericDAO<WineryModel> genericDao = (GenericDAO<WineryModel>) CoreBeanFactory.getBean("genericDAO"); BulkDeleteModel<WineryModel> bulkDeleteModel = new BulkDeleteModel<WineryModel>(); try { if (BooleanUtils.isFalse((Boolean) isforceDelete)) bulkDeleteModel = genericDao.performBulkDelete(wineryIds, WineryModel.class, "WineryModel", "isEnabled", status, "isDeleted", isforceDelete); else { BulkDeleteModel<WineryModel> bulkWineryDeleteModel = null; for (Serializable id : wineryIds) { List<Long> ids = new ArrayList<Long>(); try { ids.add((Long) id); bulkWineryDeleteModel = genericDao.performBulkDelete(ids, WineryModel.class, "WineryModel", "isEnabled", status, "isDeleted", isforceDelete); } catch (Exception e) { if (e instanceof PersistenceException) { PersistenceException persistenceException = (PersistenceException) e; bulkWineryDeleteModel = (BulkDeleteModel<WineryModel>) (persistenceException.getData()); } } finally { ApplicationUtils.mergeDeleteResult(bulkDeleteModel.getDeletedList(), bulkWineryDeleteModel.getDeletedList()); ApplicationUtils.mergeDeleteResult(bulkDeleteModel.getNotDeletedList(), bulkWineryDeleteModel.getNotDeletedList()); ApplicationUtils.mergeDeleteResult(bulkDeleteModel.getNotExistsList(), bulkWineryDeleteModel.getNotExistsList()); } } } } catch (Exception e) { if (e instanceof PersistenceException) { PersistenceException persistenceException = (PersistenceException) e; bulkDeleteModel = (BulkDeleteModel<WineryModel>) (persistenceException.getData()); } } finally { genericDao.refresh(wineryIds, WineryModel.class); } return bulkDeleteModel; }
From source file:com.square.core.service.implementations.ActionServiceImplementation.java
@Override public ActionResultatDto modifierAction(ActionModificationDto actionModificationDto) { // Dto null// w ww . j a v a 2 s . c o m if (actionModificationDto == null) { throw new BusinessException(messageSourceUtil.get(ActionKeyUtil.MESSAGE_ERREUR_ACTION_DTO_NULL)); } // Identifiant de l'action null if (actionModificationDto.getIdAction() == null) { throw new BusinessException(messageSourceUtil.get(ActionKeyUtil.MESSAGE_ERREUR_ACTION_IDACTION_NULL)); } // Rcupration de l'action correspondant final Action actionAModifier = actionDao.rechercherActionParId(actionModificationDto.getIdAction()); if (actionAModifier == null) { throw new BusinessException(messageSourceUtil.get(ActionKeyUtil.MESSAGE_ERREUR_ACTION_INEXISTANTE)); } if (logger.isDebugEnabled()) { logger.debug("bug 0008864 : modifierAction(ActionModificationDto)"); logger.debug("recuperation de l'action : " + actionModificationDto.getIdAction()); logger.debug("dateCreation = " + (actionAModifier.getDateCreation() != null ? SDF.format(actionAModifier.getDateCreation().getTime()) : "null")); } Agence agence = null; if (actionModificationDto.getAgence() != null && actionModificationDto.getAgence().getIdentifiant() != null) { agence = agenceDao.rechercheAgenceParId(actionModificationDto.getAgence().getIdentifiant()); if (agence == null) { logger.error( "L'agence id = " + actionModificationDto.getAgence().getIdentifiant() + "n'existe pas."); throw new TechnicalException( messageSourceUtil.get(ActionKeyUtil.MESSAGE_ERREUR_ACTION_AGENCE_INEXISTANTE)); } } // Rcupration de la ressource correspondant au commercial (on permet dsormais le changement de ressource mme si existant) Ressource commercial = null; if (actionAModifier.getActionAttribution() != null && actionModificationDto.getRessource() != null && actionModificationDto.getRessource().getIdentifiant() != null) { commercial = ressourceDao .rechercherRessourceParId(actionModificationDto.getRessource().getIdentifiant()); if (commercial == null) { logger.error( "La ressource " + actionModificationDto.getRessource().getIdentifiant() + " n'existe pas"); throw new BusinessException( messageSourceUtil.get(ActionKeyUtil.MESSAGE_ERREUR_ACTION_COMMERCIAL_INEXISTANTE)); } } // Rcupration de la dure ActionDuree dureeAction = null; if (actionModificationDto.getIdDuree() != null) { dureeAction = actionDureeDao.rechercherDureeActionParId(actionModificationDto.getIdDuree()); if (dureeAction == null) { throw new BusinessException( messageSourceUtil.get(ActionKeyUtil.MESSAGE_ERREUR_ACTION_DUREE_INEXISTANTE)); } } final RapportDto rapport = new RapportDto(); // Vrification de la nature if (actionModificationDto.getNatureAction() == null || actionModificationDto.getNatureAction().getIdentifiant() == null) { rapport.ajoutRapport(ActionModificationDto.class.getSimpleName() + ".nature", messageSourceUtil.get(ActionKeyUtil.MESSAGE_ERREUR_ACTION_NATURE_ACTION_NULL), true); } // Pour une action de nature "tlphone sortant" passant au statut "termin" if (actionModificationDto.getNatureAction() != null && squareMappingService.getIdNatureActionTelephoneSortant() .equals(actionModificationDto.getNatureAction().getIdentifiant()) && actionModificationDto.getStatut() != null && squareMappingService.getIdStatutActionTermine() .equals(actionModificationDto.getStatut().getIdentifiant())) { // On vrifie que le rsultat de la nature est renseign if (actionModificationDto.getNatureResultat() == null || actionModificationDto.getNatureResultat().getIdentifiant() == null) { rapport.ajoutRapport(ActionModificationDto.class.getSimpleName() + ".natureResultat", messageSourceUtil.get(ActionKeyUtil.MESSAGE_ERREUR_ACTION_NATURE_RESULTAT_ACTION_NULL), true); } } // vrification que la nature de resultat est selectionne pour la nature d'action visite sortante si on demande la vrification if (!BooleanUtils.isFalse(actionModificationDto.getVerifierResultatNatureAction()) && actionModificationDto.getNatureAction() != null && squareMappingService.getIdNatureActionVisiteSortante() .equals(actionModificationDto.getNatureAction().getIdentifiant()) && actionModificationDto.getNatureResultat() == null && squareMappingService .getIdStatutActionTermine().equals(actionModificationDto.getStatut().getIdentifiant())) { throw new BusinessException( messageSourceUtil.get(ActionKeyUtil.MESSAGE_ERREUR_ACTION_NATURE_RESULTAT_VISITE_SORTANTE)); } // Contrle du statut final ValidationExpressionProp[] propsAction = new ValidationExpressionProp[] { new ValidationExpressionProp("statut", null, messageSourceUtil.get(ActionKeyUtil.MESSAGE_ERREUR_ACTION_STATUT_NULL)), new ValidationExpressionProp("dateAction", null, messageSourceUtil.get(ActionKeyUtil.MESSAGE_ERREUR_ACTION_DATE_ACTION_NULL)) }; validationExpressionUtil.verifierSiVide(rapport, actionModificationDto, propsAction); if (actionModificationDto.getDateAction() != null) { // On copie la date de l'action enregistre en base final Calendar ancienneDateAction = DateUtils.truncate((Calendar) actionAModifier.getDate().clone(), Calendar.HOUR); // On copie la nouvelle date d'action final Calendar nouvelleDateAction = DateUtils .truncate((Calendar) actionModificationDto.getDateAction().clone(), Calendar.HOUR); // Si la date de l'action est modifie if (!ancienneDateAction.equals(nouvelleDateAction)) { // On vrifie que la date d'action est postrieure la date courante if (DateUtils.truncate(nouvelleDateAction, Calendar.DAY_OF_MONTH) .before(DateUtils.truncate(Calendar.getInstance(), Calendar.DAY_OF_MONTH))) { rapport.ajoutRapport(actionModificationDto.getClass().getSimpleName() + ".dateAction", messageSourceUtil.get(ActionKeyUtil.MESSAGE_ERREUR_ACTION_DATE_ACTION_INVALIDE), true); } } } // Une action ne peut tre termine sans tre attribue if (actionModificationDto.getStatut() != null && squareMappingService.getIdStatutActionTermine() .equals(actionModificationDto.getStatut().getIdentifiant()) && (actionModificationDto.getRessource() == null || actionModificationDto.getRessource().getIdentifiant() == null)) { rapport.ajoutRapport(ActionModificationDto.class.getSimpleName() + ".statut", messageSourceUtil.get(ActionKeyUtil.MESSAGE_ERREUR_ACTION_TERMINEE_SANS_ATTRIBUTION), true); } // On ne peut rendre visible une action dans l'agenda que si elle a une date de dbut, une dure if (actionModificationDto.getVisibleAgenda() != null && actionModificationDto.getVisibleAgenda().booleanValue() && (actionModificationDto.getDateAction() == null || actionModificationDto.getIdDuree() == null)) { rapport.ajoutRapport(actionModificationDto.getClass().getSimpleName() + ".isVisibleAgenda", messageSourceUtil.get(ActionKeyUtil.MESSAGE_ERREUR_ACTION_IMPOSSIBLE_VISIBLE_AGENDA), true); } // Prsence d'erreurs empchant la modification de l'action if (rapport.getEnErreur()) { // On retourne le rapport d'erreur RapportUtil.logRapport(rapport, logger); throw new ControleIntegriteException(rapport); } // Vrification de l'existance des nouveaux champs verificationExistanceModification(actionModificationDto, actionAModifier); // Vrification de la rgle de gestion de l'opportunit en cours if (Boolean.TRUE.equals(actionModificationDto.getVerifierRegleGestionOpportuniteEnCours())) { verifierRegleGestionOpportuniteOuverte(actionModificationDto, actionAModifier); } // Modification de l'action if (actionModificationDto.getNatureAction() != null && actionModificationDto.getNatureAction().getIdentifiant() != null) { final ActionNature nature = actionNatureDao .rechercherNatureActionParId(actionModificationDto.getNatureAction().getIdentifiant()); if (nature == null) { throw new TechnicalException( messageSourceUtil.get(ActionKeyUtil.MESSAGE_ERREUR_ACTION_NATURE_ACTION_INEXISTANT)); } actionAModifier.setNature(nature); } // modification du type d'action final IdentifiantLibelleDto typeAction = actionModificationDto.getTypeAction(); if (actionModificationDto.getTypeAction() != null && typeAction.getIdentifiant() != null) { actionAModifier.setType(actionTypeDao.rechercherTypeActionParId(typeAction.getIdentifiant())); } // modificatio de l'objet d'action final IdentifiantLibelleDto objetAction = actionModificationDto.getObjetAction(); if (actionModificationDto.getObjetAction() != null && objetAction.getIdentifiant() != null) { actionAModifier.setObjet(actionObjetDao.rechercherObjetActionParId(objetAction.getIdentifiant())); } // affectation au pot commun if (actionModificationDto.getAffectationPotCommun() != null && actionModificationDto.getAffectationPotCommun()) { actionAModifier.getActionAttribution() .setAgence(agenceDao.rechercheAgenceParId(squareMappingService.getIdentifiantAgenceFrance())); actionAModifier.getActionAttribution().setRessource(null); } if (actionModificationDto.getRappelMail() != null) { actionAModifier.setMailNotification(actionModificationDto.getRappelMail()); } // action tlphone sortant ou visite sortante if (actionModificationDto.getNatureAction() != null && (squareMappingService.getIdNatureActionTelephoneSortant() .equals(actionModificationDto.getNatureAction().getIdentifiant()) || squareMappingService.getIdNatureActionVisiteSortante() .equals(actionModificationDto.getNatureAction().getIdentifiant()))) { if (actionModificationDto.getNatureResultat() != null && actionModificationDto.getNatureResultat().getIdentifiant() != null) { actionAModifier.setNatureResultat(actionNatureResultatDao.rechercherNatureResultatActionById( actionModificationDto.getNatureResultat().getIdentifiant())); } else { actionAModifier.setNatureResultat(null); } } if (agence != null) { // si on affecte une action de relance (qui n'avait pas d'agence) une agence, on affecte aussi l'opp l'agence if (actionAModifier.getActionAttribution().getAgence() == null && actionAModifier.getType().getId().equals(squareMappingService.getIdTypeActionRelance()) && actionAModifier.getActionAffectation().getOpportunite() != null) { actionAModifier.getActionAffectation().getOpportunite().getOpportuniteAttribution() .setAgence(agence); } actionAModifier.getActionAttribution().setAgence(agence); } if (commercial != null) { // si on affecte une action de relance (qui n'avait pas de ressource) une ressource, on affecte aussi l'opp la ressource if (actionAModifier.getActionAttribution().getRessource() == null && actionAModifier.getType().getId().equals(squareMappingService.getIdTypeActionRelance()) && actionAModifier.getActionAffectation().getOpportunite() != null) { actionAModifier.getActionAffectation().getOpportunite().getOpportuniteAttribution() .setRessource(commercial); } actionAModifier.getActionAttribution().setRessource(commercial); } final Long idStatutTermine = squareMappingService.getIdStatutTerminer(); // Rsultat // Cration d'une opportunit si le rsultat passe opportunit OpportuniteDto opportuniteCree = null; if (actionAModifier.getResultat() == null) { if (actionModificationDto.getResultat() != null && actionModificationDto.getResultat().getIdentifiant() .equals(squareMappingService.getIdResultatOpportunite())) { actionAModifier.setStatut(actionStatutDao.rechercherStatutActionParId(idStatutTermine)); opportuniteCree = creationOpportunite(actionAModifier); } else if (actionModificationDto.getResultat() != null && actionModificationDto.getResultat() .getIdentifiant().equals(squareMappingService.getIdResultatRelance())) { actionAModifier.setStatut(actionStatutDao.rechercherStatutActionParId(idStatutTermine)); } else { actionAModifier.setStatut(actionStatutDao .rechercherStatutActionParId(actionModificationDto.getStatut().getIdentifiant())); } if (actionModificationDto.getResultat() != null) { actionAModifier.setResultat(actionResultatDao .rechercherActionResultatParId(actionModificationDto.getResultat().getIdentifiant())); } } else { if (actionModificationDto.getResultat() != null && actionModificationDto.getResultat().getIdentifiant() .equals(squareMappingService.getIdResultatOpportunite())) { if (!actionAModifier.getResultat().getId() .equals(squareMappingService.getIdResultatOpportunite())) { actionAModifier.setStatut(actionStatutDao.rechercherStatutActionParId(idStatutTermine)); opportuniteCree = creationOpportunite(actionAModifier); } } else if (actionModificationDto.getResultat() != null && actionModificationDto.getResultat() .getIdentifiant().equals(squareMappingService.getIdResultatRelance())) { actionAModifier.setStatut(actionStatutDao.rechercherStatutActionParId(idStatutTermine)); } else { actionAModifier.setStatut(actionStatutDao .rechercherStatutActionParId(actionModificationDto.getStatut().getIdentifiant())); } if (actionModificationDto.getResultat() != null) { actionAModifier.setResultat(actionResultatDao .rechercherActionResultatParId(actionModificationDto.getResultat().getIdentifiant())); } } // Mise jour de la date de l'action if (idStatutTermine.equals(actionModificationDto.getStatut().getIdentifiant())) { // Si l'action passe au statut "termin", on met jour la date termine de l'action en prenant la date courante actionAModifier.setDateTerminee(Calendar.getInstance()); } else { actionAModifier.setDate(actionModificationDto.getDateAction()); } // Priorit if (actionModificationDto.getPriorite() != null && actionModificationDto.getPriorite().getIdentifiant() != null) { // Rcupration de la priorit final ActionPriorite priorite = actionPrioriteDao .rechercherPrioriteActionParId(actionModificationDto.getPriorite().getIdentifiant()); if (priorite != null) { actionAModifier.setPriorite(priorite); } } // Dure de l'action if (dureeAction != null) { actionAModifier.setDuree(dureeAction); } // Action visible ou non dans l'agenda actionAModifier.setVisibleAgenda(actionModificationDto.getVisibleAgenda() != null && actionModificationDto.getVisibleAgenda().booleanValue()); // Construction de la date de notification if (actionModificationDto.getRappel() != null && actionModificationDto.getRappel()) { if (actionModificationDto.getIdNotification() != null) { final ActionNotificationInfosDto notification = squareMappingService .getActionNotificationParId(actionModificationDto.getIdNotification()); final Calendar soustraction = Calendar.getInstance(); soustraction.clear(); final Long dateTime = -notification.getNotification().getTimeInMillis() + actionAModifier.getDate().getTimeInMillis(); soustraction.setTimeInMillis(dateTime); actionAModifier.setDateNotification(soustraction); } else { actionAModifier.setDateNotification(null); } } else { actionAModifier.setDateNotification(null); } // Constuction du commentaire if (actionModificationDto.getCommentaire() != null) { final Commentaire commentaire = mapperDozerBean.map(actionModificationDto.getCommentaire(), Commentaire.class); if (actionModificationDto.getCommentaire().getRessource() != null) { final Ressource ressource = ressourceDao .rechercherRessourceParId(actionModificationDto.getCommentaire().getRessource().getId()); commentaire.setRessource(ressource); } if (actionAModifier.getCommentaires() == null) { final List<Commentaire> list = new ArrayList<Commentaire>(); list.add(commentaire); actionAModifier.setCommentaires(list); } else { actionAModifier.getCommentaires().add(commentaire); } } // Envoi d'un email si demand if (actionAModifier.isMailNotification() && squareMappingService.getIdStatutActionTermine().equals(actionAModifier.getStatut().getId())) { if (actionAModifier.getRessource() != null) { final Ressource createur = actionAModifier.getRessource(); if (createur.getEmail() == null || "".equals(createur.getEmail())) { throw new BusinessException( messageSourceUtil.get(ActionKeyUtil.MESSAGE_ERREUR_EMAIL_CREATEUR_ACTION_VIDE)); } final List<String> listeDestinataires = new ArrayList<String>(); listeDestinataires.add(createur.getEmail()); final String titre = messageSourceUtil.get(ActionKeyUtil.TITRE_EMAIL_FIN_ACTION); String personneAction = ""; String type = ""; String objet = ""; String sousObjet = ""; String nature = ""; String campagne = ""; if (actionAModifier.getActionAffectation() != null && actionAModifier.getActionAffectation().getPersonne() != null) { final Personne personne = actionAModifier.getActionAffectation().getPersonne(); if (personne instanceof PersonnePhysique) { final PersonnePhysique personnePhysique = (PersonnePhysique) actionAModifier .getActionAffectation().getPersonne(); personneAction = personnePhysique.getNom() + ESPACE + personnePhysique.getPrenom(); } else if (personne instanceof PersonneMorale) { final PersonneMorale personneMorale = (PersonneMorale) actionAModifier .getActionAffectation().getPersonne(); personneAction = personneMorale.getRaisonSociale(); } } if (actionAModifier.getType() != null) { type = actionAModifier.getType().getLibelle(); } if (actionAModifier.getObjet() != null) { objet = actionAModifier.getObjet().getLibelle(); } if (actionAModifier.getSousObjet() != null) { sousObjet = actionAModifier.getSousObjet().getLibelle(); } if (actionAModifier.getNature() != null) { nature = actionAModifier.getNature().getLibelle(); } if (actionAModifier.getCampagne() != null) { campagne = actionAModifier.getCampagne().getLibelle(); } final String message = messageSourceUtil.get(ActionKeyUtil.MESSAGE_EMAIL_FIN_ACTION, new String[] { personneAction, type, objet, sousObjet, nature, campagne }); final MailDto mailDto = new MailDto(expediteurNoReply, listeDestinataires, titre, message, null, false); emailSquarePlugin.envoyerEmail(mailDto); } } // Renseignement de la date de modification actionAModifier.setDateModification(Calendar.getInstance()); final ActionResultatDto resultat = new ActionResultatDto(); if (opportuniteCree != null) { resultat.setIdOpportunite(opportuniteCree.getIdOpportunite()); } return resultat; }
From source file:fr.paris.lutece.plugins.document.business.DocumentDAO.java
/** * Return a dao initialized with the specified filter * @param strQuerySelect the query/* w w w.jav a 2 s . c om*/ * @param filter the DocumentFilter object * @return the DaoUtil */ private DAOUtil getDaoFromFilter(String strQuerySelect, DocumentFilter filter) { String strSQL = strQuerySelect; StringBuilder sbWhere = new StringBuilder(StringUtils.EMPTY); sbWhere.append(((filter.containsDocumentTypeCriteria()) ? SQL_FILTER_DOCUMENT_TYPE : "")); if (filter.containsSpaceCriteria()) { sbWhere.append(((sbWhere.length() != 0) ? SQL_FILTER_AND : StringUtils.EMPTY)).append(SQL_FILTER_SPACE); } if (filter.containsStateCriteria()) { sbWhere.append(((sbWhere.length() != 0) ? SQL_FILTER_AND : StringUtils.EMPTY)).append(SQL_FILTER_STATE); } if (filter.containsCategoriesCriteria()) { StringBuilder sbCategories = new StringBuilder(SQL_FILTER_CATEGORIES_BEGIN); int i = 0; for (int nCategoryId : filter.getCategoriesId()) { if (nCategoryId > 0) { sbCategories.append(SQL_FILTER_CATEGORIES); } else { sbCategories.append(SQL_FILTER_CATEGORIES_NULL); } if ((i + 1) < filter.getCategoriesId().length) { sbCategories.append(SQL_FILTER_CATEGORIES_OR); } i++; } sbCategories.append(SQL_FILTER_CATEGORIES_END); sbWhere.append((sbWhere.length() != 0) ? SQL_FILTER_AND : StringUtils.EMPTY) .append(sbCategories.toString()); } if (filter.containsIdsCriteria()) { StringBuilder sbIds = new StringBuilder(SQL_FILTER_ID_BEGIN); for (int i = 0; i < filter.getIds().length; i++) { sbIds.append(SQL_FILTER_ID); if ((i + 1) < filter.getIds().length) { sbIds.append(SQL_FILTER_ID_OR); } } sbIds.append(SQL_FILTER_ID_END); sbWhere.append((sbWhere.length() != 0) ? SQL_FILTER_AND : StringUtils.EMPTY).append(sbIds.toString()); } if (BooleanUtils.isFalse(filter.isPublished())) { sbWhere.append((sbWhere.length() != 0) ? SQL_FILTER_AND : StringUtils.EMPTY) .append("a.id_document NOT IN (SELECT DISTINCT id_document FROM document_published) "); } if (StringUtils.isNotBlank(filter.getDateMin()) && StringUtils.isNotBlank(filter.getDateMax())) { sbWhere.append(((sbWhere.length() != 0) ? SQL_FILTER_AND : StringUtils.EMPTY)) .append("a.date_modification < ").append("'" + filter.getDateMax() + "'").append(SQL_FILTER_AND) .append("a.date_modification > ").append("'" + filter.getDateMin() + "'"); } else if (StringUtils.isNotBlank(filter.getDateMin())) { sbWhere.append(((sbWhere.length() != 0) ? SQL_FILTER_AND : StringUtils.EMPTY)) .append("a.date_modification > ").append("'" + filter.getDateMin() + "'"); } else if (StringUtils.isNotBlank(filter.getDateMax())) { sbWhere.append(((sbWhere.length() != 0) ? SQL_FILTER_AND : StringUtils.EMPTY)) .append("a.date_modification <= ").append("'" + filter.getDateMax() + "'"); } String strWhere = sbWhere.toString(); if (sbWhere.length() != 0) { strSQL += (SQL_FILTER_WHERE_CLAUSE + strWhere); } strSQL += SQL_ORDER_BY_LAST_MODIFICATION; AppLogService.debug("Sql query filter : " + strSQL); DAOUtil daoUtil = new DAOUtil(strSQL); int nIndex = 1; if (filter.containsDocumentTypeCriteria()) { daoUtil.setString(nIndex, filter.getCodeDocumentType()); AppLogService.debug("Param" + nIndex + " (getCodeDocumentType) = " + filter.getCodeDocumentType()); nIndex++; } if (filter.containsSpaceCriteria()) { daoUtil.setInt(nIndex, filter.getIdSpace()); AppLogService.debug("Param" + nIndex + " (getIdSpace) = " + filter.getIdSpace()); nIndex++; } if (filter.containsStateCriteria()) { daoUtil.setInt(nIndex, filter.getIdState()); AppLogService.debug("Param" + nIndex + " (getIdState) = " + filter.getIdState()); nIndex++; } if (filter.containsCategoriesCriteria()) { for (int nCategoryId : filter.getCategoriesId()) { if (nCategoryId > 0) { daoUtil.setInt(nIndex, nCategoryId); AppLogService.debug("Param" + nIndex + " (getCategoriesId) = " + nCategoryId); nIndex++; } } } if (filter.containsIdsCriteria()) { for (int nId : filter.getIds()) { daoUtil.setInt(nIndex, nId); AppLogService.debug("Param" + nIndex + " (getIds) = " + nId); nIndex++; } } return daoUtil; }
From source file:eionet.meta.dao.mysql.VocabularyFolderDAOImpl.java
@Override public VocabularyResult searchVocabularies(VocabularyFilter filter) { Map<String, Object> params = new HashMap<String, Object>(); StringBuilder sql = new StringBuilder(); sql.append(//from w w w .jav a 2s . c om "select v.VOCABULARY_ID, v.IDENTIFIER, v.LABEL, v.REG_STATUS, v.WORKING_COPY, v.BASE_URI, v.VOCABULARY_TYPE, "); sql.append("v.WORKING_USER, v.DATE_MODIFIED, v.USER_MODIFIED, v.CHECKEDOUT_COPY_ID, v.CONTINUITY_ID, "); sql.append("v.CONCEPT_IDENTIFIER_NUMERIC, f.ID, f.IDENTIFIER, f.LABEL "); sql.append("from VOCABULARY v "); sql.append("left join VOCABULARY_SET f on f.ID=v.FOLDER_ID where 1=1 "); if (StringUtils.isNotEmpty(filter.getText())) { if (filter.isWordMatch()) { params.put("text", "[[:<:]]" + filter.getText() + "[[:>:]]"); sql.append("AND (v.LABEL REGEXP :text "); sql.append("or v.IDENTIFIER REGEXP :text) "); } else if (filter.isExactMatch()) { params.put("text", filter.getText()); sql.append("AND (v.LABEL = :text "); sql.append("or v.IDENTIFIER = :text) "); } else { params.put("text", "%" + filter.getText() + "%"); sql.append("AND (v.LABEL like :text "); sql.append("or v.IDENTIFIER like :text) "); } } else if (StringUtils.isNotEmpty(filter.getIdentifier())) { params.put("identifier", filter.getIdentifier()); sql.append("AND v.IDENTIFIER like :identifier "); } if (filter.getVocabularyWorkingCopyId() != null) { if (BooleanUtils.isFalse(filter.isWorkingCopy())) { params.put("workingCopyVocabularyId", filter.getVocabularyWorkingCopyId()); sql.append( "AND ((WORKING_COPY = 0 AND (CHECKEDOUT_COPY_ID IS NULL OR CHECKEDOUT_COPY_ID <> :workingCopyVocabularyId)) " + "OR (WORKING_COPY = 1 AND VOCABULARY_ID = :workingCopyVocabularyId)) "); } } else if (filter.isWorkingCopy() != null) { params.put("workingCopy", filter.isWorkingCopy() ? 1 : 0); sql.append("AND WORKING_COPY = :workingCopy"); } if (filter.getStatus() != null) { params.put("regStatus", filter.getStatus().getLabel()); sql.append("AND REG_STATUS = :regStatus"); } // related concepts text: if (StringUtils.isNotEmpty(filter.getConceptText())) { if (filter.isWordMatch()) { params.put("text", "[[:<:]]" + filter.getConceptText() + "[[:>:]]"); sql.append( " AND EXISTS (SELECT 1 FROM VOCABULARY_CONCEPT vc WHERE vc.VOCABULARY_ID = v.VOCABULARY_ID "); sql.append(" AND (vc.LABEL REGEXP :conceptText OR vc.IDENTIFIER REGEXP :conceptText "); sql.append(" OR vc.DEFINITION REGEXP :conceptText)) "); } else if (filter.isExactMatch()) { params.put("conceptText", filter.getConceptText()); sql.append( " AND EXISTS (SELECT 1 FROM VOCABULARY_CONCEPT vc WHERE vc.VOCABULARY_ID = v.VOCABULARY_ID "); sql.append( " AND (vc.LABEL = :conceptText OR vc.IDENTIFIER = :conceptText OR vc.DEFINITION = :conceptText)) "); } else { params.put("conceptText", "%" + filter.getConceptText() + "%"); sql.append( " AND EXISTS (SELECT 1 FROM VOCABULARY_CONCEPT vc WHERE vc.VOCABULARY_ID = v.VOCABULARY_ID "); sql.append(" AND (vc.LABEL like :conceptText "); sql.append(" OR vc.IDENTIFIER like :conceptText OR vc.DEFINITION like :conceptText) ) "); } } if (StringUtils.isNotBlank(filter.getBaseUri())) { params.put("baseUri", filter.getBaseUri()); sql.append(" AND v.BASE_URI like :baseUri "); } sql.append(" ORDER BY v.IDENTIFIER"); List<VocabularyFolder> items = getNamedParameterJdbcTemplate().query(sql.toString(), params, new RowMapper<VocabularyFolder>() { @Override public VocabularyFolder mapRow(ResultSet rs, int rowNum) throws SQLException { VocabularyFolder vf = new VocabularyFolder(); vf.setId(rs.getInt("v.VOCABULARY_ID")); vf.setIdentifier(rs.getString("v.IDENTIFIER")); vf.setLabel(rs.getString("v.LABEL")); vf.setRegStatus(RegStatus.fromString(rs.getString("v.REG_STATUS"))); vf.setWorkingCopy(rs.getBoolean("v.WORKING_COPY")); vf.setBaseUri(rs.getString("v.BASE_URI")); vf.setType(VocabularyType.valueOf(rs.getString("v.VOCABULARY_TYPE"))); vf.setWorkingUser(rs.getString("v.WORKING_USER")); vf.setDateModified(rs.getTimestamp("v.DATE_MODIFIED")); vf.setUserModified(rs.getString("v.USER_MODIFIED")); vf.setCheckedOutCopyId(rs.getInt("v.CHECKEDOUT_COPY_ID")); vf.setContinuityId(rs.getString("v.CONTINUITY_ID")); vf.setNumericConceptIdentifiers(rs.getBoolean("v.CONCEPT_IDENTIFIER_NUMERIC")); vf.setFolderId(rs.getInt("f.ID")); vf.setFolderName(rs.getString("f.IDENTIFIER")); vf.setFolderLabel(rs.getString("f.LABEL")); return vf; } }); String totalSql = "SELECT FOUND_ROWS()"; int totalItems = getJdbcTemplate().queryForInt(totalSql); VocabularyResult result = new VocabularyResult(items, totalItems, filter); return result; }
From source file:models.Group.java
/** * /*from w ww.j a v a 2s.c o m*/ * * @param page 1 * @param pageSize ?? * @param industryId Id? * @param privacy ??? * @param skillTag ? * @param groupName ??? * @param memberUserId ?Id? * @param isOwner ???? * @param orderBy ??????SQL * @param isDesc ??? * @return Page */ public static Page<Group> queryByPage(int page, int pageSize, Long industryId, GroupPriv privacy, String skillTag, String groupName, List<Type> typeList, Long memberUserId, Boolean isOwner, String orderBy, Boolean isDesc) { StringBuilder hql = new StringBuilder(); Map<String, Object> paramMap = new HashMap<>(); hql.append("from Group g "); if (memberUserId != null) { hql.append(" left join g.groupmembers gm where gm.userId = :memberUserId "); paramMap.put("memberUserId", memberUserId); } else { hql.append(" where 1 = 1"); } if (memberUserId != null && isOwner != null) { hql.append(" and ((g.owner.userId ").append(isOwner ? " = " : " <> ") .append(" :ownerUserId and g.type = :hasOwnerType) or g.type <> :hasOwnerType) "); paramMap.put("hasOwnerType", Type.NORMAL); paramMap.put("ownerUserId", memberUserId); } if (CollectionUtils.isNotEmpty(typeList)) { hql.append(" and g.type in (:typeList) "); paramMap.put("typeList", typeList); } if (null != industryId) { hql.append(" and g.industry.id = :industryId "); paramMap.put("industryId", industryId); } if (null != privacy) { hql.append(" and g.groupPriv = :privacy "); paramMap.put("privacy", privacy); } if (StringUtils.isNotBlank(skillTag)) { hql.append(" and g.tags like :skillTag "); paramMap.put("skillTag", "%" + skillTag + "%"); } if (StringUtils.isNotBlank(groupName)) { hql.append(" and g.groupName like :groupName "); paramMap.put("groupName", "%" + groupName + "%"); } String countHql = "select count(g.id) " + hql.toString(); // order if (StringUtils.isNotBlank(orderBy)) { hql.append(" order by g."); hql.append(orderBy); hql.append(BooleanUtils.isFalse(isDesc) ? " asc " : " desc "); } else { hql.append(" order by countMem desc, id desc"); } hql.insert(0, "select g "); TypedQuery<Group> listTypedQuery = JPA.em().createQuery(hql.toString(), Group.class) .setFirstResult((page - 1) * pageSize).setMaxResults(pageSize); TypedQuery<Long> countTypedQuery = JPA.em().createQuery(countHql, Long.class); for (Entry<String, Object> e : paramMap.entrySet()) { listTypedQuery.setParameter(e.getKey(), e.getValue()); countTypedQuery.setParameter(e.getKey(), e.getValue()); } List<Group> resultList = listTypedQuery.getResultList(); Long count = countTypedQuery.getSingleResult(); return new Page<Group>(Constants.SUCESS, count, resultList); }
From source file:com.evolveum.midpoint.provisioning.impl.EntitlementConverter.java
private <T> void collectEntitlementAsObjectOperation( Map<ResourceObjectDiscriminator, Collection<Operation>> roMap, PrismContainerValue<ShadowAssociationType> associationCVal, RefinedObjectClassDefinition objectClassDefinition, PrismObject<ShadowType> shadowBefore, PrismObject<ShadowType> shadowAfter, RefinedResourceSchema rSchema, ResourceType resource, ModificationType modificationType) throws SchemaException { ShadowAssociationType associationType = associationCVal.asContainerable(); QName associationName = associationType.getName(); if (associationName == null) { throw new SchemaException("No name in entitlement association " + associationCVal); }/* w ww .j av a 2 s . c om*/ RefinedAssociationDefinition assocDefType = objectClassDefinition .findEntitlementAssociation(associationName); if (assocDefType == null) { throw new SchemaException( "No entitlement association with name " + assocDefType + " in schema of " + resource); } ResourceObjectAssociationDirectionType direction = assocDefType.getResourceObjectAssociationType() .getDirection(); if (direction != ResourceObjectAssociationDirectionType.OBJECT_TO_SUBJECT) { // Process just this one direction. The other direction was processed before return; } Collection<String> entitlementIntents = assocDefType.getIntents(); if (entitlementIntents == null || entitlementIntents.isEmpty()) { throw new SchemaException( "No entitlement intent specified in association " + associationCVal + " in " + resource); } RefinedObjectClassDefinition entitlementOcDef = rSchema.getRefinedDefinition(ShadowKindType.ENTITLEMENT, entitlementIntents); if (entitlementOcDef == null) { throw new SchemaException("No definition of entitlement intent(s) '" + entitlementIntents + "' specified in association " + associationCVal + " in " + resource); } QName assocAttrName = assocDefType.getResourceObjectAssociationType().getAssociationAttribute(); if (assocAttrName == null) { throw new SchemaException("No association attribute defined in entitlement association in " + resource); } RefinedAttributeDefinition assocAttrDef = entitlementOcDef.findAttributeDefinition(assocAttrName); if (assocAttrDef == null) { throw new SchemaException("Association attribute '" + assocAttrName + "'defined in entitlement association was not found in entitlement intent(s) '" + entitlementIntents + "' in schema for " + resource); } ResourceAttributeContainer identifiersContainer = ShadowUtil.getAttributesContainer(associationCVal, ShadowAssociationType.F_IDENTIFIERS); Collection<ResourceAttribute<?>> identifiers = identifiersContainer.getAttributes(); ResourceObjectDiscriminator disc = new ResourceObjectDiscriminator(entitlementOcDef, identifiers); Collection<Operation> operations = roMap.get(disc); if (operations == null) { operations = new ArrayList<Operation>(); roMap.put(disc, operations); } QName valueAttrName = assocDefType.getResourceObjectAssociationType().getValueAttribute(); if (valueAttrName == null) { throw new SchemaException("No value attribute defined in entitlement association in " + resource); } // Which shadow would we use - shadowBefore or shadowAfter? // // If the operation is ADD or REPLACE, we use current version of the shadow (shadowAfter), because we want // to ensure that we add most-recent data to the subject. // // If the operation is DELETE, we have two possibilities: // - if the resource provides referential integrity, the subject has already // new data (because the object operation was already carried out), so we use shadowAfter // - if the resource does not provide referential integrity, the subject has OLD data // so we use shadowBefore PrismObject<ShadowType> shadow; if (modificationType != ModificationType.DELETE) { shadow = shadowAfter; } else { if (BooleanUtils .isFalse(assocDefType.getResourceObjectAssociationType().isExplicitReferentialIntegrity())) { // i.e. resource has ref integrity by itself shadow = shadowAfter; } else { shadow = shadowBefore; } } ResourceAttribute<T> valueAttr = ShadowUtil.getAttribute(shadow, valueAttrName); if (valueAttr == null) { // TODO: check schema and try to fetch full shadow if necessary throw new SchemaException("No value attribute " + valueAttrName + " in shadow"); } PropertyDelta<T> attributeDelta = null; for (Operation operation : operations) { if (operation instanceof PropertyModificationOperation) { PropertyModificationOperation propOp = (PropertyModificationOperation) operation; if (propOp.getPropertyDelta().getElementName().equals(assocAttrName)) { attributeDelta = propOp.getPropertyDelta(); } } } if (attributeDelta == null) { attributeDelta = assocAttrDef.createEmptyDelta(new ItemPath(ShadowType.F_ATTRIBUTES, assocAttrName)); PropertyModificationOperation attributeModification = new PropertyModificationOperation(attributeDelta); operations.add(attributeModification); } if (modificationType == ModificationType.ADD) { attributeDelta.addValuesToAdd(valueAttr.getClonedValues()); } else if (modificationType == ModificationType.DELETE) { attributeDelta.addValuesToDelete(valueAttr.getClonedValues()); } else if (modificationType == ModificationType.REPLACE) { // TODO: check if already exists attributeDelta.setValuesToReplace(valueAttr.getClonedValues()); } }
From source file:jp.primecloud.auto.process.puppet.PuppetComponentProcess.java
protected Map<String, Object> createInstanceMap(Long componentNo, ComponentProcessContext context, boolean start, Long instanceNo, Map<String, Object> rootMap) { Map<String, Object> map = new HashMap<String, Object>(rootMap); // Instance/*from w w w .ja va 2 s.c o m*/ Instance instance = instanceDao.read(instanceNo); map.put("instance", instance); // PuppetInstance PuppetInstance puppetInstance = puppetInstanceDao.read(instanceNo); map.put("puppetInstance", puppetInstance); // InstanceConfig List<InstanceConfig> instanceConfigs = instanceConfigDao.readByInstanceNo(instanceNo); Map<String, Object> configs = new HashMap<String, Object>(); for (InstanceConfig instanceConfig : instanceConfigs) { if (componentNo.equals(instanceConfig.getComponentNo())) { configs.put(instanceConfig.getConfigName(), instanceConfig.getConfigValue()); } } map.put("instanceConfigs", configs); // Platform Platform platform = platformDao.read(instance.getPlatformNo()); map.put("platform", platform); // TODO CLOUD BRANCHING if (PCCConstant.PLATFORM_TYPE_AWS.equals(platform.getPlatformType())) { // AwsInstance AwsInstance awsInstance = awsInstanceDao.read(instanceNo); map.put("awsInstance", awsInstance); // AwsVolume AwsVolume awsVolume = awsVolumeDao.readByComponentNoAndInstanceNo(componentNo, instanceNo); if (awsVolume != null) { map.put("awsVolume", awsVolume); } } else if (PCCConstant.PLATFORM_TYPE_CLOUDSTACK.equals(platform.getPlatformType())) { // CloudStackInstance CloudstackInstance cloudstackInstance = cloudstackInstanceDao.read(instanceNo); map.put("cloudstackInstance", cloudstackInstance); // CloudStackVolume CloudstackVolume cloudstackVolume = cloudstackVolumeDao.readByComponentNoAndInstanceNo(componentNo, instanceNo); if (cloudstackVolume != null) { map.put("cloudstackVolume", cloudstackVolume); } } else if (PCCConstant.PLATFORM_TYPE_VMWARE.equals(platform.getPlatformType())) { // VmwareInstance VmwareInstance vmwareInstance = vmwareInstanceDao.read(instanceNo); map.put("vmwareInstance", vmwareInstance); // VmwareDisk VmwareDisk vmwareDisk = vmwareDiskDao.readByComponentNoAndInstanceNo(componentNo, instanceNo); if (vmwareDisk != null) { map.put("vmwareDisk", vmwareDisk); } } else if (PCCConstant.PLATFORM_TYPE_NIFTY.equals(platform.getPlatformType())) { // NiftyInstance NiftyInstance niftyInstance = niftyInstanceDao.read(instanceNo); map.put("niftyInstance", niftyInstance); // NiftyVolume NiftyVolume niftyVolume = niftyVolumeDao.readByComponentNoAndInstanceNo(componentNo, instanceNo); if (niftyVolume != null) { map.put("niftyVolume", niftyVolume); } } else if (PCCConstant.PLATFORM_TYPE_VCLOUD.equals(platform.getPlatformType())) { // VcloudInstance VcloudInstance vcloudInstance = vcloudInstanceDao.read(instanceNo); map.put("vcloudInstance", vcloudInstance); // VcloudDisk VcloudDisk vcloudDisk = null; List<VcloudDisk> vcloudDisks = vcloudDiskDao.readByComponentNo(componentNo); for (VcloudDisk tmpVcloudDisk : vcloudDisks) { if (tmpVcloudDisk.getInstanceNo().equals(instanceNo)) { vcloudDisk = tmpVcloudDisk; break; } } if (vcloudDisk != null) { map.put("vcloudDisk", vcloudDisk); } } else if (PCCConstant.PLATFORM_TYPE_AZURE.equals(platform.getPlatformType())) { // AzureInstance AzureInstance azureInstance = azureInstanceDao.read(instanceNo); map.put("azureInstance", azureInstance); // AzureDisk AzureDisk azureDisk = azureDiskDao.readByComponentNoAndInstanceNo(componentNo, instanceNo); if (azureDisk != null) { map.put("azureDisk", azureDisk); } } else if (PCCConstant.PLATFORM_TYPE_OPENSTACK.equals(platform.getPlatformType())) { // OpenstackInstance OpenstackInstance openstackInstance = openstackInstanceDao.read(instanceNo); map.put("openstackInstance", openstackInstance); // OpenstackVolume OpenstackVolume openstackVolume = openstackVolumeDao.readByComponentNoAndInstanceNo(componentNo, instanceNo); if (openstackVolume != null) { map.put("openstackVolume", openstackVolume); } } // IP List<Instance> runningInstances = instanceDao.readInInstanceNos(context.getRunningInstanceNos()); Map<String, String> accessIps = new HashMap<String, String>(); for (Instance runningInstance : runningInstances) { // ?publicIp?? String accessIp = runningInstance.getPublicIp(); if (instance.getPlatformNo().equals(runningInstance.getPlatformNo())) { // ???? // TODO CLOUD BRANCHING if (PCCConstant.PLATFORM_TYPE_AWS.equals(platform.getPlatformType())) { PlatformAws platformAws = platformAwsDao.read(runningInstance.getPlatformNo()); if (BooleanUtils.isFalse(platformAws.getVpc())) { // VPC?????privateIp?? accessIp = runningInstance.getPrivateIp(); } } else if (PCCConstant.PLATFORM_TYPE_CLOUDSTACK.equals(platform.getPlatformType())) { // Cloudstack?publicIp?? accessIp = runningInstance.getPublicIp(); } else if (PCCConstant.PLATFORM_TYPE_VMWARE.equals(platform.getPlatformType())) { // VMware???privateIp?? accessIp = runningInstance.getPrivateIp(); } else if (PCCConstant.PLATFORM_TYPE_NIFTY.equals(platform.getPlatformType())) { // ???privateIp?? accessIp = runningInstance.getPrivateIp(); } else if (PCCConstant.PLATFORM_TYPE_VCLOUD.equals(platform.getPlatformType())) { // VCloud???privateIp?? accessIp = runningInstance.getPrivateIp(); } else if (PCCConstant.PLATFORM_TYPE_AZURE.equals(platform.getPlatformType())) { // Azure???privateIp?? accessIp = runningInstance.getPrivateIp(); } else if (PCCConstant.PLATFORM_TYPE_OPENSTACK.equals(platform.getPlatformType())) { // Openstack?publicIp?? accessIp = runningInstance.getPublicIp(); } } accessIps.put(runningInstance.getInstanceNo().toString(), accessIp); } map.put("accessIps", accessIps); // ???????? boolean unDetachVolume = BooleanUtils.toBoolean(Config.getProperty("unDetachVolume")); map.put("unDetachVolume", unDetachVolume); return map; }
From source file:com.square.core.service.implementations.PersonneServiceImplementation.java
@Override public CoordonneesDto creerOuMettreAJourCoordonnees(CoordonneesDto coordonnees, Boolean impacterFamille, Boolean forcerDesactivationEservices) { final RapportDto rapportCoordonnees = new RapportDto(); if (coordonnees == null) { throw new BusinessException( messageSourceUtil.get(PersonnePhysiqueKeyUtil.MESSAGE_ERREUR_PERSONNE_DTO_NULL)); }/* w w w .j av a 2 s .co m*/ if (coordonnees.getIdPersonne() == null) { throw new BusinessException( messageSourceUtil.get(PersonnePhysiqueKeyUtil.MESSAGE_ERREUR_PERSONNE_NULL)); } final Long idNatureMobilePrive = squareMappingService.getIdNatureMobilePrive(); final Long idNatureMobileTravail = squareMappingService.getIdNatureMobileTravail(); // Controles gnriques (Au moins 1 moyen de communication) boolean unEmailTrouve = false; boolean unTelephoneTrouve = false; if (coordonnees.getEmails() != null) { for (EmailDto email : coordonnees.getEmails()) { if (email.getAdresse() != null && !"".equals(email.getAdresse().trim())) { unEmailTrouve = true; break; } } } if (coordonnees.getTelephones() != null) { for (TelephoneDto telephone : coordonnees.getTelephones()) { if (telephone != null && telephone.getNumero() != null && !"".equals(telephone.getNumero().trim())) { unTelephoneTrouve = true; break; } } } // Rcupration de la personne en base. final Personne personnePrincipale = personneDao.rechercherPersonneParId(coordonnees.getIdPersonne()); if (personnePrincipale == null) { throw new BusinessException( messageSourceUtil.get(PersonnePhysiqueKeyUtil.MESSAGE_ERREUR_PERSONNE_INEXISTANTE)); } final boolean isAdherent = personnePrincipale instanceof PersonnePhysique && ((PersonnePhysique) personnePrincipale).getNature().getId() .equals(squareMappingService.getIdNaturePersonneAdherent()); // Rcupration de la nature de la personne si personne physique Long idNaturePersonnePrincipale = null; final PersonnePhysique personnePrincipalePhysique = personnePhysiqueDao .rechercherPersonneParId(personnePrincipale.getId()); if (personnePrincipalePhysique != null && personnePrincipalePhysique.getNature() != null) { idNaturePersonnePrincipale = personnePrincipalePhysique.getNature().getId(); } final Long idNaturePersonneVivier = squareMappingService.getIdNaturePersonneVivier(); final Long idNaturePersonneBeneficiaireVivier = squareMappingService .getIdNaturePersonneBeneficiaireVivier(); // validationExpressionUtil // .verifierSiVrai(rapport, null, PersonnePhysiqueKeyUtil.MESSAGE_ERREUR_COORDONNEE_OBLIGATOIRE, testUnMoyenDeCommMin, // CoordonneesDto.class.getSimpleName() + ".telephones") // .verifierSiVrai(rapport, null, PersonnePhysiqueKeyUtil.MESSAGE_ERREUR_COORDONNEE_OBLIGATOIRE, testUnMoyenDeCommMin, // CoordonneesDto.class.getSimpleName() + ".emails"); // FIXME Pour le moment, on leve une exception car non pris en charge pour l'affichage de l'interface if (!unEmailTrouve && !unTelephoneTrouve && !idNaturePersonneVivier.equals(idNaturePersonnePrincipale) && !idNaturePersonneBeneficiaireVivier.equals(idNaturePersonnePrincipale)) { throw new BusinessException( messageSourceUtil.get(PersonnePhysiqueKeyUtil.MESSAGE_ERREUR_COORDONNEE_OBLIGATOIRE)); } final Set<Personne> personnes = new LinkedHashSet<Personne>(); // On recherche les membres de la famille de la personne final Set<Personne> famille = getFamille(personnePrincipale); // Si le flag qui indique si l'on doit ajouter la nouvelle adresse aux bnficiaires n'est pas spcifi // Si la personne a une famille, on lve une exception car le flag impacterBeneficiaires doit tre renseign // pour dterminer si il faut ajouter l'adresse aux membres de la famille de la personne if (impacterFamille == null && famille.size() > 0) { throw new ConfirmationImpacterFamilleException( messageSourceUtil.get(PersonnePhysiqueKeyUtil.CONFIRMATION_IMPACTER_FAMILLE, new String[] { String.valueOf(famille.size()) })); } personnes.add(personnePrincipale); if (BooleanUtils.isTrue(impacterFamille)) { // On ajoute les membres de la famille la liste des personnes concernes par la cration de nouvelles coordonnes personnes.addAll(famille); } final Calendar maintenant = Calendar.getInstance(); boolean desactiverEserviceTelephone = false; boolean desactiverEserviceEmail = false; // Traitement des tlphones int nbTelephonesMobile = 0; if (coordonnees.getTelephones() != null && !coordonnees.getTelephones().isEmpty()) { for (int i = 0; i < coordonnees.getTelephones().size(); i++) { final TelephoneDto telephoneDto = coordonnees.getTelephones().get(i); final boolean numeroRenseigne = StringUtils.isNotBlank(telephoneDto.getNumero()); if (telephoneDto.getNature() != null && (telephoneDto.getNature().getIdentifiant().equals(idNatureMobilePrive) || telephoneDto.getNature().getIdentifiant().equals(idNatureMobileTravail)) && numeroRenseigne) { nbTelephonesMobile++; } boolean isTelephoneModifie = false; if (telephoneDto.getId() != null) { // On rcupre le tlphone mettre jour partir de la base de donnes final Telephone telephoneAMaj = telephoneDao.rechercherTelephoneParId(telephoneDto.getId()); // Si on recoit un id ici, mais que le numro n'est pas renseign, il faut supprimer le tlphone correspondant // Note : on ne supprime pas tous les tlphones car d'autres peuvent exister mais ne pas tre affichs dans Square if (!numeroRenseigne) { // Si il faut impacter toute la famille, ou que le tlphone est li la personne principale uniquement if (BooleanUtils.isTrue(impacterFamille) || telephoneAMaj.getPersonnes().size() == 1) { // On supprime le tlphone supprimerTelephone(telephoneAMaj, maintenant); } else { // On enlve le tlphone de la liste des tlphones de la personne principale personnePrincipale.removeTelephone(telephoneAMaj); // on verifie si la personne est le porteur if (telephoneAMaj.getPorteurUid() != null && telephoneAMaj.getPorteurUid().equals(personnePrincipale.getId())) { // on supprime l'identifiant externe et le porteur du telephone restant sur la famille telephoneAMaj.setIdentifiantExterieur(null); telephoneAMaj.setPorteurUid(null); } } continue; } else { // Sinon on dtermine si le tlphone a t modifi isTelephoneModifie = isTelephoneModifie(telephoneAMaj, telephoneDto); // Si le tlphone existe et a t modifi, et qu'il ne faut pas impacter la famille if (BooleanUtils.isFalse(impacterFamille) && isTelephoneModifie && telephoneAMaj.getPersonnes().size() > 1) { // on supprime le telephone de la personne personnePrincipale.removeTelephone(telephoneAMaj); // on supprime l'identifiant pour crer un nouveau telephone telephoneDto.setId(null); // on verifie si la personne est le porteur if (telephoneAMaj.getPorteurUid() != null && telephoneAMaj.getPorteurUid().equals(personnePrincipale.getId())) { // on supprime l'identifiant externe et le porteur du telephone restant sur la famille (pas de synchro aia) telephoneAMaj.setIdentifiantExterieur(null); telephoneAMaj.setPorteurUid(null); } else { // On supprime l'identifiant externe afin de ne pas synchroniser avec aia telephoneDto.setIdext(null); } } } } if (numeroRenseigne) { final RapportDto rapportTelephone = new RapportDto(); controlerTelephone(rapportTelephone, telephoneDto, i); if (rapportTelephone.getRapports() != null && !rapportTelephone.getRapports().isEmpty()) { for (String key : rapportTelephone.getRapports().keySet()) { final SousRapportDto sousRapport = rapportTelephone.getRapports().get(key); rapportCoordonnees.ajoutRapport(sousRapport.getAttribut(), sousRapport.getMessage(), sousRapport.getErreur()); } } if (!rapportTelephone.getEnErreur()) { final Telephone telephone = creerOuMettreAJourTelephone(personnes, telephoneDto, impacterFamille); if (telephone.getId() == null) { // On rattache le tlphone la personne principale personnePrincipale.addTelephone(telephone); if (BooleanUtils.isTrue(impacterFamille)) { // On rattache aussi le tlphone aux membres de sa famille for (Personne personne : famille) { // bug 8832 : on impacte que ceux qui n'ont pas deja de telephones if (personne.getTelephones().size() == 0) { personne.addTelephone(telephone); } } } } } } } } // on desactive l'envoi par telephone if (nbTelephonesMobile == 0 && isAdherent) { // on verifie si la personne possede l'eservice final List<Long> optionsSouscrites = adherentService .getListeIdsTypesOptionsSouscrites(personnePrincipale.getId()); boolean possedeEserviceTelephone = false; for (Long idTypeOption : optionsSouscrites) { if (idTypeOption.equals(adherentMappingService.getIdTypeOptionEnvoiSms())) { possedeEserviceTelephone = true; break; } } desactiverEserviceTelephone = possedeEserviceTelephone; } // Traitement des emails if (coordonnees.getEmails() != null && !coordonnees.getEmails().isEmpty()) { for (int i = 0; i < coordonnees.getEmails().size(); i++) { final EmailDto emailDto = coordonnees.getEmails().get(i); final boolean adresseEmailRenseignee = StringUtils.isNotBlank(emailDto.getAdresse()); boolean isEmailModifie = false; // FIXME : La constante nature de l'email devrait elle etre fournie par le client ? emailDto.setNatureEmail( new IdentifiantLibelleDto(squareMappingService.getIdNatureEmailPersonnel())); if (emailDto.getIdentifiant() != null) { // On rcupre l'email mettre jour partir de la base de donnes final Email emailAMaj = emailDao.rechercherEmailParId(emailDto.getIdentifiant()); // Si on recoit un id ici, mais que les infos ne sont pas renseignes, il faut supprimer le tlphone correspondant // Note : on ne supprime pas tous les tlphones car d'autres peuvent exister mais ne pas tre affichs dans Square if (!adresseEmailRenseignee) { // Si il faut impacter toute la famille, ou que l'email est li la personne principale uniquement if (BooleanUtils.isTrue(impacterFamille) || emailAMaj.getPersonnes().size() == 1) { // On supprime l'email supprimerEmail(emailAMaj, maintenant); } else { // On enlve le tlphone de la liste des tlphones de la personne principale personnePrincipale.removeEmail(emailAMaj); // on verifie si la personne est le porteur if (emailAMaj.getPorteurUid() != null && emailAMaj.getPorteurUid().equals(personnePrincipale.getId())) { // on supprime l'identifiant externe et le porteur de l'email restant sur la famille emailAMaj.setIdentifiantExterieur(null); emailAMaj.setPorteurUid(null); } } if (isAdherent) { // on verifie si la personne possede l'eservice final List<Long> optionsSouscrites = adherentService .getListeIdsTypesOptionsSouscrites(personnePrincipale.getId()); boolean possedeEserviceEmail = false; for (Long idTypeOption : optionsSouscrites) { if (idTypeOption .equals(adherentMappingService.getIdTypeOptionEnvoiMutuellementEmail()) || idTypeOption.equals(adherentMappingService .getIdTypeOptionEnvoiRelevesPrestationEmail())) { possedeEserviceEmail = true; break; } } desactiverEserviceEmail = possedeEserviceEmail; } continue; } else { // Sinon on dtermine si l'email a t modifi isEmailModifie = isEmailModifie(emailAMaj, emailDto); // Si le tlphone existe et a t modifi, et qu'il ne faut pas impacter la famille if (BooleanUtils.isFalse(impacterFamille) && isEmailModifie && emailAMaj.getPersonnes().size() > 1) { // on supprime l'email de la personne personnePrincipale.removeEmail(emailAMaj); // on supprime l'identifiant pour crer un nouvel email emailDto.setIdentifiant(null); // on verifie si la personne est le porteur if (emailAMaj.getPorteurUid() != null && emailAMaj.getPorteurUid().equals(personnePrincipale.getId())) { // on supprime l'identifiant externe et le porteur de l'email restant sur la famille (pas de synchro aia) emailAMaj.setIdentifiantExterieur(null); emailAMaj.setPorteurUid(null); } else { // On supprime l'identifiant externe afin de ne pas synchroniser avec aia emailDto.setIdext(null); } } } } if (adresseEmailRenseignee) { final RapportDto rapportEmail = new RapportDto(); controlerEmail(rapportEmail, emailDto, i); if (rapportEmail.getRapports() != null && !rapportEmail.getRapports().isEmpty()) { for (String key : rapportEmail.getRapports().keySet()) { final SousRapportDto sousRapport = rapportEmail.getRapports().get(key); rapportCoordonnees.ajoutRapport(sousRapport.getAttribut(), sousRapport.getMessage(), sousRapport.getErreur()); } } if (!rapportEmail.getEnErreur()) { final Email email = creerOuMettreAJourEmail(personnes, emailDto, impacterFamille); // Si c'est un nouvel email if (email.getId() == null) { // On rattache le nouvel email la personne principale personnePrincipale.addEMail(email); if (BooleanUtils.isTrue(impacterFamille)) { // On rattache aussi le nouvel email aux membres de sa famille for (Personne personne : famille) { // bug 8832 : on impacte que ceux qui n'ont pas deja d'emails if (personne.getEmails().size() == 0) { personne.addEMail(email); } } } } } } } } // on desactive les eservices suivant les besoins if (!BooleanUtils.isTrue(forcerDesactivationEservices)) { if (desactiverEserviceTelephone && desactiverEserviceEmail) { throw new ConfirmationDesactivationEserviceException(messageSourceUtil .get(PersonneKeyUtil.MESSAGE_CONFIRMATION_DESACTIVATION_ESERVICE_TELEPHONE_ET_EMAIL)); } else if (desactiverEserviceTelephone) { throw new ConfirmationDesactivationEserviceException(messageSourceUtil .get(PersonneKeyUtil.MESSAGE_CONFIRMATION_DESACTIVATION_ESERVICE_TELEPHONE)); } else if (desactiverEserviceEmail) { throw new ConfirmationDesactivationEserviceException( messageSourceUtil.get(PersonneKeyUtil.MESSAGE_CONFIRMATION_DESACTIVATION_ESERVICE_EMAIL)); } } else { if (desactiverEserviceTelephone) { adherentService.desactiverOptionsEnvoiParTelephone(personnePrincipale.getId()); } if (desactiverEserviceEmail) { adherentService.desactiverOptionsEnvoiParEmail(personnePrincipale.getId()); } } // Recherche de l'adresse principale en cours final AdresseCriteresRechercheDto criteresRechercheAdressePrincipale = new AdresseCriteresRechercheDto(); criteresRechercheAdressePrincipale.setIdPersonne(personnePrincipale.getId()); criteresRechercheAdressePrincipale.setIdNature(squareMappingService.getIdNatureAdressePrincipale()); criteresRechercheAdressePrincipale.setActive(true); final List<Adresse> listAddressesPrin = adresseDao .rechercherAdresseParCritere(criteresRechercheAdressePrincipale); Adresse adressePrincipaleEnCours = new Adresse(); boolean plusQueAdressePrincipale = false; boolean choixPasserEnSecondaire = false; if (listAddressesPrin != null && listAddressesPrin.size() > 0) { adressePrincipaleEnCours = listAddressesPrin.get(0); } Calendar dateFinAdressePrincipale = null; // Traitement des adresses if (coordonnees.getAdresses() != null && !coordonnees.getAdresses().isEmpty()) { final RapportDto rapportAdresses = new RapportDto(); for (int i = 0; i < coordonnees.getAdresses().size(); i++) { final AdresseDto adresseDto = coordonnees.getAdresses().get(i); if (adresseDto.getNature() != null && adresseDto.getNature().getIdentifiant() .equals(squareMappingService.getIdNatureAdressePrincipale()) && adressePrincipaleEnCours.getId() != null && !adressePrincipaleEnCours.getId().equals(adresseDto.getIdentifiant()) && (adresseDto.getDateFin() == null || Calendar.getInstance().before(adresseDto.getDateFin()))) { dateFinAdressePrincipale = adresseDto.getDateDebut(); if (!choixPasserEnSecondaire) { choixPasserEnSecondaire = adresseDto.getChoixPasserEnSecondaire() == null ? false : adresseDto.getChoixPasserEnSecondaire().booleanValue(); } plusQueAdressePrincipale = true; } final RapportDto rapportAdresse = new RapportDto(); controlerAdresse(rapportAdresse, adresseDto, i); if (rapportAdresse.getRapports() != null && !rapportAdresse.getRapports().isEmpty()) { for (String key : rapportAdresse.getRapports().keySet()) { final SousRapportDto sousRapport = rapportAdresse.getRapports().get(key); rapportCoordonnees.ajoutRapport(sousRapport.getAttribut(), sousRapport.getMessage(), sousRapport.getErreur()); } } if (!rapportAdresse.getEnErreur()) { if (adresseDto.getIdentifiant() != null) { final Adresse adresseAMaj = adresseDao.rechercherAdresseParId(adresseDto.getIdentifiant()); final boolean isAdresseModifiee = isAdresseModifiee(adresseAMaj, adresseDto); // Si l'adresse existe et a t modifie, et qu'il ne faut pas impacter la famille if (BooleanUtils.isFalse(impacterFamille) && isAdresseModifiee && adresseAMaj.getPersonnes().size() > 1) { // on supprime l'adresse de la personne personnePrincipale.removeAdresse(adresseAMaj); // On supprime l'identifiant de l'adresse afin de crer une nouvelle adresse adresseDto.setIdentifiant(null); // on verifie si la personne est le porteur if (adresseAMaj.getPorteurUid() != null && adresseAMaj.getPorteurUid().equals(personnePrincipale.getId())) { // on supprime l'identifiant externe et le porteur de l'adresse restante sur la famille (pas de synchro aia) adresseAMaj.setIdentifiantExterieur(null); adresseAMaj.setPorteurUid(null); } else { // On supprime l'identifiant externe pour ne pas synchroniser avec aia adresseDto.setIdext(null); } } } final Adresse adresseCree = creerOuMettreAJourAdresse(personnes, adresseDto, impacterFamille); // on met l'id ext jour apres la cration (probleme de flush a cause de la contrainte d'unicit) adresseCree.setIdentifiantExterieur(adresseDto.getIdext()); } } final AdresseNature adresseNature = adresseNatureDao .rechercheAdresseNatureParId(squareMappingService.getIdNatureAdresseSecondaire()); // si le rapport n'est pas en erreur, on met jour l'adresse principale if (Boolean.FALSE.equals(rapportAdresses.getEnErreur())) { for (int i = 0; i < coordonnees.getAdresses().size(); i++) { final AdresseDto adresseDto = coordonnees.getAdresses().get(i); if (plusQueAdressePrincipale && (adressePrincipaleEnCours.getId().equals(adresseDto.getIdentifiant()))) { if (choixPasserEnSecondaire) { adressePrincipaleEnCours.setNature(adresseNature); } else { dateFinAdressePrincipale.add(Calendar.DAY_OF_MONTH, -1); adressePrincipaleEnCours.setDateFin(dateFinAdressePrincipale); } break; } } } } if (Boolean.TRUE.equals(rapportCoordonnees.getEnErreur()) && !idNaturePersonneVivier.equals(idNaturePersonnePrincipale) && !idNaturePersonneBeneficiaireVivier.equals(idNaturePersonnePrincipale)) { RapportUtil.logRapport(rapportCoordonnees, logger); throw new ControleIntegriteException(rapportCoordonnees); } /* * // Un contact devra avoir au moins une adresse principal criteresRechercheAdressePrincipale = new AdresseCriteresRechercheDto(); * criteresRechercheAdressePrincipale.setIdPersonne(personne.getId()); * criteresRechercheAdressePrincipale.setIdNature(squareMappingService.getIdNatureAdressePrincipale()); long nbPrimaires = * adresseDao.rechercherIdAdressesParCriteres(criteresRechercheAdressePrincipale).size(); if (nbPrimaires == 0) { throw new * BusinessException(messageSourceUtil.get(PersonnePhysiqueKeyUtil.MESSAGE_ERREUR_AUCUNE_ADRESSE_PRINCIPALE)); } else if (nbPrimaires > 1) { throw new * BusinessException(messageSourceUtil.get(PersonnePhysiqueKeyUtil.MESSAGE_ERREUR_ADRESSE_PRINCIPALE_DUPLIQUEE)); } */ // 2.13 Une date de fin ne pourra etre mis sur une adresse principal que s'il existe une adresse secondaire. // Dans ce cas l'adresse principal deviendra automatiquement secondaire et l'adresse secondaire deviendra principal Adresse adressePrincipale = null; Adresse adresseSecondaire = null; for (Adresse adresse : personnePrincipale.getAdresses()) { if (adresse.getNature().getId().equals(squareMappingService.getIdNatureAdressePrincipale())) { adressePrincipale = adresse; } if (adresse.getNature().getId().equals(squareMappingService.getIdNatureAdresseSecondaire()) && adresse.getDateFin() == null) { adresseSecondaire = adresse; } } if (adressePrincipale != null && adressePrincipale.getDateFin() != null && adresseSecondaire != null) { // Changement adresse principale adresse secondaire adressePrincipale.setNature(adresseNatureDao .rechercheAdresseNatureParId(squareMappingService.getIdNatureAdresseSecondaire())); adresseSecondaire.setNature(adresseNatureDao .rechercheAdresseNatureParId(squareMappingService.getIdNatureAdressePrincipale())); // Enregistrement des adresses final AdresseDto adresseDtoPrincipal = mapperDozerBean.map(adressePrincipale, AdresseDto.class); final AdresseDto adresseDtoSecondaire = mapperDozerBean.map(adresseSecondaire, AdresseDto.class); creerOuMettreAJourAdresse(personnes, adresseDtoPrincipal, impacterFamille); creerOuMettreAJourAdresse(personnes, adresseDtoSecondaire, impacterFamille); } if (!idNaturePersonneVivier.equals(idNaturePersonnePrincipale) && !idNaturePersonneBeneficiaireVivier.equals(idNaturePersonnePrincipale)) { controlerPersonneAUneAdressePrincipale(personnePrincipale); } // si il s'agit d'une personne physique et vivier ou bnficiaire vivier, on transforme en prospect ou bnficiaire prospect boolean vivierToProspect = false; boolean hasNaturePersonneChanged = false; String ancienneNaturePersonne = ""; String nouvelleNaturePersonne = ""; if (personnePrincipalePhysique != null && personnePrincipalePhysique.getNature() != null) { ancienneNaturePersonne = personnePrincipalePhysique.getNature().getLibelle(); Long idNaturePersonne = null; if (idNaturePersonneVivier.equals(idNaturePersonnePrincipale) && validationPersonneUtil.verifierContrainteProspect(personnePrincipalePhysique)) { idNaturePersonne = squareMappingService.getIdNaturePersonneProspect(); vivierToProspect = true; hasNaturePersonneChanged = true; } else if (idNaturePersonneBeneficiaireVivier.equals(idNaturePersonnePrincipale) && validationPersonneUtil.verifierContrainteBeneficiaireProspect(personnePrincipalePhysique)) { idNaturePersonne = squareMappingService.getIdNaturePersonneBeneficiaireProspect(); hasNaturePersonneChanged = true; } if (idNaturePersonne != null) { final PersonnePhysiqueNature naturePersonne = personnePhysiqueNatureDao .rechercherPersonnePhysiqueParId(idNaturePersonne); if (naturePersonne != null) { nouvelleNaturePersonne = naturePersonne.getLibelle(); } personnePrincipalePhysique.setNature(naturePersonne); } } // si la personne est passe de vivier prospect et qu'elle a des bnficiaires vivier, // on essaye de les passer en bnficiaire prospect si c'est possible if (vivierToProspect && famille != null && famille.size() > 0) { for (Personne beneficiaire : famille) { final PersonnePhysique beneficiairePhysique = (PersonnePhysique) beneficiaire; if (beneficiairePhysique.getNature() != null && idNaturePersonneBeneficiaireVivier.equals(beneficiairePhysique.getNature().getId()) && validationPersonneUtil.verifierContrainteBeneficiaireProspect(beneficiairePhysique)) { final PersonnePhysiqueNature naturePersonne = personnePhysiqueNatureDao .rechercherPersonnePhysiqueParId( squareMappingService.getIdNaturePersonneBeneficiaireProspect()); beneficiairePhysique.setNature(naturePersonne); } } } final CoordonneesDto newCoordonnees = rechercherCoordonneesParIdPersonne(personnePrincipale.getId()); newCoordonnees.setHasNaturePersonneChanged(hasNaturePersonneChanged); newCoordonnees.setAncienneNaturePersonne(ancienneNaturePersonne); newCoordonnees.setNouvelleNaturePersonne(nouvelleNaturePersonne); return newCoordonnees; }