Example usage for org.apache.commons.lang3 StringUtils replace

List of usage examples for org.apache.commons.lang3 StringUtils replace

Introduction

In this page you can find the example usage for org.apache.commons.lang3 StringUtils replace.

Prototype

public static String replace(final String text, final String searchString, final String replacement) 

Source Link

Document

Replaces all occurrences of a String within another String.

A null reference passed to this method is a no-op.

 StringUtils.replace(null, *, *)        = null StringUtils.replace("", *, *)          = "" StringUtils.replace("any", null, *)    = "any" StringUtils.replace("any", *, null)    = "any" StringUtils.replace("any", "", *)      = "any" StringUtils.replace("aba", "a", null)  = "aba" StringUtils.replace("aba", "a", "")    = "b" StringUtils.replace("aba", "a", "z")   = "zbz" 

Usage

From source file:de.micromata.genome.gwiki.page.impl.wiki.parser.GWikiWikiParser.java

public GWikiContent parse(GWikiContext wikiContext, String text) {
    GWikiWikiParserContext parseContext = new GWikiWikiParserContext();
    parseContext.getMacroFactories()//from  w  ww  . j  a  va  2  s. c  o m
            .putAll(wikiContext.getWikiWeb().getWikiConfig().getWikiMacros(wikiContext));
    String ntext = StringUtils.replace(text, "\n\r", "\n");
    ntext = StringUtils.replace(ntext, "\r\n", "\n");
    // ntext = "\n" + ntext;
    parseFrags(ntext, parseContext);
    return new GWikiContent(parseContext.popFragList());

}

From source file:me.ryanhamshire.griefprevention.permission.GPPermissionHandler.java

public static String getPermission(Object source, Object target, String flagPermission) {
    String sourceId = getPermissionIdentifier(source, true);
    String targetPermission = flagPermission;
    String targetId = getPermissionIdentifier(target);
    if (!targetId.isEmpty()) {
        if (!sourceId.isEmpty()) {
            // move target meta to end of permission
            Matcher m = PATTERN_META.matcher(targetId);
            String targetMeta = "";
            if (m.find()) {
                targetMeta = m.group(0);
                targetId = StringUtils.replace(targetId, targetMeta, "");
            }/*  ww w.j av a 2 s. c  o  m*/
            targetPermission += "." + targetId + ".source." + sourceId + targetMeta;
        } else {
            targetPermission += "." + targetId;
        }
    }
    targetPermission = StringUtils.replace(targetPermission, ":", ".");
    return targetPermission;
}

From source file:me.ryanhamshire.griefprevention.permission.GPPermissionHandler.java

public static String getIdentifierWithoutMeta(String targetId) {
    Matcher m = PATTERN_META.matcher(targetId);
    String targetMeta = "";
    if (m.find()) {
        targetMeta = m.group(0);// w w w  .  j av a 2s.co  m
        targetId = StringUtils.replace(targetId, targetMeta, "");
    }
    return targetId;
}

From source file:com.opensymphony.xwork2.util.finder.ResourceFinder.java

private Set<String> convertPathsToPackages(Set<String> resources) {
    Set<String> packageNames = new HashSet<String>(resources.size());
    for (String resource : resources) {
        packageNames.add(StringUtils.chomp(StringUtils.replace(resource, "/", "."), "."));
    }//  w  w w  .ja  v  a 2s. co  m

    return packageNames;
}

From source file:com.google.dart.java2dart.engine.MainAnalysisServer.java

/**
 * Replaces the fragment of the source specified by the RE pattern with the given source.
 * //w  w  w  . j  a  va  2s  .  co  m
 * @param source the source to replace fragment in
 * @param pattern the fragment to replace
 * @param replacement the source to replace fragment with
 * @return the source with the replacement fragment
 */
private static String replaceSourceFragment(String source, String pattern, String replacement) {
    int index = source.indexOf(pattern);
    if (index == -1) {
        throw new IllegalArgumentException("Not found: " + pattern);
    }
    return StringUtils.replace(source, pattern, replacement);
}

From source file:com.dominion.salud.nomenclator.negocio.service.impl.aemps.v5.MedicamentosV5ServiceImpl.java

