Example usage for org.apache.commons.lang WordUtils capitalizeFully

List of usage examples for org.apache.commons.lang WordUtils capitalizeFully

Introduction

In this page you can find the example usage for org.apache.commons.lang WordUtils capitalizeFully.

Prototype

public static String capitalizeFully(String str, char[] delimiters) 

Source Link

Document

Converts all the delimiter separated words in a String into capitalized words, that is each word is made up of a titlecase character and then a series of lowercase characters.

Usage

From source file:io.swagger.codegen.languages.SwiftCodegen.java

public String toSwiftyEnumName(String value) {
    // Prevent from breaking properly cased identifier
    if (value.matches("[A-Z][a-z0-9]+[a-zA-Z0-9]*")) {
        return value;
    }/*  w  w  w . j a v  a 2  s. c o m*/
    char[] separators = { '-', '_', ' ' };
    return WordUtils.capitalizeFully(StringUtils.lowerCase(value), separators).replaceAll("[-_ ]", "");
}

From source file:com.square.client.gwt.server.service.PersonneServiceGwtImpl.java

/**
 * Ajouter les relations.// w  w  w. j a  v a 2  s  .  c o  m
 * @param datasRelations les donnes en cours.
 * @param idPersonnePrincipal identifiant de la personne cible.
 * @param nomPersonne le nom de la personne.
 */
