View Javadoc

1   package org.kuali.ole.ingest;
2   
3   import com.thoughtworks.xstream.XStream;
4   import org.kuali.ole.ingest.pojo.*;
5   
6   import java.io.IOException;
7   import java.net.URISyntaxException;
8   
9   /**
10   * KrmsObjectGeneratorFromXML is for converting the string fileContent into Krms object
11   */
12  public class KrmsObjectGeneratorFromXML {
13      /**
14       *  This method returns Krms object from fileContent.
15       *  The xStream will convert the fileContent into Krms Object.
16       * @param fileContent
17       * @return Krms object
18       * @throws java.net.URISyntaxException
19       * @throws java.io.IOException
20       */
21      public Krms buildKrmsFromFileContent(String fileContent) throws URISyntaxException, IOException {
22          XStream xStream = new XStream();
23          xStream.alias("krms", Krms.class);
24          xStream.alias("agenda", OleAgenda.class);
25          xStream.alias("attribute", ProfileAttributeBo.class);
26          xStream.alias("rule", KrmsRule.class);
27          xStream.alias("proposition",KrmsProposition.class);
28          xStream.alias("compoundProposition",OleProposition.class);
29          xStream.alias("action", KrmsAction.class);
30          xStream.addImplicitCollection(Krms.class,"oleAgendaList");
31          xStream.addImplicitCollection(OleProposition.class,"propositions",KrmsProposition.class);
32          xStream.addImplicitCollection(OleProposition.class,"olePropositions",OleProposition.class);
33          xStream.registerConverter(new ProfileAttributeConverter());
34          Object object = xStream.fromXML(fileContent);
35          return (Krms) object;
36      }
37  }