@Transactional
private void loadMedicamento(MedicamentosType medicamentosType) throws Exception {
    Medicamentos medicamentos = new Medicamentos();
    medicamentos.setCodNacional(medicamentosType.getCodNacion());

    try {//from w  w  w  .j  av  a 2s.  co  m
        logger.debug("     Cargando MEDICAMENTOS para el COD_NAC: " + medicamentos.getCodNacional());
        medicamentos = medicamentosRepository.findByCodNac(medicamentos);
        logger.debug("     Se ha encontrado MEDICAMENTOS con COD_NAC: " + medicamentos.getCodNacional()
                + ". Actualizando registro: " + medicamentos.toString());
    } catch (NoResultException nre) {
        logger.debug("     No se ha encontrado MEDICAMENTOS con COD_NAC: " + medicamentos.getCodNacional()
                + ". Insertando nuevo registro: " + medicamentos.toString());
    } finally {
        medicamentos.setNroPactiv(medicamentosType.getNroPactiv());
        medicamentos.setFecSitReg(medicamentosType.getFechaSituacionRegistro() != null
                ? medicamentosType.getFechaSituacionRegistro().toGregorianCalendar().getTime()
                : null);
        medicamentos.setFecSitRegPresen(medicamentosType.getFecSitregPresen() != null
                ? medicamentosType.getFecSitregPresen().toGregorianCalendar().getTime()
                : null);
        medicamentos.setTxtDesComercial(medicamentosType.getDesNomco());
        medicamentos.setTxtDesDosific(medicamentosType.getDesDosific());
        medicamentos.setTxtDesPresen(medicamentosType.getDesPrese());
        medicamentos.setFecAutorizacion(medicamentosType.getFechaAutorizacion() != null
                ? medicamentosType.getFechaAutorizacion().toGregorianCalendar().getTime()
                : null);
        medicamentos.setFecComer(medicamentosType.getFecComer() != null
                ? medicamentosType.getFecComer().toGregorianCalendar().getTime()
                : null);
        medicamentos.setAfectaConduccion(medicamentosType.isSwAfectaConduccion() ? "S" : "N");
        medicamentos.setBaseAPlantas(medicamentosType.isSwBaseAPlantas() ? "S" : "N");
        medicamentos.setBiosimilar(medicamentosType.isBiosimilar() ? "S" : "N");
        medicamentos.setComercializado(medicamentosType.isSwComercializado() ? "S" : "N");
        medicamentos.setContenido(medicamentosType.getContenido());
        medicamentos.setDiagHospitalario(medicamentosType.isSwDiagnosticoHospitalario() ? "S" : "N");
        medicamentos.setEnvaseClinico(medicamentosType.isSwEnvaseClinico() ? "S" : "N");
        medicamentos.setEspecialCtrlMed(medicamentosType.isSwEspecialControlMedico() ? "S" : "N");
        medicamentos.setEstupefaciente(medicamentosType.isSwEstupefaciente() ? "S" : "N");
        medicamentos.setExcipDeclOblig(medicamentosType.isSwTieneExcipientesDeclObligatoria() ? "S" : "N");
        medicamentos.setGenerico(medicamentosType.isSwGenerico() ? "S" : "N");
        medicamentos.setHuerfano(medicamentosType.isSwHuerfano() ? "S" : "N");
        medicamentos.setListaEstupe(medicamentosType.getListaEstupefaciente());
        medicamentos.setListaPsicotropo(medicamentosType.getListaPsicotropo());
        medicamentos.setNroConte(medicamentosType.getNroConte());
        medicamentos.setNroRegistro(medicamentosType.getNroDefinitivo());
        medicamentos.setPsicotropo(medicamentosType.isSwPsicotropo() ? "S" : "N");
        medicamentos.setSustituible(medicamentosType.isSwSustituible() ? "S" : "N");
        medicamentos.setTld(medicamentosType.isSwTld() ? "S" : "N");
        medicamentos.setTrianguloNegro(medicamentosType.isSwTrianguloNegro() ? "S" : "N");
        medicamentos.setUsoHospitalario(medicamentosType.isSwUsoHospitalario() ? "S" : "N");
        medicamentos.setUrlFictec(medicamentosType.getUrlFictec());
        medicamentos.setUrlProsp(medicamentosType.getUrlProsp());

        //SIT_REG
        try {
            logger.debug("          Cargando SIT_REG para el COD_SIT_REG: " + medicamentosType.getCodSitreg());
            SituacionRegistro situacionRegistro = new SituacionRegistro();
            situacionRegistro.setCodSitReg(Integer.toString(medicamentosType.getCodSitreg()));

            medicamentos.setSitReg(situacionRegistroRepository.findByCodSituacionRegistro(situacionRegistro));
            logger.debug("          SIT_REG para el COD_SIT_REG: " + situacionRegistro.getCodSitReg()
                    + " cargado correctamente");
        } catch (NoResultException nre) {
            logger.warn("          No se ha encontrado SIT_REG con COD_SIT_REG: "
                    + medicamentosType.getCodSitreg());
        }

        //SIT_REG_DOS_PRESEN
        try {
            logger.debug("          Cargando SIT_REG_DOS_PRESEN para el COD_SIT_REG_DOS_PRESEN: "
                    + medicamentosType.getCodSitregPresen());
            SituacionRegistro situacionRegistroDosPresen = new SituacionRegistro();
            situacionRegistroDosPresen.setCodSitReg(Integer.toString(medicamentosType.getCodSitregPresen()));

            medicamentos.setSitRegPresen(
                    situacionRegistroRepository.findByCodSituacionRegistro(situacionRegistroDosPresen));
            logger.debug("          SIT_REG_DOS_PRESEN para el COD_SIT_REG_DOS_PRESEN: "
                    + situacionRegistroDosPresen.getCodSitReg() + " cargado correctamente");
        } catch (NoResultException nre) {
            logger.warn("          No se ha encontrado SIT_REG_DOS_PRESEN con COD_SIT_REG_DOS_PRESEN: "
                    + medicamentosType.getCodSitregPresen());
        }

        //DCP
        if (medicamentosType.getCodDcp() != null) {
            try {
                logger.debug("          Cargando DCP para el COD_DCP: " + medicamentosType.getCodDcp());
                Dcp dcp = new Dcp();
                dcp.setCodDcp(new DecimalFormat("#.#").format(medicamentosType.getCodDcp()));

                medicamentos.setDcp(dcpRepository.findByCodDcp(dcp));
                logger.debug("          DCP para el COD_DCP: " + dcp.getCodDcp() + " cargado correctamente");
            } catch (NoResultException nre) {
                logger.warn("          No se ha encontrado DCP con COD_DCP: " + medicamentosType.getCodDcp());
            }
        }

        //DCPF
        if (medicamentosType.getCodDcpf() != null) {
            try {
                logger.debug("          Cargando DCPF para el COD_DCPF: " + medicamentosType.getCodDcpf());
                Dcpf dcpf = new Dcpf();
                dcpf.setCodDcpf(new DecimalFormat("#.#").format(medicamentosType.getCodDcpf()));

                medicamentos.setDcpf(dcpfRepository.findByCodDcpf(dcpf));
                logger.debug(
                        "          DCPF para el COD_DCPF: " + dcpf.getCodDcpf() + " cargado correctamente");
            } catch (NoResultException nre) {
                logger.warn(
                        "          No se ha encontrado DCPF con COD_DCPF: " + medicamentosType.getCodDcpf());
            }
        }

        //DCSA
        if (medicamentosType.getCodDcsa() != null) {
            try {
                logger.debug("          Cargando DCSA para el COD_DCSA: " + medicamentosType.getCodDcsa());
                Dcsa dcsa = new Dcsa();
                dcsa.setCodDcsa(new DecimalFormat("#.#").format(medicamentosType.getCodDcsa()));

                medicamentos.setDcsa(dcsaRepository.findByCodDcsa(dcsa));
                logger.debug(
                        "          DCSA para el COD_DCSA: " + dcsa.getCodDcsa() + " cargado correctamente");
            } catch (NoResultException nre) {
                logger.warn(
                        "          No se ha encontrado DCSA con COD_DCSA: " + medicamentosType.getCodDcsa());
            }
        }

        //ENVASES
        if (medicamentosType.getCodEnvase() != null) {
            try {
                Envases envases = new Envases();
                envases.setCodEnvase(Integer.toString(medicamentosType.getCodEnvase()));

                logger.debug(
                        "          Cargando ENVASES para el COD_ENVASE: " + medicamentosType.getCodEnvase());
                medicamentos.setEnvases(envasesRepository.findByCodEnvase(envases));
                logger.debug("          ENVASE para el COD_ENVASE: " + envases.getCodEnvase()
                        + " cargado correctamente");
            } catch (NoResultException nre) {
                logger.warn("          No se ha encontrado ENVASES con COD_ENVASE: "
                        + medicamentosType.getCodEnvase());
            }
        }

        //FORMAS_FAR
        if (medicamentosType.getCodForfar() != null) {
            try {
                FormasFar formasFar = new FormasFar();
                formasFar.setCodFormaFar(Integer.toString(medicamentosType.getCodForfar()));

                logger.debug("          Cargando FORMAS_FAR para el COD_FORMA_FAR: "
                        + medicamentosType.getCodForfar());
                medicamentos.setFormasFar(formasFarRepository.findByCodFormaFar(formasFar));
                logger.debug("          FORMAS_FAR para el COD_FORMA_FAR: " + formasFar.getCodFormaFar()
                        + " cargado correctamente");
            } catch (NoResultException nre) {
                logger.warn("          No se ha encontrado FORMAS_FAR con COD_FORMA_FAR: "
                        + medicamentosType.getCodForfar());
            }
        }

        //FORMAS_FAR_SIMP
        if (medicamentosType.getCodForfarSimplificada() != null) {
            try {
                FormasFarSimp formasFarSimp = new FormasFarSimp();
                formasFarSimp.setCodFormaFarSimp(Integer.toString(medicamentosType.getCodForfarSimplificada()));

                logger.debug("          Cargando FORMAS_FAR_SIMP para el COD_FORMA_FAR_SIMP: "
                        + medicamentosType.getCodForfarSimplificada());
                medicamentos.setFormasfarSimp(formasFarSimpRepository.findByCodFormaFarSimp(formasFarSimp));
                logger.debug("          FORMAS_FAR_SIMP para el COD_FORMA_FAR_SIMP: "
                        + formasFarSimp.getCodFormaFarSimp() + " cargado correctamente");
            } catch (NoResultException nre) {
                logger.warn("          No se ha encontrado FORMAS_FAR_SIMP con COD_FORMA_FAR_SIMP: "
                        + medicamentosType.getCodForfarSimplificada());
            }
        }

        //LAB_COMER
        if (medicamentosType.getLaboratorioComercializador() != null) {
            try {
                Laboratorios labComer = new Laboratorios();
                labComer.setCodLaboratorio(Integer.toString(medicamentosType.getLaboratorioComercializador()));

                logger.debug("          Cargando LAB_COMER para el COD_LABORATORIO: "
                        + medicamentosType.getLaboratorioComercializador());
                medicamentos.setLaboratoriosComer(laboratoriosRepository.findByCodLaboratorio(labComer));
                logger.debug("          LAB_COMER para el COD_LABORATORIO: " + labComer.getCodLaboratorio()
                        + " cargado correctamente");
            } catch (NoResultException nre) {
                logger.warn("          No se ha encontrado LAB_COMER con COD_LABORATORIO: "
                        + medicamentosType.getLaboratorioComercializador());
            }
        }

        //LAB_TITULAR
        if (medicamentosType.getLaboratorioTitular() != null) {
            try {
                Laboratorios labTit = new Laboratorios();
                labTit.setCodLaboratorio(Integer.toString(medicamentosType.getLaboratorioTitular()));

                logger.debug("          Cargando LAB_TITULAR para el COD_LABORATORIO: "
                        + medicamentosType.getLaboratorioTitular());
                medicamentos.setLaboratoriosTit(laboratoriosRepository.findByCodLaboratorio(labTit));
                logger.debug("          LAB_TITULAR para el COD_LABORATORIO: "
                        + Integer.toString(medicamentosType.getLaboratorioTitular())
                        + " cargado correctamente");
            } catch (NoResultException nre) {
                logger.warn("          No se ha encontrado LAB_TITULAR con COD_LABORATORIO: "
                        + medicamentosType.getLaboratorioTitular());
            }
        }

        //UNIDAD_CONTENIDO
        if (medicamentosType.getUnidContenido() != null) {
            try {
                UnidadesContenido unidadesContenido = new UnidadesContenido();
                unidadesContenido.setCodUnidContenido(Integer.toString(medicamentosType.getUnidContenido()));

                logger.debug("          Cargando UNIDAD_CONTENIDO para el COD_UNID_CONTENIDO: "
                        + medicamentosType.getUnidContenido());
                medicamentos.setUnidadesContenido(
                        unidadesContenidoRepository.findByCodUnidContenido(unidadesContenido));
                logger.debug("          UNIDAD_CONTENIDO para el COD_UNID_CONTENIDO: "
                        + unidadesContenido.getCodUnidContenido() + " cargado correctamente");
            } catch (NoResultException nre) {
                logger.warn("          No se ha encontrado UNIDAD_CONTENIDO con COD_UNID_CONTENIDO: "
                        + medicamentosType.getUnidContenido());
            }
        }
        medicamentosRepository.save(medicamentos);

        //MED_PRINCIPIOS
        if (medicamentosType.getComposicionPa() != null && !medicamentosType.getComposicionPa().isEmpty()) {
            logger.debug("          Cargando MED_PRINCIPIOS");
            List<MedPrincipios> listaMedPrincipios = new ArrayList<>();

            Iterator<MedicamentosPrincipiosActivosType> iteradorMedicamentosPrincipiosActivos = medicamentosType
                    .getComposicionPa().iterator();
            while (iteradorMedicamentosPrincipiosActivos.hasNext()) {
                MedicamentosPrincipiosActivosType medicamentosPrincipiosActivosType = iteradorMedicamentosPrincipiosActivos
                        .next();

                try {

                    PrincipiosActivos principiosActivos = new PrincipiosActivos();
                    if (medicamentosPrincipiosActivosType.getCodPrincipioActivo() != null) {
                        principiosActivos.setNroPrActivo(
                                Integer.toString(medicamentosPrincipiosActivosType.getCodPrincipioActivo()));
                    } else {
                        principiosActivos.setNroPrActivo(Integer.toString(medicamentosType.getNroPactiv()));
                    }

                    logger.debug("               Cargando PRINCIPIOS_ACTIVOS para el NRO_PRINCIPIO_ACTIVO: "
                            + medicamentosPrincipiosActivosType.getCodPrincipioActivo());
                    MedPrincipios medPrincipios = new MedPrincipios();
                    medPrincipios.setPrincipiosActivos(
                            principiosActivosRepository.findByNroPrActivo(principiosActivos));
                    medPrincipios.setMedicamentos(medicamentos);

                    //UNID_CONT_ADM (U_C)
                    if (medicamentosPrincipiosActivosType.getUnidadAdministracion() != null) {
                        try {
                            UnidadesContenido uniContAdm = new UnidadesContenido();
                            uniContAdm.setTxtUnidContenido(
                                    medicamentosPrincipiosActivosType.getUnidadAdministracion());

                            logger.debug("                    Cargando UNID_CONT_ADM para el TXT_UNID_CONT: "
                                    + medicamentosPrincipiosActivosType.getUnidadAdministracion());
                            medPrincipios.setUniContAdm(
                                    unidadesContenidoRepository.findByTxtUnidContenido(uniContAdm));
                            logger.debug("                    UNID_CONT_ADM para el TXT_UNID_CONT: "
                                    + uniContAdm.getTxtUnidContenido() + " cargado correctamente");
                        } catch (NoResultException nre) {
                            logger.warn(
                                    "                    No se ha encontrado UNID_CONT_ADM con TXT_UNID_CONT: "
                                            + medicamentosPrincipiosActivosType.getUnidadAdministracion());
                        }
                    }

                    //UNI_CONT_COMP (U_C)
                    if (medicamentosPrincipiosActivosType.getUnidadComposicion() != null) {
                        try {
                            UnidadesContenido uniContComp = new UnidadesContenido();
                            uniContComp.setTxtUnidContenido(
                                    medicamentosPrincipiosActivosType.getUnidadComposicion());

                            logger.debug("                    Cargando UNI_CONT_COMP para el TXT_UNID_CONT: "
                                    + medicamentosPrincipiosActivosType.getUnidadComposicion());
                            medPrincipios.setUniContComp(
                                    unidadesContenidoRepository.findByTxtUnidContenido(uniContComp));
                            logger.debug("                    UNI_CONT_COMP para el TXT_UNID_CONT: "
                                    + uniContComp.getTxtUnidContenido() + " cargado correctamente");
                        } catch (NoResultException nre) {
                            logger.warn(
                                    "                    No se ha encontrado UNI_CONT_COMP con TXT_UNID_CONT: "
                                            + medicamentosPrincipiosActivosType.getUnidadComposicion());
                        }
                    }

                    //UNI_DOSIS_PA (U_D)
                    if (medicamentosPrincipiosActivosType.getUnidadDosisPa() != null) {
                        try {
                            UnidadesDosis uniDosisPa = new UnidadesDosis();
                            uniDosisPa.setTxtUnidadDosis(medicamentosPrincipiosActivosType.getUnidadDosisPa());

                            logger.debug("                    Cargando UNI_DOSIS_PA para el TXT_UNID_DOSIS: "
                                    + medicamentosPrincipiosActivosType.getUnidadDosisPa());
                            medPrincipios
                                    .setUniDosisPa(unidadesDosisRepository.findByTxtUnidadDosis(uniDosisPa));
                            logger.debug("                    UNI_DOSIS_PA para el TXT_UNID_DOSIS: "
                                    + uniDosisPa.getTxtUnidadDosis() + " cargado correctamente");
                        } catch (NoResultException nre) {
                            logger.warn(
                                    "                    No se ha encontrado UNI_DOSIS_PA con TXT_UNID_DOSIS: "
                                            + medicamentosPrincipiosActivosType.getUnidadDosisPa());
                        }
                    }

                    //UNI_DOSIS_PRES (U_D)
                    if (medicamentosPrincipiosActivosType.getUnidadPrescripcion() != null) {
                        try {
                            UnidadesDosis uniDosisPre = new UnidadesDosis();
                            uniDosisPre.setTxtUnidadDosis(
                                    medicamentosPrincipiosActivosType.getUnidadPrescripcion());

                            logger.debug("                    Cargando UNI_DOSIS_PRES para el TXT_UNID_DOSIS: "
                                    + medicamentosPrincipiosActivosType.getUnidadPrescripcion());
                            medPrincipios
                                    .setUniDosisPres(unidadesDosisRepository.findByTxtUnidadDosis(uniDosisPre));
                            logger.debug("                    UNI_DOSIS_PRES para el TXT_UNID_DOSIS: "
                                    + uniDosisPre.getTxtUnidadDosis() + " cargado correctamente");
                        } catch (NoResultException nre) {
                            logger.warn(
                                    "                    No se ha encontrado UNI_DOSIS_PRES con TXT_UNID_DOSIS: "
                                            + medicamentosPrincipiosActivosType.getUnidadPrescripcion());
                        }
                    }

                    //UNI_DOSIS_V_ADM (U_D)
                    if (medicamentosPrincipiosActivosType.getUnidadVolumenUnidadAdministracion() != null) {
                        try {
                            UnidadesDosis uniDosisVAdm = new UnidadesDosis();
                            uniDosisVAdm.setTxtUnidadDosis(
                                    medicamentosPrincipiosActivosType.getUnidadVolumenUnidadAdministracion());

                            logger.debug("                    Cargando UNI_DOSIS_V_ADM para el TXT_UNID_DOSIS: "
                                    + medicamentosPrincipiosActivosType.getUnidadVolumenUnidadAdministracion());
                            medPrincipios.setUniDosisVAdm(
                                    unidadesDosisRepository.findByTxtUnidadDosis(uniDosisVAdm));
                            logger.debug("                    UNI_DOSIS_V_ADM para el TXT_UNID_DOSIS: "
                                    + uniDosisVAdm.getTxtUnidadDosis() + " cargado correctamente");
                        } catch (NoResultException nre) {
                            logger.warn(
                                    "                    No se ha encontrado UNI_DOSIS_V_ADM con TXT_UNID_DOSIS: "
                                            + medicamentosPrincipiosActivosType
                                                    .getUnidadVolumenUnidadAdministracion());
                        }
                    }

                    //UNI_DOSIS_V_COMP (U_D)
                    if (medicamentosPrincipiosActivosType.getUnidadVolumenUnidadComposicion() != null) {
                        try {
                            UnidadesDosis uniDosisVComp = new UnidadesDosis();
                            uniDosisVComp.setTxtUnidadDosis(
                                    medicamentosPrincipiosActivosType.getUnidadVolumenUnidadComposicion());

                            logger.debug(
                                    "                    Cargando UNI_DOSIS_V_COMP para el TXT_UNID_DOSIS: "
                                            + medicamentosPrincipiosActivosType
                                                    .getUnidadVolumenUnidadComposicion());
                            medPrincipios.setUniDosisVCom(
                                    unidadesDosisRepository.findByTxtUnidadDosis(uniDosisVComp));
                            logger.debug("                    UNI_DOSIS_V_COMP para el TXT_UNID_DOSIS: "
                                    + uniDosisVComp.getTxtUnidadDosis() + " cargado correctamente");
                        } catch (NoResultException nre) {
                            logger.warn(
                                    "                    No se ha encontrado UNI_DOSIS_V_COMP con TXT_UNID_DOSIS: "
                                            + medicamentosPrincipiosActivosType
                                                    .getUnidadVolumenUnidadComposicion());
                        }
                    }

                    //DosisAdministracion
                    if (NumberUtils.isNumber(StringUtils
                            .replace(medicamentosPrincipiosActivosType.getDosisAdministracion(), ",", "."))) {
                        medPrincipios.setDosisAdm(NumberUtils.createDouble(StringUtils.replace(
                                medicamentosPrincipiosActivosType.getDosisAdministracion(), ",", ".")));
                    }

                    //DosisComposicion
                    if (NumberUtils.isNumber(StringUtils
                            .replace(medicamentosPrincipiosActivosType.getDosisComposicion(), ",", "."))) {
                        medPrincipios.setDosisComp(NumberUtils.createDouble(StringUtils
                                .replace(medicamentosPrincipiosActivosType.getDosisComposicion(), ",", ".")));
                    }

                    //DosisPa
                    if (NumberUtils.isNumber(
                            StringUtils.replace(medicamentosPrincipiosActivosType.getDosisPa(), ",", "."))) {
                        medPrincipios.setDosisPa(NumberUtils.createDouble(
                                StringUtils.replace(medicamentosPrincipiosActivosType.getDosisPa(), ",", ".")));
                    }

                    //CantidadVolumenUnidadAdministracion
                    if (NumberUtils.isNumber(StringUtils.replace(
                            medicamentosPrincipiosActivosType.getCantidadVolumenUnidadAdministracion(), ",",
                            "."))) {
                        medPrincipios.setDosisVAdm(NumberUtils.createDouble(StringUtils.replace(
                                medicamentosPrincipiosActivosType.getCantidadVolumenUnidadAdministracion(), ",",
                                ".")));
                    }

                    //CantidadVolumenUnidadComposicion
                    if (NumberUtils.isNumber(StringUtils.replace(
                            medicamentosPrincipiosActivosType.getCantidadVolumenUnidadComposicion(), ",",
                            "."))) {
                        medPrincipios.setDosisVCom(NumberUtils.createDouble(StringUtils.replace(
                                medicamentosPrincipiosActivosType.getCantidadVolumenUnidadComposicion(), ",",
                                ".")));
                    }

                    medPrincipios.setDosisPres(medicamentosPrincipiosActivosType.getDosisPrescripcion());
                    medPrincipios.setOrdenColacion(medicamentosPrincipiosActivosType.getOrdenColacion());

                    listaMedPrincipios.add(medPrincipios);
                    logger.debug("               PRINCIPIOS_ACTIVOS para el NRO_PRINCIPIO_ACTIVO: "
                            + principiosActivos.getNroPrActivo() + " cargado correctamente");
                } catch (NoResultException nre) {
                    logger.warn(
                            "               No se ha encontrado PRINCIPIOS_ACTIVOS con NRO_PRINCIPIO_ACTIVO: "
                                    + medicamentosPrincipiosActivosType.getCodPrincipioActivo());
                }
            }
            medPrincipiosService.save(medicamentos, listaMedPrincipios);
            logger.debug("          MED_PRINCIPIOS cargados correctamente");
        }

        //MED_EXCIPIENTES
        if (medicamentosType.getExcipientes() != null && !medicamentosType.getExcipientes().isEmpty()) {
            logger.debug("          Cargando MED_EXCIPIENTES");
            List<MedExcipientes> listaMedExcipientes = new ArrayList<>();

            Iterator<MedicamentosExcipientesType> iteradorMedicamentosExcipientes = medicamentosType
                    .getExcipientes().iterator();
            while (iteradorMedicamentosExcipientes.hasNext()) {
                MedicamentosExcipientesType medicamentosExcipientesType = iteradorMedicamentosExcipientes
                        .next();

                try {
                    Excipientes excipientes = new Excipientes();
                    excipientes
                            .setCodExcipiente(Integer.toString(medicamentosExcipientesType.getCodExcipiente()));

                    logger.debug("               Cargando EXCIPIENTES para el COD_EXCIPIENTE: "
                            + medicamentosExcipientesType.getCodExcipiente());
                    MedExcipientes medExcipientes = new MedExcipientes();
                    medExcipientes.setExcipientes(excipientesRepository.findByCodExcipiente(excipientes));
                    medExcipientes.setMedicamentos(medicamentos);
                    listaMedExcipientes.add(medExcipientes);
                    logger.debug("               EXCIPIENTES para el COD_EXCIPIENTE: "
                            + excipientes.getCodExcipiente() + " cargado correctamente");
                } catch (NoResultException nre) {
                    logger.warn("               No se ha encontrado EXCIPIENTES con COD_EXCIPIENTE: "
                            + medicamentosExcipientesType.getCodExcipiente());
                }
            }
            medExcipientesService.save(medicamentos, listaMedExcipientes);
            logger.debug("          MED_EXCIPIENTES cargados correctamente");
        }

        //MED_VIAS
        if (medicamentosType.getViasadministracion() != null
                && !medicamentosType.getViasadministracion().isEmpty()) {
            logger.debug("          Cargando MED_VIAS");
            List<MedVias> listaMedVias = new ArrayList<>();

            Iterator<MedicamentosViasAdminType> iteradorMedicamentosViasAdmin = medicamentosType
                    .getViasadministracion().iterator();
            while (iteradorMedicamentosViasAdmin.hasNext()) {
                MedicamentosViasAdminType medicamentosViasAdminType = iteradorMedicamentosViasAdmin.next();

                try {
                    ViasAdmin viasAdmin = new ViasAdmin();
                    viasAdmin.setCodViaAdmin(Integer.toString(medicamentosViasAdminType.getCodViaAdmin()));

                    logger.debug("               Cargando VIAS_ADMIN para el COD_VIA_ADMIN: "
                            + medicamentosViasAdminType.getCodViaAdmin());
                    MedVias medVias = new MedVias();
                    medVias.setViasAdmin(viasAdminRepository.findByCodViasAdmin(viasAdmin));
                    medVias.setMedicamentos(medicamentos);
                    listaMedVias.add(medVias);
                    logger.debug("               VIAS_ADMIN para el COD_VIA_ADMIN: "
                            + viasAdmin.getCodViaAdmin() + " cargado correctamente");
                } catch (NoResultException nre) {
                    logger.warn("               No se ha encontrado VIAS_ADMIN con COD_VIA_ADMIN: "
                            + medicamentosViasAdminType.getCodViaAdmin());
                }
            }
            medViasAdminService.save(medicamentos, listaMedVias);
            logger.debug("          MED_VIAS cargados correctamente");
        }

        //MED_NOTAS
        if (medicamentosType.getNotaseguridad() != null && !medicamentosType.getNotaseguridad().isEmpty()) {
            logger.debug("          Cargando MED_NOTAS");
            List<MedNotas> listaMedNotas = new ArrayList<>();

            Iterator<MedicamentosNotasType> iteradorMedicamentosNotas = medicamentosType.getNotaseguridad()
                    .iterator();
            while (iteradorMedicamentosNotas.hasNext()) {
                MedicamentosNotasType medicamentosNotasType = iteradorMedicamentosNotas.next();

                MedNotas medNotas = new MedNotas();
                medNotas.setMedicamentos(medicamentos);

                Notas notas = new Notas();
                try {
                    notas.setReferencia(medicamentosNotasType.getReferencia());
                    notas.setAsunto(medicamentosNotasType.getAsunto());
                    notas.setNumero(medicamentosNotasType.getNumero());
                    notas.setUrl(medicamentosNotasType.getUrl());
                    try {
                        notas.setFecha(DateUtils.parseDate(medicamentosNotasType.getFecha(), "dd/MM/YYYY"));
                    } catch (ParseException pe) {
                        logger.warn("               La fecha: " + medicamentosNotasType.getFecha()
                                + " no ha podido ser parseada con el pattern dd/MM/YYYY");
                    }

                    logger.debug("               Cargando NOTAS para el REFERENCIA: "
                            + medicamentosNotasType.getReferencia());
                    notas = notasRepository.findByReferencia(notas);
                    logger.debug("               NOTAS para el REFERENCIA: " + notas.getReferencia()
                            + " cargado correctamente");
                } catch (NoResultException nre) {
                    logger.warn("               No se ha encontrado NOTAS con REFERENCIA: "
                            + medicamentosNotasType.getReferencia() + ". Insertando registro");
                    notasRepository.save(notas);
                } finally {
                    medNotas.setNotas(notas);
                    listaMedNotas.add(medNotas);
                }
            }
            medNotasService.save(medicamentos, listaMedNotas);
            logger.debug("          MED_NOTAS cargados correctamente");
        }

        //MED_ATC
        if (medicamentosType.getAtc() != null && !medicamentosType.getAtc().isEmpty()) {
            logger.debug("          Cargando MED_ATC");

            Iterator<MedicamentosAtcType> iteradorMedicamentosAtc = medicamentosType.getAtc().iterator();
            while (iteradorMedicamentosAtc.hasNext()) {
                MedicamentosAtcType medicamentosAtcType = iteradorMedicamentosAtc.next();
                List<MedAtc> listaMedAtc = new ArrayList<>();

                MedAtc medAtc = new MedAtc();
                medAtc.setMedicamentos(medicamentos);

                try {
                    Atc atc = new Atc();
                    atc.setCodAtc(medicamentosAtcType.getCodAtc());

                    logger.debug(
                            "               Cargando ATC para el COD_ATC: " + medicamentosAtcType.getCodAtc());
                    medAtc.setAtc(atcRepository.findByCodAtc(atc));
                    logger.debug("               ATC para el COD_ATC: " + atc.getCodAtc()
                            + " cargado correctamente");

                    listaMedAtc.add(medAtc);
                    medAtcService.save(medicamentos, listaMedAtc);

                    //ATC_INTERACCIONES
                    if (medicamentosAtcType.getInteraccionesAtc() != null
                            && !medicamentosAtcType.getInteraccionesAtc().isEmpty()) {
                        logger.debug("                    Cargando ATC_INTERACCIONES");
                        List<AtcInteracciones> listaAtcInteracciones = new ArrayList<>();
                        Iterator<AtcInteraccionesType> iteradorAtcInteracciones = medicamentosAtcType
                                .getInteraccionesAtc().iterator();
                        while (iteradorAtcInteracciones.hasNext()) {
                            AtcInteraccionesType atcInteraccionesType = iteradorAtcInteracciones.next();

                            AtcInteracciones atcInteracciones = new AtcInteracciones();
                            atcInteracciones.setDescripcion(atcInteraccionesType.getDescripcionAtc());
                            atcInteracciones.setEfecto(atcInteraccionesType.getEfecto());
                            atcInteracciones.setOrientacion(atcInteraccionesType.getOrientacion());
                            atcInteracciones.setAtc(medAtc.getAtc());

                            try {
                                Atc atcInteraccion = new Atc();
                                atcInteraccion.setCodAtc(atcInteraccionesType.getAtcInteraccion());

                                logger.debug(
                                        "                         Cargando ATC_INTERACCION para el COD_ATC: "
                                                + atcInteraccionesType.getAtcInteraccion());
                                atcInteracciones.setInteraccion(atcRepository.findByCodAtc(atcInteraccion));
                                listaAtcInteracciones.add(atcInteracciones);
                                logger.debug("                         ATC_INTERACCION para el COD_ATC: "
                                        + atcInteraccion.getCodAtc() + " cargado correctamente");
                            } catch (NoResultException nre) {
                                logger.warn(
                                        "                         No se ha encontrado ATC_INTERACCION con COD_ATC: "
                                                + atcInteraccionesType.getAtcInteraccion()
                                                + ". Insertando registro");
                            }
                        }
                        atcInteraccionesService.save(medAtc.getAtc(), listaAtcInteracciones);
                        logger.debug("                    ATC_INTERACCIONES cargados correctamente");
                    }

                    //ATC_DUPLICIDADES
                    if (medicamentosAtcType.getDuplicidades() != null
                            && !medicamentosAtcType.getDuplicidades().isEmpty()) {
                        logger.debug("                    Cargando ATC_DUPLICIDADES");
                        List<AtcDuplicidades> listaAtcDuplicidades = new ArrayList<>();
                        Iterator<AtcDuplicidadesType> iteradorAtcDuplicidades = medicamentosAtcType
                                .getDuplicidades().iterator();
                        while (iteradorAtcDuplicidades.hasNext()) {
                            AtcDuplicidadesType atcDuplicidadesType = iteradorAtcDuplicidades.next();

                            AtcDuplicidades atcDuplicidades = new AtcDuplicidades();
                            atcDuplicidades.setDescripcionAtc(atcDuplicidadesType.getDescripcionAtc());
                            atcDuplicidades.setEfecto(atcDuplicidadesType.getEfecto());
                            atcDuplicidades.setOrientacion(atcDuplicidadesType.getOrientacion());
                            atcDuplicidades.setAtc(medAtc.getAtc());

                            try {
                                Atc atcDuplicidad = new Atc();
                                atcDuplicidad.setCodAtc(atcDuplicidadesType.getAtcDuplicidad());

                                logger.debug(
                                        "                         Cargando ATC_DUPLICIDAD para el COD_ATC: "
                                                + atcDuplicidadesType.getAtcDuplicidad());
                                atcDuplicidades.setDuplicidad(atcRepository.findByCodAtc(atcDuplicidad));
                                listaAtcDuplicidades.add(atcDuplicidades);
                                logger.debug("                         ATC_DUPLICIDAD para el COD_ATC: "
                                        + atcDuplicidad.getCodAtc() + " cargado correctamente");
                            } catch (NoResultException nre) {
                                logger.warn(
                                        "                         No se ha encontrado ATC_DUPLICIDAD con COD_ATC: "
                                                + atcDuplicidadesType.getAtcDuplicidad()
                                                + ". Insertando registro");
                            }
                        }
                        atcDuplicidadesService.save(medAtc.getAtc(), listaAtcDuplicidades);
                        logger.debug("                    ATC_DUPLICIDADES cargados correctamente");
                    }

                    //ATC_TERATOGENIAS
                    if (StringUtils.isNotBlank(medicamentosAtcType.getTeratogenia())) {
                        logger.debug("                    Cargando ATC_TERATOGENIAS");
                        AtcTeratogenias atcTeratogenias = new AtcTeratogenias();
                        atcTeratogenias.setAtc(medAtc.getAtc());

                        try {
                            logger.debug("                         Cargando ATC_TERATOGENIA para el COD_ATC: "
                                    + medAtc.getAtc().getCodAtc());
                            atcTeratogenias = atcTeratogeniasRepository.findByCodAtc(atcTeratogenias);
                            logger.debug("                         ATC_TERATOGENIA para el COD_ATC: "
                                    + atcTeratogenias.getAtc().getCodAtc() + " cargado correctamente");
                        } catch (NoResultException nre) {
                            logger.warn(
                                    "                         No se ha encontrado ATC_TERATOGENIA con COD_ATC: "
                                            + medAtc.getAtc().getCodAtc() + ". Insertando registro");
                        } finally {
                            atcTeratogenias.setTxtTeratogenia(medicamentosAtcType.getTeratogenia());
                            atcTeratogeniasRepository.save(atcTeratogenias);
                        }
                        logger.debug("                    ATC_TERATOGENIAS cargados correctamente");

                    }

                    //ATC_DESACON
                    if (medicamentosAtcType.getDesaconsejadosGeriatria() != null
                            && !medicamentosAtcType.getDesaconsejadosGeriatria().isEmpty()) {
                        logger.debug("                    Cargando ATC_DESACON");
                        Iterator<AtcDesaconsejadosType> iteradorAtcDesaconsejados = medicamentosAtcType
                                .getDesaconsejadosGeriatria().iterator();
                        while (iteradorAtcDesaconsejados.hasNext()) {
                            AtcDesaconsejadosType atcDesaconsejadosType = iteradorAtcDesaconsejados.next();

                            AtcDesacon atcDesacon = new AtcDesacon();
                            atcDesacon.setAtc(medAtc.getAtc());

                            try {
                                logger.debug("                         Cargando ATC_DESACON para el COD_ATC: "
                                        + medAtc.getAtc().getCodAtc());
                                atcDesacon = atcDesaconRepository.findByCodAtc(atcDesacon);
                                logger.debug("                         ATC_DESACON para el COD_ATC: "
                                        + atcDesacon.getAtc().getCodAtc() + " cargado correctamente");
                            } catch (NoResultException nre) {
                                logger.warn(
                                        "                         No se ha encontrado ATC_DESACON con COD_ATC: "
                                                + medAtc.getAtc().getCodAtc() + ". Insertando registro");
                            } finally {
                                atcDesacon.setBibliografia(atcDesaconsejadosType.getBibliografia());
                                atcDesacon.setDescripcion(atcDesaconsejadosType.getDescripcion());
                                atcDesacon
                                        .setOrientacionTerap(atcDesaconsejadosType.getOrientacionTerapeutica());
                                atcDesacon.setRiesgoPaciente(atcDesaconsejadosType.getRiesgoPacience());
                                atcDesacon.setSituacionAlerta(atcDesaconsejadosType.getSituacionAlerta());
                                atcDesaconRepository.save(atcDesacon);
                            }
                        }
                        logger.debug("                    ATC_DESACON cargados correctamente");
                    }

                } catch (NoResultException nre) {
                    logger.warn("               No se ha encontrado ATC con COD_ATC: "
                            + medicamentosAtcType.getCodAtc());
                }
            }
            logger.debug("          MED_ATC cargados correctamente");
        }
    }
}