private void ajouterRelations(List<String[]> datasRelations, final Long idPersonnePrincipal, boolean twoWay,
        List<Long> filtreGroupements, List<Long> filtrePasDansGroupements) {

    // On va commencer par dterminer si la personne est une personne physique ou morale
    final PersonneBaseModel personnePrincipal = rechercherPersonneParId(idPersonnePrincipal);
    if (personnePrincipal != null) {
        // Si c'est une personne morale, on garde l'ancien traitement
        if (personnePrincipal instanceof PersonneMoraleModel) {
            Integer age = 0;
            final RelationCriteresRechercheDto criteres = new RelationCriteresRechercheDto();
            if (!twoWay) {
                criteres.setIdPersonneSource(idPersonnePrincipal);
            } else {
                criteres.setIdPersonne(idPersonnePrincipal);
            }
            criteres.setGroupements(filtreGroupements);
            criteres.setPasDansGroupements(filtrePasDansGroupements);
            final RemotePagingCriteriasDto<RelationCriteresRechercheDto> criterias = new RemotePagingCriteriasDto<RelationCriteresRechercheDto>(
                    criteres, 0, Integer.MAX_VALUE);

            final RemotePagingResultsDto<RelationInfosDto<? extends PersonneRelationDto>> result = personneService
                    .rechercherRelationsParCritreres(criterias);

            if (result.getListResults() != null && result.getListResults().size() > 0) {
                for (RelationInfosDto<? extends PersonneRelationDto> personne : result.getListResults()) {
                    String nom = "";
                    if (personne.getPersonne() instanceof PersonneMoraleRelationDto) {
                        final PersonneMoraleRelationDto personneMorale = (PersonneMoraleRelationDto) personne
                                .getPersonne();
                        nom += personneMorale.getRaisonSociale().toUpperCase();
                    } else {
                        final PersonnePhysiqueRelationDto personnePhysique = (PersonnePhysiqueRelationDto) personne
                                .getPersonne();
                        final char[] delimiters = { ' ', '-', '_' };
                        final String prenomMisEnForme = WordUtils.capitalizeFully(personnePhysique.getPrenom(),
                                delimiters);
                        nom += personnePhysique.getNom().toUpperCase() + " " + prenomMisEnForme;
                        final PersonneSimpleDto personneSimpleDto = personnePhysiqueService
                                .rechercherPersonneSimpleParIdentifiant(personnePhysique.getId());
                        final String[] ageString = personneSimpleDto.getAge().split(" ");
                        if (ageString.length > 0) {
                            age = Integer.parseInt(ageString[0]);
                        }
                    }
                    final String etatRelation = (personne.getDateFin() != null) ? "Relation Termine"
                            : "Relation en cours";
                    final String[] data = new String[] { personne.getPersonne().getId().toString(),
                            idPersonnePrincipal.toString(), etatRelation, nom, personne.getType().getLibelle(),
                            age.toString() };
                    datasRelations.add(data);
                }
            }
        }
        // Si c'est une personne physique, on va rorganiser les lments de faon gnalogique
        else if (personnePrincipal instanceof PersonneModel) {
            Integer age = 0;
            final RelationCriteresRechercheDto criteres = new RelationCriteresRechercheDto();

            final List<RelationInfosDto<? extends PersonneRelationDto>> listeParents = new ArrayList<RelationInfosDto<? extends PersonneRelationDto>>();
            final List<RelationInfosDto<? extends PersonneRelationDto>> listeConjoints = new ArrayList<RelationInfosDto<? extends PersonneRelationDto>>();
            final List<RelationInfosDto<? extends PersonneRelationDto>> listeEnfants = new ArrayList<RelationInfosDto<? extends PersonneRelationDto>>();

            // dans tous les cas, on rcupre les relations dont la personne est source
            criteres.setIdPersonneSource(idPersonnePrincipal);
            criteres.setGroupements(filtreGroupements);
            criteres.setPasDansGroupements(filtrePasDansGroupements);
            final RemotePagingCriteriasDto<RelationCriteresRechercheDto> criteriasSource = new RemotePagingCriteriasDto<RelationCriteresRechercheDto>(
                    criteres, 0, Integer.MAX_VALUE);

            final RemotePagingResultsDto<RelationInfosDto<? extends PersonneRelationDto>> resultSource = personneService
                    .rechercherRelationsParCritreres(criteriasSource);

            if (resultSource.getListResults() != null && resultSource.getListResults().size() > 0) {
                for (RelationInfosDto<? extends PersonneRelationDto> personne : resultSource.getListResults()) {
                    if (personne.getType().getIdentifiant()
                            .equals(squareMappingService.getIdTypeRelationConjoint())) {
                        listeConjoints.add(personne);
                    } else {
                        listeEnfants.add(personne);
                    }
                }
            }
            // Si on les veux, on rcupre  part les relations dont la personne est la cible
            // c'est  dire les relations a pour parent et est le conjoint de
            if (twoWay) {
                criteres.setIdPersonneSource(null);
                criteres.setIdPersonne(idPersonnePrincipal);
                final RemotePagingCriteriasDto<RelationCriteresRechercheDto> criteriasCible = new RemotePagingCriteriasDto<RelationCriteresRechercheDto>(
                        criteres, 0, Integer.MAX_VALUE);

                final RemotePagingResultsDto<RelationInfosDto<? extends PersonneRelationDto>> resultCible = personneService
                        .rechercherRelationsParCritreres(criteriasCible);

                if (resultCible.getListResults() != null && resultCible.getListResults().size() > 0) {
                    for (RelationInfosDto<? extends PersonneRelationDto> personne : resultCible
                            .getListResults()) {

                        // On s'assure que la relation n'existe pas dja
                        boolean existeDeja = false;
                        for (RelationInfosDto<? extends PersonneRelationDto> relationEnfant : listeEnfants) {
                            if (relationEnfant.getId().equals(personne.getId())) {
                                existeDeja = true;
                            }
                        }
                        for (RelationInfosDto<? extends PersonneRelationDto> relationConjoint : listeConjoints) {
                            if (relationConjoint.getId().equals(personne.getId())) {
                                existeDeja = true;
                            }
                        }
                        if (!existeDeja) {
                            if (personne.getType().getIdentifiant()
                                    .equals(squareMappingService.getIdTypeRelationEnfant())) {
                                listeParents.add(personne);
                            } else {
                                listeConjoints.add(personne);
                            }
                        }
                    }
                }
            }
            // On fabrique une liste de relations tries
            final List<RelationInfosDto<? extends PersonneRelationDto>> listePersonnes = new ArrayList<RelationInfosDto<? extends PersonneRelationDto>>();
            listePersonnes.addAll(listeParents);
            listePersonnes.addAll(listeConjoints);
            listePersonnes.addAll(listeEnfants);

            // On retire la personne de la liste
            final String[] dataPersonne = datasRelations.get(0);
            datasRelations.clear();

            // On renmplie la liste avec les personnes dja tries
            for (RelationInfosDto<? extends PersonneRelationDto> personne : listePersonnes) {
                String nom = "";
                String etatRelation;
                if (listeParents.contains(personne)) {
                    etatRelation = "Parent";
                } else if (listeConjoints.contains(personne)) {
                    etatRelation = "Conjoint";
                } else {
                    etatRelation = "Enfant";
                }
                final PersonnePhysiqueRelationDto personnePhysique = (PersonnePhysiqueRelationDto) personne
                        .getPersonne();
                final char[] delimiters = { ' ', '-', '_' };
                final String prenomMisEnForme = WordUtils.capitalizeFully(personnePhysique.getPrenom(),
                        delimiters);
                nom += personnePhysique.getNom().toUpperCase() + " " + prenomMisEnForme;
                final PersonneSimpleDto personneSimpleDto = personnePhysiqueService
                        .rechercherPersonneSimpleParIdentifiant(personnePhysique.getId());
                final String[] ageString = personneSimpleDto.getAge().split(" ");
                if (ageString.length > 0) {
                    age = Integer.parseInt(ageString[0]);
                }
                if (personne.getDateFin() != null) {
                    etatRelation = "Relation Termine";
                }
                final String[] data = new String[] { personne.getPersonne().getId().toString(),
                        idPersonnePrincipal.toString(), etatRelation, nom, personne.getType().getLibelle(),
                        age.toString() };
                datasRelations.add(data);
            }

            // On rinsre la personne dans la liste aprs ses parents
            datasRelations.add(listeParents.size(), dataPersonne);

            // On fait pointer chaque parent sur lui mme
            if (!listeParents.isEmpty()) {
                for (int i = 0; i < listeParents.size(); i++) {
                    datasRelations.get(i)[1] = datasRelations.get(i)[0];
                }
                // On fait pointer la personne sur le dernier parent de la liste
                datasRelations.get(listeParents.size())[1] = datasRelations.get(listeParents.size() - 1)[0];
            }
            // Si pas de parents, la personne pointe sur elle mme
            else {
                datasRelations.get(0)[1] = datasRelations.get(0)[0];
            }
            // Si on a des conjoints, on les fait pointer sur la bonne personne
            if (!listeConjoints.isEmpty()) {
                // On fait pointer les conjoints sur le dernier parent
                for (int i = 0; i < listeConjoints.size(); i++) {
                    if (!listeParents.isEmpty()) {
                        datasRelations.get(listeParents.size() + i + 1)[1] = datasRelations
                                .get(listeParents.size() - 1)[0];
                    }
                    // Si pas de parents, on fait pointer sur lui-mme
                    else {
                        datasRelations.get(i + 1)[1] = datasRelations.get(i + 1)[0];
                    }
                }
            }
        } // fin bloc personne physique
    } // fin bloc personne existe
}

