Concept:Platform/Java

From BITPlan ceur-ws Wiki
Jump to navigation Jump to search

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 my SiDIF representation
     */
    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
 /**
  * CiteSchema
  * A CiteSchema is a schema of references Schemas
  */
  public static class CiteSchema extends TopicBase {
  
    public String name;
    public String type;
    public String iri;

    public String getName() { return name; }
    public void setName(String pName) { name=pName; }
    public String getType() { return type; }
    public void setType(String pType) { type=pType; }
    public String getIri() { return iri; }
    public void setIri(String pIri) { iri=pIri; }
    /**
     * convert this CiteSchema to a JSON string
     * @return the JSON representation
     */
    public String toJson() { return JSON.toJSONString(this); }

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

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

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

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

    /**
     * construct a CiteSchema from the given pageId
     * @param query - the TripleQuery to get the triples from
     * @param pageid - pageid
     */
    public CiteSchema(TripleQuery query,String pageid) {
      this.pageid=pageid;
      Triple nameTriple=query.selectSingle(pageid,"name",null);
      if (nameTriple==null)
        nameTriple=query.selectSingle(pageid,"Property:CiteSchema_name",null);
      if (nameTriple!=null) 
        name=nameTriple.getObject().toString();
      Triple typeTriple=query.selectSingle(pageid,"type",null);
      if (typeTriple==null)
        typeTriple=query.selectSingle(pageid,"Property:CiteSchema_type",null);
      if (typeTriple!=null) 
        type=typeTriple.getObject().toString();
      Triple iriTriple=query.selectSingle(pageid,"iri",null);
      if (iriTriple==null)
        iriTriple=query.selectSingle(pageid,"Property:CiteSchema_iri",null);
      if (iriTriple!=null) 
        iri=iriTriple.getObject().toString();
      init(query);
    } // constructor for CiteSchema
    
    // >>>{user defined topic code}{CiteSchema}{CiteSchema}
    // <<<{user defined topic code}{CiteSchema}{CiteSchema}
  } // class CiteSchema
  /**
   * Manager for CiteSchema
   */
  public static class CiteSchemaManager extends TopicBase {
 
    public String topicName="CiteSchema";
    public transient List<CiteSchema> mCiteSchemas=new ArrayList<CiteSchema>();
    public transient Map<String,CiteSchema> mCiteSchemaMap=new LinkedHashMap<String,CiteSchema>();

    /**
     * get my CiteSchemas
     */
    public List<CiteSchema> getCiteSchemas() {
      List<CiteSchema> result=this.mCiteSchemas;
      return result;
    }

    /**
     *  add a new CiteSchema 
     */
    public CiteSchema add(CiteSchema pCiteSchema) {
      mCiteSchemas.add(pCiteSchema);
      mCiteSchemaMap.put(pCiteSchema.getPageid(),pCiteSchema);
      return pCiteSchema;
    }

    /**
     *  add a new CiteSchema from the given triple
     */
    public CiteSchema add(TripleQuery query,Triple pCiteSchemaTriple) {
      CiteSchema lCiteSchema=new CiteSchema(query,pCiteSchemaTriple);
      add(lCiteSchema);
      return lCiteSchema;
    }

    // reinitialize my mCiteSchema map
    public void reinit() {
      mCiteSchemaMap.clear();
      for (CiteSchema lCiteSchema:mCiteSchemas) {
        mCiteSchemaMap.put(lCiteSchema.getPageid(),lCiteSchema);
      }
    }

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

    // default constructor for CiteSchema Manager
    public CiteSchemaManager() {}

    // add CiteSchemas from the given query
    public void addCiteSchemas(TripleQuery pCiteSchemaQuery,TripleQuery query) {
      if (pCiteSchemaQuery!=null) {
        for (Triple lCiteSchemaTriple:pCiteSchemaQuery.getTriples()) {
          add(query,lCiteSchemaTriple);
        }
      }
    }

    // construct me from the given triple Query query
    public CiteSchemaManager(TripleQuery query) {
      // first query the SiDIF bases triplestore
      TripleQuery lCiteSchemaQuery=query.query(null,"isA","CiteSchema");
      addCiteSchemas(lCiteSchemaQuery,query);
      // then the SMW triplestore
      lCiteSchemaQuery=query.query(null,"Property:IsA","CiteSchema");
      addCiteSchemas(lCiteSchemaQuery,query);
      init(query);
    } // constructor for CiteSchema Manager
    
    // >>>{user defined topicmanager code}{CiteSchema}{CiteSchema}
    // <<<{user defined topicmanager code}{CiteSchema}{CiteSchema}
  } // class CiteSchema Manager
 /**
  * SchemaProperty
  * A SchemaProperty is a property of a CiteSchema
  */
  public static class SchemaProperty extends TopicBase {
  
    public String id;
    public String name;
    public String type;
    public String kind;
    public String iri;
    public String cardinality;
    public String definition;
    public String allowedValue;
    public String examples;
    public String parent;
    public String mapsTo;
    public String comment;
    public String schema;

    public String getId() { return id; }
    public void setId(String pId) { id=pId; }
    public String getName() { return name; }
    public void setName(String pName) { name=pName; }
    public String getType() { return type; }
    public void setType(String pType) { type=pType; }
    public String getKind() { return kind; }
    public void setKind(String pKind) { kind=pKind; }
    public String getIri() { return iri; }
    public void setIri(String pIri) { iri=pIri; }
    public String getCardinality() { return cardinality; }
    public void setCardinality(String pCardinality) { cardinality=pCardinality; }
    public String getDefinition() { return definition; }
    public void setDefinition(String pDefinition) { definition=pDefinition; }
    public String getAllowedValue() { return allowedValue; }
    public void setAllowedValue(String pAllowedValue) { allowedValue=pAllowedValue; }
    public String getExamples() { return examples; }
    public void setExamples(String pExamples) { examples=pExamples; }
    public String getParent() { return parent; }
    public void setParent(String pParent) { parent=pParent; }
    public String getMapsTo() { return mapsTo; }
    public void setMapsTo(String pMapsTo) { mapsTo=pMapsTo; }
    public String getComment() { return comment; }
    public void setComment(String pComment) { comment=pComment; }
    public String getSchema() { return schema; }
    public void setSchema(String pSchema) { schema=pSchema; }
    /**
     * convert this SchemaProperty to a JSON string
     * @return the JSON representation
     */
    public String toJson() { return JSON.toJSONString(this); }

    /**
     * convert this SchemaProperty to a WikiSon string
     * @return the WikiSon representation of this SchemaProperty
     */
    public String toWikiSon() {
      String wikison= "{{SchemaProperty\n";
      wikison+=toWikiSon("id",id);
      wikison+=toWikiSon("name",name);
      wikison+=toWikiSon("type",type);
      wikison+=toWikiSon("kind",kind);
      wikison+=toWikiSon("iri",iri);
      wikison+=toWikiSon("cardinality",cardinality);
      wikison+=toWikiSon("definition",definition);
      wikison+=toWikiSon("allowedValue",allowedValue);
      wikison+=toWikiSon("examples",examples);
      wikison+=toWikiSon("parent",parent);
      wikison+=toWikiSon("mapsTo",mapsTo);
      wikison+=toWikiSon("comment",comment);
      wikison+=toWikiSon("schema",schema);
      wikison+="}}\n";
      return wikison;
    }

    /**
     * convert this SchemaProperty to a SiDIF string
     * @return the SiDIF representation of this SchemaProperty
     */
    public String toSiDIF() {
      String siDIF = String.format("%s isA SchemaProperty\n",this.pageid);
      siDIF+=propertySiDIF("id",id,"Text");
      siDIF+=propertySiDIF("name",name,"Text");
      siDIF+=propertySiDIF("type",type,"Page");
      siDIF+=propertySiDIF("kind",kind,"Text");
      siDIF+=propertySiDIF("iri",iri,"URL");
      siDIF+=propertySiDIF("cardinality",cardinality,"Text");
      siDIF+=propertySiDIF("definition",definition,"Text");
      siDIF+=propertySiDIF("allowedValue",allowedValue,"Text");
      siDIF+=propertySiDIF("examples",examples,"Text");
      siDIF+=propertySiDIF("parent",parent,"Page");
      siDIF+=propertySiDIF("mapsTo",mapsTo,"Page");
      siDIF+=propertySiDIF("comment",comment,"Text");
      siDIF+=propertySiDIF("schema",schema,"Page");
      return siDIF;
    }
 
    /**  
     * get the pageid for this topic
     */
    public String getPageid() { return pageid; };

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

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

    /**
     * construct a SchemaProperty from the given pageId
     * @param query - the TripleQuery to get the triples from
     * @param pageid - pageid
     */
    public SchemaProperty(TripleQuery query,String pageid) {
      this.pageid=pageid;
      Triple idTriple=query.selectSingle(pageid,"id",null);
      if (idTriple==null)
        idTriple=query.selectSingle(pageid,"Property:SchemaProperty_id",null);
      if (idTriple!=null) 
        id=idTriple.getObject().toString();
      Triple nameTriple=query.selectSingle(pageid,"name",null);
      if (nameTriple==null)
        nameTriple=query.selectSingle(pageid,"Property:SchemaProperty_name",null);
      if (nameTriple!=null) 
        name=nameTriple.getObject().toString();
      Triple typeTriple=query.selectSingle(pageid,"type",null);
      if (typeTriple==null)
        typeTriple=query.selectSingle(pageid,"Property:SchemaProperty_type",null);
      if (typeTriple!=null) 
        type=typeTriple.getObject().toString();
      Triple kindTriple=query.selectSingle(pageid,"kind",null);
      if (kindTriple==null)
        kindTriple=query.selectSingle(pageid,"Property:SchemaProperty_kind",null);
      if (kindTriple!=null) 
        kind=kindTriple.getObject().toString();
      Triple iriTriple=query.selectSingle(pageid,"iri",null);
      if (iriTriple==null)
        iriTriple=query.selectSingle(pageid,"Property:SchemaProperty_iri",null);
      if (iriTriple!=null) 
        iri=iriTriple.getObject().toString();
      Triple cardinalityTriple=query.selectSingle(pageid,"cardinality",null);
      if (cardinalityTriple==null)
        cardinalityTriple=query.selectSingle(pageid,"Property:SchemaProperty_cardinality",null);
      if (cardinalityTriple!=null) 
        cardinality=cardinalityTriple.getObject().toString();
      Triple definitionTriple=query.selectSingle(pageid,"definition",null);
      if (definitionTriple==null)
        definitionTriple=query.selectSingle(pageid,"Property:SchemaProperty_definition",null);
      if (definitionTriple!=null) 
        definition=definitionTriple.getObject().toString();
      Triple allowedValueTriple=query.selectSingle(pageid,"allowedValue",null);
      if (allowedValueTriple==null)
        allowedValueTriple=query.selectSingle(pageid,"Property:SchemaProperty_allowedValue",null);
      if (allowedValueTriple!=null) 
        allowedValue=allowedValueTriple.getObject().toString();
      Triple examplesTriple=query.selectSingle(pageid,"examples",null);
      if (examplesTriple==null)
        examplesTriple=query.selectSingle(pageid,"Property:SchemaProperty_examples",null);
      if (examplesTriple!=null) 
        examples=examplesTriple.getObject().toString();
      Triple parentTriple=query.selectSingle(pageid,"parent",null);
      if (parentTriple==null)
        parentTriple=query.selectSingle(pageid,"Property:SchemaProperty_parent",null);
      if (parentTriple!=null) 
        parent=parentTriple.getObject().toString();
      Triple mapsToTriple=query.selectSingle(pageid,"mapsTo",null);
      if (mapsToTriple==null)
        mapsToTriple=query.selectSingle(pageid,"Property:SchemaProperty_mapsTo",null);
      if (mapsToTriple!=null) 
        mapsTo=mapsToTriple.getObject().toString();
      Triple commentTriple=query.selectSingle(pageid,"comment",null);
      if (commentTriple==null)
        commentTriple=query.selectSingle(pageid,"Property:SchemaProperty_comment",null);
      if (commentTriple!=null) 
        comment=commentTriple.getObject().toString();
      Triple schemaTriple=query.selectSingle(pageid,"schema",null);
      if (schemaTriple==null)
        schemaTriple=query.selectSingle(pageid,"Property:SchemaProperty_schema",null);
      if (schemaTriple!=null) 
        schema=schemaTriple.getObject().toString();
      init(query);
    } // constructor for SchemaProperty
    
    // >>>{user defined topic code}{SchemaProperty}{SchemaProperty}
    // <<<{user defined topic code}{SchemaProperty}{SchemaProperty}
  } // class SchemaProperty
  /**
   * Manager for SchemaProperty
   */
  public static class SchemaPropertyManager extends TopicBase {
 
    public String topicName="SchemaProperty";
    public transient List<SchemaProperty> mSchemaPropertys=new ArrayList<SchemaProperty>();
    public transient Map<String,SchemaProperty> mSchemaPropertyMap=new LinkedHashMap<String,SchemaProperty>();

    /**
     * get my SchemaProperties
     */
    public List<SchemaProperty> getSchemaProperties() {
      List<SchemaProperty> result=this.mSchemaPropertys;
      return result;
    }

    /**
     *  add a new SchemaProperty 
     */
    public SchemaProperty add(SchemaProperty pSchemaProperty) {
      mSchemaPropertys.add(pSchemaProperty);
      mSchemaPropertyMap.put(pSchemaProperty.getPageid(),pSchemaProperty);
      return pSchemaProperty;
    }

    /**
     *  add a new SchemaProperty from the given triple
     */
    public SchemaProperty add(TripleQuery query,Triple pSchemaPropertyTriple) {
      SchemaProperty lSchemaProperty=new SchemaProperty(query,pSchemaPropertyTriple);
      add(lSchemaProperty);
      return lSchemaProperty;
    }

    // reinitialize my mSchemaProperty map
    public void reinit() {
      mSchemaPropertyMap.clear();
      for (SchemaProperty lSchemaProperty:mSchemaPropertys) {
        mSchemaPropertyMap.put(lSchemaProperty.getPageid(),lSchemaProperty);
      }
    }

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

    // default constructor for SchemaProperty Manager
    public SchemaPropertyManager() {}

    // add SchemaProperties from the given query
    public void addSchemaProperties(TripleQuery pSchemaPropertyQuery,TripleQuery query) {
      if (pSchemaPropertyQuery!=null) {
        for (Triple lSchemaPropertyTriple:pSchemaPropertyQuery.getTriples()) {
          add(query,lSchemaPropertyTriple);
        }
      }
    }

    // construct me from the given triple Query query
    public SchemaPropertyManager(TripleQuery query) {
      // first query the SiDIF bases triplestore
      TripleQuery lSchemaPropertyQuery=query.query(null,"isA","SchemaProperty");
      addSchemaProperties(lSchemaPropertyQuery,query);
      // then the SMW triplestore
      lSchemaPropertyQuery=query.query(null,"Property:IsA","SchemaProperty");
      addSchemaProperties(lSchemaPropertyQuery,query);
      init(query);
    } // constructor for SchemaProperty Manager
    
    // >>>{user defined topicmanager code}{SchemaProperty}{SchemaProperty}
    // <<<{user defined topicmanager code}{SchemaProperty}{SchemaProperty}
  } // class SchemaProperty Manager
 /**
  * Platform
  * A Platform is a platform for scholarly communication which contains scholarly event metadata
  */
  public static class Platform extends TopicBase {
  
    public String name;
    public String responsible;
    public String type;
    public String iri;
    public String priority;
    public String since;
    public String wikidataid;

    public String getName() { return name; }
    public void setName(String pName) { name=pName; }
    public String getResponsible() { return responsible; }
    public void setResponsible(String pResponsible) { responsible=pResponsible; }
    public String getType() { return type; }
    public void setType(String pType) { type=pType; }
    public String getIri() { return iri; }
    public void setIri(String pIri) { iri=pIri; }
    public String getPriority() { return priority; }
    public void setPriority(String pPriority) { priority=pPriority; }
    public String getSince() { return since; }
    public void setSince(String pSince) { since=pSince; }
    public String getWikidataid() { return wikidataid; }
    public void setWikidataid(String pWikidataid) { wikidataid=pWikidataid; }
    /**
     * convert this Platform to a JSON string
     * @return the JSON representation
     */
    public String toJson() { return JSON.toJSONString(this); }

    /**
     * convert this Platform to a WikiSon string
     * @return the WikiSon representation of this Platform
     */
    public String toWikiSon() {
      String wikison= "{{Platform\n";
      wikison+=toWikiSon("name",name);
      wikison+=toWikiSon("responsible",responsible);
      wikison+=toWikiSon("type",type);
      wikison+=toWikiSon("iri",iri);
      wikison+=toWikiSon("priority",priority);
      wikison+=toWikiSon("since",since);
      wikison+=toWikiSon("wikidataid",wikidataid);
      wikison+="}}\n";
      return wikison;
    }

    /**
     * convert this Platform to a SiDIF string
     * @return the SiDIF representation of this Platform
     */
    public String toSiDIF() {
      String siDIF = String.format("%s isA Platform\n",this.pageid);
      siDIF+=propertySiDIF("name",name,"Text");
      siDIF+=propertySiDIF("responsible",responsible,"URL");
      siDIF+=propertySiDIF("type",type,"Page");
      siDIF+=propertySiDIF("iri",iri,"URL");
      siDIF+=propertySiDIF("priority",priority,"Text");
      siDIF+=propertySiDIF("since",since,"Text");
      siDIF+=propertySiDIF("wikidataid",wikidataid,"External Identifier");
      return siDIF;
    }
 
    /**  
     * get the pageid for this topic
     */
    public String getPageid() { return pageid; };

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

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

    /**
     * construct a Platform from the given pageId
     * @param query - the TripleQuery to get the triples from
     * @param pageid - pageid
     */
    public Platform(TripleQuery query,String pageid) {
      this.pageid=pageid;
      Triple nameTriple=query.selectSingle(pageid,"name",null);
      if (nameTriple==null)
        nameTriple=query.selectSingle(pageid,"Property:Platform_name",null);
      if (nameTriple!=null) 
        name=nameTriple.getObject().toString();
      Triple responsibleTriple=query.selectSingle(pageid,"responsible",null);
      if (responsibleTriple==null)
        responsibleTriple=query.selectSingle(pageid,"Property:Platform_responsible",null);
      if (responsibleTriple!=null) 
        responsible=responsibleTriple.getObject().toString();
      Triple typeTriple=query.selectSingle(pageid,"type",null);
      if (typeTriple==null)
        typeTriple=query.selectSingle(pageid,"Property:Platform_type",null);
      if (typeTriple!=null) 
        type=typeTriple.getObject().toString();
      Triple iriTriple=query.selectSingle(pageid,"iri",null);
      if (iriTriple==null)
        iriTriple=query.selectSingle(pageid,"Property:Platform_iri",null);
      if (iriTriple!=null) 
        iri=iriTriple.getObject().toString();
      Triple priorityTriple=query.selectSingle(pageid,"priority",null);
      if (priorityTriple==null)
        priorityTriple=query.selectSingle(pageid,"Property:Platform_priority",null);
      if (priorityTriple!=null) 
        priority=priorityTriple.getObject().toString();
      Triple sinceTriple=query.selectSingle(pageid,"since",null);
      if (sinceTriple==null)
        sinceTriple=query.selectSingle(pageid,"Property:Platform_since",null);
      if (sinceTriple!=null) 
        since=sinceTriple.getObject().toString();
      Triple wikidataidTriple=query.selectSingle(pageid,"wikidataid",null);
      if (wikidataidTriple==null)
        wikidataidTriple=query.selectSingle(pageid,"Property:Platform_wikidataid",null);
      if (wikidataidTriple!=null) 
        wikidataid=wikidataidTriple.getObject().toString();
      init(query);
    } // constructor for Platform
    
    // >>>{user defined topic code}{Platform}{Platform}
    // <<<{user defined topic code}{Platform}{Platform}
  } // class Platform
  /**
   * Manager for Platform
   */
  public static class PlatformManager extends TopicBase {
 
    public String topicName="Platform";
    public transient List<Platform> mPlatforms=new ArrayList<Platform>();
    public transient Map<String,Platform> mPlatformMap=new LinkedHashMap<String,Platform>();

    /**
     * get my Platforms
     */
    public List<Platform> getPlatforms() {
      List<Platform> result=this.mPlatforms;
      return result;
    }

    /**
     *  add a new Platform 
     */
    public Platform add(Platform pPlatform) {
      mPlatforms.add(pPlatform);
      mPlatformMap.put(pPlatform.getPageid(),pPlatform);
      return pPlatform;
    }

    /**
     *  add a new Platform from the given triple
     */
    public Platform add(TripleQuery query,Triple pPlatformTriple) {
      Platform lPlatform=new Platform(query,pPlatformTriple);
      add(lPlatform);
      return lPlatform;
    }

    // reinitialize my mPlatform map
    public void reinit() {
      mPlatformMap.clear();
      for (Platform lPlatform:mPlatforms) {
        mPlatformMap.put(lPlatform.getPageid(),lPlatform);
      }
    }

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

    // default constructor for Platform Manager
    public PlatformManager() {}

    // add Platforms from the given query
    public void addPlatforms(TripleQuery pPlatformQuery,TripleQuery query) {
      if (pPlatformQuery!=null) {
        for (Triple lPlatformTriple:pPlatformQuery.getTriples()) {
          add(query,lPlatformTriple);
        }
      }
    }

    // construct me from the given triple Query query
    public PlatformManager(TripleQuery query) {
      // first query the SiDIF bases triplestore
      TripleQuery lPlatformQuery=query.query(null,"isA","Platform");
      addPlatforms(lPlatformQuery,query);
      // then the SMW triplestore
      lPlatformQuery=query.query(null,"Property:IsA","Platform");
      addPlatforms(lPlatformQuery,query);
      init(query);
    } // constructor for Platform Manager
    
    // >>>{user defined topicmanager code}{Platform}{Platform}
    // <<<{user defined topicmanager code}{Platform}{Platform}
  } // class Platform Manager
 /**
  * GlossaryEntry
  * A Glossary Entry explains a term/word
  */
  public static class GlossaryEntry extends TopicBase {
  
    public String responsible;
    public String state;
    public String since;
    public String description;
    public String references;
    public String lang;
    public String master;

    public String getResponsible() { return responsible; }
    public void setResponsible(String pResponsible) { responsible=pResponsible; }
    public String getState() { return state; }
    public void setState(String pState) { state=pState; }
    public String getSince() { return since; }
    public void setSince(String pSince) { since=pSince; }
    public String getDescription() { return description; }
    public void setDescription(String pDescription) { description=pDescription; }
    public String getReferences() { return references; }
    public void setReferences(String pReferences) { references=pReferences; }
    public String getLang() { return lang; }
    public void setLang(String pLang) { lang=pLang; }
    public String getMaster() { return master; }
    public void setMaster(String pMaster) { master=pMaster; }
    /**
     * convert this GlossaryEntry to a JSON string
     * @return the JSON representation
     */
    public String toJson() { return JSON.toJSONString(this); }

    /**
     * convert this GlossaryEntry to a WikiSon string
     * @return the WikiSon representation of this GlossaryEntry
     */
    public String toWikiSon() {
      String wikison= "{{GlossaryEntry\n";
      wikison+=toWikiSon("responsible",responsible);
      wikison+=toWikiSon("state",state);
      wikison+=toWikiSon("since",since);
      wikison+=toWikiSon("description",description);
      wikison+=toWikiSon("references",references);
      wikison+=toWikiSon("lang",lang);
      wikison+=toWikiSon("master",master);
      wikison+="}}\n";
      return wikison;
    }

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

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

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

    /**
     * construct a GlossaryEntry from the given pageId
     * @param query - the TripleQuery to get the triples from
     * @param pageid - pageid
     */
    public GlossaryEntry(TripleQuery query,String pageid) {
      this.pageid=pageid;
      Triple responsibleTriple=query.selectSingle(pageid,"responsible",null);
      if (responsibleTriple==null)
        responsibleTriple=query.selectSingle(pageid,"Property:GlossaryEntry_responsible",null);
      if (responsibleTriple!=null) 
        responsible=responsibleTriple.getObject().toString();
      Triple stateTriple=query.selectSingle(pageid,"state",null);
      if (stateTriple==null)
        stateTriple=query.selectSingle(pageid,"Property:GlossaryEntry_state",null);
      if (stateTriple!=null) 
        state=stateTriple.getObject().toString();
      Triple sinceTriple=query.selectSingle(pageid,"since",null);
      if (sinceTriple==null)
        sinceTriple=query.selectSingle(pageid,"Property:GlossaryEntry_since",null);
      if (sinceTriple!=null) 
        since=sinceTriple.getObject().toString();
      Triple descriptionTriple=query.selectSingle(pageid,"description",null);
      if (descriptionTriple==null)
        descriptionTriple=query.selectSingle(pageid,"Property:GlossaryEntry_description",null);
      if (descriptionTriple!=null) 
        description=descriptionTriple.getObject().toString();
      Triple referencesTriple=query.selectSingle(pageid,"references",null);
      if (referencesTriple==null)
        referencesTriple=query.selectSingle(pageid,"Property:GlossaryEntry_references",null);
      if (referencesTriple!=null) 
        references=referencesTriple.getObject().toString();
      Triple langTriple=query.selectSingle(pageid,"lang",null);
      if (langTriple==null)
        langTriple=query.selectSingle(pageid,"Property:GlossaryEntry_lang",null);
      if (langTriple!=null) 
        lang=langTriple.getObject().toString();
      Triple masterTriple=query.selectSingle(pageid,"master",null);
      if (masterTriple==null)
        masterTriple=query.selectSingle(pageid,"Property:GlossaryEntry_master",null);
      if (masterTriple!=null) 
        master=masterTriple.getObject().toString();
      init(query);
    } // constructor for GlossaryEntry
    
    // >>>{user defined topic code}{GlossaryEntry}{GlossaryEntry}
    // <<<{user defined topic code}{GlossaryEntry}{GlossaryEntry}
  } // class GlossaryEntry
  /**
   * Manager for GlossaryEntry
   */
  public static class GlossaryEntryManager extends TopicBase {
 
    public String topicName="GlossaryEntry";
    public transient List<GlossaryEntry> mGlossaryEntrys=new ArrayList<GlossaryEntry>();
    public transient Map<String,GlossaryEntry> mGlossaryEntryMap=new LinkedHashMap<String,GlossaryEntry>();

    /**
     * get my GlossaryEntries
     */
    public List<GlossaryEntry> getGlossaryEntries() {
      List<GlossaryEntry> result=this.mGlossaryEntrys;
      return result;
    }

    /**
     *  add a new GlossaryEntry 
     */
    public GlossaryEntry add(GlossaryEntry pGlossaryEntry) {
      mGlossaryEntrys.add(pGlossaryEntry);
      mGlossaryEntryMap.put(pGlossaryEntry.getPageid(),pGlossaryEntry);
      return pGlossaryEntry;
    }

    /**
     *  add a new GlossaryEntry from the given triple
     */
    public GlossaryEntry add(TripleQuery query,Triple pGlossaryEntryTriple) {
      GlossaryEntry lGlossaryEntry=new GlossaryEntry(query,pGlossaryEntryTriple);
      add(lGlossaryEntry);
      return lGlossaryEntry;
    }

    // reinitialize my mGlossaryEntry map
    public void reinit() {
      mGlossaryEntryMap.clear();
      for (GlossaryEntry lGlossaryEntry:mGlossaryEntrys) {
        mGlossaryEntryMap.put(lGlossaryEntry.getPageid(),lGlossaryEntry);
      }
    }

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

    // default constructor for GlossaryEntry Manager
    public GlossaryEntryManager() {}

    // add GlossaryEntries from the given query
    public void addGlossaryEntries(TripleQuery pGlossaryEntryQuery,TripleQuery query) {
      if (pGlossaryEntryQuery!=null) {
        for (Triple lGlossaryEntryTriple:pGlossaryEntryQuery.getTriples()) {
          add(query,lGlossaryEntryTriple);
        }
      }
    }

    // construct me from the given triple Query query
    public GlossaryEntryManager(TripleQuery query) {
      // first query the SiDIF bases triplestore
      TripleQuery lGlossaryEntryQuery=query.query(null,"isA","GlossaryEntry");
      addGlossaryEntries(lGlossaryEntryQuery,query);
      // then the SMW triplestore
      lGlossaryEntryQuery=query.query(null,"Property:IsA","GlossaryEntry");
      addGlossaryEntries(lGlossaryEntryQuery,query);
      init(query);
    } // constructor for GlossaryEntry Manager
    
    // >>>{user defined topicmanager code}{GlossaryEntry}{GlossaryEntry}
    // <<<{user defined topicmanager code}{GlossaryEntry}{GlossaryEntry}
  } // class GlossaryEntry Manager
 /**
  * Reference
  * A reference refers to some piece of information e.g. literature or webcontent
  */
  public static class Reference extends TopicBase {
  
    public String id;
    public String title;
    public String authors;
    public String amazonauthors;
    public String publisher;
    public String edition;
    public String booktype;
    public String language;
    public String DOI;
    public String ISBN10;
    public String ISBN13;
    public String booklink;
    public String booklink2;
    public String pdflink;
    public String pages;
    public String year;
    public String coverpicture;
    public String status;
    public String comment;

    public String getId() { return id; }
    public void setId(String pId) { id=pId; }
    public String getTitle() { return title; }
    public void setTitle(String pTitle) { title=pTitle; }
    public String getAuthors() { return authors; }
    public void setAuthors(String pAuthors) { authors=pAuthors; }
    public String getAmazonauthors() { return amazonauthors; }
    public void setAmazonauthors(String pAmazonauthors) { amazonauthors=pAmazonauthors; }
    public String getPublisher() { return publisher; }
    public void setPublisher(String pPublisher) { publisher=pPublisher; }
    public String getEdition() { return edition; }
    public void setEdition(String pEdition) { edition=pEdition; }
    public String getBooktype() { return booktype; }
    public void setBooktype(String pBooktype) { booktype=pBooktype; }
    public String getLanguage() { return language; }
    public void setLanguage(String pLanguage) { language=pLanguage; }
    public String getDOI() { return DOI; }
    public void setDOI(String pDOI) { DOI=pDOI; }
    public String getISBN10() { return ISBN10; }
    public void setISBN10(String pISBN10) { ISBN10=pISBN10; }
    public String getISBN13() { return ISBN13; }
    public void setISBN13(String pISBN13) { ISBN13=pISBN13; }
    public String getBooklink() { return booklink; }
    public void setBooklink(String pBooklink) { booklink=pBooklink; }
    public String getBooklink2() { return booklink2; }
    public void setBooklink2(String pBooklink2) { booklink2=pBooklink2; }
    public String getPdflink() { return pdflink; }
    public void setPdflink(String pPdflink) { pdflink=pPdflink; }
    public String getPages() { return pages; }
    public void setPages(String pPages) { pages=pPages; }
    public String getYear() { return year; }
    public void setYear(String pYear) { year=pYear; }
    public String getCoverpicture() { return coverpicture; }
    public void setCoverpicture(String pCoverpicture) { coverpicture=pCoverpicture; }
    public String getStatus() { return status; }
    public void setStatus(String pStatus) { status=pStatus; }
    public String getComment() { return comment; }
    public void setComment(String pComment) { comment=pComment; }
    /**
     * convert this Reference to a JSON string
     * @return the JSON representation
     */
    public String toJson() { return JSON.toJSONString(this); }

    /**
     * convert this Reference to a WikiSon string
     * @return the WikiSon representation of this Reference
     */
    public String toWikiSon() {
      String wikison= "{{Reference\n";
      wikison+=toWikiSon("id",id);
      wikison+=toWikiSon("title",title);
      wikison+=toWikiSon("authors",authors);
      wikison+=toWikiSon("amazonauthors",amazonauthors);
      wikison+=toWikiSon("publisher",publisher);
      wikison+=toWikiSon("edition",edition);
      wikison+=toWikiSon("booktype",booktype);
      wikison+=toWikiSon("language",language);
      wikison+=toWikiSon("DOI",DOI);
      wikison+=toWikiSon("ISBN10",ISBN10);
      wikison+=toWikiSon("ISBN13",ISBN13);
      wikison+=toWikiSon("booklink",booklink);
      wikison+=toWikiSon("booklink2",booklink2);
      wikison+=toWikiSon("pdflink",pdflink);
      wikison+=toWikiSon("pages",pages);
      wikison+=toWikiSon("year",year);
      wikison+=toWikiSon("coverpicture",coverpicture);
      wikison+=toWikiSon("status",status);
      wikison+=toWikiSon("comment",comment);
      wikison+="}}\n";
      return wikison;
    }

    /**
     * convert this Reference to a SiDIF string
     * @return the SiDIF representation of this Reference
     */
    public String toSiDIF() {
      String siDIF = String.format("%s isA Reference\n",this.pageid);
      siDIF+=propertySiDIF("id",id,"Text");
      siDIF+=propertySiDIF("title",title,"Text");
      siDIF+=propertySiDIF("authors",authors,"Text");
      siDIF+=propertySiDIF("amazonauthors",amazonauthors,"Text");
      siDIF+=propertySiDIF("publisher",publisher,"Text");
      siDIF+=propertySiDIF("edition",edition,"Text");
      siDIF+=propertySiDIF("booktype",booktype,"Text");
      siDIF+=propertySiDIF("language",language,"Text");
      siDIF+=propertySiDIF("DOI",DOI,"Text");
      siDIF+=propertySiDIF("ISBN10",ISBN10,"Text");
      siDIF+=propertySiDIF("ISBN13",ISBN13,"Text");
      siDIF+=propertySiDIF("booklink",booklink,"URL");
      siDIF+=propertySiDIF("booklink2",booklink2,"URL");
      siDIF+=propertySiDIF("pdflink",pdflink,"URL");
      siDIF+=propertySiDIF("pages",pages,"Number");
      siDIF+=propertySiDIF("year",year,"Date");
      siDIF+=propertySiDIF("coverpicture",coverpicture,"URL");
      siDIF+=propertySiDIF("status",status,"Text");
      siDIF+=propertySiDIF("comment",comment,"Text");
      return siDIF;
    }
 
    /**  
     * get the pageid for this topic
     */
    public String getPageid() { return pageid; };

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

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

    /**
     * construct a Reference from the given pageId
     * @param query - the TripleQuery to get the triples from
     * @param pageid - pageid
     */
    public Reference(TripleQuery query,String pageid) {
      this.pageid=pageid;
      Triple idTriple=query.selectSingle(pageid,"id",null);
      if (idTriple==null)
        idTriple=query.selectSingle(pageid,"Property:Reference_id",null);
      if (idTriple!=null) 
        id=idTriple.getObject().toString();
      Triple titleTriple=query.selectSingle(pageid,"title",null);
      if (titleTriple==null)
        titleTriple=query.selectSingle(pageid,"Property:Reference_title",null);
      if (titleTriple!=null) 
        title=titleTriple.getObject().toString();
      Triple authorsTriple=query.selectSingle(pageid,"authors",null);
      if (authorsTriple==null)
        authorsTriple=query.selectSingle(pageid,"Property:Reference_authors",null);
      if (authorsTriple!=null) 
        authors=authorsTriple.getObject().toString();
      Triple amazonauthorsTriple=query.selectSingle(pageid,"amazonauthors",null);
      if (amazonauthorsTriple==null)
        amazonauthorsTriple=query.selectSingle(pageid,"Property:Reference_amazonauthors",null);
      if (amazonauthorsTriple!=null) 
        amazonauthors=amazonauthorsTriple.getObject().toString();
      Triple publisherTriple=query.selectSingle(pageid,"publisher",null);
      if (publisherTriple==null)
        publisherTriple=query.selectSingle(pageid,"Property:Reference_publisher",null);
      if (publisherTriple!=null) 
        publisher=publisherTriple.getObject().toString();
      Triple editionTriple=query.selectSingle(pageid,"edition",null);
      if (editionTriple==null)
        editionTriple=query.selectSingle(pageid,"Property:Reference_edition",null);
      if (editionTriple!=null) 
        edition=editionTriple.getObject().toString();
      Triple booktypeTriple=query.selectSingle(pageid,"booktype",null);
      if (booktypeTriple==null)
        booktypeTriple=query.selectSingle(pageid,"Property:Reference_booktype",null);
      if (booktypeTriple!=null) 
        booktype=booktypeTriple.getObject().toString();
      Triple languageTriple=query.selectSingle(pageid,"language",null);
      if (languageTriple==null)
        languageTriple=query.selectSingle(pageid,"Property:Reference_language",null);
      if (languageTriple!=null) 
        language=languageTriple.getObject().toString();
      Triple DOITriple=query.selectSingle(pageid,"DOI",null);
      if (DOITriple==null)
        DOITriple=query.selectSingle(pageid,"Property:Reference_DOI",null);
      if (DOITriple!=null) 
        DOI=DOITriple.getObject().toString();
      Triple ISBN10Triple=query.selectSingle(pageid,"ISBN10",null);
      if (ISBN10Triple==null)
        ISBN10Triple=query.selectSingle(pageid,"Property:Reference_ISBN10",null);
      if (ISBN10Triple!=null) 
        ISBN10=ISBN10Triple.getObject().toString();
      Triple ISBN13Triple=query.selectSingle(pageid,"ISBN13",null);
      if (ISBN13Triple==null)
        ISBN13Triple=query.selectSingle(pageid,"Property:Reference_ISBN13",null);
      if (ISBN13Triple!=null) 
        ISBN13=ISBN13Triple.getObject().toString();
      Triple booklinkTriple=query.selectSingle(pageid,"booklink",null);
      if (booklinkTriple==null)
        booklinkTriple=query.selectSingle(pageid,"Property:Reference_booklink",null);
      if (booklinkTriple!=null) 
        booklink=booklinkTriple.getObject().toString();
      Triple booklink2Triple=query.selectSingle(pageid,"booklink2",null);
      if (booklink2Triple==null)
        booklink2Triple=query.selectSingle(pageid,"Property:Reference_booklink2",null);
      if (booklink2Triple!=null) 
        booklink2=booklink2Triple.getObject().toString();
      Triple pdflinkTriple=query.selectSingle(pageid,"pdflink",null);
      if (pdflinkTriple==null)
        pdflinkTriple=query.selectSingle(pageid,"Property:Reference_pdflink",null);
      if (pdflinkTriple!=null) 
        pdflink=pdflinkTriple.getObject().toString();
      Triple pagesTriple=query.selectSingle(pageid,"pages",null);
      if (pagesTriple==null)
        pagesTriple=query.selectSingle(pageid,"Property:Reference_pages",null);
      if (pagesTriple!=null) 
        pages=pagesTriple.getObject().toString();
      Triple yearTriple=query.selectSingle(pageid,"year",null);
      if (yearTriple==null)
        yearTriple=query.selectSingle(pageid,"Property:Reference_year",null);
      if (yearTriple!=null) 
        year=yearTriple.getObject().toString();
      Triple coverpictureTriple=query.selectSingle(pageid,"coverpicture",null);
      if (coverpictureTriple==null)
        coverpictureTriple=query.selectSingle(pageid,"Property:Reference_coverpicture",null);
      if (coverpictureTriple!=null) 
        coverpicture=coverpictureTriple.getObject().toString();
      Triple statusTriple=query.selectSingle(pageid,"status",null);
      if (statusTriple==null)
        statusTriple=query.selectSingle(pageid,"Property:Reference_status",null);
      if (statusTriple!=null) 
        status=statusTriple.getObject().toString();
      Triple commentTriple=query.selectSingle(pageid,"comment",null);
      if (commentTriple==null)
        commentTriple=query.selectSingle(pageid,"Property:Reference_comment",null);
      if (commentTriple!=null) 
        comment=commentTriple.getObject().toString();
      init(query);
    } // constructor for Reference
    
    // >>>{user defined topic code}{Reference}{Reference}
    // <<<{user defined topic code}{Reference}{Reference}
  } // class Reference
  /**
   * Manager for Reference
   */
  public static class ReferenceManager extends TopicBase {
 
    public String topicName="Reference";
    public transient List<Reference> mReferences=new ArrayList<Reference>();
    public transient Map<String,Reference> mReferenceMap=new LinkedHashMap<String,Reference>();

    /**
     * get my References
     */
    public List<Reference> getReferences() {
      List<Reference> result=this.mReferences;
      return result;
    }

    /**
     *  add a new Reference 
     */
    public Reference add(Reference pReference) {
      mReferences.add(pReference);
      mReferenceMap.put(pReference.getPageid(),pReference);
      return pReference;
    }

    /**
     *  add a new Reference from the given triple
     */
    public Reference add(TripleQuery query,Triple pReferenceTriple) {
      Reference lReference=new Reference(query,pReferenceTriple);
      add(lReference);
      return lReference;
    }

    // reinitialize my mReference map
    public void reinit() {
      mReferenceMap.clear();
      for (Reference lReference:mReferences) {
        mReferenceMap.put(lReference.getPageid(),lReference);
      }
    }

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

    // default constructor for Reference Manager
    public ReferenceManager() {}

    // add References from the given query
    public void addReferences(TripleQuery pReferenceQuery,TripleQuery query) {
      if (pReferenceQuery!=null) {
        for (Triple lReferenceTriple:pReferenceQuery.getTriples()) {
          add(query,lReferenceTriple);
        }
      }
    }

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

}
Showing below 0 pages.

Retrieved from "http://ceur-ws.bitplan.com/index.php?title=Concept:Platform/Java&oldid=209#smw-result"