use of org.walkmod.conf.entities.impl.ParserConfigImpl in project walkmod-core by walkmod.
the class AbstractChainConfigurationProvider method addDefaultWalker.
public void addDefaultWalker(ChainConfig ac) {
WalkerConfig wc = new WalkerConfigImpl();
wc.setType(null);
wc.setParserConfig(new ParserConfigImpl());
ac.setWalkerConfig(wc);
}
use of org.walkmod.conf.entities.impl.ParserConfigImpl in project walkmod-core by walkmod.
the class JSONConfigParser method getWalker.
public WalkerConfig getWalker(JsonNode current) {
WalkerConfig walkerCfg = new WalkerConfigImpl();
if (current.has("type")) {
walkerCfg.setType(current.get("type").asText());
}
if (current.has("parser")) {
ParserConfig parserCfg = new ParserConfigImpl();
JsonNode parserNode = current.get("parser");
parserCfg.setType(parserNode.get("type").asText());
parserCfg.setParameters(getParams(parserNode));
walkerCfg.setParserConfig(parserCfg);
}
walkerCfg.setTransformations(getTransformationCfgs(current));
if (current.has("root-namespace")) {
walkerCfg.setRootNamespace(current.get("root-namespace").asText());
}
walkerCfg.setParams(getParams(current));
return walkerCfg;
}
use of org.walkmod.conf.entities.impl.ParserConfigImpl in project walkmod-core by walkmod.
the class XMLConfigurationProvider method loadWalkerConfig.
public void loadWalkerConfig(Element element, ChainConfig ac) {
NodeList children;
Node walkerNode = element;
if ("walker".equals(walkerNode.getNodeName())) {
WalkerConfig wc = new WalkerConfigImpl();
String type = ((Element) walkerNode).getAttribute("type");
if ("".equals(type)) {
wc.setType(null);
} else {
wc.setType(type);
}
wc.setParams(getParams((Element) walkerNode));
wc.setRootNamespace(((Element) walkerNode).getAttribute("root-namespace"));
children = walkerNode.getChildNodes();
if (children.getLength() > 3) {
throw new ConfigurationException("Invalid walker definition in the " + "architecture" + ac.getName() + ". Please, verify the dtd");
}
int max = children.getLength();
int transformationIndex = wc.getParams().size();
if (transformationIndex < max) {
final String nodeName = children.item(transformationIndex).getNodeName();
if (("parser").equals(nodeName)) {
loadParserConfig((Element) children.item(transformationIndex), wc);
transformationIndex = 1;
} else {
wc.setParserConfig(new ParserConfigImpl());
}
} else {
wc.setParserConfig(new ParserConfigImpl());
}
if (transformationIndex < max) {
loadTransformationConfigs((Element) children.item(transformationIndex), wc);
}
ac.setWalkerConfig(wc);
} else {
throw new ConfigurationException("Invalid architecture definition. " + "A walker element must be defined in the architecture element " + ac.getName());
}
}
use of org.walkmod.conf.entities.impl.ParserConfigImpl in project walkmod-core by walkmod.
the class XMLConfigurationProvider method loadChains.
public void loadChains() throws ConfigurationException {
Element rootElement = document.getDocumentElement();
NodeList children = rootElement.getChildNodes();
int childSize = children.getLength();
for (int i = 0; i < childSize; i++) {
Node childNode = children.item(i);
if (childNode instanceof Element) {
Element child = (Element) childNode;
final String nodeName = child.getNodeName();
if ("chain".equals(nodeName)) {
ChainConfig ac = new ChainConfigImpl();
if ("".equals(child.getAttribute("name"))) {
if (i == 0) {
ac.setName("chain_" + (i + 1));
} else {
ac.setName("chain_" + (i + 1));
}
} else {
ac.setName(child.getAttribute("name"));
}
NodeList childrenModel = child.getChildNodes();
ac.setParameters(getParams(child));
int index = 0;
if ("reader".equals(childrenModel.item(index).getNodeName())) {
loadReaderConfig((Element) childrenModel.item(index), ac);
index++;
} else {
addDefaultReaderConfig(ac);
}
if (index >= childrenModel.getLength()) {
throw new ConfigurationException("Invalid architecture definition for the " + "element" + ac.getName());
}
if ("walker".equals(childrenModel.item(index).getNodeName())) {
loadWalkerConfig((Element) childrenModel.item(index), ac);
index++;
} else if ("transformation".equals(childrenModel.item(index).getNodeName())) {
addDefaultWalker(ac, child);
} else {
throw new ConfigurationException("Invalid transformation chain. A walker or at least one transformation must be specified");
}
if (index > childrenModel.getLength()) {
throw new ConfigurationException("Invalid architecture definition for the " + "element" + ac.getName());
}
boolean found = false;
while (index < childrenModel.getLength() && !found) {
if ("writer".equals(childrenModel.item(index).getNodeName())) {
found = true;
loadWriter((Element) childrenModel.item(index), ac);
}
index++;
}
if (!found) {
addDefaultWriterConfig(ac);
}
configuration.addChainConfig(ac);
} else if ("transformation".equals(nodeName)) {
ChainConfig ac = new ChainConfigImpl();
ac.setName("default");
List<TransformationConfig> transformationConfigs = getTransformationItems(rootElement, true);
WalkerConfig wc = new WalkerConfigImpl();
wc.setType(null);
wc.setParserConfig(new ParserConfigImpl());
wc.setTransformations(transformationConfigs);
addDefaultReaderConfig(ac);
ac.setWalkerConfig(wc);
addDefaultWriterConfig(ac);
configuration.addChainConfig(ac);
i = i + transformationConfigs.size() - 1;
}
}
}
LOG.debug("Transformation chains loaded");
}
use of org.walkmod.conf.entities.impl.ParserConfigImpl in project walkmod-core by walkmod.
the class XMLConfigurationProvider method loadParserConfig.
public void loadParserConfig(Element element, WalkerConfig wc) {
final String nodeName = element.getNodeName();
if ("parser".equals(nodeName)) {
ParserConfig pc = new ParserConfigImpl();
if ("".equals(element.getAttribute("type"))) {
pc.setType(null);
} else {
pc.setType(element.getAttribute("type"));
}
pc.setParameters(getParams(element));
}
}
Aggregations