From source file:com.square.tarificateur.noyau.service.implementations.TarificateurEditiqueServiceImpl.java

/**
 * Gnre la liste des documents PDF.//  www  .ja  v a2  s.co  m
 * @param editionDocumentDto le DTO contenant les infos d'dition
 * @param infosPersonneSquare le cache des infos de personnes Square
 * @param infosOpportuniteSquare le cache des infos d'opportunits Square
 * @param devis le devis
 * @return la liste des fichiers gnrs
 */
private List<FichierModeleBean> genererDocumentsPdf(EditionDocumentDto editionDocumentDto,
        InfosPersonneSquareBean infosPersonneSquare, InfosOpportuniteSquareBean infosOpportuniteSquare,
        Devis devis) {
    logger.info(messageSourceUtil.get(MessageKeyUtil.LOGGER_INFO_DEMANDE_DEVIS_PDF,
            new String[] { String.valueOf(editionDocumentDto.getIdentifiantDevis()) }));
    // Lignes slectionnes  imprimer > 0
    if (editionDocumentDto.getIdsLigneDevisSelection() == null
            || editionDocumentDto.getIdsLigneDevisSelection().size() == 0) {
        throw new BusinessException(
                messageSourceUtil.get(MessageKeyUtil.ERROR_LIGNE_DEVIS_SELECTIONNEE_OBLIGATOIRE));
    }
    // On vrifie qu'au moins un modle de devis a t spcifi
    final List<Long> idsModelesDevisSelectionnes = editionDocumentDto.getIdsModelesDevisSelectionnes();
    if (idsModelesDevisSelectionnes == null || idsModelesDevisSelectionnes.isEmpty()) {
        throw new BusinessException(
                messageSourceUtil.get(MessageKeyUtil.ERROR_MODELE_DEVIS_SELECTIONNE_OBLIGATOIRE));
    }

    // Rcupration de l'opportunit Square associ au devis
    final OpportuniteSimpleDto opportuniteSquare = opportuniteUtil
            .getOpportuniteSimple(devis.getOpportunite().getEidOpportunite(), infosOpportuniteSquare);

    // Rcupration de l'agence de la personne du devis
    final com.square.core.model.dto.PersonneDto personneSquare = personneUtil
            .getPersonnePhysique(devis.getPersonnePrincipale().getEidPersonne(), infosPersonneSquare);
    final Long eidAgence = Long.valueOf(personneSquare.getAgence().getIdentifiantExterieur());
    if (eidAgence == null) {
        logger.error(messageSourceUtil.get(MessageKeyUtil.LOGGER_ERROR_ABSCENCE_AGENCE_PERSONNE_OPPORTUNITE,
                new String[] { String.valueOf(devis.getOpportunite().getEidOpportunite()) }));
        throw new BusinessException(
                messageSourceUtil.get(MessageKeyUtil.ERREUR_GENERATION_DOCUMENT_AGENCE_OBLIGATOIRE));
    }

    // Rcupration des constantes
    final Long idModeleDevisBulletinAdhesion = editiqueMappingService
            .getConstanteIdModeleDevisBulletinAdhesion();
    final Long idModeleDevisFicheTransfert = editiqueMappingService.getConstanteIdModeleDevisFicheTransfert();
    final Long idModeleLetteAnnulation = editiqueMappingService.getConstanteIdModeleLettreAnnulation();
    final Long idModeleLettreRadiation = editiqueMappingService.getConstanteIdModeleLettreRadiation();
    final Long idModeleLettreRadiationLoiChatel = editiqueMappingService
            .getConstanteIdModeleLettreRadiationLoiChatel();
    final List<FichierModeleBean> fichiersGeneres = new ArrayList<FichierModeleBean>();
    for (Long idModeleDevis : idsModelesDevisSelectionnes) {
        if (idModeleDevis == null) {
            logger.error(messageSourceUtil.get(MessageKeyUtil.LOGGER_ERROR_MODELE_DEVIS_NON_RENSEIGNER));
            throw new BusinessException(messageSourceUtil.get(MessageKeyUtil.ERROR_MODELE_DEVIS_INCOMPATIBLE));
        } else if (!(idModeleDevis.equals(idModeleDevisBulletinAdhesion)
                || idModeleDevis.equals(idModeleDevisFicheTransfert)
                || idModeleDevis.equals(idModeleLetteAnnulation)
                || idModeleDevis.equals(idModeleLettreRadiation)
                || idModeleDevis.equals(idModeleLettreRadiationLoiChatel))) {
            logger.error(messageSourceUtil
                    .get(MessageKeyUtil.LOGGER_ERROR_MODELE_DEVIS_IS_NOT_BULLETIN_ADHESION_OU_FICHE_TRANSFERT));
            throw new BusinessException(messageSourceUtil.get(MessageKeyUtil.ERROR_MODELE_DEVIS_INCOMPATIBLE));
        }

        if (idModeleDevis.equals(idModeleLetteAnnulation)) {
            // On gnre la lettre d'annulation
            final LettreAnnulationDto lettreAnnulation = new LettreAnnulationDto();

            // Rcupration des informations de l'agence responsable de l'opportunit.
            final AgenceReelleDto agenceResponsable = agenceService.getAgenceReelleById(eidAgence);
            // Cration de l'agence
            final AgenceEditiqueDto agence = new AgenceEditiqueDto();
            agence.setDenomination(agenceResponsable.getDenomination());
            agence.setNumeroTelephone(utilisateurMappingService.getNumeroTelephoneUnique());
            agence.setAdresse((AdresseDto) mapperDozerBean.map(agenceResponsable, AdresseDto.class));
            lettreAnnulation.setAgence(agence);

            final Adhesion adhesion = devis.getOpportunite().getAdhesion();
            adhesion.setDateCourrier(Calendar.getInstance());

            // Rcupration de la rfrence
            final String reference = opportuniteSquare.getEidOpportunite();
            lettreAnnulation.setNumeroDossier(reference);
            lettreAnnulation.setDateCourrier(adhesion.getDateCourrier());
            lettreAnnulation.setDateCreationAdhesion(adhesion.getDateSignature());

            // Cration du prospect
            final Personne personneCiblee = devis.getPersonnePrincipale();
            // Rcupration du Prospect Square
            final PersonneSimpleDto personneCibleeSquare = personneUtil
                    .getPersonneSimple(personneCiblee.getEidPersonne(), infosPersonneSquare);
            final ProspectDevisDto prospect = new ProspectDevisDto();
            if (personneCibleeSquare.getCivilite() != null
                    && !StringUtils.isBlank(personneCibleeSquare.getCivilite().getLibelle())) {
                prospect.setGenre(personneCibleeSquare.getCivilite().getLibelle());
            }
            prospect.setNom(personneCibleeSquare.getNom().toUpperCase());
            final char[] delimiters = { ' ', '-', '_' };
            final String prenomMisEnForme = WordUtils.capitalizeFully(personneCibleeSquare.getPrenom(),
                    delimiters);
            prospect.setPrenom(prenomMisEnForme);
            // Recherche de l'adresse principale
            final CoordonneesDto coordonnees = personneUtil.getCoordonnees(personneCiblee.getEidPersonne(),
                    infosPersonneSquare);
            final com.square.core.model.dto.AdresseDto adressePrincipale = personneUtil
                    .rechercherAdressePrincipaleEnCours(coordonnees.getAdresses());
            prospect.setAdresse(mapperAdresse(adressePrincipale));
            lettreAnnulation.setProspect(prospect);
            final FichierDto fichierGenere = editiqueService.getLettreAnnulation(lettreAnnulation);
            fichierGenere.setNom(
                    getNomFichierPdf(messageSourceUtil.get(MessageKeyUtil.NOM_FICHIER_LETTRE_ANNULATION)));
            fichiersGeneres.add(new FichierModeleBean(fichierGenere, idModeleDevis));
        } else if (idModeleDevis.equals(idModeleLettreRadiation)
                || idModeleDevis.equals(idModeleLettreRadiationLoiChatel)) {
            final FichierDto fichierGenere = editiqueService
                    .getFichier(editiqueMappingService.getMapFichiersStatiques().get(idModeleDevis.toString()));
            if (idModeleDevis.equals(idModeleLettreRadiation)) {
                fichierGenere.setNom(
                        getNomFichierPdf(messageSourceUtil.get(MessageKeyUtil.NOM_FICHIER_LETTRE_RADIATION)));
            } else if (idModeleDevis.equals(idModeleLettreRadiationLoiChatel)) {
                fichierGenere.setNom(getNomFichierPdf(
                        messageSourceUtil.get(MessageKeyUtil.NOM_FICHIER_LETTRE_RADIATION_LOI_CHATEL)));
            }
            fichiersGeneres.add(new FichierModeleBean(fichierGenere, idModeleDevis));
        } else {
            // Type de devis Sant/Prvoyance
            // Rcupration de la rfrence
            final String reference = opportuniteSquare.getEidOpportunite();
            // Cration du DTO permettant la gnration du bulletin d'adhsion
            final DocumentsBulletinsAdhesionDto documentsBulletinsAdhesionDto = getDocumentsBaDtoPourDevis(
                    devis, editionDocumentDto, reference, idModeleDevis, eidAgence, infosPersonneSquare);
            final FichierDto fichierGenere = editiqueService
                    .genererPdfDocumentsBulletinsAdhesion(documentsBulletinsAdhesionDto);
            // Nom du fichier en fonction du modle
            if (idModeleDevisBulletinAdhesion.equals(idModeleDevis)) {
                fichierGenere.setNom(
                        getNomFichierPdf(messageSourceUtil.get(MessageKeyUtil.NOM_FICHIER_BULLETIN_ADHESION)));
            } else if (idModeleDevisFicheTransfert.equals(idModeleDevis)) {
                fichierGenere
                        .setNom(getNomFichierPdf(messageSourceUtil.get(MessageKeyUtil.NOM_FICHIER_AVENANT)));
            }
            fichiersGeneres.add(new FichierModeleBean(fichierGenere, idModeleDevis));

            // On met  jour la date de dernire dition du BA si elle est renseigne
            if (editionDocumentDto.getDateEditionBa() != null) {
                devis.getOpportunite().getAdhesion().setDateEditionBA(editionDocumentDto.getDateEditionBa());
            }
        }
    }
    return fichiersGeneres;
}

