// Path: elmo/src/main/java/org/openprovenance/elmo/XMLLiteral.java
// public class XMLLiteral {
//     private static DocumentBuilder builder;
// 
//     private static Transformer transformer;
// 
//     private String xml;
// 
//     public XMLLiteral(String xml) {
//         this.xml = xml;
//     }
// 
//     public XMLLiteral(Document document) {
//         this.xml = serialize(document);
//     }
// 
//     public Document getDocument() {
//         return deserialize(xml);
//     }
// 
//     @Override
// 		public String toString() {
//         return xml;
//     }
// 
//     private String serialize(Document object) {
//         Source source = new DOMSource(object);
//         CharArrayWriter writer = new CharArrayWriter();
//         Result result = new StreamResult(writer);
//         try {
//             if (transformer == null) {
//                 transformer = TransformerFactory.newInstance()
//                     .newTransformer();
//             }
//             transformer.transform(source, result);
//         } catch (Exception e) {
//             throw new ElmoConversionException(e);
//         }
//         return writer.toString();
//     }
// 
//     private Document deserialize(String xml) {
//         try {
//             char[] charArray = xml.toCharArray();
//             CharArrayReader reader = new CharArrayReader(charArray);
//             try {
//                 if (builder == null) {
//                     DocumentBuilderFactory dbf=DocumentBuilderFactory.newInstance();
//                     dbf.setNamespaceAware(true);
//                     builder = dbf.newDocumentBuilder();
//                 }
//                 return builder.parse(new InputSource(reader));
//             } finally {
//                 reader.close();
//             }
//         } catch (Exception e) {
//             throw new ElmoConversionException(e);
//         }
//     }
// 
// }
// 
// Path: opm/src/main/java/org/openprovenance/model/Annotable.java
// public interface Annotable extends Identifiable {
//     public List<JAXBElement<? extends EmbeddedAnnotation>>  getAnnotation();
// } 
// 
// Path: opm/src/main/java/org/openprovenance/model/HasAccounts.java
// public interface HasAccounts {
//     List<AccountRef> getAccount();
// } 
// 
// Path: opm/src/main/java/org/openprovenance/model/Identifiable.java
// public interface Identifiable {
//     public void setId(String s);
//     public String getId();
// } 


import java.net.URI;
import java.util.Collection;
import java.util.Set;
import java.util.List;
import java.util.LinkedList;
import java.util.HashSet;
import java.util.Hashtable;
import javax.xml.bind.JAXBElement;
import javax.xml.namespace.QName;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.openrdf.elmo.ElmoManager;
import org.openprovenance.elmo.XMLLiteral;
import org.openprovenance.model.Account;
import org.openprovenance.model.AccountRef;
import org.openprovenance.model.Agent;
import org.openprovenance.model.Annotable;
import org.openprovenance.model.Annotation;
import org.openprovenance.model.Artifact;
import org.openprovenance.model.EmbeddedAnnotation;
import org.openprovenance.model.HasAccounts;
import org.openprovenance.model.Identifiable;
import org.openprovenance.model.Label;
import org.openprovenance.model.OPMGraph;
import org.openprovenance.model.Process;
import org.openprovenance.model.Property;
import org.openprovenance.model.Type;
import org.openprovenance.model.Used;
import org.openprovenance.model.Value;
import org.openprovenance.model.WasControlledBy;
import org.openprovenance.model.WasDerivedFrom;
import org.openprovenance.model.WasGeneratedBy;
import org.openprovenance.model.WasTriggeredBy;
import org.openprovenance.rdf.AnnotationOrEdgeOrNode;
import org.openrdf.elmo.Entity;
        Object o=((HasFacade) ann).findMyFacade();
        org.openprovenance.rdf.Annotation ann2=(org.openprovenance.rdf.Annotation) o;
        org.openprovenance.rdf.Property p2=(org.openprovenance.rdf.Property) ((HasFacade)p).findMyFacade();
        ann2.getProperties().add(p2);
    }

    public void addProperty(Annotation ann, Property p) {
        super.addProperty(ann,p);
        Object o=((HasFacade) ann).findMyFacade();
        org.openprovenance.rdf.Annotation ann2=(org.openprovenance.rdf.Annotation) o;
        org.openprovenance.rdf.Property p2=(org.openprovenance.rdf.Property) ((HasFacade)p).findMyFacade();
        ann2.getProperties().add(p2);
    }

    public void addAccounts(HasAccounts element, Collection<AccountRef> accounts) {
        super.addAccounts(element,accounts);
        if (element instanceof HasAccounts) { //Annotable
            HasFacade facade=(HasFacade) element;
            Object o=facade.findMyFacade();
            AnnotationOrEdgeOrNode el=(AnnotationOrEdgeOrNode) o;

            Set set=new HashSet();
            for (AccountRef accr: accounts) {
                set.add(((HasFacade)accr.getRef()).findMyFacade());
            }
            el.getAccounts().addAll(set);
            //el.setAccounts(set);
        }
    }

