List of usage examples for org.apache.commons.lang3.math NumberUtils isNumber
public static boolean isNumber(final String str)
Checks whether the String a valid Java number.
Valid numbers include hexadecimal marked with the 0x
or 0X
qualifier, octal numbers, scientific notation and numbers marked with a type qualifier (e.g.
From source file:edu.odu.cs.cs350.yellow1.mutationgeneration.JavaFile.java
private void constantOperations(String required) { ANTLRInputStream input = new ANTLRInputStream(fileContents.toString()); JavaLexer lexer = new JavaLexer(input); CommonTokenStream tokens = new CommonTokenStream(lexer); JavaParser parser = new JavaParser(tokens); ParseTree tree = parser.compilationUnit(); TokenRewriteStream trs = new TokenRewriteStream(); ParseTreeWalker walker = new ParseTreeWalker(); // create standard for (Integer i = 0; i < tokens.size(); i++) { if (NumberUtils.isNumber(tokens.get(i).getText().toString())) { int startIndex = tokens.get(i).getStartIndex(); int stopIndex = tokens.get(i).getStopIndex() + 1; String by = fileContents.substring(startIndex, stopIndex) + required; mvc.add(startIndex, stopIndex, by); }/* ww w .ja va2s . com*/ } }
From source file:hudson.model.AbstractProject.java
/** * Sets scmCheckoutRetryCount, Uses {@link NumberUtils#isNumber(String)} for checking retryCount param. * If it is not valid number, null will be set. * * @param scmCheckoutRetryCount retry count. * @throws IOException if any./* www. j ava2 s . c o m*/ */ protected void setScmCheckoutRetryCount(String scmCheckoutRetryCount) throws IOException { Integer retryCount = null; if (NumberUtils.isNumber(scmCheckoutRetryCount)) { retryCount = NumberUtils.createInteger(scmCheckoutRetryCount); } setScmCheckoutRetryCount(retryCount); }
From source file:hudson.model.AbstractProject.java
/** * Sets quietPeriod, Uses {@link NumberUtils#isNumber(String)} for checking seconds param. If seconds is not valid * number, null will be set./*from w ww .j a v a2 s . co m*/ * * @param seconds quiet period. * @throws IOException if any. */ protected void setQuietPeriod(String seconds) throws IOException { Integer period = null; if (NumberUtils.isNumber(seconds)) { period = NumberUtils.createInteger(seconds); } setQuietPeriod(period); }
From source file:com.kegare.caveworld.core.Config.java
public static void syncVeinsCfg() { if (veinsCfg == null) { veinsCfg = loadConfig("veins"); } else {/*from w w w .j ava 2s . c om*/ CaveworldAPI.clearCaveVeins(); } if (veinsCfg.getCategoryNames().isEmpty()) { CaveworldAPI.addCaveVein(new CaveVein(new BlockEntry(CaveBlocks.cavenium_ore, 0), 4, 7, 100, 128, 255)); CaveworldAPI.addCaveVein(new CaveVein(new BlockEntry(CaveBlocks.cavenium_ore, 0), 20, 1, 8, 128, 255)); CaveworldAPI.addCaveVein(new CaveVein(new BlockEntry(CaveBlocks.cavenium_ore, 1), 1, 3, 100, 150, 255)); CaveworldAPI.addCaveVein(new CaveVein(new BlockEntry(Blocks.coal_ore, 0), 17, 20, 100, 0, 255)); CaveworldAPI.addCaveVein(new CaveVein(new BlockEntry(Blocks.coal_ore, 0), 85, 1, 10, 0, 255)); CaveworldAPI.addCaveVein(new CaveVein(new BlockEntry(Blocks.iron_ore, 0), 10, 28, 100, 0, 255)); CaveworldAPI.addCaveVein(new CaveVein(new BlockEntry(Blocks.iron_ore, 0), 50, 1, 10, 0, 255)); CaveworldAPI.addCaveVein(new CaveVein(new BlockEntry(Blocks.gold_ore, 0), 8, 3, 100, 0, 127)); CaveworldAPI.addCaveVein(new CaveVein(new BlockEntry(Blocks.gold_ore, 0), 24, 1, 8, 0, 127)); CaveworldAPI.addCaveVein(new CaveVein(new BlockEntry(Blocks.redstone_ore, 0), 7, 8, 100, 0, 40)); CaveworldAPI.addCaveVein(new CaveVein(new BlockEntry(Blocks.redstone_ore, 0), 30, 1, 8, 0, 40)); CaveworldAPI.addCaveVein(new CaveVein(new BlockEntry(Blocks.lapis_ore, 0), 5, 2, 100, 0, 50)); CaveworldAPI.addCaveVein(new CaveVein(new BlockEntry(Blocks.lapis_ore, 0), 18, 1, 8, 0, 50)); CaveworldAPI.addCaveVein(new CaveVein(new BlockEntry(Blocks.diamond_ore, 0), 8, 1, 100, 0, 20)); CaveworldAPI.addCaveVein(new CaveVein(new BlockEntry(Blocks.diamond_ore, 0), 15, 1, 5, 0, 20)); CaveworldAPI.addCaveVein(new CaveVein(new BlockEntry(Blocks.emerald_ore, 0), 5, 3, 100, 50, 255, null, Type.MOUNTAIN, Type.HILLS)); CaveworldAPI.addCaveVein(new CaveVein(new BlockEntry(Blocks.emerald_ore, 0), 16, 1, 6, 50, 255, null, Type.MOUNTAIN, Type.HILLS)); CaveworldAPI.addCaveVein(new CaveVein(new BlockEntry(Blocks.quartz_ore, 0), 10, 16, 100, 0, 255, new BlockEntry(Blocks.netherrack, 0), Type.NETHER)); CaveworldAPI.addCaveVein(new CaveVein(new BlockEntry(Blocks.dirt, 0), 25, 20, 100, 0, 255)); CaveworldAPI.addCaveVein(new CaveVein(new BlockEntry(Blocks.gravel, 0), 20, 6, 100, 0, 255)); CaveworldAPI.addCaveVein( new CaveVein(new BlockEntry(Blocks.sand, 0), 20, 8, 100, 0, 255, null, Type.SANDY)); CaveworldAPI.addCaveVein(new CaveVein(new BlockEntry(Blocks.sand, 0), 20, 8, 100, 0, 20, new BlockEntry(Blocks.gravel, 0), Type.SANDY)); CaveworldAPI.addCaveVein(new CaveVein(new BlockEntry(Blocks.soul_sand, 0), 20, 10, 100, 0, 255, new BlockEntry(Blocks.netherrack, 0), Type.NETHER)); CaveworldAPI.addCaveVein(new CaveVein(new BlockEntry(Blocks.hardened_clay, 1), 24, 20, 100, 0, 255, new BlockEntry(Blocks.dirt, 0), Type.MESA)); CaveworldAPI.addCaveVein(new CaveVein(new BlockEntry(Blocks.hardened_clay, 12), 24, 14, 100, 0, 255, new BlockEntry(Blocks.dirt, 0), Type.MESA)); } else { int i = 0; for (String name : veinsCfg.getCategoryNames()) { if (NumberUtils.isNumber(name)) { CaveworldAPI.addCaveVein(null); } else ++i; } if (i > 0) { try { FileUtils.forceDelete(new File(veinsCfg.toString())); CaveworldAPI.clearCaveVeins(); veinsCfg = null; syncVeinsCfg(); } catch (Exception e) { e.printStackTrace(); } } } if (veinsCfg.hasChanged()) { veinsCfg.save(); } }
From source file:com.netsteadfast.greenstep.bsc.service.logic.impl.ImportDataLogicServiceImpl.java
@ServiceMethodAuthority(type = { ServiceMethodType.INSERT, ServiceMethodType.UPDATE }) @Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = { RuntimeException.class, IOException.class, Exception.class }) @Override//from www . j a v a 2s . co m public DefaultResult<Boolean> importMeasureData(String uploadOid) throws ServiceException, Exception { List<Map<String, String>> csvResults = UploadSupportUtils.getTransformSegmentData(uploadOid, "TRAN005"); if (csvResults.size() < 1) { throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.DATA_NO_EXIST)); } boolean success = false; DefaultResult<Boolean> result = new DefaultResult<Boolean>(); StringBuilder msg = new StringBuilder(); Map<String, Object> paramMap = new HashMap<String, Object>(); for (int i = 0; i < csvResults.size(); i++) { int row = i + 1; Map<String, String> data = csvResults.get(i); String kpiId = data.get("KPI_ID"); String date = data.get("DATE"); String target = data.get("TARGET"); String actual = data.get("ACTUAL"); String frequency = data.get("FREQUENCY"); String orgId = data.get("ORG_ID"); String empId = data.get("EMP_ID"); if (super.isBlank(kpiId)) { msg.append("row: " + row + " kpi id is blank." + Constants.HTML_BR); continue; } if (super.isBlank(date)) { msg.append("row: " + row + " date is blank." + Constants.HTML_BR); continue; } if (super.isBlank(target)) { msg.append("row: " + row + " target is blank." + Constants.HTML_BR); continue; } if (super.isBlank(actual)) { msg.append("row: " + row + " actual is blank." + Constants.HTML_BR); continue; } if (super.isBlank(frequency)) { msg.append("row: " + row + " frequency is blank." + Constants.HTML_BR); continue; } if (super.isBlank(orgId)) { msg.append("row: " + row + " organization-id is blank." + Constants.HTML_BR); continue; } if (super.isBlank(empId)) { msg.append("row: " + row + " employee-no is blank." + Constants.HTML_BR); continue; } if (!SimpleUtils.isDate(date)) { msg.append("row: " + row + " is not date " + date + Constants.HTML_BR); continue; } if (!NumberUtils.isNumber(target)) { msg.append("row: " + row + " target is not number." + Constants.HTML_BR); continue; } if (!NumberUtils.isNumber(actual)) { msg.append("row: " + row + " actual is not number." + Constants.HTML_BR); continue; } if (BscMeasureDataFrequency.getFrequencyMap(false).get(frequency) == null) { msg.append("row: " + row + " frequency is not found." + Constants.HTML_BR); continue; } paramMap.clear(); paramMap.put("id", kpiId); if (this.kpiService.countByParams(paramMap) < 1) { msg.append("row: " + row + " KPI is not found " + kpiId + Constants.HTML_BR); continue; } if (!BscConstants.MEASURE_DATA_ORGANIZATION_FULL.equals(orgId)) { paramMap.clear(); paramMap.put("orgId", orgId); if (this.organizationService.countByParams(paramMap) < 1) { msg.append("row: " + row + " organization-id is not found " + orgId + Constants.HTML_BR); continue; } } if (!BscConstants.MEASURE_DATA_EMPLOYEE_FULL.equals(empId)) { paramMap.clear(); paramMap.put("empId", empId); if (this.employeeService.countByParams(paramMap) < 1) { msg.append("row: " + row + " employee-no is not found " + empId + Constants.HTML_BR); continue; } } MeasureDataVO measureData = new MeasureDataVO(); measureData.setKpiId(kpiId); measureData.setDate(date); measureData.setTarget(Float.valueOf(target)); measureData.setActual(Float.valueOf(actual)); measureData.setFrequency(frequency); measureData.setOrgId(orgId); measureData.setEmpId(empId); DefaultResult<MeasureDataVO> oldResult = this.measureDataService.findByUK(measureData); if (oldResult.getValue() != null) { // update measureData.setOid(oldResult.getValue().getOid()); this.measureDataService.updateObject(measureData); } else { // insert this.measureDataService.saveObject(measureData); } success = true; } if (msg.length() > 0) { result.setSystemMessage(new SystemMessage(msg.toString())); } else { result.setSystemMessage(new SystemMessage(SysMessageUtil.get(GreenStepSysMsgConstants.UPDATE_SUCCESS))); } result.setValue(success); return result; }
From source file:com.nridge.ds.solr.SolrConfigJSON.java
private void appendFieldValueJSON(StringBuilder aStringBuilder, DataField aField) { if (aField.isValueNotEmpty()) { String fieldName = aField.getName(); aStringBuilder.append(String.format(" \"%s\":", fieldName)); if (aField.isMultiValue()) { int appendCount = 0; aStringBuilder.append(String.format(" [%n")); for (String fieldValue : aField.getValues()) { if (appendCount > 0) aStringBuilder.append(String.format(",%n")); if ((Field.isNumber(aField.getType())) || ((StringUtils.contains(fieldName, ".facet.") && (NumberUtils.isNumber(fieldValue))))) aStringBuilder.append(String.format("%s", fieldValue)); else if (Field.isBoolean(aField.getType())) aStringBuilder.append(String.format("%s", StrUtl.stringToBoolean(fieldValue))); else aStringBuilder.append(String.format("\"%s\"", fieldValue)); appendCount++;/* w ww .ja v a 2 s . c o m*/ } aStringBuilder.append(" ]"); } else { if ((Field.isNumber(aField.getType())) || (NumberUtils.isNumber(aField.getValue()))) aStringBuilder.append(String.format("%s", aField.getValue())); else if (Field.isBoolean(aField.getType())) aStringBuilder.append(String.format("%s", aField.isValueTrue())); else aStringBuilder.append(String.format("\"%s\"", aField.getValue())); } } }
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 {// w w w . j a va 2 s.c om 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:gov.nih.nci.caintegrator.application.study.StudyManagementServiceImpl.java
private void retrieveValueDomain(CommonDataElement dataElement) throws ConnectionException { ValueDomain valueDomain;// w w w . jav a 2 s. c o m String dataElementVersion = dataElement.getVersion(); valueDomain = caDSRFacade.retrieveValueDomainForDataElement(dataElement.getPublicID(), NumberUtils.isNumber(dataElementVersion) ? Float.valueOf(dataElementVersion) : null); dataElement.setValueDomain(valueDomain); }
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 {/* w w w . j av a 2 s. 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.moviejukebox.plugin.ImdbPlugin.java
/** * Process a awards in the IMDb web page * * @param movie//from ww w .ja v a 2s .com * @return */ private boolean updateAwards(Movie movie) { String imdbId = movie.getId(IMDB_PLUGIN_ID); String awardXML = getImdbData(getImdbUrl(imdbId, IMDB_TITLE, SUFFIX_AWARDS)); if (awardXML.contains("<h1 class=\"header\">Awards</h1>")) { List<String> awardHtmlList = HTMLTools.extractTags(awardXML, "<h1 class=\"header\">Awards</h1>", "<div class=\"article\"", "<h3>", "</table>", false); Collection<AwardEvent> awardList = new ArrayList<>(); for (String awardBlock : awardHtmlList) { String awardEvent = awardBlock.substring(0, awardBlock.indexOf('<')).trim(); AwardEvent aEvent = new AwardEvent(); aEvent.setName(awardEvent); String tmpString = HTMLTools.extractTag(awardBlock, "<a href=", HTML_A_END).trim(); tmpString = tmpString.substring(tmpString.indexOf('>') + 1).trim(); int awardYear = NumberUtils.isNumber(tmpString) ? Integer.parseInt(tmpString) : -1; tmpString = StringUtils.trimToEmpty( HTMLTools.extractTag(awardBlock, "<span class=\"award_category\">", "</span>")); Award aAward = new Award(); aAward.setName(tmpString); aAward.setYear(awardYear); boolean awardOutcomeWon = true; for (String outcomeBlock : HTMLTools.extractHtmlTags(awardBlock, "<table class=", null, "<tr>", "</tr>")) { String outcome = HTMLTools.extractTag(outcomeBlock, "<b>", "</b>"); if (StringTools.isValidString(outcome)) { awardOutcomeWon = "won".equalsIgnoreCase(outcome); } String awardDescription = StringUtils.trimToEmpty( HTMLTools.extractTag(outcomeBlock, "<td class=\"award_description\">", "<br />")); // Check to see if there was a missing title and just the name in the result if (awardDescription.contains("href=\"/name/")) { awardDescription = StringUtils.trimToEmpty( HTMLTools.extractTag(outcomeBlock, "<span class=\"award_category\">", "</span>")); } if (awardOutcomeWon) { aAward.addWon(awardDescription); } else { aAward.addNomination(awardDescription); } } if (!scrapeWonAwards || (aAward.getWon() > 0)) { LOG.debug("{} - Adding award: {}", movie.getBaseName(), aAward.toString()); aEvent.addAward(aAward); } if (!aEvent.getAwards().isEmpty()) { awardList.add(aEvent); } } if (!awardList.isEmpty()) { movie.setAwards(awardList); } } else { LOG.debug("No awards found for {}", movie.getBaseName()); } return Boolean.TRUE; }