From source file:com.square.tarificateur.noyau.service.implementations.TarificateurEditiqueServiceImpl.java

/**
 * Mappe une personne dans un DTO adapt au noyau ditique.
 * @param personne la personne  mapper./* w ww.  j  a v a  2  s  . co m*/
 * @param infosPersonneSquare le cache des infos de personnes Square
 * @return La personne mappe dans un DTO adapt au noyau ditique.
 */
private ProspectBADto mapperProspect(Personne personne, Long eidRelationParrain,
        InfosPersonneSquareBean infosPersonneSquare) {
    // Mapping de la personne
    final ProspectBADto prospect = mapperDozerBean.map(personne, ProspectBADto.class);
    // Rcupration de la personne
    final PersonneSimpleDto personneSimpleSquare = personneUtil.getPersonneSimple(personne.getEidPersonne(),
            infosPersonneSquare);
    mapperDozerBean.map(personneSimpleSquare, prospect);

    prospect.setNom(prospect.getNom().toUpperCase());
    final char[] delimiters = { ' ', '-', '_' };
    final String prenomMisEnForme = WordUtils.capitalizeFully(prospect.getPrenom().trim(), delimiters);
    prospect.setPrenom(prenomMisEnForme);

    // Rcupration des coordonnes de la personne
    final CoordonneesDto coordonnees = personneUtil.getCoordonnees(personne.getEidPersonne(),
            infosPersonneSquare);

    // Rcupration de l'adresse principale
    final com.square.core.model.dto.AdresseDto adressePrincipale = personneUtil
            .rechercherAdressePrincipaleEnCours(coordonnees.getAdresses());
    prospect.setAdresse(mapperAdresse(adressePrincipale));

    // Rcupration du tlphone parmi fixe, portable et bureau
    final Long idNatureTelephoneFixe = squareMappingService.getIdNatureTelephoneFixe();
    final TelephoneDto telephoneFixe = personneUtil.rechercherTelephoneParNature(coordonnees.getTelephones(),
            idNatureTelephoneFixe);
    if (telephoneFixe != null && !StringUtils.isBlank(telephoneFixe.getNumero())) {
        prospect.setNumeroTelephone(telephoneFixe.getNumero());
    } else {
        final Long idNatureMobilePrive = squareMappingService.getIdNatureMobilePrive();
        final TelephoneDto telephonePortable = personneUtil
                .rechercherTelephoneParNature(coordonnees.getTelephones(), idNatureMobilePrive);
        if (telephonePortable != null && !StringUtils.isBlank(telephonePortable.getNumero())) {
            prospect.setNumeroTelephone(telephonePortable.getNumero());
        } else {
            final Long idNatureMobileTravail = squareMappingService.getIdNatureMobileTravail();
            final TelephoneDto telephoneBureau = personneUtil
                    .rechercherTelephoneParNature(coordonnees.getTelephones(), idNatureMobileTravail);
            if (telephoneBureau != null && !StringUtils.isBlank(telephoneBureau.getNumero())) {
                prospect.setNumeroTelephone(telephoneBureau.getNumero());
            }
        }
    }

    // Rcupration du mail personnel
    final Long idNatureEmailPersonnel = squareMappingService.getIdNatureEmailPersonnel();
    final EmailDto email = personneUtil.rechercherEmailParNature(coordonnees.getEmails(),
            idNatureEmailPersonnel);
    if (email != null && !StringUtils.isBlank(email.getAdresse())) {
        prospect.setEmail(email.getAdresse());
    }

    // Rcupration de la caisse
    if (personne.getInfoSante() != null && personne.getInfoSante().getEidCaisse() != null) {
        final CaisseDto caisse = dimensionService.rechercherCaisseParId(personne.getInfoSante().getEidCaisse());
        if (caisse == null) {
            logger.error(messageSourceUtil.get(MessageKeyUtil.LOGGER_ERROR_CAISSE_NULL,
                    new String[] { String.valueOf(personne.getInfoSante().getEidCaisse()) }));
        } else {
            prospect.setLibelleCaisse(caisse.getCode());
            prospect.setLibelleRegime(caisse.getRegime().getLibelle());
        }
    }

    // Rcupration du numro d'adherent du parrain
    if (eidRelationParrain != null) {
        final RelationDto relation = personneService.rechercherRelationParId(eidRelationParrain);
        // on verifie si le parrain vient du segment individuel
        final com.square.core.model.dto.PersonneDto parrain = personneUtil
                .getPersonnePhysique(relation.getIdPersonnePrincipale(), infosPersonneSquare);
        prospect.setNumeroAdherentParrain(parrain.getNumClient());
    }

    return prospect;
}

