package uk.ac.ebi.quickgo.document.ontology;

import java.util.List;
import org.apache.solr.client.solrj.beans.Field;

/**
 * Solr document class defining all fields within the ontology core.
 *
 * See {@link http://docs.spring.io/spring-data/solr/docs/current/reference/html/}.
 *
 * TODO: Discuss
 * I have tried modelling multiple docTypes in different XDocument classes, using
 * basic inheritance/interfaces -- however, this does not work cleanly, and this
 * is not really the place for distinguishing different document types even though
 * they all reside within the same core.
 *
 *      We could possibly have multiple Repositories accessing the same core, for adding/retrieving different
 *      docTypes,
 *      e.g.,
 *      SynonymDocument/TermDocument. However, the CrudRepositories won't then work for queries that fetch
 *      information across multiple Repos (e.g., fetch synonyms for a term).
 *
 *      I believe we should retain a single OntologyRepository, which can have complex queries
 *      defined, spanning whatever docTypes we want. Then, at the service layer, we can
 *      transform results into whatever we want, on demand. I'd suggest transforming into
 *      DTOs. E.g., given results:
 *      [SynDoc1, TermDoc1, SynDoc2, TermDoc2] -> [SynModel1, TermModel1, SynModel2, TermModel2]
 *      where *Model is an object that can be produced from a *Doc object, e.g., using Spring's
 *      converter libraries.
 *
 *      See http://docs.spring.io/spring/docs/current/spring-framework-reference/html/validation.html
 *
 *      Moreover, the DTOs can then be handled at the REST layer, and serialized to whatever format required,
 *      on demand, e.g., json, xml, etc.
 *
 *
 * Created 11/11/15
 * @author Edd
 */
public class OntologyDocument {
    @Field
    public String id;
    @Field
    public String docType;
    @Field
    public String name;
    @Field
    public String ontology;
    @Field
    public String category;
    @Field
    public boolean isObsolete;
    @Field
    public String definition;
    @Field("definitionXref")
    public List<String> definitionXrefs;
    @Field
    public String comment;
    @Field("secondaryId")
    public List<String> secondaryIds;
}

@@ -39,16 +39,39 @@
 ology;%0A%0A
+import java.util.Date;%0A
 import j
@@ -1808,36 +1808,28 @@
     
-@Field%0A    public String id;
+// Basic information
 %0A   
@@ -1866,32 +1866,65 @@
 ype;%0A    @Field%0A
+    public String id;%0A    @Field%0A
     public Strin
@@ -2121,31 +2121,24 @@
 nXref%22)%0A    
-public 
 List%3CString%3E
@@ -2152,17 +2152,16 @@
 tionXref
-s
 ;%0A    @F
@@ -2222,23 +2222,16 @@
 d%22)%0A    
-public 
 List%3CStr
@@ -2248,11 +2248,1814 @@
 daryIds;
+%0A%0A    @Field%0A    public String version;%0A    @Field%0A    public String usage;%0A    @Field(%22credit%22)%0A    List%3CString%3E credits;%0A%0A    // Relations%0A//    @Field%0A//    public String child;%0A//    @Field%0A//    public String parent;%0A//    @Field%0A//    public String relationType;%0A%0A    // Synonyms%0A    @Field%0A    public String synonymName;%0A    @Field%0A    public String synonymType;%0A%0A    // Taxonomy Constraints%0A    @Field%0A    public String taxonConstraintRuleId;%0A    @Field%0A    public String taxonConstraintAncestorId;%0A    @Field%0A    public String taxonConstraintName;%0A    @Field%0A    public String taxonConstraintRelationship;%0A    @Field%0A    public String taxonConstraintTaxIdType;%0A    @Field%0A    public String taxonConstraintTaxId;%0A    @Field%0A    public String taxonConstraintTaxName;%0A    @Field(%22pubMedId%22)%0A    List%3CString%3E pubMedIds;%0A%0A    // Cross References%0A    @Field%0A    public String xrefDbCode;%0A    @Field%0A    public String xrefDbId;%0A    @Field%0A    public String xrefName;%0A%0A    // Replaces%0A    @Field%0A    public String obsoleteId;%0A    @Field%0A    public String reason;%0A%0A    // Annotation Guidelines%0A    @Field%0A    public String annotationGuidelineTitle;%0A    @Field%0A    public String annotationGuidelineUrl;%0A%0A    // Cross-ontology relations%0A    @Field%0A    public String crossOntologyRelation;%0A    @Field%0A    public String crossOntologyOtherNamespace;%0A    @Field%0A    public String crossOntologyForeignId;%0A    @Field%0A    public String crossOntologyForeignTerm;%0A    @Field%0A    public String crossOntologyUrl;%0A%0A    // Change log%0A    @Field%0A    public String historyName;%0A    @Field%0A    public Date historyTimeStamp;%0A    @Field%0A    public String historyAction;%0A    @Field%0A    public String historyCategory;%0A    @Field%0A    public String historyText;%0A%0A    // OBO Fields%0A    @Field(%22subset%22)%0A    List%3CString%3E subsets;
 %0A%7D%0A

add all fields (exception relation related -- these are likely to be stored externally in a file, loaded 1 time @ app startup) to ontology document