List of usage examples for java.util Properties entrySet
@Override
public Set<Map.Entry<Object, Object>> entrySet()
From source file:edu.cornell.med.icb.goby.alignments.ConcatAlignmentReader.java
/** * Obtain statistics about this alignment as a Java property instance. * * @return statistics about this alignment *//*from w w w . ja v a 2 s . c o m*/ public Properties getStatistics() { int index = 1; final Properties result = new Properties(); for (final AlignmentReader reader : this.readers) { final Properties localProps = reader.getStatistics(); for (final Map.Entry<Object, Object> localProp : localProps.entrySet()) { result.put("part" + index + "." + localProp.getKey().toString(), localProp.getValue()); } index++; } return result; }
From source file:edu.cornell.med.icb.geo.GEOPlatformIndexed.java
/** * Set the current state of the object from a map of properties. * @param propertyMap A map of properties indexed by string key names that can be then * used to reconstruct the object state. *///from w ww .j a v a 2 s .c o m public void fromPropertyMap(final Map<String, Properties> propertyMap) { if (propertyMap == null) { throw new IllegalArgumentException("Property map cannot be null"); } // IndexedIdentifier probeIds2ProbeIndex final Map<String, Properties> probeIds2ProbeIndexPropertyMap = new HashMap<String, Properties>(); for (final Map.Entry<String, Properties> entry : propertyMap.entrySet()) { final String key = entry.getKey(); if (key.startsWith(PROBE_IDS2_PROBE_INDEX_KEY)) { probeIds2ProbeIndexPropertyMap.put(StringUtils.removeStart(key, PROBE_IDS2_PROBE_INDEX_KEY), entry.getValue()); } } probeIds2ProbeIndex.fromPropertyMap(probeIds2ProbeIndexPropertyMap); // IndexedIdentifier externalIds2TranscriptIndex final Map<String, Properties> externalIds2TranscriptIndexPropertyMap = new HashMap<String, Properties>(); for (final Map.Entry<String, Properties> entry : propertyMap.entrySet()) { final String key = entry.getKey(); if (key.startsWith(EXTERNAL_IDS2_TRANSCRIPT_INDEX_KEY)) { externalIds2TranscriptIndexPropertyMap .put(StringUtils.removeStart(key, EXTERNAL_IDS2_TRANSCRIPT_INDEX_KEY), entry.getValue()); } } externalIds2TranscriptIndex.fromPropertyMap(externalIds2TranscriptIndexPropertyMap); // Int2IntMap probeIndex2ExternalIDIndex probeIndex2ExternalIDIndex.clear(); // reset any previous state final Properties probeIndex2ExternalIDIndexProperties = propertyMap.get(PROBE_INDEX2_EXTERNAL_IDINDEX_KEY); if (probeIndex2ExternalIDIndexProperties != null) { for (final Map.Entry<Object, Object> entry : probeIndex2ExternalIDIndexProperties.entrySet()) { probeIndex2ExternalIDIndex.put(NumberUtils.toInt(entry.getKey().toString()), NumberUtils.toInt(entry.getValue().toString())); } } // MutableString externalIdType final Properties externalIdTypeProperties = propertyMap.get(EXTERNAL_ID_TYPE_KEY); if (externalIdTypeProperties != null) { externalIdType = new MutableString( StringUtils.defaultString(externalIdTypeProperties.getProperty(EXTERNAL_ID_TYPE_KEY))); } else { externalIdType = null; } // MutableString name final Properties nameProperties = propertyMap.get(NAME_KEY); if (nameProperties != null) { name = new MutableString(StringUtils.defaultString(nameProperties.getProperty(NAME_KEY))); } else { name = null; } // Int2ObjectMap<MutableString> externalIndex2Id externalIndex2Id.clear(); // reset any previous state final Properties externalIndex2IdProperties = propertyMap.get(EXTERNAL_INDEX2_ID_KEY); if (externalIndex2IdProperties != null) { for (final Map.Entry<Object, Object> entry : externalIndex2IdProperties.entrySet()) { externalIndex2Id.put(NumberUtils.toInt(entry.getKey().toString()), new MutableString(entry.getValue().toString())); } } // Int2ObjectMap<MutableString> probeIndex2probeId probeIndex2probeId.clear(); // reset any previous state final Properties probeIndex2probeIdProperties = propertyMap.get(PROBE_INDEX2PROBE_ID_KEY); if (probeIndex2probeIdProperties != null) { for (final Map.Entry<Object, Object> entry : probeIndex2probeIdProperties.entrySet()) { probeIndex2probeId.put(NumberUtils.toInt(entry.getKey().toString()), new MutableString(entry.getValue().toString())); } } }
From source file:org.fosstrak.ale.server.persistence.impl.ReadConfigImpl.java
/** * subscribe the subscribers on the ec spec. * @param properties the properties holding the subscribers urls. the hash key of the input encodes the ec spec where to subscribe to. *//* ww w. j a v a 2s.c o m*/ private void subscribeSubscribers(Map<String, Properties> properties) { for (Map.Entry<String, Properties> entry : properties.entrySet()) { try { final String specName = entry.getKey(); final Properties props = entry.getValue(); LOG.debug("try to define subscribers for specName " + specName); for (Map.Entry<Object, Object> propsEntries : props.entrySet()) { try { final String notificationURI = (String) propsEntries.getValue(); LOG.debug("defining notification URI: " + notificationURI); ale.subscribe(specName, notificationURI); } catch (InvalidURIException e) { LOG.error("Illegal Notification URI", e); } catch (DuplicateSubscriptionException e) { LOG.error("Notification URI is already defined.", e); } } } catch (NoSuchNameException e) { LOG.error("ECSpec does not exist", e); } } }
From source file:org.apache.ddlutils.TestAgainstLiveDatabaseBase.java
/** * Initializes the test datasource and the platform. * /*from w w w . j a v a 2s . c o m*/ * @param props The properties to initialize from * @return The data source object */ private static DataSource initDataSourceFromProperties(Properties props) { if (props == null) { return null; } try { String dataSourceClass = props.getProperty(DATASOURCE_PROPERTY_PREFIX + "class", BasicDataSource.class.getName()); DataSource dataSource = (DataSource) Class.forName(dataSourceClass).newInstance(); for (Iterator it = props.entrySet().iterator(); it.hasNext();) { Map.Entry entry = (Map.Entry) it.next(); String propName = (String) entry.getKey(); if (propName.startsWith(DATASOURCE_PROPERTY_PREFIX) && !propName.equals(DATASOURCE_PROPERTY_PREFIX + "class")) { BeanUtils.setProperty(dataSource, propName.substring(DATASOURCE_PROPERTY_PREFIX.length()), entry.getValue()); } } return dataSource; } catch (Exception ex) { throw new DatabaseOperationException(ex); } }
From source file:com.liferay.portal.security.ldap.BasePortalToLDAPConverter.java
protected Modifications getModifications(Object object, Properties objectMappings, Map<String, String> reservedFieldNames) { Modifications modifications = Modifications.getInstance(); for (Map.Entry<Object, Object> entry : objectMappings.entrySet()) { String fieldName = (String) entry.getKey(); if (reservedFieldNames.containsKey(fieldName)) { continue; }//w ww .j a va 2s .c om String ldapAttributeName = (String) entry.getValue(); try { Object attributeValue = PropertyUtils.getProperty(object, fieldName); if (attributeValue != null) { addModificationItem(ldapAttributeName, attributeValue.toString(), modifications); } } catch (Exception e) { if (_log.isWarnEnabled()) { _log.warn("Unable to map field " + fieldName + " to class " + object.getClass(), e); } } } return modifications; }
From source file:com.liferay.portal.security.ldap.BasePortalToLDAPConverter.java
protected void populateCustomAttributeModifications(Object object, ExpandoBridge expandoBridge, Map<String, Serializable> expandoAttributes, Properties expandoMappings, Modifications modifications) { if ((expandoAttributes == null) || expandoAttributes.isEmpty()) { return;//from w w w . ja v a 2 s . co m } for (Map.Entry<Object, Object> entry : expandoMappings.entrySet()) { String fieldName = (String) entry.getKey(); String ldapAttributeName = (String) entry.getValue(); Serializable fieldValue = expandoAttributes.get(fieldName); if (fieldValue == null) { continue; } try { int type = expandoBridge.getAttributeType(fieldName); String value = ExpandoConverterUtil.getStringFromAttribute(type, fieldValue); addModificationItem(ldapAttributeName, value, modifications); } catch (Exception e) { if (_log.isWarnEnabled()) { _log.warn("Unable to map field " + fieldName + " to class " + object.getClass(), e); } } } }
From source file:org.ala.spatial.web.services.SitesBySpeciesWSControllerTabulated.java
public void run() throws IOException { synchronized (lockProperties) { //get all incomplete runs String pth = AlaspatialProperties.getAnalysisWorkingDir() + File.separator + "sxs" + File.separator; Properties p = new Properties(); p.load(new FileReader(pth + "list.properties")); ArrayList<SxS> list = new ArrayList<SxS>(); for (Entry entry : p.entrySet()) { if (!new File(pth + entry.getKey()).exists()) { list.add(new SxS((String) entry.getValue(), (String) entry.getKey(), "")); }/* w w w. j ava 2 s . c om*/ } for (SxS sxs : list) { String url = AlaspatialProperties.getAlaspatialUrl() + "ws/sitesbyspeciestabulated?" + sxs.getValue() + "&bs=" + AlaspatialProperties.getBiocacheWsURL(); try { //start GetMethod get = new GetMethod(url); HttpClient client = new HttpClient(); client.executeMethod(get); if (get.getStatusCode() == 200) { String id = get.getResponseBodyAsString(); long lid = Long.parseLong(id); //test analysis id FileWriter fw = new FileWriter(pth + sxs.getAnalysisId()); fw.write(id); fw.flush(); fw.close(); } else { System.out.println("sxs failed for: " + url); System.out.println("response code: " + get.getStatusCode()); FileWriter fw = new FileWriter(pth + sxs.getAnalysisId()); fw.write("0"); fw.flush(); fw.close(); } } catch (Exception e) { System.out.println("sxs failed for: " + url); e.printStackTrace(); FileWriter fw = new FileWriter(pth + sxs.getAnalysisId()); fw.write("0"); fw.flush(); fw.close(); } } } }
From source file:org.ala.spatial.web.services.SitesBySpeciesWSControllerTabulated.java
List<SxS> getSxSList() throws IOException { initListProperties();//from ww w .j a v a 2 s . c om String pth = AlaspatialProperties.getAnalysisWorkingDir() + File.separator + "sxs" + File.separator; Properties p = new Properties(); p.load(new FileReader(pth + "list.properties")); ArrayList<SxS> list = new ArrayList<SxS>(); boolean runagain = false; for (Entry entry : p.entrySet()) { if (new File(pth + entry.getKey()).exists()) { BufferedReader br = new BufferedReader(new FileReader(pth + entry.getKey())); String analysisId = br.readLine(); br.close(); String status; if (analysisId != null && analysisId.equals("-1")) { continue; } else if (analysisId == null || analysisId.equals("0")) { status = AnalysisJob.FAILED; } else { status = AnalysisQueue.getState(analysisId); } list.add(new SxS((String) entry.getValue(), analysisId, status)); } else { //something did not run runagain = true; } } if (runagain) { run(); } return list; }
From source file:com.bstek.dorado.data.config.definition.DataTypeDefinition.java
private void injectResourceStrings(DataTypeDefinition dataTypeDefinition, EntityDataType dataType) throws Exception { Context doradoContext = Context.getCurrent(); ModelResourceManager modelResourceManager = (ModelResourceManager) doradoContext .getServiceBean("modelResourceManager"); ModelResourceBundle bundle = (ModelResourceBundle) modelResourceManager.getBundle(dataTypeDefinition); if (bundle == null) { return;/*from www . j a va2 s. co m*/ } Properties strings = bundle.getSubProperties(dataTypeDefinition.getName()); if (strings == null) { return; } for (Map.Entry<Object, Object> entry : strings.entrySet()) { injectResourceString(dataType, (String) entry.getKey(), (String) entry.getValue()); } }
From source file:com.datatorrent.stram.client.StramClientUtils.java
public static void evalProperties(Properties target, Configuration vars) { ScriptEngine engine = new ScriptEngineManager().getEngineByName("javascript"); Pattern substitutionPattern = Pattern.compile("\\$\\{(.+?)\\}"); Pattern evalPattern = Pattern.compile("\\{% (.+?) %\\}"); try {/* w w w . j a v a2 s. c o m*/ engine.eval("var _prop = {}"); for (Map.Entry<String, String> entry : vars) { String evalString = String.format("_prop[\"%s\"] = \"%s\"", StringEscapeUtils.escapeJava(entry.getKey()), StringEscapeUtils.escapeJava(entry.getValue())); engine.eval(evalString); } } catch (ScriptException ex) { LOG.warn("Javascript error: {}", ex.getMessage()); } for (Map.Entry<Object, Object> entry : target.entrySet()) { String value = entry.getValue().toString(); Matcher matcher = substitutionPattern.matcher(value); if (matcher.find()) { StringBuilder newValue = new StringBuilder(); int cursor = 0; do { newValue.append(value.substring(cursor, matcher.start())); String subst = vars.get(matcher.group(1)); if (subst != null) { newValue.append(subst); } cursor = matcher.end(); } while (matcher.find()); newValue.append(value.substring(cursor)); target.put(entry.getKey(), newValue.toString()); } matcher = evalPattern.matcher(value); if (matcher.find()) { StringBuilder newValue = new StringBuilder(); int cursor = 0; do { newValue.append(value.substring(cursor, matcher.start())); try { Object result = engine.eval(matcher.group(1)); String eval = result.toString(); if (eval != null) { newValue.append(eval); } } catch (ScriptException ex) { LOG.warn("JavaScript exception {}", ex.getMessage()); } cursor = matcher.end(); } while (matcher.find()); newValue.append(value.substring(cursor)); target.put(entry.getKey(), newValue.toString()); } } }