Mercurial > dive4elements > gnv-client
diff gnv-artifacts/src/main/java/de/intevation/gnv/artifacts/GNVArtifactBase.java @ 204:734ac082c8d1
Split the Configuration File in several small Documents to speed up the Artifactinstantiation and also make the administration of the Artifactdatabase easier. issue40 and issue59
gnv-artifacts/trunk@259 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Tim Englich <tim.englich@intevation.de> |
---|---|
date | Thu, 22 Oct 2009 08:50:21 +0000 |
parents | 00c1a931b9c3 |
children | d87347142702 |
line wrap: on
line diff
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/artifacts/GNVArtifactBase.java Wed Oct 21 11:10:28 2009 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/artifacts/GNVArtifactBase.java Thu Oct 22 08:50:21 2009 +0000 @@ -10,6 +10,8 @@ import java.util.Iterator; import java.util.Map; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.ParserConfigurationException; import javax.xml.xpath.XPathConstants; import org.apache.log4j.Logger; @@ -17,6 +19,7 @@ import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; +import org.xml.sax.SAXException; import de.intevation.artifactdatabase.Config; import de.intevation.artifactdatabase.DefaultArtifact; @@ -108,7 +111,7 @@ .get(transitionName); // 2.Ergebnisse Berechnen this.current.advance(uuid, context.getMeta()); - // 3. Ergebnisse übergeben + // 3. Ergebnisse Übergeben nextStep.setDescibeData(this.current .getDescibeData()); nextStep.putInputData(this.current.getInputData(), @@ -166,7 +169,34 @@ String xpathQuery = XPATH_ARTIFACT_CONFIGURATION.replaceAll( XPATH_IDENTIFIER_REPLACE, this.name); log.debug(xpathQuery); - return Config.getNodeXPath(document, xpathQuery); + + Element configurationNode = (Element)Config.getNodeXPath(document, xpathQuery); + + String link = configurationNode.getAttribute("xlink:href"); + if (link != null ){ + String absolutFileName = Config.replaceConfigDir(link); + configurationNode = (Element)this.readConfiguration(absolutFileName); + } + + return configurationNode; + } + + + private Node readConfiguration(String fileName){ + try { + DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); + factory.setValidating(false); + return factory.newDocumentBuilder().parse(fileName).getChildNodes().item(0); + } catch (SAXException e) { + log.error(e,e); + return null; + } catch (IOException e) { + log.error(e,e); + return null; + } catch (ParserConfigurationException e) { + log.error(e,e); + return null; + } } /** @@ -226,6 +256,7 @@ GNVArtifactContext gnvContext = (GNVArtifactContext) localContext; Document doc = gnvContext.getConfig(); Node artifactNode = this.getConfigurationFragment(doc); + NodeList transitionList = Config.getNodeSetXPath(artifactNode, "transitions/transition"); this.transitions = new HashMap<String, Transition>(transitionList @@ -403,9 +434,9 @@ returnValue = new HashMap<String, InputData>(inputElemets .getLength()); for (int i = 0; i < inputElemets.getLength(); i++) { - Node inputDataNode = inputElemets.item(i); - String name = Config.getStringXPath(inputDataNode, "@name"); - String value = Config.getStringXPath(inputDataNode, "@value"); + Element inputDataNode = (Element)inputElemets.item(i); + String name = inputDataNode.getAttribute("name"); + String value = inputDataNode.getAttribute("value"); if (returnValue.containsKey(name)) { InputData inputData = returnValue.get(name);