List of usage examples for java.lang Integer equals
public boolean equals(Object obj)
From source file:edu.ku.brc.specify.tasks.subpane.wb.TemplateEditor.java
/** * Modify mappings to be more user-friendly. * Currently, just handles situation where only Taxon fields are contained in the import file - remaps Taxon and Determination * fields to Taxon Only equivalents./* w ww . java 2 s . c om*/ * Currently, very very klugey. Totally dependent on current behavior of automapper functions, and * on workbench_datamodel schema. */ protected void adjustMappings() { boolean doTaxOnlyRemap = true; boolean unMapTaxOnlys = false; boolean contaminateAgent = false; boolean agentMapped = false; boolean nonAgentMapped = false; for (Integer tblId : getTblsMapped()) { if (!(tblId.equals(DBTableIdMgr.getInstance().getByClassName(Taxon.class.getName()).getTableId()) || tblId.equals( DBTableIdMgr.getInstance().getByClassName(Determination.class.getName()).getTableId()) || tblId.equals(4000))) { doTaxOnlyRemap = false; } if (tblId.equals(4000)) { unMapTaxOnlys = true; } if (tblId.equals(Agent.getClassTableId())) { agentMapped = true; } else { nonAgentMapped = true; } } contaminateAgent = agentMapped && nonAgentMapped; if (contaminateAgent) { int agentFlds = 0; Vector<Integer> others = new Vector<Integer>(); for (int m = 0; m < mapModel.getSize(); m++) { FieldMappingPanel fmp = mapModel.getElementAt(m); if (fmp.getFieldInfo() != null) { if (fmp.getFieldInfo().getTableinfo().getTableId() == Agent.getClassTableId()) { agentFlds++; } else { others.add(fmp.getFieldInfo().getTableinfo().getTableId()); } } } if (agentFlds < others.size()) { unmapTable(Agent.getClassTableId()); } else { for (Integer tblId : others) { unmapTable(tblId); } } } if (doTaxOnlyRemap) { log.debug("remapping for taxon-only import"); TableInfo taxaOnly = null; for (int i = 0; i < tableModel.size(); i++) { TableListItemIFace item = tableModel.getElementAt(i); if (item.isExpandable() && ((TableInfo) item).getTableInfo().getTableId() == 4000) { taxaOnly = (TableInfo) item; break; } } if (taxaOnly == null) { log.warn("couldn't find taxon-only table in workbench schema"); return; } for (int m = 0; m < mapModel.getSize(); m++) { FieldMappingPanel fmp = mapModel.getElementAt(m); if (fmp.getFieldInfo() != null) { String fldName = fmp.getFieldInfo().getFieldInfo().getName(); if (fldName.endsWith("1") || fldName.endsWith("2")) { fldName = fldName.substring(0, fldName.length() - 1); } FieldInfo newInfo = null; // System.out.println("re-mapping " + fldName); for (FieldInfo fi : taxaOnly.getFieldItems()) { System.out.println(" checking " + fi.getFieldInfo().getName()); if (fi.getFieldInfo().getName().equalsIgnoreCase(fldName)) { newInfo = fi; break; } } if (newInfo == null) { log.warn("Couldn't find Taxon Only field info for " + fldName); continue; } if (fmp.getFieldInfo() != newInfo) { fmp.getFieldInfo().setInUse(false); newInfo.setInUse(true); fmp.setFieldInfo(newInfo); fmp.setIcon(DBTableIdMgr.getInstance().getByClassName(Taxon.class.getName()) .getIcon(IconManager.STD_ICON_SIZE)); } } } } else if (unMapTaxOnlys) { unmapTable(4000); } }
From source file:com.clustercontrol.jobmanagement.factory.JobSessionJobImpl.java
/** * ???//www . j a va2s . c o m * * @param sessionId ID * @param jobId ID * @param status * @param endStatus * @param result ? * @throws JobInfoNotFound */ private void setEndStatus(String sessionId, String jobunitId, String jobId, Integer status, Integer endStatus, Integer endValue, String result) throws JobInfoNotFound, InvalidRole { m_log.debug("setEndStaus() : sessionId=" + sessionId + ", jobId=" + jobId); //ID?ID??? JobSessionJobEntity sessionJob = QueryUtil.getJobSessionJobPK(sessionId, jobunitId, jobId); // ?? JobInfoEntity jobInfo = sessionJob.getJobInfoEntity(); // sessionJob.setStatus(status); // Integer preEndStatus = sessionJob.getEndStatus(); sessionJob.setEndStatus(endStatus); if (endValue != null) { sessionJob.setEndValue(endValue); } else { // if (Integer.valueOf(EndStatusConstant.TYPE_NORMAL).equals(endStatus)) { sessionJob.setEndValue(jobInfo.getNormalEndValue()); } else if (Integer.valueOf(EndStatusConstant.TYPE_WARNING).equals(endStatus)) { sessionJob.setEndValue(jobInfo.getWarnEndValue()); } else if (Integer.valueOf(EndStatusConstant.TYPE_ABNORMAL).equals(endStatus)) { sessionJob.setEndValue(jobInfo.getAbnormalEndValue()); } } // sessionJob.setEndDate(HinemosTime.currentTimeMillis()); //? sessionJob.setResult(result); //? //?????????? if (preEndStatus == null || !preEndStatus.equals(endStatus)) { new Notice().notify(sessionId, jobunitId, jobId, endStatus); } }
From source file:org.madsonic.service.SettingsService.java
/** * Returns the music folder with the given ID. * * @param id The ID./*from w ww.j a v a2 s .c om*/ * @return The music folder with the given ID, or <code>null</code> if not found. */ public MusicFolder getMusicFolderById(Integer id) { List<MusicFolder> all = getAllMusicFolders(); for (MusicFolder folder : all) { if (id.equals(folder.getId())) { return folder; } } return null; }
From source file:com.square.tarificateur.noyau.service.implementations.TarificateurEditiqueServiceImpl.java
/** * Crer le bnficiaire et le montant d'une ligne de devis. * @param ligneDevis la ligne de devis associe au bnficiaire * @param prospect le prospect (pour dfinir le prospect comme bnficiaire si le bnficiaire est null) * @return le beneficiaireMontant//from w w w.j a va 2s . c o m */ private BeneficiaireMontantBADto creerBeneficiaireMontant(LigneDevis ligneDevis, ProspectBADto prospect, Map<Integer, ProduitLieDto> mapProduitLies) { boolean afficherObligatoire = false; if (mapProduitLies != null && mapProduitLies.containsKey(ligneDevis.getEidProduit())) { afficherObligatoire = !mapProduitLies.get(ligneDevis.getEidProduit()).getOptionnel() && mapProduitLies.get(ligneDevis.getEidProduit()).getAffichageDevis(); } // Calcul du montant offert float montantOffert = 0; if (ligneDevis.getMontantTtc() != null) { montantOffert += ligneDevis.getMontantTtc(); } if (ligneDevis.getMontantRemise() != null) { montantOffert -= ligneDevis.getMontantRemise(); } // Cration des critres final Set<ValeurCritereLigneDevis> listeValeursCriteres = ligneDevis.getListeValeurCritereLigneDevis(); final List<CritereProduitBADto> listeCriteresProduits = new ArrayList<CritereProduitBADto>(); // RECHERCHE DU CRITERE AGE_MIN ET MONTANT_MIN final Integer idCritereAgeMin = tarificateurMappingService.getIdentifiantCritereAgeMin(); final Integer idCritereAgeMax = tarificateurMappingService.getIdentifiantCritereAgeMax(); final Integer idCritereMontantMin = tarificateurMappingService.getIdentifiantCritereMontant(); final Integer idCritereMontantMax = tarificateurMappingService.getIdentifiantCritereMontantDeux(); final Integer idCritereGarantieSouscrite = tarificateurMappingService .getIdentifiantCritereGarantieSouscrite(); boolean critereMontantMinPresent = false; for (ValeurCritereLigneDevis valeurCritere : listeValeursCriteres) { if (valeurCritere.getEidCritere().equals(idCritereMontantMin)) { critereMontantMinPresent = true; } } // Parcours de la liste des valeurs critres pour crer les critres de produits du devis for (ValeurCritereLigneDevis valeurCritere : listeValeursCriteres) { if (!(valeurCritere.getEidCritere().equals(idCritereAgeMin) || valeurCritere.getEidCritere().equals(idCritereAgeMax)) && !(valeurCritere.getEidCritere().equals(idCritereMontantMax) && critereMontantMinPresent)) { // Rcupration du libell du critre par le service final CritereCriteresDto critereCriteresDto = new CritereCriteresDto(); critereCriteresDto.setIdentifiantProduit(ligneDevis.getEidProduit()); critereCriteresDto.setIdentifiantCritere(valeurCritere.getEidCritere()); critereCriteresDto .setIdentifiantApplication(tarificateurMappingService.getIdentifiantApplicationGestcom()); critereCriteresDto.setChargerValeursPossibles(false); final List<CritereDto> listeCriteres = produitService .getListeCriteresParProduit(critereCriteresDto); if (listeCriteres.size() != 1) { logger.error(messageSourceUtil.get(MessageKeyUtil.LOGGER_ERROR_GENERATION_PDF_IMPOSSIBLE, new String[] { String.valueOf(valeurCritere.getEidCritere()), String.valueOf(listeCriteres.size()) })); throw new BusinessException(messageSourceUtil.get(MessageKeyUtil.GENERATION_PDF_IMPOSSIBLE)); } final Integer idCritere = listeCriteres.get(0).getIdentifiant(); // Bug 1116 : on n'affiche pas le critre garantie soucrite final Boolean afficherCritere = !idCritere.equals(idCritereGarantieSouscrite); // Cration du critre final CritereProduitBADto critereProduit = new CritereProduitBADto(idCritere, listeCriteres.get(0).getLibelle(), valeurCritere.getValeur(), valeurCritere.getAffichageValeur(), afficherCritere); // Ajout du critre la liste listeCriteresProduits.add(critereProduit); } } // On ordonne les critres final Comparator<CritereProduitBADto> comparateurCriteres = new Comparator<CritereProduitBADto>() { public int compare(CritereProduitBADto o1, CritereProduitBADto o2) { return o1.getIdCritere().compareTo(o2.getIdCritere()); } }; Collections.sort(listeCriteresProduits, comparateurCriteres); // Recherche d'un bonus co int pourcentageBonusEco = 0; final Integer idRegleReductionSelonProduit = regleMappingService.getIdRegleReductionSelonProduit(); // On teste si la ligne de devis possde la rgle "Rduction selon le produit" // Parcours des Rgles for (RegleValeur regleValeur : ligneDevis.getListeReglesValeurs()) { if (regleValeur.getIdRegle().equals(idRegleReductionSelonProduit)) { // Rcupration du pourcentage de la remise la plus forte if (Integer.parseInt(regleValeur.getValeurRegle()) > pourcentageBonusEco) { pourcentageBonusEco = Integer.parseInt(regleValeur.getValeurRegle()); } } } // L'identifiant du bnficiaire est celui du prospect si le bnficiaire est null final Long idProspect; final Long idBeneficiaire; // Prospect if (ligneDevis.getBeneficiaire() == null) { idProspect = ligneDevis.getDevis().getPersonnePrincipale().getId(); idBeneficiaire = null; } else { // Bnficiaire idProspect = null; idBeneficiaire = ligneDevis.getBeneficiaire().getId(); } // La date d'effet est celle de la ligne de devis final Calendar dateEffet = ligneDevis.getDateEffet(); // Cration du BeneficiaireMontant return new BeneficiaireMontantBADto(idProspect, idBeneficiaire, ligneDevis.getMontantTtc(), ligneDevis.getMontantRemise(), dateEffet, listeCriteresProduits, pourcentageBonusEco != 0 ? pourcentageBonusEco : null, montantOffert == 0f && ligneDevis.getMontantTtc() > 0f); }
From source file:com.jd.survey.web.settings.SurveyDefinitionController.java
/** * Lists survey definitions// w w w . j av a2s . co m * @param page * @param size * @param uiModel * @param principal * @return */ @Secured({ "ROLE_ADMIN", "ROLE_SURVEY_ADMIN" }) @RequestMapping(produces = "text/html") public String list(@RequestParam(value = "s", required = false) Integer showPublishedSurveyDeleteFailMessage, @RequestParam(value = "page", required = false) Integer page, @RequestParam(value = "size", required = false) Integer size, Principal principal, Model uiModel) { try { String login = principal.getName(); User user = userService.user_findByLogin(login); log.info(login); if (page != null || size != null) { int sizeNo = size == null ? 10 : size.intValue(); final int firstResult = page == null ? 0 : (page.intValue() - 1) * sizeNo; uiModel.addAttribute("surveyDefinitions", surveySettingsService.surveyDefinition_findAllInternal(user, firstResult, sizeNo)); float nrOfPages = (float) surveySettingsService.surveyDefinition_getCount() / sizeNo; uiModel.addAttribute("maxPages", (int) ((nrOfPages > (int) nrOfPages || nrOfPages == 0.0) ? nrOfPages + 1 : nrOfPages)); } else { uiModel.addAttribute("surveyDefinitions", surveySettingsService.surveyDefinition_findAllInternal(user)); } if (showPublishedSurveyDeleteFailMessage != null && showPublishedSurveyDeleteFailMessage.equals(1)) { uiModel.addAttribute("showPublishedSurveyDeleteFailMessage", true); } if (surveySettingsService.department_getCount() <= 0) { uiModel.addAttribute("noDepartments", true); } return "settings/surveyDefinitions/list"; } catch (Exception e) { log.error(e.getMessage(), e); throw (new RuntimeException(e)); } }
From source file:com.aurel.track.admin.customize.category.report.execute.ReportBeansToLaTeXConverter.java
/** * This method creates for a single topic (or document without sections) a * map with field names as key and values in LaTeX format. Inline items are * resolved for long text fields. Inline items are furthermore accessible * via field name "inlineItems" as a map with the item oid as a key and the * map of fields as a value./*from w w w . j av a 2 s . co m*/ * * @param reportBean * @param inlineItems * @param fields * @return */ private static HashMap<String, Object> getFieldMap(ReportBean reportBean, Map<Integer, ReportBean> inlineItems, List<TFieldBean> fields, StringBuilder inlineMacroBuffer) { Integer inlineOid; LOGGER.debug("Creating the context (field map) for report bean '" + reportBean.getWorkItemBean().getSynopsis() + "'"); HashMap<String, Object> topicFieldMap = new HashMap<String, Object>(); HashMap<Integer, Object> inlineItemMap = new HashMap<Integer, Object>(); int noOfTables = 0; int noOfFigures = 0; String TOKEN = ".X27645154678345875"; int index = 0; for (TFieldBean fieldBean : fields) { Integer fieldID = fieldBean.getObjectID(); Object value = reportBean.getShowValue(fieldID); IFieldTypeRT fieldTypeRT = FieldTypeManager.getFieldTypeRT(fieldID); if (fieldTypeRT != null) { if (fieldTypeRT.isLong()) { String s = value.toString(); s = s.trim(); Matcher matcher = inlineItemNoPattern.matcher(s); HashMap<Integer, String> inlines = new HashMap<Integer, String>(); while (matcher.find()) { LOGGER.debug("Found inline item here..."); inlineOid = Integer.valueOf(matcher.group(1)); ReportBean irb = inlineItems.get(inlineOid); if (irb != null) { // Render the inline item here HashMap<String, Object> inlineItemFieldMap = getFieldMap(irb, inlineItems, fields, inlineMacroBuffer); inlineItemFieldMap.put("serverurl", ApplicationBean.getInstance().getSiteBean().getServerURL() + ApplicationBean.getInstance().getServletContext().getContextPath()); // Render the inline item here LOGGER.debug("Rendering inline item here..."); inlines.put(index, renderInlineItem(irb, inlineItemFieldMap, inlineMacroBuffer)); s = s.replaceFirst("\\[issue [0-9]+\\/\\]", index + TOKEN); inlineItemMap.put(inlineOid, inlineItemFieldMap); } else { s = s.replaceAll("\\[issue [0-9]+\\/\\]", ""); } ++index; } value = Html2LaTeX.getLaTeX(s); String sl = value.toString(); for (Entry<Integer, String> entry : inlines.entrySet()) { sl = sl.replace(entry.getKey() + TOKEN, entry.getValue()); } if (sl.contains("\\begin{tabular")) { ++noOfTables; } if (sl.contains("\\begin{fig")) { ++noOfFigures; } value = sl; } if (fieldID.equals(SystemFields.WBS)) { // replace WBS by level String[] wbstokens = ((String) value).split("\\."); value = wbstokens.length; } topicFieldMap.put(fieldBean.getName(), value); if ("Synopsis".equals(fieldBean.getName())) { topicFieldMap.put("Title", value); } } } topicFieldMap.put("inlineItems", inlineItemMap); topicFieldMap.put("noOfFigures", String.valueOf(noOfFigures)); topicFieldMap.put("noOfTables", String.valueOf(noOfTables)); return topicFieldMap; }
From source file:com.aionemu.gameserver.services.LegionService.java
/** * @param legion/* w w w. ja v a 2 s .co m*/ */ public ArrayList<LegionMemberEx> loadLegionMemberExList(Legion legion, Integer objExcluded) { ArrayList<LegionMemberEx> legionMembers = new ArrayList<LegionMemberEx>(); for (Integer memberObjId : legion.getLegionMembers()) { LegionMemberEx legionMemberEx; if (objExcluded != null && objExcluded.equals(memberObjId)) { continue; } Player memberPlayer = world.findPlayer(memberObjId); if (memberPlayer != null) { legionMemberEx = new LegionMemberEx(memberPlayer, memberPlayer.getLegionMember(), true); } else { legionMemberEx = getLegionMemberEx(memberObjId); } legionMembers.add(legionMemberEx); } return legionMembers; }
From source file:com.aurel.track.persist.TWorkItemPeer.java
/** * The project was changed: recalculate the WBS * @param workItemBean/*w ww.j a v a 2 s . c om*/ * @param workItemBeanOriginal */ @Override public void projectChanged(TWorkItemBean workItemBean, TWorkItemBean workItemBeanOriginal) { if (workItemBeanOriginal == null) { //new item return; } Integer oldProjectID = workItemBeanOriginal.getProjectID(); Integer newProjectID = workItemBean.getProjectID(); if (oldProjectID == null || newProjectID == null) { LOGGER.warn("Old project " + oldProjectID + " new project " + newProjectID); return; } //same project -> no wbs change if (oldProjectID.equals(newProjectID)) { LOGGER.debug("No project changed "); return; } TWorkItemBean parentWorkItemBean = null; Integer parentID = workItemBean.getSuperiorworkitem(); Integer parentProjectID = null; if (parentID != null) { try { parentWorkItemBean = loadByPrimaryKey(parentID); } catch (ItemLoaderException e) { LOGGER.warn("The parent workItem " + parentID + " does not exist"); } if (parentWorkItemBean != null) { parentProjectID = parentWorkItemBean.getProjectID(); } } Integer originalWBS = workItemBean.getWBSOnLevel(); if (originalWBS == null) { //renumber if null and get the WBS number again setWbs(oldProjectID); try { //load them again this time with wbs numbers set workItemBean = loadByPrimaryKey(workItemBean.getObjectID()); originalWBS = workItemBean.getWBSOnLevel(); } catch (ItemLoaderException e) { } } //1. remove the item from the original parent's childen and shift the following items up //if the item has no parent or the item's parent project and the item's old project is the same if (parentProjectID == null || parentProjectID.equals(oldProjectID)) { //if there were no previous wbs or the project of the workItem differs form the //oldParent's project then there is no need to change anything in the old branch //String commaSeparatedSubprojects = getCommaSepararedSubprojectIDs(oldProjectID, new HashSet<Integer>()); shiftBranch(originalWBS, parentID, oldProjectID, false); } else { LOGGER.debug( "The originalSortOrder was null. There is no need to shift the children of the old parent "); } //2. add the item as last child of the new (parent project) if (parentProjectID == null || parentProjectID.equals(newProjectID)) { //if the new project differs from the workItem's parent then no change in wbs Integer newWbs = getNextWbsOnLevel(parentID, newProjectID); if (EqualUtils.notEqual(workItemBean.getWBSOnLevel(), newWbs)) { workItemBean.setWBSOnLevel(newWbs); } } Integer idNumber = calculateIDNumber(newProjectID, null); if (idNumber != null) { workItemBean.setIDNumber(idNumber); } }
From source file:edu.berkeley.compbio.phyloutils.HugenholtzTaxonomyService.java
@NotNull public synchronized Integer findTaxidByName(String name) throws NoSuchNodeException { ConcurrentHashMap<String, Integer> nameToUniqueIdMap = (ConcurrentHashMap<String, Integer>) nameToUniqueIdMapStub .get();/*from ww w. j a va2 s .co m*/ Integer result = nameToUniqueIdMap.get(name); if (result == null) { BasicRootedPhylogeny<Integer> theIntegerTree = (BasicRootedPhylogeny<Integer>) theIntegerTreeStub.get(); try { Integer id = new Integer(name); theIntegerTree.getNode(id); // throws exception if not present // intToNodeMap.containsKey(id)) result = id; } catch (NumberFormatException e) { // ok, try the next thing } catch (NoSuchNodeException e) { // ok, try the next thing } if (result == null) { if (!name.contains(";")) { try { BasicRootedPhylogeny<Integer> bTree = findSubtreeByNameRelaxed(name); result = bTree.getShallowestLeaf(); } catch (NoSuchNodeException e) { result = NO_VALID_ID; } //result = getUniqueNodeForName(name); // REVIEW for our present purposes we always want the worst-case node; but in other contexts that may be the wrong thing to do // result = getDeepestNodeForName(name); } else { result = getUniqueNodeForMultilevelName(name.split("[; ]+")); } } nameToUniqueIdMap.put(name, result); } if (result.equals(NO_VALID_ID)) { throw new NoSuchNodeException("Taxon not found: " + name); } return result; }