From source file:com.taobao.android.differ.dex.DexDiffer.java

/**
 * ?davikclass??/*from w  w w  .j  ava  2 s . c  o m*/
 *
 * @param className
 * @return
 */
public static String getDalvikClassName(String className) {
    if (className.charAt(0) != 'L' || className.charAt(className.length() - 1) != ';') {
        throw new RuntimeException("Not a valid dalvik class name");
    }
    return StringUtils.replace(className.substring(1, className.length() - 1), "/", ".");
}

From source file:com.neophob.sematrix.gui.GeneratorGui.java

public void setup() {
    size(windowWidth, windowHeight);/*from www.j a v  a 2s  .c  o  m*/
    LOG.log(Level.INFO, "Create GUI Window with size " + this.getWidth() + "/" + this.getHeight()); //$NON-NLS-1$ //$NON-NLS-2$

    frameRate(Collector.getInstance().getFps());
    smooth();
    background(0, 0, 0);
    int i = 0;

    cp5 = new ControlP5(this);
    cp5.setAutoDraw(false);

    //press alt and you can move gui elements arround. disable this *should* work but does not...
    cp5.setMoveable(false);

    //alt-h hide all controls - I don't want that!
    cp5.disableShortcuts();

    cp5.getTooltip().setDelay(200);
    P5EventListener listener = new P5EventListener(this);

    //selected visual
    Collector col = Collector.getInstance();
    int nrOfVisuals = col.getAllVisuals().size();

    int w = singleVisualXSize < MINIMAL_VISUAL_WIDTH ? MINIMAL_VISUAL_WIDTH - 1 : singleVisualXSize - 1;
    selectedVisualList = cp5.addRadioButton(GuiElement.CURRENT_VISUAL.guiText(), getVisualCenter(col),
            p5GuiYOffset - 58);
    selectedVisualList.setItemsPerRow(nrOfVisuals);
    selectedVisualList.setNoneSelectedAllowed(false);
    for (i = 0; i < nrOfVisuals; i++) {
        String s = messages.getString("GeneratorGui.GUI_SELECTED_VISUAL") + (1 + i); //$NON-NLS-1$
        Toggle t = cp5.addToggle(s, 0, 0, w, 13);
        t.setCaptionLabel(s);
        selectedVisualList.addItem(t, i);
        cp5.getTooltip().register(s, messages.getString("GeneratorGui.GUI_SELECTED_VISUAL_TOOLTIP_PREFIX") //$NON-NLS-1$
                + (1 + i) + messages.getString("GeneratorGui.GUI_SELECTED_VISUAL_TOOLTIP_POSTFIX")); //$NON-NLS-1$
    }
    selectedVisualList.moveTo(ALWAYS_VISIBLE_TAB);

    cp5.addTextlabel("gen1", messages.getString("GeneratorGui.GUI_GENERATOR_LAYER_1"), GENERIC_X_OFS + 3, //$NON-NLS-1$//$NON-NLS-2$
            3 + p5GuiYOffset).moveTo(ALWAYS_VISIBLE_TAB).getValueLabel();
    cp5.addTextlabel("gen2", messages.getString("GeneratorGui.GUI_GENERATOR_LAYER_2"), //$NON-NLS-1$//$NON-NLS-2$
            GENERIC_X_OFS + 3 + 3 * Theme.DROPBOX_XOFS, 3 + p5GuiYOffset).moveTo(ALWAYS_VISIBLE_TAB)
            .getValueLabel();
    cp5.addTextlabel("fx1", messages.getString("GeneratorGui.GUI_EFFECT_LAYER_1"), //$NON-NLS-1$//$NON-NLS-2$
            GENERIC_X_OFS + 3 + 1 * Theme.DROPBOX_XOFS, 3 + p5GuiYOffset).moveTo(ALWAYS_VISIBLE_TAB)
            .getValueLabel();
    cp5.addTextlabel("fx2", messages.getString("GeneratorGui.GUI_EFFECT_LAYER_2"), //$NON-NLS-1$//$NON-NLS-2$
            GENERIC_X_OFS + 3 + 4 * Theme.DROPBOX_XOFS, 3 + p5GuiYOffset).moveTo(ALWAYS_VISIBLE_TAB)
            .getValueLabel();
    cp5.addTextlabel("mix2", messages.getString("GeneratorGui.GUI_LAYER_MIXER"), //$NON-NLS-1$//$NON-NLS-2$
            GENERIC_X_OFS + 3 + 2 * Theme.DROPBOX_XOFS, 3 + p5GuiYOffset).moveTo(ALWAYS_VISIBLE_TAB)
            .getValueLabel();

    cp5.getTooltip().register("gen1", messages.getString("GeneratorGui.GUI_TOOLTIP_GENERATOR_1")); //$NON-NLS-1$ //$NON-NLS-2$
    cp5.getTooltip().register("gen2", messages.getString("GeneratorGui.GUI_TOOLTIP_GENERATOR_2")); //$NON-NLS-1$ //$NON-NLS-2$
    cp5.getTooltip().register("fx1", messages.getString("GeneratorGui.GUI_TOOLTIP_EFFECT_1")); //$NON-NLS-1$ //$NON-NLS-2$
    cp5.getTooltip().register("fx2", messages.getString("GeneratorGui.GUI_TOOLTIP_EFFECT_2")); //$NON-NLS-1$ //$NON-NLS-2$
    cp5.getTooltip().register("mix2", messages.getString("GeneratorGui.GUI_TOOLTIP_MIXER")); //$NON-NLS-1$ //$NON-NLS-2$

    //Generator 
    generatorListOne = cp5.addDropdownList(GuiElement.GENERATOR_ONE_DROPDOWN.guiText(), GENERIC_X_OFS,
            p5GuiYOffset, Theme.DROPBOXLIST_LENGTH, 140);
    generatorListTwo = cp5.addDropdownList(GuiElement.GENERATOR_TWO_DROPDOWN.guiText(),
            GENERIC_X_OFS + 3 * Theme.DROPBOX_XOFS, p5GuiYOffset, Theme.DROPBOXLIST_LENGTH, 140);
    Theme.themeDropdownList(generatorListOne);
    Theme.themeDropdownList(generatorListTwo);

    for (GeneratorName gn : GeneratorName.values()) {
        generatorListOne.addItem(gn.guiText(), gn.getId());
        generatorListTwo.addItem(gn.guiText(), gn.getId());
    }

    generatorListOne.setLabel(generatorListOne.getItem(1).getName());
    generatorListTwo.setLabel(generatorListTwo.getItem(1).getName());
    generatorListOne.moveTo(ALWAYS_VISIBLE_TAB);
    generatorListTwo.moveTo(ALWAYS_VISIBLE_TAB);
    generatorListOne.setHeight(Theme.DROPBOXLIST_LARGE_HEIGHT);
    generatorListTwo.setHeight(Theme.DROPBOXLIST_LARGE_HEIGHT);

    //Effect 
    effectListOne = cp5.addDropdownList(GuiElement.EFFECT_ONE_DROPDOWN.guiText(),
            GENERIC_X_OFS + 1 * Theme.DROPBOX_XOFS, p5GuiYOffset, Theme.DROPBOXLIST_LENGTH, 140);
    effectListTwo = cp5.addDropdownList(GuiElement.EFFECT_TWO_DROPDOWN.guiText(),
            GENERIC_X_OFS + 4 * Theme.DROPBOX_XOFS, p5GuiYOffset, Theme.DROPBOXLIST_LENGTH, 140);
    Theme.themeDropdownList(effectListOne);
    Theme.themeDropdownList(effectListTwo);

    for (EffectName gn : EffectName.values()) {
        effectListOne.addItem(gn.guiText(), gn.getId());
        effectListTwo.addItem(gn.guiText(), gn.getId());
    }
    effectListOne.setLabel(effectListOne.getItem(0).getName());
    effectListTwo.setLabel(effectListTwo.getItem(0).getName());
    effectListOne.moveTo(ALWAYS_VISIBLE_TAB);
    effectListTwo.moveTo(ALWAYS_VISIBLE_TAB);
    effectListOne.setHeight(Theme.DROPBOXLIST_LARGE_HEIGHT);
    effectListTwo.setHeight(Theme.DROPBOXLIST_LARGE_HEIGHT);

    //Mixer 
    mixerList = cp5.addDropdownList(GuiElement.MIXER_DROPDOWN.guiText(), GENERIC_X_OFS + 2 * Theme.DROPBOX_XOFS,
            p5GuiYOffset, Theme.DROPBOXLIST_LENGTH, 140);
    Theme.themeDropdownList(mixerList);

    for (MixerName gn : MixerName.values()) {
        mixerList.addItem(gn.guiText(), gn.getId());
    }
    mixerList.setLabel(mixerList.getItem(0).getName());
    mixerList.setHeight(Theme.DROPBOXLIST_LARGE_HEIGHT);
    mixerList.moveTo(ALWAYS_VISIBLE_TAB);

    //---------------------------------
    //TABS
    //---------------------------------

    final int yPosStartLabel = p5GuiYOffset + 50;
    final int yPosStartDrowdown = p5GuiYOffset + 36;

    cp5.getWindow().setPositionOfTabs(GENERIC_X_OFS, this.getHeight() - 20);

    //there a default tab which is present all the time. rename this tab
    Tab generatorTab = cp5.getTab("default"); //$NON-NLS-1$
    allTabs.add(generatorTab);
    generatorTab.setLabel(messages.getString("GeneratorGui.TAB_GENERATOR_EFFECT")); //$NON-NLS-1$
    Tab outputTab = cp5.addTab(messages.getString("GeneratorGui.TAB_SINGLE_OUTPUT_MAPPING")); //$NON-NLS-1$
    allTabs.add(outputTab);
    Tab allOutputTab = null;

    //add all output mapping only if multiple output panels exist
    if (nrOfVisuals > 2) {
        allOutputTab = cp5.addTab(messages.getString("GeneratorGui.TAB_ALL_OUTPUT_MAPPING")); //$NON-NLS-1$
        allOutputTab.setColorForeground(0xffff0000);
        allTabs.add(allOutputTab);
    }

    Tab randomTab = cp5.addTab(messages.getString("GeneratorGui.TAB_RANDOMIZE")); //$NON-NLS-1$
    allTabs.add(randomTab);
    Tab presetTab = cp5.addTab(messages.getString("GeneratorGui.TAB_PRESETS")); //$NON-NLS-1$
    allTabs.add(presetTab);
    Tab infoTab = cp5.addTab(messages.getString("GeneratorGui.TAB_INFO")); //$NON-NLS-1$
    allTabs.add(infoTab);
    Tab helpTab = cp5.addTab(messages.getString("GeneratorGui.TAB_HELP")); //$NON-NLS-1$
    allTabs.add(helpTab);

    generatorTab.setColorForeground(0xffff0000);
    outputTab.setColorForeground(0xffff0000);
    randomTab.setColorForeground(0xffff0000);
    presetTab.setColorForeground(0xffff0000);
    helpTab.setColorForeground(0xffff0000);

    generatorTab.bringToFront();

    //-------------
    //Generic Options
    //-------------
    //generator speed slider
    generatorSpeedSlider = cp5.addSlider(GuiElement.GENERATOR_SPEED.guiText(), 0f, 2.0f, 1f, 38 + GENERIC_X_OFS,
            p5GuiYOffset + 97, 140, 14);
    generatorSpeedSlider.setSliderMode(Slider.FIX);
    generatorSpeedSlider.setGroup(generatorTab);
    generatorSpeedSlider.setDecimalPrecision(0);
    generatorSpeedSlider.setRange(0, 200);
    generatorSpeedSlider.setLabelVisible(true);

    //beat animation
    cp5.addTextlabel("beatWorkmode", messages.getString("GeneratorGui.BEAT_WORKMODE"),
            38 + GENERIC_X_OFS + 2 * Theme.DROPBOX_XOFS, p5GuiYOffset + 113 + 5).moveTo(generatorTab)
            .getValueLabel();
    beatWorkmode = cp5.addDropdownList(GuiElement.BEAT_WORKMODE.guiText(),
            38 + GENERIC_X_OFS + 2 * Theme.DROPBOX_XOFS, p5GuiYOffset + 113, Theme.DROPBOXLIST_LENGTH, 140);
    Theme.themeDropdownList(beatWorkmode);
    for (BeatToAnimation bta : BeatToAnimation.values()) {
        beatWorkmode.addItem(bta.guiText(), bta.getId());
    }
    beatWorkmode.setLabel(beatWorkmode.getItem(0).getName());
    beatWorkmode.setGroup(generatorTab);
    beatWorkmode.setHeight(Theme.DROPBOXLIST_HEIGHT);

    //freeze update 
    freeze = cp5.addToggle(GuiElement.BUTTON_TOGGLE_FREEZE.guiText(), 730, 2, 15, 15)
            .moveTo(ALWAYS_VISIBLE_TAB);
    freeze.setLabelVisible(false);
    cp5.addTextlabel("freezeUpdateTxt", messages.getString("GeneratorGui.GUI_TOGGLE_FREEZE"), 745, 5)
            .moveTo(ALWAYS_VISIBLE_TAB);
    cp5.getTooltip().register(GuiElement.BUTTON_TOGGLE_FREEZE.guiText(),
            messages.getString("GeneratorGui.TOOLTIP_FREEZE")); //$NON-NLS-1$

    //toggle internal visuals
    Toggle t2 = cp5.addToggle(GuiElement.BUTTON_TOGGLE_INTERNAL_VISUALS.guiText(), 730, 20, 15, 15)
            .moveTo(ALWAYS_VISIBLE_TAB);
    t2.setLabelVisible(false);
    cp5.addTextlabel("toggleIKnternalVisualsTxt", messages.getString("GeneratorGui.GUI_TOGGLE_INTERNAL_BUFFER"), //$NON-NLS-1$
            745, 23).moveTo(ALWAYS_VISIBLE_TAB);
    ;
    cp5.getTooltip().register(GuiElement.BUTTON_TOGGLE_INTERNAL_VISUALS.guiText(),
            messages.getString("GeneratorGui.TOOLTIP_GUI_TOGGLE_INTERNAL_BUFFER")); //$NON-NLS-1$

    //-------------
    //GENERATOR/EFFECT tab
    //-------------

    int genFxXOfs = 38 + GENERIC_X_OFS;

    //EFFECTS OPTIONS
    //---------------
    int genElYOfs = yPosStartDrowdown + 105;
    cp5.addTextlabel("genOptionsFx", messages.getString("GeneratorGui.EFFECT_OPTIONS"), GENERIC_X_OFS, //$NON-NLS-1$//$NON-NLS-2$
            genElYOfs).moveTo(generatorTab).getValueLabel();

    //threshold slider
    thresholdSlider = cp5.addSlider(GuiElement.THRESHOLD.guiText(), 0, 255, 255, genFxXOfs, genElYOfs + 60, 140,
            14);
    thresholdSlider.setSliderMode(Slider.FIX);
    thresholdSlider.setGroup(generatorTab);
    thresholdSlider.setDecimalPrecision(0);

    //rotozoom slider
    fxRotoSlider = cp5.addSlider(GuiElement.FX_ROTOZOOMER.guiText(), -127, 127, 0,
            genFxXOfs + 2 * Theme.DROPBOX_XOFS, genElYOfs + 60, 140, 14);
    fxRotoSlider.setSliderMode(Slider.FIX);
    fxRotoSlider.setGroup(generatorTab);
    fxRotoSlider.setDecimalPrecision(0);
    fxRotoSlider.setCaptionLabel(messages.getString("GeneratorGui.EFFECT_ROTOZOOM_SPEED")); //$NON-NLS-1$

    genElYOfs += 25;

    //texturedeform options
    cp5.addTextlabel("genTextdefOpt", messages.getString("GeneratorGui.TEXTUREDDEFORM_OPTIONS"), //$NON-NLS-1$//$NON-NLS-2$
            genFxXOfs + 3 + 0 * Theme.DROPBOX_XOFS, genElYOfs + 16).moveTo(generatorTab).getValueLabel();
    textureDeformOptions = cp5.addDropdownList(GuiElement.TEXTUREDEFORM_OPTIONS.guiText(),
            genFxXOfs + 0 * Theme.DROPBOX_XOFS, genElYOfs + 11, Theme.DROPBOXLIST_LENGTH, 80);
    Theme.themeDropdownList(textureDeformOptions);
    textureDeformOptions.addItem(messages.getString("GeneratorGui.TEXTUREDEFORM_ANAMORPHOSIS"), 1); //$NON-NLS-1$
    textureDeformOptions.addItem(messages.getString("GeneratorGui.TEXTUREDEFORM_SPIRAL"), 2); //$NON-NLS-1$
    textureDeformOptions.addItem(messages.getString("GeneratorGui.TEXTUREDEFORM_ROTATINGTUNNEL"), 3); //$NON-NLS-1$
    textureDeformOptions.addItem(messages.getString("GeneratorGui.TEXTUREDEFORM_START"), 4); //$NON-NLS-1$
    textureDeformOptions.addItem(messages.getString("GeneratorGui.TEXTUREDEFORM_TUNNEL"), 5); //$NON-NLS-1$
    textureDeformOptions.addItem(messages.getString("GeneratorGui.TEXTUREDEFORM_FLOWER"), 6); //$NON-NLS-1$
    textureDeformOptions.addItem(messages.getString("GeneratorGui.TEXTUREDEFORM_CLOUD"), 7); //$NON-NLS-1$
    textureDeformOptions.addItem(messages.getString("GeneratorGui.TEXTUREDEFORM_PLANAR"), 8); //$NON-NLS-1$
    textureDeformOptions.addItem(messages.getString("GeneratorGui.TEXTUREDEFORM_CIRCLE"), 9); //$NON-NLS-1$
    textureDeformOptions.addItem(messages.getString("GeneratorGui.TEXTUREDEFORM_SPIRAL"), 10); //$NON-NLS-1$
    textureDeformOptions.addItem(messages.getString("GeneratorGui.TEXTUREDEFORM_3D"), 11); //$NON-NLS-1$
    textureDeformOptions.setLabel(textureDeformOptions.getItem(1).getName());
    textureDeformOptions.setGroup(generatorTab);

    cp5.addTextlabel("genZoomOpt", messages.getString("GeneratorGui.ZOOM_OPTIONS"), //$NON-NLS-1$//$NON-NLS-2$
            genFxXOfs + 3 + 1 * Theme.DROPBOX_XOFS, genElYOfs + 16).moveTo(generatorTab).getValueLabel();
    zoomOptions = cp5.addDropdownList(GuiElement.ZOOM_OPTIONS.guiText(), genFxXOfs + 1 * Theme.DROPBOX_XOFS,
            genElYOfs + 11, Theme.DROPBOXLIST_LENGTH, 80);
    Theme.themeDropdownList(zoomOptions);
    zoomOptions.addItem(messages.getString("GeneratorGui.ZOOM_IN"), 0); //$NON-NLS-1$
    zoomOptions.addItem(messages.getString("GeneratorGui.ZOOM_OUT"), 1); //$NON-NLS-1$
    zoomOptions.addItem(messages.getString("GeneratorGui.ZOOM_HORIZONTAL"), 2); //$NON-NLS-1$
    zoomOptions.addItem(messages.getString("GeneratorGui.ZOOM_VERTICAL"), 3); //$NON-NLS-1$
    zoomOptions.setLabel(zoomOptions.getItem(0).getName());
    zoomOptions.setGroup(generatorTab);

    //GENERATOR OPTIONS
    //-----------------

    FileUtils fu = new FileUtils();

    genElYOfs = p5GuiYOffset + 35;
    cp5.addTextlabel("genOptionsGen", messages.getString("GeneratorGui.GENERATOR_OPTIONS"), GENERIC_X_OFS, //$NON-NLS-1$//$NON-NLS-2$
            genElYOfs).moveTo(generatorTab).getValueLabel();

    genElYOfs = yPosStartLabel + 5;

    //blinkenlights
    cp5.addTextlabel("genBlinken", messages.getString("GeneratorGui.BLINKENLIGHT_LOAD"), genFxXOfs + 3, //$NON-NLS-1$//$NON-NLS-2$
            genElYOfs + 16).moveTo(generatorTab).getValueLabel();
    blinkenLightsList = cp5.addDropdownList(GuiElement.BLINKENLIGHTS_DROPDOWN.guiText(), genFxXOfs,
            genElYOfs + 11, Theme.DROPBOXLIST_LENGTH, 140);
    Theme.themeDropdownList(blinkenLightsList);
    blinkenLightsList.addItems(fu.findBlinkenFiles());
    blinkenLightsList.setLabel(blinkenLightsList.getItem(1).getName());
    blinkenLightsList.setGroup(generatorTab);
    blinkenLightsList.setHeight(Theme.DROPBOXLIST_HEIGHT);

    //images
    cp5.addTextlabel("genImg", messages.getString("GeneratorGui.IMAGE_LOAD"), //$NON-NLS-1$//$NON-NLS-2$
            genFxXOfs + 3 + 1 * Theme.DROPBOX_XOFS, genElYOfs + 16).moveTo(generatorTab).getValueLabel();
    imageList = cp5.addDropdownList(GuiElement.IMAGE_DROPDOWN.guiText(), genFxXOfs + Theme.DROPBOX_XOFS,
            genElYOfs + 11, Theme.DROPBOXLIST_LENGTH, 140);
    Theme.themeDropdownList(imageList);
    imageList.addItems(fu.findImagesFiles());
    imageList.setLabel(imageList.getItem(1).getName());
    imageList.setGroup(generatorTab);
    imageList.setHeight(Theme.DROPBOXLIST_HEIGHT);

    //colorscroll options
    cp5.addTextlabel("genColorScroll", messages.getString("GeneratorGui.COLORSCROLL_OPTIONS"), //$NON-NLS-1$//$NON-NLS-2$
            genFxXOfs + 3 + 2 * Theme.DROPBOX_XOFS, genElYOfs + 16).moveTo(generatorTab).getValueLabel();
    colorScrollList = cp5.addDropdownList(GuiElement.COLORSCROLL_OPTIONS.guiText(),
            genFxXOfs + 2 * Theme.DROPBOX_XOFS, genElYOfs + 11, Theme.DROPBOXLIST_LENGTH, 140);
    Theme.themeDropdownList(colorScrollList);

    for (ScrollMode sm : ScrollMode.values()) {
        colorScrollList.addItem(sm.getDisplayName(), sm.getMode()); //$NON-NLS-1$ //$NON-NLS-2$
    }
    colorScrollList.setGroup(generatorTab);
    colorScrollList.setHeight(Theme.DROPBOXLIST_HEIGHT);
    colorScrollList.setLabel(col.getPixelControllerGenerator().getScrollMode().getDisplayName());

    //add textfield options
    cp5.addTextlabel("genTextwriterOpt", messages.getString("GeneratorGui.TEXTWRITER_OPTION"), //$NON-NLS-1$//$NON-NLS-2$
            genFxXOfs + 3 + 3 * Theme.DROPBOX_XOFS, genElYOfs + 16).moveTo(generatorTab).getValueLabel();
    textwriterOption = cp5.addDropdownList(GuiElement.TEXTWR_OPTION.guiText(),
            genFxXOfs + 3 * Theme.DROPBOX_XOFS, genElYOfs + 11, Theme.DROPBOXLIST_LENGTH, 140);
    Theme.themeDropdownList(textwriterOption);
    textwriterOption.addItem(messages.getString("GeneratorGui.TEXTWRITER_PINGPONG"), 0); //$NON-NLS-1$
    textwriterOption.addItem(messages.getString("GeneratorGui.TEXTWRITER_LEFT"), 1); //$NON-NLS-1$
    textwriterOption.setLabel(textwriterOption.getItem(0).getName());
    textwriterOption.setGroup(generatorTab);
    textwriterOption.setHeight(Theme.DROPBOXLIST_HEIGHT);

    //add textfield
    textGenerator = cp5.addTextfield(GuiElement.TEXTFIELD, GuiElement.TEXTFIELD.guiText(),
            GuiElement.TEXTFIELD.guiText(), genFxXOfs + 3 + 4 * Theme.DROPBOX_XOFS, genElYOfs - 6,
            Theme.DROPBOXLIST_LENGTH, 16); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$

    passThroughMode = cp5.addTextlabel("passThroughMode", "", genFxXOfs, yPosStartDrowdown + 50)
            .moveTo(generatorTab).getValueLabel();
    passThroughMode.setColor(0xffff0000);

    //-----------------
    //Single Output tab
    //-----------------            

    //brightness control
    cp5.addTextlabel("brightnessControllTxt", messages.getString("GeneratorGui.BRIGHTNESS"), 5,
            yPosStartDrowdown + 95).moveTo(outputTab);

    brightnessControll = cp5.addSlider(GuiElement.BRIGHTNESS.guiText(), 0, 255, 255, 38,
            yPosStartDrowdown + 110, 160, 14);
    brightnessControll.setSliderMode(Slider.FIX);
    brightnessControll.setGroup(outputTab);
    brightnessControll.setDecimalPrecision(0);
    brightnessControll.setNumberOfTickMarks(11);
    brightnessControll.setRange(0, 100);
    brightnessControll.setLabelVisible(false);

    int nrOfOutputs = Collector.getInstance().getAllOutputMappings().size();
    selectedOutputs = cp5.addRadioButton(GuiElement.CURRENT_OUTPUT.guiText(), GENERIC_X_OFS, yPosStartDrowdown);
    selectedOutputs.setItemsPerRow(nrOfOutputs);
    selectedOutputs.setNoneSelectedAllowed(false);
    for (i = 0; i < nrOfOutputs; i++) {
        String s = messages.getString("GeneratorGui.OUTPUT_NR") + (1 + i); //$NON-NLS-1$
        Toggle t = cp5.addToggle(s, 0, 0, singleVisualXSize, 13);
        t.setCaptionLabel(s);
        selectedOutputs.addItem(t, i);
        cp5.getTooltip().register(s, messages.getString("GeneratorGui.TOOLTIP_OUTPUT_PREFIX") + (1 + i) //$NON-NLS-1$
                + messages.getString("GeneratorGui.TOOLTIP_OUTPUT_POSTFIX")); //$NON-NLS-1$
    }
    selectedOutputs.moveTo(outputTab);

    //visual
    cp5.addTextlabel("singleOutputVisual", messages.getString("GeneratorGui.OUTPUT_VISUAL"), 38, //$NON-NLS-1$//$NON-NLS-2$
            yPosStartDrowdown + 60).moveTo(outputTab).getValueLabel();
    dropdownOutputVisual = GeneratorGuiHelper.createVisualDropdown(cp5,
            GuiElement.OUTPUT_SELECTED_VISUAL_DROPDOWN.guiText(), yPosStartDrowdown + 10, nrOfVisuals);
    dropdownOutputVisual.moveTo(outputTab);

    //Fader         
    cp5.addTextlabel("singleOutputTransition", messages.getString("GeneratorGui.OUTPUT_TRANSITION"), //$NON-NLS-1$//$NON-NLS-2$
            38 + Theme.DROPBOX_XOFS * 2, yPosStartDrowdown + 60).moveTo(outputTab).getValueLabel();
    dropdownOutputFader = GeneratorGuiHelper.createFaderDropdown(cp5,
            GuiElement.OUTPUT_FADER_DROPDOWN.guiText(), yPosStartDrowdown + 10);
    dropdownOutputFader.moveTo(outputTab);

    //--------------
    //All Output tab
    //--------------            

    if (allOutputTab != null) {
        cp5.addTextlabel("allOutputTabLabel", //$NON-NLS-1$
                messages.getString("GeneratorGui.TEXT_CHANGE_ALL_OUTPUT_MAPPINGS"), 20, yPosStartDrowdown) //$NON-NLS-1$
                .moveTo(allOutputTab).getValueLabel();

        cp5.addTextlabel("allOutputVisual", messages.getString("GeneratorGui.ALL_OUTPUT_VISUAL"), 38, //$NON-NLS-1$//$NON-NLS-2$
                yPosStartDrowdown + 68).moveTo(allOutputTab).getValueLabel();
        allOutputTabVis = GeneratorGuiHelper.createVisualDropdown(cp5,
                GuiElement.OUTPUT_ALL_SELECTED_VISUAL_DROPDOWN.guiText(), yPosStartDrowdown + 20, nrOfVisuals);
        allOutputTabVis.moveTo(allOutputTab);

        //Fader         
        cp5.addTextlabel("allOutputTransition", messages.getString("GeneratorGui.ALL_OUTPUT_TRANSITION"), //$NON-NLS-1$//$NON-NLS-2$
                38 + Theme.DROPBOX_XOFS * 2, yPosStartDrowdown + 68).moveTo(allOutputTab).getValueLabel();
        allOutputTabFader = GeneratorGuiHelper.createFaderDropdown(cp5,
                GuiElement.OUTPUT_ALL_FADER_DROPDOWN.guiText(), yPosStartDrowdown + 20);
        allOutputTabFader.moveTo(allOutputTab);
    }

    //palette dropdown list   
    cp5.addTextlabel("colSet", messages.getString("GeneratorGui.SELECT_COLORSET"), //$NON-NLS-1$//$NON-NLS-2$
            GENERIC_X_OFS + 5 * Theme.DROPBOX_XOFS, p5GuiYOffset + 3).moveTo(ALWAYS_VISIBLE_TAB)
            .getValueLabel();

    colorSetList = cp5.addDropdownList(GuiElement.COLOR_SET_DROPDOWN.guiText(),
            GENERIC_X_OFS + 5 * Theme.DROPBOX_XOFS, p5GuiYOffset, Theme.DROPBOXLIST_LENGTH, 140);
    Theme.themeDropdownList(colorSetList);
    i = 0;
    for (ColorSet cs : Collector.getInstance().getColorSets()) {
        colorSetList.addItem(cs.getName(), i);
        i++;
    }
    colorSetList.setLabel(colorSetList.getItem(1).getName());
    colorSetList.setHeight(Theme.DROPBOXLIST_LARGE_HEIGHT);
    colorSetList.moveTo(ALWAYS_VISIBLE_TAB);
    cp5.getTooltip().register("colSet", messages.getString("GeneratorGui.TOOLTIP_COLORSET")); //$NON-NLS-1$ //$NON-NLS-2$

    //----------
    //RANDOM Tab
    //----------            

    Textlabel tRnd = cp5.addTextlabel("rndDesc", //$NON-NLS-1$
            messages.getString("GeneratorGui.TEXT_RANDOM_MODE_SELECT_ELEMENTS"), //$NON-NLS-1$
            20, yPosStartDrowdown);
    tRnd.moveTo(randomTab).getValueLabel();

    randomCheckbox = cp5.addCheckBox(GuiElement.RANDOM_ELEMENT.guiText())
            .setPosition(35, 20 + yPosStartDrowdown).setSize(40, 20).setColorForeground(color(120))
            .setColorActive(color(255)).setColorLabel(color(255)).setItemsPerRow(5).setSpacingColumn(90);

    for (ShufflerOffset so : ShufflerOffset.values()) {
        randomCheckbox.addItem(so.guiText(), i);
    }
    randomCheckbox.activateAll();
    randomCheckbox.moveTo(randomTab);

    //Button
    randomSelection = cp5.addButton(GuiElement.BUTTON_RANDOM_CONFIGURATION.guiText(), 0,
            GENERIC_X_OFS + 5 * Theme.DROPBOX_XOFS, p5GuiYOffset + 30, 110, 15);
    randomSelection.setCaptionLabel(messages.getString("GeneratorGui.RANDOMIZE")); //$NON-NLS-1$
    randomSelection.moveTo(randomTab);
    cp5.getTooltip().register(GuiElement.BUTTON_RANDOM_CONFIGURATION.guiText(),
            messages.getString("GeneratorGui.TOOLTIP_RANDOMIZE")); //$NON-NLS-1$

    randomPresets = cp5.addButton(GuiElement.BUTTON_RANDOM_PRESET.guiText(), 0,
            GENERIC_X_OFS + 5 * Theme.DROPBOX_XOFS, p5GuiYOffset + 55, 110, 15);
    randomPresets.setCaptionLabel(messages.getString("GeneratorGui.RANDOM_PRESET")); //$NON-NLS-1$
    randomPresets.moveTo(randomTab);
    cp5.getTooltip().register(GuiElement.BUTTON_RANDOM_PRESET.guiText(),
            messages.getString("GeneratorGui.TOOLTIP_RANDOM_PRESET")); //$NON-NLS-1$

    randomButtons = cp5.addRadioButton(GuiElement.BUTTONS_RANDOM_MODE.guiText())
            .setPosition(GENERIC_X_OFS + 5 * Theme.DROPBOX_XOFS, p5GuiYOffset + 85).setSize(45, 15)
            .setColorForeground(color(120)).setColorActive(color(255)).setColorLabel(color(255))
            .setItemsPerRow(1).setSpacingColumn(26).setNoneSelectedAllowed(true).moveTo(randomTab);
    randomButtons.addItem(messages.getString("GeneratorGui.RANDOM_MODE"), 0);
    randomButtons.addItem(messages.getString("GeneratorGui.RANDOM_MODE_PRESET"), 1);

    //----------
    //PRESET Tab
    //----------

    presetButtons = cp5.addRadioButton(GuiElement.PRESET_BUTTONS.guiText()).setPosition(10, yPosStartDrowdown)
            .setSize(24, 14).setColorForeground(color(120)).setColorActive(color(255)).setColorLabel(color(255))
            .setItemsPerRow(16).setSpacingColumn(26).setNoneSelectedAllowed(false);

    for (i = 0; i < 96 + 48; i++) {
        String label = "" + i; //$NON-NLS-1$
        if (i < 10) {
            label = "0" + i; //$NON-NLS-1$
        }
        presetButtons.addItem(label, i);
    }
    presetButtons.activate(col.getSelectedPreset());
    presetButtons.moveTo(presetTab);

    loadPreset = cp5.addButton(GuiElement.LOAD_PRESET.guiText(), 0, GENERIC_X_OFS + 2 * Theme.DROPBOX_XOFS,
            yPosStartDrowdown + 170, 100, 15);
    loadPreset.setCaptionLabel(GuiElement.LOAD_PRESET.guiText());
    loadPreset.moveTo(presetTab);
    cp5.getTooltip().register(GuiElement.LOAD_PRESET.guiText(),
            messages.getString("GeneratorGui.TOOLTIP_LOAD_PRESET")); //$NON-NLS-1$

    savePreset = cp5.addButton(GuiElement.SAVE_PRESET.guiText(), 0, GENERIC_X_OFS + 3 * Theme.DROPBOX_XOFS,
            yPosStartDrowdown + 170, 100, 15);
    savePreset.setCaptionLabel(GuiElement.SAVE_PRESET.guiText());
    savePreset.moveTo(presetTab);
    cp5.getTooltip().register(GuiElement.SAVE_PRESET.guiText(),
            messages.getString("GeneratorGui.TOOLTIP_SAVE_PRESET")); //$NON-NLS-1$

    presetName = cp5.addTextfield("presetName", 20, yPosStartDrowdown + 170, Theme.DROPBOXLIST_LENGTH * 2, 16) //$NON-NLS-1$
            .moveTo(presetTab);
    presetInfo = cp5.addTextlabel("presetInfo", "", 160, yPosStartDrowdown + 170 + 18).moveTo(presetTab) //$NON-NLS-1$//$NON-NLS-2$
            .getValueLabel();

    updateCurrentPresetState();

    //-------------
    //Info tab
    //-------------

    int yposAdd = 18;
    int xposAdd = 200;

    //center it, we have 3 row which are 160 pixels wide
    int xOfs = (this.getWidth() - 3 * xposAdd) / 2;
    int nfoYPos = yPosStartDrowdown + 20;
    int nfoXPos = xOfs;

    cp5.addTextlabel("nfoFpsConf", messages.getString("GeneratorGui.CONF_FPS") + col.getFps(), nfoXPos, nfoYPos) //$NON-NLS-1$//$NON-NLS-2$
            .moveTo(infoTab).getValueLabel();
    nfoYPos += yposAdd;
    currentFps = cp5.addTextlabel("nfoFpsCurrent", "", nfoXPos, nfoYPos).moveTo(infoTab).getValueLabel(); //$NON-NLS-1$ //$NON-NLS-2$
    nfoYPos += yposAdd;
    runtime = cp5.addTextlabel("nfoRuntime", "", nfoXPos, nfoYPos).moveTo(infoTab).getValueLabel(); //$NON-NLS-1$ //$NON-NLS-2$
    nfoYPos += yposAdd;
    cp5.addTextlabel("nfoSrvVersion", //$NON-NLS-1$
            messages.getString("GeneratorGui.SERVER_VERSION") //$NON-NLS-1$
                    + Collector.getInstance().getPixConStat().getVersion(),
            nfoXPos, nfoYPos).moveTo(infoTab).getValueLabel();
    nfoYPos += yposAdd;
    float volNorm = Collector.getInstance().getSound().getVolumeNormalized();
    currentVolume = cp5.addTextlabel("nfoVolumeCurrent", //$NON-NLS-1$
            messages.getString("GeneratorGui.CURRENT_VOLUME") + volNorm, nfoXPos, nfoYPos).moveTo(infoTab) //$NON-NLS-1$
            .getValueLabel();
    nfoYPos += yposAdd;
    cp5.addTextlabel("nfoWindowHeight", //$NON-NLS-1$
            messages.getString("GeneratorGui.INFO_WINDOW_HEIGHT") + this.getHeight(), nfoXPos, nfoYPos) //$NON-NLS-1$
            .moveTo(infoTab).getValueLabel();
    nfoYPos += yposAdd;
    int ibsX = col.getPixelControllerGenerator().getGenerator(0).getInternalBufferXSize();
    int ibsY = col.getPixelControllerGenerator().getGenerator(0).getInternalBufferYSize();
    cp5.addTextlabel("nfoInternalBuffer", //$NON-NLS-1$
            messages.getString("GeneratorGui.INFO_INTERNAL_BUFFERSIZE") + ibsX + "/" + ibsY, nfoXPos, nfoYPos) //$NON-NLS-1$
            .moveTo(infoTab).getValueLabel();
    nfoYPos += yposAdd;

    Button saveScreenshot = cp5.addButton(GuiElement.SAVE_SCREENSHOT.guiText(), 0, nfoXPos, nfoYPos, 110, 15);
    saveScreenshot.setCaptionLabel(messages.getString("GeneratorGui.SAVE_SCREENSHOT")); //$NON-NLS-1$
    saveScreenshot.moveTo(infoTab);
    cp5.getTooltip().register(GuiElement.SAVE_SCREENSHOT.guiText(),
            messages.getString("GeneratorGui.TOOLTIP_SAVE_SCREENSHOT")); //$NON-NLS-1$

    nfoXPos += xposAdd;
    nfoYPos = yPosStartDrowdown + 20;
    IOutput output = col.getOutputDevice();
    if (output != null) {
        String gammaText = WordUtils
                .capitalizeFully(StringUtils.replace(output.getGammaType().toString(), "_", " "));
        cp5.addTextlabel("nfoGamma", messages.getString("GeneratorGui.GAMMA_CORRECTION") + gammaText, nfoXPos, //$NON-NLS-1$//$NON-NLS-2$
                nfoYPos).moveTo(infoTab).getValueLabel();
        nfoYPos += yposAdd;
        cp5.addTextlabel("nfoBps", messages.getString("GeneratorGui.OUTPUT_BPP") + output.getBpp(), nfoXPos, //$NON-NLS-1$//$NON-NLS-2$
                nfoYPos).moveTo(infoTab).getValueLabel();
        nfoYPos += yposAdd;
    }
    sentFrames = cp5.addTextlabel("nfoSentFrames", "", nfoXPos, nfoYPos).moveTo(infoTab).getValueLabel(); //$NON-NLS-1$ //$NON-NLS-2$
    nfoYPos += yposAdd;
    outputErrorCounter = cp5.addTextlabel("nfoErrorFrames", "", nfoXPos, nfoYPos).moveTo(infoTab) //$NON-NLS-1$//$NON-NLS-2$
            .getValueLabel();
    nfoYPos += yposAdd;
    outputState = cp5.addTextlabel("nfoOutputState", "", nfoXPos, nfoYPos).moveTo(infoTab).getValueLabel(); //$NON-NLS-1$ //$NON-NLS-2$
    nfoYPos += yposAdd;

    nfoXPos += xposAdd;
    nfoYPos = yPosStartDrowdown + 20;
    String oscPort = col.getPh().getProperty(ConfigConstant.NET_OSC_LISTENING_PORT, ""); //$NON-NLS-1$ //$NON-NLS-2$
    cp5.addTextlabel("nfoOscPort", messages.getString("GeneratorGui.OSC_PORT") + oscPort, nfoXPos, nfoYPos) //$NON-NLS-1$//$NON-NLS-2$
            .moveTo(infoTab).getValueLabel();
    nfoYPos += yposAdd;
    oscStatistic = cp5
            .addTextlabel("nfoOscStatistic", messages.getString("GeneratorGui.OSC_STATISTIC"), nfoXPos, nfoYPos)
            .moveTo(infoTab).getValueLabel();
    nfoYPos += yposAdd;

    //-------------
    //Help tab
    //-------------

    int hlpYOfs = yPosStartDrowdown;
    int hlpXOfs1 = 20;
    int hlpXOfs2 = 240;
    int hlpYposAdd = 15;

    cp5.addTextlabel("hlpHeader1", messages.getString("GeneratorGui.HLP_HEADER1"), hlpXOfs1, hlpYOfs) //$NON-NLS-1$//$NON-NLS-2$
            .moveTo(helpTab).getValueLabel();
    hlpYOfs += hlpYposAdd / 2;
    cp5.addTextlabel("hlpHeader2", messages.getString("GeneratorGui.HLP_HEADER2"), hlpXOfs1, hlpYOfs) //$NON-NLS-1$//$NON-NLS-2$
            .moveTo(helpTab).getValueLabel();
    hlpYOfs += hlpYposAdd;
    cp5.addTextlabel("hlpHeader3", messages.getString("GeneratorGui.HLP_HEADER3"), hlpXOfs1, hlpYOfs) //$NON-NLS-1$//$NON-NLS-2$
            .moveTo(helpTab).getValueLabel();
    hlpYOfs += hlpYposAdd;
    cp5.addTextlabel("hlpHeader4", messages.getString("GeneratorGui.HLP_HEADER4"), hlpXOfs1, hlpYOfs) //$NON-NLS-1$//$NON-NLS-2$
            .moveTo(helpTab).getValueLabel();
    hlpYOfs += hlpYposAdd;
    hlpYOfs += hlpYposAdd / 2;
    cp5.addTextlabel("hlpKeyHeader", messages.getString("GeneratorGui.HLP_KEYBINDING_HEADER"), hlpXOfs1, //$NON-NLS-1$//$NON-NLS-2$
            hlpYOfs).moveTo(helpTab).getValueLabel();

    hlpXOfs1 *= 2;
    hlpYOfs += hlpYposAdd;
    cp5.addTextlabel("HLP_KEY_19", messages.getString("GeneratorGui.HLP_KEY_19"), hlpXOfs1, hlpYOfs) //$NON-NLS-1$//$NON-NLS-2$
            .moveTo(helpTab).getValueLabel();

    hlpYOfs += hlpYposAdd;
    cp5.addTextlabel("HLP_KEY_F", messages.getString("GeneratorGui.HLP_KEY_F"), hlpXOfs1, hlpYOfs) //$NON-NLS-1$//$NON-NLS-2$
            .moveTo(helpTab).getValueLabel();
    cp5.addTextlabel("HLP_KEY_G", messages.getString("GeneratorGui.HLP_KEY_G"), hlpXOfs2, hlpYOfs) //$NON-NLS-1$//$NON-NLS-2$
            .moveTo(helpTab).getValueLabel();

    hlpYOfs += hlpYposAdd;
    cp5.addTextlabel("HLP_KEY_W", messages.getString("GeneratorGui.HLP_KEY_W"), hlpXOfs1, hlpYOfs) //$NON-NLS-1$//$NON-NLS-2$
            .moveTo(helpTab).getValueLabel();
    cp5.addTextlabel("HLP_KEY_E", messages.getString("GeneratorGui.HLP_KEY_E"), hlpXOfs2, hlpYOfs) //$NON-NLS-1$//$NON-NLS-2$
            .moveTo(helpTab).getValueLabel();

    hlpYOfs += hlpYposAdd;
    cp5.addTextlabel("HLP_KEY_M", messages.getString("GeneratorGui.HLP_KEY_M"), hlpXOfs1, hlpYOfs) //$NON-NLS-1$//$NON-NLS-2$
            .moveTo(helpTab).getValueLabel();

    hlpYOfs += hlpYposAdd;
    cp5.addTextlabel("HLP_KEY_C", messages.getString("GeneratorGui.HLP_KEY_C"), hlpXOfs1, hlpYOfs) //$NON-NLS-1$//$NON-NLS-2$
            .moveTo(helpTab).getValueLabel();

    hlpYOfs += hlpYposAdd;
    cp5.addTextlabel("HLP_KEY_R", messages.getString("GeneratorGui.HLP_KEY_R"), hlpXOfs1, hlpYOfs) //$NON-NLS-1$//$NON-NLS-2$
            .moveTo(helpTab).getValueLabel();

    hlpYOfs += hlpYposAdd;
    cp5.addTextlabel("HLP_KEY_LEFT", messages.getString("GeneratorGui.HLP_KEY_LEFT"), hlpXOfs1, hlpYOfs) //$NON-NLS-1$//$NON-NLS-2$
            .moveTo(helpTab).getValueLabel();
    cp5.addTextlabel("HLP_KEY_RIGHT", messages.getString("GeneratorGui.HLP_KEY_RIGHT"), hlpXOfs2, hlpYOfs) //$NON-NLS-1$//$NON-NLS-2$
            .moveTo(helpTab).getValueLabel();
    //----------
    // LOGO
    //----------    

    try {
        logo = loadImage(fu.getDataDir() + File.separator + "gui" + File.separatorChar + "guilogo.jpg");
        LOG.log(Level.INFO, "GUI logo loaded");
    } catch (Exception e) {
        LOG.log(Level.INFO, "Failed to load gui logo!", e);
    }

    //----------
    // MISC
    //----------    

    int xSizeForEachWidget = (windowWidth - 2 * GENERIC_X_OFS) / NR_OF_WIDGETS;

    cp5.addTextlabel("frameDesc", messages.getString("GeneratorGui.FRAME_PROGRESS"), GENERIC_X_OFS, //$NON-NLS-1$//$NON-NLS-2$
            GENERIC_Y_OFS).moveTo(ALWAYS_VISIBLE_TAB).getValueLabel();
    cp5.addTextlabel("sndDesc", messages.getString("GeneratorGui.SOUND_DESC"), //$NON-NLS-1$//$NON-NLS-2$
            GENERIC_X_OFS + xSizeForEachWidget, GENERIC_Y_OFS).moveTo(ALWAYS_VISIBLE_TAB).getValueLabel();
    cp5.addTextlabel("sndVol", messages.getString("GeneratorGui.INPUT_VOLUME"), //$NON-NLS-1$//$NON-NLS-2$
            GENERIC_X_OFS + xSizeForEachWidget * 2, GENERIC_Y_OFS).moveTo(ALWAYS_VISIBLE_TAB).getValueLabel();
    cp5.addTextlabel("outputDevice", messages.getString("GeneratorGui.OUTPUT_DEVICE"), //$NON-NLS-1$//$NON-NLS-2$
            GENERIC_X_OFS + xSizeForEachWidget * 3, GENERIC_Y_OFS).moveTo(ALWAYS_VISIBLE_TAB).getValueLabel();
    cp5.addTextlabel("outputDeviceName", col.getOutputDeviceName(), 15 + GENERIC_X_OFS + xSizeForEachWidget * 3, //$NON-NLS-1$
            2 + GENERIC_Y_OFS + 10).moveTo(ALWAYS_VISIBLE_TAB).getValueLabel();

    //register event listener
    cp5.addListener(listener);

    //select first visual
    selectedVisualList.activate(0);
    selectedOutputs.activate(0);

    //register callback function
    GuiUpdateFeedback guf = new GuiUpdateFeedback(this);
    col.addObserver(guf);
    col.notifyGuiUpdate();

    initialized = true;
}

