use of org.walkmod.conf.entities.Configuration in project walkmod-core by walkmod.
the class WalkModFacade method inspectPlugin.
/**
* Retrieves the bean definitions that contains an specific plugin.
*
* @param plugin
* Plugin container of bean definitions.
* @return List of bean definitions.
*/
public List<BeanDefinition> inspectPlugin(PluginConfig plugin) {
Configuration conf = new ConfigurationImpl();
Collection<PluginConfig> plugins = new LinkedList<PluginConfig>();
plugins.add(plugin);
conf.setPlugins(plugins);
ConfigurationManager manager = new ConfigurationManager(conf, false, locateConfigurationProvider());
manager.executeConfigurationProviders();
return conf.getAvailableBeans(plugin);
}
use of org.walkmod.conf.entities.Configuration in project walkmod-core by walkmod.
the class WalkModFacade method run.
private void run(List<File> result, WalkmodCommand command, ExecutionModeEnum execMode, String... chains) throws InvalidConfigurationException {
userDir = new File(System.getProperty("user.dir")).getAbsolutePath();
System.setProperty("user.dir", options.getExecutionDirectory().getAbsolutePath());
Configuration config = null;
if (cfg.exists()) {
if (options.isVerbose()) {
log.info(cfg.getAbsoluteFile() + " [ok]");
}
config = readConfig(locateConfigurationProvider(), new ExecutionModeProvider(execMode));
} else {
config = createConfig(chains, locateConfigurationProvider(), new ExecutionModeProvider(execMode));
}
try {
config.executeModuleChains(options, command, chains);
} catch (Exception e) {
System.setProperty("user.dir", userDir);
if (options.isVerbose()) {
if (!options.isPrintErrors()) {
log.error(cfg.getAbsolutePath() + " is invalid. Please, execute walkmod with -e to see the details.");
} else {
log.error("Invalid configuration", e);
}
if (options.isThrowException()) {
RuntimeException re = new RuntimeException();
re.setStackTrace(e.getStackTrace());
throw re;
}
} else {
throw new InvalidConfigurationException(e);
}
}
config.execute(userDir, options, chains);
result.addAll(Summary.getInstance().getWrittenFiles());
System.setProperty("user.dir", userDir);
}
use of org.walkmod.conf.entities.Configuration in project walkmod-core by walkmod.
the class WalkModFacade method createConfig.
private Configuration createConfig(String[] chains, ConfigurationProvider... cp) throws InvalidConfigurationException {
Configuration config = new ConfigurationImpl();
try {
DynamicConfigurationProvider prov = new DynamicConfigurationProvider(options, chains);
prov.init(config);
prov.load();
ConfigurationManager cfgManager = new ConfigurationManager(config, cp);
DynamicModulesConfigurationProvider prov2 = new DynamicModulesConfigurationProvider();
prov2.init(config);
prov2.load();
config = cfgManager.getConfiguration();
config.setParameters(options.getMutableCopyOfDynamicArgs());
} catch (Exception e) {
printConfigError(e);
}
return config;
}
use of org.walkmod.conf.entities.Configuration in project walkmod-core by walkmod.
the class PrintModulesCommand method execute.
@Override
public void execute() throws Exception {
if (help) {
command.usage("modules");
} else {
WalkModFacade facade = new WalkModFacade(OptionsBuilder.options());
Configuration cfg = facade.getConfiguration();
if (cfg == null) {
log.error("Sorry, the current directory does not contain a walkmod configuration file or it is invalid.");
}
at = new V2_AsciiTable();
at.addRule();
at.addRow("MODULE");
at.addRule();
if (cfg != null) {
List<String> modules = cfg.getModules();
if (modules != null) {
for (String module : modules) {
at.addRow(module);
}
}
}
at.addRule();
}
}
use of org.walkmod.conf.entities.Configuration in project walkmod-core by walkmod.
the class PrintTransformationsCommand method execute.
@Override
public void execute() throws Exception {
if (help) {
command.usage("transformations");
} else {
if (chain == null) {
chain = new LinkedList<String>();
}
if (chain.isEmpty()) {
chain.add("default");
}
WalkModFacade facade = new WalkModFacade(OptionsBuilder.options());
Configuration cfg = facade.getConfiguration();
if (cfg != null) {
Collection<ChainConfig> chains = cfg.getChainConfigs();
if (chains != null) {
Iterator<ChainConfig> it = chains.iterator();
ChainConfig selected = null;
while (it.hasNext() && selected == null) {
ChainConfig current = it.next();
if (current.getName().equals(chain.get(0))) {
selected = current;
}
}
if (selected != null) {
at = new V2_AsciiTable();
at.addRule();
at.addRow("TRANSFORMATION TYPE", "PARAMETERS", "NAME/ALIAS");
at.addStrongRule();
List<TransformationConfig> transformations = selected.getWalkerConfig().getTransformations();
if (transformations != null) {
for (TransformationConfig transf : transformations) {
Map<String, Object> parameters = transf.getParameters();
if (parameters == null || parameters.isEmpty()) {
at.addRow(transf.getType(), "", transf.getName());
} else {
Set<String> keys = parameters.keySet();
int i = 0;
for (String key : keys) {
if (i == 0) {
String name = transf.getName();
if (name == null) {
name = "";
}
at.addRow(transf.getType(), "-" + key + ":" + parameters.get(key), "");
} else {
at.addRow("", "-" + key + ":" + parameters.get(key), "");
}
i++;
}
}
at.addRule();
}
}
}
}
} else {
log.error("Sorry, the current directory does not contain a walkmod configuration file or it is invalid.");
at = new V2_AsciiTable();
at.addRule();
at.addRow("TRANSFORMATION TYPE", "PARAMETERS", "NAME/ALIAS");
at.addStrongRule();
at.addRule();
}
}
}
Aggregations