Search in sources :

Example 11 with ConfigurationManager

use of org.walkmod.conf.ConfigurationManager in project walkmod-core by walkmod.

the class WalkModFacade method addChainConfig.

/**
 * Adds a new chain configuration into the configuration file
 *
 * @param chainCfg
 *            chain configuration to add
 * @param recursive
 *            Adds the new chain into all the submodules
 * @param before
 *            Decides which is the next chain to execute.
 * @throws Exception
 *             in case that the walkmod configuration file can't be read.
 */
public void addChainConfig(ChainConfig chainCfg, boolean recursive, String before) throws Exception {
    long startTime = System.currentTimeMillis();
    Exception exception = null;
    if (!cfg.exists()) {
        init();
    }
    userDir = new File(System.getProperty("user.dir")).getAbsolutePath();
    System.setProperty("user.dir", options.getExecutionDirectory().getAbsolutePath());
    try {
        ConfigurationManager manager = new ConfigurationManager(cfg, false);
        ProjectConfigurationProvider cfgProvider = manager.getProjectConfigurationProvider();
        cfgProvider.addChainConfig(chainCfg, recursive, before);
    } catch (Exception e) {
        exception = e;
    } finally {
        System.setProperty("user.dir", userDir);
        updateMsg(startTime, exception);
    }
}
Also used : ProjectConfigurationProvider(org.walkmod.conf.ProjectConfigurationProvider) File(java.io.File) ConfigurationManager(org.walkmod.conf.ConfigurationManager) WalkModException(org.walkmod.exceptions.WalkModException) IOException(java.io.IOException) InvalidConfigurationException(org.walkmod.exceptions.InvalidConfigurationException)

Example 12 with ConfigurationManager

use of org.walkmod.conf.ConfigurationManager in project walkmod-core by walkmod.

the class WalkModFacade method addTransformationConfig.

/**
 * Adds a new transformation configuration into the configuration file
 *
 * @param chain
 *            chain identifier where the transformation will be appended. It can be null.
 * @param path
 *            the path where the transformation config will be applied if the chain does not
 *            exists or is null.
 * @param recursive
 *            if the transformation config is added recursively to all the submodules.
 * @param transformationCfg
 *            transformation configuration to add
 * @param order
 *            priority order
 * @param before
 *            defines which is the next chain to execute
 * @throws Exception
 *             in case that the walkmod configuration file can't be read.
 */
public void addTransformationConfig(String chain, String path, boolean recursive, TransformationConfig transformationCfg, Integer order, String before) throws Exception {
    long startTime = System.currentTimeMillis();
    Exception exception = null;
    if (!cfg.exists()) {
        init();
    }
    userDir = new File(System.getProperty("user.dir")).getAbsolutePath();
    System.setProperty("user.dir", options.getExecutionDirectory().getAbsolutePath());
    try {
        ConfigurationManager manager = new ConfigurationManager(cfg, false);
        ProjectConfigurationProvider cfgProvider = manager.getProjectConfigurationProvider();
        cfgProvider.addTransformationConfig(chain, path, transformationCfg, recursive, order, before);
    } catch (Exception e) {
        exception = e;
    } finally {
        System.setProperty("user.dir", userDir);
        updateMsg(startTime, exception);
    }
}
Also used : ProjectConfigurationProvider(org.walkmod.conf.ProjectConfigurationProvider) File(java.io.File) ConfigurationManager(org.walkmod.conf.ConfigurationManager) WalkModException(org.walkmod.exceptions.WalkModException) IOException(java.io.IOException) InvalidConfigurationException(org.walkmod.exceptions.InvalidConfigurationException)

Example 13 with ConfigurationManager

use of org.walkmod.conf.ConfigurationManager in project walkmod-core by walkmod.

the class WalkModFacade method removeIncludesToChain.

/**
 * Removes a list of excludes rules into a chain
 *
 * @param chain
 *            Chain to apply the excludes list
 * @param includes
 *            List of includes
 * @param recursive
 *            If it necessary to set the parameter to all the submodules.
 * @param setToReader
 *            If it is added into the reader includes list
 * @param setToWriter
 *            If it is added into the writer includes list
 */