From source file:com.square.adherent.noyau.service.implementations.ContratServiceImpl.java

/**
 * Construit le rcapitulatif des garanties d'un contrat.
 * @param listeBeneficiaires la liste des bnficiaires.
 * @param listeGaranties la liste des garanties.
 * @return le rcapitulatif.// www.  j av a 2 s  .co m
 */
private RecapitulatifGarantiesContratDto construireRecapitulatif(
        List<GarantieBeneficiaireDto> listeBeneficiaires, List<Garantie> listeGaranties) {
    final RecapitulatifGarantiesContratDto recapitulatif = new RecapitulatifGarantiesContratDto();
    final List<GarantieBeneficiaireDto> listeBenefsRecap = new ArrayList<GarantieBeneficiaireDto>();
    for (GarantieBeneficiaireDto benef : listeBeneficiaires) {
        // Rcupration du nom et du prnom du bnficiaire
        final PersonneDto personneDto = personnePhysiqueService
                .rechercherPersonneParIdentifiant(benef.getIdBenef());
        if (personneDto == null) {
            throw new BusinessException(
                    messageSourceUtil.get(MessageKeyUtil.ERROR_BENEFICIAIRE_CONTRAT_INEXISTANT));
        }
        benef.setNom(personneDto.getNom().toUpperCase());
        benef.setPrenom(WordUtils.capitalizeFully(personneDto.getPrenom(), DELIMITERS));
        listeBenefsRecap.add(benef);
    }
    recapitulatif.setListeBeneficiaires(listeBenefsRecap);
    final List<GarantieSimpleDto> listeGarantiesSimples = new ArrayList<GarantieSimpleDto>();
    final List<Integer> listeProduitsDejaPresents = new ArrayList<Integer>();
    if (listeGaranties != null && listeGaranties.size() > 0) {
        for (Garantie garantie : listeGaranties) {
            final GarantieSimpleDto garantieSimpleDto = new GarantieSimpleDto();
            garantieSimpleDto.setId(garantie.getId());
            garantieSimpleDto.setIdContrat(garantie.getContrat().getId());
            final ProduitCriteresDto critereProduit = new ProduitCriteresDto();
            critereProduit.setProduitAia(garantie.getLibelleProduitGestion());
            critereProduit.setGarantieAia(garantie.getLibelleGarantieGestion());
            final List<ProduitDto> listeProduits = produitService.getListeProduits(critereProduit);
            if (listeProduits == null || listeProduits.size() != 1) {
                throw new BusinessException(
                        messageSourceUtil.get(MessageKeyUtil.ERROR_RECUPERATION_PRODUIT_IMPOSSIBLE));
            }
            final ProduitDto produit = listeProduits.get(0);
            if (!listeProduitsDejaPresents.contains(produit.getIdentifiant())) {
                listeProduitsDejaPresents.add(produit.getIdentifiant());
                garantieSimpleDto.setIdGamme(Long.valueOf(produit.getGamme().getIdentifiant()));
                garantieSimpleDto.setIdProduit(produit.getIdentifiant());
                garantieSimpleDto.setLibelle(produit.getLibelleCommercial());
                if (produit.getFormulePresta() != null) {
                    garantieSimpleDto.setIdFormulePresta(produit.getFormulePresta().getIdentifiant());
                    garantieSimpleDto.setLibelleFormulePresta(produit.getFormulePresta().getLibelle());
                }
                final IdentifiantLibelleDto segmentDto = mapperDozerBean.map(garantie.getSegment(),
                        IdentifiantLibelleDto.class);
                garantieSimpleDto.setSegment(segmentDto);
                final List<InfosGarantieBeneficiaireDto> listeInfosGarantiesBeneficiaires = new ArrayList<InfosGarantieBeneficiaireDto>();
                final InfosGarantieBeneficiaireDto infosGarantieBeneficiaireDto = new InfosGarantieBeneficiaireDto();
                infosGarantieBeneficiaireDto.setIdBeneficiaire(garantie.getUidBeneficiaire());
                infosGarantieBeneficiaireDto.setDateAdhesion(garantie.getDateAdhesion());
                infosGarantieBeneficiaireDto.setDateResiliation(garantie.getDateResiliation());
                final IdentifiantLibelleDto statutDto = mapperDozerBean.map(garantie.getStatut(),
                        IdentifiantLibelleDto.class);
                infosGarantieBeneficiaireDto.setStatut(statutDto);
                listeInfosGarantiesBeneficiaires.add(infosGarantieBeneficiaireDto);
                garantieSimpleDto.setListeInfosGarantiesBeneficiaires(listeInfosGarantiesBeneficiaires);
                listeGarantiesSimples.add(garantieSimpleDto);
            } else {
                for (GarantieSimpleDto garantieDto : listeGarantiesSimples) {
                    if (garantieDto.getIdProduit().equals(produit.getIdentifiant())) {
                        Integer indexBenefExistant = null;
                        for (int i = 0; i < garantieDto.getListeInfosGarantiesBeneficiaires().size(); i++) {
                            if (garantieDto.getListeInfosGarantiesBeneficiaires().get(i).getIdBeneficiaire()
                                    .equals(garantie.getUidBeneficiaire())) {
                                indexBenefExistant = i;
                                break;
                            }
                        }
                        final IdentifiantLibelleDto statutDto = mapperDozerBean.map(garantie.getStatut(),
                                IdentifiantLibelleDto.class);
                        if (indexBenefExistant != null) {
                            final InfosGarantieBeneficiaireDto infoGarantieBenefDto = garantieDto
                                    .getListeInfosGarantiesBeneficiaires().get(indexBenefExistant);
                            if (infoGarantieBenefDto.getDateAdhesion().before(garantie.getDateAdhesion())) {
                                infoGarantieBenefDto.setDateAdhesion(garantie.getDateAdhesion());
                                infoGarantieBenefDto.setDateResiliation(garantie.getDateResiliation());
                                infoGarantieBenefDto.setStatut(statutDto);
                            }
                        } else {
                            final InfosGarantieBeneficiaireDto infosGarantieBeneficiaireDto = new InfosGarantieBeneficiaireDto();
                            infosGarantieBeneficiaireDto.setIdBeneficiaire(garantie.getUidBeneficiaire());
                            infosGarantieBeneficiaireDto.setDateAdhesion(garantie.getDateAdhesion());
                            infosGarantieBeneficiaireDto.setDateResiliation(garantie.getDateResiliation());
                            infosGarantieBeneficiaireDto.setStatut(statutDto);
                            garantieDto.getListeInfosGarantiesBeneficiaires().add(infosGarantieBeneficiaireDto);
                        }
                    }
                }
            }
        }
    }
    recapitulatif.setListeGaranties(listeGarantiesSimples);
    return recapitulatif;
}

