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}// w w w . j av a2s. c o m */ @Override public void updateUltraMonkeyLoadBalancer(Long loadBalancerNo, String loadBalancerName, String comment, Long componentNo) { // ? if (loadBalancerNo == null) { throw new AutoApplicationException("ECOMMON-000003", "loadBalancerNo"); } if (loadBalancerName == null || loadBalancerName.length() == 0) { throw new AutoApplicationException("ECOMMON-000003", "loadBalancerName"); } if (componentNo == null) { throw new AutoApplicationException("ECOMMON-000003", "componentNo"); } // ?? if (!Pattern.matches("^[0-9a-z]|[0-9a-z][0-9a-z-]*[0-9a-z]$", loadBalancerName)) { throw new AutoApplicationException("ECOMMON-000012", "loadBalancerName"); } // TODO: ?? // ??? LoadBalancer loadBalancer = loadBalancerDao.read(loadBalancerNo); if (loadBalancer == null) { // ?????? throw new AutoApplicationException("ESERVICE-000603", loadBalancerNo); } // ??????? if (LoadBalancerStatus.fromStatus(loadBalancer.getStatus()) != LoadBalancerStatus.STOPPED) { // ?????????????????? if (!StringUtils.equals(loadBalancer.getLoadBalancerName(), loadBalancerName) || !componentNo.equals(loadBalancer.getComponentNo())) { throw new AutoApplicationException("ESERVICE-000604", loadBalancer.getLoadBalancerName()); } } // ?????? LoadBalancer checkLoadBalancer = loadBalancerDao.readByFarmNoAndLoadBalancerName(loadBalancer.getFarmNo(), loadBalancerName); if (checkLoadBalancer != null && !loadBalancerNo.equals(checkLoadBalancer.getLoadBalancerNo())) { // ???????? throw new AutoApplicationException("ESERVICE-000601", loadBalancerName); } // ???? long countComponent = componentDao.countByComponentNo(componentNo); if (countComponent == 0) { // ??????? throw new AutoApplicationException("ESERVICE-000607", componentNo); } // ??????????? long countListener = loadBalancerListenerDao.countByLoadBalancerNo(loadBalancerNo); if (countListener > 0) { if (!loadBalancer.getComponentNo().equals(componentNo)) { // ???????? throw new AutoApplicationException("ESERVICE-000608"); } } Farm farm = farmDao.read(loadBalancer.getFarmNo()); // ?? loadBalancer.setLoadBalancerName(loadBalancerName); loadBalancer.setComment(comment); loadBalancer.setFqdn(loadBalancerName + "." + farm.getDomainName()); loadBalancer.setComponentNo(componentNo); loadBalancerDao.update(loadBalancer); // eventLogger.log(EventLogLevel.INFO, farm.getFarmNo(), farm.getFarmName(), null, null, null, null, "LoadBalancerUpdate", null, null, new Object[] { loadBalancerName }); }
From source file:com.square.core.service.implementations.PersonnePhysiqueServiceImplementation.java
@Override public boolean hasMembreFamilleNaturePersonne(Long idPersonne, List<Long> listeIdsNaturesPersonne) { final PersonnePhysique personnePrincipale = personnePhysiqueDao.rechercherPersonneParId(idPersonne); if (personnePrincipale == null) { logger.error("La personne " + idPersonne + " n'existe pas"); throw new TechnicalException( messageSourceUtil.get(PersonnePhysiqueKeyUtil.MESSAGE_ERREUR_PERSONNE_INEXISTANTE)); }/*from www . j ava2s . c o m*/ // Vrification pour la personne principale if (personnePrincipale.getNature() != null && listeIdsNaturesPersonne.contains(personnePrincipale.getNature().getId())) { return true; } // Vrification pour les personnes de la famille final RelationCriteresRechercheDto criteres = new RelationCriteresRechercheDto(); final RemotePagingCriteriasDto<RelationCriteresRechercheDto> criterias = new RemotePagingCriteriasDto<RelationCriteresRechercheDto>( criteres, 0, Integer.MAX_VALUE); criteres.setIdPersonne(idPersonne); final List<Long> listeGroupements = new ArrayList<Long>(); listeGroupements.add(squareMappingService.getIdGroupementFamille()); criteres.setGroupements(listeGroupements); final List<Relation> listeRelations = relationDao.rechercherRelationsParCriteres(criterias); if (listeRelations != null && listeRelations.size() > 0) { for (Relation relation : listeRelations) { PersonnePhysique personneFamille = null; if (idPersonne.equals(relation.getPersonneSource().getId())) { personneFamille = (PersonnePhysique) relation.getPersonneCible(); } else { personneFamille = (PersonnePhysique) relation.getPersonneSource(); } if (personneFamille.getNature() != null && listeIdsNaturesPersonne.contains(personneFamille.getNature().getId())) { return true; } } } return false; }
From source file:com.square.tarificateur.noyau.service.implementations.TarificateurServiceImpl.java
/** * {@inheritDoc}/*from w w w.j av a 2 s .c o m*/ */ @Override public InfosAdhesionDto getInfosAdhesion(Long idDevis) { logger.debug(messageSourceUtil.get(MessageKeyUtil.LOGGER_DEBUG_RECUP_INFO_ADHESION_DEVIS, new String[] { String.valueOf(idDevis) })); // Rcupration du devis final Devis devis = devisDao.getDevis(idDevis); if (devis == null) { logger.error(messageSourceUtil.get(MessageKeyUtil.LOGGER_ERROR_DEVIS_INEXISTANT, new String[] { String.valueOf(idDevis) })); throw new TechnicalException(messageSourceUtil.get(MessageKeyUtil.ERROR_DEVIS_INEXISTANT)); } // Rcupration des personnes final Personne personnePrincipale = devis.getPersonnePrincipale(); if (personnePrincipale == null) { logger.error(messageSourceUtil.get(MessageKeyUtil.LOGGER_ERROR_DEVIS_PERSONNE_PRINCIPALE_INEXISTANTE, new String[] { String.valueOf(idDevis) })); throw new TechnicalException( messageSourceUtil.get(MessageKeyUtil.ERROR_AUCUNE_PERSONNE_PRINCIPALE_POUR_DEVIS)); } // Rcupration de l'adhsion partir de l'opportunit final Opportunite opportunite = devis.getOpportunite(); if (opportunite == null) { logger.error(messageSourceUtil.get(MessageKeyUtil.LOGGER_ERROR_DEVIS_OPPORTUNITE_INEXISTANTE, new String[] { String.valueOf(idDevis) })); throw new TechnicalException(messageSourceUtil.get(MessageKeyUtil.ERROR_AUCUNE_OPPORTUNITE_POUR_DEVIS)); } final Adhesion adhesion = opportunite.getAdhesion(); if (adhesion == null) { logger.error(messageSourceUtil.get(MessageKeyUtil.LOGGER_ERROR_OPPORTUNITE_ADHESION_INEXISTANTE, new String[] { String.valueOf(idDevis) })); throw new TechnicalException( messageSourceUtil.get(MessageKeyUtil.ERROR_AUCUNE_ADHESION_POUR_OPPORTUNITE)); } // Mapping des donnes final InfosAdhesionDto infosAdhesion = new InfosAdhesionDto(); infosAdhesion.setIdDevis(idDevis); // Mapping des donnes des personnes final List<InfosPersonneDto> listeInfosPersonnes = new ArrayList<InfosPersonneDto>(); final InfosPersonneDto infosPersonnePrincipale = mapperDozerBean.map(personnePrincipale, InfosPersonneDto.class); final PersonneSimpleDto personnePrincipaleSquare = personnePhysiqueService .rechercherPersonneSimpleParIdentifiant(personnePrincipale.getEidPersonne()); infosPersonnePrincipale.setNom(personnePrincipaleSquare.getNom()); infosPersonnePrincipale.setPrenom(personnePrincipaleSquare.getPrenom()); infosPersonnePrincipale.setNumClient(personnePrincipaleSquare.getNumeroClient()); getInfosAdhesionRelation(infosPersonnePrincipale); listeInfosPersonnes.add(infosPersonnePrincipale); // Mapping des bnficiaires if (personnePrincipale.getListeBeneficiaires() != null && !personnePrincipale.getListeBeneficiaires().isEmpty()) { for (Beneficiaire beneficiaire : personnePrincipale.getListeBeneficiaires()) { // Seulement si ils sont prsent sur une des lignes du devis Boolean estDansLeDevis = false; final List<LigneDevis> lignesPrincipales = ligneDevisDao.getLigneDevisPrincipalParIdDevis(idDevis); for (LigneDevis lp : lignesPrincipales) { final List<LigneDevis> lignesLies = ligneDevisDao.getLignesLieesLignePrincipale(lp.getId()); for (LigneDevis ll : lignesLies) { if (ll.getBeneficiaire() != null && ll.getBeneficiaire().getId() == beneficiaire.getPersonneCible().getId()) { estDansLeDevis = true; break; } } if (estDansLeDevis) { break; } } if (estDansLeDevis) { final InfosPersonneDto infosBeneficiaire = mapperDozerBean.map(beneficiaire.getPersonneCible(), InfosPersonneDto.class); final IdentifiantLibelleDto lienFamilial = mapperDozerBean.map(beneficiaire.getLienFamilial(), IdentifiantLibelleDto.class); infosBeneficiaire.setLienFamilial(lienFamilial); final PersonneSimpleDto beneficiaireSquare = personnePhysiqueService .rechercherPersonneSimpleParIdentifiant( beneficiaire.getPersonneCible().getEidPersonne()); infosBeneficiaire.setNom(beneficiaireSquare.getNom()); infosBeneficiaire.setPrenom(beneficiaireSquare.getPrenom()); infosBeneficiaire.setNumClient(beneficiaireSquare.getNumeroClient()); getInfosAdhesionRelation(infosBeneficiaire); listeInfosPersonnes.add(infosBeneficiaire); } } } Collections.sort(listeInfosPersonnes, new Comparator<InfosPersonneDto>() { @Override public int compare(InfosPersonneDto o1, InfosPersonneDto o2) { if (o1.getLienFamilial() == null || o1.getLienFamilial().getIdentifiant() == null) { return -1; } if (o2.getLienFamilial() == null || o2.getLienFamilial().getIdentifiant() == null) { return -1; } if (o1.getLienFamilial().getIdentifiant().compareTo(o2.getLienFamilial().getIdentifiant()) != 0) { return o1.getLienFamilial().getIdentifiant().compareTo(o2.getLienFamilial().getIdentifiant()); } return 0; } }); infosAdhesion.setInfosPersonnes(listeInfosPersonnes); // Mapping des infos sur l'adhesion infosAdhesion.setDateClicBA(adhesion.getDateClicBA()); infosAdhesion.setDateTelechargementBA(adhesion.getDateTelechargementBA()); InfosPaiementDto infosPaiement = new InfosPaiementDto(); InfosRibDto infosRib = null; infosPaiement = mapperDozerBean.map(adhesion, InfosPaiementDto.class); if (adhesion.getInfosRib() != null) { infosRib = mapperDozerBean.map(adhesion.getInfosRib(), InfosRibDto.class); } final Long idContratSante = adherentMappingService.getIdContratSante(); final int jourPaiementDefault = adherentMappingService.getJourPaiementPrelevementCinq(); final Long idFrequencePaiementDefault = adherentMappingService.getIdFrequencePrelevementMensuelle(); final Long idMoyenPaiementPrelevement = adherentMappingService.getIdMoyenPaiementPrelevement(); final Long idMoyenPaiementVirement = adherentMappingService.getIdMoyenPaiementVirement(); ContratDto contratRecent = null; if (adhesion.getMoyenPaiement() == null && adhesion.getPeriodicitePaiement() == null && adhesion.getJourPaiement() == null) { final ListeContratsDto contrats = contratService.getListeContrats(personnePrincipaleSquare.getId()); // Si la personne a au moins un contrat, on recopie les informations du plus rcent if (contrats != null && contrats.getListeContrats() != null && contrats.getListeContrats().size() > 0) { for (ContratSimpleDto contratSimple : contrats.getListeContrats()) { // si le contrat est un contrat de sant if (idContratSante.equals(contratSimple.getNature().getIdentifiant())) { final ContratDto contrat = contratService.getContrat(contratSimple.getIdentifiant()); if (contratRecent == null || contratRecent.getDateSignature().before(contrat.getDateSignature())) { contratRecent = contrat; } } } // Si on a trouv un contrat avec des infos de paiement valide, on remplit les infos de paiement de l'adhsion if (contratRecent != null) { if (contratRecent.getInfosPaiementCotisation() != null && contratRecent.getInfosPaiementCotisation().getMoyenPaiement() != null && contratRecent.getInfosPaiementCotisation().getFrequencePaiement() != null && contratRecent.getInfosPaiementCotisation().getJourPaiement() != null) { // On convertit les infos de paiement ct contrat en infos de paiement ct tarificateur final IdentifiantLibelleDto moyenPaiementCritere = new IdentifiantLibelleDto(null, contratRecent.getInfosPaiementCotisation().getMoyenPaiement().getLibelle()); final List<MoyenPaiement> listMoyenPaiement = moyenPaiementDao .rechercherMoyensPaiementParCriteres(moyenPaiementCritere); if (listMoyenPaiement != null && listMoyenPaiement.size() != 0) { infosPaiement.setIdMoyenPaiement(listMoyenPaiement.get(0).getId()); } final IdentifiantLibelleDto periodicitePaiementCritere = new IdentifiantLibelleDto(null, contratRecent.getInfosPaiementCotisation().getFrequencePaiement().getLibelle()); final List<PeriodicitePaiement> listPeriodicitePaiement = periodicitePaiementDao .rechercherPeriodicitesPaiementParCriteres(periodicitePaiementCritere); if (listPeriodicitePaiement != null && listPeriodicitePaiement.size() != 0) { infosPaiement.setIdPeriodicitePaiement(listPeriodicitePaiement.get(0).getId()); } final IdentifiantLibelleDto jourPaiementCritere = new IdentifiantLibelleDto(null, contratRecent.getInfosPaiementCotisation().getJourPaiement().toString()); final List<JourPaiement> listJourPaiement = jourPaiementDao .rechercherJoursPaiementParCriteres(jourPaiementCritere); if (listJourPaiement != null && listJourPaiement.size() != 0) { infosPaiement.setIdJourPaiement(listJourPaiement.get(0).getId()); } // rcupration des informations du RIB if (adhesion.getInfosRib() == null && contratRecent.getInfoBanqueCotisation() != null) { infosRib = mapperDozerBean.map(contratRecent.getInfoBanqueCotisation(), InfosRibDto.class); } } else { if (contratRecent.getInfosPaiementPrestation() != null && idMoyenPaiementVirement.equals( contratRecent.getInfosPaiementPrestation().getMoyenPaiement().getIdentifiant())) { // On convertit les infos de paiement ct contrat en infos de paiement ct tarificateur infosPaiement.setIdMoyenPaiement(idMoyenPaiementPrelevement); // si il n'existe pas de frequence de paiement prestation on en cre une par dfaut Long idFrequencePaiementPrestation = idFrequencePaiementDefault; if (contratRecent.getInfosPaiementPrestation().getFrequencePaiement() != null) { idFrequencePaiementPrestation = contratRecent.getInfosPaiementPrestation() .getFrequencePaiement().getIdentifiant(); } infosPaiement.setIdPeriodicitePaiement(idFrequencePaiementPrestation); // si il n'existe pas de jour de paiement prestation on en cre un par dfaut String jourPaiementPrestation = "" + jourPaiementDefault; if (contratRecent.getInfosPaiementPrestation().getJourPaiement() != null) { jourPaiementPrestation = "" + contratRecent.getInfosPaiementPrestation().getJourPaiement(); } final IdentifiantLibelleDto jourPaiementCritere = new IdentifiantLibelleDto(null, jourPaiementPrestation); final List<JourPaiement> listJourPaiement = jourPaiementDao .rechercherJoursPaiementParCriteres(jourPaiementCritere); if (listJourPaiement != null && listJourPaiement.size() != 0) { infosPaiement.setIdJourPaiement(listJourPaiement.get(0).getId()); } // rcupration des informations du RIB if (adhesion.getInfosRib() == null && contratRecent.getInfoBanquePrestation() != null) { infosRib = mapperDozerBean.map(contratRecent.getInfoBanquePrestation(), InfosRibDto.class); } } } } } } infosAdhesion.setInfosPaiement(infosPaiement); infosAdhesion.setInfosRib(infosRib); infosAdhesion.setTeletransmission(adhesion.getTeletransmission()); infosAdhesion.setAncienneComplemetaireAdherent(adhesion.getAncienneComplemetaireAdherent()); infosAdhesion.setAncienneComplemetaireConjoint(adhesion.getAncienneComplemetaireConjoint()); infosAdhesion.setDateFinContratAdherent(adhesion.getDateFinContratAdherent()); infosAdhesion.setDateFinContratConjoint(adhesion.getDateFinContratConjoint()); return infosAdhesion; }
From source file:com.mobileman.projecth.web.controller.PublicController.java
@Transactional @RequestMapping(method = RequestMethod.POST, value = "/behandlung/signup") public String signup(HttpServletRequest request, HttpServletResponse response, Model model) { ViewState.copyViewState(request, model); KeepScroll.save(request, model);// w w w. j a va 2 s. c o m String result = "behandlung/mitmachen"; boolean error = false; boolean passworderror = false; String login = request.getParameter("login"); String password = request.getParameter("password"); String password2 = request.getParameter("password2"); String nameOfInstitution = request.getParameter("nameofinstitution"); String title = request.getParameter("title"); String namename = request.getParameter("namename"); String surname = request.getParameter("surname"); String address = request.getParameter("address"); String nr = request.getParameter("nr"); String postcode = request.getParameter("postcode"); String place = request.getParameter("place"); String country = request.getParameter("country"); String telefonCountryCode = request.getParameter("telefoncountrycode"); String telefon = request.getParameter("telefonnumber"); String faxCountryCode = request.getParameter("faxcountrycode"); String fax = request.getParameter("faxnumber"); String homepage = request.getParameter("homepage"); String email = request.getParameter("email"); String accepted = request.getParameter("accepted"); String type = request.getParameter("usertype"); String strDisease = request.getParameter("disease"); Long diseaseId = NumUtils.convert2long(strDisease); model.addAttribute("val_nameofinstitution", nameOfInstitution); model.addAttribute("val_title", title); model.addAttribute("val_namename", namename); model.addAttribute("val_surname", surname); model.addAttribute("val_address", address); model.addAttribute("val_nr", nr); model.addAttribute("val_postcode", postcode); model.addAttribute("val_place", place); model.addAttribute("val_country", country); model.addAttribute("val_telefonnumber", telefon); model.addAttribute("val_homepage", homepage); model.addAttribute("val_disease_id", strDisease); model.addAttribute("val_telefoncountrycode", telefonCountryCode); model.addAttribute("val_faxcountrycode", faxCountryCode); if (StringUtils.isBlank(nameOfInstitution)) { nameOfInstitution = null; } if (StringUtils.isBlank(title)) { title = null; } if (StringUtils.isBlank(namename)) { namename = null; } if (StringUtils.isBlank(surname)) { surname = null; } if (StringUtils.isBlank(address)) { address = null; } if (StringUtils.isBlank(nr)) { nr = null; } if (StringUtils.isBlank(postcode)) { postcode = null; } if (StringUtils.isBlank(place)) { place = null; } if (StringUtils.isBlank(country)) { country = null; } if (StringUtils.isBlank(telefonCountryCode)) { telefonCountryCode = null; } if (StringUtils.isBlank(telefon)) { telefon = null; } if (StringUtils.isBlank(faxCountryCode)) { faxCountryCode = null; } if (StringUtils.isBlank(fax)) { fax = null; } if (StringUtils.isBlank(homepage)) { homepage = null; } if (StringUtils.isBlank(accepted)) { model.addAttribute("erroraccepted", true); error = true; } // send activation if (StringUtils.isBlank(login)) { model.addAttribute("errorlogin", true); error = true; } if (StringUtils.isBlank(password)) { model.addAttribute("errorpassword", true); error = true; passworderror = true; } if (StringUtils.isBlank(email)) { model.addAttribute("erroremail", true); error = true; } if (type.equals("D")) { error = checkDoctorMandatoryFileds(request, model); } if (StringUtils.isBlank(type)) { model.addAttribute("errortype", true); error = true; } else { if (type.equals("D")) { result = "behandlung/mitmachen_arzt"; } else { result = "behandlung/mitmachen_chronisch_betroffener"; } } if (diseaseId == null || diseaseId.equals(0L)) { model.addAttribute("errordisease", true); error = true; } if (!CaptchaUtil.verify(request, model)) { error = true; } if (!passworderror) { if (!password.equals(password2)) { model.addAttribute("errorpasssame", true); error = true; } } UserType utype = request.getParameter("usertype").equals("D") ? UserType.D : UserType.P; if (!error) { do { // check login try { User user = userService.findUserByLogin(login); if (user != null) { model.addAttribute("errorloginexists", true); break; } } catch (Exception ex) { } // check email try { User user = userService.findUserByEmail(email); if (user != null) { model.addAttribute("erroremailexists", true); break; } } catch (Exception ex) { } try { diseaseService.findById(diseaseId); List<Disease> diseases = Arrays.asList(diseaseService.findById(diseaseId)); if (utype.equals(UserType.D)) { Doctor doctor = new Doctor(); Name name = new Name(namename, surname); doctor.setName(name); MedicalInstitution medicalInstitution = new MedicalInstitution(); medicalInstitution.setName(nameOfInstitution); Address add = new Address(); add.setAddress(address); add.setNumber(nr); add.setPlace(place); PostalCode postalCode = new PostalCode(); postalCode.setCode(postcode); add.setPostalCode(postalCode); medicalInstitution.setAddress(add); Country countr = countryService.findByCode(country); medicalInstitution.setCountry(countr); PhoneNumber phoneNumber = new PhoneNumber(); phoneNumber.setCountryCode(telefonCountryCode); phoneNumber.setNumber(telefon); PhoneNumber faxNumber = new PhoneNumber(); faxNumber.setCountryCode(faxCountryCode); faxNumber.setNumber(fax); medicalInstitution.setPhoneNumber(phoneNumber); medicalInstitution.setFaxNumber(faxNumber); medicalInstitution.setHomePageUrl(homepage); doctor.setMedicalInstitution(medicalInstitution); doctor.setTitle(title); userService.register(doctor, login, password, email, diseases, request.getServerName()); } else if (utype.equals(UserType.P)) { Patient patient = new Patient(); patient.setName(new Name(login, null)); userService.register(patient, login, password, email, diseases, request.getServerName()); } model.addAttribute("info", true); result = "behandlung/anmeldung_erfolg"; } catch (Exception ex) { if (LoginException.class.isInstance(ex)) { fillLoginError(model, LoginException.class.cast(ex)); } else { model.addAttribute("error", "System error"); } ex.printStackTrace(); TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); } } while (false); } prepareSignUpModel(model, utype); return result; }
From source file:com.flexive.core.storage.genericSQL.GenericHierarchicalStorage.java
/** * {@inheritDoc}// w ww .ja va 2 s .c o m */ @Override public void convertContentType(Connection con, FxPK pk, long sourceTypeId, long destinationTypeId, boolean allVersions, Map<Long, Long> assignmentMap, List<Long> flatStoreAssignments, List<Long> nonFlatSourceAssignments, List<Long> nonFlatDestinationAssignments, Map<Long, String> sourcePathsMap, Map<Long, String> destPathsMap, Map<Long, String> sourceRemoveMap, FxEnvironment env) throws SQLException, FxApplicationException { PreparedStatement ps = null, ps_group = null; final long pkId = pk.getId(); final Integer[] versions; // check if all versions should be converted or the current one only if (allVersions) { final FxContentVersionInfo versionInfo = getContentVersionInfo(con, pkId); versions = versionInfo.getVersions(); } else { versions = new Integer[] { pk.getVersion() }; } // cache the content versions final List<FxContent> contentVersions = new ArrayList<FxContent>(versions.length); for (int v : versions) { contentVersions.add(contentLoad(con, new FxPK(pkId, v), env, new StringBuilder(2000))); } long userId = FxContext.getUserTicket().getUserId(); FxFlatStorage flatStorage = FxFlatStorageManager.getInstance(); boolean flatRewrite = false; // lossy conversion source remove map if (sourceRemoveMap.size() > 0) { final Set<Long> removeSet = sourceRemoveMap.keySet(); for (Long removeId : removeSet) { for (FxContent content : contentVersions) { List<FxData> data = content.getData(sourceRemoveMap.get(removeId)); FulltextIndexer ft = getFulltextIndexer(pk, con); ft.remove(removeId); for (FxData d : data) { deleteDetailData(con, new StringBuilder(2000), content.getPk(), d); } } } // if no flatstorage assignments remain, delete all orphaned flat entries final List<Long> compareRemoveList = new ArrayList<Long>(removeSet.size()); for (Long flatStoreId : flatStoreAssignments) { for (Long removeId : removeSet) { if (assignmentMap.containsKey(removeId)) { final Long mappedItem = assignmentMap.get(removeId); if (mappedItem == null || (mappedItem != null && mappedItem.equals(flatStoreId))) compareRemoveList.add(flatStoreId); } } } Collections.sort(flatStoreAssignments); Collections.sort(compareRemoveList); // compare compareRemoveList & flatStoreAssignments, if no differences found, remove all source flat store content final FxDiff diff = new FxDiff(compareRemoveList, flatStoreAssignments); if (diff.diff().size() == 0) { flatStorage.removeContent(con, sourceTypeId, pkId); } } /** * use cases: * 1. hierarchical --> flat conversion * 2. flat --> hierrarchical conversion * 3. hierarchical --> hierarchical conversion * 4. flat --> flat conversion */ try { for (Long sourceId : assignmentMap.keySet()) { // do not convert any removed source content assignments if (sourceRemoveMap.containsKey(sourceId)) continue; final String sourceXPath = sourcePathsMap.get(sourceId); final Long destinationId = assignmentMap.get(sourceId); final String destXPath = destPathsMap.get(destinationId); for (FxContent content : contentVersions) { if (destinationId == null) { // delete from the source if (nonFlatSourceAssignments.contains(sourceId) && content.getValue(destXPath) != null) { // source is hierarchical final List<FxData> data = content.getData(destXPath); for (FxData d : data) { deleteDetailData(con, new StringBuilder(2000), content.getPk(), d); } } continue; // goto next source id } // move on if no value was set if (content.getValue(sourceXPath) == null) continue; final FxPropertyData propData = content.getPropertyData(destXPath); final List<FxData> data = content.getData(destXPath); // use case 1: hierarchical --> flat if (nonFlatSourceAssignments.contains(sourceId) && flatStoreAssignments.contains(destinationId)) { for (FxData d : data) { deleteDetailData(con, new StringBuilder(2000), content.getPk(), d); } flatRewrite = true; } // use case 2: flat --> hierarchical if (!nonFlatSourceAssignments.contains(sourceId) && nonFlatDestinationAssignments.contains(destinationId)) { ps = con.prepareStatement(CONTENT_DATA_INSERT); // data for the current xpath createDetailEntries(con, ps, null, new StringBuilder(2000), content.getPk(), content.isMaxVersion(), content.isLiveVersion(), data, true); ps.executeBatch(); ps.close(); // remove the old entry from the flatstorage flatStorage.deletePropertyData(con, content.getPk(), propData); flatRewrite = true; } } } if (flatRewrite || flatStoreAssignments.size() > 0) { // re-create (remove old entries first) all flat storage entries with correct column settings flatStorage.removeContent(con, sourceTypeId, pkId); for (FxContent content : contentVersions) { List<FxPropertyData> data = new ArrayList<FxPropertyData>(5); for (Long id : flatStoreAssignments) { final String destXPath = destPathsMap.get(id); if (content.getValue(destXPath) != null) data.add(content.getPropertyData(destXPath)); } if (data.size() > 0) { flatStorage.setConvertedPropertyData(con, content.getPk(), sourceTypeId, destinationTypeId, content.getStepId(), content.isMaxVersion(), content.isLiveVersion(), data); } } } // update tables w/ new assignment ids (valid for all use cases) if (allVersions) { ps = con.prepareStatement(CONTENT_CONVERT_ALL_VERSIONS_UPDATE); ps.setLong(1, destinationTypeId); ps.setLong(2, userId); ps.setLong(3, System.currentTimeMillis()); ps.setLong(4, pkId); ps.executeUpdate(); ps.close(); ps = con.prepareStatement(CONTENT_DATA_CONVERT_ALL_VERSIONS_UPDATE); // perform one update per assignmentMap entry for (Long sourceId : assignmentMap.keySet()) { final Long destId = assignmentMap.get(sourceId); if (destId != null) { ps.setLong(1, destId); ps.setLong(2, pkId); ps.setLong(3, sourceId); ps.executeUpdate(); } } ps.close(); ps = con.prepareStatement(CONTENT_DATA_FT_CONVERT_ALL_VERSIONS_UPDATE); // perform one update per assignmentMap entry for (Long sourceId : assignmentMap.keySet()) { final Long destId = assignmentMap.get(sourceId); if (destId != null) { ps.setLong(1, destId); ps.setLong(2, pkId); ps.setLong(3, sourceId); ps.executeUpdate(); } } ps.close(); } else { // convert single version ps = con.prepareStatement(CONTENT_CONVERT_SINGLE_VERSION_UPDATE); ps.setLong(1, destinationTypeId); ps.setLong(2, userId); ps.setLong(3, System.currentTimeMillis()); ps.setLong(4, pkId); ps.setInt(5, pk.getVersion()); ps.executeUpdate(); ps.close(); ps = con.prepareStatement(CONTENT_DATA_CONVERT_SINGLE_VERSION_UPDATE); // perform one update per assignmentMap entry for (Long sourceId : assignmentMap.keySet()) { final Long destId = assignmentMap.get(sourceId); if (destId != null) { ps.setLong(1, destId); ps.setLong(2, pkId); ps.setLong(3, sourceId); ps.setInt(4, pk.getVersion()); ps.executeUpdate(); } } ps.close(); ps = con.prepareStatement(CONTENT_DATA_FT_CONVERT_SINGLE_VERSION_UPDATE); // perform one update per assignmentMap entry for (Long sourceId : assignmentMap.keySet()) { final Long destId = assignmentMap.get(sourceId); if (destId != null) { ps.setLong(1, destId); ps.setLong(2, pkId); ps.setLong(3, sourceId); ps.setInt(4, pk.getVersion()); ps.executeUpdate(); } } ps.close(); } } catch (SQLException e) { throw new FxUpdateException(LOG, e, "ex.db.sqlError", e.getMessage()); } finally { Database.closeObjects(GenericHierarchicalStorage.class, ps); } }
From source file:de.innovationgate.webgate.api.jdbc.WGDatabaseImpl.java
private TableGenerator getTableGenerator(String seqName, Long startValue) throws InstantiationException, IllegalAccessException { TableGenerator tg = _generatorCache.get(seqName); if (tg != null && (startValue == null || startValue.equals(tg.getInitialValue()))) { return tg; }/*from www . j ava 2s.c o m*/ Properties props = new Properties(); props.put(TableGenerator.TABLE_PARAM, "cs_sequences"); props.put(TableGenerator.SEGMENT_COLUMN_PARAM, "name"); props.put(TableGenerator.SEGMENT_VALUE_PARAM, seqName); props.put(TableGenerator.VALUE_COLUMN_PARAM, "value"); props.put(TableGenerator.OPT_PARAM, "none"); props.put(TableGenerator.IDENTIFIER_NORMALIZER, _conf.createMappings().getObjectNameNormalizer()); if (startValue != null) { props.put(TableGenerator.INITIAL_PARAM, startValue.intValue()); } tg = TableGenerator.class.newInstance(); Dialect dialect = ((SessionFactoryImplementor) _sessionFactory).getJdbcServices().getDialect(); tg.configure(_sessionFactory.getTypeHelper().basic(Long.class), props, dialect); _generatorCache.put(seqName, tg); return tg; }
From source file:jp.primecloud.auto.service.impl.LoadBalancerServiceImpl.java
/** * {@inheritDoc}/*from ww w. j a v a 2s . c o m*/ */ @Override public void updateAwsLoadBalancer(Long loadBalancerNo, String loadBalancerName, String comment, Long componentNo, String subnetId, String securityGroupName, String availabilityZone, boolean internal) { // ? if (loadBalancerNo == null) { throw new AutoApplicationException("ECOMMON-000003", "loadBalancerNo"); } if (loadBalancerName == null || loadBalancerName.length() == 0) { throw new AutoApplicationException("ECOMMON-000003", "loadBalancerName"); } if (componentNo == null) { throw new AutoApplicationException("ECOMMON-000003", "componentNo"); } // ?? if (!Pattern.matches("^[0-9a-z]|[0-9a-z][0-9a-z-]*[0-9a-z]$", loadBalancerName)) { throw new AutoApplicationException("ECOMMON-000012", "loadBalancerName"); } // TODO: ?? // ??? LoadBalancer loadBalancer = loadBalancerDao.read(loadBalancerNo); AwsLoadBalancer awsLoadBalancer = awsLoadBalancerDao.read(loadBalancerNo); if (loadBalancer == null || awsLoadBalancer == null) { // ?????? throw new AutoApplicationException("ESERVICE-000603", loadBalancerNo); } // ??????? if (LoadBalancerStatus.fromStatus(loadBalancer.getStatus()) != LoadBalancerStatus.STOPPED) { // ?????????????????? if (!StringUtils.equals(loadBalancer.getLoadBalancerName(), loadBalancerName) || !componentNo.equals(loadBalancer.getComponentNo())) { throw new AutoApplicationException("ESERVICE-000604", loadBalancer.getLoadBalancerName()); } if (StringUtils.isEmpty(awsLoadBalancer.getSubnetId()) ? StringUtils.isNotEmpty(subnetId) : !StringUtils.equals(awsLoadBalancer.getSubnetId(), subnetId)) { throw new AutoApplicationException("ESERVICE-000604", loadBalancer.getLoadBalancerName()); } if (StringUtils.isEmpty(awsLoadBalancer.getSecurityGroups()) ? StringUtils.isNotEmpty(securityGroupName) : !StringUtils.equals(awsLoadBalancer.getSecurityGroups(), securityGroupName)) { throw new AutoApplicationException("ESERVICE-000604", loadBalancer.getLoadBalancerName()); } } // ????? if (!StringUtils.equals(loadBalancer.getLoadBalancerName(), loadBalancerName)) { // ?????? LoadBalancer checkLoadBalancer = loadBalancerDao .readByFarmNoAndLoadBalancerName(loadBalancer.getFarmNo(), loadBalancerName); if (checkLoadBalancer != null && !loadBalancerNo.equals(checkLoadBalancer.getLoadBalancerNo())) { // ???????? throw new AutoApplicationException("ESERVICE-000601", loadBalancerName); } // ???? Instance checkInstance = instanceDao.readByFarmNoAndInstanceName(loadBalancer.getFarmNo(), loadBalancerName); if (checkInstance != null) { // ??????? throw new AutoApplicationException("ESERVICE-000626", loadBalancerName); } } // ???? long countComponent = componentDao.countByComponentNo(componentNo); if (countComponent == 0) { // ??????? throw new AutoApplicationException("ESERVICE-000607", componentNo); } // ??????????? long countListener = loadBalancerListenerDao.countByLoadBalancerNo(loadBalancerNo); if (countListener > 0) { if (!loadBalancer.getComponentNo().equals(componentNo)) { // ???????? throw new AutoApplicationException("ESERVICE-000608"); } } Farm farm = farmDao.read(loadBalancer.getFarmNo()); //? if (loadBalancer.getComponentNo().equals(componentNo) == false || (StringUtils.isNotEmpty(awsLoadBalancer.getAvailabilityZone()) && StringUtils.equals(awsLoadBalancer.getAvailabilityZone(), availabilityZone) == false)) { //?????????EnableFalse?? List<LoadBalancerInstance> loadBalancerInstances = loadBalancerInstanceDao .readByLoadBalancerNo(loadBalancerNo); for (LoadBalancerInstance loadBalancerInstance : loadBalancerInstances) { loadBalancerInstance.setEnabled(false); loadBalancerInstanceDao.update(loadBalancerInstance); } } //AWS? awsLoadBalancer.setSubnetId(subnetId); awsLoadBalancer.setSecurityGroups(securityGroupName); awsLoadBalancer.setAvailabilityZone(availabilityZone); awsLoadBalancer.setInternal(internal); awsLoadBalancerDao.update(awsLoadBalancer); // ?? loadBalancer.setLoadBalancerName(loadBalancerName); loadBalancer.setComment(comment); loadBalancer.setFqdn(loadBalancerName + "." + farm.getDomainName()); loadBalancer.setComponentNo(componentNo); loadBalancerDao.update(loadBalancer); // eventLogger.log(EventLogLevel.INFO, farm.getFarmNo(), farm.getFarmName(), null, null, null, null, "LoadBalancerUpdate", null, null, new Object[] { loadBalancerName }); }
From source file:com.prcsteel.platform.account.service.impl.AccountServiceImpl.java
@Override @Transactional//from w w w . ja va 2s.c om public HashMap<String, Object> insert(AccountDto record, List<MultipartFile> attachments, AccountContact contact) throws BusinessException { HashMap<String, Object> result = new HashMap<String, Object>(); Account account = record.getAccount(); String accountCode = account.getAccountCode(); if (accountCode != null && !"".equals(accountCode.replaceAll(" ", ""))) { // ?? AccountBank accountBank = accountBankDao.selectByAccountCode(StringToReplace.toReplaceAll(accountCode)); if (accountBank != null) { throw new BusinessException(Constant.EXCEPTIONCODE_BUSINESS, "??" + accountCode.substring(accountCode.length() - 4) + "???" + accountDao.selectByPrimaryKey(accountBank.getAccountId()).getName() + "??" + userDao.queryByLoginId("chenhu").getTel() + "?"); } } User user = record.getManager(); account.setManagerId(user.getId()); account.setCreatedBy(user.getLoginId()); account.setLastUpdatedBy(user.getLoginId()); account.setRegTime(new Date()); account.setCode(getCode()); if (StringUtils.isEmpty(account.getBusinessType())) { account.setBusinessType(null); } accountDao.insertSelective(account); Long accountId = account.getId(); // ??????? modify by kongbinheng 20150803 if (accountCode != null && !"".equals(accountCode.replaceAll(" ", ""))) { AccountBank accountBank = accountBankDao.selectByAccountCode(StringToReplace.toReplaceAll(accountCode)); if (accountBank == null) { accountBank = new AccountBank(); accountBank.setAccountId(accountId); // ?ID accountBank.setBankCode(StringToReplace.toReplaceAll(account.getBankCode())); // ? accountBank.setBankName(StringToReplace.toReplaceAll(account.getBankNameMain())); // accountBank.setBankNameBranch(StringToReplace.toReplaceAll(account.getBankNameBranch())); // accountBank.setBankProvinceId(account.getBankProvinceId()); accountBank.setBankCityId(account.getBankCityId()); if (account.getBankProvinceId() != null) accountBank.setBankProvinceName( provinceDao.selectByPrimaryKey(account.getBankProvinceId()).getName()); if (account.getBankCityId() != null) accountBank.setBankCityName(cityDao.selectByPrimaryKey(account.getBankCityId()).getName()); accountBank.setBankAccountCode(StringToReplace.toReplaceAll(accountCode)); // ? accountBank.setCreated(new Date()); accountBank.setCreatedBy(user.getLoginId()); accountBank.setLastUpdated(new Date()); accountBank.setLastUpdatedBy(user.getLoginId()); accountBank.setModificationNumber(0); accountBankDao.insertSelective(accountBank); } else { if (accountId.equals(accountBank.getAccountId())) { accountBank.setBankCode(StringToReplace.toReplaceAll(account.getBankCode())); // ? accountBank.setBankName(StringToReplace.toReplaceAll(account.getBankNameMain())); // accountBank.setBankNameBranch(StringToReplace.toReplaceAll(account.getBankNameBranch())); // accountBankDao.updateByPrimaryKeySelective(accountBank); } else { } } } // String basePath = rootPath + ATTACHMENTSAVEPATH + account.getCode() // + File.separator; boolean hasTaxReg = false; boolean hasInvoiceData = false; boolean hasPaymentData = false;// boolean hasOpenAccountLicense = false;//?? if (attachments != null) { for (MultipartFile file : attachments) { if ("pic_tax_reg".equals(file.getName())) { hasTaxReg = true; } else if ("pic_invoice_data".equals(file.getName())) { hasInvoiceData = true; } else if ("pic_payment_data".equals(file.getName())) { hasPaymentData = true; } else if ("pic_open_account_license".equals(file.getName())) { hasOpenAccountLicense = true; } AccountAttachment accountAttachment = new AccountAttachment(); accountAttachment.setCreatedBy(user.getLoginId()); accountAttachment.setLastUpdatedBy(user.getLoginId()); accountAttachment.setAccountId(accountId); AttachmentType type = AttachmentType.valueOf(file.getName()); accountAttachment.setType(type.getCode()); // String savePath = basePath + type.getCode() + "." // + FileUtil.getFileSuffix(file.getOriginalFilename()); // FileUtil.saveFile(file, savePath); String saveKey = ""; try { saveKey = fileService.saveFile(file.getInputStream(), ATTACHMENTSAVEPATH + account.getCode() + File.separator + type.getCode() + "." + FileUtil.getFileSuffix(file.getOriginalFilename())); } catch (IOException e) { BusinessException be = new BusinessException(Constant.EXCEPTIONCODE_SYSTEM, "?" + AttachmentType.valueOf(file.getName()) + ""); throw be; } accountAttachment.setUrl(saveKey); aamDao.insertSelective(accountAttachment); } } if (hasTaxReg || hasInvoiceData) { accountDao.updateInvoiceDataStatusByPrimaryKey(account.getId(), InvoiceDataStatus.Requested.getCode(), null, user.getLoginId());// } else { accountDao.updateInvoiceDataStatusByPrimaryKey(account.getId(), InvoiceDataStatus.Insufficient.getCode(), null, user.getLoginId());// ? } // ?? if (hasPaymentData || hasOpenAccountLicense) { accountDao.updateBankDataStatusByPrimaryKey(account.getId(), AccountBankDataStatus.Requested.getCode(), null, null, user.getLoginId()); } else { accountDao.updateBankDataStatusByPrimaryKey(account.getId(), AccountBankDataStatus.Insufficient.getCode(), null, null, user.getLoginId()); } accountDao.updateByPrimaryKeySelective(account); insertAccountContact(contact, accountId, user); result.put("success", true); result.put("data", accountId); return result; }
From source file:edu.ku.brc.specify.tasks.subpane.qb.QueryBldrPane.java
/** * @param hql// ww w .java 2 s . com * @return true if each record in the query defined by hql has * a unique key. * * NOTE: for large databases this method might take a long time. * It probably should be called from a SwingWorker. */ public static Pair<Boolean, Long> checkUniqueRecIds(final String hql, final List<Pair<String, Object>> params) { String countHql = getCountHql(hql); String distinctHql = getCountDistinctHql(hql); DataProviderSessionIFace session = DataProviderFactory.getInstance().createSession(); try { try { QueryIFace q1 = session.createQuery(countHql, false); QueryIFace q2 = session.createQuery(distinctHql, false); for (Pair<String, Object> param : params) { q1.setParameter(param.getFirst(), param.getSecond()); q2.setParameter(param.getFirst(), param.getSecond()); } Long q1Size = Long.valueOf(q1.list().get(0).toString()); Long q2Size = Long.valueOf(q2.list().get(0).toString()); return new Pair<Boolean, Long>(q1Size.equals(q2Size), q1Size); } catch (Exception ex) { UsageTracker.incrHandledUsageCount(); edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(QueryBldrPane.class, ex); } } finally { session.close(); } return new Pair<Boolean, Long>(false, 0L); }
From source file:com.youanmi.scrm.smp.facade.org.OrgInfoFacade.java
/** * //w w w.j a va 2 s . c o m * * * @param param ? */ public void orgDetailEdit(OrgDetailParam param) { Long currentTimeStamp = System.currentTimeMillis(); // Long orgId = param.getOrgId(); Long topOrgId = UserTokenThreadLocal.get().getTopOrgId(); Long orgId = UserTokenThreadLocal.get().getOrgId(); String name = param.getName(); Long provinceId = param.getProvinceId(); Long cityId = param.getCityId(); Long areaId = param.getAreaId(); String address = param.getAddress(); String businessLicense = param.getBusinessLicense(); // ? Long parentOrgId = param.getParentOrgId(); // id // 1. if (orgId == null) { throw new ViewExternalDisplayException(ResultCode.System.PARAMETER_NOT_NULL, "id"); } if (StringUtils.isBlank(name)) { throw new ViewExternalDisplayException(ResultCode.System.PARAMETER_NOT_NULL, "??"); } if (StringUtils.isBlank(businessLicense)) { throw new ViewExternalDisplayException(ResultCode.System.PARAMETER_NOT_NULL, "??"); } if (provinceId == null) { throw new ViewExternalDisplayException(ResultCode.System.PARAMETER_NOT_NULL, "?"); } if (cityId == null) { throw new ViewExternalDisplayException(ResultCode.System.PARAMETER_NOT_NULL, ""); } if (areaId == null) { throw new ViewExternalDisplayException(ResultCode.System.PARAMETER_NOT_NULL, ""); } if (StringUtils.isBlank(address)) { throw new ViewExternalDisplayException(ResultCode.System.PARAMETER_NOT_NULL, "?"); } if (parentOrgId == null) { throw new ViewExternalDisplayException(ResultCode.System.PARAMETER_NOT_NULL, ""); } // ??? if (!MatcherUtils.matcherString(businessLicense, "^[0-9a-zA-Z\\S]+$")) { throw new ViewExternalDisplayException(ResultCode.orgDetail.BUSINESS_LICENSE_ILLEGAL); } // ??50 if (address.length() > AccountTableConstants.Org.MAX_DETAIL_ADDRESS_LENGTH) { throw new ViewExternalDisplayException(ResultCode.System.PARAMETER_LENGTH_BEYOND, "?"); } // ? Byte orgChildOrgType = orgInfoService.getOrgChildOrgType(parentOrgId); if (null != orgChildOrgType && orgChildOrgType.equals(AccountTableConstants.Org.ORG_TYPE_CHAIN_DEPART)) { throw new ViewExternalDisplayException(ResultCode.Org.DIRECT_ORG_HAS_DEPART); } // ??? Long parentTopOrgId = null; OrgInfoDto parentOrgInfoDto = orgInfoService.getOrgById(parentOrgId); if (parentOrgInfoDto != null) { parentTopOrgId = parentOrgInfoDto.getTopOrgId(); } if (!topOrgId.equals(parentTopOrgId)) { throw new ViewExternalDisplayException(ResultCode.System.ILLEGALITY_REQUEST); } // ?????? boolean flag = uniqueneShopOrgName(name, orgId, topOrgId); if (!flag) { throw new ViewExternalDisplayException(ResultCode.Org.ORG_NAME_REPEAT); } //checkOrgName(orgId, name); // 2.? OrgDetailInfoDto dto = new OrgDetailInfoDto(); dto.setOrgId(orgId); dto.setProvinceId(provinceId); dto.setCityId(cityId); dto.setAreaId(areaId); dto.setAddress(address); dto.setBusinessLicense(businessLicense); String provinceName = null; GeogProvincePo provincePo = geogProvinceService.selectByPrimaryKey(provinceId.intValue()); if (provincePo != null) { provinceName = provincePo.getName(); dto.setProvinceName(provinceName); } String cityName = null; GeogCityPo cityPo = geogCityService.selectByPrimaryKey(cityId.intValue()); if (cityPo != null) { cityName = cityPo.getName(); dto.setCityName(cityName); } String areaName = null; GeogAreaPo areaPo = geogAreaService.selectByPrimaryKey(areaId.intValue()); if (areaPo != null) { areaName = areaPo.getName(); dto.setAreaName(areaName); } // ???? if (StringUtils.isBlank(provinceName) || StringUtils.isBlank(cityName) || StringUtils.isBlank(areaName)) { throw new ViewExternalDisplayException(ResultCode.System.ILLEGALITY_REQUEST); } dto.setUpdateTime(currentTimeStamp); orgDetailInfoService.updateByParam(dto); // 3.org OrgInfoDto updateOrgInfoDto = new OrgInfoDto(); updateOrgInfoDto.setId(orgId); updateOrgInfoDto.setOrgName(name); updateOrgInfoDto.setParentOrgId(parentOrgId); updateOrgInfoDto.setUpdateTime(currentTimeStamp); orgInfoService.updateByPrimaryKeySelective(updateOrgInfoDto); }