package DBFOschemafy_V_3_001;

/**
 *  <b>Environment:</b> 
 *  <ul>
 *  <li>    IDE:              Eclipse IDE for Java Developers
 *  <li>    Version:          2021-12 (4.22.0)
 *  <li>    Build id:         20211202-1639
 *  <li>    HW Model Name:    iMac, MacOS Monterey, 12.5.1
 *  <li>    Processor Name:   Quad-Core Intel Core i5
 *  <li>    Processor Speed:  3.2 GHz
 *  <li>    Memory:           32 GB 1867 MHz DDR3
 *  <li>    Disk:             APPLE SSD SM0256G    
 *  <li>    Serial:           DGKRC080GG7V
 *  <li>    RDB:              MySQL Server (Version 8.0.30), 
 *  <li>    Workbench:        MySQL Workbench (Version 8.0.31 build 2235049 CE (64 bits) Community)
 *  <li>    JDBC connector:   mysql-connector-j-9.1.0.jar
 *  </ul>
 *  @version 1-001
 *  @since   2024/11/27
 *  @author  Edit Hlaszny PhD (https://www.edithlaszny.eu/) 
 */

public class SharedUtils 
{
	    	/**
	     *  W3C-defined separator between IRI and unique variable names
	     */
    private final String  SEPARATOR = "#" ;

    SharedUtils()
    {
        ; 
        
    }   //  end of constructor()

    public String assertClassAnnotation(String class_IRI,
                                        String annotation_type_IRI,
                                        String language,
                                        String annotation
                                       )
    {
        return  "    <AnnotationAssertion>\n" +
                "        <AnnotationProperty abbreviatedIRI=\"" + annotation_type_IRI  + "\"/>\n" +
                "        <IRI>" + this.SEPARATOR + class_IRI + "</IRI>\n" +
                "        <Literal xml:lang=\"" + language + "\">" + annotation + "</Literal>\n" +
                "    </AnnotationAssertion>\n" ;
        
    }   //  end of method assertClassAnnotation()

    /**
     *  Declares OWL subclass according to OWL2 XML Syntax
     *  
     *  @param superClass Name of the OWL superclass
     *  @param subClass Name of the OWL subclass
     *  
     *  @return XML code snippet     
     */
    public String declareSubClass(String superClass, 
                                  String subClass
                                 ) 
    {
        /**
         *  compensating the Protege's displaying error
         */
        if (superClass.equals("owl:Thing")) 
            return "" ;
        
        return "    <SubClassOf>\n" +
               "        <Class IRI=\"" + SEPARATOR + subClass   + "\"/>\n" +
               "        <Class IRI=\"" + SEPARATOR + superClass + "\"/>\n" +
               "    </SubClassOf>\n" ;
        
    }   //  end of method declareSubClass_2()
    
    public String declareClass(String class_IRI)
    {
        return  "    <Declaration>\n" +
                "        <Class IRI=\"" + SEPARATOR + class_IRI + "\"/>\n" +
                "    </Declaration>\n" ;

    }   //  end of method declareClass_2()
    
    public String addHdrAnnotation(String iri,
                                   String literal
                                  )
    {
        return "    <Annotation>\n" +
               "        <AnnotationProperty abbreviatedIRI=\"" + iri + "\"/>\n" +
               "        <Literal>" + literal + "</Literal>\n" +
               "    </Annotation>\n" ;
               
    }   //  end of addHdrAnnotation()
        
    public String declareIAOannotation(String abbreviated_IRI)
    {
        return  "    <Declaration>\n" +
                "        <AnnotationProperty abbreviatedIRI=\"" + abbreviated_IRI + "\"/>\n" +
                "    </Declaration>\n" ;

    }   //  end of method declareIAOannotation()
    
    public String addIAOannotation(String abbreviated_IRI,
                                   String annotation_literal,
                                   String language
                                  )
    {
        return  "    <AnnotationAssertion>\n" +
                "        <AnnotationProperty abbreviatedIRI=\"rdfs:label\"/>\n" +
                "        <AbbreviatedIRI>" + abbreviated_IRI + "</AbbreviatedIRI>\n" +
                "        <Literal xml:lang=\"" + language + "\">" + annotation_literal + "</Literal>\n" +
                "    </AnnotationAssertion>\n" ;
        
    }   //  end of method addIAOannotation()

    public String declareObjectproperty(String objectProperty)
    {
         return
         "    <Declaration>\n" +
         "        <ObjectProperty IRI=\"" + this.SEPARATOR + objectProperty + "\"/>\n" +
         "    </Declaration>\n" ;

    }   //  end of method declareObjectproperty()
    
    public String setSubObjectPropertyOf(String objectProperty,
                                         String superObjectProperty
                                        )
    {
        if (superObjectProperty.equals("owl:topObjectProperty") == false)
        {
            /**
             *  if the superObjectProperty is NOT the 'owl:topObjectProperty' than
             *  must be prefixed with the SEPARATOR
             */
            superObjectProperty = this.SEPARATOR + superObjectProperty ;
        }
        
        return
        "    <SubObjectPropertyOf>\n" +
        "        <ObjectProperty IRI=\"" + this.SEPARATOR + objectProperty + "\"/>\n" +
        "        <ObjectProperty abbreviatedIRI=\"" +  superObjectProperty + "\"/>\n" +
        "    </SubObjectPropertyOf>\n" ;

    }   //  end of method setSubObjectPropertyOf()
    
