List of usage examples for java.util LinkedHashMap containsKey
boolean containsKey(Object key);
From source file:ubic.gemma.core.datastructure.matrix.ExpressionDataMatrixColumnSort.java
/** * Organized the results by the factor values (for one factor) * * @param fv2bms master map//from www.java 2s . c om * @param bioMaterialChunk biomaterials to organize * @param factorValues factor value to consider - biomaterials will be organized in the order given * @param chunks map of factor values to chunks goes here * @param organized the results go here */ private static void organizeByFactorValues(Map<FactorValue, List<BioMaterial>> fv2bms, List<BioMaterial> bioMaterialChunk, List<FactorValue> factorValues, LinkedHashMap<FactorValue, List<BioMaterial>> chunks, List<BioMaterial> organized) { Collection<BioMaterial> seenBioMaterials = new HashSet<>(); for (FactorValue fv : factorValues) { if (!fv2bms.containsKey(fv)) { /* * This can happen if a factorvalue has been created but not yet associated with any biomaterials. This * can also be cruft. */ continue; } // all in entire experiment, so we might not want them all as we may just be processing a small chunk. List<BioMaterial> bioMsForFv = fv2bms.get(fv); for (BioMaterial bioMaterial : bioMsForFv) { if (bioMaterialChunk.contains(bioMaterial)) { if (!chunks.containsKey(fv)) { chunks.put(fv, new ArrayList<BioMaterial>()); } if (!chunks.get(fv).contains(bioMaterial)) { /* * shouldn't be twice, but ya never know. */ chunks.get(fv).add(bioMaterial); } } seenBioMaterials.add(bioMaterial); } // If we used that fv ... if (chunks.containsKey(fv)) { organized.addAll(chunks.get(fv)); // now at least this is in order of this factor } } // Leftovers contains biomaterials which have no factorvalue assigned for this factor. Collection<BioMaterial> leftovers = new HashSet<>(); for (BioMaterial bm : bioMaterialChunk) { if (!seenBioMaterials.contains(bm)) { leftovers.add(bm); } } if (leftovers.size() > 0) { organized.addAll(leftovers); chunks.put(null, new ArrayList<>(leftovers)); } }
From source file:com.chen.ex.chips.BaseRecipientAdapter.java
private static void putOneEntry(TemporaryEntry entry, boolean isAggregatedEntry, LinkedHashMap<Long, List<RecipientEntry>> entryMap, List<RecipientEntry> nonAggregatedEntries, Set<String> existingDestinations) { if (existingDestinations.contains(entry.destination)) { return;//from w w w. j a va 2 s .c o m } existingDestinations.add(entry.destination); if (!isAggregatedEntry) { nonAggregatedEntries.add(RecipientEntry.constructTopLevelEntry(entry.displayName, entry.displayNameSource, entry.destination, entry.destinationType, entry.destinationLabel, entry.contactId, entry.dataId, entry.thumbnailUriString, true)); } else if (entryMap.containsKey(entry.contactId)) { // We already have a section for the person. final List<RecipientEntry> entryList = entryMap.get(entry.contactId); entryList.add(RecipientEntry.constructSecondLevelEntry(entry.displayName, entry.displayNameSource, entry.destination, entry.destinationType, entry.destinationLabel, entry.contactId, entry.dataId, entry.thumbnailUriString, true)); } else { final List<RecipientEntry> entryList = new ArrayList<RecipientEntry>(); entryList.add(RecipientEntry.constructTopLevelEntry(entry.displayName, entry.displayNameSource, entry.destination, entry.destinationType, entry.destinationLabel, entry.contactId, entry.dataId, entry.thumbnailUriString, true)); entryMap.put(entry.contactId, entryList); } }
From source file:com.espertech.esper.filter.FilterSpecCompiler.java
private static FilterSpecParam handleProperty(FilterOperator op, ExprIdentNode identNodeLeft, ExprIdentNode identNodeRight, LinkedHashMap<String, Pair<EventType, String>> arrayEventTypes, String statementName) throws ExprValidationException { String propertyName = identNodeLeft.getResolvedPropertyName(); Class leftType = identNodeLeft.getExprEvaluator().getType(); Class rightType = identNodeRight.getExprEvaluator().getType(); SimpleNumberCoercer numberCoercer = getNumberCoercer(leftType, rightType, propertyName); boolean isMustCoerce = numberCoercer != null; Class numericCoercionType = JavaClassHelper.getBoxedType(leftType); String streamName = identNodeRight.getResolvedStreamName(); if (arrayEventTypes != null && !arrayEventTypes.isEmpty() && arrayEventTypes.containsKey(streamName)) { Pair<Integer, String> indexAndProp = getStreamIndex(identNodeRight.getResolvedPropertyName()); return new FilterSpecParamEventPropIndexed(identNodeLeft.getFilterLookupable(), op, identNodeRight.getResolvedStreamName(), indexAndProp.getFirst(), indexAndProp.getSecond(), isMustCoerce, numberCoercer, numericCoercionType, statementName); }//from www . j a va2s .c o m return new FilterSpecParamEventProp(identNodeLeft.getFilterLookupable(), op, identNodeRight.getResolvedStreamName(), identNodeRight.getResolvedPropertyName(), isMustCoerce, numberCoercer, numericCoercionType, statementName); }
From source file:com.perceptive.epm.perkolcentral.bl.EmployeeBL.java
@TriggersRemove(cacheName = { "EmployeeCache", "GroupCache", "EmployeeKeyedByGroupCache" }, when = When.AFTER_METHOD_INVOCATION, removeAll = true, keyGenerator = @KeyGenerator(name = "HashCodeCacheKeyGenerator", properties = @Property(name = "includeMethod", value = "false"))) @Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.SERIALIZABLE, rollbackFor = ExceptionWrapper.class) public void updateAllEmployee(List<EmployeeBO> employeeListFromLDAP) throws ExceptionWrapper { try {/*from w ww . j a va2 s .co m*/ String messageTemplateAdded = "<html>\n" + "<head>\n" + "</head>\n" + "\n" + "<body style=\"font:Georgia; font-size:12px;\">\n" + "<p>Dear All,</p>\n" + "<blockquote>\n" + " <p>A new user is added to the system.</p>\n" + "</blockquote>\n" + "<ul>\n" + " <li><strong><em>User Name</em></strong>: <strong>%s</strong></li>\n" + " <li><em><strong>User Short Id</strong></em>: <strong>%s</strong></li>\n" + " <li><em><strong>Employee Id</strong></em>: <strong>%s</strong></li>\n" + " <li><strong><em>User Email-Id</em></strong>:<strong> %s</strong></li>\n" + " <li><em><strong>Mobile Number</strong></em>:<strong> %s</strong></li>\n" + " <li><em><strong>Job Title</strong></em> : <strong>%s</strong></li>\n" + "</ul>\n" + "<p>Please take necessary actions.</p>\n" + "<p>Thanks,</p>\n" + "<blockquote>\n" + " <p>Perceptive Kolkata Central</p>\n" + "</blockquote>\n" + "</body>\n" + "</html>"; String messageTemplateDeleted = "<html>\n" + "<head>\n" + "</head>\n" + "\n" + "<body style=\"font:Georgia; font-size:12px;\">\n" + "<p>Dear All,</p>\n" + "<blockquote>\n" + " <p>An user is removed from the system.</p>\n" + "</blockquote>\n" + "<ul>\n" + " <li><strong><em>User Name</em></strong>: <strong>%s</strong></li>\n" + " <li><em><strong>User Short Id</strong></em>: <strong>%s</strong></li>\n" + " <li><em><strong>Employee Id</strong></em>: <strong>%s</strong></li>\n" + " <li><strong><em>User Email-Id</em></strong>:<strong> %s</strong></li>\n" + " <li><em><strong>Mobile Number</strong></em>:<strong> %s</strong></li>\n" + " <li><em><strong>Job Title</strong></em> : <strong>%s</strong></li>\n" + "</ul>\n" + "<p>Please take necessary actions.</p>\n" + "<p>Thanks,</p>\n" + "<blockquote>\n" + " <p>Perceptive Kolkata Central</p>\n" + "</blockquote>\n" + "</body>\n" + "</html>"; LinkedHashMap<Long, EmployeeBO> employeeLinkedHashMap = employeeDataAccessor.getAllEmployees(); for (EmployeeBO employeeBO : employeeListFromLDAP) { if (!employeeLinkedHashMap.containsKey(Long.valueOf(employeeBO.getEmployeeId()))) { //Add a new employee Employee employee = new Employee(); employee.setEmployeeId(Long.parseLong(employeeBO.getEmployeeId())); employee.setEmail(employeeBO.getEmail()); employee.setEmployeeName(employeeBO.getEmployeeName()); employee.setEmployeeUid(employeeBO.getEmployeeUid()); employee.setJobTitle(employeeBO.getJobTitle()); employee.setMobileNumber(employeeBO.getMobileNumber()); employee.setManager(employeeBO.getManager()); employee.setManagerEmail(employeeBO.getManagerEmail()); employee.setExtensionNum(employeeBO.getExtensionNum()); employee.setWorkspace(employeeBO.getWorkspace()); employee.setIsActive(true); employeeDataAccessor.addEmployee(employee); LoggingHelpUtil.printDebug(String.format("Adding user ----> %s with details %s %s", employeeBO.getEmployeeName(), System.getProperty("line.separator"), ReflectionToStringBuilder.toString(employeeBO))); //Send the mail HtmlEmail emailToSend = new HtmlEmail(); emailToSend.setHostName(email.getHostName()); String messageToSend = String.format(messageTemplateAdded, employeeBO.getEmployeeName(), employeeBO.getEmployeeUid(), employeeBO.getEmployeeId().toString(), employeeBO.getEmail(), employeeBO.getMobileNumber(), employeeBO.getJobTitle()); emailToSend.setHtmlMsg(messageToSend); //emailToSend.setTextMsg(StringEscapeUtils.escapeHtml(messageToSend)); emailToSend.getToAddresses().clear(); //Send mail to scrum masters and Development Managers Group Id 15 Collection<EmployeeBO> allEmployeesNeedToGetMail = CollectionUtils.union( getAllEmployeesKeyedByGroupId().get(Integer.valueOf("14")), getAllEmployeesKeyedByGroupId().get(Integer.valueOf("15"))); for (EmployeeBO item : allEmployeesNeedToGetMail) { emailToSend.addTo(item.getEmail(), item.getEmployeeName()); } emailToSend.addTo(employeeBO.getManagerEmail(), employeeBO.getManager());//Send the mail to manager //emailToSend.setFrom("PerceptiveKolkataCentral@perceptivesoftware.com", "Perceptive Kolkata Central"); emailToSend.setFrom("EnterpriseSoftwareKolkata@lexmark.com", "Enterprise Software Kolkata"); emailToSend.setSubject(String.format("New employee added : %s", employeeBO.getEmployeeName())); emailToSend.send(); //==========================Mail send ends here=========================================================================================================== //sendMailToPerceptiveOpsTeam(employeeBO);//Send mail to operations team in Shawnee } else { //Update a new employee employeeDataAccessor.updateEmployee(employeeBO); LoggingHelpUtil.printDebug(String.format("Updating user ----> %s with details %s %s", employeeBO.getEmployeeName(), System.getProperty("line.separator"), ReflectionToStringBuilder.toString(employeeBO))); } //======================================================================================================================================== } //Delete employees if any for (Object obj : employeeLinkedHashMap.values()) { final EmployeeBO emp = (EmployeeBO) obj; if (!CollectionUtils.exists(employeeListFromLDAP, new Predicate() { @Override public boolean evaluate(Object o) { return emp.getEmployeeId().trim().equalsIgnoreCase(((EmployeeBO) o).getEmployeeId().trim()); //To change body of implemented methods use File | Settings | File Templates. } })) { emp.setActive(false); //Soft delete the Employee employeeDataAccessor.updateEmployee(emp);//Rest deletion will be taken care by the Trigger AFTER_EMPLOYEE_UPDATE LoggingHelpUtil.printDebug( String.format("Deleting user ----> %s with details %s %s", emp.getEmployeeName(), System.getProperty("line.separator"), ReflectionToStringBuilder.toString(emp))); //Send the mail HtmlEmail emailToSend = new HtmlEmail(); emailToSend.setHostName(email.getHostName()); String messageToSend = String.format(messageTemplateDeleted, emp.getEmployeeName(), emp.getEmployeeUid(), emp.getEmployeeId().toString(), emp.getEmail(), emp.getMobileNumber(), emp.getJobTitle()); emailToSend.setHtmlMsg(messageToSend); //emailToSend.setTextMsg(StringEscapeUtils.escapeHtml(messageToSend)); emailToSend.getToAddresses().clear(); //Send mail to scrum masters ==Group ID 14 and Development Managers Group Id 15 Collection<EmployeeBO> allEmployeesNeedToGetMail = CollectionUtils.union( getAllEmployeesKeyedByGroupId().get(Integer.valueOf("14")), getAllEmployeesKeyedByGroupId().get(Integer.valueOf("15"))); for (EmployeeBO item : allEmployeesNeedToGetMail) { emailToSend.addTo(item.getEmail(), item.getEmployeeName()); } //emailToSend.setFrom("PerceptiveKolkataCentral@perceptivesoftware.com", "Perceptive Kolkata Central"); emailToSend.setFrom("EnterpriseSoftwareKolkata@lexmark.com", "Enterprise Software Kolkata"); emailToSend.setSubject(String.format("Employee removed : %s", emp.getEmployeeName())); emailToSend.send(); } } luceneUtil.indexUserInfo(getAllEmployees().values()); } catch (Exception ex) { throw new ExceptionWrapper(ex); } }
From source file:com.zimbra.cs.db.SQLite.java
@Override public void registerDatabaseInterest(DbConnection conn, String dbname) throws SQLException, ServiceException { LinkedHashMap<String, String> attachedDBs = getAttachedDatabases(conn); if (attachedDBs != null && attachedDBs.containsKey(dbname)) return;//ww w .java2 s .c om // if we're using more databases than we're allowed to, detach the least recently used if (attachedDBs != null && attachedDBs.size() >= MAX_ATTACHED_DATABASES) { for (Iterator<String> it = attachedDBs.keySet().iterator(); attachedDBs.size() >= MAX_ATTACHED_DATABASES && it.hasNext();) { String name = it.next(); if (!name.equals("zimbra") && detachDatabase(conn, name)) it.remove(); } } attachDatabase(conn, dbname); }
From source file:org.skb.lang.dal.DalPass3_Gen.java
public ArrayList<StringTemplate> sequenceFields(String repo, String table, List<StringTemplate> fields) { ArrayList<StringTemplate> ret = new ArrayList<StringTemplate>(); //extract keys from fields (grammar) LinkedHashMap<String, StringTemplate> ordered = new LinkedHashMap<String, StringTemplate>(); for (Iterator<StringTemplate> it = fields.iterator(); it.hasNext();) { StringTemplate st = it.next();//from w w w. ja va 2s . c o m ordered.put(st.getAttribute("ident").toString(), st); } //go through sequence and add st in correct order to return list for (int i = 0; i < this.tempSeq.size(); i++) { String field = this.tempSeq.get(i).toString(); if (ordered.containsKey(field)) ret.add(ordered.get(field)); } this.tempSeq.clear(); return ret; }
From source file:com.opengamma.component.ComponentManager.java
/** * Initializes the component definitions from the config. *///from w ww. ja v a 2s . com protected void initComponents() { for (String groupName : _configIni.getGroups()) { LinkedHashMap<String, String> groupData = _configIni.getGroup(groupName); if (groupData.containsKey("factory")) { initComponent(groupName, groupData); } } }
From source file:org.kuali.rice.kew.docsearch.DocumentSearchCustomizationMediatorImpl.java
@Override public List<RemotableAttributeError> validateLookupFieldParameters(DocumentType documentType, DocumentSearchCriteria documentSearchCriteria) { List<DocumentTypeAttributeBo> searchableAttributes = documentType.getSearchableAttributes(); LinkedHashMap<String, List<String>> applicationIdToAttributeNameMap = new LinkedHashMap<String, List<String>>(); for (DocumentTypeAttributeBo searchableAttribute : searchableAttributes) { RuleAttribute ruleAttribute = searchableAttribute.getRuleAttribute(); String attributeName = ruleAttribute.getName(); String applicationId = ruleAttribute.getApplicationId(); if (!applicationIdToAttributeNameMap.containsKey(applicationId)) { applicationIdToAttributeNameMap.put(applicationId, new ArrayList<String>()); }/* www.ja va 2s . com*/ applicationIdToAttributeNameMap.get(applicationId).add(attributeName); } List<RemotableAttributeError> errors = new ArrayList<RemotableAttributeError>(); for (String applicationId : applicationIdToAttributeNameMap.keySet()) { DocumentSearchCustomizationHandlerService documentSearchCustomizationService = loadCustomizationService( applicationId); List<String> searchableAttributeNames = applicationIdToAttributeNameMap.get(applicationId); List<RemotableAttributeError> searchErrors = documentSearchCustomizationService .validateCriteria(documentSearchCriteria, searchableAttributeNames); if (!CollectionUtils.isEmpty(searchErrors)) { errors.addAll(searchErrors); } } return errors; }
From source file:org.devgateway.ocds.web.rest.controller.CostEffectivenessVisualsController.java
@ApiOperation(value = "Aggregated version of /api/costEffectivenessTenderAmount and " + "/api/costEffectivenessAwardAmount." + "This endpoint aggregates the responses from the specified endpoints, per year. " + "Responds to the same filters.") @RequestMapping(value = "/api/costEffectivenessTenderAwardAmount", method = { RequestMethod.POST, RequestMethod.GET }, produces = "application/json") public List<DBObject> costEffectivenessTenderAwardAmount( @ModelAttribute @Valid final GroupingFilterPagingRequest filter) { Future<List<DBObject>> costEffectivenessAwardAmountFuture = controllerLookupService.asyncInvoke( new AsyncBeanParamControllerMethodCallable<List<DBObject>, GroupingFilterPagingRequest>() { @Override/*w w w. j a va 2 s .com*/ public List<DBObject> invokeControllerMethod(GroupingFilterPagingRequest filter) { return costEffectivenessAwardAmount(filter); } }, filter); Future<List<DBObject>> costEffectivenessTenderAmountFuture = controllerLookupService.asyncInvoke( new AsyncBeanParamControllerMethodCallable<List<DBObject>, GroupingFilterPagingRequest>() { @Override public List<DBObject> invokeControllerMethod(GroupingFilterPagingRequest filter) { return costEffectivenessTenderAmount(filter); } }, filter); //this is completely unnecessary since the #get methods are blocking //controllerLookupService.waitTillDone(costEffectivenessAwardAmountFuture, costEffectivenessTenderAmountFuture); LinkedHashMap<Object, DBObject> response = new LinkedHashMap<>(); try { costEffectivenessAwardAmountFuture.get() .forEach(dbobj -> response.put(getYearMonthlyKey(filter, dbobj), dbobj)); costEffectivenessTenderAmountFuture.get().forEach(dbobj -> { if (response.containsKey(getYearMonthlyKey(filter, dbobj))) { Map<?, ?> map = dbobj.toMap(); map.remove(Keys.YEAR); if (filter.getMonthly()) { map.remove(Keys.MONTH); } response.get(getYearMonthlyKey(filter, dbobj)).putAll(map); } else { response.put(getYearMonthlyKey(filter, dbobj), dbobj); } }); } catch (InterruptedException | ExecutionException e) { throw new RuntimeException(e); } Collection<DBObject> respCollection = response.values(); respCollection.forEach(dbobj -> { BigDecimal totalTenderAmount = BigDecimal.valueOf(dbobj.get(Keys.TOTAL_TENDER_AMOUNT) == null ? 0d : ((Number) dbobj.get(Keys.TOTAL_TENDER_AMOUNT)).doubleValue()); BigDecimal totalAwardAmount = BigDecimal.valueOf(dbobj.get(Keys.TOTAL_AWARD_AMOUNT) == null ? 0d : ((Number) dbobj.get(Keys.TOTAL_AWARD_AMOUNT)).doubleValue()); dbobj.put(Keys.DIFF_TENDER_AWARD_AMOUNT, totalTenderAmount.subtract(totalAwardAmount)); dbobj.put(Keys.PERCENTAGE_AWARD_AMOUNT, totalTenderAmount.compareTo(BigDecimal.ZERO) != 0 ? (totalAwardAmount.setScale(15).divide(totalTenderAmount, BigDecimal.ROUND_HALF_UP) .multiply(ONE_HUNDRED)) : BigDecimal.ZERO); dbobj.put(Keys.PERCENTAGE_DIFF_AMOUNT, totalTenderAmount.compareTo(BigDecimal.ZERO) != 0 ? (((BigDecimal) dbobj.get(Keys.DIFF_TENDER_AWARD_AMOUNT)).setScale(15) .divide(totalTenderAmount, BigDecimal.ROUND_HALF_UP).multiply(ONE_HUNDRED)) : BigDecimal.ZERO); }); return new ArrayList<>(respCollection); }
From source file:org.eclipse.php.composer.api.entities.AbstractJsonObject.java
@SuppressWarnings({ "unchecked", "rawtypes" }) protected void doParse(Object obj) { clear();//from www . j a v a 2 s . c o m if (obj instanceof LinkedHashMap) { List<String> fields = getFieldNames(this.getClass()); LinkedHashMap json = (LinkedHashMap) obj; for (Entry<String, Object> entry : ((Map<String, Object>) obj).entrySet()) { String property = entry.getKey(); if (fields.contains(property)) { parseField(json, property); } else { Object value = null; if (json.containsKey(property)) { value = json.get(property); if (value instanceof LinkedList) { value = new JsonArray(value); } else if (value instanceof LinkedHashMap) { value = new JsonObject(value); } } set(property, value); } } } }