List of usage examples for java.lang Long equals
public boolean equals(Object obj)
From source file:jp.primecloud.auto.service.impl.LoadBalancerServiceImpl.java
/** * {@inheritDoc}//from w w w.j av a 2s . co m */ @Override public void enableInstances(Long loadBalancerNo, List<Long> instanceNos) { // ? if (loadBalancerNo == null) { throw new AutoApplicationException("ECOMMON-000003", "loadBalancerNo"); } if (instanceNos == null) { throw new AutoApplicationException("ECOMMON-000003", "instanceNos"); } // ??? LoadBalancer loadBalancer = loadBalancerDao.read(loadBalancerNo); if (loadBalancer == null) { // ?????? throw new AutoApplicationException("ESERVICE-000603", loadBalancerNo); } // ??? List<Long> tmpInstanceNos = new ArrayList<Long>(); for (Long instanceNo : instanceNos) { if (!tmpInstanceNos.contains(instanceNo)) { tmpInstanceNos.add(instanceNo); } } instanceNos = tmpInstanceNos; // ?? List<Instance> instances = instanceDao.readInInstanceNos(instanceNos); if (instanceNos.size() != instances.size()) { tmpInstanceNos = new ArrayList<Long>(instanceNos); for (Instance instance : instances) { tmpInstanceNos.remove(instance.getInstanceNo()); } if (tmpInstanceNos.size() > 0) { throw new AutoApplicationException("ESERVICE-000621", tmpInstanceNos.iterator().next()); } } // ???? List<ComponentInstance> componentInstances = componentInstanceDao .readByComponentNo(loadBalancer.getComponentNo()); for (Instance instance : instances) { boolean contain = false; for (ComponentInstance componentInstance : componentInstances) { if (BooleanUtils.isNotTrue(componentInstance.getAssociate())) { continue; } if (componentInstance.getInstanceNo().equals(instance.getInstanceNo())) { contain = true; break; } } if (!contain) { // ??????????? Component component = componentDao.read(loadBalancer.getComponentNo()); throw new AutoApplicationException("ESERVICE-000622", instance.getInstanceName(), component.getComponentName()); } } // AWS????? // if ("aws".equals(loadBalancer.getType()) || "cloudstack".equals(loadBalancer.getType())) { if (PCCConstant.LOAD_BALANCER_ELB.equals(loadBalancer.getType())) { // ? Long platformNo = loadBalancer.getPlatformNo(); for (Instance instance : instances) { if (!platformNo.equals(instance.getPlatformNo())) { throw new AutoApplicationException("ESERVICE-000623", instance.getInstanceName()); } } // ?AWS?????????????? List<LoadBalancerInstance> lbInstances = loadBalancerInstanceDao.readInInstanceNos(instanceNos); Set<Long> otherLoadBalancerNos = new HashSet<Long>(); for (LoadBalancerInstance lbInstance : lbInstances) { if (!loadBalancerNo.equals(lbInstance.getLoadBalancerNo())) { otherLoadBalancerNos.add(lbInstance.getLoadBalancerNo()); } } List<LoadBalancer> otherLoadBalancers = loadBalancerDao.readInLoadBalancerNos(otherLoadBalancerNos); for (LoadBalancer otherLoadBalancer : otherLoadBalancers) { if (PCCConstant.LOAD_BALANCER_ELB.equals(otherLoadBalancer.getType())) { // ?AWS????????? for (LoadBalancerInstance lbInstance : lbInstances) { if (otherLoadBalancer.getLoadBalancerNo().equals(otherLoadBalancer.getLoadBalancerNo())) { for (Instance instance : instances) { if (instance.getInstanceNo().equals(lbInstance.getInstanceNo())) { throw new AutoApplicationException("ESERVICE-000624", instance.getInstanceName()); } } } } } } // //VPC?????????????????? // PlatformAws platformAws = platformAwsDao.read(platformNo); // if (platformAws.getVpc()) { // AwsLoadBalancer awsLoadBalancer = awsLoadBalancerDao.read(loadBalancerNo); // List<String> zones = new ArrayList<String>(); // if (StringUtils.isEmpty(awsLoadBalancer.getAvailabilityZone())) { // //ELB?(?)??????????????? // throw new AutoApplicationException("ESERVICE-000630", loadBalancer.getLoadBalancerName()); // } // for (String zone: awsLoadBalancer.getAvailabilityZone().split(",")) { // zones.add(zone.trim()); // } // for (Instance instance : instances) { // AwsInstance awsInstance = awsInstanceDao.read(instance.getInstanceNo()); // if (zones.contains(awsInstance.getAvailabilityZone()) == false) { // //???????????? // throw new AutoApplicationException("ESERVICE-000629", instance.getInstanceName()); // } // } // } } // ??? List<LoadBalancerInstance> lbInstances = loadBalancerInstanceDao.readByLoadBalancerNo(loadBalancerNo); Map<Long, LoadBalancerInstance> lbInstanceMap = new HashMap<Long, LoadBalancerInstance>(); for (LoadBalancerInstance lbInstance : lbInstances) { lbInstanceMap.put(lbInstance.getInstanceNo(), lbInstance); } // ?? for (Instance instance : instances) { // ??????? LoadBalancerInstance lbInstance = lbInstanceMap.remove(instance.getInstanceNo()); // ???????? if (lbInstance == null) { lbInstance = new LoadBalancerInstance(); lbInstance.setLoadBalancerNo(loadBalancerNo); lbInstance.setInstanceNo(instance.getInstanceNo()); lbInstance.setEnabled(true); lbInstance.setStatus(LoadBalancerInstanceStatus.STOPPED.toString()); loadBalancerInstanceDao.create(lbInstance); } // ?????? else { if (BooleanUtils.isNotTrue(lbInstance.getEnabled())) { lbInstance.setEnabled(true); loadBalancerInstanceDao.update(lbInstance); } } } // ??? if (BooleanUtils.isNotTrue(loadBalancer.getConfigure())) { loadBalancer.setConfigure(true); loadBalancerDao.update(loadBalancer); } // ?? Farm farm = farmDao.read(loadBalancer.getFarmNo()); if (BooleanUtils.isNotTrue(farm.getScheduled())) { farm.setScheduled(true); farmDao.update(farm); } }
From source file:com.square.adherent.noyau.dao.implementations.contrat.ContratDaoImpl.java
@Override @SuppressWarnings("unchecked") public RecapitulatifPopulationDto getRecapitulatifPopulationContrat(String eidContrat) { final RecapitulatifPopulationDto recapitulatif = new RecapitulatifPopulationDto(); // Rcupration de la liste des statuts final StringBuffer requeteStatuts = new StringBuffer( "select distinct statut.id, statut.libelle, statut.ordre from Contrat ") .append("where identifiantExterieur like :idContrat ").append("and uidAssure is not null ") .append("and isVisible = true ").append("group by statut.id, statut.libelle, statut.ordre ") .append("order by statut.ordre asc "); final Query queryStatuts = createQuery(requeteStatuts.toString()); queryStatuts.setString("idContrat", eidContrat.substring(0, NB_CARACTERE_ID_CONTRAT) + POURCENT); final List<Object[]> listResultStatuts = queryStatuts.list(); final List<IdentifiantLibelleDto> listeStatuts = new ArrayList<IdentifiantLibelleDto>(); if (listResultStatuts != null && listResultStatuts.size() > 0) { for (Object[] result : listResultStatuts) { final Long idStatut = (Long) result[0]; final String libelleStatut = (String) result[1]; listeStatuts.add(new IdentifiantLibelleDto(idStatut, libelleStatut)); }/*from w w w . j a v a 2 s . c o m*/ } recapitulatif.setListeStatuts(listeStatuts); // Rcupration des effectifs pour chaque population et chaque statut final StringBuffer requete = new StringBuffer( "select population, statut.id, count(distinct uidAssure) from Contrat ") .append("where identifiantExterieur like :idContrat ").append("and uidAssure is not null ") .append("and isVisible = true ").append("group by population, statut.id, statut.ordre ") .append("order by statut.ordre asc"); final Query query = createQuery(requete.toString()); query.setString("idContrat", eidContrat.substring(0, NB_CARACTERE_ID_CONTRAT) + POURCENT); final List<Object[]> listResult = query.list(); final List<ValeursStatutsPopulationDto> listeValeursPopulation = new ArrayList<ValeursStatutsPopulationDto>(); if (listResult != null && listResult.size() > 0) { for (Object[] result : listResult) { final String libellePopulation = (String) result[0]; final Long idStatut = (Long) result[1]; final Integer effectif = Integer.valueOf((String) result[2].toString()); ValeursStatutsPopulationDto valeurStatutpopulationTrouve = isPopulationPresenteDansListe( listeValeursPopulation, libellePopulation); if (valeurStatutpopulationTrouve != null) { for (EffectifStatutDto effectifStatutDto : valeurStatutpopulationTrouve .getListeEffectifsParStatut()) { if (idStatut.equals(effectifStatutDto.getIdStatut())) { effectifStatutDto.setEffectif(effectif); break; } } } else { valeurStatutpopulationTrouve = new ValeursStatutsPopulationDto(); valeurStatutpopulationTrouve.setLibellePopulation(libellePopulation); final List<EffectifStatutDto> listeEffectifsStatutsDto = new ArrayList<EffectifStatutDto>(); for (IdentifiantLibelleDto statutDto : listeStatuts) { final EffectifStatutDto effectifStatutDto = new EffectifStatutDto(); effectifStatutDto.setIdStatut(statutDto.getIdentifiant()); if (idStatut.equals(statutDto.getIdentifiant())) { effectifStatutDto.setEffectif(effectif); } listeEffectifsStatutsDto.add(effectifStatutDto); } valeurStatutpopulationTrouve.setListeEffectifsParStatut(listeEffectifsStatutsDto); listeValeursPopulation.add(valeurStatutpopulationTrouve); } } } recapitulatif.setListeValeursPopulation(listeValeursPopulation); return recapitulatif; }
From source file:com.selfsoft.baseinformation.dao.impl.TbPartInfoDaoImpl.java
public Double getOutTmStoreHouseAsBegin(Long storeHouseId, String year, String mounth, Long outType) { StringBuilder sql = new StringBuilder(); String stockoutWhereStr = " and ("; String maintainWhereStr = " and ("; if (mounth.equals("01")) { int lastyear = Integer.valueOf(year) - 1; stockoutWhereStr += " so.stock_out_code like '%" + lastyear + "12" + "%'"; maintainWhereStr += " m.maintain_code like '%" + lastyear + "12" + "%'"; } else {//from w ww . j a v a 2 s . co m for (int i = 1; i < Integer.valueOf(mounth); i++) { String mounthStr = i < 10 ? "0" + i : i + ""; String yearhMonth = year + "" + mounthStr; if (i == 1) { stockoutWhereStr += " so.stock_out_code like '%" + yearhMonth + "%'"; maintainWhereStr += " m.maintain_code like '%" + yearhMonth + "%'"; } else { stockoutWhereStr += " or so.stock_out_code like '%" + yearhMonth + "%'"; maintainWhereStr += " or m.maintain_code like '%" + yearhMonth + "%'"; } } } stockoutWhereStr += ")"; maintainWhereStr += ")"; sql.append("select sum(aa.so_quantity) from ("); if (outType != null && outType.equals(StockTypeElements.MAINTAIN.getElementValue())) { sql.append( "select sum(m.part_quantity*pi.cost_price) so_quantity from tb_maintain_part_content m ,tb_part_info pi "); sql.append("where pi.id = m.part_id and m.is_confirm not in(8000) and m.is_free = 1"); sql.append(" and pi.store_house_id = " + storeHouseId + " " + maintainWhereStr); } else { //sql.append(" union all "); sql.append( "select sum(sod.quantity*pi.cost_price) so_quantity from tm_stock_out so , tm_stockout_detail sod ,tb_part_info pi "); sql.append( "where pi.id = sod.partinfo_Id and so.id = sod.stockout_id and so.is_confirm not in(8000) and (sod.is_free = 1 or sod.is_free is null)"); sql.append(" and pi.store_house_id = " + storeHouseId + " " + stockoutWhereStr); sql.append(" and so.out_Type=" + outType); } sql.append(") aa"); List<Object[]> list = this.findByOriginSql(sql.toString(), null); Object obj = list.get(0); if (null == obj) return 0D; Double result = obj != null ? Double.valueOf(obj.toString()) : 0D; return result; }
From source file:com.square.tarificateur.noyau.service.implementations.TarificateurEditiqueServiceImpl.java
/** * Gnre la liste des documents PDF.//from w ww .j av a 2s. c o m * @param editionDocumentDto le DTO contenant les infos d'dition * @param infosPersonneSquare le cache des infos de personnes Square * @param infosOpportuniteSquare le cache des infos d'opportunits Square * @param devis le devis * @return la liste des fichiers gnrs */ private List<FichierModeleBean> genererDocumentsPdf(EditionDocumentDto editionDocumentDto, InfosPersonneSquareBean infosPersonneSquare, InfosOpportuniteSquareBean infosOpportuniteSquare, Devis devis) { logger.info(messageSourceUtil.get(MessageKeyUtil.LOGGER_INFO_DEMANDE_DEVIS_PDF, new String[] { String.valueOf(editionDocumentDto.getIdentifiantDevis()) })); // Lignes slectionnes imprimer > 0 if (editionDocumentDto.getIdsLigneDevisSelection() == null || editionDocumentDto.getIdsLigneDevisSelection().size() == 0) { throw new BusinessException( messageSourceUtil.get(MessageKeyUtil.ERROR_LIGNE_DEVIS_SELECTIONNEE_OBLIGATOIRE)); } // On vrifie qu'au moins un modle de devis a t spcifi final List<Long> idsModelesDevisSelectionnes = editionDocumentDto.getIdsModelesDevisSelectionnes(); if (idsModelesDevisSelectionnes == null || idsModelesDevisSelectionnes.isEmpty()) { throw new BusinessException( messageSourceUtil.get(MessageKeyUtil.ERROR_MODELE_DEVIS_SELECTIONNE_OBLIGATOIRE)); } // Rcupration de l'opportunit Square associ au devis final OpportuniteSimpleDto opportuniteSquare = opportuniteUtil .getOpportuniteSimple(devis.getOpportunite().getEidOpportunite(), infosOpportuniteSquare); // Rcupration de l'agence de la personne du devis final com.square.core.model.dto.PersonneDto personneSquare = personneUtil .getPersonnePhysique(devis.getPersonnePrincipale().getEidPersonne(), infosPersonneSquare); final Long eidAgence = Long.valueOf(personneSquare.getAgence().getIdentifiantExterieur()); if (eidAgence == null) { logger.error(messageSourceUtil.get(MessageKeyUtil.LOGGER_ERROR_ABSCENCE_AGENCE_PERSONNE_OPPORTUNITE, new String[] { String.valueOf(devis.getOpportunite().getEidOpportunite()) })); throw new BusinessException( messageSourceUtil.get(MessageKeyUtil.ERREUR_GENERATION_DOCUMENT_AGENCE_OBLIGATOIRE)); } // Rcupration des constantes final Long idModeleDevisBulletinAdhesion = editiqueMappingService .getConstanteIdModeleDevisBulletinAdhesion(); final Long idModeleDevisFicheTransfert = editiqueMappingService.getConstanteIdModeleDevisFicheTransfert(); final Long idModeleLetteAnnulation = editiqueMappingService.getConstanteIdModeleLettreAnnulation(); final Long idModeleLettreRadiation = editiqueMappingService.getConstanteIdModeleLettreRadiation(); final Long idModeleLettreRadiationLoiChatel = editiqueMappingService .getConstanteIdModeleLettreRadiationLoiChatel(); final List<FichierModeleBean> fichiersGeneres = new ArrayList<FichierModeleBean>(); for (Long idModeleDevis : idsModelesDevisSelectionnes) { if (idModeleDevis == null) { logger.error(messageSourceUtil.get(MessageKeyUtil.LOGGER_ERROR_MODELE_DEVIS_NON_RENSEIGNER)); throw new BusinessException(messageSourceUtil.get(MessageKeyUtil.ERROR_MODELE_DEVIS_INCOMPATIBLE)); } else if (!(idModeleDevis.equals(idModeleDevisBulletinAdhesion) || idModeleDevis.equals(idModeleDevisFicheTransfert) || idModeleDevis.equals(idModeleLetteAnnulation) || idModeleDevis.equals(idModeleLettreRadiation) || idModeleDevis.equals(idModeleLettreRadiationLoiChatel))) { logger.error(messageSourceUtil .get(MessageKeyUtil.LOGGER_ERROR_MODELE_DEVIS_IS_NOT_BULLETIN_ADHESION_OU_FICHE_TRANSFERT)); throw new BusinessException(messageSourceUtil.get(MessageKeyUtil.ERROR_MODELE_DEVIS_INCOMPATIBLE)); } if (idModeleDevis.equals(idModeleLetteAnnulation)) { // On gnre la lettre d'annulation final LettreAnnulationDto lettreAnnulation = new LettreAnnulationDto(); // Rcupration des informations de l'agence responsable de l'opportunit. final AgenceReelleDto agenceResponsable = agenceService.getAgenceReelleById(eidAgence); // Cration de l'agence final AgenceEditiqueDto agence = new AgenceEditiqueDto(); agence.setDenomination(agenceResponsable.getDenomination()); agence.setNumeroTelephone(utilisateurMappingService.getNumeroTelephoneUnique()); agence.setAdresse((AdresseDto) mapperDozerBean.map(agenceResponsable, AdresseDto.class)); lettreAnnulation.setAgence(agence); final Adhesion adhesion = devis.getOpportunite().getAdhesion(); adhesion.setDateCourrier(Calendar.getInstance()); // Rcupration de la rfrence final String reference = opportuniteSquare.getEidOpportunite(); lettreAnnulation.setNumeroDossier(reference); lettreAnnulation.setDateCourrier(adhesion.getDateCourrier()); lettreAnnulation.setDateCreationAdhesion(adhesion.getDateSignature()); // Cration du prospect final Personne personneCiblee = devis.getPersonnePrincipale(); // Rcupration du Prospect Square final PersonneSimpleDto personneCibleeSquare = personneUtil .getPersonneSimple(personneCiblee.getEidPersonne(), infosPersonneSquare); final ProspectDevisDto prospect = new ProspectDevisDto(); if (personneCibleeSquare.getCivilite() != null && !StringUtils.isBlank(personneCibleeSquare.getCivilite().getLibelle())) { prospect.setGenre(personneCibleeSquare.getCivilite().getLibelle()); } prospect.setNom(personneCibleeSquare.getNom().toUpperCase()); final char[] delimiters = { ' ', '-', '_' }; final String prenomMisEnForme = WordUtils.capitalizeFully(personneCibleeSquare.getPrenom(), delimiters); prospect.setPrenom(prenomMisEnForme); // Recherche de l'adresse principale final CoordonneesDto coordonnees = personneUtil.getCoordonnees(personneCiblee.getEidPersonne(), infosPersonneSquare); final com.square.core.model.dto.AdresseDto adressePrincipale = personneUtil .rechercherAdressePrincipaleEnCours(coordonnees.getAdresses()); prospect.setAdresse(mapperAdresse(adressePrincipale)); lettreAnnulation.setProspect(prospect); final FichierDto fichierGenere = editiqueService.getLettreAnnulation(lettreAnnulation); fichierGenere.setNom( getNomFichierPdf(messageSourceUtil.get(MessageKeyUtil.NOM_FICHIER_LETTRE_ANNULATION))); fichiersGeneres.add(new FichierModeleBean(fichierGenere, idModeleDevis)); } else if (idModeleDevis.equals(idModeleLettreRadiation) || idModeleDevis.equals(idModeleLettreRadiationLoiChatel)) { final FichierDto fichierGenere = editiqueService .getFichier(editiqueMappingService.getMapFichiersStatiques().get(idModeleDevis.toString())); if (idModeleDevis.equals(idModeleLettreRadiation)) { fichierGenere.setNom( getNomFichierPdf(messageSourceUtil.get(MessageKeyUtil.NOM_FICHIER_LETTRE_RADIATION))); } else if (idModeleDevis.equals(idModeleLettreRadiationLoiChatel)) { fichierGenere.setNom(getNomFichierPdf( messageSourceUtil.get(MessageKeyUtil.NOM_FICHIER_LETTRE_RADIATION_LOI_CHATEL))); } fichiersGeneres.add(new FichierModeleBean(fichierGenere, idModeleDevis)); } else { // Type de devis Sant/Prvoyance // Rcupration de la rfrence final String reference = opportuniteSquare.getEidOpportunite(); // Cration du DTO permettant la gnration du bulletin d'adhsion final DocumentsBulletinsAdhesionDto documentsBulletinsAdhesionDto = getDocumentsBaDtoPourDevis( devis, editionDocumentDto, reference, idModeleDevis, eidAgence, infosPersonneSquare); final FichierDto fichierGenere = editiqueService .genererPdfDocumentsBulletinsAdhesion(documentsBulletinsAdhesionDto); // Nom du fichier en fonction du modle if (idModeleDevisBulletinAdhesion.equals(idModeleDevis)) { fichierGenere.setNom( getNomFichierPdf(messageSourceUtil.get(MessageKeyUtil.NOM_FICHIER_BULLETIN_ADHESION))); } else if (idModeleDevisFicheTransfert.equals(idModeleDevis)) { fichierGenere .setNom(getNomFichierPdf(messageSourceUtil.get(MessageKeyUtil.NOM_FICHIER_AVENANT))); } fichiersGeneres.add(new FichierModeleBean(fichierGenere, idModeleDevis)); // On met jour la date de dernire dition du BA si elle est renseigne if (editionDocumentDto.getDateEditionBa() != null) { devis.getOpportunite().getAdhesion().setDateEditionBA(editionDocumentDto.getDateEditionBa()); } } } return fichiersGeneres; }
From source file:org.apache.flink.streaming.connectors.kafka.KafkaConsumerTestBase.java
/** * This test ensures that when the consumers retrieve some start offset from kafka (earliest, latest), that this offset * is committed to Kafka, even if some partitions are not read. * * Test://from w w w.ja va 2s. c om * - Create 3 partitions * - write 50 messages into each. * - Start three consumers with auto.offset.reset='latest' and wait until they committed into Kafka. * - Check if the offsets in Kafka are set to 50 for the three partitions * * See FLINK-3440 as well */ public void runAutoOffsetRetrievalAndCommitToKafka() throws Exception { // 3 partitions with 50 records each (0-49, so the expected commit offset of each partition should be 50) final int parallelism = 3; final int recordsInEachPartition = 50; final String topicName = writeSequence("testAutoOffsetRetrievalAndCommitToKafkaTopic", recordsInEachPartition, parallelism, 1); final StreamExecutionEnvironment env = StreamExecutionEnvironment.createRemoteEnvironment("localhost", flinkPort); env.getConfig().disableSysoutLogging(); env.getConfig().setRestartStrategy(RestartStrategies.noRestart()); env.setParallelism(parallelism); env.enableCheckpointing(200); Properties readProps = new Properties(); readProps.putAll(standardProps); readProps.setProperty("auto.offset.reset", "latest"); // set to reset to latest, so that partitions are initially not read DataStream<String> stream = env .addSource(kafkaServer.getConsumer(topicName, new SimpleStringSchema(), readProps)); stream.addSink(new DiscardingSink<String>()); final AtomicReference<Throwable> errorRef = new AtomicReference<>(); final Thread runner = new Thread("runner") { @Override public void run() { try { env.execute(); } catch (Throwable t) { if (!(t.getCause() instanceof JobCancellationException)) { errorRef.set(t); } } } }; runner.start(); KafkaTestEnvironment.KafkaOffsetHandler kafkaOffsetHandler = kafkaServer.createOffsetHandler(); final Long l50 = 50L; // the final committed offset in Kafka should be 50 final long deadline = 30_000_000_000L + System.nanoTime(); do { Long o1 = kafkaOffsetHandler.getCommittedOffset(topicName, 0); Long o2 = kafkaOffsetHandler.getCommittedOffset(topicName, 1); Long o3 = kafkaOffsetHandler.getCommittedOffset(topicName, 2); if (l50.equals(o1) && l50.equals(o2) && l50.equals(o3)) { break; } Thread.sleep(100); } while (System.nanoTime() < deadline); // cancel the job JobManagerCommunicationUtils.cancelCurrentJob(flink.getLeaderGateway(timeout)); final Throwable t = errorRef.get(); if (t != null) { throw new RuntimeException("Job failed with an exception", t); } // final check to see if offsets are correctly in Kafka Long o1 = kafkaOffsetHandler.getCommittedOffset(topicName, 0); Long o2 = kafkaOffsetHandler.getCommittedOffset(topicName, 1); Long o3 = kafkaOffsetHandler.getCommittedOffset(topicName, 2); Assert.assertEquals(Long.valueOf(50L), o1); Assert.assertEquals(Long.valueOf(50L), o2); Assert.assertEquals(Long.valueOf(50L), o3); kafkaOffsetHandler.close(); deleteTestTopic(topicName); }
From source file:data.services.ParseBaseService.java
private void updateCars() throws SQLException, ClassNotFoundException, Exception { List<Car> carsForSaveList = new ArrayList(); List<Car> carsForUpdateList = new ArrayList(); List<Car> carList = carDao.getAllAsc(); List<Long> actualQutoIdList = new ArrayList(); HashMap<Long, Car> ourOldIdCarMap = new HashMap(); for (Car car : carList) { ourOldIdCarMap.put(car.getCmqId(), car); }// w ww .j av a 2 s . co m ResultSet resSet = getFromQutoBase( "SELECT c.*,cmc.title,cmsg.car_model_sub_id cms_id,cmsg.car_model_generation_id cmg_id,cmc.title completion_title,cmg.car_model_id model_id FROM car_modification c LEFT JOIN car_modification_completion cmc ON c.car_modification_completion_id=cmc.id LEFT JOIN car_model_sub_generation cmsg ON c.car_model_sub_generation_id=cmsg.id LEFT JOIN car_model_generation cmg ON cmsg.car_model_generation_id=cmg.id WHERE c.usage='ad_archive_catalog'"); while (resSet.next()) { Long cmqId = resSet.getLong("id"); actualQutoIdList.add(cmqId); Long modelQutoId = resSet.getLong("model_id"); String completionTitle = StringAdapter.getString(resSet.getString("completion_title")).trim(); Long cmsId = resSet.getLong("cms_id"); Long cmgId = resSet.getLong("cmg_id"); String title = StringAdapter.getString(resSet.getString("title")).trim(); Long cmsgId = resSet.getLong("car_model_sub_generation_id"); Long mediaId = resSet.getLong("media_id"); String url = StringAdapter.getString(resSet.getString("url")).trim(); Double price = resSet.getDouble("dt_price_min"); Model model = new Model(); model.setQutoId(modelQutoId); List<Model> supModelList = modelDao.find(model); if (!supModelList.isEmpty() && modelQutoId != 0) { model = supModelList.get(0); if (!ourOldIdCarMap.keySet().contains(cmqId)) { Car car = new Car(); car.setCmqId(cmqId); car.setModel(model); ; car.setTitle(title); car.setMediaId(mediaId); car.setUrl(url); car.setCmPrice(price); car.setCmgqId(cmgId); car.setCmsgqId(cmsgId); car.setCmsqId(cmsId); car.setCompletionTitle(completionTitle); if (validate(car, " , TroubleQutoId=" + car.getCmqId() + "; ")) { carsForSaveList.add(car); } } else { Car car = ourOldIdCarMap.get(cmqId); if (!cmgId.equals(car.getCmgqId()) || !title.equals(car.getTitle()) || !price.equals(car.getCmPrice()) || !url.equals(car.getUrl()) || !mediaId.equals(car.getMediaId()) || !completionTitle.equals(car.getCompletionTitle()) || !cmsgId.equals(car.getCmsgqId()) || !cmsId.equals(car.getCmsqId())) { car.setCmqId(cmqId); car.setModel(model); ; car.setTitle(title); car.setMediaId(mediaId); car.setUrl(url); car.setCmPrice(price); car.setCmgqId(cmgId); car.setCmsgqId(cmsgId); car.setCmsqId(cmsId); car.setCompletionTitle(completionTitle); ; if (validate(car, " , TroubleQutoId=" + car.getCmqId() + "; ")) { carsForUpdateList.add(car); } } } } } int s = 0; int u = 0; int d = 0; for (Car car : carsForSaveList) { carService.create(car); s++; } for (Car car : carsForUpdateList) { carDao.update(car); u++; } for (Long qutoId : ourOldIdCarMap.keySet()) { if (!actualQutoIdList.contains(qutoId)) { d++; carService.delete(ourOldIdCarMap.get(qutoId)); } } addError(" : " + s + " ? ?, " + u + " , " + d + " ."); }
From source file:edu.harvard.iq.dvn.core.study.StudyServiceBean.java
public List getRecentlyReleasedStudyIds(Long vdcId, Long vdcNetworkId, int numResults) { String linkedStudyClause = ""; String networkClause = ""; if (vdcNetworkId != null && !vdcNetworkId.equals(vdcNetworkService.findRootNetwork().getId())) { networkClause = " and v.vdcnetwork_id = " + vdcNetworkId + " "; VDCNetwork vdcNetwork = vdcNetworkService.findById(vdcNetworkId); List<Study> linkedStudys = (List) vdcNetwork.getLinkedStudies(); List<Long> studyIdList = new ArrayList<Long>(); for (Study study : linkedStudys) { studyIdList.add(study.getId()); }//from w w w . jav a 2 s.c o m if (studyIdList != null && studyIdList.size() > 0) { String studyIds = generateTempTableString(studyIdList); linkedStudyClause = " or sv.study_id in (" + studyIds + ") "; } } String queryStr = " SELECT sv.study_id FROM StudyVersion sv where sv.versionstate = " + "'" + StudyVersion.VersionState.RELEASED + "'" + " and (sv.study_id in ( " + " select s.id FROM VDC v, Study s, StudyVersion sv where s.id = sv.study_id and sv.versionstate = " + "'" + StudyVersion.VersionState.RELEASED + "'" + " and s.owner_id = v.id and v.restricted = false " + networkClause + ") " + linkedStudyClause + ") ORDER BY sv.releaseTime desc"; if (vdcId != null) { queryStr = "SELECT s.id FROM Study s, StudyVersion sv where s.id = sv.study_id " + " and sv.versionstate = '" + StudyVersion.VersionState.RELEASED + "'" + " and s.owner_id = " + vdcId + " ORDER BY sv.releaseTime desc"; } //System.out.print("release data query " + queryStr); Query query = em.createNativeQuery(queryStr); List<Long> returnList = new ArrayList<Long>(); if (numResults == -1) { for (Object currentResult : query.getResultList()) { if (currentResult instanceof Integer) { // convert results into Longs returnList.add(new Long(((Integer) currentResult).longValue())); } else { returnList.add(new Long(((Long) currentResult).longValue())); } } } else { int i = 0; for (Object currentResult : query.getResultList()) { i++; if (i > numResults) { break; } else { if (currentResult instanceof Integer) { // convert results into Longs returnList.add(new Long(((Integer) currentResult).longValue())); } else { returnList.add(new Long(((Long) currentResult).longValue())); } } } } return returnList; }
From source file:org.alfresco.repo.usage.ContentUsageImpl.java
/** * Called after a node's properties have been changed. * /* w w w . j a va 2 s. c om*/ * @param nodeRef reference to the updated node * @param before the node's properties before the change * @param after the node's properties after the change */ public void onUpdateProperties(NodeRef nodeRef, Map<QName, Serializable> before, Map<QName, Serializable> after) { if (stores.contains(tenantService.getBaseName(nodeRef.getStoreRef()).toString()) && (!alreadyCreated(nodeRef))) { // Check for change in content size // TODO use data dictionary to get content property ContentData contentDataBefore = (ContentData) before.get(ContentModel.PROP_CONTENT); Long contentSizeBefore = (contentDataBefore == null ? null : contentDataBefore.getSize()); ContentData contentDataAfter = (ContentData) after.get(ContentModel.PROP_CONTENT); Long contentSizeAfter = (contentDataAfter == null ? null : contentDataAfter.getSize()); // Check for change in owner/creator String ownerBefore = (String) before.get(ContentModel.PROP_OWNER); if ((ownerBefore == null) || (ownerBefore.equals(OwnableService.NO_OWNER))) { ownerBefore = (String) before.get(ContentModel.PROP_CREATOR); } String ownerAfter = (String) after.get(ContentModel.PROP_OWNER); if ((ownerAfter == null) || (ownerAfter.equals(OwnableService.NO_OWNER))) { ownerAfter = (String) after.get(ContentModel.PROP_CREATOR); } // check change in size (and possibly owner) if (contentSizeBefore == null && contentSizeAfter != null && contentSizeAfter != 0 && ownerAfter != null) { // new size has been added - note: ownerBefore does not matter since the contentSizeBefore is null if (logger.isDebugEnabled()) logger.debug("onUpdateProperties: updateSize (null -> " + contentSizeAfter + "): nodeRef=" + nodeRef + ", ownerAfter=" + ownerAfter); incrementUserUsage(ownerAfter, contentSizeAfter, nodeRef); } else if (contentSizeAfter == null && contentSizeBefore != null && contentSizeBefore != 0 && ownerBefore != null) { // old size has been removed - note: ownerAfter does not matter since contentSizeAfter is null if (logger.isDebugEnabled()) logger.debug("onUpdateProperties: updateSize (" + contentSizeBefore + " -> null): nodeRef=" + nodeRef + ", ownerBefore=" + ownerBefore); decrementUserUsage(ownerBefore, contentSizeBefore, nodeRef); } else if (contentSizeBefore != null && contentSizeAfter != null) { if (contentSizeBefore.equals(contentSizeAfter) == false) { // size has changed (and possibly owner) if (logger.isDebugEnabled()) logger.debug("onUpdateProperties: updateSize (" + contentSizeBefore + " -> " + contentSizeAfter + "): nodeRef=" + nodeRef + ", ownerBefore=" + ownerBefore + ", ownerAfter=" + ownerAfter); if (contentSizeBefore != 0 && ownerBefore != null) { decrementUserUsage(ownerBefore, contentSizeBefore, nodeRef); } if (contentSizeAfter != 0 && ownerAfter != null) { incrementUserUsage(ownerAfter, contentSizeAfter, nodeRef); } } else { // same size - check change in owner only if (ownerBefore == null && ownerAfter != null && contentSizeAfter != 0 && ownerAfter != null) { // new owner has been added if (logger.isDebugEnabled()) logger.debug("onUpdateProperties: updateOwner (null -> " + ownerAfter + "): nodeRef=" + nodeRef + ", contentSize=" + contentSizeAfter); incrementUserUsage(ownerAfter, contentSizeAfter, nodeRef); } else if (ownerAfter == null && ownerBefore != null && contentSizeBefore != 0) { // old owner has been removed if (logger.isDebugEnabled()) logger.debug("onUpdateProperties: updateOwner (" + ownerBefore + " -> null): nodeRef=" + nodeRef + ", contentSize=" + contentSizeBefore); decrementUserUsage(ownerBefore, contentSizeBefore, nodeRef); } else if (ownerBefore != null && ownerAfter != null && ownerBefore.equals(ownerAfter) == false) { // owner has changed (size has not) if (logger.isDebugEnabled()) logger.debug("onUpdateProperties: updateOwner (" + ownerBefore + " -> " + ownerAfter + "): nodeRef=" + nodeRef + ", contentSize=" + contentSizeBefore); if (contentSizeBefore != 0) { decrementUserUsage(ownerBefore, contentSizeBefore, nodeRef); } if (contentSizeAfter != 0) { incrementUserUsage(ownerAfter, contentSizeAfter, nodeRef); } } } } } }
From source file:controllers.core.PortfolioEntryPlanningController.java
/** * Create or edit a planning package.//from w w w . ja v a 2s .c o m * * @param id * the portfolio entry id * @param planningPackageId * the planning package id (0 for create case) */ @With(CheckPortfolioEntryExists.class) @Dynamic(IMafConstants.PORTFOLIO_ENTRY_EDIT_DYNAMIC_PERMISSION) public Result managePackage(Long id, Long planningPackageId) { // get the portfolioEntry PortfolioEntry portfolioEntry = PortfolioEntryDao.getPEById(id); // initiate the form with the template Form<PortfolioEntryPlanningPackageFormData> planningPackageForm = planningPackageFormTemplate; // edit case: inject values if (!planningPackageId.equals(Long.valueOf(0))) { PortfolioEntryPlanningPackage planningPackage = PortfolioEntryPlanningPackageDao .getPEPlanningPackageById(planningPackageId); // security: the portfolioEntry must be related to the object if (!planningPackage.portfolioEntry.id.equals(id)) { return forbidden(views.html.error.access_forbidden.render("")); } planningPackageForm = planningPackageFormTemplate .fill(new PortfolioEntryPlanningPackageFormData(planningPackage)); // add the custom attributes values this.getCustomAttributeManagerService().fillWithValues(planningPackageForm, PortfolioEntryPlanningPackage.class, planningPackageId); } else { planningPackageForm = planningPackageFormTemplate.fill(new PortfolioEntryPlanningPackageFormData()); // add the custom attributes default values this.getCustomAttributeManagerService().fillWithValues(planningPackageForm, PortfolioEntryPlanningPackage.class, null); } DefaultSelectableValueHolderCollection<CssValueForValueHolder> selectablePortfolioEntryPlanningPackageTypes = PortfolioEntryPlanningPackageDao .getPEPlanningPackageTypeActiveAsCssVH(); return ok(views.html.core.portfolioentryplanning.package_manage.render(portfolioEntry, selectablePortfolioEntryPlanningPackageTypes, planningPackageForm, PortfolioEntryPlanningPackageDao.getPEPlanningPackageGroupActiveAsVH(), getPackageStatusAsValueHolderCollection())); }
From source file:controllers.core.PortfolioEntryPlanningController.java
/** * Create or edit an allocated actor (for a resource plan). * // w w w.j a v a2s . c o m * @param id * the portfolio entry id * @param allocatedActorId * the allocated actor id, set to 0 for create case */ @With(CheckPortfolioEntryExists.class) @Dynamic(IMafConstants.PORTFOLIO_ENTRY_EDIT_DYNAMIC_PERMISSION) public Result manageAllocatedActor(Long id, Long allocatedActorId) { // get the portfolioEntry PortfolioEntry portfolioEntry = PortfolioEntryDao.getPEById(id); // initiate the form with the template Form<PortfolioEntryResourcePlanAllocatedActorFormData> allocatedActorForm = allocatedActorFormTemplate; // edit case: inject values if (!allocatedActorId.equals(Long.valueOf(0))) { PortfolioEntryResourcePlanAllocatedActor allocatedActor = PortfolioEntryResourcePlanDAO .getPEPlanAllocatedActorById(allocatedActorId); // security: the portfolioEntry must be related to the object if (!allocatedActor.portfolioEntryResourcePlan.lifeCycleInstancePlannings .get(0).lifeCycleInstance.portfolioEntry.id.equals(id)) { return forbidden(views.html.error.access_forbidden.render("")); } allocatedActorForm = allocatedActorFormTemplate .fill(new PortfolioEntryResourcePlanAllocatedActorFormData(allocatedActor)); // add the custom attributes values this.getCustomAttributeManagerService().fillWithValues(allocatedActorForm, PortfolioEntryResourcePlanAllocatedActor.class, allocatedActorId); } else { // add the custom attributes default values this.getCustomAttributeManagerService().fillWithValues(allocatedActorForm, PortfolioEntryResourcePlanAllocatedActor.class, null); } return ok(views.html.core.portfolioentryplanning.allocated_actor_manage.render(portfolioEntry, allocatedActorForm)); }