List of usage examples for java.util HashMap isEmpty
public boolean isEmpty()
From source file:com.ibm.bi.dml.api.DMLScript.java
/** * //from w ww . j a va 2 s . co m * @param fnameScript * @param fnameOptConfig * @param argVals */ private static void printInvocationInfo(String fnameScript, String fnameOptConfig, HashMap<String, String> argVals) { LOG.debug("****** args to DML Script ******\n" + "UUID: " + getUUID() + "\n" + "SCRIPT PATH: " + fnameScript + "\n" + "RUNTIME: " + rtplatform + "\n" + "BUILTIN CONFIG: " + DMLConfig.DEFAULT_SYSTEMML_CONFIG_FILEPATH + "\n" + "OPTIONAL CONFIG: " + fnameOptConfig + "\n"); if (!argVals.isEmpty()) { LOG.debug("Script arguments are: \n"); for (int i = 1; i <= argVals.size(); i++) LOG.debug("Script argument $" + i + " = " + argVals.get("$" + i)); } }
From source file:gridool.db.partitioning.phihash.DBPartitioningJob.java
@Override public GridTaskResultPolicy result(GridTaskResult result) throws GridException { final HashMap<GridNode, MutableLong> processed = result.getResult(); if (processed == null || processed.isEmpty()) { Exception err = result.getException(); if (err == null) { throw new GridException("failed to execute a task: " + result.getTaskId()); } else {/* ww w . j a v a 2 s. co m*/ throw new GridException("failed to execute a task: " + result.getTaskId(), err); } } if (LOG.isInfoEnabled()) { final long elapsed = System.currentTimeMillis() - started; final int numNodes = processed.size(); final long[] counts = new long[numNodes]; long maxRecords = -1L, minRecords = -1L; int i = 0; for (final MutableLong e : processed.values()) { long v = e.longValue(); numProcessed += v; counts[i++] = v; maxRecords = Math.max(v, maxRecords); minRecords = (minRecords == -1L) ? v : Math.min(v, minRecords); } double mean = numProcessed / numNodes; double sd = MathUtils.stddev(counts); double avg = numProcessed / numNodes; float percent = ((float) (sd / mean)) * 100.0f; LOG.info("Job executed in " + DateTimeFormatter.formatTime(elapsed) + ".\n\tSTDDEV of data distribution in " + numNodes + " nodes: " + sd + " (" + percent + "%)\n\tAverage records: " + PrintUtils.formatNumber(avg) + " [ total: " + numProcessed + ", max: " + maxRecords + ", min: " + minRecords + " ]"); } else { for (MutableLong e : processed.values()) { numProcessed += e.intValue(); } } return GridTaskResultPolicy.CONTINUE; }
From source file:it.unibas.spicygui.controllo.datasource.ActionAddTargetInstanceCsv.java
@Override public void performAction() { Scenario scenario = (Scenario) modello.getBean(Costanti.CURRENT_SCENARIO); MappingTask mappingTask = scenario.getMappingTask(); IDataSourceProxy dataSource = mappingTask.getTargetProxy(); LoadCsvInstancesMainFrame jd = new LoadCsvInstancesMainFrame(dataSource); InstancesTopComponent viewInstancesTopComponent = scenario.getInstancesTopComponent(); HashMap<String, String> absolutePaths = jd.getResponse(); if (!absolutePaths.isEmpty()) { if (scenario.getMappingTask().getTargetProxy().getType().equalsIgnoreCase("CSV")) { try { //pathHashMap is a multimap set with the tablename String as key //and an arraylist with two values: a)the tablename //b)a boolean value that represents if the file contains column names and //c)a boolean that contains the info if the instance file has been already loaded HashMap<String, ArrayList<Object>> pathHashMap = new HashMap<String, ArrayList<Object>>(); for (Map.Entry<String, String> entry : absolutePaths.entrySet()) { ArrayList<Object> valSet = new ArrayList<Object>(); valSet.add(entry.getValue()); valSet.add(jd.getColNames()); valSet.add(false);//w w w .j a v a 2s.co m pathHashMap.put(entry.getKey(), valSet); } DAOCsv daoCsv = new DAOCsv(); daoCsv.addInstances(dataSource, pathHashMap); if (!viewInstancesTopComponent.isRipulito()) { viewInstancesTopComponent.createTargetInstanceTree(); viewInstancesTopComponent.requestActive(); } DialogDisplayer.getDefault().notify(new NotifyDescriptor.Message( NbBundle.getMessage(Costanti.class, Costanti.ADD_INSTANCE_OK))); } catch (DAOException ex) { DialogDisplayer.getDefault().notify(new NotifyDescriptor.Message( NbBundle.getMessage(Costanti.class, Costanti.OPEN_ERROR) + " : " + ex.getMessage(), DialogDescriptor.ERROR_MESSAGE)); logger.error(ex); } } else { DialogDisplayer.getDefault() .notify(new NotifyDescriptor.Message( NbBundle.getMessage(Costanti.class, Costanti.CSV_INST_NOTIF), DialogDescriptor.ERROR_MESSAGE)); } } else { DialogDisplayer.getDefault() .notify(new NotifyDescriptor.Message( NbBundle.getMessage(Costanti.class, Costanti.CSV_EMPTY_INST_NOTIF), DialogDescriptor.ERROR_MESSAGE)); } }
From source file:morphy.service.ServerListManagerService.java
private ServerListManagerService() { HashMap<ServerList, List<String>> map = loadFromDatabase(); if (map == null || map.isEmpty()) { // load defaults initialize();//from w w w . j a v a 2s .c o m } else { ServerList[] listArr = map.keySet().toArray(new ServerList[map.keySet().size()]); lists = new ArrayList<ServerList>(listArr.length); for (int i = 0; i < listArr.length; i++) { ServerList list = listArr[i]; lists.add(list); } elements = map; } if (LOG.isInfoEnabled()) { LOG.info("Initialized ServerListManagerService."); } }
From source file:it.unibas.spicygui.controllo.datasource.ActionAddSourceInstanceCsv.java
@Override public void performAction() { Scenario scenario = (Scenario) modello.getBean(Costanti.CURRENT_SCENARIO); MappingTask mappingTask = scenario.getMappingTask(); IDataSourceProxy dataSource = mappingTask.getSourceProxy(); LoadCsvInstancesMainFrame jd = new LoadCsvInstancesMainFrame(dataSource); InstancesTopComponent viewInstancesTopComponent = scenario.getInstancesTopComponent(); //jd.getResponse() returns the file path and the table name HashMap<String, String> absolutePaths = jd.getResponse(); if (!absolutePaths.isEmpty()) { if (scenario.getMappingTask().getSourceProxy().getType().equalsIgnoreCase("CSV")) { try { //pathHashMap is a multimap set with the file path String as key //and an arraylist with two values: a)the tablename //b)a boolean value that represents if the file contains column names and //c)a boolean that contains the info if the instance file has been already loaded HashMap<String, ArrayList<Object>> pathHashMap = new HashMap<String, ArrayList<Object>>(); for (Map.Entry<String, String> entry : absolutePaths.entrySet()) { ArrayList<Object> valSet = new ArrayList<Object>(); //table name valSet.add(entry.getValue()); valSet.add(jd.getColNames()); valSet.add(false);/*from ww w . j a v a 2 s .c o m*/ pathHashMap.put(entry.getKey(), valSet); } //dataSource.getInstances().clear(); //dataSource.getOriginalInstances().clear(); DAOCsv daoCsv = new DAOCsv(); daoCsv.addInstances(dataSource, pathHashMap); if (!viewInstancesTopComponent.isRipulito()) { viewInstancesTopComponent.clearSource(); viewInstancesTopComponent.createSourceInstanceTree(); viewInstancesTopComponent.requestActive(); } //StatusDisplayer.getDefault().setStatusText(NbBundle.getMessage(Costanti.class, Costanti.ADD_INSTANCE_OK)); DialogDisplayer.getDefault().notify(new NotifyDescriptor.Message( NbBundle.getMessage(Costanti.class, Costanti.ADD_INSTANCE_OK))); } catch (DAOException ex) { DialogDisplayer.getDefault().notify(new NotifyDescriptor.Message( NbBundle.getMessage(Costanti.class, Costanti.OPEN_ERROR) + " : " + ex.getMessage(), DialogDescriptor.ERROR_MESSAGE)); logger.error(ex); } } else { DialogDisplayer.getDefault() .notify(new NotifyDescriptor.Message( NbBundle.getMessage(Costanti.class, Costanti.CSV_INST_NOTIF), DialogDescriptor.ERROR_MESSAGE)); } } else { DialogDisplayer.getDefault() .notify(new NotifyDescriptor.Message( NbBundle.getMessage(Costanti.class, Costanti.CSV_EMPTY_INST_NOTIF), DialogDescriptor.ERROR_MESSAGE)); } }
From source file:edu.wustl.xipHost.caGrid.QueryNBIATest.java
/** * @throws java.lang.Exception// www . j a va 2 s. co m */ @Before public void setUp() throws Exception { HashMap<String, String> queryHashMap = new HashMap<String, String>(); if (queryHashMap.isEmpty()) { queryHashMap.put(HashmapToCQLQuery.TARGET_NAME_KEY, Series.class.getCanonicalName()); //queryHashMap.put(HashmapToCQLQuery.TARGET_NAME_KEY, Study.class.getCanonicalName()); //queryHashMap.put(HashmapToCQLQuery.TARGET_NAME_KEY, Image.class.getCanonicalName()); //queryHashMap.put(HashmapToCQLQuery.TARGET_NAME_KEY, Patient.class.getCanonicalName()); queryHashMap.put("gov.nih.nci.ncia.domain.Patient.patientId", "1.3.6.1.4.1.9328.50.1.0009"); queryHashMap.put("gov.nih.nci.ncia.domain.Study.studyInstanceUID", "1.3.6.1.4.1.9328.50.1.4717"); //queryHashMap.put("gov.nih.nci.ncia.domain.Series.instanceUID", "1.3.6.1.4.1.9328.50.1.4435"); //queryHashMap.put("gov.nih.nci.ncia.domain.Image.sopInstanceUID", "1.3.6.1.4.1.9328.50.1.4433"); queryHashMap.put("gov.nih.nci.ncia.domain.Image.acquisitionDatetime", "test"); } else { } HashmapToCQLQuery h2cql; try { h2cql = new HashmapToCQLQuery(new ModelMap(new File("./resources/modelmap/NCIAModelMap.properties"))); try { cqlQuery = h2cql.makeCQLQuery(queryHashMap); /*QueryModifier queryModifier = new QueryModifier(); //String[] attributeNames = new String[1]; //attributeNames[0] = "gov.nih.nci.ncia.domain.Image.sopInstanceUID"; //queryModifier.setAttributeNames(attributeNames); queryModifier.setCountOnly(true); cqlQuery.setQueryModifier(queryModifier); System.err.println(ObjectSerializer.toString(cqlQuery, new QName("http://CQL.caBIG/1/gov.nih.nci.cagrid.CQLQuery", "CQLQuery")));*/ } catch (MalformedQueryException e) { e.printStackTrace(); } } catch (FileNotFoundException e1) { e1.printStackTrace(); } catch (ModelMapException e1) { e1.printStackTrace(); } catch (IOException e1) { e1.printStackTrace(); } catch (ClassNotFoundException e1) { } }
From source file:fungus.FluctuationObserver.java
@SuppressWarnings("unchecked") public boolean execute() { if (CDState.getCycle() % period != 0) return false; updateStats();//from w w w . j a va 2s. c om if (fluctuations.isEmpty()) return false; StringBuilder sb = new StringBuilder(); java.util.Formatter f = new java.util.Formatter(sb, Locale.US); Integer i = 0; HashMap<Integer, Integer> map = (HashMap<Integer, Integer>) fluctuations.clone(); while (!map.isEmpty()) { Integer val = map.remove(i); if (val == null) { f.format("%1d:%1d, ", i, 0); } else { f.format("%1d:%1d, ", i, val); } i++; } // ah: remove last commaspace and add a newline sb.delete(sb.length() - 2, sb.length()); sb.append("\n"); // ah: TODO: copy experiment writer to get this writing to // a file, too, so i can make a graph out of it. try { FileOutputStream out = new FileOutputStream(filename, true); PrintStream p = new PrintStream(out); p.print(sb.toString()); out.close(); } catch (IOException e) { log.severe("Error writing fluctuation data to file"); debug(e.getMessage()); } log.info("fluctuation counts " + sb.toString()); return false; }
From source file:com.microsoft.aad.adal.IdToken.java
public IdToken(String idtoken) throws AuthenticationException { // Message segments: Header.Body.Signature final HashMap<String, String> responseItems = this.parseJWT(idtoken); if (responseItems != null && !responseItems.isEmpty()) { this.mSubject = responseItems.get(AuthenticationConstants.OAuth2.ID_TOKEN_SUBJECT); this.mTenantId = responseItems.get(AuthenticationConstants.OAuth2.ID_TOKEN_TENANTID); this.mUpn = responseItems.get(AuthenticationConstants.OAuth2.ID_TOKEN_UPN); this.mEmail = responseItems.get(AuthenticationConstants.OAuth2.ID_TOKEN_EMAIL); this.mGivenName = responseItems.get(AuthenticationConstants.OAuth2.ID_TOKEN_GIVEN_NAME); this.mFamilyName = responseItems.get(AuthenticationConstants.OAuth2.ID_TOKEN_FAMILY_NAME); this.mIdentityProvider = responseItems.get(AuthenticationConstants.OAuth2.ID_TOKEN_IDENTITY_PROVIDER); this.mObjectId = responseItems.get(AuthenticationConstants.OAuth2.ID_TOKEN_OBJECT_ID); final String expiration = responseItems .get(AuthenticationConstants.OAuth2.ID_TOKEN_PASSWORD_EXPIRATION); if (!StringExtensions.IsNullOrBlank(expiration)) { this.mPasswordExpiration = Long.parseLong(expiration); }/*from w ww . j a v a2s . com*/ this.mPasswordChangeUrl = responseItems .get(AuthenticationConstants.OAuth2.ID_TOKEN_PASSWORD_CHANGE_URL); } }
From source file:com.webbfontaine.valuewebb.timer.RatesUpdater.java
@Asynchronous @Transactional//from www. j a v a 2s . co m public QuartzTriggerHandle scheduleTask(@Expiration Date when, @IntervalCron String interval) { HashMap<String, BigDecimal> ratesFromBank = ratesFromBank(); if (ratesFromBank.isEmpty()) { LOGGER.error("No rates passed to update, check web site and source code!"); return null; } EntityManager entityManager = Utils.getEntityManager(); List<Rate> existingRates = entityManager.createQuery("from Rate r where r.eov is null").getResultList(); Transaction tx = ((org.jboss.seam.persistence.HibernateSessionProxy) entityManager.getDelegate()) .getTransaction(); try { tx.begin(); for (Rate existingRecord : existingRates) { BigDecimal latestRateForCurrency = ratesFromBank.get(existingRecord.getCod()); if (latestRateForCurrency == null) { LOGGER.warn("Currency code '{0}' exists but absent in updates", existingRecord.getCod()); continue; } if (existingRecord.getExch().doubleValue() != latestRateForCurrency.doubleValue()) { //i get double value because bigdecimal can return 0.2240 which is not equal to 0.224 when comparing BD values /* close existing rate and open new one from today */ Date tomorrowDate = Utils.getTomorrowDate(); existingRecord.setEov(tomorrowDate); // since scheduler works at 21:00 Rate newRecord = new Rate(null, existingRecord.getCod(), 1, latestRateForCurrency, tomorrowDate, null); entityManager.persist(existingRecord); entityManager.persist(newRecord); LOGGER.info("Updated Exchange rate for {0}, old: {1}, new: {2}", newRecord.getCod(), existingRecord.unitRate(), newRecord.unitRate()); } } entityManager.flush(); tx.commit(); } catch (Exception e) { LOGGER.error("Exception on updating rates", e); if (tx != null) { tx.rollback(); } } return null; }
From source file:com.datatorrent.lib.math.CountMap.java
/** * Emits on all ports that are connected. Data is precomputed during process * on input port endWindow just emits it for each key Clears the internal data * before return/*from w w w .j a v a2 s.c om*/ */ @Override public void endWindow() { HashMap<K, Integer> tuples = new HashMap<K, Integer>(); for (Map.Entry<K, MutableInt> e : counts.entrySet()) { tuples.put(e.getKey(), e.getValue().intValue()); } if (!tuples.isEmpty()) { count.emit(tuples); } clearCache(); }