001package org.kuali.ole.ingest; 002 003import com.thoughtworks.xstream.XStream; 004import org.kuali.ole.ingest.pojo.*; 005 006import java.io.IOException; 007import java.net.URISyntaxException; 008 009/** 010 * KrmsObjectGeneratorFromXML is for converting the string fileContent into Krms object 011 */ 012public class KrmsObjectGeneratorFromXML { 013 /** 014 * This method returns Krms object from fileContent. 015 * The xStream will convert the fileContent into Krms Object. 016 * @param fileContent 017 * @return Krms object 018 * @throws java.net.URISyntaxException 019 * @throws java.io.IOException 020 */ 021 public Krms buildKrmsFromFileContent(String fileContent) throws URISyntaxException, IOException { 022 XStream xStream = new XStream(); 023 xStream.alias("krms", Krms.class); 024 xStream.alias("agenda", OleAgenda.class); 025 xStream.alias("attribute", ProfileAttributeBo.class); 026 xStream.alias("rule", KrmsRule.class); 027 xStream.alias("proposition",KrmsProposition.class); 028 xStream.alias("compoundProposition",OleProposition.class); 029 xStream.alias("action", KrmsAction.class); 030 xStream.addImplicitCollection(Krms.class,"oleAgendaList"); 031 xStream.addImplicitCollection(OleProposition.class,"propositions",KrmsProposition.class); 032 xStream.addImplicitCollection(OleProposition.class,"olePropositions",OleProposition.class); 033 xStream.registerConverter(new ProfileAttributeConverter()); 034 Object object = xStream.fromXML(fileContent); 035 return (Krms) object; 036 } 037}