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