List of usage examples for java.util HashMap putAll
public void putAll(Map<? extends K, ? extends V> m)
From source file:edu.arizona.kra.kim.impl.identity.PersonServiceImpl.java
@Override public Map<String, String> convertPersonPropertiesToEntityProperties(Map<String, String> criteria) { if (LOG.isDebugEnabled()) { LOG.debug("convertPersonPropertiesToEntityProperties: " + criteria); }// w ww . j a va 2 s. co m boolean nameCriteria = false; boolean addressCriteria = false; boolean affiliationCriteria = false; boolean affiliationDefaultOnlyCriteria = false; boolean phoneCriteria = false; boolean emailCriteria = false; boolean employeeIdCriteria = false; // add base lookups for all person lookups HashMap<String, String> newCriteria = new HashMap<String, String>(); newCriteria.putAll(baseLookupCriteria); newCriteria.put("entityTypeContactInfos.entityTypeCode", personEntityTypeLookupCriteria); if (criteria != null) { for (String key : criteria.keySet()) { //check active radio button if (key.equals(KIMPropertyConstants.Person.ACTIVE)) { newCriteria.put(criteriaConversion.get(KIMPropertyConstants.Person.ACTIVE), criteria.get(KIMPropertyConstants.Person.ACTIVE)); } else { // The following if statement enables the "both" button to work correctly. if (!(criteria.containsKey(KIMPropertyConstants.Person.ACTIVE))) { newCriteria.remove(KIMPropertyConstants.Person.ACTIVE); } } // if no value was passed, skip the entry in the Map if (StringUtils.isEmpty(criteria.get(key))) { continue; } // check if the value needs to be encrypted // handle encrypted external identifiers if (key.equals(KIMPropertyConstants.Person.EXTERNAL_ID) && StringUtils.isNotBlank(criteria.get(key))) { // look for a ext ID type property if (criteria.containsKey(KIMPropertyConstants.Person.EXTERNAL_IDENTIFIER_TYPE_CODE)) { String extIdTypeCode = criteria .get(KIMPropertyConstants.Person.EXTERNAL_IDENTIFIER_TYPE_CODE); if (StringUtils.isNotBlank(extIdTypeCode)) { // if found, load that external ID Type via service EntityExternalIdentifierType extIdType = getIdentityService() .getExternalIdentifierType(extIdTypeCode); // if that type needs to be encrypted, encrypt the value in the criteria map if (extIdType != null && extIdType.isEncryptionRequired()) { try { if (CoreApiServiceLocator.getEncryptionService().isEnabled()) { criteria.put(key, CoreApiServiceLocator.getEncryptionService() .encrypt(criteria.get(key))); } } catch (GeneralSecurityException ex) { LOG.error("Unable to encrypt value for external ID search of type " + extIdTypeCode, ex); } } } } } // convert the property to the Entity data model String entityProperty = criteriaConversion.get(key); if (entityProperty != null) { newCriteria.put(entityProperty, criteria.get(key)); } else { entityProperty = key; // just pass it through if no translation present newCriteria.put(key, criteria.get(key)); } // check if additional criteria are needed based on the types of properties specified if (isNameEntityCriteria(entityProperty)) { nameCriteria = true; } if (isAffiliationEntityCriteria(entityProperty)) { affiliationCriteria = true; } if (isAddressEntityCriteria(entityProperty)) { addressCriteria = true; } if (isPhoneEntityCriteria(entityProperty)) { phoneCriteria = true; } if (isEmailEntityCriteria(entityProperty)) { emailCriteria = true; } if (isEmployeeIdEntityCriteria(entityProperty)) { employeeIdCriteria = true; } // special handling for the campus code, since that forces the query to look // at the default affiliation record only if (key.equals("campusCode")) { affiliationDefaultOnlyCriteria = true; } } if (nameCriteria) { newCriteria.put(ENTITY_NAME_PROPERTY_PREFIX + "active", "Y"); newCriteria.put(ENTITY_NAME_PROPERTY_PREFIX + "defaultValue", "Y"); //newCriteria.put(ENTITY_NAME_PROPERTY_PREFIX + "nameCode", "PRFR");//so we only display 1 result } if (addressCriteria) { newCriteria.put(ENTITY_ADDRESS_PROPERTY_PREFIX + "active", "Y"); newCriteria.put(ENTITY_ADDRESS_PROPERTY_PREFIX + "defaultValue", "Y"); } if (phoneCriteria) { newCriteria.put(ENTITY_PHONE_PROPERTY_PREFIX + "active", "Y"); newCriteria.put(ENTITY_PHONE_PROPERTY_PREFIX + "defaultValue", "Y"); } if (emailCriteria) { newCriteria.put(ENTITY_EMAIL_PROPERTY_PREFIX + "active", "Y"); newCriteria.put(ENTITY_EMAIL_PROPERTY_PREFIX + "defaultValue", "Y"); } if (employeeIdCriteria) { newCriteria.put(ENTITY_EMPLOYEE_ID_PROPERTY_PREFIX + "active", "Y"); newCriteria.put(ENTITY_EMPLOYEE_ID_PROPERTY_PREFIX + "primary", "Y"); } if (affiliationCriteria) { newCriteria.put(ENTITY_AFFILIATION_PROPERTY_PREFIX + "active", "Y"); } if (affiliationDefaultOnlyCriteria) { newCriteria.put(ENTITY_AFFILIATION_PROPERTY_PREFIX + "defaultValue", "Y"); } } if (LOG.isDebugEnabled()) { LOG.debug("Converted: " + newCriteria); } return newCriteria; }
From source file:in.sc.main.HomeController.java
@RequestMapping(value = { "category" }) public String getCategiryProduct(Model model, @RequestParam(required = false) String filterQ) { try {//www . j av a 2 s . c o m HashMap a = new HashMap(); ArrayList brandL = new ArrayList(); brandL.add("apple"); a.put(category, 137); a.put(country, 1); a.put(from, 0); a.put(featureTable, "product_feature_map"); a.put("src_id", 4); try { if (filterQ != null) { HashMap reqMap = generateRequestMap(filterQ, pHelper.getFeatureMap(a)); a.putAll(reqMap); model.addAttribute("filterQ", filterQ); } ArrayList data = (ArrayList) pHelper.getProductLists1(a); model.addAttribute("dataList", data); model.addAttribute("bMap", pHelper.selectBrand((int) a.get(category))); model.addAttribute("gFeatureMap", pHelper.getFeatureMap(a)); } catch (Exception e) { e.printStackTrace(); } // model.addAttribute("country_id", country_id); return "category_1"; } catch (Exception e) { e.printStackTrace(); throw new ResourceNotFoundException(); } }
From source file:com.surveypanel.form.Form.java
public Map<String, Object> getFieldValues() { HashMap<String, Object> map = new HashMap<String, Object>(); map.putAll(frmValues); return map;/*from w w w .j a v a 2 s .c o m*/ }
From source file:com.surveypanel.form.Form.java
/** * @return the variables/*from w ww .j a va 2 s .com*/ */ public Map<String, Object> getVariables() { HashMap<String, Object> map = new HashMap<String, Object>(); map.putAll(variables); return map; }
From source file:com.oneops.transistor.service.BomManagerImpl.java
protected void check4Secondary(CmsCI platform, List<CmsCIRelation> platformCloudRels, String nsPath) { //get manifest clouds and priority; what is intended Map<Long, Integer> intendedCloudpriority = platformCloudRels.stream().filter(cloudUtil::isCloudActive) .collect(toMap(CmsCIRelationBasic::getToCiId, this::getPriority, (i, j) -> i)); //are there any secondary clouds for deployment long numberOfSecondaryClouds = intendedCloudpriority.entrySet().stream() .filter(entry -> (entry.getValue().equals(SECONDARY_CLOUD_STATUS))).count(); if (numberOfSecondaryClouds == 0) { return;/*from w w w .j a v a2s .c o m*/ } String finalNsPath = nsPath; //what is deployed currently. String entryPoint = getEntryPoint(platform); if (entryPoint == null) { //for platforms which dont have entry points, like schema. logger.info("Skipping secondary check , as entry point is absent for this " + nsPath + " platform ciId " + platform.getCiId()); return; } Map<Long, Integer> existingCloudPriority = platformCloudRels.stream().map(CmsCIRelationBasic::getToCiId) .flatMap(cloudId -> cmProcessor .getToCIRelationsByNs(cloudId, CmsConstants.DEPLOYED_TO, null, entryPoint, finalNsPath) .stream()) .collect(toMap(CmsCIRelationBasic::getToCiId, this::getPriority, (i, j) -> { return Math.max(i, j); })); HashMap<Long, Integer> computedCloudPriority = new HashMap<>(existingCloudPriority); computedCloudPriority.putAll(intendedCloudpriority); //Now, take all offline clouds from Map<Long, Integer> offlineClouds = platformCloudRels.stream().filter(cloudUtil::isCloudOffline) .collect(toMap(CmsCIRelationBasic::getToCiId, this::getPriority, (i, j) -> i)); if (!offlineClouds.isEmpty()) { offlineClouds.forEach((k, v) -> { if (computedCloudPriority.containsKey(k)) { computedCloudPriority.remove(k); } }); } long count = computedCloudPriority.entrySet().stream() .filter(entry -> (entry.getValue().equals(CmsConstants.SECONDARY_CLOUD_STATUS))).count(); if (computedCloudPriority.size() == count) { //throw transistor exception String message = ""; String clouds = platformCloudRels.stream().filter(rel -> !cloudUtil.isCloudActive(rel)) .filter(rel -> (getPriority(rel) == PRIMARY_CLOUD_STATUS)).map(rel -> rel.getToCi().getCiName()) .collect(joining(",")); if (StringUtils.isNotEmpty(clouds)) { message = String.format( "The deployment will result in no instances in primary clouds for platform %s. Primary clouds <%s> are not in active state for this platform. ", nsPath, clouds); } else { message = String.format( "The deployment will result in no instances in primary clouds for platform %s. Please check the cloud priority of the clouds. . ", nsPath); } throw new TransistorException(TRANSISTOR_ALL_INSTANCES_SECONDARY, message); } }
From source file:com.runwaysdk.manager.general.MainWindow.java
@Override public HashMap<String, String> getExportProperties() { HashMap<String, String> properties = new HashMap<String, String>(); for (IModule module : modules) { properties.putAll(module.getExportProperties()); }/*from www. j a v a 2 s.c om*/ return properties; }
From source file:org.springframework.security.oauth.consumer.filter.OAuthConsumerContextFilter.java
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain chain) throws IOException, ServletException { HttpServletRequest request = (HttpServletRequest) servletRequest; HttpServletResponse response = (HttpServletResponse) servletResponse; OAuthSecurityContextImpl context = new OAuthSecurityContextImpl(); context.setDetails(request);//from w w w . j a va 2 s. c om Map<String, OAuthConsumerToken> rememberedTokens = getRememberMeServices().loadRememberedTokens(request, response); Map<String, OAuthConsumerToken> accessTokens = new TreeMap<String, OAuthConsumerToken>(); Map<String, OAuthConsumerToken> requestTokens = new TreeMap<String, OAuthConsumerToken>(); if (rememberedTokens != null) { for (Map.Entry<String, OAuthConsumerToken> tokenEntry : rememberedTokens.entrySet()) { OAuthConsumerToken token = tokenEntry.getValue(); if (token != null) { if (token.isAccessToken()) { accessTokens.put(tokenEntry.getKey(), token); } else { requestTokens.put(tokenEntry.getKey(), token); } } } } context.setAccessTokens(accessTokens); OAuthSecurityContextHolder.setContext(context); if (LOG.isDebugEnabled()) { LOG.debug("Storing access tokens in request attribute '" + getAccessTokensRequestAttribute() + "'."); } try { try { request.setAttribute(getAccessTokensRequestAttribute(), new ArrayList<OAuthConsumerToken>(accessTokens.values())); chain.doFilter(request, response); } catch (Exception e) { try { ProtectedResourceDetails resourceThatNeedsAuthorization = checkForResourceThatNeedsAuthorization( e); String neededResourceId = resourceThatNeedsAuthorization.getId(); while (!accessTokens.containsKey(neededResourceId)) { OAuthConsumerToken token = requestTokens.remove(neededResourceId); if (token == null) { token = getTokenServices().getToken(neededResourceId); } String verifier = request.getParameter(OAuthProviderParameter.oauth_verifier.toString()); // if the token is null OR // if there is NO access token and (we're not using 1.0a or the verifier is not null) if (token == null || (!token.isAccessToken() && (!resourceThatNeedsAuthorization.isUse10a() || verifier == null))) { //no token associated with the resource, start the oauth flow. //if there's a request token, but no verifier, we'll assume that a previous oauth request failed and we need to get a new request token. if (LOG.isDebugEnabled()) { LOG.debug("Obtaining request token for resource: " + neededResourceId); } //obtain authorization. String callbackURL = response.encodeRedirectURL(getCallbackURL(request)); token = getConsumerSupport().getUnauthorizedRequestToken(neededResourceId, callbackURL); if (LOG.isDebugEnabled()) { LOG.debug("Request token obtained for resource " + neededResourceId + ": " + token); } //okay, we've got a request token, now we need to authorize it. requestTokens.put(neededResourceId, token); getTokenServices().storeToken(neededResourceId, token); String redirect = getUserAuthorizationRedirectURL(resourceThatNeedsAuthorization, token, callbackURL); if (LOG.isDebugEnabled()) { LOG.debug("Redirecting request to " + redirect + " for user authorization of the request token for resource " + neededResourceId + "."); } request.setAttribute( "org.springframework.security.oauth.consumer.AccessTokenRequiredException", e); this.redirectStrategy.sendRedirect(request, response, redirect); return; } else if (!token.isAccessToken()) { //we have a presumably authorized request token, let's try to get an access token with it. if (LOG.isDebugEnabled()) { LOG.debug("Obtaining access token for resource: " + neededResourceId); } //authorize the request token and store it. try { token = getConsumerSupport().getAccessToken(token, verifier); } finally { getTokenServices().removeToken(neededResourceId); } if (LOG.isDebugEnabled()) { LOG.debug("Access token " + token + " obtained for resource " + neededResourceId + ". Now storing and using."); } getTokenServices().storeToken(neededResourceId, token); } accessTokens.put(neededResourceId, token); try { //try again if (!response.isCommitted()) { request.setAttribute(getAccessTokensRequestAttribute(), new ArrayList<OAuthConsumerToken>(accessTokens.values())); chain.doFilter(request, response); } else { //dang. what do we do now? throw new IllegalStateException( "Unable to reprocess filter chain with needed OAuth2 resources because the response is already committed."); } } catch (Exception e1) { resourceThatNeedsAuthorization = checkForResourceThatNeedsAuthorization(e1); neededResourceId = resourceThatNeedsAuthorization.getId(); } } } catch (OAuthRequestFailedException eo) { fail(request, response, eo); } catch (Exception ex) { Throwable[] causeChain = getThrowableAnalyzer().determineCauseChain(ex); OAuthRequestFailedException rfe = (OAuthRequestFailedException) getThrowableAnalyzer() .getFirstThrowableOfType(OAuthRequestFailedException.class, causeChain); if (rfe != null) { fail(request, response, rfe); } else { // Rethrow ServletExceptions and RuntimeExceptions as-is if (ex instanceof ServletException) { throw (ServletException) ex; } else if (ex instanceof RuntimeException) { throw (RuntimeException) ex; } // Wrap other Exceptions. These are not expected to happen throw new RuntimeException(ex); } } } } finally { OAuthSecurityContextHolder.setContext(null); HashMap<String, OAuthConsumerToken> tokensToRemember = new HashMap<String, OAuthConsumerToken>(); tokensToRemember.putAll(requestTokens); tokensToRemember.putAll(accessTokens); getRememberMeServices().rememberTokens(tokensToRemember, request, response); } }
From source file:org.openspaces.maven.plugin.CreatePUProjectMojo.java
/** * Returns an array of available project templates names. *//*from w ww .j a va 2s . co m*/ private HashMap getAvailableTemplates() throws Exception { HashMap templates = new HashMap(); Enumeration urls = Thread.currentThread().getContextClassLoader().getResources(DIR_TEMPLATES); while (urls.hasMoreElements()) { URL url = (URL) urls.nextElement(); PluginLog.getLog().debug("retrieving all templates from url: " + url); HashMap jarTemplates = getJarTemplates(getJarURLFromURL(url, "")); templates.putAll(jarTemplates); } LinkedHashMap sortedTemplates = new LinkedHashMap(); String desc = (String) templates.remove("event-processing"); if (desc != null) { sortedTemplates.put("event-processing", desc); } desc = (String) templates.remove("persistent-event-processing"); if (desc != null) { sortedTemplates.put("persistent-event-processing", desc); } sortedTemplates.putAll(templates); return sortedTemplates; }
From source file:FastHashMap.java
/** * Copy all of the mappings from the specified map to this one, replacing * any mappings with the same keys./* w w w .j a va 2 s . co m*/ * * @param in the map whose mappings are to be copied */ public void putAll(Map in) { if (fast) { synchronized (this) { HashMap temp = (HashMap) map.clone(); temp.putAll(in); map = temp; } } else { synchronized (map) { map.putAll(in); } } }
From source file:org.lemurproject.galago.contrib.learning.XFoldLearner.java
/** * learning function - returns a list of learnt parameters *//*from ww w .j a v a 2s .c o m*/ @Override public RetrievalModelInstance learn() throws Exception { if (execute) { final List<RetrievalModelInstance> learntParams = new ArrayList<>(); HashMap<String, List<EvalDoc>> allTestResMap = new HashMap<>(); // one set of results per fold. for (int foldId : foldLearners.keySet()) { RetrievalModelInstance result = foldLearners.get(foldId).learn(); Pair<Double, HashMap<String, List<EvalDoc>>> testResult = evaluateSpecificQueries(result, testQueryFolds.get(foldId)); result.setAnnotation("testScore", Double.toString(testResult.getFirst())); allTestResMap.putAll(testResult.getSecond()); double allScore = evaluateSpecificQueries(result, queryNumbers).getFirst(); result.setAnnotation("allScore", Double.toString(allScore)); this.outputPrintStream.println(result.toPrettyString()); learntParams.add(result); } // results for test folds combined QuerySetResults allTestResults = new QuerySetResults(allTestResMap); allTestResults.ensureQuerySet(queries.getQueryParameters()); if (outputFolder != null) { PrintWriter out = new PrintWriter(new File(outputFolder, name + "-test-fold-all.run"), "UTF-8"); for (String queryNumber : allTestResults.getQueryIterator()) { QueryResults results = allTestResults.get(queryNumber); results.outputTrecrun(out, "galago"); } out.close(); } double allTestScore = evalFunction.evaluate(allTestResults, qrels); outputTraceStream.println(String.format("Score on all test sets combined: %f", allTestScore)); // take an average value across fold instances Parameters settings = Parameters.create(); for (String param : this.learnableParameters.getParams()) { double setting = 0.0; for (RetrievalModelInstance foldOpt : learntParams) { setting += foldOpt.get(param); } setting /= learntParams.size(); settings.set(param, setting); } RetrievalModelInstance averageParams = new RetrievalModelInstance(this.learnableParameters, settings); double score = evaluateSpecificQueries(averageParams, queryNumbers).getFirst(); averageParams.setAnnotation("score", Double.toString(score)); averageParams.setAnnotation("name", name + "-xfold-avg"); outputPrintStream.println(averageParams.toPrettyString()); return averageParams; } else { outputPrintStream.println("NOT OPTIMIZING, returning random parameters."); return this.generateRandomInitalValues(); } }