Search in sources :

Example 6 with ProjectConfigurationProvider

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

the class WalkModFacade method addModules.

/**
 * Adds a module into the configuration file
 *
 * @param modules
 *            Modules to add
 * @throws Exception
 *             if the walkmod configuration file can't be read.
 */
public void addModules(List<String> modules) throws Exception {
    long startTime = System.currentTimeMillis();
    Exception exception = null;
    if (modules != 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.addModules(modules);
        } 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 7 with ProjectConfigurationProvider

use of org.walkmod.conf.ProjectConfigurationProvider 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 8 with ProjectConfigurationProvider

use of org.walkmod.conf.ProjectConfigurationProvider 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 9 with ProjectConfigurationProvider

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

the class WalkModFacade method setReader.

/**
 * Sets an specific reader for an specific chain.
 *
 * @param chain
 *            Chain to apply the writer
 * @param type
 *            Reader type to set
 * @param path
 *            Reader path to set
 * @param recursive
 *            If to set the reader to all the submodules.
 * @param params
 *            Reader parameters
 * @throws Exception
 *             if the walkmod configuration file can't be read.
 */
public void setReader(String chain, String type, String path, boolean recursive, Map<String, String> params) throws Exception {
    if ((type != null && !"".equals(type.trim())) || (path != null && !"".equals(path.trim()))) {
        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.setReader(chain, type, path, recursive, params);
        } 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 10 with ProjectConfigurationProvider

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

the class WalkModFacade method addPluginConfig.

/**
 * Adds a new plugin into the configuration file
 *
 * @param pluginConfig
 *            the plugin to add
 * @param recursive
 *            if the plugin config is added recursively to all the submodules.
 * @throws Exception
 *             in case that the walkmod configuration file can't be read.
 */
public void addPluginConfig(PluginConfig pluginConfig, boolean recursive) 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.addPluginConfig(pluginConfig, recursive);
    } 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)

Aggregations

File (java.io.File)11 IOException (java.io.IOException)11 ConfigurationManager (org.walkmod.conf.ConfigurationManager)11 ProjectConfigurationProvider (org.walkmod.conf.ProjectConfigurationProvider)11 InvalidConfigurationException (org.walkmod.exceptions.InvalidConfigurationException)11 WalkModException (org.walkmod.exceptions.WalkModException)11