public void removeIncludesToChain(String chain, List<String> includes, boolean recursive, boolean setToReader, boolean setToWriter) {
    long startTime = System.currentTimeMillis();
    Exception exception = null;
    if (cfg.exists()) {
        userDir = new File(System.getProperty("user.dir")).getAbsolutePath();
        System.setProperty("user.dir", options.getExecutionDirectory().getAbsolutePath());
        try {
            ConfigurationManager manager = new ConfigurationManager(cfg, false);
            manager.getProjectConfigurationProvider().removeIncludesFromChain(chain, includes, recursive, setToReader, setToWriter);
        } catch (Exception e) {
            exception = e;
        } finally {
            System.setProperty("user.dir", userDir);
            updateMsg(startTime, exception);
        }
    }
}
Also used : File(java.io.File) ConfigurationManager(org.walkmod.conf.ConfigurationManager) WalkModException(org.walkmod.exceptions.WalkModException) IOException(java.io.IOException) InvalidConfigurationException(org.walkmod.exceptions.InvalidConfigurationException)

Example 14 with ConfigurationManager

use of org.walkmod.conf.ConfigurationManager in project walkmod-core by walkmod.

the class WalkModFacade method addConfigurationParameter.

/**
 * Sets an specific parameter value into a bean.
 *
 * @param param
 *            Parameter name
 * @param value
 *            Parameter value
 * @param type
 *            Bean type to set the parameter
 * @param category
 *            Bean category to set the parameter (walker, reader, transformation, writer)
 * @param name
 *            Bean name/alias to set the parameter
 * @param chain
 *            Bean chain to filter the beans to take into account
 * @param recursive
 *            If it necessary to set the parameter to all the submodules.
 * @throws Exception
 *             If the walkmod configuration file can't be read.
 */
public void addConfigurationParameter(String param, String value, String type, String category, String name, String chain, boolean recursive) throws Exception {
    long startTime = System.currentTimeMillis();
    Exception exception = null;
    if (cfg.exists()) {
        userDir = new File(System.getProperty("user.dir")).getAbsolutePath();
        System.setProperty("user.dir", options.getExecutionDirectory().getAbsolutePath());
        try {
            ConfigurationManager manager = new ConfigurationManager(cfg, false);
            manager.getProjectConfigurationProvider().addConfigurationParameter(param, value, type, category, name, chain, recursive);
        } catch (Exception e) {
            exception = e;
        } finally {
            System.setProperty("user.dir", userDir);
            updateMsg(startTime, exception);
        }
    }
}
Also used : File(java.io.File) ConfigurationManager(org.walkmod.conf.ConfigurationManager) WalkModException(org.walkmod.exceptions.WalkModException) IOException(java.io.IOException) InvalidConfigurationException(org.walkmod.exceptions.InvalidConfigurationException)

Example 15 with ConfigurationManager

use of org.walkmod.conf.ConfigurationManager in project walkmod-core by walkmod.

the class WalkModFacade method getConfiguration.

/**
 * Returns the equivalent configuration representation of the Walkmod config file.
 *
 * @return Configuration object representation of the config file.
 * @throws Exception
 *             If the walkmod configuration file can't be read.
 */
public Configuration getConfiguration() throws Exception {
    Configuration result = null;
    if (cfg.exists()) {
        userDir = new File(System.getProperty("user.dir")).getAbsolutePath();
        System.setProperty("user.dir", options.getExecutionDirectory().getAbsolutePath());
        try {
            ConfigurationManager manager = new ConfigurationManager(cfg, false);
            manager.executeConfigurationProviders();
            result = manager.getConfiguration();
        } finally {
            System.setProperty("user.dir", userDir);
        }
    }
    return result;
}
Also used : Configuration(org.walkmod.conf.entities.Configuration) File(java.io.File) ConfigurationManager(org.walkmod.conf.ConfigurationManager)

Aggregations

ConfigurationManager (org.walkmod.conf.ConfigurationManager)23 IOException (java.io.IOException)21 File (java.io.File)20 InvalidConfigurationException (org.walkmod.exceptions.InvalidConfigurationException)20 WalkModException (org.walkmod.exceptions.WalkModException)20 ProjectConfigurationProvider (org.walkmod.conf.ProjectConfigurationProvider)12 Configuration (org.walkmod.conf.entities.Configuration)5 ConfigurationImpl (org.walkmod.conf.entities.impl.ConfigurationImpl)2 DynamicConfigurationProvider (org.walkmod.conf.providers.DynamicConfigurationProvider)2 DynamicModulesConfigurationProvider (org.walkmod.conf.providers.DynamicModulesConfigurationProvider)2 DateFormat (java.text.DateFormat)1 DecimalFormat (java.text.DecimalFormat)1 SimpleDateFormat (java.text.SimpleDateFormat)1 Date (java.util.Date)1 LinkedList (java.util.LinkedList)1 ConfigurationProvider (org.walkmod.conf.ConfigurationProvider)1 PluginConfig (org.walkmod.conf.entities.PluginConfig)1 IvyConfigurationProvider (org.walkmod.conf.providers.IvyConfigurationProvider)1