Search in sources :

Example 21 with WalkModFacade

use of org.walkmod.WalkModFacade 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();
        }
    }
}
Also used : Configuration(org.walkmod.conf.entities.Configuration) TransformationConfig(org.walkmod.conf.entities.TransformationConfig) ChainConfig(org.walkmod.conf.entities.ChainConfig) V2_AsciiTable(de.vandermeer.asciitable.v2.V2_AsciiTable) WalkModFacade(org.walkmod.WalkModFacade)

Example 22 with WalkModFacade

use of org.walkmod.WalkModFacade in project walkmod-core by walkmod.

the class RemoveChainCommand method execute.

@Override
public void execute() throws Exception {
    if (help) {
        jcommander.usage("rm-chain");
    } else {
        WalkModFacade facade = new WalkModFacade(OptionsBuilder.options().printErrors(printErrors));
        facade.removeChains(chains, recursive);
    }
}
Also used : WalkModFacade(org.walkmod.WalkModFacade)

Example 23 with WalkModFacade

use of org.walkmod.WalkModFacade in project walkmod-core by walkmod.

the class RemoveExcludesCommand method execute.

@Override
public void execute() throws Exception {
    if (help) {
        jcommander.usage("rm-excludes");
    } else {
        WalkModFacade facade = new WalkModFacade(OptionsBuilder.options().printErrors(printErrors));
        facade.removeExcludesToChain(chain, excludes, recursive, setToReader, setToWriter);
    }
}
Also used : WalkModFacade(org.walkmod.WalkModFacade)

Example 24 with WalkModFacade

use of org.walkmod.WalkModFacade in project walkmod-core by walkmod.

the class RemoveProviderCommand method execute.

@Override
public void execute() throws Exception {
    if (help) {
        command.usage("rm-provider");
    } else {
        WalkModFacade facade = new WalkModFacade(OptionsBuilder.options().printErrors(printErrors));
        facade.removeProviders(providers, recursive);
    }
}
Also used : WalkModFacade(org.walkmod.WalkModFacade)

Example 25 with WalkModFacade

use of org.walkmod.WalkModFacade in project walkmod-core by walkmod.

the class PatchCommand method execute.

@Override
public void execute() throws Exception {
    if (isHelpNeeded()) {
        command.usage("patch");
    } else {
        Map<String, String> dynParams = getDynamicParams();
        dynParams.put("patchPerFile", Boolean.toString(patchPerFile));
        dynParams.put("patchPerChange", Boolean.toString(patchPerChange));
        dynParams.put("patchFormat", patchFormat);
        WalkModFacade facade = new WalkModFacade(buildOptions());
        String[] params = new String[getParameters().size()];
        if (params.length == 0) {
            facade.patch();
        } else {
            facade.patch(getParameters().toArray(params));
        }
    }
}
Also used : WalkModFacade(org.walkmod.WalkModFacade)

Aggregations

WalkModFacade (org.walkmod.WalkModFacade)25 V2_AsciiTable (de.vandermeer.asciitable.v2.V2_AsciiTable)6 Configuration (org.walkmod.conf.entities.Configuration)5 PluginConfig (org.walkmod.conf.entities.PluginConfig)3 ChainConfig (org.walkmod.conf.entities.ChainConfig)2 TransformationConfig (org.walkmod.conf.entities.TransformationConfig)2 PluginConfigImpl (org.walkmod.conf.entities.impl.PluginConfigImpl)2 JSONArray (com.alibaba.fastjson.JSONArray)1 JSONObject (com.alibaba.fastjson.JSONObject)1 DefaultJSONParser (com.alibaba.fastjson.parser.DefaultJSONParser)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 URL (java.net.URL)1 LinkedHashMap (java.util.LinkedHashMap)1 LinkedList (java.util.LinkedList)1 DocumentBuilder (javax.xml.parsers.DocumentBuilder)1 DocumentBuilderFactory (javax.xml.parsers.DocumentBuilderFactory)1 Document (org.w3c.dom.Document)1 NodeList (org.w3c.dom.NodeList)1 BeanDefinition (org.walkmod.conf.entities.BeanDefinition)1