Search in sources :

Example 51 with CompositeConfiguration

use of org.apache.commons.configuration.CompositeConfiguration in project bookkeeper by apache.

the class TestStorageConfiguration method testGetStorageSettings.

@Test(timeout = 60000)
public void testGetStorageSettings() {
    CompositeConfiguration conf = new CompositeConfiguration();
    conf.setProperty("xxx.key", "xxx.value");
    conf.setProperty("storage.key", "storage.value");
    conf.setProperty("storage-key", "storage-value");
    StorageConfiguration storageConf = new StorageConfiguration(conf);
    assertEquals("storage.value", storageConf.getString("key"));
    assertTrue(storageConf.containsKey("key"));
    assertFalse(storageConf.containsKey("xxx.key"));
    assertFalse(storageConf.containsKey("storage.key"));
    assertFalse(storageConf.containsKey("storage-key"));
}
Also used : CompositeConfiguration(org.apache.commons.configuration.CompositeConfiguration) Test(org.junit.Test)

Example 52 with CompositeConfiguration

use of org.apache.commons.configuration.CompositeConfiguration in project UniversalMediaServer by UniversalMediaServer.

the class DeviceConfiguration method inherit.

/**
 * Creates a composite configuration for this device consisting of a dedicated device
 * configuration plus the given reference renderer configuration and the default pms
 * configuration for fallback lookup.
 *
 * @param ref The reference renderer configuration.
 */
public void inherit(RendererConfiguration ref) throws ConfigurationException {
    CompositeConfiguration cconf = new CompositeConfiguration();
    // Add the component configurations in order of lookup priority:
    // 1. The device configuration, marked as "in memory" (i.e. writeable)
    cconf.addConfiguration(deviceConf != null ? deviceConf : initConfiguration(null), true);
    // 2. The reference renderer configuration (read-only)
    cconf.addConfiguration(ref.getConfiguration());
    // 3. The default pms configuration (read-only)
    PmsConfiguration baseConf = PMS.getConfiguration();
    cconf.addConfiguration(baseConf.getConfiguration());
    // Handle all queries (external and internal) via the composite configuration
    configuration = cconf;
    pmsConfiguration = this;
    configurationReader = new ConfigurationReader(configuration, true);
    // Sync our internal PmsConfiguration vars
    // TODO: create new objects here instead?
    tempFolder = baseConf.tempFolder;
    programPaths = baseConf.programPaths;
    filter = baseConf.filter;
    // Initialize our internal RendererConfiguration vars
    sortedHeaderMatcher = ref.sortedHeaderMatcher;
    // Note: intentionally omitting 'player = null' so as to preserve player state when reloading
    loaded = true;
    this.ref = ref;
    init(NOFILE);
}
Also used : CompositeConfiguration(org.apache.commons.configuration.CompositeConfiguration)

Example 53 with CompositeConfiguration

use of org.apache.commons.configuration.CompositeConfiguration in project ffx by mjschnie.

the class MainPanel method openInit.

/**
 * Attempts to load the supplied file
 *
 * @param files Files to open
 * @param commandDescription Description of the command that created this
 * file.
 * @return a {@link java.lang.Thread} object.
 */
