Volume/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 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
 /**
  * Volume
  * A Volume is a collection of papers mostly documenting the results of an academic event
  */
  public static class Volume extends TopicBase {
  
    public String number;
    public String title;

    public String getNumber() { return number; }
    public void setNumber(String pNumber) { number=pNumber; }
    public String getTitle() { return title; }
    public void setTitle(String pTitle) { title=pTitle; }
    /**
     * convert this Volume to a JSON string
     * @return the JSON representation
     */
    public String toJson() { return JSON.toJSONString(this); }

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

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

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

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

    /**
     * construct a Volume from the given pageId
     * @param query - the TripleQuery to get the triples from
     * @param pageid - pageid
     */
    public Volume(TripleQuery query,String pageid) {
      this.pageid=pageid;
      Triple numberTriple=query.selectSingle(pageid,"number",null);
      if (numberTriple==null)
        numberTriple=query.selectSingle(pageid,"Property:Volume_number",null);
      if (numberTriple!=null) 
        number=numberTriple.getObject().toString();
      Triple titleTriple=query.selectSingle(pageid,"title",null);
      if (titleTriple==null)
        titleTriple=query.selectSingle(pageid,"Property:Volume_title",null);
      if (titleTriple!=null) 
        title=titleTriple.getObject().toString();
      init(query);
    } // constructor for Volume
    
    // >>>{user defined topic code}{Volume}{Volume}
    // <<<{user defined topic code}{Volume}{Volume}
  } // class Volume
  /**
   * Manager for Volume
   */
  public static class VolumeManager extends TopicBase {
 
    public String topicName="Volume";
    public transient List<Volume> mVolumes=new ArrayList<Volume>();
    public transient Map<String,Volume> mVolumeMap=new LinkedHashMap<String,Volume>();

    /**
     * get my Volumes
     */
    public List<Volume> getVolumes() {
      List<Volume> result=this.mVolumes;
      return result;
    }

    /**
     *  add a new Volume 
     */
    public Volume add(Volume pVolume) {
      mVolumes.add(pVolume);
      mVolumeMap.put(pVolume.getPageid(),pVolume);
      return pVolume;
    }

    /**
     *  add a new Volume from the given triple
     */
    public Volume add(TripleQuery query,Triple pVolumeTriple) {
      Volume lVolume=new Volume(query,pVolumeTriple);
      add(lVolume);
      return lVolume;
    }

    // reinitialize my mVolume map
    public void reinit() {
      mVolumeMap.clear();
      for (Volume lVolume:mVolumes) {
        mVolumeMap.put(lVolume.getPageid(),lVolume);
      }
    }

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

    // default constructor for Volume Manager
    public VolumeManager() {}

    // add Volumes from the given query
    public void addVolumes(TripleQuery pVolumeQuery,TripleQuery query) {
      if (pVolumeQuery!=null) {
        for (Triple lVolumeTriple:pVolumeQuery.getTriples()) {
          add(query,lVolumeTriple);
        }
      }
    }

    // construct me from the given triple Query query
    public VolumeManager(TripleQuery query) {
      // first query the SiDIF bases triplestore
      TripleQuery lVolumeQuery=query.query(null,"isA","Volume");
      addVolumes(lVolumeQuery,query);
      // then the SMW triplestore
      lVolumeQuery=query.query(null,"Property:IsA","Volume");
      addVolumes(lVolumeQuery,query);
      init(query);
    } // constructor for Volume Manager
    
    // >>>{user defined topicmanager code}{Volume}{Volume}
    // <<<{user defined topicmanager code}{Volume}{Volume}
  } // class Volume Manager
 /**
  * Session
  * A Session is a a collection of papers as part of a Volume
  */
  public static class Session extends TopicBase {
  
    public String title;
    public String volume;

    public String getTitle() { return title; }
    public void setTitle(String pTitle) { title=pTitle; }
    public String getVolume() { return volume; }
    public void setVolume(String pVolume) { volume=pVolume; }
    /**
     * convert this Session to a JSON string
     * @return the JSON representation
     */
    public String toJson() { return JSON.toJSONString(this); }

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

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

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

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

    /**
     * construct a Session from the given pageId
     * @param query - the TripleQuery to get the triples from
     * @param pageid - pageid
     */
    public Session(TripleQuery query,String pageid) {
      this.pageid=pageid;
      Triple titleTriple=query.selectSingle(pageid,"title",null);
      if (titleTriple==null)
        titleTriple=query.selectSingle(pageid,"Property:Session_title",null);
      if (titleTriple!=null) 
        title=titleTriple.getObject().toString();
      Triple volumeTriple=query.selectSingle(pageid,"volume",null);
      if (volumeTriple==null)
        volumeTriple=query.selectSingle(pageid,"Property:Session_volume",null);
      if (volumeTriple!=null) 
        volume=volumeTriple.getObject().toString();
      init(query);
    } // constructor for Session
    
    // >>>{user defined topic code}{Session}{Session}
    // <<<{user defined topic code}{Session}{Session}
  } // class Session
  /**
   * Manager for Session
   */
  public static class SessionManager extends TopicBase {
 
    public String topicName="Session";
    public transient List<Session> mSessions=new ArrayList<Session>();
    public transient Map<String,Session> mSessionMap=new LinkedHashMap<String,Session>();

    /**
     * get my Sessions
     */
    public List<Session> getSessions() {
      List<Session> result=this.mSessions;
      return result;
    }

    /**
     *  add a new Session 
     */
    public Session add(Session pSession) {
      mSessions.add(pSession);
      mSessionMap.put(pSession.getPageid(),pSession);
      return pSession;
    }

    /**
     *  add a new Session from the given triple
     */
    public Session add(TripleQuery query,Triple pSessionTriple) {
      Session lSession=new Session(query,pSessionTriple);
      add(lSession);
      return lSession;
    }

    // reinitialize my mSession map
    public void reinit() {
      mSessionMap.clear();
      for (Session lSession:mSessions) {
        mSessionMap.put(lSession.getPageid(),lSession);
      }
    }

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

    // default constructor for Session Manager
    public SessionManager() {}

    // add Sessions from the given query
    public void addSessions(TripleQuery pSessionQuery,TripleQuery query) {
      if (pSessionQuery!=null) {
        for (Triple lSessionTriple:pSessionQuery.getTriples()) {
          add(query,lSessionTriple);
        }
      }
    }

    // construct me from the given triple Query query
    public SessionManager(TripleQuery query) {
      // first query the SiDIF bases triplestore
      TripleQuery lSessionQuery=query.query(null,"isA","Session");
      addSessions(lSessionQuery,query);
      // then the SMW triplestore
      lSessionQuery=query.query(null,"Property:IsA","Session");
      addSessions(lSessionQuery,query);
      init(query);
    } // constructor for Session Manager
    
    // >>>{user defined topicmanager code}{Session}{Session}
    // <<<{user defined topicmanager code}{Session}{Session}
  } // class Session Manager
 /**
  * Paper
  * A paper is e.g. a scholarly article
  */
  public static class Paper extends TopicBase {
  
    public String id;
    public String title;
    public String authors;
    public String pdfUrl;
    public String volume;
    public String session;

    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 getPdfUrl() { return pdfUrl; }
    public void setPdfUrl(String pPdfUrl) { pdfUrl=pPdfUrl; }
    public String getVolume() { return volume; }
    public void setVolume(String pVolume) { volume=pVolume; }
    public String getSession() { return session; }
    public void setSession(String pSession) { session=pSession; }
    /**
     * convert this Paper to a JSON string
     * @return the JSON representation
     */
    public String toJson() { return JSON.toJSONString(this); }

    /**
     * convert this Paper to a WikiSon string
     * @return the WikiSon representation of this Paper
     */
    public String toWikiSon() {
      String wikison= "{{Paper\n";
      wikison+=toWikiSon("id",id);
      wikison+=toWikiSon("title",title);
      wikison+=toWikiSon("authors",authors);
      wikison+=toWikiSon("pdfUrl",pdfUrl);
      wikison+=toWikiSon("volume",volume);
      wikison+=toWikiSon("session",session);
      wikison+="}}\n";
      return wikison;
    }

    /**
     * convert this Paper to a SiDIF string
     * @return the SiDIF representation of this Paper
     */
    public String toSiDIF() {
      String siDIF = String.format("%s isA Paper\n",this.pageid);
      siDIF+=propertySiDIF("id",id,"Text");
      siDIF+=propertySiDIF("title",title,"Text");
      siDIF+=propertySiDIF("authors",authors,"Text");
      siDIF+=propertySiDIF("pdfUrl",pdfUrl,"URL");
      siDIF+=propertySiDIF("volume",volume,"Page");
      siDIF+=propertySiDIF("session",session,"Page");
      return siDIF;
    }
 
    /**  
     * get the pageid for this topic
     */
    public String getPageid() { return pageid; };

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

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

    /**
     * construct a Paper from the given pageId
     * @param query - the TripleQuery to get the triples from
     * @param pageid - pageid
     */
    public Paper(TripleQuery query,String pageid) {
      this.pageid=pageid;
      Triple idTriple=query.selectSingle(pageid,"id",null);
      if (idTriple==null)
        idTriple=query.selectSingle(pageid,"Property:Paper_id",null);
      if (idTriple!=null) 
        id=idTriple.getObject().toString();
      Triple titleTriple=query.selectSingle(pageid,"title",null);
      if (titleTriple==null)
        titleTriple=query.selectSingle(pageid,"Property:Paper_title",null);
      if (titleTriple!=null) 
        title=titleTriple.getObject().toString();
      Triple authorsTriple=query.selectSingle(pageid,"authors",null);
      if (authorsTriple==null)
        authorsTriple=query.selectSingle(pageid,"Property:Paper_authors",null);
      if (authorsTriple!=null) 
        authors=authorsTriple.getObject().toString();
      Triple pdfUrlTriple=query.selectSingle(pageid,"pdfUrl",null);
      if (pdfUrlTriple==null)
        pdfUrlTriple=query.selectSingle(pageid,"Property:Paper_pdfUrl",null);
      if (pdfUrlTriple!=null) 
        pdfUrl=pdfUrlTriple.getObject().toString();
      Triple volumeTriple=query.selectSingle(pageid,"volume",null);
      if (volumeTriple==null)
        volumeTriple=query.selectSingle(pageid,"Property:Paper_volume",null);
      if (volumeTriple!=null) 
        volume=volumeTriple.getObject().toString();
      Triple sessionTriple=query.selectSingle(pageid,"session",null);
      if (sessionTriple==null)
        sessionTriple=query.selectSingle(pageid,"Property:Paper_session",null);
      if (sessionTriple!=null) 
        session=sessionTriple.getObject().toString();
      init(query);
    } // constructor for Paper
    
    // >>>{user defined topic code}{Paper}{Paper}
    // <<<{user defined topic code}{Paper}{Paper}
  } // class Paper
  /**
   * Manager for Paper
   */
  public static class PaperManager extends TopicBase {
 
    public String topicName="Paper";
    public transient List<Paper> mPapers=new ArrayList<Paper>();
    public transient Map<String,Paper> mPaperMap=new LinkedHashMap<String,Paper>();

    /**
     * get my Papers
     */
    public List<Paper> getPapers() {
      List<Paper> result=this.mPapers;
      return result;
    }

    /**
     *  add a new Paper 
     */
    public Paper add(Paper pPaper) {
      mPapers.add(pPaper);
      mPaperMap.put(pPaper.getPageid(),pPaper);
      return pPaper;
    }

    /**
     *  add a new Paper from the given triple
     */
    public Paper add(TripleQuery query,Triple pPaperTriple) {
      Paper lPaper=new Paper(query,pPaperTriple);
      add(lPaper);
      return lPaper;
    }

    // reinitialize my mPaper map
    public void reinit() {
      mPaperMap.clear();
      for (Paper lPaper:mPapers) {
        mPaperMap.put(lPaper.getPageid(),lPaper);
      }
    }

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

    // default constructor for Paper Manager
    public PaperManager() {}

    // add Papers from the given query
    public void addPapers(TripleQuery pPaperQuery,TripleQuery query) {
      if (pPaperQuery!=null) {
        for (Triple lPaperTriple:pPaperQuery.getTriples()) {
          add(query,lPaperTriple);
        }
      }
    }

    // construct me from the given triple Query query
    public PaperManager(TripleQuery query) {
      // first query the SiDIF bases triplestore
      TripleQuery lPaperQuery=query.query(null,"isA","Paper");
      addPapers(lPaperQuery,query);
      // then the SMW triplestore
      lPaperQuery=query.query(null,"Property:IsA","Paper");
      addPapers(lPaperQuery,query);
      init(query);
    } // constructor for Paper Manager
    
    // >>>{user defined topicmanager code}{Paper}{Paper}
    // <<<{user defined topicmanager code}{Paper}{Paper}
  } // class Paper 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 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
 /**
  * Volume
  * A Volume is a collection of papers mostly documenting the results of an academic event
  */
  public static class Volume extends TopicBase {
  
    public String number;
    public String title;

    public String getNumber() { return number; }
    public void setNumber(String pNumber) { number=pNumber; }
    public String getTitle() { return title; }
    public void setTitle(String pTitle) { title=pTitle; }
    /**
     * convert this Volume to a JSON string
     * @return the JSON representation
     */
    public String toJson() { return JSON.toJSONString(this); }

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

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

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

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

    /**
     * construct a Volume from the given pageId
     * @param query - the TripleQuery to get the triples from
     * @param pageid - pageid
     */
    public Volume(TripleQuery query,String pageid) {
      this.pageid=pageid;
      Triple numberTriple=query.selectSingle(pageid,"number",null);
      if (numberTriple==null)
        numberTriple=query.selectSingle(pageid,"Property:Volume_number",null);
      if (numberTriple!=null) 
        number=numberTriple.getObject().toString();
      Triple titleTriple=query.selectSingle(pageid,"title",null);
      if (titleTriple==null)
        titleTriple=query.selectSingle(pageid,"Property:Volume_title",null);
      if (titleTriple!=null) 
        title=titleTriple.getObject().toString();
      init(query);
    } // constructor for Volume
    
    // >>>{user defined topic code}{Volume}{Volume}
    // <<<{user defined topic code}{Volume}{Volume}
  } // class Volume
  /**
   * Manager for Volume
   */
  public static class VolumeManager extends TopicBase {
 
    public String topicName="Volume";
    public transient List<Volume> mVolumes=new ArrayList<Volume>();
    public transient Map<String,Volume> mVolumeMap=new LinkedHashMap<String,Volume>();

    /**
     * get my Volumes
     */
    public List<Volume> getVolumes() {
      List<Volume> result=this.mVolumes;
      return result;
    }

    /**
     *  add a new Volume 
     */
    public Volume add(Volume pVolume) {
      mVolumes.add(pVolume);
      mVolumeMap.put(pVolume.getPageid(),pVolume);
      return pVolume;
    }

    /**
     *  add a new Volume from the given triple
     */
    public Volume add(TripleQuery query,Triple pVolumeTriple) {
      Volume lVolume=new Volume(query,pVolumeTriple);
      add(lVolume);
      return lVolume;
    }

    // reinitialize my mVolume map
    public void reinit() {
      mVolumeMap.clear();
      for (Volume lVolume:mVolumes) {
        mVolumeMap.put(lVolume.getPageid(),lVolume);
      }
    }

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

    // default constructor for Volume Manager
    public VolumeManager() {}

    // add Volumes from the given query
    public void addVolumes(TripleQuery pVolumeQuery,TripleQuery query) {
      if (pVolumeQuery!=null) {
        for (Triple lVolumeTriple:pVolumeQuery.getTriples()) {
          add(query,lVolumeTriple);
        }
      }
    }

    // construct me from the given triple Query query
    public VolumeManager(TripleQuery query) {
      // first query the SiDIF bases triplestore
      TripleQuery lVolumeQuery=query.query(null,"isA","Volume");
      addVolumes(lVolumeQuery,query);
      // then the SMW triplestore
      lVolumeQuery=query.query(null,"Property:IsA","Volume");
      addVolumes(lVolumeQuery,query);
      init(query);
    } // constructor for Volume Manager
    
    // >>>{user defined topicmanager code}{Volume}{Volume}
    // <<<{user defined topicmanager code}{Volume}{Volume}
  } // class Volume Manager
 /**
  * Session
  * A Session is a a collection of papers as part of a Volume
  */
  public static class Session extends TopicBase {
  
    public String title;
    public String volume;

    public String getTitle() { return title; }
    public void setTitle(String pTitle) { title=pTitle; }
    public String getVolume() { return volume; }
    public void setVolume(String pVolume) { volume=pVolume; }
    /**
     * convert this Session to a JSON string
     * @return the JSON representation
     */
    public String toJson() { return JSON.toJSONString(this); }

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

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

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

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

    /**
     * construct a Session from the given pageId
     * @param query - the TripleQuery to get the triples from
     * @param pageid - pageid
     */
    public Session(TripleQuery query,String pageid) {
      this.pageid=pageid;
      Triple titleTriple=query.selectSingle(pageid,"title",null);
      if (titleTriple==null)
        titleTriple=query.selectSingle(pageid,"Property:Session_title",null);
      if (titleTriple!=null) 
        title=titleTriple.getObject().toString();
      Triple volumeTriple=query.selectSingle(pageid,"volume",null);
      if (volumeTriple==null)
        volumeTriple=query.selectSingle(pageid,"Property:Session_volume",null);
      if (volumeTriple!=null) 
        volume=volumeTriple.getObject().toString();
      init(query);
    } // constructor for Session
    
    // >>>{user defined topic code}{Session}{Session}
    // <<<{user defined topic code}{Session}{Session}
  } // class Session
  /**
   * Manager for Session
   */
  public static class SessionManager extends TopicBase {
 
    public String topicName="Session";
    public transient List<Session> mSessions=new ArrayList<Session>();
    public transient Map<String,Session> mSessionMap=new LinkedHashMap<String,Session>();

    /**
     * get my Sessions
     */
    public List<Session> getSessions() {
      List<Session> result=this.mSessions;
      return result;
    }

    /**
     *  add a new Session 
     */
    public Session add(Session pSession) {
      mSessions.add(pSession);
      mSessionMap.put(pSession.getPageid(),pSession);
      return pSession;
    }

    /**
     *  add a new Session from the given triple
     */
    public Session add(TripleQuery query,Triple pSessionTriple) {
      Session lSession=new Session(query,pSessionTriple);
      add(lSession);
      return lSession;
    }

    // reinitialize my mSession map
    public void reinit() {
      mSessionMap.clear();
      for (Session lSession:mSessions) {
        mSessionMap.put(lSession.getPageid(),lSession);
      }
    }

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

    // default constructor for Session Manager
    public SessionManager() {}

    // add Sessions from the given query
    public void addSessions(TripleQuery pSessionQuery,TripleQuery query) {
      if (pSessionQuery!=null) {
        for (Triple lSessionTriple:pSessionQuery.getTriples()) {
          add(query,lSessionTriple);
        }
      }
    }

    // construct me from the given triple Query query
    public SessionManager(TripleQuery query) {
      // first query the SiDIF bases triplestore
      TripleQuery lSessionQuery=query.query(null,"isA","Session");
      addSessions(lSessionQuery,query);
      // then the SMW triplestore
      lSessionQuery=query.query(null,"Property:IsA","Session");
      addSessions(lSessionQuery,query);
      init(query);
    } // constructor for Session Manager
    
    // >>>{user defined topicmanager code}{Session}{Session}
    // <<<{user defined topicmanager code}{Session}{Session}
  } // class Session Manager
 /**
  * Paper
  * A paper is e.g. a scholarly article
  */
  public static class Paper extends TopicBase {
  
    public String id;
    public String title;
    public String authors;
    public String pdfUrl;
    public String volume;
    public String session;

    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 getPdfUrl() { return pdfUrl; }
    public void setPdfUrl(String pPdfUrl) { pdfUrl=pPdfUrl; }
    public String getVolume() { return volume; }
    public void setVolume(String pVolume) { volume=pVolume; }
    public String getSession() { return session; }
    public void setSession(String pSession) { session=pSession; }
    /**
     * convert this Paper to a JSON string
     * @return the JSON representation
     */
    public String toJson() { return JSON.toJSONString(this); }

    /**
     * convert this Paper to a WikiSon string
     * @return the WikiSon representation of this Paper
     */
    public String toWikiSon() {
      String wikison= "{{Paper\n";
      wikison+=toWikiSon("id",id);
      wikison+=toWikiSon("title",title);
      wikison+=toWikiSon("authors",authors);
      wikison+=toWikiSon("pdfUrl",pdfUrl);
      wikison+=toWikiSon("volume",volume);
      wikison+=toWikiSon("session",session);
      wikison+="}}\n";
      return wikison;
    }

    /**
     * convert this Paper to a SiDIF string
     * @return the SiDIF representation of this Paper
     */
    public String toSiDIF() {
      String siDIF = String.format("%s isA Paper\n",this.pageid);
      siDIF+=propertySiDIF("id",id,"Text");
      siDIF+=propertySiDIF("title",title,"Text");
      siDIF+=propertySiDIF("authors",authors,"Text");
      siDIF+=propertySiDIF("pdfUrl",pdfUrl,"URL");
      siDIF+=propertySiDIF("volume",volume,"Page");
      siDIF+=propertySiDIF("session",session,"Page");
      return siDIF;
    }
 
    /**  
     * get the pageid for this topic
     */
    public String getPageid() { return pageid; };

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

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

    /**
     * construct a Paper from the given pageId
     * @param query - the TripleQuery to get the triples from
     * @param pageid - pageid
     */
    public Paper(TripleQuery query,String pageid) {
      this.pageid=pageid;
      Triple idTriple=query.selectSingle(pageid,"id",null);
      if (idTriple==null)
        idTriple=query.selectSingle(pageid,"Property:Paper_id",null);
      if (idTriple!=null) 
        id=idTriple.getObject().toString();
      Triple titleTriple=query.selectSingle(pageid,"title",null);
      if (titleTriple==null)
        titleTriple=query.selectSingle(pageid,"Property:Paper_title",null);
      if (titleTriple!=null) 
        title=titleTriple.getObject().toString();
      Triple authorsTriple=query.selectSingle(pageid,"authors",null);
      if (authorsTriple==null)
        authorsTriple=query.selectSingle(pageid,"Property:Paper_authors",null);
      if (authorsTriple!=null) 
        authors=authorsTriple.getObject().toString();
      Triple pdfUrlTriple=query.selectSingle(pageid,"pdfUrl",null);
      if (pdfUrlTriple==null)
        pdfUrlTriple=query.selectSingle(pageid,"Property:Paper_pdfUrl",null);
      if (pdfUrlTriple!=null) 
        pdfUrl=pdfUrlTriple.getObject().toString();
      Triple volumeTriple=query.selectSingle(pageid,"volume",null);
      if (volumeTriple==null)
        volumeTriple=query.selectSingle(pageid,"Property:Paper_volume",null);
      if (volumeTriple!=null) 
        volume=volumeTriple.getObject().toString();
      Triple sessionTriple=query.selectSingle(pageid,"session",null);
      if (sessionTriple==null)
        sessionTriple=query.selectSingle(pageid,"Property:Paper_session",null);
      if (sessionTriple!=null) 
        session=sessionTriple.getObject().toString();
      init(query);
    } // constructor for Paper
    
    // >>>{user defined topic code}{Paper}{Paper}
    // <<<{user defined topic code}{Paper}{Paper}
  } // class Paper
  /**
   * Manager for Paper
   */
  public static class PaperManager extends TopicBase {
 
    public String topicName="Paper";
    public transient List<Paper> mPapers=new ArrayList<Paper>();
    public transient Map<String,Paper> mPaperMap=new LinkedHashMap<String,Paper>();

    /**
     * get my Papers
     */
    public List<Paper> getPapers() {
      List<Paper> result=this.mPapers;
      return result;
    }

    /**
     *  add a new Paper 
     */
    public Paper add(Paper pPaper) {
      mPapers.add(pPaper);
      mPaperMap.put(pPaper.getPageid(),pPaper);
      return pPaper;
    }

    /**
     *  add a new Paper from the given triple
     */
    public Paper add(TripleQuery query,Triple pPaperTriple) {
      Paper lPaper=new Paper(query,pPaperTriple);
      add(lPaper);
      return lPaper;
    }

    // reinitialize my mPaper map
    public void reinit() {
      mPaperMap.clear();
      for (Paper lPaper:mPapers) {
        mPaperMap.put(lPaper.getPageid(),lPaper);
      }
    }

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

    // default constructor for Paper Manager
    public PaperManager() {}

    // add Papers from the given query
    public void addPapers(TripleQuery pPaperQuery,TripleQuery query) {
      if (pPaperQuery!=null) {
        for (Triple lPaperTriple:pPaperQuery.getTriples()) {
          add(query,lPaperTriple);
        }
      }
    }

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

}
🖨 🚪