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