private UIFileOpener openInit(List<File> files, String commandDescription) {
    if (files == null) {
        return null;
    }
    File file = new File(FilenameUtils.normalize(files.get(0).getAbsolutePath()));
    // Set the Current Working Directory based on this file.
    setCWD(file.getParentFile());
    // Get "filename" from "filename.extension".
    String name = file.getName();
    String extension = FilenameUtils.getExtension(name);
    // Create the CompositeConfiguration properties.
    CompositeConfiguration properties = Keyword.loadProperties(file);
    forceFieldFilter = new ForceFieldFilter(properties);
    ForceField forceField = forceFieldFilter.parse();
    // Create an FFXSystem for this file.
    FFXSystem newSystem = new FFXSystem(file, commandDescription, properties);
    String[] patches = properties.getStringArray("patch");
    for (String patch : patches) {
        logger.info(" Attempting to read force field patch from " + patch + ".");
        CompositeConfiguration patchConfiguration = new CompositeConfiguration();
        patchConfiguration.addProperty("parameters", patch);
        forceFieldFilter = new ForceFieldFilter(patchConfiguration);
        ForceField patchForceField = forceFieldFilter.parse();
        forceField.append(patchForceField);
        if (RotamerLibrary.addRotPatch(patch)) {
            logger.info(String.format(" Loaded rotamer definitions from patch %s.", patch));
        }
    }
    newSystem.setForceField(forceField);
    // Decide what parser to use.
    SystemFilter systemFilter = null;
    if (xyzFileFilter.acceptDeep(file)) {
        // Use the TINKER Cartesian Coordinate File Parser.
        systemFilter = new XYZFilter(files, newSystem, forceField, properties);
    } else if (intFileFilter.acceptDeep(file)) {
        // Use the TINKER Internal Coordinate File Parser.
        systemFilter = new INTFilter(files, newSystem, forceField, properties);
    } else {
        // Use the PDB File Parser.
        systemFilter = new PDBFilter(files, newSystem, forceField, properties);
    }
    setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
    activeFilter = systemFilter;
    // return new UIFileOpener(systemFilter, this);
    UIFileOpener fileOpener = new UIFileOpener(systemFilter, this);
    if (fileOpenerThreads > 0) {
        fileOpener.setNThreads(fileOpenerThreads);
    }
    return fileOpener;
}
Also used : CompositeConfiguration(org.apache.commons.configuration.CompositeConfiguration) ForceFieldFilter(ffx.potential.parsers.ForceFieldFilter) ForceField(ffx.potential.parameters.ForceField) ForceFieldString(ffx.potential.parameters.ForceField.ForceFieldString) SystemFilter(ffx.potential.parsers.SystemFilter) XYZFilter(ffx.potential.parsers.XYZFilter) File(java.io.File) PDBFilter(ffx.potential.parsers.PDBFilter) INTFilter(ffx.potential.parsers.INTFilter)

Example 54 with CompositeConfiguration

use of org.apache.commons.configuration.CompositeConfiguration in project ffx by mjschnie.

the class MainPanel method openFromPDB.

/**
 * Opens a file from the PDB
 */
public void openFromPDB() {
    if (openThread != null && openThread.isAlive()) {
        return;
    }
    String code = JOptionPane.showInputDialog("Enter the PDB Identifier (4 characters)", "");
    if (code == null) {
        return;
    }
    code = code.toLowerCase().trim();
    if (code == null || code.length() != 4) {
        return;
    }
    String fileName = code + ".pdb";
    String path = getPWD().getAbsolutePath();
    File pdbFile = new File(path + File.separatorChar + fileName);
    CompositeConfiguration properties = Keyword.loadProperties(pdbFile);
    forceFieldFilter = new ForceFieldFilter(properties);
    ForceField forceField = forceFieldFilter.parse();
    FFXSystem newSystem = new FFXSystem(pdbFile, "PDB", properties);
    newSystem.setForceField(forceField);
    if (!pdbFile.exists()) {
        String fromURL = pdbForID(code);
        pdbFile = downloadURL(fromURL);
        if (pdbFile == null || !pdbFile.exists()) {
            return;
        }
    } else {
        String message = String.format(" Reading the local copy of the PDB file %s.", pdbFile);
        logger.info(message);
    }
    PDBFilter pdbFilter = new PDBFilter(pdbFile, newSystem, forceField, properties);
    setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
    UIFileOpener openFile = new UIFileOpener(pdbFilter, this);
    if (fileOpenerThreads > 0) {
        openFile.setNThreads(fileOpenerThreads);
    }
    openThread = new Thread(openFile);
    openThread.start();
    setPanel(GRAPHICS);
}
Also used : CompositeConfiguration(org.apache.commons.configuration.CompositeConfiguration) ForceFieldFilter(ffx.potential.parsers.ForceFieldFilter) ForceField(ffx.potential.parameters.ForceField) ForceFieldString(ffx.potential.parameters.ForceField.ForceFieldString) File(java.io.File) PDBFilter(ffx.potential.parsers.PDBFilter)

Example 55 with CompositeConfiguration

use of org.apache.commons.configuration.CompositeConfiguration in project ffx by mjschnie.

the class MainPanel method openInit.

/**
 * Attempts to load the supplied file
 *
 * @param file File to open
 * @param commandDescription Description of the command that created this
 * file.
 * @return a {@link java.lang.Thread} object.
 */
