Hi,
I am using a transform template to convert data from a database to CSV, XLS or XLSX files for output. This is linked in my app to a “Template builder” that determines which fields from the database the user wants to select. Once the user has “described” the fields, I want to construct a graph based on the template builder.
Steps I want to use are:
- Convert template to Metadata fields
- use CSV or XLS(X) writer
- Store constructed graph XML in database for later use.
Reading lists and docos, I think the easiest way to do this is to construct the graph XML file based on a partial template (dB reader, transformer) and specific records based on the user selected fields. This would mean I create metadata and a CSV/XLS node.
I have seen that there are DTDs for the graph and was wondering if you have a complete listing of these DTDs. I have bits and pieces from the lists and howtos
Thanks
Des
I discovered there was a XSD, so looking at that rather,
Thanks
Des
ok, so had a look at XSD and this is what I am after, except that I need to understand if there is a way to Marshall the TransformationGraph object using the XSD
It seems JAXB is the way to do it, but was wondering if Clover has a build in way of doing this?
TransformationGraphXMLReaderWriter.write seems to something in this direction, but from the posts it does not appear to be supported.
Thanks
Des
I have been fiddling around a bit with JAXB, but no luck. Here is what I tried. Would you be able to help me out on how to construct an XML representation of the transformationGraph again?
FileInputStream graphXMLFile;
try {
graphXMLFile = new FileInputStream(MAIN_GRAPH);
GraphRuntimeContext graphRuntimeContext = new GraphRuntimeContext();
TransformationGraph mainGraph = TransformationGraphXMLReaderWriter.loadGraph(graphXMLFile, graphRuntimeContext);
// Now we have the Java Object mainGraph.
// Convert it back to XML using JAXB
try {
JAXBContext jc = JAXBContext.newInstance(TransformationGraph.class);
Marshaller m = jc.createMarshaller();
m.marshal(mainGraph, System.out);
} catch (JAXBException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Result I get is
INFO [main] - Checking graph configuration…
com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException: 4 counts of IllegalAnnotationExceptions
org.jetel.graph.runtime.WatchDog does not have a no-arg default constructor.
this problem is related to the following location:
at org.jetel.graph.runtime.WatchDog
at public org.jetel.graph.runtime.WatchDog org.jetel.graph.TransformationGraph.getWatchDog()
at org.jetel.graph.TransformationGraph
org.jetel.graph.runtime.IThreadManager is an interface, and JAXB can’t handle interfaces.
this problem is related to the following location:
at org.jetel.graph.runtime.IThreadManager
at public org.jetel.graph.runtime.IThreadManager org.jetel.graph.runtime.WatchDog.getThreadManager()
at org.jetel.graph.runtime.WatchDog
at public org.jetel.graph.runtime.WatchDog org.jetel.graph.TransformationGraph.getWatchDog()
at org.jetel.graph.TransformationGraph
org.jetel.graph.runtime.IThreadManager does not have a no-arg default constructor.
this problem is related to the following location:
at org.jetel.graph.runtime.IThreadManager
at public org.jetel.graph.runtime.IThreadManager org.jetel.graph.runtime.WatchDog.getThreadManager()
at org.jetel.graph.runtime.WatchDog
at public org.jetel.graph.runtime.WatchDog org.jetel.graph.TransformationGraph.getWatchDog()
at org.jetel.graph.TransformationGraph
org.jetel.graph.GraphElement does not have a no-arg default constructor.
this problem is related to the following location:
at org.jetel.graph.GraphElement
at org.jetel.graph.TransformationGraph
at com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException$Builder.check(IllegalAnnotationsException.java:91)
at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.getTypeInfoSet(JAXBContextImpl.java:436)
at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.(JAXBContextImpl.java:277)
at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl$JAXBContextBuilder.build(JAXBContextImpl.java:1100)
at com.sun.xml.internal.bind.v2.ContextFactory.createContext(ContextFactory.java:143)
at com.sun.xml.internal.bind.v2.ContextFactory.createContext(ContextFactory.java:110)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:202)
at javax.xml.bind.ContextFinder.find(ContextFinder.java:376)
at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:574)
at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:522)
at com.wl.cfx.Main.runETL(Main.java:53)
at com.wl.cfx.Main.main(Main.java:112)
Hello Des,
unfortunately storing graph into xml doesn’t work and can’t be done with Clover ETL. You would write your own serializer.
You need to transform your graph as xml document - so to work directly with graph file or with org.w3c.dom.Document.