use of org.walkmod.conf.entities.impl.TransformationConfigImpl in project walkmod-core by walkmod.
the class XMLConfigurationProvider method getTransformationItems.
public List<TransformationConfig> getTransformationItems(Element element, boolean exceptionsEnabled) {
List<TransformationConfig> transformationConfigs = new LinkedList<TransformationConfig>();
NodeList transfNodes = element.getChildNodes();
for (int j = 0; j < transfNodes.getLength(); j++) {
element = (Element) transfNodes.item(j);
if ("transformation".equals(element.getNodeName())) {
TransformationConfig tc = new TransformationConfigImpl();
String name = element.getAttribute("name");
String visitor = element.getAttribute("type");
String isMergeable = element.getAttribute("isMergeable");
String mergePolicy = element.getAttribute("merge-policy");
if ("".equals(visitor)) {
throw new ConfigurationException("Invalid transformation definition: A " + "type attribute must be specified");
}
if ("".equals(name)) {
name = null;
}
tc.setName(name);
tc.setType(visitor);
tc.setParameters(getParams(element));
if (isMergeable != null && !("".equals(isMergeable))) {
tc.isMergeable(Boolean.parseBoolean(isMergeable));
}
if (!"".equals(mergePolicy.trim())) {
tc.isMergeable(true);
tc.setMergePolicy(mergePolicy);
}
transformationConfigs.add(tc);
}
}
return transformationConfigs;
}
use of org.walkmod.conf.entities.impl.TransformationConfigImpl in project walkmod-core by walkmod.
the class JSONConfigParser method getTransformationCfgs.
public List<TransformationConfig> getTransformationCfgs(JsonNode current) {
if (current.has("transformations")) {
List<TransformationConfig> transList = new LinkedList<TransformationConfig>();
Iterator<JsonNode> itTrans = current.get("transformations").iterator();
while (itTrans.hasNext()) {
JsonNode item = itTrans.next();
TransformationConfig trans = new TransformationConfigImpl();
if (item.has("type")) {
trans.setType(item.get("type").asText());
}
if (item.has("name")) {
trans.setName(item.get("name").asText());
}
if (item.has("merge-policy")) {
trans.setMergePolicy(item.get("merge-policy").asText());
}
if (item.has("isMergeable")) {
trans.isMergeable(item.get("isMergeable").asBoolean());
}
trans.setParameters(getParams(item));
transList.add(trans);
}
return transList;
}
return null;
}
use of org.walkmod.conf.entities.impl.TransformationConfigImpl in project walkmod-core by walkmod.
the class AddTransformationCommand method buildTransformationCfg.
public TransformationConfig buildTransformationCfg() {
TransformationConfig tconfig = new TransformationConfigImpl();
tconfig.setType(type.get(0));
tconfig.isMergeable(isMergeable);
tconfig.setMergePolicy(mergePolicy);
tconfig.setName(name);
if (params != null) {
tconfig.setParameters(new HashMap<String, Object>(params));
}
return tconfig;
}
use of org.walkmod.conf.entities.impl.TransformationConfigImpl in project walkmod-core by walkmod.
the class DynamicConfigurationProvider method load.
@Override
public void load() throws ConfigurationException {
config.prepareInitializers();
if (chains != null) {
for (String chain : chains) {
if (StringUtils.isNotEmpty(chain)) {
PluginConfig plugin = config.resolvePlugin(chain);
config.getPlugins().add(plugin);
}
}
config.preparePlugins();
}
String path = options.getPath();
if (chains != null) {
for (String chain : chains) {
if (StringUtils.isNotEmpty(chain)) {
ChainConfig cc = config.getChainConfig(chain);
if (cc == null) {
cc = new ChainConfigImpl(new TransformationConfigImpl(chain));
config.addChainConfig(cc);
}
}
}
}
if (StringUtils.isNotEmpty(path)) {
for (ChainConfig cc : config.getChainConfigs()) {
cc.setPath(path);
}
}
}
use of org.walkmod.conf.entities.impl.TransformationConfigImpl in project walkmod-core by walkmod.
the class LanguageConfigurationProviderTest method testNullOverwriting.
@Test
public void testNullOverwriting() {
LanguageConfigurationProvider provider = new LanguageConfigurationProvider();
Configuration conf = new ConfigurationImpl();
ChainConfig cc = new ChainConfigImpl();
cc.setName("test-chain");
ReaderConfig reader = new ReaderConfig();
WalkerConfig walker = new WalkerConfigImpl();
TransformationConfig transformation = new TransformationConfigImpl();
transformation.isMergeable(true);
List<TransformationConfig> transf = new LinkedList<TransformationConfig>();
transf.add(transformation);
walker.setParserConfig(new ParserConfigImpl());
walker.setTransformations(transf);
WriterConfig writer = new WriterConfigImpl();
cc.setReaderConfig(reader);
cc.setWalkerConfig(walker);
cc.setWriterConfig(writer);
conf.addChainConfig(cc);
provider.init(conf);
provider.load();
Assert.assertNotNull(reader.getPath());
Assert.assertNotNull(reader.getType());
Assert.assertNotNull(walker.getType());
Assert.assertNotNull(walker.getParserConfig().getType());
Assert.assertNotNull(writer.getPath());
Assert.assertNotNull(writer.getType());
Assert.assertNotNull(transformation.getMergePolicy());
Assert.assertNotNull(conf.getMergePolicies());
Collection<MergePolicyConfig> mergec = conf.getMergePolicies();
Assert.assertEquals(1, mergec.size());
MergePolicyConfig mpc = mergec.iterator().next();
Assert.assertNotNull(mpc.getDefaultObjectPolicy());
Assert.assertNotNull(mpc.getDefaultTypePolicy());
Map<String, String> entries = mpc.getPolicyEntries();
Assert.assertEquals(2, entries.size());
}
Aggregations