private UIFileOpener openInit(File file, String commandDescription) {
    if (file == null || !file.isFile() || !file.canRead()) {
        return null;
    }
    file = new File(FilenameUtils.normalize(file.getAbsolutePath()));
    // Set the Current Working Directory based on this file.
    setCWD(file.getParentFile());
    // Get "filename" from "filename.extension".
    String name = file.getName();
    String extension = FilenameUtils.getExtension(name);
    /**
     * Run a Force Field X script.
     */
    if (extension.equalsIgnoreCase("ffx") || extension.equalsIgnoreCase("groovy")) {
        ModelingShell shell = getModelingShell();
        shell.runFFXScript(file);
        boolean shutDown = Boolean.parseBoolean(System.getProperty("ffx.shutDown", "true"));
        if (java.awt.GraphicsEnvironment.isHeadless() && shutDown) {
            exit();
        } else {
            return null;
        }
    }
    // Create the CompositeConfiguration properties.
    CompositeConfiguration properties = Keyword.loadProperties(file);
    // Create an FFXSystem for this file.
    FFXSystem newSystem = new FFXSystem(file, commandDescription, properties);
    // Create a Force Field.
    forceFieldFilter = new ForceFieldFilter(properties);
    ForceField forceField = forceFieldFilter.parse();
    String[] patches = properties.getStringArray("patch");
    for (String patch : patches) {
        logger.info(" Attempting to read force field patch from " + patch + ".");
        CompositeConfiguration patchConfiguration = new CompositeConfiguration();
        patchConfiguration.addProperty("parameters", patch);
        forceFieldFilter = new ForceFieldFilter(patchConfiguration);
        ForceField patchForceField = forceFieldFilter.parse();
        forceField.append(patchForceField);
        if (RotamerLibrary.addRotPatch(patch)) {
            logger.info(String.format(" Loaded rotamer definitions from patch %s.", patch));
        }
    }
    newSystem.setForceField(forceField);
    SystemFilter systemFilter = null;
    // Decide what parser to use.
    if (xyzFileFilter.acceptDeep(file)) {
        // Use the TINKER Cartesian Coordinate File Parser.
        systemFilter = new XYZFilter(file, newSystem, forceField, properties);
    } else if (intFileFilter.acceptDeep(file)) {
        // Use the TINKER Internal Coordinate File Parser.
        systemFilter = new INTFilter(file, newSystem, forceField, properties);
    } else {
        // Use the PDB File Parser.
        systemFilter = new PDBFilter(file, newSystem, forceField, properties);
    }
    setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
    activeFilter = systemFilter;
    UIFileOpener fileOpener = new UIFileOpener(systemFilter, this);
    if (fileOpenerThreads > 0) {
        fileOpener.setNThreads(fileOpenerThreads);
    }
    return fileOpener;
// return new UIFileOpener(systemFilter, this);
}
Also used : CompositeConfiguration(org.apache.commons.configuration.CompositeConfiguration) ForceFieldFilter(ffx.potential.parsers.ForceFieldFilter) ForceFieldString(ffx.potential.parameters.ForceField.ForceFieldString) ForceField(ffx.potential.parameters.ForceField) SystemFilter(ffx.potential.parsers.SystemFilter) XYZFilter(ffx.potential.parsers.XYZFilter) File(java.io.File) PDBFilter(ffx.potential.parsers.PDBFilter) INTFilter(ffx.potential.parsers.INTFilter)

Aggregations

CompositeConfiguration (org.apache.commons.configuration.CompositeConfiguration)89 PropertiesConfiguration (org.apache.commons.configuration.PropertiesConfiguration)46 Test (org.junit.Test)24 ClusterController (org.apache.whirr.ClusterController)22 Configuration (org.apache.commons.configuration.Configuration)21 File (java.io.File)17 Before (org.junit.Before)11 ForceField (ffx.potential.parameters.ForceField)10 ConfigurationException (org.apache.commons.configuration.ConfigurationException)9 HadoopProxy (org.apache.whirr.service.hadoop.HadoopProxy)9 BeforeClass (org.junit.BeforeClass)9 IOException (java.io.IOException)8 ClusterSpec (org.apache.whirr.ClusterSpec)8 MolecularAssembly (ffx.potential.MolecularAssembly)7 ForceFieldFilter (ffx.potential.parsers.ForceFieldFilter)7 PDBFilter (ffx.potential.parsers.PDBFilter)7 MapConfiguration (org.apache.commons.configuration.MapConfiguration)6 Crystal (ffx.crystal.Crystal)5 ReflectionList (ffx.crystal.ReflectionList)5 ForceFieldEnergy (ffx.potential.ForceFieldEnergy)5