    public String annotateObjectProperty(String object_property_IRI,
                                         String annotation_type_IRI,
                                         String language           ,
                                         String annotation
                                        )
    {
        return
        "    <AnnotationAssertion>\n" +
        "        <AnnotationProperty abbreviatedIRI=\"" + annotation_type_IRI + "\"/>\n" +
        "        <IRI>" + this.SEPARATOR + object_property_IRI + "</IRI>\n" +
        "        <Literal xml:lang=\"" + language + "\">\"" + annotation + "\"\n" +
        "        </Literal>\n" +
        "    </AnnotationAssertion>\n" ;
            
    }   //  end of method annotateObjectProperty() 
    
    public String setInverseObjectProperties(String objProp_IRI_1,
                                             String objProp_IRI_2
                                            )
    {
        return
        "    <InverseObjectProperties>\n" + 
        "        <ObjectProperty IRI=\"" + this.SEPARATOR + objProp_IRI_1 + "\"/>\n" +
        "        <ObjectProperty IRI=\"" + this.SEPARATOR + objProp_IRI_2 + "\"/>\n" +
        "    </InverseObjectProperties>" ;
        
    }   //  end of method setInverseObjectProperties()

    public String declareIndividual(String namedIndividual)
    {
        return
        "    <Declaration>\n" +
        "        <NamedIndividual IRI=\"" + this.SEPARATOR + namedIndividual + "\"/>\n" +
        "    </Declaration>\n" ;

    }   // end of method declareIndividual()

    public String assertIndividual(String classIRI,
                                   String namedIndividual)
    {
        return
        "    <ClassAssertion>\n" +
        "        <Class IRI=\"" + this.SEPARATOR + classIRI + "\"/>\n" +
        "        <NamedIndividual IRI=\"" + this.SEPARATOR + namedIndividual + "\"/>\n" +
        "    </ClassAssertion>\n" ;

    }   // end of method assertIndividual()

    public String classAssertion(String namedIndividual,
                                 String annotation)
    {
        return 
        "    <AnnotationAssertion>\n" +
        "        <AnnotationProperty abbreviatedIRI=\"obo:IAO_0000115\"/>\n" +
        "        <IRI>" + this.SEPARATOR + namedIndividual + "</IRI>\n" +
        "        <Literal>" + annotation + "</Literal>\n" +
        "    </AnnotationAssertion>\n" ;

    }   // end of method classAssertion()

    public String assertObjectProperty(String objectProperty,
                                       String subjectIndividual,
                                       String objectIndividual)
    {
        return 
        "    <ObjectPropertyAssertion>\n" +
        "        <ObjectProperty  IRI=\"" + this.SEPARATOR + objectProperty + "\"/>\n" +     
        "        <NamedIndividual IRI=\"" + this.SEPARATOR + subjectIndividual + "\"/>\n" +  
        "        <NamedIndividual IRI=\"" + this.SEPARATOR + objectIndividual + "\"/>\n" +   
        "    </ObjectPropertyAssertion>\n" ;

    }   // end of method assertObjectProperty()

    public String declareDataProperty(String dataProperty)
    {
        return
        "    <Declaration>\n" +
        "        <DataProperty IRI=\"" + this.SEPARATOR + dataProperty + "\"/>\n" +
        "    </Declaration>\n" ;

    }   // end of method declareDataProperty()

    public String declareDataSubProperty(String dataProperty,
                                         String superDataProperty
                                        )
    {
        return
        "    <SubDataPropertyOf>\n" +
        "        <DataProperty IRI=\"" + this.SEPARATOR + dataProperty + "\"/>\n" +
        "        <DataProperty abbreviatedIRI=\"" + superDataProperty + "\"/>\n" +
        "    </SubDataPropertyOf>\n" ;

    }   // end of method declareDataSubProperty()

    public String annotateDataProperty(String dataProperty,
                                       String annotation,
                                       String annotationType,
                                       String language
                                      )
    {
        return
        "    <AnnotationAssertion>\n" +
        "        <AnnotationProperty abbreviatedIRI=\"" + annotationType + "\"/>\n" +
        "        <IRI>" + this.SEPARATOR + dataProperty + "</IRI>\n" +
        "        <Literal xml:lang=\"" + language + "\">" + annotation + "</Literal>\n" +
        "    </AnnotationAssertion>\n" ;

    }   // end of method annotateDataProperty()

    public String assertDataProperty(String dataProperty,
                                     String namedIndividual,
                                     String dataType,
                                     String dataValue
                                    )
    {   //  call it AFTER a triplet definition !

        return
        "    <DataPropertyAssertion>\n" +
        "        <DataProperty IRI=\"" + this.SEPARATOR + dataProperty + "\"/>\n" +
        "        <NamedIndividual IRI=\"" + this.SEPARATOR + namedIndividual + "\"/>\n" +
        "        <Literal datatypeIRI=\"" + dataType + "\">" + dataValue + "</Literal>\n" +
        "    </DataPropertyAssertion>\n" ;

    }   // end of method assertDataProperty()
    
}   //  end of class SharedUtils