// Path: elmo/src/main/java/org/openprovenance/elmo/XMLLiteral.java
// public class XMLLiteral {
//     private static DocumentBuilder builder;
// 
//     private static Transformer transformer;
// 
//     private String xml;
// 
//     public XMLLiteral(String xml) {
//         this.xml = xml;
//     }
// 
//     public XMLLiteral(Document document) {
//         this.xml = serialize(document);
//     }
// 
//     public Document getDocument() {
//         return deserialize(xml);
//     }
// 
//     @Override
// 		public String toString() {
//         return xml;
//     }
// 
//     private String serialize(Document object) {
//         Source source = new DOMSource(object);
//         CharArrayWriter writer = new CharArrayWriter();
//         Result result = new StreamResult(writer);
//         try {
//             if (transformer == null) {
//                 transformer = TransformerFactory.newInstance()
//                     .newTransformer();
//             }
//             transformer.transform(source, result);
//         } catch (Exception e) {
//             throw new ElmoConversionException(e);
//         }
//         return writer.toString();
//     }
// 
//     private Document deserialize(String xml) {
//         try {
//             char[] charArray = xml.toCharArray();
//             CharArrayReader reader = new CharArrayReader(charArray);
//             try {
//                 if (builder == null) {
//                     DocumentBuilderFactory dbf=DocumentBuilderFactory.newInstance();
//                     dbf.setNamespaceAware(true);
//                     builder = dbf.newDocumentBuilder();
//                 }
//                 return builder.parse(new InputSource(reader));
//             } finally {
//                 reader.close();
//             }
//         } catch (Exception e) {
//             throw new ElmoConversionException(e);
//         }
//     }
// 
// }
// 
// Path: opm/src/main/java/org/openprovenance/model/Annotable.java
// public interface Annotable extends Identifiable {
//     public List<JAXBElement<? extends EmbeddedAnnotation>>  getAnnotation();
// } 
// 
// Path: opm/src/main/java/org/openprovenance/model/HasAccounts.java
// public interface HasAccounts {
//     List<AccountRef> getAccount();
// } 
// 
// Path: opm/src/main/java/org/openprovenance/model/Identifiable.java
// public interface Identifiable {
//     public void setId(String s);
//     public String getId();
// } 


// Path: elmo/src/main/java/org/openprovenance/elmo/RdfOPMFactory.java
import java.net.URI;
import java.util.Collection;
import java.util.Set;
import java.util.List;
import java.util.LinkedList;
import java.util.HashSet;
import java.util.Hashtable;
import javax.xml.bind.JAXBElement;
import javax.xml.namespace.QName;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.openrdf.elmo.ElmoManager;
import org.openprovenance.elmo.XMLLiteral;
import org.openprovenance.model.Account;
import org.openprovenance.model.AccountRef;
import org.openprovenance.model.Agent;
import org.openprovenance.model.Annotable;
import org.openprovenance.model.Annotation;
import org.openprovenance.model.Artifact;
import org.openprovenance.model.EmbeddedAnnotation;
import org.openprovenance.model.HasAccounts;
import org.openprovenance.model.Identifiable;
import org.openprovenance.model.Label;
import org.openprovenance.model.OPMGraph;
import org.openprovenance.model.Process;
import org.openprovenance.model.Property;
import org.openprovenance.model.Type;
import org.openprovenance.model.Used;
import org.openprovenance.model.Value;
import org.openprovenance.model.WasControlledBy;
import org.openprovenance.model.WasDerivedFrom;
import org.openprovenance.model.WasGeneratedBy;
import org.openprovenance.model.WasTriggeredBy;
import org.openprovenance.rdf.AnnotationOrEdgeOrNode;
import org.openrdf.elmo.Entity;

        Object o=((HasFacade) ann).findMyFacade();
        org.openprovenance.rdf.Annotation ann2=(org.openprovenance.rdf.Annotation) o;
        org.openprovenance.rdf.Property p2=(org.openprovenance.rdf.Property) ((HasFacade)p).findMyFacade();
        ann2.getProperties().add(p2);
    }

    public void addProperty(Annotation ann, Property p) {
        super.addProperty(ann,p);
        Object o=((HasFacade) ann).findMyFacade();
        org.openprovenance.rdf.Annotation ann2=(org.openprovenance.rdf.Annotation) o;
        org.openprovenance.rdf.Property p2=(org.openprovenance.rdf.Property) ((HasFacade)p).findMyFacade();
        ann2.getProperties().add(p2);
    }

    public void addAccounts(HasAccounts element, Collection<AccountRef> accounts) {
        super.addAccounts(element,accounts);
        if (element instanceof HasAccounts) { //Annotable
            HasFacade facade=(HasFacade) element;
            Object o=facade.findMyFacade();
            AnnotationOrEdgeOrNode el=(AnnotationOrEdgeOrNode) o;

            Set set=new HashSet();
            for (AccountRef accr: accounts) {
                set.add(((HasFacade)accr.getRef()).findMyFacade());
            }
            el.getAccounts().addAll(set);
            //el.setAccounts(set);
        }
    }

    public void addAnnotation(Annotable annotable,