List of usage examples for org.apache.commons.collections MapUtils toProperties
public static Properties toProperties(final Map map)
From source file:com.mirth.connect.client.ui.components.DataTypesComboBoxCellEditor.java
@Override public void actionPerformed(ActionEvent e) { if (super.table.getEditingRow() != -1) { int selectedRow = super.table.convertRowIndexToModel(super.table.getEditingRow()); String dataType = (String) ((JComboBox) super.getComponent()).getSelectedItem(); Channel currentChannel = PlatformUI.MIRTH_FRAME.channelEditPanel.currentChannel; MessageObject.Protocol protocol = getProtocol(dataType); Properties defaultProperties = MapUtils .toProperties(DefaultSerializerPropertiesFactory.getDefaultSerializerProperties(protocol)); // Set the new data type and default properties for that data type if (source) { if (selectedRow == 0) { if (!currentChannel.getSourceConnector().getTransformer().getInboundProtocol() .equals(protocol)) { currentChannel.getSourceConnector().getTransformer().setInboundProtocol(protocol); currentChannel.getSourceConnector().getTransformer() .setInboundProperties(defaultProperties); }//from w ww . ja va2 s. c om } else { if (!currentChannel.getSourceConnector().getTransformer().getOutboundProtocol() .equals(protocol)) { currentChannel.getSourceConnector().getTransformer().setOutboundProtocol(protocol); currentChannel.getSourceConnector().getTransformer() .setOutboundProperties(defaultProperties); // Also set the inbound data type and properties for all destinations for (Connector connector : currentChannel.getDestinationConnectors()) { connector.getTransformer().setInboundProtocol(protocol); connector.getTransformer().setInboundProperties(defaultProperties); } } } } else { if (!currentChannel.getDestinationConnectors().get(selectedRow).getTransformer() .getOutboundProtocol().equals(protocol)) { currentChannel.getDestinationConnectors().get(selectedRow).getTransformer() .setOutboundProtocol(protocol); currentChannel.getDestinationConnectors().get(selectedRow).getTransformer() .setOutboundProperties(defaultProperties); } } } PlatformUI.MIRTH_FRAME.setSaveEnabled(true); }
From source file:de.hybris.platform.b2b.mock.MockitoTenant.java
public MockitoTenant(final String tenantId) { super(tenantId); try {/*from w ww. j av a 2 s . co m*/ final AbstractTenant abstractTenant = mock(AbstractTenant.class); rawConfig = loadRawConfigFile(); configIntf = new HybrisConfig(MapUtils.toProperties(rawConfig), true, -1); // set up AbstractTenant to set up HybrisDatasource when(abstractTenant.getConfig()).thenReturn(configIntf); dataSource = createAlternativeDataSource("junit", rawConfig, false, abstractTenant); } catch (Exception e) { throw new RuntimeException(e); } }
From source file:com.thruzero.common.core.config.AbstractConfig.java
@Override public Properties getSectionAsProperties(final String sectionName) { return MapUtils.toProperties(getSection(sectionName)); }
From source file:com.galeoconsulting.leonardinius.servlet.ScriptRunnerSessionServlet.java
private String getVelocityTemplate(HttpServletRequest request) throws ServletException { try {// ww w.ja v a2s . c o m String templateNamePathKey = getTemplateKey(request); Map<String, String> templates = getConfiguredTemplates(); if (templates.containsKey(templateNamePathKey)) { String template = templates.get(templateNamePathKey); log.trace("Velocity template to be parsed: {}", template); return template; } log.warn("No templates mapped for: {} (mapping: {})", templateNamePathKey, MapUtils.toProperties(templates)); return null; } catch (IllegalArgumentException e) { throw new ServletException(e); } catch (URISyntaxException e) { throw new ServletException(e); } }
From source file:org.bdval.Predict.java
@Override public void interpretArguments(final JSAP jsap, final JSAPResult result, final DAVOptions options) { checkArgumentsSound(jsap, result, false); if (result.contains("model")) { modelFilenamePrefix = result.getString("model"); modelFilenamePrefix = BDVModel.removeSuffix(modelFilenamePrefix, ".model"); modelFilenamePrefixNoPath = FilenameUtils.getName(modelFilenamePrefix); }//from w ww . j a v a 2 s. com setupOutput(result, options); setupModelId(result, options); setupDatasetName(result, options); setupSplitPlan(result, options); loadModel(options); preparePathwayOptions(result, options); setupTableCache(result, options); setupInput(result, options); setupPlatforms(result, options); setupGeneLists(result, options); setupRandomArguments(result, options); setupArrayAttributes(result, options); setupRservePort(result, options); setupClassifier(result, options); if (result.contains("estimate-with-replacement")) { sampleWithReplacement = result.getBoolean("estimate-with-replacement"); } printStats = result.getBoolean("print-stats"); if (result.contains("survival")) { survivalFileName = result.getString("survival"); } trueLabelFilename = result.getString("true-labels"); sample2TrueLabelMap = readSampleToTrueLabelsMap(trueLabelFilename, printStats); final String testSampleFilename = result.getString("test-samples"); this.testSampleFilename = testSampleFilename; if (testSampleFilename != null) { LOG.info("Reading test sample filename: " + testSampleFilename); testSampleIds = new ObjectOpenHashSet<String>(); FastBufferedReader reader = null; try { reader = new FastBufferedReader(new FileReader(testSampleFilename)); final LineIterator lit = new LineIterator(reader); while (lit.hasNext()) { final String sampleId = lit.next().toString().trim(); testSampleIds.add(sampleId); } } catch (FileNotFoundException e) { LOG.fatal("Cannot read test sample file: " + testSampleFilename, e); System.exit(10); } finally { IOUtils.closeQuietly(reader); } } if (printStats) { if ("auto".equals(result.getString("label"))) { final File filename = new File(modelFilenamePrefix); final String cleanModelPrefix = filename.getName(); String label = StatsMode.guessLabel("", cleanModelPrefix, "[^-]*-(.*)-....."); if (label == null) { label = "unknown-label"; } maqciiHelper.setupSubmissionFile(result, options, label); } else { maqciiHelper.setupSubmissionFile(result, options); } if (LOG.isDebugEnabled()) { LOG.debug("Inside predict process filename = " + survivalFileName); } if (survivalFileName != null && !survivalFileName.equals("-")) { maqciiHelper.printSubmissionHeaders(options, true); } else { maqciiHelper.printSubmissionHeaders(options); } } if (LOG.isTraceEnabled()) { LOG.trace("sample2TrueLabelMap:"); LOG.trace(MapUtils.toProperties(sample2TrueLabelMap).toString()); } }
From source file:org.springframework.xd.dirt.module.store.ZooKeeperModuleMetadataRepository.java
/** * Get the deployment properties associated with this module metadata path. * * @param moduleDeploymentsPath the module deployment path * @return deployment properties//from w ww .j av a 2s .co m */ private Properties getDeploymentProperties(String moduleDeploymentsPath) { Map<String, String> deploymentProperties = new HashMap<String, String>(); try { deploymentProperties = ZooKeeperUtils .bytesToMap(zkConnection.getClient().getData().forPath(moduleDeploymentsPath)); } catch (Exception e) { ZooKeeperUtils.wrapAndThrowIgnoring(e, NoNodeException.class); } return MapUtils.toProperties(deploymentProperties); }
From source file:org.springframework.xd.dirt.module.store.ZooKeeperModuleMetadataRepository.java
/** * Resolve the module option value using the module metadata. * * @param metadataMap the values map from ZK module metadata * @return the resolved option values// ww w. j a v a2 s. c om */ private Properties getResolvedModuleOptions(Map<String, String> metadataMap) { Map<String, String> optionsMap = new HashMap<String, String>(); for (Map.Entry<String, String> entry : metadataMap.entrySet()) { String propertyKey = entry.getKey(); String propertyValue = entry.getValue(); if (!propertyKey.startsWith(XD_MODULE_PROPERTIES_PREFIX) && !StringUtils.isEmpty(propertyValue)) { if (propertyValue.startsWith(PlaceholderConfigurerSupport.DEFAULT_PLACEHOLDER_PREFIX) && propertyValue.endsWith(PlaceholderConfigurerSupport.DEFAULT_PLACEHOLDER_SUFFIX)) { // For a property ${module.property}, we just extract "module.property" and // check if the metadataMap has a value for it. String placeholderKey = propertyValue.substring(2, propertyValue.length() - 1); if (metadataMap.get(placeholderKey) != null) { propertyValue = metadataMap.get(placeholderKey); } } optionsMap.put(propertyKey, propertyValue); } } return MapUtils.toProperties(optionsMap); }