From source file:com.square.tarificateur.noyau.service.implementations.TarificateurEditiqueServiceImpl.java

/**
 * Mappe une personne dans un DTO adapt pour le noyau ditique.
 * @param beneficiaire la personne bnficiaire.
 * @param infosPersonneSquare le cache des infos de personnes Square
 * @return le DTO contenant les informations de la personne.
 *///from w  ww  . j av  a2  s . c o m
private BeneficiaireBADto mapperBeneficiaire(Personne beneficiaire,
        InfosPersonneSquareBean infosPersonneSquare) {
    final BeneficiaireBADto beneficiaireBA = mapperDozerBean.map(beneficiaire, BeneficiaireBADto.class);
    // Rcupration de la personne
    final PersonneSimpleDto personneSquare = personneUtil.getPersonneSimple(beneficiaire.getEidPersonne(),
            infosPersonneSquare);
    mapperDozerBean.map(personneSquare, beneficiaireBA);
    beneficiaireBA.setNom(beneficiaireBA.getNom().toUpperCase());
    final char[] delimiters = { ' ', '-', '_' };
    final String prenomMisEnForme = WordUtils.capitalizeFully(beneficiaireBA.getPrenom().trim(), delimiters);
    beneficiaireBA.setPrenom(prenomMisEnForme);
    if (beneficiaire.getInfoSante() != null && beneficiaire.getInfoSante().getEidCaisse() != null) {
        final CaisseDto caisse = dimensionService
                .rechercherCaisseParId(beneficiaire.getInfoSante().getEidCaisse());
        if (caisse == null) {
            logger.error(messageSourceUtil.get(MessageKeyUtil.LOGGER_ERROR_CAISSE_NULL,
                    new String[] { String.valueOf(beneficiaire.getInfoSante().getEidCaisse()) }));
        } else {
            beneficiaireBA.setLibelleCaisse(caisse.getCode());
            beneficiaireBA.setLibelleRegime(caisse.getRegime().getLibelle());
        }
    }
    return beneficiaireBA;
}

