use of org.walkmod.WalkModFacade in project walkmod-core by walkmod.
the class InitCommand method execute.
@Override
public void execute() throws Exception {
if (help) {
command.usage("init");
} else {
WalkModFacade facade = new WalkModFacade(OptionsBuilder.options().configurationFormat(format));
facade.init();
}
}
use of org.walkmod.WalkModFacade in project walkmod-core by walkmod.
the class InspectCommand method execute.
@Override
public void execute() throws Exception {
if (help) {
command.usage("inspect");
} else {
WalkModFacade facade = new WalkModFacade(OptionsBuilder.options().offline(offline));
List<BeanDefinition> beans = facade.inspectPlugin(new PluginConfigImpl(pluginId.get(0)));
List<String> validTypesList = Arrays.asList("String", "JSONObject", "JSONArray");
if (beans != null) {
at = new V2_AsciiTable();
at.addRule();
at.addRow("TYPE NAME (ID)", "CATEGORY", "PROPERTIES", "DESCRIPTION");
at.addStrongRule();
for (BeanDefinition bean : beans) {
List<PropertyDefinition> properties = bean.getProperties();
if (properties == null || properties.isEmpty()) {
at.addRow(bean.getType(), bean.getCategory(), "", bean.getDescription());
} else {
int i = 0;
for (PropertyDefinition pd : properties) {
if (validTypesList.contains(pd.getType())) {
String label = pd.getName() + ":" + pd.getType();
if (pd.getDefaultValue() != null && pd.getDefaultValue().length() != 0) {
label = label + " (" + pd.getDefaultValue() + ")";
}
if (i == 0) {
at.addRow(bean.getType(), bean.getCategory(), label, bean.getDescription());
} else {
at.addRow("", "", label, "");
}
i++;
}
}
}
at.addRule();
}
}
}
}
use of org.walkmod.WalkModFacade in project walkmod-core by walkmod.
the class InstallCommand method execute.
@Override
public void execute() throws Exception {
if (help) {
command.usage("install");
} else {
WalkModFacade facade = new WalkModFacade(OptionsBuilder.options().printErrors(showException));
facade.install();
}
}
use of org.walkmod.WalkModFacade in project walkmod-core by walkmod.
the class PrintChainsCommand method execute.
@Override
public void execute() throws Exception {
if (help) {
command.usage("chains");
} else {
WalkModFacade facade = new WalkModFacade(OptionsBuilder.options().configurationFile(configurationFile).build());
Configuration cfg = facade.getConfiguration();
at = new V2_AsciiTable();
at.addRule();
at.addRow("CHAIN", "READER PATH", "WRITER PATH", "TRANSFORMATIONS");
at.addStrongRule();
if (cfg == null) {
at.addRule();
log.error("Sorry, the current directory does not contain a walkmod configuration file or it is invalid.");
}
if (cfg != null) {
Collection<ChainConfig> chains = cfg.getChainConfigs();
if (chains != null) {
for (ChainConfig cc : chains) {
List<TransformationConfig> transformations = cc.getWalkerConfig().getTransformations();
int numTransformations = transformations.size();
int numReaderIncludesExcludes = 0;
int includesLength = 0;
String[] excludes = cc.getReaderConfig().getExcludes();
if (excludes != null) {
numReaderIncludesExcludes = excludes.length;
}
String[] includes = cc.getReaderConfig().getIncludes();
if (includes != null) {
includesLength = includes.length;
numReaderIncludesExcludes += includes.length;
}
int limit = numReaderIncludesExcludes + 1;
if (numTransformations > numReaderIncludesExcludes) {
limit = numTransformations;
}
int includesExcludesWriterLength = 0;
int includesWriterLength = 0;
String[] excludesWriter = cc.getWriterConfig().getExcludes();
if (excludesWriter != null) {
includesExcludesWriterLength += excludesWriter.length;
if (excludesWriter.length + 1 > limit) {
limit = excludesWriter.length + 1;
}
}
String[] includesWriter = cc.getWriterConfig().getIncludes();
if (includesWriter != null) {
includesExcludesWriterLength += includesWriter.length;
includesWriterLength = includesWriter.length;
if (includesWriter.length + 1 > limit) {
limit = includesWriter.length + 1;
}
}
for (int i = 0; i < limit; i++) {
TransformationConfig next = null;
String type = "";
if (i < numTransformations) {
next = transformations.get(i);
type = "- " + next.getType();
}
if (i == 0) {
at.addRow(cc.getName(), cc.getReaderConfig().getPath(), cc.getWriterConfig().getPath(), type);
} else {
String readerWildcard = "";
if (i - 1 < includesLength) {
readerWildcard = "> " + includes[i - 1];
} else {
if (i - 1 < numReaderIncludesExcludes) {
readerWildcard = "< " + excludes[i - 1 + includesLength];
}
}
String writerWildcard = "";
if (includesWriter != null && i - 1 < includesWriter.length) {
writerWildcard = "> " + includesWriter[i - 1];
} else if (i - 1 < includesExcludesWriterLength) {
writerWildcard = "< " + excludesWriter[i - 1 + includesWriterLength];
}
at.addRow("", readerWildcard, writerWildcard, type);
}
}
at.addRule();
}
}
}
}
}
use of org.walkmod.WalkModFacade in project walkmod-core by walkmod.
the class RemoveTransformationCommand method execute.
@Override
public void execute() throws Exception {
if (help) {
jcommander.usage("rm");
} else {
WalkModFacade facade = new WalkModFacade(OptionsBuilder.options().printErrors(printErrors));
facade.removeTransformations(chain, types, recursive);
}
}
Aggregations