Topic/Java


Wolfgang Fahl

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
 /**
  * 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
 /**
  * Property
  * a Property is a Feature/Attribute of a Topic
  */
  public static class Property extends TopicBase {
  
    public String name;
    public String label;
    public String type;
    public String index;
    public String sortPos;
    public String primaryKey;
    public String mandatory;
    public String namespace;
    public String size;
    public String uploadable;
    public String defaultValue;
    public String inputType;
    public String allowedValues;
    public String documentation;
    public String values_from;
    public String showInGrid;
    public String isLink;
    public String nullable;
    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 void setIndex(String pIndex) { index=pIndex; }
    public String getSortPos() { return sortPos; }
    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 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 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 getDocumentation() { return documentation; }
    public void setDocumentation(String pDocumentation) { documentation=pDocumentation; }
    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 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("name",name);
      wikison+=toWikiSon("label",label);
      wikison+=toWikiSon("type",type);
      wikison+=toWikiSon("index",index);
      wikison+=toWikiSon("sortPos",sortPos);
      wikison+=toWikiSon("primaryKey",primaryKey);
      wikison+=toWikiSon("mandatory",mandatory);
      wikison+=toWikiSon("namespace",namespace);
      wikison+=toWikiSon("size",size);
      wikison+=toWikiSon("uploadable",uploadable);
      wikison+=toWikiSon("defaultValue",defaultValue);
      wikison+=toWikiSon("inputType",inputType);
      wikison+=toWikiSon("allowedValues",allowedValues);
      wikison+=toWikiSon("documentation",documentation);
      wikison+=toWikiSon("values_from",values_from);
      wikison+=toWikiSon("showInGrid",showInGrid);
      wikison+=toWikiSon("isLink",isLink);
      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("name",name,"Text");
      siDIF+=propertySiDIF("label",label,"Text");
      siDIF+=propertySiDIF("type",type,"Page");
      siDIF+=propertySiDIF("index",index,"Number");
      siDIF+=propertySiDIF("sortPos",sortPos,"Number");
      siDIF+=propertySiDIF("primaryKey",primaryKey,"Boolean");
      siDIF+=propertySiDIF("mandatory",mandatory,"Boolean");
      siDIF+=propertySiDIF("namespace",namespace,"Text");
      siDIF+=propertySiDIF("size",size,"Number");
      siDIF+=propertySiDIF("uploadable",uploadable,"Boolean");
      siDIF+=propertySiDIF("defaultValue",defaultValue,"Code");
      siDIF+=propertySiDIF("inputType",inputType,"Text");
      siDIF+=propertySiDIF("allowedValues",allowedValues,"Text");
      siDIF+=propertySiDIF("documentation",documentation,"Text");
      siDIF+=propertySiDIF("values_from",values_from,"Code");
      siDIF+=propertySiDIF("showInGrid",showInGrid,"Boolean");
      siDIF+=propertySiDIF("isLink",isLink,"Boolean");
      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 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);
      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 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);
      if (mandatoryTriple==null)
        mandatoryTriple=query.selectSingle(pageid,"Property:Property_mandatory",null);
      if (mandatoryTriple!=null) 
        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);
      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 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);
      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 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
 /**
  * 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 documentation;
    public String helppage;
    public String typepage;
    public String javaType;
    public String id;
    public String usedByProperties;

    public String getType() { return type; }
    public void setType(String pType) { type=pType; }
    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 getTypepage() { return typepage; }
    public void setTypepage(String pTypepage) { typepage=pTypepage; }
    public String getJavaType() { return javaType; }
    public void setJavaType(String pJavaType) { javaType=pJavaType; }
    public String getId() { return id; }
    public void setId(String pId) { id=pId; }
    public String getUsedByProperties() { return usedByProperties; }
    public void setUsedByProperties(String pUsedByProperties) { usedByProperties=pUsedByProperties; }
    /**
     * 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("documentation",documentation);
      wikison+=toWikiSon("helppage",helppage);
      wikison+=toWikiSon("typepage",typepage);
      wikison+=toWikiSon("javaType",javaType);
      wikison+=toWikiSon("id",id);
      wikison+=toWikiSon("usedByProperties",usedByProperties);
      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("documentation",documentation,"Text");
      siDIF+=propertySiDIF("helppage",helppage,"URL");
      siDIF+=propertySiDIF("typepage",typepage,"Page");
      siDIF+=propertySiDIF("javaType",javaType,"Text");
      siDIF+=propertySiDIF("id",id,"Text");
      siDIF+=propertySiDIF("usedByProperties",usedByProperties,"Page");
      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 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 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 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();
      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);
    } // 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
 /**
  * Topic
  * A Topic is a Concept/Class/Thing/Entity
  */
  public static class Topic extends TopicBase {
  
    public String name;
    public String pluralName;
    public String icon;
    public String iconUrl;
    public String documentation;
    public String wikiDocumentation;
    public String defaultstoremode;
    public String listLimit;
    public String cargo;
    public String headerTabs;
    public String context;

    public String getName() { return name; }
    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 void setIcon(String pIcon) { icon=pIcon; }
    public String getIconUrl() { return iconUrl; }
    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 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 getCargo() { return cargo; }
    public void setCargo(String pCargo) { cargo=pCargo; }
    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("name",name);
      wikison+=toWikiSon("pluralName",pluralName);
      wikison+=toWikiSon("icon",icon);
      wikison+=toWikiSon("iconUrl",iconUrl);
      wikison+=toWikiSon("documentation",documentation);
      wikison+=toWikiSon("wikiDocumentation",wikiDocumentation);
      wikison+=toWikiSon("defaultstoremode",defaultstoremode);
      wikison+=toWikiSon("listLimit",listLimit);
      wikison+=toWikiSon("cargo",cargo);
      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("name",name,"Text");
      siDIF+=propertySiDIF("pluralName",pluralName,"Text");
      siDIF+=propertySiDIF("icon",icon,"Page");
      siDIF+=propertySiDIF("iconUrl",iconUrl,"Code");
      siDIF+=propertySiDIF("documentation",documentation,"Text");
      siDIF+=propertySiDIF("wikiDocumentation",wikiDocumentation,"Text");
      siDIF+=propertySiDIF("defaultstoremode",defaultstoremode,"Text");
      siDIF+=propertySiDIF("listLimit",listLimit,"Number");
      siDIF+=propertySiDIF("cargo",cargo,"Boolean");
      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 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 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);
      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 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);
      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 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);
      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 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 masterDetail;

    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; }
    public String getMasterDetail() { return masterDetail; }
    public void setMasterDetail(String pMasterDetail) { masterDetail=pMasterDetail; }
    /**
     * 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("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+=toWikiSon("masterDetail",masterDetail);
      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("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");
      siDIF+=propertySiDIF("masterDetail",masterDetail,"Boolean");
      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 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();
      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);
    } // 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.

java code[edit]

@// 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
 /**
  * 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
 /**
  * Property
  * a Property is a Feature/Attribute of a Topic
  */
  public static class Property extends TopicBase {
  
    public String name;
    public String label;
    public String type;
    public String index;
    public String sortPos;
    public String primaryKey;
    public String mandatory;
    public String namespace;
    public String size;
    public String uploadable;
    public String defaultValue;
    public String inputType;
    public String allowedValues;
    public String documentation;
    public String values_from;
    public String showInGrid;
    public String isLink;
    public String nullable;
    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 void setIndex(String pIndex) { index=pIndex; }
    public String getSortPos() { return sortPos; }
    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 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 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 getDocumentation() { return documentation; }
    public void setDocumentation(String pDocumentation) { documentation=pDocumentation; }
    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 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("name",name);
      wikison+=toWikiSon("label",label);
      wikison+=toWikiSon("type",type);
      wikison+=toWikiSon("index",index);
      wikison+=toWikiSon("sortPos",sortPos);
      wikison+=toWikiSon("primaryKey",primaryKey);
      wikison+=toWikiSon("mandatory",mandatory);
      wikison+=toWikiSon("namespace",namespace);
      wikison+=toWikiSon("size",size);
      wikison+=toWikiSon("uploadable",uploadable);
      wikison+=toWikiSon("defaultValue",defaultValue);
      wikison+=toWikiSon("inputType",inputType);
      wikison+=toWikiSon("allowedValues",allowedValues);
      wikison+=toWikiSon("documentation",documentation);
      wikison+=toWikiSon("values_from",values_from);
      wikison+=toWikiSon("showInGrid",showInGrid);
      wikison+=toWikiSon("isLink",isLink);
      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("name",name,"Text");
      siDIF+=propertySiDIF("label",label,"Text");
      siDIF+=propertySiDIF("type",type,"Page");
      siDIF+=propertySiDIF("index",index,"Number");
      siDIF+=propertySiDIF("sortPos",sortPos,"Number");
      siDIF+=propertySiDIF("primaryKey",primaryKey,"Boolean");
      siDIF+=propertySiDIF("mandatory",mandatory,"Boolean");
      siDIF+=propertySiDIF("namespace",namespace,"Text");
      siDIF+=propertySiDIF("size",size,"Number");
      siDIF+=propertySiDIF("uploadable",uploadable,"Boolean");
      siDIF+=propertySiDIF("defaultValue",defaultValue,"Code");
      siDIF+=propertySiDIF("inputType",inputType,"Text");
      siDIF+=propertySiDIF("allowedValues",allowedValues,"Text");
      siDIF+=propertySiDIF("documentation",documentation,"Text");
      siDIF+=propertySiDIF("values_from",values_from,"Code");
      siDIF+=propertySiDIF("showInGrid",showInGrid,"Boolean");
      siDIF+=propertySiDIF("isLink",isLink,"Boolean");
      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 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);
      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 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);
      if (mandatoryTriple==null)
        mandatoryTriple=query.selectSingle(pageid,"Property:Property_mandatory",null);
      if (mandatoryTriple!=null) 
        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);
      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 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);
      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 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
 /**
  * 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 documentation;
    public String helppage;
    public String typepage;
    public String javaType;
    public String id;
    public String usedByProperties;

    public String getType() { return type; }
    public void setType(String pType) { type=pType; }
    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 getTypepage() { return typepage; }
    public void setTypepage(String pTypepage) { typepage=pTypepage; }
    public String getJavaType() { return javaType; }
    public void setJavaType(String pJavaType) { javaType=pJavaType; }
    public String getId() { return id; }
    public void setId(String pId) { id=pId; }
    public String getUsedByProperties() { return usedByProperties; }
    public void setUsedByProperties(String pUsedByProperties) { usedByProperties=pUsedByProperties; }
    /**
     * 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("documentation",documentation);
      wikison+=toWikiSon("helppage",helppage);
      wikison+=toWikiSon("typepage",typepage);
      wikison+=toWikiSon("javaType",javaType);
      wikison+=toWikiSon("id",id);
      wikison+=toWikiSon("usedByProperties",usedByProperties);
      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("documentation",documentation,"Text");
      siDIF+=propertySiDIF("helppage",helppage,"URL");
      siDIF+=propertySiDIF("typepage",typepage,"Page");
      siDIF+=propertySiDIF("javaType",javaType,"Text");
      siDIF+=propertySiDIF("id",id,"Text");
      siDIF+=propertySiDIF("usedByProperties",usedByProperties,"Page");
      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 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 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 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();
      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);
    } // 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
 /**
  * Topic
  * A Topic is a Concept/Class/Thing/Entity
  */
  public static class Topic extends TopicBase {
  
    public String name;
    public String pluralName;
    public String icon;
    public String iconUrl;
    public String documentation;
    public String wikiDocumentation;
    public String defaultstoremode;
    public String listLimit;
    public String cargo;
    public String headerTabs;
    public String context;

    public String getName() { return name; }
    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 void setIcon(String pIcon) { icon=pIcon; }
    public String getIconUrl() { return iconUrl; }
    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 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 getCargo() { return cargo; }
    public void setCargo(String pCargo) { cargo=pCargo; }
    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("name",name);
      wikison+=toWikiSon("pluralName",pluralName);
      wikison+=toWikiSon("icon",icon);
      wikison+=toWikiSon("iconUrl",iconUrl);
      wikison+=toWikiSon("documentation",documentation);
      wikison+=toWikiSon("wikiDocumentation",wikiDocumentation);
      wikison+=toWikiSon("defaultstoremode",defaultstoremode);
      wikison+=toWikiSon("listLimit",listLimit);
      wikison+=toWikiSon("cargo",cargo);
      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("name",name,"Text");
      siDIF+=propertySiDIF("pluralName",pluralName,"Text");
      siDIF+=propertySiDIF("icon",icon,"Page");
      siDIF+=propertySiDIF("iconUrl",iconUrl,"Code");
      siDIF+=propertySiDIF("documentation",documentation,"Text");
      siDIF+=propertySiDIF("wikiDocumentation",wikiDocumentation,"Text");
      siDIF+=propertySiDIF("defaultstoremode",defaultstoremode,"Text");
      siDIF+=propertySiDIF("listLimit",listLimit,"Number");
      siDIF+=propertySiDIF("cargo",cargo,"Boolean");
      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 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 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);
      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 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);
      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 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);
      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 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 masterDetail;

    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; }
    public String getMasterDetail() { return masterDetail; }
    public void setMasterDetail(String pMasterDetail) { masterDetail=pMasterDetail; }
    /**
     * 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("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+=toWikiSon("masterDetail",masterDetail);
      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("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");
      siDIF+=propertySiDIF("masterDetail",masterDetail,"Boolean");
      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 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();
      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);
    } // 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

}
🖨 🚪