Difference between revisions of "Concept:Action/Java"

From BITPlan royal-family Wiki
Jump to navigation Jump to search
(created by WikiTask 2017-10-03T17:25:05Z)
 
m (created by WikiTask 2019-10-11T04:57:42Z)
 
Line 37: Line 37:
  
 
     /**
 
     /**
     * get the propertySidif of the given property
+
     * get the SiDIF representation of the given property
 
     *  
 
     *  
     * @param name
+
     * @param name - the name of the property
     * @param value
+
     * @param value - the value of the property
     * @return
+
    * @param type - the type of the property
 +
     * @return - the SiDIF Sting representation of the property
 
     */
 
     */
 
     public static String propertySiDIF(String name, String value, String type) {
 
     public static String propertySiDIF(String name, String value, String type) {
       // default is an empty string - no property line for emtpy values
+
       // default is a comment line which can be filled by uncommenting
       String result = "";
+
       String result = String.format("# is is %s of it\n",name);;
 
       // if the value is not empty
 
       // if the value is not empty
 
       if ((value != null) && (!("".equals(value.trim())))) {
 
       if ((value != null) && (!("".equals(value.trim())))) {
Line 56: Line 57:
 
         // create a SIDIF Property line like
 
         // create a SIDIF Property line like
 
         // "John" is lastname of it
 
         // "John" is lastname of it
         result += quote + value + quote + " is " + name + " of it\n";
+
         // convert double quotes to single quotes - FIXME - should we escape instead?
 +
        value=value.replace("\"","'");
 +
        result = String.format("%s%s%s is %s of it\n",quote,value,quote,name);
 
       }
 
       }
 
       // return the SiDIF property line
 
       // return the SiDIF property line
Line 96: Line 99:
 
   } // TopicBase
 
   } // TopicBase
 
  /**
 
  /**
   * Context
+
   * SMW_Type
   * A Context groups some topics like a Namespace/Package
+
   * an SMW_Type is a data type which determines the possible values for that type e.g. a Boolean can hold true/false values while a Number can hold 3.1459 or 20. A Page can hold the name of a Wiki page see https://semantic-mediawiki.org/wiki/Help:List_of_datatypes
 
   */
 
   */
   public static class Context extends TopicBase {
+
   public static class SMW_Type extends TopicBase {
 
    
 
    
     public String name;
+
     public String type;
     public String since;
+
     public String typepage;
     public String master;
+
     public String usedByProperties;
 +
    public String documentation;
 +
    public String helppage;
 +
    public String javaType;
 +
    public String id;
  
     public String getName() { return name; }
+
     public String getType() { return type; }
     public void setName(String pName) { name=pName; }
+
     public void setType(String pType) { type=pType; }
     public String getSince() { return since; }
+
     public String getTypepage() { return typepage; }
     public void setSince(String pSince) { since=pSince; }
+
     public void setTypepage(String pTypepage) { typepage=pTypepage; }
     public String getMaster() { return master; }
+
     public String getUsedByProperties() { return usedByProperties; }
     public void setMaster(String pMaster) { master=pMaster; }
+
     public void setUsedByProperties(String pUsedByProperties) { usedByProperties=pUsedByProperties; }
 +
    public String getDocumentation() { return documentation; }
 +
    public void setDocumentation(String pDocumentation) { documentation=pDocumentation; }
 +
    public String getHelppage() { return helppage; }
 +
    public void setHelppage(String pHelppage) { helppage=pHelppage; }
 +
    public String getJavaType() { return javaType; }
 +
    public void setJavaType(String pJavaType) { javaType=pJavaType; }
 +
    public String getId() { return id; }
 +
    public void setId(String pId) { id=pId; }
 
     /**
 
     /**
     * convert this Context to a JSON string
+
     * convert this SMW_Type to a JSON string
 
     */
 
     */
 
     public String toJson() { return JSON.toJSONString(this); }
 
     public String toJson() { return JSON.toJSONString(this); }
  
 
     /**
 
     /**
     * convert this Context to a WikiSon string
+
     * convert this SMW_Type to a WikiSon string
 +
    * @return the WikiSon representation of this SMW_Type
 
     */
 
     */
 
     public String toWikiSon() {
 
     public String toWikiSon() {
       String wikison= "{{Context\n";
+
       String wikison= "{{SMW_Type\n";
       wikison+=toWikiSon("name",name);
+
       wikison+=toWikiSon("type",type);
       wikison+=toWikiSon("since",since);
+
       wikison+=toWikiSon("typepage",typepage);
       wikison+=toWikiSon("master",master);
+
       wikison+=toWikiSon("usedByProperties",usedByProperties);
 +
      wikison+=toWikiSon("documentation",documentation);
 +
      wikison+=toWikiSon("helppage",helppage);
 +
      wikison+=toWikiSon("javaType",javaType);
 +
      wikison+=toWikiSon("id",id);
 
       wikison+="}}\n";
 
       wikison+="}}\n";
 
       return wikison;
 
       return wikison;
 +
    }
 +
 +
    /**
 +
    * convert this SMW_Type to a SiDIF string
 +
    * @return the SiDIF representation of this SMW_Type
 +
    */
 +
    public String toSiDIF() {
 +
      String siDIF = String.format("%s isA SMW_Type\n",this.pageid);
 +
      siDIF+=propertySiDIF("type",type,"Text");
 +
      siDIF+=propertySiDIF("typepage",typepage,"Page");
 +
      siDIF+=propertySiDIF("usedByProperties",usedByProperties,"Page");
 +
      siDIF+=propertySiDIF("documentation",documentation,"Text");
 +
      siDIF+=propertySiDIF("helppage",helppage,"URL");
 +
      siDIF+=propertySiDIF("javaType",javaType,"Text");
 +
      siDIF+=propertySiDIF("id",id,"Text");
 +
      return siDIF;
 
     }
 
     }
 
   
 
   
Line 134: Line 170:
  
 
     /**
 
     /**
     * default constructor for Context
+
     * default constructor for SMW_Type
 
     */
 
     */
     public Context() {}
+
     public SMW_Type() {}
  
 
     /**
 
     /**
     * construct a Context from the given Triple
+
     * construct a SMW_Type from the given Triple
 
     * @param query - the TripleQuery to get the triples from
 
     * @param query - the TripleQuery to get the triples from
     * @param pContextTriple - the triple to construct me from
+
     * @param pSMW_TypeTriple - the triple to construct me from
 
     */
 
     */
     public Context(TripleQuery query,Triple pContextTriple) {
+
     public SMW_Type(TripleQuery query,Triple pSMW_TypeTriple) {
       this(query,pContextTriple.getSubject().toString());
+
       this(query,pSMW_TypeTriple.getSubject().toString());
 
     } // constructor
 
     } // constructor
  
 
     /**
 
     /**
     * construct a Context from the given pageId
+
     * construct a SMW_Type from the given pageId
 
     * @param query - the TripleQuery to get the triples from
 
     * @param query - the TripleQuery to get the triples from
 
     * @param pageid - pageid
 
     * @param pageid - pageid
 
     */
 
     */
     public Context(TripleQuery query,String pageid) {
+
     public SMW_Type(TripleQuery query,String pageid) {
 
       this.pageid=pageid;
 
       this.pageid=pageid;
       Triple nameTriple=query.selectSingle(pageid,"name",null);
+
       Triple typeTriple=query.selectSingle(pageid,"type",null);
       if (nameTriple==null)
+
       if (typeTriple==null)
         nameTriple=query.selectSingle(pageid,"Property:Context_name",null);
+
         typeTriple=query.selectSingle(pageid,"Property:SMW_Type_type",null);
       if (nameTriple!=null)  
+
       if (typeTriple!=null)  
         name=nameTriple.getObject().toString();
+
         type=typeTriple.getObject().toString();
       Triple sinceTriple=query.selectSingle(pageid,"since",null);
+
       Triple typepageTriple=query.selectSingle(pageid,"typepage",null);
       if (sinceTriple==null)
+
       if (typepageTriple==null)
         sinceTriple=query.selectSingle(pageid,"Property:Context_since",null);
+
         typepageTriple=query.selectSingle(pageid,"Property:SMW_Type_typepage",null);
       if (sinceTriple!=null)  
+
       if (typepageTriple!=null)  
         since=sinceTriple.getObject().toString();
+
         typepage=typepageTriple.getObject().toString();
       Triple masterTriple=query.selectSingle(pageid,"master",null);
+
       Triple usedByPropertiesTriple=query.selectSingle(pageid,"usedByProperties",null);
       if (masterTriple==null)
+
       if (usedByPropertiesTriple==null)
         masterTriple=query.selectSingle(pageid,"Property:Context_master",null);
+
         usedByPropertiesTriple=query.selectSingle(pageid,"Property:SMW_Type_usedByProperties",null);
       if (masterTriple!=null)  
+
       if (usedByPropertiesTriple!=null)  
         master=masterTriple.getObject().toString();
+
         usedByProperties=usedByPropertiesTriple.getObject().toString();
 +
      Triple documentationTriple=query.selectSingle(pageid,"documentation",null);
 +
      if (documentationTriple==null)
 +
        documentationTriple=query.selectSingle(pageid,"Property:SMW_Type_documentation",null);
 +
      if (documentationTriple!=null)
 +
        documentation=documentationTriple.getObject().toString();
 +
      Triple helppageTriple=query.selectSingle(pageid,"helppage",null);
 +
      if (helppageTriple==null)
 +
        helppageTriple=query.selectSingle(pageid,"Property:SMW_Type_helppage",null);
 +
      if (helppageTriple!=null)
 +
        helppage=helppageTriple.getObject().toString();
 +
      Triple javaTypeTriple=query.selectSingle(pageid,"javaType",null);
 +
      if (javaTypeTriple==null)
 +
        javaTypeTriple=query.selectSingle(pageid,"Property:SMW_Type_javaType",null);
 +
      if (javaTypeTriple!=null)
 +
        javaType=javaTypeTriple.getObject().toString();
 +
      Triple idTriple=query.selectSingle(pageid,"id",null);
 +
      if (idTriple==null)
 +
        idTriple=query.selectSingle(pageid,"Property:SMW_Type_id",null);
 +
      if (idTriple!=null)
 +
        id=idTriple.getObject().toString();
 
       init(query);
 
       init(query);
     } // constructor for Context
+
     } // constructor for SMW_Type
 
      
 
      
     // >>>{user defined topic code}{Context}{Context}
+
     // >>>{user defined topic code}{SMW_Type}{SMW_Type}
     // <<<{user defined topic code}{Context}{Context}
+
     // <<<{user defined topic code}{SMW_Type}{SMW_Type}
   } // class Context
+
   } // class SMW_Type
 
   /**
 
   /**
   * Manager for Context
+
   * Manager for SMW_Type
 
   */
 
   */
   public static class ContextManager extends TopicBase {
+
   public static class SMW_TypeManager extends TopicBase {
 
   
 
   
     public String topicName="Context";
+
     public String topicName="SMW_Type";
     public transient List<Context> mContexts=new ArrayList<Context>();
+
     public transient List<SMW_Type> mSMW_Types=new ArrayList<SMW_Type>();
     public transient Map<String,Context> mContextMap=new LinkedHashMap<String,Context>();
+
     public transient Map<String,SMW_Type> mSMW_TypeMap=new LinkedHashMap<String,SMW_Type>();
  
 
     /**
 
     /**
     * get my Contexts
+
     * get my SMW_Types
 
     */
 
     */
     public List<Context> getContexts() {
+
     public List<SMW_Type> getSMW_Types() {
       List<Context> result=this.mContexts;
+
       List<SMW_Type> result=this.mSMW_Types;
 
       return result;
 
       return result;
 
     }
 
     }
  
 
     /**
 
     /**
     *  add a new Context
+
     *  add a new SMW_Type
 
     */
 
     */
     public Context add(Context pContext) {
+
     public SMW_Type add(SMW_Type pSMW_Type) {
       mContexts.add(pContext);
+
       mSMW_Types.add(pSMW_Type);
       mContextMap.put(pContext.getPageid(),pContext);
+
       mSMW_TypeMap.put(pSMW_Type.getPageid(),pSMW_Type);
       return pContext;
+
       return pSMW_Type;
 
     }
 
     }
  
 
     /**
 
     /**
     *  add a new Context from the given triple
+
     *  add a new SMW_Type from the given triple
 
     */
 
     */
     public Context add(TripleQuery query,Triple pContextTriple) {
+
     public SMW_Type add(TripleQuery query,Triple pSMW_TypeTriple) {
       Context lContext=new Context(query,pContextTriple);
+
       SMW_Type lSMW_Type=new SMW_Type(query,pSMW_TypeTriple);
       add(lContext);
+
       add(lSMW_Type);
       return lContext;
+
       return lSMW_Type;
 
     }
 
     }
  
     // reinitialize my mContext map
+
     // reinitialize my mSMW_Type map
 
     public void reinit() {
 
     public void reinit() {
       mContextMap.clear();
+
       mSMW_TypeMap.clear();
       for (Context lContext:mContexts) {
+
       for (SMW_Type lSMW_Type:mSMW_Types) {
         mContextMap.put(lContext.getPageid(),lContext);
+
         mSMW_TypeMap.put(lSMW_Type.getPageid(),lSMW_Type);
 
       }
 
       }
 
     }
 
     }
Line 222: Line 278:
 
      
 
      
 
     // get a new manager from the given json string
 
     // get a new manager from the given json string
     public static ContextManager fromJson(String json) {
+
     public static SMW_TypeManager fromJson(String json) {
       ContextManager result=JSON.parseObject(json, ContextManager.class);
+
       SMW_TypeManager result=JSON.parseObject(json, SMW_TypeManager.class);
 
       result.reinit();
 
       result.reinit();
 
       return result;
 
       return result;
 
     }
 
     }
  
     // default constructor for Context Manager
+
     // default constructor for SMW_Type Manager
     public ContextManager() {}
+
     public SMW_TypeManager() {}
  
     // add Contexts from the given query
+
     // add SMW_Types from the given query
     public void addContexts(TripleQuery pContextQuery,TripleQuery query) {
+
     public void addSMW_Types(TripleQuery pSMW_TypeQuery,TripleQuery query) {
       if (pContextQuery!=null) {
+
       if (pSMW_TypeQuery!=null) {
         for (Triple lContextTriple:pContextQuery.getTriples()) {
+
         for (Triple lSMW_TypeTriple:pSMW_TypeQuery.getTriples()) {
           add(query,lContextTriple);
+
           add(query,lSMW_TypeTriple);
 
         }
 
         }
 
       }
 
       }
Line 241: Line 297:
  
 
     // construct me from the given triple Query query
 
     // construct me from the given triple Query query
     public ContextManager(TripleQuery query) {
+
     public SMW_TypeManager(TripleQuery query) {
 
       // first query the SiDIF bases triplestore
 
       // first query the SiDIF bases triplestore
       TripleQuery lContextQuery=query.query(null,"isA","Context");
+
       TripleQuery lSMW_TypeQuery=query.query(null,"isA","SMW_Type");
       addContexts(lContextQuery,query);
+
       addSMW_Types(lSMW_TypeQuery,query);
 
       // then the SMW triplestore
 
       // then the SMW triplestore
       lContextQuery=query.query(null,"Property:IsA","Context");
+
       lSMW_TypeQuery=query.query(null,"Property:IsA","SMW_Type");
       addContexts(lContextQuery,query);
+
       addSMW_Types(lSMW_TypeQuery,query);
 
       init(query);
 
       init(query);
     } // constructor for Context Manager
+
     } // constructor for SMW_Type Manager
 
      
 
      
     // >>>{user defined topicmanager code}{Context}{Context}
+
     // >>>{user defined topicmanager code}{SMW_Type}{SMW_Type}
     // <<<{user defined topicmanager code}{Context}{Context}
+
     // <<<{user defined topicmanager code}{SMW_Type}{SMW_Type}
   } // class Context Manager
+
   } // class SMW_Type Manager
 
  /**
 
  /**
 
   * Property
 
   * Property
Line 260: Line 316:
 
   public static class Property extends TopicBase {
 
   public static class Property extends TopicBase {
 
    
 
    
    public String name;
 
    public String label;
 
    public String type;
 
 
     public String index;
 
     public String index;
 
     public String sortPos;
 
     public String sortPos;
    public String primaryKey;
 
 
     public String mandatory;
 
     public String mandatory;
    public String namespace;
 
    public String size;
 
 
     public String uploadable;
 
     public String uploadable;
 
     public String defaultValue;
 
     public String defaultValue;
 
     public String inputType;
 
     public String inputType;
 
     public String allowedValues;
 
     public String allowedValues;
    public String documentation;
 
 
     public String values_from;
 
     public String values_from;
 
     public String showInGrid;
 
     public String showInGrid;
 
     public String isLink;
 
     public String isLink;
 +
    public String type;
 +
    public String name;
 +
    public String label;
 +
    public String primaryKey;
 +
    public String namespace;
 +
    public String size;
 +
    public String documentation;
 
     public String nullable;
 
     public String nullable;
 
     public String topic;
 
     public String topic;
  
    public String getName() { return name; }
 
    public void setName(String pName) { name=pName; }
 
    public String getLabel() { return label; }
 
    public void setLabel(String pLabel) { label=pLabel; }
 
    public String getType() { return type; }
 
    public void setType(String pType) { type=pType; }
 
 
     public String getIndex() { return index; }
 
     public String getIndex() { return index; }
 
     public void setIndex(String pIndex) { index=pIndex; }
 
     public void setIndex(String pIndex) { index=pIndex; }
 
     public String getSortPos() { return sortPos; }
 
     public String getSortPos() { return sortPos; }
 
     public void setSortPos(String pSortPos) { sortPos=pSortPos; }
 
     public void setSortPos(String pSortPos) { sortPos=pSortPos; }
    public String getPrimaryKey() { return primaryKey; }
 
    public void setPrimaryKey(String pPrimaryKey) { primaryKey=pPrimaryKey; }
 
 
     public String getMandatory() { return mandatory; }
 
     public String getMandatory() { return mandatory; }
 
     public void setMandatory(String pMandatory) { mandatory=pMandatory; }
 
     public void setMandatory(String pMandatory) { mandatory=pMandatory; }
    public String getNamespace() { return namespace; }
 
    public void setNamespace(String pNamespace) { namespace=pNamespace; }
 
    public String getSize() { return size; }
 
    public void setSize(String pSize) { size=pSize; }
 
 
     public String getUploadable() { return uploadable; }
 
     public String getUploadable() { return uploadable; }
 
     public void setUploadable(String pUploadable) { uploadable=pUploadable; }
 
     public void setUploadable(String pUploadable) { uploadable=pUploadable; }
Line 306: Line 350:
 
     public String getAllowedValues() { return allowedValues; }
 
     public String getAllowedValues() { return allowedValues; }
 
     public void setAllowedValues(String pAllowedValues) { allowedValues=pAllowedValues; }
 
     public void setAllowedValues(String pAllowedValues) { allowedValues=pAllowedValues; }
    public String getDocumentation() { return documentation; }
 
    public void setDocumentation(String pDocumentation) { documentation=pDocumentation; }
 
 
     public String getValues_from() { return values_from; }
 
     public String getValues_from() { return values_from; }
 
     public void setValues_from(String pValues_from) { values_from=pValues_from; }
 
     public void setValues_from(String pValues_from) { values_from=pValues_from; }
Line 314: Line 356:
 
     public String getIsLink() { return isLink; }
 
     public String getIsLink() { return isLink; }
 
     public void setIsLink(String pIsLink) { isLink=pIsLink; }
 
     public void setIsLink(String pIsLink) { isLink=pIsLink; }
 +
    public String getType() { return type; }
 +
    public void setType(String pType) { type=pType; }
 +
    public String getName() { return name; }
 +
    public void setName(String pName) { name=pName; }
 +
    public String getLabel() { return label; }
 +
    public void setLabel(String pLabel) { label=pLabel; }
 +
    public String getPrimaryKey() { return primaryKey; }
 +
    public void setPrimaryKey(String pPrimaryKey) { primaryKey=pPrimaryKey; }
 +
    public String getNamespace() { return namespace; }
 +
    public void setNamespace(String pNamespace) { namespace=pNamespace; }
 +
    public String getSize() { return size; }
 +
    public void setSize(String pSize) { size=pSize; }
 +
    public String getDocumentation() { return documentation; }
 +
    public void setDocumentation(String pDocumentation) { documentation=pDocumentation; }
 
     public String getNullable() { return nullable; }
 
     public String getNullable() { return nullable; }
 
     public void setNullable(String pNullable) { nullable=pNullable; }
 
     public void setNullable(String pNullable) { nullable=pNullable; }
Line 325: Line 381:
 
     /**
 
     /**
 
     * convert this Property to a WikiSon string
 
     * convert this Property to a WikiSon string
 +
    * @return the WikiSon representation of this Property
 
     */
 
     */
 
     public String toWikiSon() {
 
     public String toWikiSon() {
 
       String wikison= "{{Property\n";
 
       String wikison= "{{Property\n";
      wikison+=toWikiSon("name",name);
 
      wikison+=toWikiSon("label",label);
 
      wikison+=toWikiSon("type",type);
 
 
       wikison+=toWikiSon("index",index);
 
       wikison+=toWikiSon("index",index);
 
       wikison+=toWikiSon("sortPos",sortPos);
 
       wikison+=toWikiSon("sortPos",sortPos);
      wikison+=toWikiSon("primaryKey",primaryKey);
 
 
       wikison+=toWikiSon("mandatory",mandatory);
 
       wikison+=toWikiSon("mandatory",mandatory);
      wikison+=toWikiSon("namespace",namespace);
 
      wikison+=toWikiSon("size",size);
 
 
       wikison+=toWikiSon("uploadable",uploadable);
 
       wikison+=toWikiSon("uploadable",uploadable);
 
       wikison+=toWikiSon("defaultValue",defaultValue);
 
       wikison+=toWikiSon("defaultValue",defaultValue);
 
       wikison+=toWikiSon("inputType",inputType);
 
       wikison+=toWikiSon("inputType",inputType);
 
       wikison+=toWikiSon("allowedValues",allowedValues);
 
       wikison+=toWikiSon("allowedValues",allowedValues);
      wikison+=toWikiSon("documentation",documentation);
 
 
       wikison+=toWikiSon("values_from",values_from);
 
       wikison+=toWikiSon("values_from",values_from);
 
       wikison+=toWikiSon("showInGrid",showInGrid);
 
       wikison+=toWikiSon("showInGrid",showInGrid);
 
       wikison+=toWikiSon("isLink",isLink);
 
       wikison+=toWikiSon("isLink",isLink);
 +
      wikison+=toWikiSon("type",type);
 +
      wikison+=toWikiSon("name",name);
 +
      wikison+=toWikiSon("label",label);
 +
      wikison+=toWikiSon("primaryKey",primaryKey);
 +
      wikison+=toWikiSon("namespace",namespace);
 +
      wikison+=toWikiSon("size",size);
 +
      wikison+=toWikiSon("documentation",documentation);
 
       wikison+=toWikiSon("nullable",nullable);
 
       wikison+=toWikiSon("nullable",nullable);
 
       wikison+=toWikiSon("topic",topic);
 
       wikison+=toWikiSon("topic",topic);
 
       wikison+="}}\n";
 
       wikison+="}}\n";
 
       return wikison;
 
       return wikison;
 +
    }
 +
 +
    /**
 +
    * convert this Property to a SiDIF string
 +
    * @return the SiDIF representation of this Property
 +
    */
 +
    public String toSiDIF() {
 +
      String siDIF = String.format("%s isA Property\n",this.pageid);
 +
      siDIF+=propertySiDIF("index",index,"Number");
 +
      siDIF+=propertySiDIF("sortPos",sortPos,"Number");
 +
      siDIF+=propertySiDIF("mandatory",mandatory,"Boolean");
 +
      siDIF+=propertySiDIF("uploadable",uploadable,"Boolean");
 +
      siDIF+=propertySiDIF("defaultValue",defaultValue,"Code");
 +
      siDIF+=propertySiDIF("inputType",inputType,"Text");
 +
      siDIF+=propertySiDIF("allowedValues",allowedValues,"Text");
 +
      siDIF+=propertySiDIF("values_from",values_from,"Code");
 +
      siDIF+=propertySiDIF("showInGrid",showInGrid,"Boolean");
 +
      siDIF+=propertySiDIF("isLink",isLink,"Boolean");
 +
      siDIF+=propertySiDIF("type",type,"Page");
 +
      siDIF+=propertySiDIF("name",name,"Text");
 +
      siDIF+=propertySiDIF("label",label,"Text");
 +
      siDIF+=propertySiDIF("primaryKey",primaryKey,"Boolean");
 +
      siDIF+=propertySiDIF("namespace",namespace,"Text");
 +
      siDIF+=propertySiDIF("size",size,"Number");
 +
      siDIF+=propertySiDIF("documentation",documentation,"Text");
 +
      siDIF+=propertySiDIF("nullable",nullable,"Boolean");
 +
      siDIF+=propertySiDIF("topic",topic,"Page");
 +
      return siDIF;
 
     }
 
     }
 
   
 
   
Line 377: Line 462:
 
     public Property(TripleQuery query,String pageid) {
 
     public Property(TripleQuery query,String pageid) {
 
       this.pageid=pageid;
 
       this.pageid=pageid;
      Triple nameTriple=query.selectSingle(pageid,"name",null);
 
      if (nameTriple==null)
 
        nameTriple=query.selectSingle(pageid,"Property:Property_name",null);
 
      if (nameTriple!=null)
 
        name=nameTriple.getObject().toString();
 
      Triple labelTriple=query.selectSingle(pageid,"label",null);
 
      if (labelTriple==null)
 
        labelTriple=query.selectSingle(pageid,"Property:Property_label",null);
 
      if (labelTriple!=null)
 
        label=labelTriple.getObject().toString();
 
      Triple typeTriple=query.selectSingle(pageid,"type",null);
 
      if (typeTriple==null)
 
        typeTriple=query.selectSingle(pageid,"Property:Property_type",null);
 
      if (typeTriple!=null)
 
        type=typeTriple.getObject().toString();
 
 
       Triple indexTriple=query.selectSingle(pageid,"index",null);
 
       Triple indexTriple=query.selectSingle(pageid,"index",null);
 
       if (indexTriple==null)
 
       if (indexTriple==null)
Line 402: Line 472:
 
       if (sortPosTriple!=null)  
 
       if (sortPosTriple!=null)  
 
         sortPos=sortPosTriple.getObject().toString();
 
         sortPos=sortPosTriple.getObject().toString();
      Triple primaryKeyTriple=query.selectSingle(pageid,"primaryKey",null);
 
      if (primaryKeyTriple==null)
 
        primaryKeyTriple=query.selectSingle(pageid,"Property:Property_primaryKey",null);
 
      if (primaryKeyTriple!=null)
 
        primaryKey=primaryKeyTriple.getObject().toString();
 
 
       Triple mandatoryTriple=query.selectSingle(pageid,"mandatory",null);
 
       Triple mandatoryTriple=query.selectSingle(pageid,"mandatory",null);
 
       if (mandatoryTriple==null)
 
       if (mandatoryTriple==null)
Line 412: Line 477:
 
       if (mandatoryTriple!=null)  
 
       if (mandatoryTriple!=null)  
 
         mandatory=mandatoryTriple.getObject().toString();
 
         mandatory=mandatoryTriple.getObject().toString();
      Triple namespaceTriple=query.selectSingle(pageid,"namespace",null);
 
      if (namespaceTriple==null)
 
        namespaceTriple=query.selectSingle(pageid,"Property:Property_namespace",null);
 
      if (namespaceTriple!=null)
 
        namespace=namespaceTriple.getObject().toString();
 
      Triple sizeTriple=query.selectSingle(pageid,"size",null);
 
      if (sizeTriple==null)
 
        sizeTriple=query.selectSingle(pageid,"Property:Property_size",null);
 
      if (sizeTriple!=null)
 
        size=sizeTriple.getObject().toString();
 
 
       Triple uploadableTriple=query.selectSingle(pageid,"uploadable",null);
 
       Triple uploadableTriple=query.selectSingle(pageid,"uploadable",null);
 
       if (uploadableTriple==null)
 
       if (uploadableTriple==null)
Line 442: Line 497:
 
       if (allowedValuesTriple!=null)  
 
       if (allowedValuesTriple!=null)  
 
         allowedValues=allowedValuesTriple.getObject().toString();
 
         allowedValues=allowedValuesTriple.getObject().toString();
      Triple documentationTriple=query.selectSingle(pageid,"documentation",null);
 
      if (documentationTriple==null)
 
        documentationTriple=query.selectSingle(pageid,"Property:Property_documentation",null);
 
      if (documentationTriple!=null)
 
        documentation=documentationTriple.getObject().toString();
 
 
       Triple values_fromTriple=query.selectSingle(pageid,"values_from",null);
 
       Triple values_fromTriple=query.selectSingle(pageid,"values_from",null);
 
       if (values_fromTriple==null)
 
       if (values_fromTriple==null)
Line 462: Line 512:
 
       if (isLinkTriple!=null)  
 
       if (isLinkTriple!=null)  
 
         isLink=isLinkTriple.getObject().toString();
 
         isLink=isLinkTriple.getObject().toString();
 +
      Triple typeTriple=query.selectSingle(pageid,"type",null);
 +
      if (typeTriple==null)
 +
        typeTriple=query.selectSingle(pageid,"Property:Property_type",null);
 +
      if (typeTriple!=null)
 +
        type=typeTriple.getObject().toString();
 +
      Triple nameTriple=query.selectSingle(pageid,"name",null);
 +
      if (nameTriple==null)
 +
        nameTriple=query.selectSingle(pageid,"Property:Property_name",null);
 +
      if (nameTriple!=null)
 +
        name=nameTriple.getObject().toString();
 +
      Triple labelTriple=query.selectSingle(pageid,"label",null);
 +
      if (labelTriple==null)
 +
        labelTriple=query.selectSingle(pageid,"Property:Property_label",null);
 +
      if (labelTriple!=null)
 +
        label=labelTriple.getObject().toString();
 +
      Triple primaryKeyTriple=query.selectSingle(pageid,"primaryKey",null);
 +
      if (primaryKeyTriple==null)
 +
        primaryKeyTriple=query.selectSingle(pageid,"Property:Property_primaryKey",null);
 +
      if (primaryKeyTriple!=null)
 +
        primaryKey=primaryKeyTriple.getObject().toString();
 +
      Triple namespaceTriple=query.selectSingle(pageid,"namespace",null);
 +
      if (namespaceTriple==null)
 +
        namespaceTriple=query.selectSingle(pageid,"Property:Property_namespace",null);
 +
      if (namespaceTriple!=null)
 +
        namespace=namespaceTriple.getObject().toString();
 +
      Triple sizeTriple=query.selectSingle(pageid,"size",null);
 +
      if (sizeTriple==null)
 +
        sizeTriple=query.selectSingle(pageid,"Property:Property_size",null);
 +
      if (sizeTriple!=null)
 +
        size=sizeTriple.getObject().toString();
 +
      Triple documentationTriple=query.selectSingle(pageid,"documentation",null);
 +
      if (documentationTriple==null)
 +
        documentationTriple=query.selectSingle(pageid,"Property:Property_documentation",null);
 +
      if (documentationTriple!=null)
 +
        documentation=documentationTriple.getObject().toString();
 
       Triple nullableTriple=query.selectSingle(pageid,"nullable",null);
 
       Triple nullableTriple=query.selectSingle(pageid,"nullable",null);
 
       if (nullableTriple==null)
 
       if (nullableTriple==null)
Line 558: Line 643:
 
   } // class Property Manager
 
   } // class Property Manager
 
  /**
 
  /**
   * SMW_Type
+
   * Context
   * an SMW_Type is a data type which determines the possible values for that type e.g. a Boolean can hold true/fals values while a Number can hold 3.1459 or 20. A Page can hold the name of a Wiki page see https://semantic-mediawiki.org/wiki/Help:List_of_datatypes
+
   * A Context groups some topics like a Namespace/Package
 
   */
 
   */
   public static class SMW_Type extends TopicBase {
+
   public static class Context extends TopicBase {
 
    
 
    
     public String type;
+
     public String name;
     public String documentation;
+
     public String since;
     public String helppage;
+
     public String master;
    public String typepage;
 
    public String javaType;
 
    public String usedByProperties;
 
  
     public String getType() { return type; }
+
     public String getName() { return name; }
     public void setType(String pType) { type=pType; }
+
     public void setName(String pName) { name=pName; }
     public String getDocumentation() { return documentation; }
+
     public String getSince() { return since; }
     public void setDocumentation(String pDocumentation) { documentation=pDocumentation; }
+
     public void setSince(String pSince) { since=pSince; }
     public String getHelppage() { return helppage; }
+
     public String getMaster() { return master; }
     public void setHelppage(String pHelppage) { helppage=pHelppage; }
+
     public void setMaster(String pMaster) { master=pMaster; }
    public String getTypepage() { return typepage; }
 
    public void setTypepage(String pTypepage) { typepage=pTypepage; }
 
    public String getJavaType() { return javaType; }
 
    public void setJavaType(String pJavaType) { javaType=pJavaType; }
 
    public String getUsedByProperties() { return usedByProperties; }
 
    public void setUsedByProperties(String pUsedByProperties) { usedByProperties=pUsedByProperties; }
 
 
     /**
 
     /**
     * convert this SMW_Type to a JSON string
+
     * convert this Context to a JSON string
 
     */
 
     */
 
     public String toJson() { return JSON.toJSONString(this); }
 
     public String toJson() { return JSON.toJSONString(this); }
  
 
     /**
 
     /**
     * convert this SMW_Type to a WikiSon string
+
     * convert this Context to a WikiSon string
 +
    * @return the WikiSon representation of this Context
 
     */
 
     */
 
     public String toWikiSon() {
 
     public String toWikiSon() {
       String wikison= "{{SMW_Type\n";
+
       String wikison= "{{Context\n";
       wikison+=toWikiSon("type",type);
+
       wikison+=toWikiSon("name",name);
       wikison+=toWikiSon("documentation",documentation);
+
       wikison+=toWikiSon("since",since);
       wikison+=toWikiSon("helppage",helppage);
+
       wikison+=toWikiSon("master",master);
      wikison+=toWikiSon("typepage",typepage);
 
      wikison+=toWikiSon("javaType",javaType);
 
      wikison+=toWikiSon("usedByProperties",usedByProperties);
 
 
       wikison+="}}\n";
 
       wikison+="}}\n";
 
       return wikison;
 
       return wikison;
 +
    }
 +
 +
    /**
 +
    * convert this Context to a SiDIF string
 +
    * @return the SiDIF representation of this Context
 +
    */
 +
    public String toSiDIF() {
 +
      String siDIF = String.format("%s isA Context\n",this.pageid);
 +
      siDIF+=propertySiDIF("name",name,"Text");
 +
      siDIF+=propertySiDIF("since",since,"Date");
 +
      siDIF+=propertySiDIF("master",master,"URL");
 +
      return siDIF;
 
     }
 
     }
 
   
 
   
Line 608: Line 694:
  
 
     /**
 
     /**
     * default constructor for SMW_Type
+
     * default constructor for Context
 
     */
 
     */
     public SMW_Type() {}
+
     public Context() {}
  
 
     /**
 
     /**
     * construct a SMW_Type from the given Triple
+
     * construct a Context from the given Triple
 
     * @param query - the TripleQuery to get the triples from
 
     * @param query - the TripleQuery to get the triples from
     * @param pSMW_TypeTriple - the triple to construct me from
+
     * @param pContextTriple - the triple to construct me from
 
     */
 
     */
     public SMW_Type(TripleQuery query,Triple pSMW_TypeTriple) {
+
     public Context(TripleQuery query,Triple pContextTriple) {
       this(query,pSMW_TypeTriple.getSubject().toString());
+
       this(query,pContextTriple.getSubject().toString());
 
     } // constructor
 
     } // constructor
  
 
     /**
 
     /**
     * construct a SMW_Type from the given pageId
+
     * construct a Context from the given pageId
 
     * @param query - the TripleQuery to get the triples from
 
     * @param query - the TripleQuery to get the triples from
 
     * @param pageid - pageid
 
     * @param pageid - pageid
 
     */
 
     */
     public SMW_Type(TripleQuery query,String pageid) {
+
     public Context(TripleQuery query,String pageid) {
 
       this.pageid=pageid;
 
       this.pageid=pageid;
       Triple typeTriple=query.selectSingle(pageid,"type",null);
+
       Triple nameTriple=query.selectSingle(pageid,"name",null);
       if (typeTriple==null)
+
       if (nameTriple==null)
         typeTriple=query.selectSingle(pageid,"Property:SMW_Type_type",null);
+
         nameTriple=query.selectSingle(pageid,"Property:Context_name",null);
       if (typeTriple!=null)  
+
       if (nameTriple!=null)  
         type=typeTriple.getObject().toString();
+
         name=nameTriple.getObject().toString();
       Triple documentationTriple=query.selectSingle(pageid,"documentation",null);
+
       Triple sinceTriple=query.selectSingle(pageid,"since",null);
       if (documentationTriple==null)
+
       if (sinceTriple==null)
         documentationTriple=query.selectSingle(pageid,"Property:SMW_Type_documentation",null);
+
         sinceTriple=query.selectSingle(pageid,"Property:Context_since",null);
       if (documentationTriple!=null)  
+
       if (sinceTriple!=null)  
         documentation=documentationTriple.getObject().toString();
+
         since=sinceTriple.getObject().toString();
       Triple helppageTriple=query.selectSingle(pageid,"helppage",null);
+
       Triple masterTriple=query.selectSingle(pageid,"master",null);
       if (helppageTriple==null)
+
       if (masterTriple==null)
         helppageTriple=query.selectSingle(pageid,"Property:SMW_Type_helppage",null);
+
         masterTriple=query.selectSingle(pageid,"Property:Context_master",null);
       if (helppageTriple!=null)  
+
       if (masterTriple!=null)  
         helppage=helppageTriple.getObject().toString();
+
         master=masterTriple.getObject().toString();
      Triple typepageTriple=query.selectSingle(pageid,"typepage",null);
 
      if (typepageTriple==null)
 
        typepageTriple=query.selectSingle(pageid,"Property:SMW_Type_typepage",null);
 
      if (typepageTriple!=null)
 
        typepage=typepageTriple.getObject().toString();
 
      Triple javaTypeTriple=query.selectSingle(pageid,"javaType",null);
 
      if (javaTypeTriple==null)
 
        javaTypeTriple=query.selectSingle(pageid,"Property:SMW_Type_javaType",null);
 
      if (javaTypeTriple!=null)
 
        javaType=javaTypeTriple.getObject().toString();
 
      Triple usedByPropertiesTriple=query.selectSingle(pageid,"usedByProperties",null);
 
      if (usedByPropertiesTriple==null)
 
        usedByPropertiesTriple=query.selectSingle(pageid,"Property:SMW_Type_usedByProperties",null);
 
      if (usedByPropertiesTriple!=null)
 
        usedByProperties=usedByPropertiesTriple.getObject().toString();
 
 
       init(query);
 
       init(query);
     } // constructor for SMW_Type
+
     } // constructor for Context
 
      
 
      
     // >>>{user defined topic code}{SMW_Type}{SMW_Type}
+
     // >>>{user defined topic code}{Context}{Context}
     // <<<{user defined topic code}{SMW_Type}{SMW_Type}
+
     // <<<{user defined topic code}{Context}{Context}
   } // class SMW_Type
+
   } // class Context
 
   /**
 
   /**
   * Manager for SMW_Type
+
   * Manager for Context
 
   */
 
   */
   public static class SMW_TypeManager extends TopicBase {
+
   public static class ContextManager extends TopicBase {
 
   
 
   
     public String topicName="SMW_Type";
+
     public String topicName="Context";
     public transient List<SMW_Type> mSMW_Types=new ArrayList<SMW_Type>();
+
     public transient List<Context> mContexts=new ArrayList<Context>();
     public transient Map<String,SMW_Type> mSMW_TypeMap=new LinkedHashMap<String,SMW_Type>();
+
     public transient Map<String,Context> mContextMap=new LinkedHashMap<String,Context>();
  
 
     /**
 
     /**
     * get my SMW_Types
+
     * get my Contexts
 
     */
 
     */
     public List<SMW_Type> getSMW_Types() {
+
     public List<Context> getContexts() {
       List<SMW_Type> result=this.mSMW_Types;
+
       List<Context> result=this.mContexts;
 
       return result;
 
       return result;
 
     }
 
     }
  
 
     /**
 
     /**
     *  add a new SMW_Type
+
     *  add a new Context
 
     */
 
     */
     public SMW_Type add(SMW_Type pSMW_Type) {
+
     public Context add(Context pContext) {
       mSMW_Types.add(pSMW_Type);
+
       mContexts.add(pContext);
       mSMW_TypeMap.put(pSMW_Type.getPageid(),pSMW_Type);
+
       mContextMap.put(pContext.getPageid(),pContext);
       return pSMW_Type;
+
       return pContext;
 
     }
 
     }
  
 
     /**
 
     /**
     *  add a new SMW_Type from the given triple
+
     *  add a new Context from the given triple
 
     */
 
     */
     public SMW_Type add(TripleQuery query,Triple pSMW_TypeTriple) {
+
     public Context add(TripleQuery query,Triple pContextTriple) {
       SMW_Type lSMW_Type=new SMW_Type(query,pSMW_TypeTriple);
+
       Context lContext=new Context(query,pContextTriple);
       add(lSMW_Type);
+
       add(lContext);
       return lSMW_Type;
+
       return lContext;
 
     }
 
     }
  
     // reinitialize my mSMW_Type map
+
     // reinitialize my mContext map
 
     public void reinit() {
 
     public void reinit() {
       mSMW_TypeMap.clear();
+
       mContextMap.clear();
       for (SMW_Type lSMW_Type:mSMW_Types) {
+
       for (Context lContext:mContexts) {
         mSMW_TypeMap.put(lSMW_Type.getPageid(),lSMW_Type);
+
         mContextMap.put(lContext.getPageid(),lContext);
 
       }
 
       }
 
     }
 
     }
Line 711: Line 782:
 
      
 
      
 
     // get a new manager from the given json string
 
     // get a new manager from the given json string
     public static SMW_TypeManager fromJson(String json) {
+
     public static ContextManager fromJson(String json) {
       SMW_TypeManager result=JSON.parseObject(json, SMW_TypeManager.class);
+
       ContextManager result=JSON.parseObject(json, ContextManager.class);
 
       result.reinit();
 
       result.reinit();
 
       return result;
 
       return result;
 
     }
 
     }
  
     // default constructor for SMW_Type Manager
+
     // default constructor for Context Manager
     public SMW_TypeManager() {}
+
     public ContextManager() {}
  
     // add SMW_Types from the given query
+
     // add Contexts from the given query
     public void addSMW_Types(TripleQuery pSMW_TypeQuery,TripleQuery query) {
+
     public void addContexts(TripleQuery pContextQuery,TripleQuery query) {
       if (pSMW_TypeQuery!=null) {
+
       if (pContextQuery!=null) {
         for (Triple lSMW_TypeTriple:pSMW_TypeQuery.getTriples()) {
+
         for (Triple lContextTriple:pContextQuery.getTriples()) {
           add(query,lSMW_TypeTriple);
+
           add(query,lContextTriple);
 
         }
 
         }
 
       }
 
       }
Line 730: Line 801:
  
 
     // construct me from the given triple Query query
 
     // construct me from the given triple Query query
     public SMW_TypeManager(TripleQuery query) {
+
     public ContextManager(TripleQuery query) {
 
       // first query the SiDIF bases triplestore
 
       // first query the SiDIF bases triplestore
       TripleQuery lSMW_TypeQuery=query.query(null,"isA","SMW_Type");
+
       TripleQuery lContextQuery=query.query(null,"isA","Context");
       addSMW_Types(lSMW_TypeQuery,query);
+
       addContexts(lContextQuery,query);
 
       // then the SMW triplestore
 
       // then the SMW triplestore
       lSMW_TypeQuery=query.query(null,"Property:IsA","SMW_Type");
+
       lContextQuery=query.query(null,"Property:IsA","Context");
       addSMW_Types(lSMW_TypeQuery,query);
+
       addContexts(lContextQuery,query);
 
       init(query);
 
       init(query);
     } // constructor for SMW_Type Manager
+
     } // constructor for Context Manager
 
      
 
      
     // >>>{user defined topicmanager code}{SMW_Type}{SMW_Type}
+
     // >>>{user defined topicmanager code}{Context}{Context}
     // <<<{user defined topicmanager code}{SMW_Type}{SMW_Type}
+
     // <<<{user defined topicmanager code}{Context}{Context}
   } // class SMW_Type Manager
+
   } // class Context Manager
 
  /**
 
  /**
 
   * Topic
 
   * Topic
Line 749: Line 820:
 
   public static class Topic extends TopicBase {
 
   public static class Topic extends TopicBase {
 
    
 
    
 +
    public String pluralName;
 +
    public String documentation;
 +
    public String cargo;
 
     public String name;
 
     public String name;
    public String pluralName;
 
 
     public String icon;
 
     public String icon;
 
     public String iconUrl;
 
     public String iconUrl;
    public String documentation;
 
 
     public String wikiDocumentation;
 
     public String wikiDocumentation;
 
     public String defaultstoremode;
 
     public String defaultstoremode;
 
     public String listLimit;
 
     public String listLimit;
    public String cargo;
 
 
     public String headerTabs;
 
     public String headerTabs;
 
     public String context;
 
     public String context;
  
 +
    public String getPluralName() { return pluralName; }
 +
    public void setPluralName(String pPluralName) { pluralName=pPluralName; }
 +
    public String getDocumentation() { return documentation; }
 +
    public void setDocumentation(String pDocumentation) { documentation=pDocumentation; }
 +
    public String getCargo() { return cargo; }
 +
    public void setCargo(String pCargo) { cargo=pCargo; }
 
     public String getName() { return name; }
 
     public String getName() { return name; }
 
     public void setName(String pName) { name=pName; }
 
     public void setName(String pName) { name=pName; }
    public String getPluralName() { return pluralName; }
 
    public void setPluralName(String pPluralName) { pluralName=pPluralName; }
 
 
     public String getIcon() { return icon; }
 
     public String getIcon() { return icon; }
 
     public void setIcon(String pIcon) { icon=pIcon; }
 
     public void setIcon(String pIcon) { icon=pIcon; }
 
     public String getIconUrl() { return iconUrl; }
 
     public String getIconUrl() { return iconUrl; }
 
     public void setIconUrl(String pIconUrl) { iconUrl=pIconUrl; }
 
     public void setIconUrl(String pIconUrl) { iconUrl=pIconUrl; }
    public String getDocumentation() { return documentation; }
 
    public void setDocumentation(String pDocumentation) { documentation=pDocumentation; }
 
 
     public String getWikiDocumentation() { return wikiDocumentation; }
 
     public String getWikiDocumentation() { return wikiDocumentation; }
 
     public void setWikiDocumentation(String pWikiDocumentation) { wikiDocumentation=pWikiDocumentation; }
 
     public void setWikiDocumentation(String pWikiDocumentation) { wikiDocumentation=pWikiDocumentation; }
Line 777: Line 850:
 
     public String getListLimit() { return listLimit; }
 
     public String getListLimit() { return listLimit; }
 
     public void setListLimit(String pListLimit) { listLimit=pListLimit; }
 
     public void setListLimit(String pListLimit) { listLimit=pListLimit; }
    public String getCargo() { return cargo; }
 
    public void setCargo(String pCargo) { cargo=pCargo; }
 
 
     public String getHeaderTabs() { return headerTabs; }
 
     public String getHeaderTabs() { return headerTabs; }
 
     public void setHeaderTabs(String pHeaderTabs) { headerTabs=pHeaderTabs; }
 
     public void setHeaderTabs(String pHeaderTabs) { headerTabs=pHeaderTabs; }
Line 790: Line 861:
 
     /**
 
     /**
 
     * convert this Topic to a WikiSon string
 
     * convert this Topic to a WikiSon string
 +
    * @return the WikiSon representation of this Topic
 
     */
 
     */
 
     public String toWikiSon() {
 
     public String toWikiSon() {
 
       String wikison= "{{Topic\n";
 
       String wikison= "{{Topic\n";
 +
      wikison+=toWikiSon("pluralName",pluralName);
 +
      wikison+=toWikiSon("documentation",documentation);
 +
      wikison+=toWikiSon("cargo",cargo);
 
       wikison+=toWikiSon("name",name);
 
       wikison+=toWikiSon("name",name);
      wikison+=toWikiSon("pluralName",pluralName);
 
 
       wikison+=toWikiSon("icon",icon);
 
       wikison+=toWikiSon("icon",icon);
 
       wikison+=toWikiSon("iconUrl",iconUrl);
 
       wikison+=toWikiSon("iconUrl",iconUrl);
      wikison+=toWikiSon("documentation",documentation);
 
 
       wikison+=toWikiSon("wikiDocumentation",wikiDocumentation);
 
       wikison+=toWikiSon("wikiDocumentation",wikiDocumentation);
 
       wikison+=toWikiSon("defaultstoremode",defaultstoremode);
 
       wikison+=toWikiSon("defaultstoremode",defaultstoremode);
 
       wikison+=toWikiSon("listLimit",listLimit);
 
       wikison+=toWikiSon("listLimit",listLimit);
      wikison+=toWikiSon("cargo",cargo);
 
 
       wikison+=toWikiSon("headerTabs",headerTabs);
 
       wikison+=toWikiSon("headerTabs",headerTabs);
 
       wikison+=toWikiSon("context",context);
 
       wikison+=toWikiSon("context",context);
 
       wikison+="}}\n";
 
       wikison+="}}\n";
 
       return wikison;
 
       return wikison;
 +
    }
 +
 +
    /**
 +
    * convert this Topic to a SiDIF string
 +
    * @return the SiDIF representation of this Topic
 +
    */
 +
    public String toSiDIF() {
 +
      String siDIF = String.format("%s isA Topic\n",this.pageid);
 +
      siDIF+=propertySiDIF("pluralName",pluralName,"Text");
 +
      siDIF+=propertySiDIF("documentation",documentation,"Text");
 +
      siDIF+=propertySiDIF("cargo",cargo,"Boolean");
 +
      siDIF+=propertySiDIF("name",name,"Text");
 +
      siDIF+=propertySiDIF("icon",icon,"Page");
 +
      siDIF+=propertySiDIF("iconUrl",iconUrl,"Code");
 +
      siDIF+=propertySiDIF("wikiDocumentation",wikiDocumentation,"Text");
 +
      siDIF+=propertySiDIF("defaultstoremode",defaultstoremode,"Text");
 +
      siDIF+=propertySiDIF("listLimit",listLimit,"Number");
 +
      siDIF+=propertySiDIF("headerTabs",headerTabs,"Boolean");
 +
      siDIF+=propertySiDIF("context",context,"Page");
 +
      return siDIF;
 
     }
 
     }
 
   
 
   
Line 834: Line 926:
 
     public Topic(TripleQuery query,String pageid) {
 
     public Topic(TripleQuery query,String pageid) {
 
       this.pageid=pageid;
 
       this.pageid=pageid;
 +
      Triple pluralNameTriple=query.selectSingle(pageid,"pluralName",null);
 +
      if (pluralNameTriple==null)
 +
        pluralNameTriple=query.selectSingle(pageid,"Property:Topic_pluralName",null);
 +
      if (pluralNameTriple!=null)
 +
        pluralName=pluralNameTriple.getObject().toString();
 +
      Triple documentationTriple=query.selectSingle(pageid,"documentation",null);
 +
      if (documentationTriple==null)
 +
        documentationTriple=query.selectSingle(pageid,"Property:Topic_documentation",null);
 +
      if (documentationTriple!=null)
 +
        documentation=documentationTriple.getObject().toString();
 +
      Triple cargoTriple=query.selectSingle(pageid,"cargo",null);
 +
      if (cargoTriple==null)
 +
        cargoTriple=query.selectSingle(pageid,"Property:Topic_cargo",null);
 +
      if (cargoTriple!=null)
 +
        cargo=cargoTriple.getObject().toString();
 
       Triple nameTriple=query.selectSingle(pageid,"name",null);
 
       Triple nameTriple=query.selectSingle(pageid,"name",null);
 
       if (nameTriple==null)
 
       if (nameTriple==null)
Line 839: Line 946:
 
       if (nameTriple!=null)  
 
       if (nameTriple!=null)  
 
         name=nameTriple.getObject().toString();
 
         name=nameTriple.getObject().toString();
      Triple pluralNameTriple=query.selectSingle(pageid,"pluralName",null);
 
      if (pluralNameTriple==null)
 
        pluralNameTriple=query.selectSingle(pageid,"Property:Topic_pluralName",null);
 
      if (pluralNameTriple!=null)
 
        pluralName=pluralNameTriple.getObject().toString();
 
 
       Triple iconTriple=query.selectSingle(pageid,"icon",null);
 
       Triple iconTriple=query.selectSingle(pageid,"icon",null);
 
       if (iconTriple==null)
 
       if (iconTriple==null)
Line 854: Line 956:
 
       if (iconUrlTriple!=null)  
 
       if (iconUrlTriple!=null)  
 
         iconUrl=iconUrlTriple.getObject().toString();
 
         iconUrl=iconUrlTriple.getObject().toString();
      Triple documentationTriple=query.selectSingle(pageid,"documentation",null);
 
      if (documentationTriple==null)
 
        documentationTriple=query.selectSingle(pageid,"Property:Topic_documentation",null);
 
      if (documentationTriple!=null)
 
        documentation=documentationTriple.getObject().toString();
 
 
       Triple wikiDocumentationTriple=query.selectSingle(pageid,"wikiDocumentation",null);
 
       Triple wikiDocumentationTriple=query.selectSingle(pageid,"wikiDocumentation",null);
 
       if (wikiDocumentationTriple==null)
 
       if (wikiDocumentationTriple==null)
Line 874: Line 971:
 
       if (listLimitTriple!=null)  
 
       if (listLimitTriple!=null)  
 
         listLimit=listLimitTriple.getObject().toString();
 
         listLimit=listLimitTriple.getObject().toString();
      Triple cargoTriple=query.selectSingle(pageid,"cargo",null);
 
      if (cargoTriple==null)
 
        cargoTriple=query.selectSingle(pageid,"Property:Topic_cargo",null);
 
      if (cargoTriple!=null)
 
        cargo=cargoTriple.getObject().toString();
 
 
       Triple headerTabsTriple=query.selectSingle(pageid,"headerTabs",null);
 
       Triple headerTabsTriple=query.selectSingle(pageid,"headerTabs",null);
 
       if (headerTabsTriple==null)
 
       if (headerTabsTriple==null)
Line 1,021: Line 1,113:
 
     /**
 
     /**
 
     * convert this Action to a WikiSon string
 
     * convert this Action to a WikiSon string
 +
    * @return the WikiSon representation of this Action
 
     */
 
     */
 
     public String toWikiSon() {
 
     public String toWikiSon() {
Line 1,037: Line 1,130:
 
       wikison+="}}\n";
 
       wikison+="}}\n";
 
       return wikison;
 
       return wikison;
 +
    }
 +
 +
    /**
 +
    * convert this Action to a SiDIF string
 +
    * @return the SiDIF representation of this Action
 +
    */
 +
    public String toSiDIF() {
 +
      String siDIF = String.format("%s isA Action\n",this.pageid);
 +
      siDIF+=propertySiDIF("name",name,"Text");
 +
      siDIF+=propertySiDIF("servicetype",servicetype,"Text");
 +
      siDIF+=propertySiDIF("service",service,"URL");
 +
      siDIF+=propertySiDIF("inputtype",inputtype,"Text");
 +
      siDIF+=propertySiDIF("input",input,"Code");
 +
      siDIF+=propertySiDIF("actionpage",actionpage,"Page");
 +
      siDIF+=propertySiDIF("output",output,"Text");
 +
      siDIF+=propertySiDIF("engine",engine,"Text");
 +
      siDIF+=propertySiDIF("author",author,"Page");
 +
      siDIF+=propertySiDIF("since",since,"Date");
 +
      siDIF+=propertySiDIF("comment",comment,"Text");
 +
      return siDIF;
 
     }
 
     }
 
   
 
   
Line 1,211: Line 1,324:
 
   public static class TopicLink extends TopicBase {
 
   public static class TopicLink extends TopicBase {
 
    
 
    
 +
    public String masterDetail;
 
     public String name;
 
     public String name;
 
     public String source;
 
     public String source;
Line 1,220: Line 1,334:
 
     public String targetMultiple;
 
     public String targetMultiple;
 
     public String targetDocumentation;
 
     public String targetDocumentation;
    public String masterDetail;
 
  
 +
    public String getMasterDetail() { return masterDetail; }
 +
    public void setMasterDetail(String pMasterDetail) { masterDetail=pMasterDetail; }
 
     public String getName() { return name; }
 
     public String getName() { return name; }
 
     public void setName(String pName) { name=pName; }
 
     public void setName(String pName) { name=pName; }
Line 1,240: Line 1,355:
 
     public String getTargetDocumentation() { return targetDocumentation; }
 
     public String getTargetDocumentation() { return targetDocumentation; }
 
     public void setTargetDocumentation(String pTargetDocumentation) { targetDocumentation=pTargetDocumentation; }
 
     public void setTargetDocumentation(String pTargetDocumentation) { targetDocumentation=pTargetDocumentation; }
    public String getMasterDetail() { return masterDetail; }
 
    public void setMasterDetail(String pMasterDetail) { masterDetail=pMasterDetail; }
 
 
     /**
 
     /**
 
     * convert this TopicLink to a JSON string
 
     * convert this TopicLink to a JSON string
Line 1,249: Line 1,362:
 
     /**
 
     /**
 
     * convert this TopicLink to a WikiSon string
 
     * convert this TopicLink to a WikiSon string
 +
    * @return the WikiSon representation of this TopicLink
 
     */
 
     */
 
     public String toWikiSon() {
 
     public String toWikiSon() {
 
       String wikison= "{{TopicLink\n";
 
       String wikison= "{{TopicLink\n";
 +
      wikison+=toWikiSon("masterDetail",masterDetail);
 
       wikison+=toWikiSon("name",name);
 
       wikison+=toWikiSon("name",name);
 
       wikison+=toWikiSon("source",source);
 
       wikison+=toWikiSon("source",source);
Line 1,261: Line 1,376:
 
       wikison+=toWikiSon("targetMultiple",targetMultiple);
 
       wikison+=toWikiSon("targetMultiple",targetMultiple);
 
       wikison+=toWikiSon("targetDocumentation",targetDocumentation);
 
       wikison+=toWikiSon("targetDocumentation",targetDocumentation);
      wikison+=toWikiSon("masterDetail",masterDetail);
 
 
       wikison+="}}\n";
 
       wikison+="}}\n";
 
       return wikison;
 
       return wikison;
 +
    }
 +
 +
    /**
 +
    * convert this TopicLink to a SiDIF string
 +
    * @return the SiDIF representation of this TopicLink
 +
    */
 +
    public String toSiDIF() {
 +
      String siDIF = String.format("%s isA TopicLink\n",this.pageid);
 +
      siDIF+=propertySiDIF("masterDetail",masterDetail,"Boolean");
 +
      siDIF+=propertySiDIF("name",name,"Text");
 +
      siDIF+=propertySiDIF("source",source,"Page");
 +
      siDIF+=propertySiDIF("sourceRole",sourceRole,"Text");
 +
      siDIF+=propertySiDIF("sourceMultiple",sourceMultiple,"Boolean");
 +
      siDIF+=propertySiDIF("sourceDocumentation",sourceDocumentation,"Text");
 +
      siDIF+=propertySiDIF("target",target,"Page");
 +
      siDIF+=propertySiDIF("targetRole",targetRole,"Text");
 +
      siDIF+=propertySiDIF("targetMultiple",targetMultiple,"Boolean");
 +
      siDIF+=propertySiDIF("targetDocumentation",targetDocumentation,"Text");
 +
      return siDIF;
 
     }
 
     }
 
   
 
   
Line 1,292: Line 1,425:
 
     public TopicLink(TripleQuery query,String pageid) {
 
     public TopicLink(TripleQuery query,String pageid) {
 
       this.pageid=pageid;
 
       this.pageid=pageid;
 +
      Triple masterDetailTriple=query.selectSingle(pageid,"masterDetail",null);
 +
      if (masterDetailTriple==null)
 +
        masterDetailTriple=query.selectSingle(pageid,"Property:TopicLink_masterDetail",null);
 +
      if (masterDetailTriple!=null)
 +
        masterDetail=masterDetailTriple.getObject().toString();
 
       Triple nameTriple=query.selectSingle(pageid,"name",null);
 
       Triple nameTriple=query.selectSingle(pageid,"name",null);
 
       if (nameTriple==null)
 
       if (nameTriple==null)
Line 1,337: Line 1,475:
 
       if (targetDocumentationTriple!=null)  
 
       if (targetDocumentationTriple!=null)  
 
         targetDocumentation=targetDocumentationTriple.getObject().toString();
 
         targetDocumentation=targetDocumentationTriple.getObject().toString();
      Triple masterDetailTriple=query.selectSingle(pageid,"masterDetail",null);
 
      if (masterDetailTriple==null)
 
        masterDetailTriple=query.selectSingle(pageid,"Property:TopicLink_masterDetail",null);
 
      if (masterDetailTriple!=null)
 
        masterDetail=masterDetailTriple.getObject().toString();
 
 
       init(query);
 
       init(query);
 
     } // constructor for TopicLink
 
     } // constructor for TopicLink
Line 1,429: Line 1,562:
  
 
}
 
}
 +
</source>

Latest revision as of 05:57, 11 October 2019

java code

@// This is a rythm template
@// the args are the standard wikiTask arguments
@import org.sidif.triple.TripleQuery
@import org.sidif.triple.Triple
@import com.alibaba.fastjson.JSON
@args() {
  String title 
  String logo
  org.sidif.wiki.WikiTask wikiTask
  org.sidif.triple.TripleStore tripleStore
}


@def static {

  /**
   * Base class
   */
  static abstract class TopicBase {
    // each Topic has a pageid - for non subobject thats the pagename
    public String pageid;

    /**
     * get a WikiSon version of the given name value
     * 
     * @param name
     * @param value
     * @return - the string representation
     */
    public String toWikiSon(String name, String value) {
      String result = "<!-- " + name + " is null-->\n";
      if (value != null)
        result = "|" + name + "=" + value + "\n";
      return result;
    }

    /**
     * get the SiDIF representation of the given property
     * 
     * @param name - the name of the property
     * @param value - the value of the property
     * @param type - the type of the property
     * @return - the SiDIF Sting representation of the property
     */
    public static String propertySiDIF(String name, String value, String type) {
      // default is a comment line which can be filled by uncommenting
      String result = String.format("# is is %s of it\n",name);;
      // if the value is not empty
      if ((value != null) && (!("".equals(value.trim())))) {
        // do we need to quote the result?
        String quote = "";
        // this depends on the Type
        if ("Text".equals(type)) {
          quote = "\"";
        }
        // create a SIDIF Property line like
        // "John" is lastname of it
        // convert double quotes to single quotes - FIXME - should we escape instead?
        value=value.replace("\"","'");
        result = String.format("%s%s%s is %s of it\n",quote,value,quote,name);
      }
      // return the SiDIF property line
      return result;
    }

    /**
     * get me as a String
     * 
     * @param name
     * @param value
     * @return
     */
    public static String propertySiDIF(String name, String value) {
      String result = propertySiDIF(name, value, "Text");
      return result;
    }

    /**
     * check if the given boolean String value is true
     * 
     * @param value
     * @return true if the value is not null and has true/TRUE as it's string
     *         content
     */
    public boolean isTrue(String value) {
      boolean result = false;
      if (value != null && value.toLowerCase().equals("true")) {
        result = true;
      }
      return result;
    }

    /**
     * initialize
     */
    public void init(TripleQuery query) {
    }
  } // TopicBase
 /**
  * SMW_Type
  * an SMW_Type is a data type which determines the possible values for that type e.g. a Boolean can hold true/false values while a Number can hold 3.1459 or 20. A Page can hold the name of a Wiki page see https://semantic-mediawiki.org/wiki/Help:List_of_datatypes
  */
  public static class SMW_Type extends TopicBase {
  
    public String type;
    public String typepage;
    public String usedByProperties;
    public String documentation;
    public String helppage;
    public String javaType;
    public String id;

    public String getType() { return type; }
    public void setType(String pType) { type=pType; }
    public String getTypepage() { return typepage; }
    public void setTypepage(String pTypepage) { typepage=pTypepage; }
    public String getUsedByProperties() { return usedByProperties; }
    public void setUsedByProperties(String pUsedByProperties) { usedByProperties=pUsedByProperties; }
    public String getDocumentation() { return documentation; }
    public void setDocumentation(String pDocumentation) { documentation=pDocumentation; }
    public String getHelppage() { return helppage; }
    public void setHelppage(String pHelppage) { helppage=pHelppage; }
    public String getJavaType() { return javaType; }
    public void setJavaType(String pJavaType) { javaType=pJavaType; }
    public String getId() { return id; }
    public void setId(String pId) { id=pId; }
    /**
     * convert this SMW_Type to a JSON string
     */
    public String toJson() { return JSON.toJSONString(this); }

    /**
     * convert this SMW_Type to a WikiSon string
     * @return the WikiSon representation of this SMW_Type
     */
    public String toWikiSon() {
      String wikison= "{{SMW_Type\n";
      wikison+=toWikiSon("type",type);
      wikison+=toWikiSon("typepage",typepage);
      wikison+=toWikiSon("usedByProperties",usedByProperties);
      wikison+=toWikiSon("documentation",documentation);
      wikison+=toWikiSon("helppage",helppage);
      wikison+=toWikiSon("javaType",javaType);
      wikison+=toWikiSon("id",id);
      wikison+="}}\n";
      return wikison;
    }

    /**
     * convert this SMW_Type to a SiDIF string
     * @return the SiDIF representation of this SMW_Type
     */
    public String toSiDIF() {
      String siDIF = String.format("%s isA SMW_Type\n",this.pageid);
      siDIF+=propertySiDIF("type",type,"Text");
      siDIF+=propertySiDIF("typepage",typepage,"Page");
      siDIF+=propertySiDIF("usedByProperties",usedByProperties,"Page");
      siDIF+=propertySiDIF("documentation",documentation,"Text");
      siDIF+=propertySiDIF("helppage",helppage,"URL");
      siDIF+=propertySiDIF("javaType",javaType,"Text");
      siDIF+=propertySiDIF("id",id,"Text");
      return siDIF;
    }
 
    /**  
     * get the pageid for this topic
     */
    public String getPageid() { return pageid; };

    /**
     * default constructor for SMW_Type
     */
    public SMW_Type() {}

    /**
     * construct a SMW_Type from the given Triple
     * @param query - the TripleQuery to get the triples from
     * @param pSMW_TypeTriple - the triple to construct me from
     */
    public SMW_Type(TripleQuery query,Triple pSMW_TypeTriple) {
      this(query,pSMW_TypeTriple.getSubject().toString());
    } // constructor

    /**
     * construct a SMW_Type from the given pageId
     * @param query - the TripleQuery to get the triples from
     * @param pageid - pageid
     */
    public SMW_Type(TripleQuery query,String pageid) {
      this.pageid=pageid;
      Triple typeTriple=query.selectSingle(pageid,"type",null);
      if (typeTriple==null)
        typeTriple=query.selectSingle(pageid,"Property:SMW_Type_type",null);
      if (typeTriple!=null) 
        type=typeTriple.getObject().toString();
      Triple typepageTriple=query.selectSingle(pageid,"typepage",null);
      if (typepageTriple==null)
        typepageTriple=query.selectSingle(pageid,"Property:SMW_Type_typepage",null);
      if (typepageTriple!=null) 
        typepage=typepageTriple.getObject().toString();
      Triple usedByPropertiesTriple=query.selectSingle(pageid,"usedByProperties",null);
      if (usedByPropertiesTriple==null)
        usedByPropertiesTriple=query.selectSingle(pageid,"Property:SMW_Type_usedByProperties",null);
      if (usedByPropertiesTriple!=null) 
        usedByProperties=usedByPropertiesTriple.getObject().toString();
      Triple documentationTriple=query.selectSingle(pageid,"documentation",null);
      if (documentationTriple==null)
        documentationTriple=query.selectSingle(pageid,"Property:SMW_Type_documentation",null);
      if (documentationTriple!=null) 
        documentation=documentationTriple.getObject().toString();
      Triple helppageTriple=query.selectSingle(pageid,"helppage",null);
      if (helppageTriple==null)
        helppageTriple=query.selectSingle(pageid,"Property:SMW_Type_helppage",null);
      if (helppageTriple!=null) 
        helppage=helppageTriple.getObject().toString();
      Triple javaTypeTriple=query.selectSingle(pageid,"javaType",null);
      if (javaTypeTriple==null)
        javaTypeTriple=query.selectSingle(pageid,"Property:SMW_Type_javaType",null);
      if (javaTypeTriple!=null) 
        javaType=javaTypeTriple.getObject().toString();
      Triple idTriple=query.selectSingle(pageid,"id",null);
      if (idTriple==null)
        idTriple=query.selectSingle(pageid,"Property:SMW_Type_id",null);
      if (idTriple!=null) 
        id=idTriple.getObject().toString();
      init(query);
    } // constructor for SMW_Type
    
    // >>>{user defined topic code}{SMW_Type}{SMW_Type}
    // <<<{user defined topic code}{SMW_Type}{SMW_Type}
  } // class SMW_Type
  /**
   * Manager for SMW_Type
   */
  public static class SMW_TypeManager extends TopicBase {
 
    public String topicName="SMW_Type";
    public transient List<SMW_Type> mSMW_Types=new ArrayList<SMW_Type>();
    public transient Map<String,SMW_Type> mSMW_TypeMap=new LinkedHashMap<String,SMW_Type>();

    /**
     * get my SMW_Types
     */
    public List<SMW_Type> getSMW_Types() {
      List<SMW_Type> result=this.mSMW_Types;
      return result;
    }

    /**
     *  add a new SMW_Type 
     */
    public SMW_Type add(SMW_Type pSMW_Type) {
      mSMW_Types.add(pSMW_Type);
      mSMW_TypeMap.put(pSMW_Type.getPageid(),pSMW_Type);
      return pSMW_Type;
    }

    /**
     *  add a new SMW_Type from the given triple
     */
    public SMW_Type add(TripleQuery query,Triple pSMW_TypeTriple) {
      SMW_Type lSMW_Type=new SMW_Type(query,pSMW_TypeTriple);
      add(lSMW_Type);
      return lSMW_Type;
    }

    // reinitialize my mSMW_Type map
    public void reinit() {
      mSMW_TypeMap.clear();
      for (SMW_Type lSMW_Type:mSMW_Types) {
        mSMW_TypeMap.put(lSMW_Type.getPageid(),lSMW_Type);
      }
    }

    // convert this manager to json format 
    public String toJson() { return JSON.toJSONString(this); }
    
    // get a new manager from the given json string
    public static SMW_TypeManager fromJson(String json) {
      SMW_TypeManager result=JSON.parseObject(json, SMW_TypeManager.class);
      result.reinit();
      return result;
    }

    // default constructor for SMW_Type Manager
    public SMW_TypeManager() {}

    // add SMW_Types from the given query
    public void addSMW_Types(TripleQuery pSMW_TypeQuery,TripleQuery query) {
      if (pSMW_TypeQuery!=null) {
        for (Triple lSMW_TypeTriple:pSMW_TypeQuery.getTriples()) {
          add(query,lSMW_TypeTriple);
        }
      }
    }

    // construct me from the given triple Query query
    public SMW_TypeManager(TripleQuery query) {
      // first query the SiDIF bases triplestore
      TripleQuery lSMW_TypeQuery=query.query(null,"isA","SMW_Type");
      addSMW_Types(lSMW_TypeQuery,query);
      // then the SMW triplestore
      lSMW_TypeQuery=query.query(null,"Property:IsA","SMW_Type");
      addSMW_Types(lSMW_TypeQuery,query);
      init(query);
    } // constructor for SMW_Type Manager
    
    // >>>{user defined topicmanager code}{SMW_Type}{SMW_Type}
    // <<<{user defined topicmanager code}{SMW_Type}{SMW_Type}
  } // class SMW_Type Manager
 /**
  * Property
  * a Property is a Feature/Attribute of a Topic
  */
  public static class Property extends TopicBase {
  
    public String index;
    public String sortPos;
    public String mandatory;
    public String uploadable;
    public String defaultValue;
    public String inputType;
    public String allowedValues;
    public String values_from;
    public String showInGrid;
    public String isLink;
    public String type;
    public String name;
    public String label;
    public String primaryKey;
    public String namespace;
    public String size;
    public String documentation;
    public String nullable;
    public String topic;

    public String getIndex() { return index; }
    public void setIndex(String pIndex) { index=pIndex; }
    public String getSortPos() { return sortPos; }
    public void setSortPos(String pSortPos) { sortPos=pSortPos; }
    public String getMandatory() { return mandatory; }
    public void setMandatory(String pMandatory) { mandatory=pMandatory; }
    public String getUploadable() { return uploadable; }
    public void setUploadable(String pUploadable) { uploadable=pUploadable; }
    public String getDefaultValue() { return defaultValue; }
    public void setDefaultValue(String pDefaultValue) { defaultValue=pDefaultValue; }
    public String getInputType() { return inputType; }
    public void setInputType(String pInputType) { inputType=pInputType; }
    public String getAllowedValues() { return allowedValues; }
    public void setAllowedValues(String pAllowedValues) { allowedValues=pAllowedValues; }
    public String getValues_from() { return values_from; }
    public void setValues_from(String pValues_from) { values_from=pValues_from; }
    public String getShowInGrid() { return showInGrid; }
    public void setShowInGrid(String pShowInGrid) { showInGrid=pShowInGrid; }
    public String getIsLink() { return isLink; }
    public void setIsLink(String pIsLink) { isLink=pIsLink; }
    public String getType() { return type; }
    public void setType(String pType) { type=pType; }
    public String getName() { return name; }
    public void setName(String pName) { name=pName; }
    public String getLabel() { return label; }
    public void setLabel(String pLabel) { label=pLabel; }
    public String getPrimaryKey() { return primaryKey; }
    public void setPrimaryKey(String pPrimaryKey) { primaryKey=pPrimaryKey; }
    public String getNamespace() { return namespace; }
    public void setNamespace(String pNamespace) { namespace=pNamespace; }
    public String getSize() { return size; }
    public void setSize(String pSize) { size=pSize; }
    public String getDocumentation() { return documentation; }
    public void setDocumentation(String pDocumentation) { documentation=pDocumentation; }
    public String getNullable() { return nullable; }
    public void setNullable(String pNullable) { nullable=pNullable; }
    public String getTopic() { return topic; }
    public void setTopic(String pTopic) { topic=pTopic; }
    /**
     * convert this Property to a JSON string
     */
    public String toJson() { return JSON.toJSONString(this); }

    /**
     * convert this Property to a WikiSon string
     * @return the WikiSon representation of this Property
     */
    public String toWikiSon() {
      String wikison= "{{Property\n";
      wikison+=toWikiSon("index",index);
      wikison+=toWikiSon("sortPos",sortPos);
      wikison+=toWikiSon("mandatory",mandatory);
      wikison+=toWikiSon("uploadable",uploadable);
      wikison+=toWikiSon("defaultValue",defaultValue);
      wikison+=toWikiSon("inputType",inputType);
      wikison+=toWikiSon("allowedValues",allowedValues);
      wikison+=toWikiSon("values_from",values_from);
      wikison+=toWikiSon("showInGrid",showInGrid);
      wikison+=toWikiSon("isLink",isLink);
      wikison+=toWikiSon("type",type);
      wikison+=toWikiSon("name",name);
      wikison+=toWikiSon("label",label);
      wikison+=toWikiSon("primaryKey",primaryKey);
      wikison+=toWikiSon("namespace",namespace);
      wikison+=toWikiSon("size",size);
      wikison+=toWikiSon("documentation",documentation);
      wikison+=toWikiSon("nullable",nullable);
      wikison+=toWikiSon("topic",topic);
      wikison+="}}\n";
      return wikison;
    }

    /**
     * convert this Property to a SiDIF string
     * @return the SiDIF representation of this Property
     */
    public String toSiDIF() {
      String siDIF = String.format("%s isA Property\n",this.pageid);
      siDIF+=propertySiDIF("index",index,"Number");
      siDIF+=propertySiDIF("sortPos",sortPos,"Number");
      siDIF+=propertySiDIF("mandatory",mandatory,"Boolean");
      siDIF+=propertySiDIF("uploadable",uploadable,"Boolean");
      siDIF+=propertySiDIF("defaultValue",defaultValue,"Code");
      siDIF+=propertySiDIF("inputType",inputType,"Text");
      siDIF+=propertySiDIF("allowedValues",allowedValues,"Text");
      siDIF+=propertySiDIF("values_from",values_from,"Code");
      siDIF+=propertySiDIF("showInGrid",showInGrid,"Boolean");
      siDIF+=propertySiDIF("isLink",isLink,"Boolean");
      siDIF+=propertySiDIF("type",type,"Page");
      siDIF+=propertySiDIF("name",name,"Text");
      siDIF+=propertySiDIF("label",label,"Text");
      siDIF+=propertySiDIF("primaryKey",primaryKey,"Boolean");
      siDIF+=propertySiDIF("namespace",namespace,"Text");
      siDIF+=propertySiDIF("size",size,"Number");
      siDIF+=propertySiDIF("documentation",documentation,"Text");
      siDIF+=propertySiDIF("nullable",nullable,"Boolean");
      siDIF+=propertySiDIF("topic",topic,"Page");
      return siDIF;
    }
 
    /**  
     * get the pageid for this topic
     */
    public String getPageid() { return pageid; };

    /**
     * default constructor for Property
     */
    public Property() {}

    /**
     * construct a Property from the given Triple
     * @param query - the TripleQuery to get the triples from
     * @param pPropertyTriple - the triple to construct me from
     */
    public Property(TripleQuery query,Triple pPropertyTriple) {
      this(query,pPropertyTriple.getSubject().toString());
    } // constructor

    /**
     * construct a Property from the given pageId
     * @param query - the TripleQuery to get the triples from
     * @param pageid - pageid
     */
    public Property(TripleQuery query,String pageid) {
      this.pageid=pageid;
      Triple indexTriple=query.selectSingle(pageid,"index",null);
      if (indexTriple==null)
        indexTriple=query.selectSingle(pageid,"Property:Property_index",null);
      if (indexTriple!=null) 
        index=indexTriple.getObject().toString();
      Triple sortPosTriple=query.selectSingle(pageid,"sortPos",null);
      if (sortPosTriple==null)
        sortPosTriple=query.selectSingle(pageid,"Property:Property_sortPos",null);
      if (sortPosTriple!=null) 
        sortPos=sortPosTriple.getObject().toString();
      Triple mandatoryTriple=query.selectSingle(pageid,"mandatory",null);
      if (mandatoryTriple==null)
        mandatoryTriple=query.selectSingle(pageid,"Property:Property_mandatory",null);
      if (mandatoryTriple!=null) 
        mandatory=mandatoryTriple.getObject().toString();
      Triple uploadableTriple=query.selectSingle(pageid,"uploadable",null);
      if (uploadableTriple==null)
        uploadableTriple=query.selectSingle(pageid,"Property:Property_uploadable",null);
      if (uploadableTriple!=null) 
        uploadable=uploadableTriple.getObject().toString();
      Triple defaultValueTriple=query.selectSingle(pageid,"defaultValue",null);
      if (defaultValueTriple==null)
        defaultValueTriple=query.selectSingle(pageid,"Property:Property_defaultValue",null);
      if (defaultValueTriple!=null) 
        defaultValue=defaultValueTriple.getObject().toString();
      Triple inputTypeTriple=query.selectSingle(pageid,"inputType",null);
      if (inputTypeTriple==null)
        inputTypeTriple=query.selectSingle(pageid,"Property:Property_inputType",null);
      if (inputTypeTriple!=null) 
        inputType=inputTypeTriple.getObject().toString();
      Triple allowedValuesTriple=query.selectSingle(pageid,"allowedValues",null);
      if (allowedValuesTriple==null)
        allowedValuesTriple=query.selectSingle(pageid,"Property:Property_allowedValues",null);
      if (allowedValuesTriple!=null) 
        allowedValues=allowedValuesTriple.getObject().toString();
      Triple values_fromTriple=query.selectSingle(pageid,"values_from",null);
      if (values_fromTriple==null)
        values_fromTriple=query.selectSingle(pageid,"Property:Property_values_from",null);
      if (values_fromTriple!=null) 
        values_from=values_fromTriple.getObject().toString();
      Triple showInGridTriple=query.selectSingle(pageid,"showInGrid",null);
      if (showInGridTriple==null)
        showInGridTriple=query.selectSingle(pageid,"Property:Property_showInGrid",null);
      if (showInGridTriple!=null) 
        showInGrid=showInGridTriple.getObject().toString();
      Triple isLinkTriple=query.selectSingle(pageid,"isLink",null);
      if (isLinkTriple==null)
        isLinkTriple=query.selectSingle(pageid,"Property:Property_isLink",null);
      if (isLinkTriple!=null) 
        isLink=isLinkTriple.getObject().toString();
      Triple typeTriple=query.selectSingle(pageid,"type",null);
      if (typeTriple==null)
        typeTriple=query.selectSingle(pageid,"Property:Property_type",null);
      if (typeTriple!=null) 
        type=typeTriple.getObject().toString();
      Triple nameTriple=query.selectSingle(pageid,"name",null);
      if (nameTriple==null)
        nameTriple=query.selectSingle(pageid,"Property:Property_name",null);
      if (nameTriple!=null) 
        name=nameTriple.getObject().toString();
      Triple labelTriple=query.selectSingle(pageid,"label",null);
      if (labelTriple==null)
        labelTriple=query.selectSingle(pageid,"Property:Property_label",null);
      if (labelTriple!=null) 
        label=labelTriple.getObject().toString();
      Triple primaryKeyTriple=query.selectSingle(pageid,"primaryKey",null);
      if (primaryKeyTriple==null)
        primaryKeyTriple=query.selectSingle(pageid,"Property:Property_primaryKey",null);
      if (primaryKeyTriple!=null) 
        primaryKey=primaryKeyTriple.getObject().toString();
      Triple namespaceTriple=query.selectSingle(pageid,"namespace",null);
      if (namespaceTriple==null)
        namespaceTriple=query.selectSingle(pageid,"Property:Property_namespace",null);
      if (namespaceTriple!=null) 
        namespace=namespaceTriple.getObject().toString();
      Triple sizeTriple=query.selectSingle(pageid,"size",null);
      if (sizeTriple==null)
        sizeTriple=query.selectSingle(pageid,"Property:Property_size",null);
      if (sizeTriple!=null) 
        size=sizeTriple.getObject().toString();
      Triple documentationTriple=query.selectSingle(pageid,"documentation",null);
      if (documentationTriple==null)
        documentationTriple=query.selectSingle(pageid,"Property:Property_documentation",null);
      if (documentationTriple!=null) 
        documentation=documentationTriple.getObject().toString();
      Triple nullableTriple=query.selectSingle(pageid,"nullable",null);
      if (nullableTriple==null)
        nullableTriple=query.selectSingle(pageid,"Property:Property_nullable",null);
      if (nullableTriple!=null) 
        nullable=nullableTriple.getObject().toString();
      Triple topicTriple=query.selectSingle(pageid,"topic",null);
      if (topicTriple==null)
        topicTriple=query.selectSingle(pageid,"Property:Property_topic",null);
      if (topicTriple!=null) 
        topic=topicTriple.getObject().toString();
      init(query);
    } // constructor for Property
    
    // >>>{user defined topic code}{Property}{Property}
    // <<<{user defined topic code}{Property}{Property}
  } // class Property
  /**
   * Manager for Property
   */
  public static class PropertyManager extends TopicBase {
 
    public String topicName="Property";
    public transient List<Property> mPropertys=new ArrayList<Property>();
    public transient Map<String,Property> mPropertyMap=new LinkedHashMap<String,Property>();

    /**
     * get my Properties
     */
    public List<Property> getProperties() {
      List<Property> result=this.mPropertys;
      return result;
    }

    /**
     *  add a new Property 
     */
    public Property add(Property pProperty) {
      mPropertys.add(pProperty);
      mPropertyMap.put(pProperty.getPageid(),pProperty);
      return pProperty;
    }

    /**
     *  add a new Property from the given triple
     */
    public Property add(TripleQuery query,Triple pPropertyTriple) {
      Property lProperty=new Property(query,pPropertyTriple);
      add(lProperty);
      return lProperty;
    }

    // reinitialize my mProperty map
    public void reinit() {
      mPropertyMap.clear();
      for (Property lProperty:mPropertys) {
        mPropertyMap.put(lProperty.getPageid(),lProperty);
      }
    }

    // convert this manager to json format 
    public String toJson() { return JSON.toJSONString(this); }
    
    // get a new manager from the given json string
    public static PropertyManager fromJson(String json) {
      PropertyManager result=JSON.parseObject(json, PropertyManager.class);
      result.reinit();
      return result;
    }

    // default constructor for Property Manager
    public PropertyManager() {}

    // add Properties from the given query
    public void addProperties(TripleQuery pPropertyQuery,TripleQuery query) {
      if (pPropertyQuery!=null) {
        for (Triple lPropertyTriple:pPropertyQuery.getTriples()) {
          add(query,lPropertyTriple);
        }
      }
    }

    // construct me from the given triple Query query
    public PropertyManager(TripleQuery query) {
      // first query the SiDIF bases triplestore
      TripleQuery lPropertyQuery=query.query(null,"isA","Property");
      addProperties(lPropertyQuery,query);
      // then the SMW triplestore
      lPropertyQuery=query.query(null,"Property:IsA","Property");
      addProperties(lPropertyQuery,query);
      init(query);
    } // constructor for Property Manager
    
    // >>>{user defined topicmanager code}{Property}{Property}
    // <<<{user defined topicmanager code}{Property}{Property}
  } // class Property Manager
 /**
  * Context
  * A Context groups some topics like a Namespace/Package
  */
  public static class Context extends TopicBase {
  
    public String name;
    public String since;
    public String master;

    public String getName() { return name; }
    public void setName(String pName) { name=pName; }
    public String getSince() { return since; }
    public void setSince(String pSince) { since=pSince; }
    public String getMaster() { return master; }
    public void setMaster(String pMaster) { master=pMaster; }
    /**
     * convert this Context to a JSON string
     */
    public String toJson() { return JSON.toJSONString(this); }

    /**
     * convert this Context to a WikiSon string
     * @return the WikiSon representation of this Context
     */
    public String toWikiSon() {
      String wikison= "{{Context\n";
      wikison+=toWikiSon("name",name);
      wikison+=toWikiSon("since",since);
      wikison+=toWikiSon("master",master);
      wikison+="}}\n";
      return wikison;
    }

    /**
     * convert this Context to a SiDIF string
     * @return the SiDIF representation of this Context
     */
    public String toSiDIF() {
      String siDIF = String.format("%s isA Context\n",this.pageid);
      siDIF+=propertySiDIF("name",name,"Text");
      siDIF+=propertySiDIF("since",since,"Date");
      siDIF+=propertySiDIF("master",master,"URL");
      return siDIF;
    }
 
    /**  
     * get the pageid for this topic
     */
    public String getPageid() { return pageid; };

    /**
     * default constructor for Context
     */
    public Context() {}

    /**
     * construct a Context from the given Triple
     * @param query - the TripleQuery to get the triples from
     * @param pContextTriple - the triple to construct me from
     */
    public Context(TripleQuery query,Triple pContextTriple) {
      this(query,pContextTriple.getSubject().toString());
    } // constructor

    /**
     * construct a Context from the given pageId
     * @param query - the TripleQuery to get the triples from
     * @param pageid - pageid
     */
    public Context(TripleQuery query,String pageid) {
      this.pageid=pageid;
      Triple nameTriple=query.selectSingle(pageid,"name",null);
      if (nameTriple==null)
        nameTriple=query.selectSingle(pageid,"Property:Context_name",null);
      if (nameTriple!=null) 
        name=nameTriple.getObject().toString();
      Triple sinceTriple=query.selectSingle(pageid,"since",null);
      if (sinceTriple==null)
        sinceTriple=query.selectSingle(pageid,"Property:Context_since",null);
      if (sinceTriple!=null) 
        since=sinceTriple.getObject().toString();
      Triple masterTriple=query.selectSingle(pageid,"master",null);
      if (masterTriple==null)
        masterTriple=query.selectSingle(pageid,"Property:Context_master",null);
      if (masterTriple!=null) 
        master=masterTriple.getObject().toString();
      init(query);
    } // constructor for Context
    
    // >>>{user defined topic code}{Context}{Context}
    // <<<{user defined topic code}{Context}{Context}
  } // class Context
  /**
   * Manager for Context
   */
  public static class ContextManager extends TopicBase {
 
    public String topicName="Context";
    public transient List<Context> mContexts=new ArrayList<Context>();
    public transient Map<String,Context> mContextMap=new LinkedHashMap<String,Context>();

    /**
     * get my Contexts
     */
    public List<Context> getContexts() {
      List<Context> result=this.mContexts;
      return result;
    }

    /**
     *  add a new Context 
     */
    public Context add(Context pContext) {
      mContexts.add(pContext);
      mContextMap.put(pContext.getPageid(),pContext);
      return pContext;
    }

    /**
     *  add a new Context from the given triple
     */
    public Context add(TripleQuery query,Triple pContextTriple) {
      Context lContext=new Context(query,pContextTriple);
      add(lContext);
      return lContext;
    }

    // reinitialize my mContext map
    public void reinit() {
      mContextMap.clear();
      for (Context lContext:mContexts) {
        mContextMap.put(lContext.getPageid(),lContext);
      }
    }

    // convert this manager to json format 
    public String toJson() { return JSON.toJSONString(this); }
    
    // get a new manager from the given json string
    public static ContextManager fromJson(String json) {
      ContextManager result=JSON.parseObject(json, ContextManager.class);
      result.reinit();
      return result;
    }

    // default constructor for Context Manager
    public ContextManager() {}

    // add Contexts from the given query
    public void addContexts(TripleQuery pContextQuery,TripleQuery query) {
      if (pContextQuery!=null) {
        for (Triple lContextTriple:pContextQuery.getTriples()) {
          add(query,lContextTriple);
        }
      }
    }

    // construct me from the given triple Query query
    public ContextManager(TripleQuery query) {
      // first query the SiDIF bases triplestore
      TripleQuery lContextQuery=query.query(null,"isA","Context");
      addContexts(lContextQuery,query);
      // then the SMW triplestore
      lContextQuery=query.query(null,"Property:IsA","Context");
      addContexts(lContextQuery,query);
      init(query);
    } // constructor for Context Manager
    
    // >>>{user defined topicmanager code}{Context}{Context}
    // <<<{user defined topicmanager code}{Context}{Context}
  } // class Context Manager
 /**
  * Topic
  * A Topic is a Concept/Class/Thing/Entity
  */
  public static class Topic extends TopicBase {
  
    public String pluralName;
    public String documentation;
    public String cargo;
    public String name;
    public String icon;
    public String iconUrl;
    public String wikiDocumentation;
    public String defaultstoremode;
    public String listLimit;
    public String headerTabs;
    public String context;

    public String getPluralName() { return pluralName; }
    public void setPluralName(String pPluralName) { pluralName=pPluralName; }
    public String getDocumentation() { return documentation; }
    public void setDocumentation(String pDocumentation) { documentation=pDocumentation; }
    public String getCargo() { return cargo; }
    public void setCargo(String pCargo) { cargo=pCargo; }
    public String getName() { return name; }
    public void setName(String pName) { name=pName; }
    public String getIcon() { return icon; }
    public void setIcon(String pIcon) { icon=pIcon; }
    public String getIconUrl() { return iconUrl; }
    public void setIconUrl(String pIconUrl) { iconUrl=pIconUrl; }
    public String getWikiDocumentation() { return wikiDocumentation; }
    public void setWikiDocumentation(String pWikiDocumentation) { wikiDocumentation=pWikiDocumentation; }
    public String getDefaultstoremode() { return defaultstoremode; }
    public void setDefaultstoremode(String pDefaultstoremode) { defaultstoremode=pDefaultstoremode; }
    public String getListLimit() { return listLimit; }
    public void setListLimit(String pListLimit) { listLimit=pListLimit; }
    public String getHeaderTabs() { return headerTabs; }
    public void setHeaderTabs(String pHeaderTabs) { headerTabs=pHeaderTabs; }
    public String getContext() { return context; }
    public void setContext(String pContext) { context=pContext; }
    /**
     * convert this Topic to a JSON string
     */
    public String toJson() { return JSON.toJSONString(this); }

    /**
     * convert this Topic to a WikiSon string
     * @return the WikiSon representation of this Topic
     */
    public String toWikiSon() {
      String wikison= "{{Topic\n";
      wikison+=toWikiSon("pluralName",pluralName);
      wikison+=toWikiSon("documentation",documentation);
      wikison+=toWikiSon("cargo",cargo);
      wikison+=toWikiSon("name",name);
      wikison+=toWikiSon("icon",icon);
      wikison+=toWikiSon("iconUrl",iconUrl);
      wikison+=toWikiSon("wikiDocumentation",wikiDocumentation);
      wikison+=toWikiSon("defaultstoremode",defaultstoremode);
      wikison+=toWikiSon("listLimit",listLimit);
      wikison+=toWikiSon("headerTabs",headerTabs);
      wikison+=toWikiSon("context",context);
      wikison+="}}\n";
      return wikison;
    }

    /**
     * convert this Topic to a SiDIF string
     * @return the SiDIF representation of this Topic
     */
    public String toSiDIF() {
      String siDIF = String.format("%s isA Topic\n",this.pageid);
      siDIF+=propertySiDIF("pluralName",pluralName,"Text");
      siDIF+=propertySiDIF("documentation",documentation,"Text");
      siDIF+=propertySiDIF("cargo",cargo,"Boolean");
      siDIF+=propertySiDIF("name",name,"Text");
      siDIF+=propertySiDIF("icon",icon,"Page");
      siDIF+=propertySiDIF("iconUrl",iconUrl,"Code");
      siDIF+=propertySiDIF("wikiDocumentation",wikiDocumentation,"Text");
      siDIF+=propertySiDIF("defaultstoremode",defaultstoremode,"Text");
      siDIF+=propertySiDIF("listLimit",listLimit,"Number");
      siDIF+=propertySiDIF("headerTabs",headerTabs,"Boolean");
      siDIF+=propertySiDIF("context",context,"Page");
      return siDIF;
    }
 
    /**  
     * get the pageid for this topic
     */
    public String getPageid() { return pageid; };

    /**
     * default constructor for Topic
     */
    public Topic() {}

    /**
     * construct a Topic from the given Triple
     * @param query - the TripleQuery to get the triples from
     * @param pTopicTriple - the triple to construct me from
     */
    public Topic(TripleQuery query,Triple pTopicTriple) {
      this(query,pTopicTriple.getSubject().toString());
    } // constructor

    /**
     * construct a Topic from the given pageId
     * @param query - the TripleQuery to get the triples from
     * @param pageid - pageid
     */
    public Topic(TripleQuery query,String pageid) {
      this.pageid=pageid;
      Triple pluralNameTriple=query.selectSingle(pageid,"pluralName",null);
      if (pluralNameTriple==null)
        pluralNameTriple=query.selectSingle(pageid,"Property:Topic_pluralName",null);
      if (pluralNameTriple!=null) 
        pluralName=pluralNameTriple.getObject().toString();
      Triple documentationTriple=query.selectSingle(pageid,"documentation",null);
      if (documentationTriple==null)
        documentationTriple=query.selectSingle(pageid,"Property:Topic_documentation",null);
      if (documentationTriple!=null) 
        documentation=documentationTriple.getObject().toString();
      Triple cargoTriple=query.selectSingle(pageid,"cargo",null);
      if (cargoTriple==null)
        cargoTriple=query.selectSingle(pageid,"Property:Topic_cargo",null);
      if (cargoTriple!=null) 
        cargo=cargoTriple.getObject().toString();
      Triple nameTriple=query.selectSingle(pageid,"name",null);
      if (nameTriple==null)
        nameTriple=query.selectSingle(pageid,"Property:Topic_name",null);
      if (nameTriple!=null) 
        name=nameTriple.getObject().toString();
      Triple iconTriple=query.selectSingle(pageid,"icon",null);
      if (iconTriple==null)
        iconTriple=query.selectSingle(pageid,"Property:Topic_icon",null);
      if (iconTriple!=null) 
        icon=iconTriple.getObject().toString();
      Triple iconUrlTriple=query.selectSingle(pageid,"iconUrl",null);
      if (iconUrlTriple==null)
        iconUrlTriple=query.selectSingle(pageid,"Property:Topic_iconUrl",null);
      if (iconUrlTriple!=null) 
        iconUrl=iconUrlTriple.getObject().toString();
      Triple wikiDocumentationTriple=query.selectSingle(pageid,"wikiDocumentation",null);
      if (wikiDocumentationTriple==null)
        wikiDocumentationTriple=query.selectSingle(pageid,"Property:Topic_wikiDocumentation",null);
      if (wikiDocumentationTriple!=null) 
        wikiDocumentation=wikiDocumentationTriple.getObject().toString();
      Triple defaultstoremodeTriple=query.selectSingle(pageid,"defaultstoremode",null);
      if (defaultstoremodeTriple==null)
        defaultstoremodeTriple=query.selectSingle(pageid,"Property:Topic_defaultstoremode",null);
      if (defaultstoremodeTriple!=null) 
        defaultstoremode=defaultstoremodeTriple.getObject().toString();
      Triple listLimitTriple=query.selectSingle(pageid,"listLimit",null);
      if (listLimitTriple==null)
        listLimitTriple=query.selectSingle(pageid,"Property:Topic_listLimit",null);
      if (listLimitTriple!=null) 
        listLimit=listLimitTriple.getObject().toString();
      Triple headerTabsTriple=query.selectSingle(pageid,"headerTabs",null);
      if (headerTabsTriple==null)
        headerTabsTriple=query.selectSingle(pageid,"Property:Topic_headerTabs",null);
      if (headerTabsTriple!=null) 
        headerTabs=headerTabsTriple.getObject().toString();
      Triple contextTriple=query.selectSingle(pageid,"context",null);
      if (contextTriple==null)
        contextTriple=query.selectSingle(pageid,"Property:Topic_context",null);
      if (contextTriple!=null) 
        context=contextTriple.getObject().toString();
      init(query);
    } // constructor for Topic
    
    // >>>{user defined topic code}{Topic}{Topic}
    // <<<{user defined topic code}{Topic}{Topic}
  } // class Topic
  /**
   * Manager for Topic
   */
  public static class TopicManager extends TopicBase {
 
    public String topicName="Topic";
    public transient List<Topic> mTopics=new ArrayList<Topic>();
    public transient Map<String,Topic> mTopicMap=new LinkedHashMap<String,Topic>();

    /**
     * get my Topics
     */
    public List<Topic> getTopics() {
      List<Topic> result=this.mTopics;
      return result;
    }

    /**
     *  add a new Topic 
     */
    public Topic add(Topic pTopic) {
      mTopics.add(pTopic);
      mTopicMap.put(pTopic.getPageid(),pTopic);
      return pTopic;
    }

    /**
     *  add a new Topic from the given triple
     */
    public Topic add(TripleQuery query,Triple pTopicTriple) {
      Topic lTopic=new Topic(query,pTopicTriple);
      add(lTopic);
      return lTopic;
    }

    // reinitialize my mTopic map
    public void reinit() {
      mTopicMap.clear();
      for (Topic lTopic:mTopics) {
        mTopicMap.put(lTopic.getPageid(),lTopic);
      }
    }

    // convert this manager to json format 
    public String toJson() { return JSON.toJSONString(this); }
    
    // get a new manager from the given json string
    public static TopicManager fromJson(String json) {
      TopicManager result=JSON.parseObject(json, TopicManager.class);
      result.reinit();
      return result;
    }

    // default constructor for Topic Manager
    public TopicManager() {}

    // add Topics from the given query
    public void addTopics(TripleQuery pTopicQuery,TripleQuery query) {
      if (pTopicQuery!=null) {
        for (Triple lTopicTriple:pTopicQuery.getTriples()) {
          add(query,lTopicTriple);
        }
      }
    }

    // construct me from the given triple Query query
    public TopicManager(TripleQuery query) {
      // first query the SiDIF bases triplestore
      TripleQuery lTopicQuery=query.query(null,"isA","Topic");
      addTopics(lTopicQuery,query);
      // then the SMW triplestore
      lTopicQuery=query.query(null,"Property:IsA","Topic");
      addTopics(lTopicQuery,query);
      init(query);
    } // constructor for Topic Manager
    
    // >>>{user defined topicmanager code}{Topic}{Topic}
    // <<<{user defined topicmanager code}{Topic}{Topic}
  } // class Topic Manager
 /**
  * Action
  * An action/function/operation to be performed
  */
  public static class Action extends TopicBase {
  
    public String name;
    public String servicetype;
    public String service;
    public String inputtype;
    public String input;
    public String actionpage;
    public String output;
    public String engine;
    public String author;
    public String since;
    public String comment;

    public String getName() { return name; }
    public void setName(String pName) { name=pName; }
    public String getServicetype() { return servicetype; }
    public void setServicetype(String pServicetype) { servicetype=pServicetype; }
    public String getService() { return service; }
    public void setService(String pService) { service=pService; }
    public String getInputtype() { return inputtype; }
    public void setInputtype(String pInputtype) { inputtype=pInputtype; }
    public String getInput() { return input; }
    public void setInput(String pInput) { input=pInput; }
    public String getActionpage() { return actionpage; }
    public void setActionpage(String pActionpage) { actionpage=pActionpage; }
    public String getOutput() { return output; }
    public void setOutput(String pOutput) { output=pOutput; }
    public String getEngine() { return engine; }
    public void setEngine(String pEngine) { engine=pEngine; }
    public String getAuthor() { return author; }
    public void setAuthor(String pAuthor) { author=pAuthor; }
    public String getSince() { return since; }
    public void setSince(String pSince) { since=pSince; }
    public String getComment() { return comment; }
    public void setComment(String pComment) { comment=pComment; }
    /**
     * convert this Action to a JSON string
     */
    public String toJson() { return JSON.toJSONString(this); }

    /**
     * convert this Action to a WikiSon string
     * @return the WikiSon representation of this Action
     */
    public String toWikiSon() {
      String wikison= "{{Action\n";
      wikison+=toWikiSon("name",name);
      wikison+=toWikiSon("servicetype",servicetype);
      wikison+=toWikiSon("service",service);
      wikison+=toWikiSon("inputtype",inputtype);
      wikison+=toWikiSon("input",input);
      wikison+=toWikiSon("actionpage",actionpage);
      wikison+=toWikiSon("output",output);
      wikison+=toWikiSon("engine",engine);
      wikison+=toWikiSon("author",author);
      wikison+=toWikiSon("since",since);
      wikison+=toWikiSon("comment",comment);
      wikison+="}}\n";
      return wikison;
    }

    /**
     * convert this Action to a SiDIF string
     * @return the SiDIF representation of this Action
     */
    public String toSiDIF() {
      String siDIF = String.format("%s isA Action\n",this.pageid);
      siDIF+=propertySiDIF("name",name,"Text");
      siDIF+=propertySiDIF("servicetype",servicetype,"Text");
      siDIF+=propertySiDIF("service",service,"URL");
      siDIF+=propertySiDIF("inputtype",inputtype,"Text");
      siDIF+=propertySiDIF("input",input,"Code");
      siDIF+=propertySiDIF("actionpage",actionpage,"Page");
      siDIF+=propertySiDIF("output",output,"Text");
      siDIF+=propertySiDIF("engine",engine,"Text");
      siDIF+=propertySiDIF("author",author,"Page");
      siDIF+=propertySiDIF("since",since,"Date");
      siDIF+=propertySiDIF("comment",comment,"Text");
      return siDIF;
    }
 
    /**  
     * get the pageid for this topic
     */
    public String getPageid() { return pageid; };

    /**
     * default constructor for Action
     */
    public Action() {}

    /**
     * construct a Action from the given Triple
     * @param query - the TripleQuery to get the triples from
     * @param pActionTriple - the triple to construct me from
     */
    public Action(TripleQuery query,Triple pActionTriple) {
      this(query,pActionTriple.getSubject().toString());
    } // constructor

    /**
     * construct a Action from the given pageId
     * @param query - the TripleQuery to get the triples from
     * @param pageid - pageid
     */
    public Action(TripleQuery query,String pageid) {
      this.pageid=pageid;
      Triple nameTriple=query.selectSingle(pageid,"name",null);
      if (nameTriple==null)
        nameTriple=query.selectSingle(pageid,"Property:Action_name",null);
      if (nameTriple!=null) 
        name=nameTriple.getObject().toString();
      Triple servicetypeTriple=query.selectSingle(pageid,"servicetype",null);
      if (servicetypeTriple==null)
        servicetypeTriple=query.selectSingle(pageid,"Property:Action_servicetype",null);
      if (servicetypeTriple!=null) 
        servicetype=servicetypeTriple.getObject().toString();
      Triple serviceTriple=query.selectSingle(pageid,"service",null);
      if (serviceTriple==null)
        serviceTriple=query.selectSingle(pageid,"Property:Action_service",null);
      if (serviceTriple!=null) 
        service=serviceTriple.getObject().toString();
      Triple inputtypeTriple=query.selectSingle(pageid,"inputtype",null);
      if (inputtypeTriple==null)
        inputtypeTriple=query.selectSingle(pageid,"Property:Action_inputtype",null);
      if (inputtypeTriple!=null) 
        inputtype=inputtypeTriple.getObject().toString();
      Triple inputTriple=query.selectSingle(pageid,"input",null);
      if (inputTriple==null)
        inputTriple=query.selectSingle(pageid,"Property:Action_input",null);
      if (inputTriple!=null) 
        input=inputTriple.getObject().toString();
      Triple actionpageTriple=query.selectSingle(pageid,"actionpage",null);
      if (actionpageTriple==null)
        actionpageTriple=query.selectSingle(pageid,"Property:Action_actionpage",null);
      if (actionpageTriple!=null) 
        actionpage=actionpageTriple.getObject().toString();
      Triple outputTriple=query.selectSingle(pageid,"output",null);
      if (outputTriple==null)
        outputTriple=query.selectSingle(pageid,"Property:Action_output",null);
      if (outputTriple!=null) 
        output=outputTriple.getObject().toString();
      Triple engineTriple=query.selectSingle(pageid,"engine",null);
      if (engineTriple==null)
        engineTriple=query.selectSingle(pageid,"Property:Action_engine",null);
      if (engineTriple!=null) 
        engine=engineTriple.getObject().toString();
      Triple authorTriple=query.selectSingle(pageid,"author",null);
      if (authorTriple==null)
        authorTriple=query.selectSingle(pageid,"Property:Action_author",null);
      if (authorTriple!=null) 
        author=authorTriple.getObject().toString();
      Triple sinceTriple=query.selectSingle(pageid,"since",null);
      if (sinceTriple==null)
        sinceTriple=query.selectSingle(pageid,"Property:Action_since",null);
      if (sinceTriple!=null) 
        since=sinceTriple.getObject().toString();
      Triple commentTriple=query.selectSingle(pageid,"comment",null);
      if (commentTriple==null)
        commentTriple=query.selectSingle(pageid,"Property:Action_comment",null);
      if (commentTriple!=null) 
        comment=commentTriple.getObject().toString();
      init(query);
    } // constructor for Action
    
    // >>>{user defined topic code}{Action}{Action}
    // <<<{user defined topic code}{Action}{Action}
  } // class Action
  /**
   * Manager for Action
   */
  public static class ActionManager extends TopicBase {
 
    public String topicName="Action";
    public transient List<Action> mActions=new ArrayList<Action>();
    public transient Map<String,Action> mActionMap=new LinkedHashMap<String,Action>();

    /**
     * get my Actions
     */
    public List<Action> getActions() {
      List<Action> result=this.mActions;
      return result;
    }

    /**
     *  add a new Action 
     */
    public Action add(Action pAction) {
      mActions.add(pAction);
      mActionMap.put(pAction.getPageid(),pAction);
      return pAction;
    }

    /**
     *  add a new Action from the given triple
     */
    public Action add(TripleQuery query,Triple pActionTriple) {
      Action lAction=new Action(query,pActionTriple);
      add(lAction);
      return lAction;
    }

    // reinitialize my mAction map
    public void reinit() {
      mActionMap.clear();
      for (Action lAction:mActions) {
        mActionMap.put(lAction.getPageid(),lAction);
      }
    }

    // convert this manager to json format 
    public String toJson() { return JSON.toJSONString(this); }
    
    // get a new manager from the given json string
    public static ActionManager fromJson(String json) {
      ActionManager result=JSON.parseObject(json, ActionManager.class);
      result.reinit();
      return result;
    }

    // default constructor for Action Manager
    public ActionManager() {}

    // add Actions from the given query
    public void addActions(TripleQuery pActionQuery,TripleQuery query) {
      if (pActionQuery!=null) {
        for (Triple lActionTriple:pActionQuery.getTriples()) {
          add(query,lActionTriple);
        }
      }
    }

    // construct me from the given triple Query query
    public ActionManager(TripleQuery query) {
      // first query the SiDIF bases triplestore
      TripleQuery lActionQuery=query.query(null,"isA","Action");
      addActions(lActionQuery,query);
      // then the SMW triplestore
      lActionQuery=query.query(null,"Property:IsA","Action");
      addActions(lActionQuery,query);
      init(query);
    } // constructor for Action Manager
    
    // >>>{user defined topicmanager code}{Action}{Action}
    // <<<{user defined topicmanager code}{Action}{Action}
  } // class Action Manager
 /**
  * TopicLink
  * A TopicLink links two Concepts
  */
  public static class TopicLink extends TopicBase {
  
    public String masterDetail;
    public String name;
    public String source;
    public String sourceRole;
    public String sourceMultiple;
    public String sourceDocumentation;
    public String target;
    public String targetRole;
    public String targetMultiple;
    public String targetDocumentation;

    public String getMasterDetail() { return masterDetail; }
    public void setMasterDetail(String pMasterDetail) { masterDetail=pMasterDetail; }
    public String getName() { return name; }
    public void setName(String pName) { name=pName; }
    public String getSource() { return source; }
    public void setSource(String pSource) { source=pSource; }
    public String getSourceRole() { return sourceRole; }
    public void setSourceRole(String pSourceRole) { sourceRole=pSourceRole; }
    public String getSourceMultiple() { return sourceMultiple; }
    public void setSourceMultiple(String pSourceMultiple) { sourceMultiple=pSourceMultiple; }
    public String getSourceDocumentation() { return sourceDocumentation; }
    public void setSourceDocumentation(String pSourceDocumentation) { sourceDocumentation=pSourceDocumentation; }
    public String getTarget() { return target; }
    public void setTarget(String pTarget) { target=pTarget; }
    public String getTargetRole() { return targetRole; }
    public void setTargetRole(String pTargetRole) { targetRole=pTargetRole; }
    public String getTargetMultiple() { return targetMultiple; }
    public void setTargetMultiple(String pTargetMultiple) { targetMultiple=pTargetMultiple; }
    public String getTargetDocumentation() { return targetDocumentation; }
    public void setTargetDocumentation(String pTargetDocumentation) { targetDocumentation=pTargetDocumentation; }
    /**
     * convert this TopicLink to a JSON string
     */
    public String toJson() { return JSON.toJSONString(this); }

    /**
     * convert this TopicLink to a WikiSon string
     * @return the WikiSon representation of this TopicLink
     */
    public String toWikiSon() {
      String wikison= "{{TopicLink\n";
      wikison+=toWikiSon("masterDetail",masterDetail);
      wikison+=toWikiSon("name",name);
      wikison+=toWikiSon("source",source);
      wikison+=toWikiSon("sourceRole",sourceRole);
      wikison+=toWikiSon("sourceMultiple",sourceMultiple);
      wikison+=toWikiSon("sourceDocumentation",sourceDocumentation);
      wikison+=toWikiSon("target",target);
      wikison+=toWikiSon("targetRole",targetRole);
      wikison+=toWikiSon("targetMultiple",targetMultiple);
      wikison+=toWikiSon("targetDocumentation",targetDocumentation);
      wikison+="}}\n";
      return wikison;
    }

    /**
     * convert this TopicLink to a SiDIF string
     * @return the SiDIF representation of this TopicLink
     */
    public String toSiDIF() {
      String siDIF = String.format("%s isA TopicLink\n",this.pageid);
      siDIF+=propertySiDIF("masterDetail",masterDetail,"Boolean");
      siDIF+=propertySiDIF("name",name,"Text");
      siDIF+=propertySiDIF("source",source,"Page");
      siDIF+=propertySiDIF("sourceRole",sourceRole,"Text");
      siDIF+=propertySiDIF("sourceMultiple",sourceMultiple,"Boolean");
      siDIF+=propertySiDIF("sourceDocumentation",sourceDocumentation,"Text");
      siDIF+=propertySiDIF("target",target,"Page");
      siDIF+=propertySiDIF("targetRole",targetRole,"Text");
      siDIF+=propertySiDIF("targetMultiple",targetMultiple,"Boolean");
      siDIF+=propertySiDIF("targetDocumentation",targetDocumentation,"Text");
      return siDIF;
    }
 
    /**  
     * get the pageid for this topic
     */
    public String getPageid() { return pageid; };

    /**
     * default constructor for TopicLink
     */
    public TopicLink() {}

    /**
     * construct a TopicLink from the given Triple
     * @param query - the TripleQuery to get the triples from
     * @param pTopicLinkTriple - the triple to construct me from
     */
    public TopicLink(TripleQuery query,Triple pTopicLinkTriple) {
      this(query,pTopicLinkTriple.getSubject().toString());
    } // constructor

    /**
     * construct a TopicLink from the given pageId
     * @param query - the TripleQuery to get the triples from
     * @param pageid - pageid
     */
    public TopicLink(TripleQuery query,String pageid) {
      this.pageid=pageid;
      Triple masterDetailTriple=query.selectSingle(pageid,"masterDetail",null);
      if (masterDetailTriple==null)
        masterDetailTriple=query.selectSingle(pageid,"Property:TopicLink_masterDetail",null);
      if (masterDetailTriple!=null) 
        masterDetail=masterDetailTriple.getObject().toString();
      Triple nameTriple=query.selectSingle(pageid,"name",null);
      if (nameTriple==null)
        nameTriple=query.selectSingle(pageid,"Property:TopicLink_name",null);
      if (nameTriple!=null) 
        name=nameTriple.getObject().toString();
      Triple sourceTriple=query.selectSingle(pageid,"source",null);
      if (sourceTriple==null)
        sourceTriple=query.selectSingle(pageid,"Property:TopicLink_source",null);
      if (sourceTriple!=null) 
        source=sourceTriple.getObject().toString();
      Triple sourceRoleTriple=query.selectSingle(pageid,"sourceRole",null);
      if (sourceRoleTriple==null)
        sourceRoleTriple=query.selectSingle(pageid,"Property:TopicLink_sourceRole",null);
      if (sourceRoleTriple!=null) 
        sourceRole=sourceRoleTriple.getObject().toString();
      Triple sourceMultipleTriple=query.selectSingle(pageid,"sourceMultiple",null);
      if (sourceMultipleTriple==null)
        sourceMultipleTriple=query.selectSingle(pageid,"Property:TopicLink_sourceMultiple",null);
      if (sourceMultipleTriple!=null) 
        sourceMultiple=sourceMultipleTriple.getObject().toString();
      Triple sourceDocumentationTriple=query.selectSingle(pageid,"sourceDocumentation",null);
      if (sourceDocumentationTriple==null)
        sourceDocumentationTriple=query.selectSingle(pageid,"Property:TopicLink_sourceDocumentation",null);
      if (sourceDocumentationTriple!=null) 
        sourceDocumentation=sourceDocumentationTriple.getObject().toString();
      Triple targetTriple=query.selectSingle(pageid,"target",null);
      if (targetTriple==null)
        targetTriple=query.selectSingle(pageid,"Property:TopicLink_target",null);
      if (targetTriple!=null) 
        target=targetTriple.getObject().toString();
      Triple targetRoleTriple=query.selectSingle(pageid,"targetRole",null);
      if (targetRoleTriple==null)
        targetRoleTriple=query.selectSingle(pageid,"Property:TopicLink_targetRole",null);
      if (targetRoleTriple!=null) 
        targetRole=targetRoleTriple.getObject().toString();
      Triple targetMultipleTriple=query.selectSingle(pageid,"targetMultiple",null);
      if (targetMultipleTriple==null)
        targetMultipleTriple=query.selectSingle(pageid,"Property:TopicLink_targetMultiple",null);
      if (targetMultipleTriple!=null) 
        targetMultiple=targetMultipleTriple.getObject().toString();
      Triple targetDocumentationTriple=query.selectSingle(pageid,"targetDocumentation",null);
      if (targetDocumentationTriple==null)
        targetDocumentationTriple=query.selectSingle(pageid,"Property:TopicLink_targetDocumentation",null);
      if (targetDocumentationTriple!=null) 
        targetDocumentation=targetDocumentationTriple.getObject().toString();
      init(query);
    } // constructor for TopicLink
    
    // >>>{user defined topic code}{TopicLink}{TopicLink}
    // <<<{user defined topic code}{TopicLink}{TopicLink}
  } // class TopicLink
  /**
   * Manager for TopicLink
   */
  public static class TopicLinkManager extends TopicBase {
 
    public String topicName="TopicLink";
    public transient List<TopicLink> mTopicLinks=new ArrayList<TopicLink>();
    public transient Map<String,TopicLink> mTopicLinkMap=new LinkedHashMap<String,TopicLink>();

    /**
     * get my TopicLinks
     */
    public List<TopicLink> getTopicLinks() {
      List<TopicLink> result=this.mTopicLinks;
      return result;
    }

    /**
     *  add a new TopicLink 
     */
    public TopicLink add(TopicLink pTopicLink) {
      mTopicLinks.add(pTopicLink);
      mTopicLinkMap.put(pTopicLink.getPageid(),pTopicLink);
      return pTopicLink;
    }

    /**
     *  add a new TopicLink from the given triple
     */
    public TopicLink add(TripleQuery query,Triple pTopicLinkTriple) {
      TopicLink lTopicLink=new TopicLink(query,pTopicLinkTriple);
      add(lTopicLink);
      return lTopicLink;
    }

    // reinitialize my mTopicLink map
    public void reinit() {
      mTopicLinkMap.clear();
      for (TopicLink lTopicLink:mTopicLinks) {
        mTopicLinkMap.put(lTopicLink.getPageid(),lTopicLink);
      }
    }

    // convert this manager to json format 
    public String toJson() { return JSON.toJSONString(this); }
    
    // get a new manager from the given json string
    public static TopicLinkManager fromJson(String json) {
      TopicLinkManager result=JSON.parseObject(json, TopicLinkManager.class);
      result.reinit();
      return result;
    }

    // default constructor for TopicLink Manager
    public TopicLinkManager() {}

    // add TopicLinks from the given query
    public void addTopicLinks(TripleQuery pTopicLinkQuery,TripleQuery query) {
      if (pTopicLinkQuery!=null) {
        for (Triple lTopicLinkTriple:pTopicLinkQuery.getTriples()) {
          add(query,lTopicLinkTriple);
        }
      }
    }

    // construct me from the given triple Query query
    public TopicLinkManager(TripleQuery query) {
      // first query the SiDIF bases triplestore
      TripleQuery lTopicLinkQuery=query.query(null,"isA","TopicLink");
      addTopicLinks(lTopicLinkQuery,query);
      // then the SMW triplestore
      lTopicLinkQuery=query.query(null,"Property:IsA","TopicLink");
      addTopicLinks(lTopicLinkQuery,query);
      init(query);
    } // constructor for TopicLink Manager
    
    // >>>{user defined topicmanager code}{TopicLink}{TopicLink}
    // <<<{user defined topicmanager code}{TopicLink}{TopicLink}
  } // class TopicLink Manager

}
Showing below 0 pages.

Retrieved from "http://royal-family.bitplan.com/index.php?title=Concept:Action/Java&oldid=1387#smw-result"