From source file:com.dominion.salud.nomenclator.negocio.service.impl.aemps.v6.MedicamentosV6ServiceImpl.java

@Transactional
private void loadMedicamento(MedicamentosType medicamentosType) throws Exception {
    Medicamentos medicamentos = new Medicamentos();
    medicamentos.setCodNacional(medicamentosType.getCodNacion());

    try {//www  . j a  v  a 2s .c  o  m
        logger.debug("     Cargando MEDICAMENTOS para el COD_NAC: " + medicamentos.getCodNacional());
        medicamentos = medicamentosRepository.findByCodNac(medicamentos);
        logger.debug("     Se ha encontrado MEDICAMENTOS con COD_NAC: " + medicamentos.getCodNacional()
                + ". Actualizando registro: " + medicamentos.toString());
    } catch (NoResultException nre) {
        logger.debug("     No se ha encontrado MEDICAMENTOS con COD_NAC: " + medicamentos.getCodNacional()
                + ". Insertando nuevo registro: " + medicamentos.toString());
    } finally {
        medicamentos.setNroPactiv(0);
        medicamentos.setFecSitReg(medicamentosType.getFechaSituacionRegistro() != null
                ? medicamentosType.getFechaSituacionRegistro().toGregorianCalendar().getTime()
                : null);
        medicamentos.setFecSitRegPresen(medicamentosType.getFecSitregPresen() != null
                ? medicamentosType.getFecSitregPresen().toGregorianCalendar().getTime()
                : null);
        medicamentos.setTxtDesComercial(medicamentosType.getDesNomco());
        medicamentos.setTxtDesDosific(medicamentosType.getDesDosific());
        medicamentos.setTxtDesPresen(medicamentosType.getDesPrese());
        medicamentos.setFecAutorizacion(medicamentosType.getFechaAutorizacion() != null
                ? medicamentosType.getFechaAutorizacion().toGregorianCalendar().getTime()
                : null);
        medicamentos.setFecComer(medicamentosType.getFecComer() != null
                ? medicamentosType.getFecComer().toGregorianCalendar().getTime()
                : null);
        medicamentos.setAfectaConduccion(medicamentosType.isSwAfectaConduccion() ? "S" : "N");
        medicamentos.setBaseAPlantas(medicamentosType.isSwBaseAPlantas() ? "S" : "N");
        medicamentos.setBiosimilar(medicamentosType.isBiosimilar() ? "S" : "N");
        medicamentos.setComercializado(medicamentosType.isSwComercializado() ? "S" : "N");
        medicamentos.setContenido(medicamentosType.getContenido());
        medicamentos.setDiagHospitalario(medicamentosType.isSwDiagnosticoHospitalario() ? "S" : "N");
        medicamentos.setEnvaseClinico(medicamentosType.isSwEnvaseClinico() ? "S" : "N");
        medicamentos.setEspecialCtrlMed(medicamentosType.isSwEspecialControlMedico() ? "S" : "N");
        medicamentos.setEstupefaciente(medicamentosType.isSwEstupefaciente() ? "S" : "N");
        medicamentos.setExcipDeclOblig(medicamentosType.isSwTieneExcipientesDeclObligatoria() ? "S" : "N");
        medicamentos.setGenerico(medicamentosType.isSwGenerico() ? "S" : "N");
        medicamentos.setHuerfano(medicamentosType.isSwHuerfano() ? "S" : "N");
        medicamentos.setListaEstupe(medicamentosType.getListaEstupefaciente());
        medicamentos.setListaPsicotropo(medicamentosType.getListaPsicotropo());
        medicamentos.setNroConte(medicamentosType.getNroConte());
        medicamentos.setNroRegistro(medicamentosType.getNroDefinitivo());
        medicamentos.setPsicotropo(medicamentosType.isSwPsicotropo() ? "S" : "N");
        medicamentos.setSustituible(medicamentosType.isSwSustituible() ? "S" : "N");
        medicamentos.setTld(medicamentosType.isSwTld() ? "S" : "N");
        medicamentos.setTrianguloNegro(medicamentosType.isSwTrianguloNegro() ? "S" : "N");
        medicamentos.setUsoHospitalario(medicamentosType.isSwUsoHospitalario() ? "S" : "N");
        medicamentos.setUrlFictec(medicamentosType.getUrlFictec());
        medicamentos.setUrlProsp(medicamentosType.getUrlProsp());

        //SIT_REG
        try {
            logger.debug("          Cargando SIT_REG para el COD_SIT_REG: " + medicamentosType.getCodSitreg());
            SituacionRegistro situacionRegistro = new SituacionRegistro();
            situacionRegistro.setCodSitReg(Integer.toString(medicamentosType.getCodSitreg()));

            medicamentos.setSitReg(situacionRegistroRepository.findByCodSituacionRegistro(situacionRegistro));
            logger.debug("          SIT_REG para el COD_SIT_REG: " + situacionRegistro.getCodSitReg()
                    + " cargado correctamente");
        } catch (NoResultException nre) {
            logger.warn("          No se ha encontrado SIT_REG con COD_SIT_REG: "
                    + medicamentosType.getCodSitreg());
        }

        //SIT_REG_DOS_PRESEN
        try {
            logger.debug("          Cargando SIT_REG_DOS_PRESEN para el COD_SIT_REG_DOS_PRESEN: "
                    + medicamentosType.getCodSitregPresen());
            SituacionRegistro situacionRegistroDosPresen = new SituacionRegistro();
            situacionRegistroDosPresen.setCodSitReg(Integer.toString(medicamentosType.getCodSitregPresen()));

            medicamentos.setSitRegPresen(
                    situacionRegistroRepository.findByCodSituacionRegistro(situacionRegistroDosPresen));
            logger.debug("          SIT_REG_DOS_PRESEN para el COD_SIT_REG_DOS_PRESEN: "
                    + situacionRegistroDosPresen.getCodSitReg() + " cargado correctamente");
        } catch (NoResultException nre) {
            logger.warn("          No se ha encontrado SIT_REG_DOS_PRESEN con COD_SIT_REG_DOS_PRESEN: "
                    + medicamentosType.getCodSitregPresen());
        }

        //DCP
        if (medicamentosType.getCodDcp() != null) {
            try {
                logger.debug("          Cargando DCP para el COD_DCP: " + medicamentosType.getCodDcp());
                Dcp dcp = new Dcp();
                dcp.setCodDcp(new DecimalFormat("#.#").format(medicamentosType.getCodDcp()));

                medicamentos.setDcp(dcpRepository.findByCodDcp(dcp));
                logger.debug("          DCP para el COD_DCP: " + dcp.getCodDcp() + " cargado correctamente");
            } catch (NoResultException nre) {
                logger.warn("          No se ha encontrado DCP con COD_DCP: " + medicamentosType.getCodDcp());
            }
        }

        //DCPF
        if (medicamentosType.getCodDcpf() != null) {
            try {
                logger.debug("          Cargando DCPF para el COD_DCPF: " + medicamentosType.getCodDcpf());
                Dcpf dcpf = new Dcpf();
                dcpf.setCodDcpf(new DecimalFormat("#.#").format(medicamentosType.getCodDcpf()));

                medicamentos.setDcpf(dcpfRepository.findByCodDcpf(dcpf));
                logger.debug(
                        "          DCPF para el COD_DCPF: " + dcpf.getCodDcpf() + " cargado correctamente");
            } catch (NoResultException nre) {
                logger.warn(
                        "          No se ha encontrado DCPF con COD_DCPF: " + medicamentosType.getCodDcpf());
            }
        }

        //DCSA
        if (medicamentosType.getCodDcsa() != null) {
            try {
                logger.debug("          Cargando DCSA para el COD_DCSA: " + medicamentosType.getCodDcsa());
                Dcsa dcsa = new Dcsa();
                dcsa.setCodDcsa(new DecimalFormat("#.#").format(medicamentosType.getCodDcsa()));

                medicamentos.setDcsa(dcsaRepository.findByCodDcsa(dcsa));
                logger.debug(
                        "          DCSA para el COD_DCSA: " + dcsa.getCodDcsa() + " cargado correctamente");
            } catch (NoResultException nre) {
                logger.warn(
                        "          No se ha encontrado DCSA con COD_DCSA: " + medicamentosType.getCodDcsa());
            }
        }

        //ENVASES
        if (medicamentosType.getCodEnvase() != null) {
            try {
                Envases envases = new Envases();
                envases.setCodEnvase(Integer.toString(medicamentosType.getCodEnvase()));

                logger.debug(
                        "          Cargando ENVASES para el COD_ENVASE: " + medicamentosType.getCodEnvase());
                medicamentos.setEnvases(envasesRepository.findByCodEnvase(envases));
                logger.debug("          ENVASE para el COD_ENVASE: " + envases.getCodEnvase()
                        + " cargado correctamente");
            } catch (NoResultException nre) {
                logger.warn("          No se ha encontrado ENVASES con COD_ENVASE: "
                        + medicamentosType.getCodEnvase());
            }
        }

        //LAB_COMER
        if (medicamentosType.getLaboratorioComercializador() != null) {
            try {
                Laboratorios labComer = new Laboratorios();
                labComer.setCodLaboratorio(Integer.toString(medicamentosType.getLaboratorioComercializador()));

                logger.debug("          Cargando LAB_COMER para el COD_LABORATORIO: "
                        + medicamentosType.getLaboratorioComercializador());
                medicamentos.setLaboratoriosComer(laboratoriosRepository.findByCodLaboratorio(labComer));
                logger.debug("          LAB_COMER para el COD_LABORATORIO: " + labComer.getCodLaboratorio()
                        + " cargado correctamente");
            } catch (NoResultException nre) {
                logger.warn("          No se ha encontrado LAB_COMER con COD_LABORATORIO: "
                        + medicamentosType.getLaboratorioComercializador());
            }
        }

        //LAB_TITULAR
        if (medicamentosType.getLaboratorioTitular() != null) {
            try {
                Laboratorios labTit = new Laboratorios();
                labTit.setCodLaboratorio(Integer.toString(medicamentosType.getLaboratorioTitular()));

                logger.debug("          Cargando LAB_TITULAR para el COD_LABORATORIO: "
                        + medicamentosType.getLaboratorioTitular());
                medicamentos.setLaboratoriosTit(laboratoriosRepository.findByCodLaboratorio(labTit));
                logger.debug("          LAB_TITULAR para el COD_LABORATORIO: "
                        + Integer.toString(medicamentosType.getLaboratorioTitular())
                        + " cargado correctamente");
            } catch (NoResultException nre) {
                logger.warn("          No se ha encontrado LAB_TITULAR con COD_LABORATORIO: "
                        + medicamentosType.getLaboratorioTitular());
            }
        }

        //UNIDAD_CONTENIDO
        if (medicamentosType.getUnidContenido() != null) {
            try {
                UnidadesContenido unidadesContenido = new UnidadesContenido();
                unidadesContenido.setCodUnidContenido(Integer.toString(medicamentosType.getUnidContenido()));

                logger.debug("          Cargando UNIDAD_CONTENIDO para el COD_UNID_CONTENIDO: "
                        + medicamentosType.getUnidContenido());
                medicamentos.setUnidadesContenido(
                        unidadesContenidoRepository.findByCodUnidContenido(unidadesContenido));
                logger.debug("          UNIDAD_CONTENIDO para el COD_UNID_CONTENIDO: "
                        + unidadesContenido.getCodUnidContenido() + " cargado correctamente");
            } catch (NoResultException nre) {
                logger.warn("          No se ha encontrado UNIDAD_CONTENIDO con COD_UNID_CONTENIDO: "
                        + medicamentosType.getUnidContenido());
            }
        }
        medicamentosRepository.save(medicamentos);

        //FORMAS_FARMACEUTICAS
        if (medicamentosType.getFormasfarmaceuticas() != null
                && !medicamentosType.getFormasfarmaceuticas().isEmpty()) {
            Iterator<MedicamentosFormafarmaceuticaType> iteradorMedicamentosFormafarmaceuticaType = medicamentosType
                    .getFormasfarmaceuticas().iterator();
            while (iteradorMedicamentosFormafarmaceuticaType.hasNext()) {
                MedicamentosFormafarmaceuticaType medicamentosFormafarmaceuticaType = iteradorMedicamentosFormafarmaceuticaType
                        .next();

                //NRO_PACTIV
                medicamentos.setNroPactiv(medicamentosFormafarmaceuticaType.getNroPactiv());
                medicamentosRepository.save(medicamentos);

                //FORMAS_FAR
                if (medicamentosFormafarmaceuticaType.getCodForfar() != null) {
                    try {
                        FormasFar formasFar = new FormasFar();
                        formasFar.setCodFormaFar(
                                Integer.toString(medicamentosFormafarmaceuticaType.getCodForfar()));

                        logger.debug("          Cargando FORMAS_FAR para el COD_FORMA_FAR: "
                                + medicamentosFormafarmaceuticaType.getCodForfar());
                        medicamentos.setFormasFar(formasFarRepository.findByCodFormaFar(formasFar));
                        logger.debug("          FORMAS_FAR para el COD_FORMA_FAR: " + formasFar.getCodFormaFar()
                                + " cargado correctamente");
                    } catch (NoResultException nre) {
                        logger.warn("          No se ha encontrado FORMAS_FAR con COD_FORMA_FAR: "
                                + medicamentosFormafarmaceuticaType.getCodForfar());
                    }
                }

                //FORMAS_FAR_SIMP
                if (medicamentosFormafarmaceuticaType.getCodForfarSimplificada() != null) {
                    try {
                        FormasFarSimp formasFarSimp = new FormasFarSimp();
                        formasFarSimp.setCodFormaFarSimp(
                                Integer.toString(medicamentosFormafarmaceuticaType.getCodForfarSimplificada()));

                        logger.debug("          Cargando FORMAS_FAR_SIMP para el COD_FORMA_FAR_SIMP: "
                                + medicamentosFormafarmaceuticaType.getCodForfarSimplificada());
                        medicamentos
                                .setFormasfarSimp(formasFarSimpRepository.findByCodFormaFarSimp(formasFarSimp));
                        logger.debug("          FORMAS_FAR_SIMP para el COD_FORMA_FAR_SIMP: "
                                + formasFarSimp.getCodFormaFarSimp() + " cargado correctamente");
                    } catch (NoResultException nre) {
                        logger.warn("          No se ha encontrado FORMAS_FAR_SIMP con COD_FORMA_FAR_SIMP: "
                                + medicamentosFormafarmaceuticaType.getCodForfarSimplificada());
                    }
                }

                //MED_PRINCIPIOS
                if (medicamentosFormafarmaceuticaType.getComposicionPa() != null
                        && !medicamentosFormafarmaceuticaType.getComposicionPa().isEmpty()) {
                    logger.debug("          Cargando MED_PRINCIPIOS");
                    List<MedPrincipios> listaMedPrincipios = new ArrayList<>();

                    Iterator<MedicamentosPrincipiosActivosType> iteradorMedicamentosPrincipiosActivos = medicamentosFormafarmaceuticaType
                            .getComposicionPa().iterator();
                    while (iteradorMedicamentosPrincipiosActivos.hasNext()) {
                        MedicamentosPrincipiosActivosType medicamentosPrincipiosActivosType = iteradorMedicamentosPrincipiosActivos
                                .next();

                        try {

                            PrincipiosActivos principiosActivos = new PrincipiosActivos();
                            principiosActivos.setNroPrActivo(Integer
                                    .toString(medicamentosPrincipiosActivosType.getCodPrincipioActivo()));
                            logger.debug(
                                    "               Cargando PRINCIPIOS_ACTIVOS para el NRO_PRINCIPIO_ACTIVO: "
                                            + medicamentosPrincipiosActivosType.getCodPrincipioActivo());
                            MedPrincipios medPrincipios = new MedPrincipios();
                            medPrincipios.setPrincipiosActivos(
                                    principiosActivosRepository.findByNroPrActivo(principiosActivos));
                            medPrincipios.setMedicamentos(medicamentos);

                            //UNID_CONT_ADM (U_C)
                            if (medicamentosPrincipiosActivosType.getUnidadAdministracion() != null) {
                                try {
                                    UnidadesContenido uniContAdm = new UnidadesContenido();
                                    uniContAdm.setTxtUnidContenido(
                                            medicamentosPrincipiosActivosType.getUnidadAdministracion());

                                    logger.debug(
                                            "                    Cargando UNID_CONT_ADM para el TXT_UNID_CONT: "
                                                    + medicamentosPrincipiosActivosType
                                                            .getUnidadAdministracion());
                                    medPrincipios.setUniContAdm(
                                            unidadesContenidoRepository.findByTxtUnidContenido(uniContAdm));
                                    logger.debug("                    UNID_CONT_ADM para el TXT_UNID_CONT: "
                                            + uniContAdm.getTxtUnidContenido() + " cargado correctamente");
                                } catch (NoResultException nre) {
                                    logger.warn(
                                            "                    No se ha encontrado UNID_CONT_ADM con TXT_UNID_CONT: "
                                                    + medicamentosPrincipiosActivosType
                                                            .getUnidadAdministracion());
                                }
                            }

                            //UNI_CONT_COMP (U_C)
                            if (medicamentosPrincipiosActivosType.getUnidadComposicion() != null) {
                                try {
                                    UnidadesContenido uniContComp = new UnidadesContenido();
                                    uniContComp.setTxtUnidContenido(
                                            medicamentosPrincipiosActivosType.getUnidadComposicion());

                                    logger.debug(
                                            "                    Cargando UNI_CONT_COMP para el TXT_UNID_CONT: "
                                                    + medicamentosPrincipiosActivosType.getUnidadComposicion());
                                    medPrincipios.setUniContComp(
                                            unidadesContenidoRepository.findByTxtUnidContenido(uniContComp));
                                    logger.debug("                    UNI_CONT_COMP para el TXT_UNID_CONT: "
                                            + uniContComp.getTxtUnidContenido() + " cargado correctamente");
                                } catch (NoResultException nre) {
                                    logger.warn(
                                            "                    No se ha encontrado UNI_CONT_COMP con TXT_UNID_CONT: "
                                                    + medicamentosPrincipiosActivosType.getUnidadComposicion());
                                }
                            }

                            //UNI_DOSIS_PA (U_D)
                            if (medicamentosPrincipiosActivosType.getUnidadDosisPa() != null) {
                                try {
                                    UnidadesDosis uniDosisPa = new UnidadesDosis();
                                    uniDosisPa.setTxtUnidadDosis(
                                            medicamentosPrincipiosActivosType.getUnidadDosisPa());

                                    logger.debug(
                                            "                    Cargando UNI_DOSIS_PA para el TXT_UNID_DOSIS: "
                                                    + medicamentosPrincipiosActivosType.getUnidadDosisPa());
                                    medPrincipios.setUniDosisPa(
                                            unidadesDosisRepository.findByTxtUnidadDosis(uniDosisPa));
                                    logger.debug("                    UNI_DOSIS_PA para el TXT_UNID_DOSIS: "
                                            + uniDosisPa.getTxtUnidadDosis() + " cargado correctamente");
                                } catch (NoResultException nre) {
                                    logger.warn(
                                            "                    No se ha encontrado UNI_DOSIS_PA con TXT_UNID_DOSIS: "
                                                    + medicamentosPrincipiosActivosType.getUnidadDosisPa());
                                }
                            }

                            //UNI_DOSIS_PRES (U_D)
                            if (medicamentosPrincipiosActivosType.getUnidadPrescripcion() != null) {
                                try {
                                    UnidadesDosis uniDosisPre = new UnidadesDosis();
                                    uniDosisPre.setTxtUnidadDosis(
                                            medicamentosPrincipiosActivosType.getUnidadPrescripcion());

                                    logger.debug(
                                            "                    Cargando UNI_DOSIS_PRES para el TXT_UNID_DOSIS: "
                                                    + medicamentosPrincipiosActivosType
                                                            .getUnidadPrescripcion());
                                    medPrincipios.setUniDosisPres(
                                            unidadesDosisRepository.findByTxtUnidadDosis(uniDosisPre));
                                    logger.debug("                    UNI_DOSIS_PRES para el TXT_UNID_DOSIS: "
                                            + uniDosisPre.getTxtUnidadDosis() + " cargado correctamente");
                                } catch (NoResultException nre) {
                                    logger.warn(
                                            "                    No se ha encontrado UNI_DOSIS_PRES con TXT_UNID_DOSIS: "
                                                    + medicamentosPrincipiosActivosType
                                                            .getUnidadPrescripcion());
                                }
                            }

                            //UNI_DOSIS_V_ADM (U_D)
                            if (medicamentosPrincipiosActivosType
                                    .getUnidadVolumenUnidadAdministracion() != null) {
                                try {
                                    UnidadesDosis uniDosisVAdm = new UnidadesDosis();
                                    uniDosisVAdm.setTxtUnidadDosis(medicamentosPrincipiosActivosType
                                            .getUnidadVolumenUnidadAdministracion());

                                    logger.debug(
                                            "                    Cargando UNI_DOSIS_V_ADM para el TXT_UNID_DOSIS: "
                                                    + medicamentosPrincipiosActivosType
                                                            .getUnidadVolumenUnidadAdministracion());
                                    medPrincipios.setUniDosisVAdm(
                                            unidadesDosisRepository.findByTxtUnidadDosis(uniDosisVAdm));
                                    logger.debug("                    UNI_DOSIS_V_ADM para el TXT_UNID_DOSIS: "
                                            + uniDosisVAdm.getTxtUnidadDosis() + " cargado correctamente");
                                } catch (NoResultException nre) {
                                    logger.warn(
                                            "                    No se ha encontrado UNI_DOSIS_V_ADM con TXT_UNID_DOSIS: "
                                                    + medicamentosPrincipiosActivosType
                                                            .getUnidadVolumenUnidadAdministracion());
                                }
                            }

                            //UNI_DOSIS_V_COMP (U_D)
                            if (medicamentosPrincipiosActivosType.getUnidadVolumenUnidadComposicion() != null) {
                                try {
                                    UnidadesDosis uniDosisVComp = new UnidadesDosis();
                                    uniDosisVComp.setTxtUnidadDosis(medicamentosPrincipiosActivosType
                                            .getUnidadVolumenUnidadComposicion());

                                    logger.debug(
                                            "                    Cargando UNI_DOSIS_V_COMP para el TXT_UNID_DOSIS: "
                                                    + medicamentosPrincipiosActivosType
                                                            .getUnidadVolumenUnidadComposicion());
                                    medPrincipios.setUniDosisVCom(
                                            unidadesDosisRepository.findByTxtUnidadDosis(uniDosisVComp));
                                    logger.debug("                    UNI_DOSIS_V_COMP para el TXT_UNID_DOSIS: "
                                            + uniDosisVComp.getTxtUnidadDosis() + " cargado correctamente");
                                } catch (NoResultException nre) {
                                    logger.warn(
                                            "                    No se ha encontrado UNI_DOSIS_V_COMP con TXT_UNID_DOSIS: "
                                                    + medicamentosPrincipiosActivosType
                                                            .getUnidadVolumenUnidadComposicion());
                                }
                            }

                            //DosisAdministracion
                            if (NumberUtils.isNumber(StringUtils.replace(
                                    medicamentosPrincipiosActivosType.getDosisAdministracion(), ",", "."))) {
                                medPrincipios.setDosisAdm(NumberUtils.createDouble(StringUtils.replace(
                                        medicamentosPrincipiosActivosType.getDosisAdministracion(), ",", ".")));
                            }

                            //DosisComposicion
                            if (NumberUtils.isNumber(StringUtils.replace(
                                    medicamentosPrincipiosActivosType.getDosisComposicion(), ",", "."))) {
                                medPrincipios.setDosisComp(NumberUtils.createDouble(StringUtils.replace(
                                        medicamentosPrincipiosActivosType.getDosisComposicion(), ",", ".")));
                            }

                            //DosisPa
                            if (NumberUtils.isNumber(StringUtils
                                    .replace(medicamentosPrincipiosActivosType.getDosisPa(), ",", "."))) {
                                medPrincipios.setDosisPa(NumberUtils.createDouble(StringUtils
                                        .replace(medicamentosPrincipiosActivosType.getDosisPa(), ",", ".")));
                            }

                            //CantidadVolumenUnidadAdministracion
                            if (NumberUtils.isNumber(StringUtils.replace(
                                    medicamentosPrincipiosActivosType.getCantidadVolumenUnidadAdministracion(),
                                    ",", "."))) {
                                medPrincipios
                                        .setDosisVAdm(
                                                NumberUtils.createDouble(StringUtils.replace(
                                                        medicamentosPrincipiosActivosType
                                                                .getCantidadVolumenUnidadAdministracion(),
                                                        ",", ".")));
                            }

                            //CantidadVolumenUnidadComposicion
                            if (NumberUtils.isNumber(StringUtils.replace(
                                    medicamentosPrincipiosActivosType.getCantidadVolumenUnidadComposicion(),
                                    ",", "."))) {
                                medPrincipios.setDosisVCom(NumberUtils.createDouble(StringUtils.replace(
                                        medicamentosPrincipiosActivosType.getCantidadVolumenUnidadComposicion(),
                                        ",", ".")));
                            }

                            medPrincipios
                                    .setDosisPres(medicamentosPrincipiosActivosType.getDosisPrescripcion());
                            medPrincipios
                                    .setOrdenColacion(medicamentosPrincipiosActivosType.getOrdenColacion());

                            listaMedPrincipios.add(medPrincipios);
                            logger.debug("               PRINCIPIOS_ACTIVOS para el NRO_PRINCIPIO_ACTIVO: "
                                    + principiosActivos.getNroPrActivo() + " cargado correctamente");
                        } catch (NoResultException nre) {
                            logger.warn(
                                    "               No se ha encontrado PRINCIPIOS_ACTIVOS con NRO_PRINCIPIO_ACTIVO: "
                                            + medicamentosPrincipiosActivosType.getCodPrincipioActivo());
                        }
                    }
                    medPrincipiosService.save(medicamentos, listaMedPrincipios);
                    logger.debug("          MED_PRINCIPIOS cargados correctamente");
                }

                //MED_EXCIPIENTES
                if (medicamentosFormafarmaceuticaType.getExcipientes() != null
                        && !medicamentosFormafarmaceuticaType.getExcipientes().isEmpty()) {
                    logger.debug("          Cargando MED_EXCIPIENTES");
                    List<MedExcipientes> listaMedExcipientes = new ArrayList<>();

                    Iterator<MedicamentosExcipientesType> iteradorMedicamentosExcipientes = medicamentosFormafarmaceuticaType
                            .getExcipientes().iterator();
                    while (iteradorMedicamentosExcipientes.hasNext()) {
                        MedicamentosExcipientesType medicamentosExcipientesType = iteradorMedicamentosExcipientes
                                .next();

                        try {
                            Excipientes excipientes = new Excipientes();
                            excipientes.setCodExcipiente(
                                    Integer.toString(medicamentosExcipientesType.getCodExcipiente()));

                            logger.debug("               Cargando EXCIPIENTES para el COD_EXCIPIENTE: "
                                    + medicamentosExcipientesType.getCodExcipiente());
                            MedExcipientes medExcipientes = new MedExcipientes();
                            medExcipientes
                                    .setExcipientes(excipientesRepository.findByCodExcipiente(excipientes));
                            medExcipientes.setMedicamentos(medicamentos);
                            listaMedExcipientes.add(medExcipientes);
                            logger.debug("               EXCIPIENTES para el COD_EXCIPIENTE: "
                                    + excipientes.getCodExcipiente() + " cargado correctamente");
                        } catch (NoResultException nre) {
                            logger.warn("               No se ha encontrado EXCIPIENTES con COD_EXCIPIENTE: "
                                    + medicamentosExcipientesType.getCodExcipiente());
                        }
                    }
                    medExcipientesService.save(medicamentos, listaMedExcipientes);
                    logger.debug("          MED_EXCIPIENTES cargados correctamente");
                }

                //MED_VIAS
                if (medicamentosFormafarmaceuticaType.getViasadministracion() != null
                        && !medicamentosFormafarmaceuticaType.getViasadministracion().isEmpty()) {
                    logger.debug("          Cargando MED_VIAS");
                    List<MedVias> listaMedVias = new ArrayList<>();

                    Iterator<MedicamentosViasAdminType> iteradorMedicamentosViasAdmin = medicamentosFormafarmaceuticaType
                            .getViasadministracion().iterator();
                    while (iteradorMedicamentosViasAdmin.hasNext()) {
                        MedicamentosViasAdminType medicamentosViasAdminType = iteradorMedicamentosViasAdmin
                                .next();

                        try {
                            ViasAdmin viasAdmin = new ViasAdmin();
                            viasAdmin.setCodViaAdmin(
                                    Integer.toString(medicamentosViasAdminType.getCodViaAdmin()));

                            logger.debug("               Cargando VIAS_ADMIN para el COD_VIA_ADMIN: "
                                    + medicamentosViasAdminType.getCodViaAdmin());
                            MedVias medVias = new MedVias();
                            medVias.setViasAdmin(viasAdminRepository.findByCodViasAdmin(viasAdmin));
                            medVias.setMedicamentos(medicamentos);
                            listaMedVias.add(medVias);
                            logger.debug("               VIAS_ADMIN para el COD_VIA_ADMIN: "
                                    + viasAdmin.getCodViaAdmin() + " cargado correctamente");
                        } catch (NoResultException nre) {
                            logger.warn("               No se ha encontrado VIAS_ADMIN con COD_VIA_ADMIN: "
                                    + medicamentosViasAdminType.getCodViaAdmin());
                        }
                    }
                    medViasAdminService.save(medicamentos, listaMedVias);
                    logger.debug("          MED_VIAS cargados correctamente");
                }
            }
        }

        //MED_NOTAS
        if (medicamentosType.getNotaseguridad() != null && !medicamentosType.getNotaseguridad().isEmpty()) {
            logger.debug("          Cargando MED_NOTAS");
            List<MedNotas> listaMedNotas = new ArrayList<>();

            Iterator<MedicamentosNotasType> iteradorMedicamentosNotas = medicamentosType.getNotaseguridad()
                    .iterator();
            while (iteradorMedicamentosNotas.hasNext()) {
                MedicamentosNotasType medicamentosNotasType = iteradorMedicamentosNotas.next();

                MedNotas medNotas = new MedNotas();
                medNotas.setMedicamentos(medicamentos);

                Notas notas = new Notas();
                try {
                    notas.setReferencia(medicamentosNotasType.getReferenciaNotaSeguridad());
                    notas.setAsunto(medicamentosNotasType.getAsuntoNotaSeguridad());
                    notas.setNumero(medicamentosNotasType.getNumeroNotaSeguridad());
                    notas.setUrl(medicamentosNotasType.getUrlNotaSeguridad());
                    try {
                        notas.setFecha(DateUtils.parseDate(medicamentosNotasType.getFechaNotaSeguridad(),
                                "dd/MM/YYYY"));
                    } catch (ParseException pe) {
                        logger.warn("               La fecha: " + medicamentosNotasType.getFechaNotaSeguridad()
                                + " no ha podido ser parseada con el pattern dd/MM/YYYY");
                    }

                    logger.debug("               Cargando NOTAS para el REFERENCIA: "
                            + medicamentosNotasType.getReferenciaNotaSeguridad());
                    notas = notasRepository.findByReferencia(notas);
                    logger.debug("               NOTAS para el REFERENCIA: " + notas.getReferencia()
                            + " cargado correctamente");
                } catch (NoResultException nre) {
                    logger.warn("               No se ha encontrado NOTAS con REFERENCIA: "
                            + medicamentosNotasType.getReferenciaNotaSeguridad() + ". Insertando registro");
                    notasRepository.save(notas);
                } finally {
                    medNotas.setNotas(notas);
                    listaMedNotas.add(medNotas);
                }
            }
            medNotasService.save(medicamentos, listaMedNotas);
            logger.debug("          MED_NOTAS cargados correctamente");
        }

        //MED_ATC
        if (medicamentosType.getAtc() != null && !medicamentosType.getAtc().isEmpty()) {
            logger.debug("          Cargando MED_ATC");

            Iterator<MedicamentosAtcType> iteradorMedicamentosAtc = medicamentosType.getAtc().iterator();
            while (iteradorMedicamentosAtc.hasNext()) {
                MedicamentosAtcType medicamentosAtcType = iteradorMedicamentosAtc.next();
                List<MedAtc> listaMedAtc = new ArrayList<>();

                MedAtc medAtc = new MedAtc();
                medAtc.setMedicamentos(medicamentos);

                try {
                    Atc atc = new Atc();
                    atc.setCodAtc(medicamentosAtcType.getCodAtc());

                    logger.debug(
                            "               Cargando ATC para el COD_ATC: " + medicamentosAtcType.getCodAtc());
                    medAtc.setAtc(atcRepository.findByCodAtc(atc));
                    logger.debug("               ATC para el COD_ATC: " + atc.getCodAtc()
                            + " cargado correctamente");

                    listaMedAtc.add(medAtc);
                    medAtcService.save(medicamentos, listaMedAtc);

                    //ATC_INTERACCIONES
                    if (medicamentosAtcType.getInteraccionesAtc() != null
                            && !medicamentosAtcType.getInteraccionesAtc().isEmpty()) {
                        logger.debug("                    Cargando ATC_INTERACCIONES");
                        List<AtcInteracciones> listaAtcInteracciones = new ArrayList<>();
                        Iterator<AtcInteraccionesType> iteradorAtcInteracciones = medicamentosAtcType
                                .getInteraccionesAtc().iterator();
                        while (iteradorAtcInteracciones.hasNext()) {
                            AtcInteraccionesType atcInteraccionesType = iteradorAtcInteracciones.next();

                            AtcInteracciones atcInteracciones = new AtcInteracciones();
                            atcInteracciones
                                    .setDescripcion(atcInteraccionesType.getDescripcionAtcInteraccion());
                            atcInteracciones.setEfecto(atcInteraccionesType.getEfectoInteraccion());
                            atcInteracciones.setOrientacion(atcInteraccionesType.getRecomendacionInteraccion());
                            atcInteracciones.setAtc(medAtc.getAtc());

                            try {
                                Atc atcInteraccion = new Atc();
                                atcInteraccion.setCodAtc(atcInteraccionesType.getAtcInteraccion());

                                logger.debug(
                                        "                         Cargando ATC_INTERACCION para el COD_ATC: "
                                                + atcInteraccionesType.getAtcInteraccion());
                                atcInteracciones.setInteraccion(atcRepository.findByCodAtc(atcInteraccion));
                                listaAtcInteracciones.add(atcInteracciones);
                                logger.debug("                         ATC_INTERACCION para el COD_ATC: "
                                        + atcInteraccion.getCodAtc() + " cargado correctamente");
                            } catch (NoResultException nre) {
                                logger.warn(
                                        "                         No se ha encontrado ATC_INTERACCION con COD_ATC: "
                                                + atcInteraccionesType.getAtcInteraccion()
                                                + ". Insertando registro");
                            }
                        }
                        atcInteraccionesService.save(medAtc.getAtc(), listaAtcInteracciones);
                        logger.debug("                    ATC_INTERACCIONES cargados correctamente");
                    }

                    //ATC_DUPLICIDADES
                    if (medicamentosAtcType.getDuplicidades() != null
                            && !medicamentosAtcType.getDuplicidades().isEmpty()) {
                        logger.debug("                    Cargando ATC_DUPLICIDADES");
                        List<AtcDuplicidades> listaAtcDuplicidades = new ArrayList<>();
                        Iterator<AtcDuplicidadesType> iteradorAtcDuplicidades = medicamentosAtcType
                                .getDuplicidades().iterator();
                        while (iteradorAtcDuplicidades.hasNext()) {
                            AtcDuplicidadesType atcDuplicidadesType = iteradorAtcDuplicidades.next();

                            AtcDuplicidades atcDuplicidades = new AtcDuplicidades();
                            atcDuplicidades
                                    .setDescripcionAtc(atcDuplicidadesType.getDescripcionAtcDuplicidad());
                            atcDuplicidades.setEfecto(atcDuplicidadesType.getEfectoDuplicidad());
                            atcDuplicidades.setOrientacion(atcDuplicidadesType.getRecomendacionDuplicidad());
                            atcDuplicidades.setAtc(medAtc.getAtc());

                            try {
                                Atc atcDuplicidad = new Atc();
                                atcDuplicidad.setCodAtc(atcDuplicidadesType.getAtcDuplicidad());

                                logger.debug(
                                        "                         Cargando ATC_DUPLICIDAD para el COD_ATC: "
                                                + atcDuplicidadesType.getAtcDuplicidad());
                                atcDuplicidades.setDuplicidad(atcRepository.findByCodAtc(atcDuplicidad));
                                listaAtcDuplicidades.add(atcDuplicidades);
                                logger.debug("                         ATC_DUPLICIDAD para el COD_ATC: "
                                        + atcDuplicidad.getCodAtc() + " cargado correctamente");
                            } catch (NoResultException nre) {
                                logger.warn(
                                        "                         No se ha encontrado ATC_DUPLICIDAD con COD_ATC: "
                                                + atcDuplicidadesType.getAtcDuplicidad()
                                                + ". Insertando registro");
                            }
                        }
                        atcDuplicidadesService.save(medAtc.getAtc(), listaAtcDuplicidades);
                        logger.debug("                    ATC_DUPLICIDADES cargados correctamente");
                    }

                    //ATC_TERATOGENIAS
                    if (StringUtils.isNotBlank(medicamentosAtcType.getTeratogenia())) {
                        logger.debug("                    Cargando ATC_TERATOGENIAS");
                        AtcTeratogenias atcTeratogenias = new AtcTeratogenias();
                        atcTeratogenias.setAtc(medAtc.getAtc());

                        try {
                            logger.debug("                         Cargando ATC_TERATOGENIA para el COD_ATC: "
                                    + medAtc.getAtc().getCodAtc());
                            atcTeratogenias = atcTeratogeniasRepository.findByCodAtc(atcTeratogenias);
                            logger.debug("                         ATC_TERATOGENIA para el COD_ATC: "
                                    + atcTeratogenias.getAtc().getCodAtc() + " cargado correctamente");
                        } catch (NoResultException nre) {
                            logger.warn(
                                    "                         No se ha encontrado ATC_TERATOGENIA con COD_ATC: "
                                            + medAtc.getAtc().getCodAtc() + ". Insertando registro");
                        } finally {
                            atcTeratogenias.setTxtTeratogenia(medicamentosAtcType.getTeratogenia());
                            atcTeratogeniasRepository.save(atcTeratogenias);
                        }
                        logger.debug("                    ATC_TERATOGENIAS cargados correctamente");

                    }

                    //ATC_DESACON
                    if (medicamentosAtcType.getDesaconsejadosGeriatria() != null
                            && !medicamentosAtcType.getDesaconsejadosGeriatria().isEmpty()) {
                        logger.debug("                    Cargando ATC_DESACON");
                        List<AtcDesacon> listaAtcDesacon = new ArrayList<>();
                        Iterator<AtcDesaconsejadosType> iteradorAtcDesaconsejados = medicamentosAtcType
                                .getDesaconsejadosGeriatria().iterator();
                        while (iteradorAtcDesaconsejados.hasNext()) {
                            AtcDesaconsejadosType atcDesaconsejadosType = iteradorAtcDesaconsejados.next();

                            AtcDesacon atcDesacon = new AtcDesacon();
                            atcDesacon.setAtc(medAtc.getAtc());

                            try {
                                logger.debug("                         Cargando ATC_DESACON para el COD_ATC: "
                                        + medAtc.getAtc().getCodAtc());
                                atcDesacon = atcDesaconRepository.findByCodAtc(atcDesacon);
                                logger.debug("                         ATC_DESACON para el COD_ATC: "
                                        + atcDesacon.getAtc().getCodAtc() + " cargado correctamente");
                            } catch (NoResultException nre) {
                                logger.warn(
                                        "                         No se ha encontrado ATC_DESACON con COD_ATC: "
                                                + medAtc.getAtc().getCodAtc() + ". Insertando registro");
                            } finally {
                                atcDesacon
                                        .setOrientacionTerap(atcDesaconsejadosType.getRecomendacionGeriatria());
                                atcDesacon
                                        .setRiesgoPaciente(atcDesaconsejadosType.getRiesgoPacienceGeriatria());
                                atcDesacon.setSituacionAlerta(atcDesaconsejadosType.getAlertaGeriatria());
                                atcDesaconRepository.save(atcDesacon);
                            }
                        }
                        logger.debug("                    ATC_DESACON cargados correctamente");
                    }

                } catch (NoResultException nre) {
                    logger.warn("               No se ha encontrado ATC con COD_ATC: "
                            + medicamentosAtcType.getCodAtc());
                }
            }
            logger.debug("          MED_ATC cargados correctamente");
        }
    }
}

From source file:com.sonicle.webtop.core.app.WebTopApp.java

/**
 * Returns the localized string for desired service and bound to the specified key.
 * @param serviceId The service ID./*from   w w w  .j av  a2s .c o m*/
 * @param locale Desired locale.
 * @param key Resource key.
 * @param escapeHtml True to apply HTML escaping, false otherwise.
 * @return Localized string
 */
public String lookupResource(String serviceId, Locale locale, String key, boolean escapeHtml) {
    try {
        String baseName = StringUtils.replace(serviceId, ".", "/") + "/locale";
        String value = ResourceBundle.getBundle(baseName, locale).getString(key);
        if (escapeHtml)
            value = StringEscapeUtils.escapeHtml4(value);
        return value;

    } catch (MissingResourceException ex) {
        return key;
        //logger.trace("Missing resource [{}, {}, {}]", baseName, locale.toString(), key, ex);
    }
}