List of usage examples for java.util HashMap putAll
public void putAll(Map<? extends K, ? extends V> m)
From source file:com.almende.eve.monitor.ResultMonitorFactory.java
@Override public String store(final ResultMonitor monitor) { try {/*from w ww.j a v a2 s . c o m*/ final Map<String, ResultMonitor> monitors = myAgent.getState().get(MONITORS); final HashMap<String, ResultMonitor> newmonitors = new HashMap<String, ResultMonitor>(); if (monitors != null) { newmonitors.putAll(monitors); } newmonitors.put(monitor.getId(), monitor); if (!myAgent.getState().putIfUnchanged(MONITORS.getKey(), newmonitors, monitors)) { // recursive retry. store(monitor); } } catch (final Exception e) { LOG.log(Level.WARNING, "Couldn't find monitors:" + myAgent.getId() + "." + monitor.getId(), e); } return monitor.getId(); }
From source file:org.apache.solr.handler.dataimport.AbstractDataImportHandlerTestCase.java
/** * Runs a full-import using the given dataConfig and the provided request parameters. * * By default, debug=on, clean=true and commit=true are passed which can be overridden. * * @param dataConfig the data-config xml as a string * @param extraParams any extra request parameters needed to be passed to DataImportHandler * @throws Exception in case of any error *///from ww w .j av a2 s . c o m protected void runFullImport(String dataConfig, Map<String, String> extraParams) throws Exception { HashMap<String, String> params = new HashMap<>(); params.put("command", "full-import"); params.put("debug", "on"); params.put("dataConfig", dataConfig); params.put("clean", "true"); params.put("commit", "true"); params.putAll(extraParams); NamedList l = new NamedList(); for (Map.Entry<String, String> e : params.entrySet()) { l.add(e.getKey(), e.getValue()); } LocalSolrQueryRequest request = new LocalSolrQueryRequest(h.getCore(), l); h.query("/dataimport", request); }
From source file:org.cloudata.core.fs.PipeBasedCommitLogFileSystem.java
public void processCommitLogServerFailed(Set<String> failedHostNames, List<String> tabletNames) { HashMap<ServerSet, CommitLogFileSystemInfo> tempFsCache = new HashMap<ServerSet, CommitLogFileSystemInfo>(); tempFsCache.putAll(fsCache); for (Map.Entry<ServerSet, CommitLogFileSystemInfo> entry : tempFsCache.entrySet()) { ServerSet set = entry.getKey();/* w w w .ja va 2 s . c om*/ InetSocketAddress[] addressList = set.getAddressList(); for (InetSocketAddress eachAddress : addressList) { String hostName = eachAddress.getHostName() + ":" + eachAddress.getPort(); if (failedHostNames.contains(hostName)) { CommitLogFileSystemInfo info = entry.getValue(); info.clear(); } } } for (String tabletName : tabletNames) { staleTabletNameSet.add(tabletName); } }
From source file:org.egov.pgr.dashboard.service.DashboardService.java
public Map<String, Object> topComplaints() { DateTime currentDate = new DateTime(); List<Object> dataHolderNumber = constructListOfMonthPlaceHolder(currentDate.minusMonths(5), currentDate.plusMonths(1), "MM"); List<Object> dataHolderString = constructListOfMonthPlaceHolder(currentDate.minusMonths(5), currentDate.plusMonths(1), "MMM"); List<Object[]> topFiveCompTypeData = dashboardRepository.fetchTopComplaintsBetween( startOfGivenDate(currentDate.minusMonths(5).withDayOfMonth(1)).toDate(), endOfGivenDate(currentDate).toDate()); List<Object[]> topFiveCompTypeCurrentMonth = dashboardRepository.fetchTopComplaintsForCurrentMonthBetween( startOfGivenDate(currentDate.minusMonths(5).withDayOfMonth(1)).toDate(), endOfGivenDate(currentDate).toDate()); Map<Object, Object> constructResultPlaceholder = new LinkedHashMap<>(); Map<Object, Object> actualdata = new LinkedHashMap<>(); for (Object complaintType : topFiveCompTypeCurrentMonth) for (Object month : dataHolderNumber) constructResultPlaceholder.put(month + "-" + complaintType, BigInteger.ZERO); for (Object[] top5CompType : topFiveCompTypeData) actualdata.put(top5CompType[0] + "-" + top5CompType[2], top5CompType[1]); Map<Object, Object> newdata = new LinkedHashMap<>(); for (Object placeholderMapKey : constructResultPlaceholder.keySet()) if (actualdata.get(placeholderMapKey) == null) newdata.put(placeholderMapKey, BigInteger.ZERO); else/*from w w w . jav a 2 s . c o m*/ newdata.put(placeholderMapKey, actualdata.get(placeholderMapKey)); Map<String, Object> topFiveCompDataHolder = new LinkedHashMap<>(); List<Object> dataHolder = new LinkedList<>(); List<Object> compCount = new ArrayList<>(); Iterator<Entry<Object, Object>> entries = newdata.entrySet().iterator(); int index = 0; while (entries.hasNext()) { Map<String, Object> tmpdata = new LinkedHashMap<>(); Entry<Object, Object> entry = entries.next(); if (index < 5) { compCount.add(entry.getValue()); index++; } else if (index == 5) { compCount.add(entry.getValue()); String[] parts = entry.getKey().toString().split("-"); tmpdata.put("name", parts[1]); tmpdata.put("data", new LinkedList<Object>(compCount)); HashMap<String, Object> ctypeCountMap = new LinkedHashMap<>(); ctypeCountMap.putAll(tmpdata); dataHolder.add(ctypeCountMap); index = 0; compCount.clear(); tmpdata.clear(); } } topFiveCompDataHolder.put("year", dataHolderString); topFiveCompDataHolder.put("series", dataHolder); return topFiveCompDataHolder; }
From source file:com.cesnet.pki.DigicertConnector.java
/** * load generated data of organization ids and validation dates * //from w ww .j a va 2 s . com * @return generated data if exists. Else returns new empty HashMap */ private HashMap<Integer, CertificateData> loadGeneratedData() { HashMap<Integer, CertificateData> data = new HashMap<>(); try (ObjectInputStream ois = new ObjectInputStream(new FileInputStream("data.properties"))) { Object readMap = ois.readObject(); if (readMap != null && readMap instanceof HashMap) { data.putAll((Map<? extends Integer, ? extends CertificateData>) readMap); } System.out.println(ANSI_GREEN + "Great :) Data already exist. The size is " + data.size()); } catch (IOException | ClassNotFoundException e) { // data do not exist yet System.out.println(ANSI_RED + "Data do not exist yet..."); } return data; }
From source file:org.kuali.kpme.core.bo.dao.KPMEHrGroupKeyedBusinessObjectLookupDaoOjbImpl.java
@SuppressWarnings("rawtypes") protected Map<String, String> removeAndTransformFormProperties( Class<? extends HrBusinessObjectContract> businessObjectClass, Map formProps) { HashMap<String, String> retVal = new HashMap<String, String>(); // remove the institution and location field from the form map and add them to the return value map String institution = (String) formProps.remove(INSTITUTION_PARAM_NAME); if (institution != null) { retVal.put(INSTITUTION_PARAM_NAME, institution); }//from w w w . jav a2 s .co m String location = (String) formProps.remove(LOCATION_PARAM_NAME); if (location != null) { retVal.put(LOCATION_PARAM_NAME, location); } // call super class method retVal.putAll(super.removeAndTransformFormProperties(businessObjectClass, formProps)); return retVal; }
From source file:org.apache.struts2.convention.DefaultResultMapBuilder.java
/** * Creates the result configuration for the single result annotation. This will use all the * information from the annotation and anything that isn't specified will be fetched from the * PackageConfig defaults (if they exist). * * @param actionClass The action class the results are being built for. * @param info The result info that is used to create the ResultConfig instance. * @param packageConfig The PackageConfig to use to fetch defaults for result and parameters. * @param result (Optional) The result annotation to pull additional information from. * @return The ResultConfig or null if the Result annotation is given and the annotation is * targeted to some other action than this one. *///from w w w . j av a 2 s . c o m @SuppressWarnings(value = { "unchecked" }) protected ResultConfig createResultConfig(Class<?> actionClass, ResultInfo info, PackageConfig packageConfig, Result result) { // Look up by the type that was determined from the annotation or by the extension in the // ResultInfo class ResultTypeConfig resultTypeConfig = packageConfig.getAllResultTypeConfigs().get(info.type); if (resultTypeConfig == null) { throw new ConfigurationException("The Result type [" + info.type + "] which is" + " defined in the Result annotation on the class [" + actionClass + "] or determined" + " by the file extension or is the default result type for the PackageConfig of the" + " action, could not be found as a result-type defined for the Struts/XWork package [" + packageConfig.getName() + "]"); } // Add the default parameters for the result type config (if any) HashMap<String, String> params = new HashMap<String, String>(); if (resultTypeConfig.getParams() != null) { params.putAll(resultTypeConfig.getParams()); } // Handle the annotation if (result != null) { params.putAll(StringTools.createParameterMap(result.params())); } // Map the location to the default param for the result or a param named location if (info.location != null) { String defaultParamName = resultTypeConfig.getDefaultResultParam(); if (!params.containsKey(defaultParamName)) { params.put(defaultParamName, info.location); } } return new ResultConfig.Builder(info.name, resultTypeConfig.getClassName()).addParams(params).build(); }
From source file:contrail.stages.CompressAndCorrect.java
/** * Get the parameters used by this stage. */// w w w .ja va2 s .c o m protected Map<String, ParameterDefinition> createParameterDefinitions() { HashMap<String, ParameterDefinition> definitions = new HashMap<String, ParameterDefinition>(); // We add all the options for the stages we depend on. Stage[] substages = { new CompressChains(), new RemoveTipsAvro(), new FindBubblesAvro(), new PopBubblesAvro(), new RemoveLowCoverageAvro() }; for (Stage stage : substages) { definitions.putAll(stage.getParameterDefinitions()); } return Collections.unmodifiableMap(definitions); }
From source file:com.atolcd.alfresco.AuditFilter.java
/** * Cut and analysis the url and analysis parameters * //from w ww .j av a 2 s .c om * @param request * HttpServletRequest * @param requestURL * String * @return HashMap */ public HashMap<String, String> getAuditData(HttpServletRequest request, String userId, String requestURL) { HashMap<String, String> auditData = new HashMap<String, String>(); String[] urlTokens = requestURL.split("/"); HashMap<String, String> urlData = getUrlData(urlTokens, requestURL.indexOf("site") != -1); auditData.putAll(urlData); try { // Retrieves the id of the <<objet>> viewed from its module String obj = request.getParameter(moduleIds.get(urlData.get(KEY_MODULE))); if (obj != null) { if (auditData.get(KEY_MODULE).equals("calendar")) { auditData.put(KEY_ACTION, obj); auditData.put(KEY_OBJECT, ""); } else if (auditData.get(KEY_MODULE).equals(MOD_LINKS) && auditData.get(KEY_ACTION).equals("view")) { String auditObject = getNodeRefRemoteCall(request, userId, auditData.get(KEY_SITE), auditData.get(KEY_MODULE), obj); auditData.put(KEY_OBJECT, auditObject); auditData.put(KEY_ACTION, "single-view"); } else if (auditData.get("module").equals("search")) { if (!obj.isEmpty()) { auditData.put(KEY_ACTION, "query"); auditData.put(KEY_OBJECT, obj); } else { auditData.put(KEY_OBJECT, ""); } } else { String auditObject = getNodeRefRemoteCall(request, userId, auditData.get(KEY_SITE), auditData.get(KEY_MODULE), obj); auditData.put(KEY_OBJECT, auditObject); } } else { auditData.put(KEY_OBJECT, ""); } } catch (Exception e) { auditData.put(KEY_OBJECT, ""); } return filter(auditData); }
From source file:org.egov.pgr.service.dashboard.DashboardService.java
public Map<String, Object> topComplaints() { final DateTime currentDate = new DateTime(); final List<Object> dataHolderNumber = constructListOfMonthPlaceHolder(currentDate.minusMonths(5), currentDate.plusMonths(1), "MM"); final List<Object> dataHolderString = constructListOfMonthPlaceHolder(currentDate.minusMonths(5), currentDate.plusMonths(1), "MMM"); final List<Object[]> topFiveCompTypeData = dashboardRepository.fetchTopComplaintsBetween( startOfGivenDate(currentDate.minusMonths(5).withDayOfMonth(1)).toDate(), endOfGivenDate(currentDate).toDate()); final List<Object[]> topFiveCompTypeCurrentMonth = dashboardRepository .fetchTopComplaintsForCurrentMonthBetween( startOfGivenDate(currentDate.minusMonths(5).withDayOfMonth(1)).toDate(), endOfGivenDate(currentDate).toDate()); final Map<Object, Object> constructResultPlaceholder = new LinkedHashMap<Object, Object>(); final Map<Object, Object> actualdata = new LinkedHashMap<Object, Object>(); for (final Object complaintType : topFiveCompTypeCurrentMonth) for (final Object month : dataHolderNumber) constructResultPlaceholder.put(month + "-" + complaintType, BigInteger.ZERO); for (final Object[] top5CompType : topFiveCompTypeData) actualdata.put(top5CompType[0] + "-" + top5CompType[2], top5CompType[1]); final Map<Object, Object> newdata = new LinkedHashMap<Object, Object>(); for (final Object placeholderMapKey : constructResultPlaceholder.keySet()) if (actualdata.get(placeholderMapKey) == null) newdata.put(placeholderMapKey, BigInteger.ZERO); else//from w w w . j a v a 2 s. c o m newdata.put(placeholderMapKey, actualdata.get(placeholderMapKey)); final Map<String, Object> topFiveCompDataHolder = new LinkedHashMap<String, Object>(); final List<Object> dataHolder = new LinkedList<Object>(); final List<Object> compCount = new ArrayList<Object>(); final Iterator<Entry<Object, Object>> entries = newdata.entrySet().iterator(); int index = 0; while (entries.hasNext()) { final Map<String, Object> tmpdata = new LinkedHashMap<String, Object>(); final Entry<Object, Object> entry = entries.next(); if (index < 5) { compCount.add(entry.getValue()); index++; } else if (index == 5) { compCount.add(entry.getValue()); final String[] parts = entry.getKey().toString().split("-"); tmpdata.put("name", parts[1]); tmpdata.put("data", new LinkedList<Object>(compCount)); final HashMap<String, Object> ctypeCountMap = new LinkedHashMap<String, Object>(); ctypeCountMap.putAll(tmpdata); dataHolder.add(ctypeCountMap); index = 0; compCount.clear(); tmpdata.clear(); } } topFiveCompDataHolder.put("year", dataHolderString); topFiveCompDataHolder.put("series", dataHolder); return topFiveCompDataHolder; }