1 package org.kuali.ole.ingest.krms.builder;
2
3 import com.thoughtworks.xstream.XStream;
4 import org.kuali.ole.ingest.krms.pojo.*;
5
6 import java.io.IOException;
7 import java.net.URISyntaxException;
8
9
10
11
12
13
14
15
16 public class OleKrmsObjectGeneratorFromXML {
17
18
19
20
21
22
23
24
25 public OleKrms buildKrmsFromFileContent(String fileContent) throws URISyntaxException, IOException {
26 XStream xStream = new XStream();
27 xStream.alias("agendas", OleKrms.class);
28 xStream.alias("agenda", OleKrmsAgenda.class);
29 xStream.alias("rule", OleKrmsRule.class);
30 xStream.alias("oleProposition",OleKrmsProposition.class);
31 xStream.alias("simpleProposition",OleSimpleProposition.class);
32 xStream.alias("compoundProposition",OleCompoundProposition.class);
33 xStream.alias("action", OleKrmsAction.class);
34 xStream.alias("value", OleValue.class);
35 xStream.alias("term", OleTerm.class);
36 xStream.addImplicitCollection(OleKrms.class,"agendas");
37 xStream.addImplicitCollection(OleCompoundProposition.class,"simplePropositions",OleSimpleProposition.class);
38 xStream.addImplicitCollection(OleCompoundProposition.class,"compoundPropositions",OleCompoundProposition.class);
39 xStream.addImplicitCollection(OleKrmsRuleAction.class,"krmsActions",OleKrmsAction.class);
40 xStream.addImplicitCollection(OleKrmsRuleAction.class,"krmsRules",OleKrmsRule.class);
41 xStream.addImplicitCollection(OleSimpleProposition.class,"terms",OleTerm.class);
42 Object object = xStream.fromXML(fileContent);
43 return (OleKrms) object;
44 }
45 }