From source file:com.square.tarificateur.noyau.service.implementations.TarificateurEditiqueServiceImpl.java

/**
 * Cre le prospect d'un devis pdf  partir du devis.
 * @param infosPersonneSquare le cache des infos de personnes Square
 * @param devis le devis//from www .j  ava 2 s  . c  o m
 * @return le prospect
 */
@SuppressWarnings("unused")
private ProspectDevisDto creerProspectDevisPdf(Devis devis, InfosPersonneSquareBean infosPersonneSquare) {
    // Rcupration du prospect
    final Personne prospect = devis.getPersonnePrincipale();
    // Rcupration de la personne Square
    final PersonneSimpleDto personneSquare = personneUtil.getPersonneSimple(prospect.getEidPersonne(),
            infosPersonneSquare);
    // Rcupration de l'adresse principale de la personne square
    final CoordonneesDto coordonnees = personneUtil.getCoordonnees(prospect.getEidPersonne(),
            infosPersonneSquare);
    final com.square.core.model.dto.AdresseDto adressePrincipale = personneUtil
            .rechercherAdressePrincipaleEnCours(coordonnees.getAdresses());
    // Mapping de l'adresse
    final AdresseDto adresseDto = mapperAdresse(adressePrincipale);
    // Cration du prospect
    String civilite = "";
    if (personneSquare.getCivilite() != null
            && !StringUtils.isBlank(personneSquare.getCivilite().getLibelle())) {
        civilite = personneSquare.getCivilite().getLibelle();
    }
    final char[] delimiters = { ' ', '-', '_' };
    final String prenomMisEnForme = WordUtils.capitalizeFully(personneSquare.getPrenom().trim(), delimiters);
    return new ProspectDevisDto(prospect.getId(), civilite, personneSquare.getNom().toUpperCase(),
            prenomMisEnForme, adresseDto);
}

From source file:nl.strohalm.cyclos.utils.access.PermissionHelper.java

private static String process(final String string) {
    return StringUtils.uncapitalize(WordUtils.capitalizeFully(string, NAME_DELIMITERS).replaceAll("\\_", ""));
}

From source file:nl.strohalm.cyclos.utils.EnumHelper.java

/**
 * Capitalizes an enum item name/*  w  ww.ja  v a2s  . c om*/
 */
public static String capitalizeName(final Enum<?> item) {
    final String capitalized = StringUtils.replace(WordUtils.capitalizeFully(item.name(), new char[] { '_' }),
            "_", "");
    return Character.toLowerCase(capitalized.charAt(0)) + capitalized.substring(1);
}

From source file:org.apache.hadoop.hive.ql.exec.vector.expressions.ExtendedStringInitCap.java

public ExtendedStringInitCap(int colNum, int outputColumn) {
    super(colNum, outputColumn, new IUDFUnaryString() {

        Text t = new Text();

        @Override/*w ww  .ja v a2  s  .c o  m*/
        public Text evaluate(Text s) {
            if (s == null) {
                return null;
            }
            t.set(WordUtils.capitalizeFully(s.toString(), new char[] { '-', ',', ' ' }));
            return t;
        }
    });
}