Concept:SeminarTopic/Java

From BITPlan Wiki
Revision as of 11:12, 10 November 2017 by Wf (talk | contribs) (created by WikiTask 2017-11-10T10:12:15Z)
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
     */
    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
 /**
  * Seminar
  * Ein Seminar ist die Durchfuehrung einer Ausbildungsveranstaltung an einem bestimmten Ort in einem bestimmten Zeitraum zu einem bestimmten Thema
  */
  public static class Seminar extends TopicBase {
  
    public String kind;
    public String lang;
    public String year;
    public String month;
    public String inHouse;
    public String from;
    public String to;
    public String title;
    public String contact;
    public String customer;
    public String documentation;
    public String trainer;
    public String city;
    public String thema;

    public String getKind() { return kind; }
    public void setKind(String pKind) { kind=pKind; }
    public String getLang() { return lang; }
    public void setLang(String pLang) { lang=pLang; }
    public String getYear() { return year; }
    public void setYear(String pYear) { year=pYear; }
    public String getMonth() { return month; }
    public void setMonth(String pMonth) { month=pMonth; }
    public String getInHouse() { return inHouse; }
    public void setInHouse(String pInHouse) { inHouse=pInHouse; }
    public String getFrom() { return from; }
    public void setFrom(String pFrom) { from=pFrom; }
    public String getTo() { return to; }
    public void setTo(String pTo) { to=pTo; }
    public String getTitle() { return title; }
    public void setTitle(String pTitle) { title=pTitle; }
    public String getContact() { return contact; }
    public void setContact(String pContact) { contact=pContact; }
    public String getCustomer() { return customer; }
    public void setCustomer(String pCustomer) { customer=pCustomer; }
    public String getDocumentation() { return documentation; }
    public void setDocumentation(String pDocumentation) { documentation=pDocumentation; }
    public String getTrainer() { return trainer; }
    public void setTrainer(String pTrainer) { trainer=pTrainer; }
    public String getCity() { return city; }
    public void setCity(String pCity) { city=pCity; }
    public String getThema() { return thema; }
    public void setThema(String pThema) { thema=pThema; }
    /**
     * convert this Seminar to a JSON string
     */
    public String toJson() { return JSON.toJSONString(this); }

    /**
     * convert this Seminar to a WikiSon string
     * @return the WikiSon representation of this Seminar
     */
    public String toWikiSon() {
      String wikison= "{{Seminar\n";
      wikison+=toWikiSon("kind",kind);
      wikison+=toWikiSon("lang",lang);
      wikison+=toWikiSon("year",year);
      wikison+=toWikiSon("month",month);
      wikison+=toWikiSon("inHouse",inHouse);
      wikison+=toWikiSon("from",from);
      wikison+=toWikiSon("to",to);
      wikison+=toWikiSon("title",title);
      wikison+=toWikiSon("contact",contact);
      wikison+=toWikiSon("customer",customer);
      wikison+=toWikiSon("documentation",documentation);
      wikison+=toWikiSon("trainer",trainer);
      wikison+=toWikiSon("city",city);
      wikison+=toWikiSon("thema",thema);
      wikison+="}}\n";
      return wikison;
    }

    /**
     * convert this Seminar to a SiDIF string
     * @return the SiDIF representation of this Seminar
     */
    public String toSiDIF() {
      String siDIF = String.format("%s isA Seminar\n",this.pageid);
      siDIF+=propertySiDIF("kind",kind,"Page");
      siDIF+=propertySiDIF("lang",lang,"Text");
      siDIF+=propertySiDIF("year",year,"Text");
      siDIF+=propertySiDIF("month",month,"Text");
      siDIF+=propertySiDIF("inHouse",inHouse,"Boolean");
      siDIF+=propertySiDIF("from",from,"Date");
      siDIF+=propertySiDIF("to",to,"Date");
      siDIF+=propertySiDIF("title",title,"Text");
      siDIF+=propertySiDIF("contact",contact,"Text");
      siDIF+=propertySiDIF("customer",customer,"Text");
      siDIF+=propertySiDIF("documentation",documentation,"Text");
      siDIF+=propertySiDIF("trainer",trainer,"Page");
      siDIF+=propertySiDIF("city",city,"Page");
      siDIF+=propertySiDIF("thema",thema,"Page");
      return siDIF;
    }
 
    /**  
     * get the pageid for this topic
     */
    public String getPageid() { return pageid; };

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

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

    /**
     * construct a Seminar from the given pageId
     * @param query - the TripleQuery to get the triples from
     * @param pageid - pageid
     */
    public Seminar(TripleQuery query,String pageid) {
      this.pageid=pageid;
      Triple kindTriple=query.selectSingle(pageid,"kind",null);
      if (kindTriple==null)
        kindTriple=query.selectSingle(pageid,"Property:Seminar_kind",null);
      if (kindTriple!=null) 
        kind=kindTriple.getObject().toString();
      Triple langTriple=query.selectSingle(pageid,"lang",null);
      if (langTriple==null)
        langTriple=query.selectSingle(pageid,"Property:Seminar_lang",null);
      if (langTriple!=null) 
        lang=langTriple.getObject().toString();
      Triple yearTriple=query.selectSingle(pageid,"year",null);
      if (yearTriple==null)
        yearTriple=query.selectSingle(pageid,"Property:Seminar_year",null);
      if (yearTriple!=null) 
        year=yearTriple.getObject().toString();
      Triple monthTriple=query.selectSingle(pageid,"month",null);
      if (monthTriple==null)
        monthTriple=query.selectSingle(pageid,"Property:Seminar_month",null);
      if (monthTriple!=null) 
        month=monthTriple.getObject().toString();
      Triple inHouseTriple=query.selectSingle(pageid,"inHouse",null);
      if (inHouseTriple==null)
        inHouseTriple=query.selectSingle(pageid,"Property:Seminar_inHouse",null);
      if (inHouseTriple!=null) 
        inHouse=inHouseTriple.getObject().toString();
      Triple fromTriple=query.selectSingle(pageid,"from",null);
      if (fromTriple==null)
        fromTriple=query.selectSingle(pageid,"Property:Seminar_from",null);
      if (fromTriple!=null) 
        from=fromTriple.getObject().toString();
      Triple toTriple=query.selectSingle(pageid,"to",null);
      if (toTriple==null)
        toTriple=query.selectSingle(pageid,"Property:Seminar_to",null);
      if (toTriple!=null) 
        to=toTriple.getObject().toString();
      Triple titleTriple=query.selectSingle(pageid,"title",null);
      if (titleTriple==null)
        titleTriple=query.selectSingle(pageid,"Property:Seminar_title",null);
      if (titleTriple!=null) 
        title=titleTriple.getObject().toString();
      Triple contactTriple=query.selectSingle(pageid,"contact",null);
      if (contactTriple==null)
        contactTriple=query.selectSingle(pageid,"Property:Seminar_contact",null);
      if (contactTriple!=null) 
        contact=contactTriple.getObject().toString();
      Triple customerTriple=query.selectSingle(pageid,"customer",null);
      if (customerTriple==null)
        customerTriple=query.selectSingle(pageid,"Property:Seminar_customer",null);
      if (customerTriple!=null) 
        customer=customerTriple.getObject().toString();
      Triple documentationTriple=query.selectSingle(pageid,"documentation",null);
      if (documentationTriple==null)
        documentationTriple=query.selectSingle(pageid,"Property:Seminar_documentation",null);
      if (documentationTriple!=null) 
        documentation=documentationTriple.getObject().toString();
      Triple trainerTriple=query.selectSingle(pageid,"trainer",null);
      if (trainerTriple==null)
        trainerTriple=query.selectSingle(pageid,"Property:Seminar_trainer",null);
      if (trainerTriple!=null) 
        trainer=trainerTriple.getObject().toString();
      Triple cityTriple=query.selectSingle(pageid,"city",null);
      if (cityTriple==null)
        cityTriple=query.selectSingle(pageid,"Property:Seminar_city",null);
      if (cityTriple!=null) 
        city=cityTriple.getObject().toString();
      Triple themaTriple=query.selectSingle(pageid,"thema",null);
      if (themaTriple==null)
        themaTriple=query.selectSingle(pageid,"Property:Seminar_thema",null);
      if (themaTriple!=null) 
        thema=themaTriple.getObject().toString();
      init(query);
    } // constructor for Seminar
    
    // >>>{user defined topic code}{Seminar}{Seminar}
    // <<<{user defined topic code}{Seminar}{Seminar}
  } // class Seminar
  /**
   * Manager for Seminar
   */
  public static class SeminarManager extends TopicBase {
 
    public String topicName="Seminar";
    public transient List<Seminar> mSeminars=new ArrayList<Seminar>();
    public transient Map<String,Seminar> mSeminarMap=new LinkedHashMap<String,Seminar>();

    /**
     * get my Seminars
     */
    public List<Seminar> getSeminars() {
      List<Seminar> result=this.mSeminars;
      return result;
    }

    /**
     *  add a new Seminar 
     */
    public Seminar add(Seminar pSeminar) {
      mSeminars.add(pSeminar);
      mSeminarMap.put(pSeminar.getPageid(),pSeminar);
      return pSeminar;
    }

    /**
     *  add a new Seminar from the given triple
     */
    public Seminar add(TripleQuery query,Triple pSeminarTriple) {
      Seminar lSeminar=new Seminar(query,pSeminarTriple);
      add(lSeminar);
      return lSeminar;
    }

    // reinitialize my mSeminar map
    public void reinit() {
      mSeminarMap.clear();
      for (Seminar lSeminar:mSeminars) {
        mSeminarMap.put(lSeminar.getPageid(),lSeminar);
      }
    }

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

    // default constructor for Seminar Manager
    public SeminarManager() {}

    // add Seminars from the given query
    public void addSeminars(TripleQuery pSeminarQuery,TripleQuery query) {
      if (pSeminarQuery!=null) {
        for (Triple lSeminarTriple:pSeminarQuery.getTriples()) {
          add(query,lSeminarTriple);
        }
      }
    }

    // construct me from the given triple Query query
    public SeminarManager(TripleQuery query) {
      // first query the SiDIF bases triplestore
      TripleQuery lSeminarQuery=query.query(null,"isA","Seminar");
      addSeminars(lSeminarQuery,query);
      // then the SMW triplestore
      lSeminarQuery=query.query(null,"Property:IsA","Seminar");
      addSeminars(lSeminarQuery,query);
      init(query);
    } // constructor for Seminar Manager
    
    // >>>{user defined topicmanager code}{Seminar}{Seminar}
    // <<<{user defined topicmanager code}{Seminar}{Seminar}
  } // class Seminar Manager
 /**
  * Traininglocation
  * A location for a training
  */
  public static class Traininglocation extends TopicBase {
  
    public String name;
    public String url;
    public String coordinate;
    public String address;
    public String city;
    public String country;

    public String getName() { return name; }
    public void setName(String pName) { name=pName; }
    public String getUrl() { return url; }
    public void setUrl(String pUrl) { url=pUrl; }
    public String getCoordinate() { return coordinate; }
    public void setCoordinate(String pCoordinate) { coordinate=pCoordinate; }
    public String getAddress() { return address; }
    public void setAddress(String pAddress) { address=pAddress; }
    public String getCity() { return city; }
    public void setCity(String pCity) { city=pCity; }
    public String getCountry() { return country; }
    public void setCountry(String pCountry) { country=pCountry; }
    /**
     * convert this Traininglocation to a JSON string
     */
    public String toJson() { return JSON.toJSONString(this); }

    /**
     * convert this Traininglocation to a WikiSon string
     * @return the WikiSon representation of this Traininglocation
     */
    public String toWikiSon() {
      String wikison= "{{Traininglocation\n";
      wikison+=toWikiSon("name",name);
      wikison+=toWikiSon("url",url);
      wikison+=toWikiSon("coordinate",coordinate);
      wikison+=toWikiSon("address",address);
      wikison+=toWikiSon("city",city);
      wikison+=toWikiSon("country",country);
      wikison+="}}\n";
      return wikison;
    }

    /**
     * convert this Traininglocation to a SiDIF string
     * @return the SiDIF representation of this Traininglocation
     */
    public String toSiDIF() {
      String siDIF = String.format("%s isA Traininglocation\n",this.pageid);
      siDIF+=propertySiDIF("name",name,"Text");
      siDIF+=propertySiDIF("url",url,"URL");
      siDIF+=propertySiDIF("coordinate",coordinate,"Geographic_coordinate");
      siDIF+=propertySiDIF("address",address,"Text");
      siDIF+=propertySiDIF("city",city,"Text");
      siDIF+=propertySiDIF("country",country,"Text");
      return siDIF;
    }
 
    /**  
     * get the pageid for this topic
     */
    public String getPageid() { return pageid; };

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

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

    /**
     * construct a Traininglocation from the given pageId
     * @param query - the TripleQuery to get the triples from
     * @param pageid - pageid
     */
    public Traininglocation(TripleQuery query,String pageid) {
      this.pageid=pageid;
      Triple nameTriple=query.selectSingle(pageid,"name",null);
      if (nameTriple==null)
        nameTriple=query.selectSingle(pageid,"Property:Traininglocation_name",null);
      if (nameTriple!=null) 
        name=nameTriple.getObject().toString();
      Triple urlTriple=query.selectSingle(pageid,"url",null);
      if (urlTriple==null)
        urlTriple=query.selectSingle(pageid,"Property:Traininglocation_url",null);
      if (urlTriple!=null) 
        url=urlTriple.getObject().toString();
      Triple coordinateTriple=query.selectSingle(pageid,"coordinate",null);
      if (coordinateTriple==null)
        coordinateTriple=query.selectSingle(pageid,"Property:Traininglocation_coordinate",null);
      if (coordinateTriple!=null) 
        coordinate=coordinateTriple.getObject().toString();
      Triple addressTriple=query.selectSingle(pageid,"address",null);
      if (addressTriple==null)
        addressTriple=query.selectSingle(pageid,"Property:Traininglocation_address",null);
      if (addressTriple!=null) 
        address=addressTriple.getObject().toString();
      Triple cityTriple=query.selectSingle(pageid,"city",null);
      if (cityTriple==null)
        cityTriple=query.selectSingle(pageid,"Property:Traininglocation_city",null);
      if (cityTriple!=null) 
        city=cityTriple.getObject().toString();
      Triple countryTriple=query.selectSingle(pageid,"country",null);
      if (countryTriple==null)
        countryTriple=query.selectSingle(pageid,"Property:Traininglocation_country",null);
      if (countryTriple!=null) 
        country=countryTriple.getObject().toString();
      init(query);
    } // constructor for Traininglocation
    
    // >>>{user defined topic code}{Traininglocation}{Traininglocation}
    // <<<{user defined topic code}{Traininglocation}{Traininglocation}
  } // class Traininglocation
  /**
   * Manager for Traininglocation
   */
  public static class TraininglocationManager extends TopicBase {
 
    public String topicName="Traininglocation";
    public transient List<Traininglocation> mTraininglocations=new ArrayList<Traininglocation>();
    public transient Map<String,Traininglocation> mTraininglocationMap=new LinkedHashMap<String,Traininglocation>();

    /**
     * get my Traininglocations
     */
    public List<Traininglocation> getTraininglocations() {
      List<Traininglocation> result=this.mTraininglocations;
      return result;
    }

    /**
     *  add a new Traininglocation 
     */
    public Traininglocation add(Traininglocation pTraininglocation) {
      mTraininglocations.add(pTraininglocation);
      mTraininglocationMap.put(pTraininglocation.getPageid(),pTraininglocation);
      return pTraininglocation;
    }

    /**
     *  add a new Traininglocation from the given triple
     */
    public Traininglocation add(TripleQuery query,Triple pTraininglocationTriple) {
      Traininglocation lTraininglocation=new Traininglocation(query,pTraininglocationTriple);
      add(lTraininglocation);
      return lTraininglocation;
    }

    // reinitialize my mTraininglocation map
    public void reinit() {
      mTraininglocationMap.clear();
      for (Traininglocation lTraininglocation:mTraininglocations) {
        mTraininglocationMap.put(lTraininglocation.getPageid(),lTraininglocation);
      }
    }

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

    // default constructor for Traininglocation Manager
    public TraininglocationManager() {}

    // add Traininglocations from the given query
    public void addTraininglocations(TripleQuery pTraininglocationQuery,TripleQuery query) {
      if (pTraininglocationQuery!=null) {
        for (Triple lTraininglocationTriple:pTraininglocationQuery.getTriples()) {
          add(query,lTraininglocationTriple);
        }
      }
    }

    // construct me from the given triple Query query
    public TraininglocationManager(TripleQuery query) {
      // first query the SiDIF bases triplestore
      TripleQuery lTraininglocationQuery=query.query(null,"isA","Traininglocation");
      addTraininglocations(lTraininglocationQuery,query);
      // then the SMW triplestore
      lTraininglocationQuery=query.query(null,"Property:IsA","Traininglocation");
      addTraininglocations(lTraininglocationQuery,query);
      init(query);
    } // constructor for Traininglocation Manager
    
    // >>>{user defined topicmanager code}{Traininglocation}{Traininglocation}
    // <<<{user defined topicmanager code}{Traininglocation}{Traininglocation}
  } // class Traininglocation Manager
 /**
  * Trainer
  * A trainer is a teacher
  */
  public static class Trainer extends TopicBase {
  
    public String name;
    public String picture;
    public String description;
    public String description_de;
    public String rank;

    public String getName() { return name; }
    public void setName(String pName) { name=pName; }
    public String getPicture() { return picture; }
    public void setPicture(String pPicture) { picture=pPicture; }
    public String getDescription() { return description; }
    public void setDescription(String pDescription) { description=pDescription; }
    public String getDescription_de() { return description_de; }
    public void setDescription_de(String pDescription_de) { description_de=pDescription_de; }
    public String getRank() { return rank; }
    public void setRank(String pRank) { rank=pRank; }
    /**
     * convert this Trainer to a JSON string
     */
    public String toJson() { return JSON.toJSONString(this); }

    /**
     * convert this Trainer to a WikiSon string
     * @return the WikiSon representation of this Trainer
     */
    public String toWikiSon() {
      String wikison= "{{Trainer\n";
      wikison+=toWikiSon("name",name);
      wikison+=toWikiSon("picture",picture);
      wikison+=toWikiSon("description",description);
      wikison+=toWikiSon("description_de",description_de);
      wikison+=toWikiSon("rank",rank);
      wikison+="}}\n";
      return wikison;
    }

    /**
     * convert this Trainer to a SiDIF string
     * @return the SiDIF representation of this Trainer
     */
    public String toSiDIF() {
      String siDIF = String.format("%s isA Trainer\n",this.pageid);
      siDIF+=propertySiDIF("name",name,"Text");
      siDIF+=propertySiDIF("picture",picture,"Page");
      siDIF+=propertySiDIF("description",description,"text");
      siDIF+=propertySiDIF("description_de",description_de,"text");
      siDIF+=propertySiDIF("rank",rank,"number");
      return siDIF;
    }
 
    /**  
     * get the pageid for this topic
     */
    public String getPageid() { return pageid; };

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

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

    /**
     * construct a Trainer from the given pageId
     * @param query - the TripleQuery to get the triples from
     * @param pageid - pageid
     */
    public Trainer(TripleQuery query,String pageid) {
      this.pageid=pageid;
      Triple nameTriple=query.selectSingle(pageid,"name",null);
      if (nameTriple==null)
        nameTriple=query.selectSingle(pageid,"Property:Trainer_name",null);
      if (nameTriple!=null) 
        name=nameTriple.getObject().toString();
      Triple pictureTriple=query.selectSingle(pageid,"picture",null);
      if (pictureTriple==null)
        pictureTriple=query.selectSingle(pageid,"Property:Trainer_picture",null);
      if (pictureTriple!=null) 
        picture=pictureTriple.getObject().toString();
      Triple descriptionTriple=query.selectSingle(pageid,"description",null);
      if (descriptionTriple==null)
        descriptionTriple=query.selectSingle(pageid,"Property:Trainer_description",null);
      if (descriptionTriple!=null) 
        description=descriptionTriple.getObject().toString();
      Triple description_deTriple=query.selectSingle(pageid,"description_de",null);
      if (description_deTriple==null)
        description_deTriple=query.selectSingle(pageid,"Property:Trainer_description_de",null);
      if (description_deTriple!=null) 
        description_de=description_deTriple.getObject().toString();
      Triple rankTriple=query.selectSingle(pageid,"rank",null);
      if (rankTriple==null)
        rankTriple=query.selectSingle(pageid,"Property:Trainer_rank",null);
      if (rankTriple!=null) 
        rank=rankTriple.getObject().toString();
      init(query);
    } // constructor for Trainer
    
    // >>>{user defined topic code}{Trainer}{Trainer}
    // <<<{user defined topic code}{Trainer}{Trainer}
  } // class Trainer
  /**
   * Manager for Trainer
   */
  public static class TrainerManager extends TopicBase {
 
    public String topicName="Trainer";
    public transient List<Trainer> mTrainers=new ArrayList<Trainer>();
    public transient Map<String,Trainer> mTrainerMap=new LinkedHashMap<String,Trainer>();

    /**
     * get my Trainers
     */
    public List<Trainer> getTrainers() {
      List<Trainer> result=this.mTrainers;
      return result;
    }

    /**
     *  add a new Trainer 
     */
    public Trainer add(Trainer pTrainer) {
      mTrainers.add(pTrainer);
      mTrainerMap.put(pTrainer.getPageid(),pTrainer);
      return pTrainer;
    }

    /**
     *  add a new Trainer from the given triple
     */
    public Trainer add(TripleQuery query,Triple pTrainerTriple) {
      Trainer lTrainer=new Trainer(query,pTrainerTriple);
      add(lTrainer);
      return lTrainer;
    }

    // reinitialize my mTrainer map
    public void reinit() {
      mTrainerMap.clear();
      for (Trainer lTrainer:mTrainers) {
        mTrainerMap.put(lTrainer.getPageid(),lTrainer);
      }
    }

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

    // default constructor for Trainer Manager
    public TrainerManager() {}

    // add Trainers from the given query
    public void addTrainers(TripleQuery pTrainerQuery,TripleQuery query) {
      if (pTrainerQuery!=null) {
        for (Triple lTrainerTriple:pTrainerQuery.getTriples()) {
          add(query,lTrainerTriple);
        }
      }
    }

    // construct me from the given triple Query query
    public TrainerManager(TripleQuery query) {
      // first query the SiDIF bases triplestore
      TripleQuery lTrainerQuery=query.query(null,"isA","Trainer");
      addTrainers(lTrainerQuery,query);
      // then the SMW triplestore
      lTrainerQuery=query.query(null,"Property:IsA","Trainer");
      addTrainers(lTrainerQuery,query);
      init(query);
    } // constructor for Trainer Manager
    
    // >>>{user defined topicmanager code}{Trainer}{Trainer}
    // <<<{user defined topicmanager code}{Trainer}{Trainer}
  } // class Trainer Manager
 /**
  * SeminarTopic
  * A SeminarTopic is the topic of one or more Seminars
  */
  public static class SeminarTopic extends TopicBase {
  
    public String name;
    public String logo;
    public String level;
    public String licensee;
    public String licenseeUrl;
    public String syllabus;
    public String syllabusPdf;

    public String getName() { return name; }
    public void setName(String pName) { name=pName; }
    public String getLogo() { return logo; }
    public void setLogo(String pLogo) { logo=pLogo; }
    public String getLevel() { return level; }
    public void setLevel(String pLevel) { level=pLevel; }
    public String getLicensee() { return licensee; }
    public void setLicensee(String pLicensee) { licensee=pLicensee; }
    public String getLicenseeUrl() { return licenseeUrl; }
    public void setLicenseeUrl(String pLicenseeUrl) { licenseeUrl=pLicenseeUrl; }
    public String getSyllabus() { return syllabus; }
    public void setSyllabus(String pSyllabus) { syllabus=pSyllabus; }
    public String getSyllabusPdf() { return syllabusPdf; }
    public void setSyllabusPdf(String pSyllabusPdf) { syllabusPdf=pSyllabusPdf; }
    /**
     * convert this SeminarTopic to a JSON string
     */
    public String toJson() { return JSON.toJSONString(this); }

    /**
     * convert this SeminarTopic to a WikiSon string
     * @return the WikiSon representation of this SeminarTopic
     */
    public String toWikiSon() {
      String wikison= "{{SeminarTopic\n";
      wikison+=toWikiSon("name",name);
      wikison+=toWikiSon("logo",logo);
      wikison+=toWikiSon("level",level);
      wikison+=toWikiSon("licensee",licensee);
      wikison+=toWikiSon("licenseeUrl",licenseeUrl);
      wikison+=toWikiSon("syllabus",syllabus);
      wikison+=toWikiSon("syllabusPdf",syllabusPdf);
      wikison+="}}\n";
      return wikison;
    }

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

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

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

    /**
     * construct a SeminarTopic from the given pageId
     * @param query - the TripleQuery to get the triples from
     * @param pageid - pageid
     */
    public SeminarTopic(TripleQuery query,String pageid) {
      this.pageid=pageid;
      Triple nameTriple=query.selectSingle(pageid,"name",null);
      if (nameTriple==null)
        nameTriple=query.selectSingle(pageid,"Property:SeminarTopic_name",null);
      if (nameTriple!=null) 
        name=nameTriple.getObject().toString();
      Triple logoTriple=query.selectSingle(pageid,"logo",null);
      if (logoTriple==null)
        logoTriple=query.selectSingle(pageid,"Property:SeminarTopic_logo",null);
      if (logoTriple!=null) 
        logo=logoTriple.getObject().toString();
      Triple levelTriple=query.selectSingle(pageid,"level",null);
      if (levelTriple==null)
        levelTriple=query.selectSingle(pageid,"Property:SeminarTopic_level",null);
      if (levelTriple!=null) 
        level=levelTriple.getObject().toString();
      Triple licenseeTriple=query.selectSingle(pageid,"licensee",null);
      if (licenseeTriple==null)
        licenseeTriple=query.selectSingle(pageid,"Property:SeminarTopic_licensee",null);
      if (licenseeTriple!=null) 
        licensee=licenseeTriple.getObject().toString();
      Triple licenseeUrlTriple=query.selectSingle(pageid,"licenseeUrl",null);
      if (licenseeUrlTriple==null)
        licenseeUrlTriple=query.selectSingle(pageid,"Property:SeminarTopic_licenseeUrl",null);
      if (licenseeUrlTriple!=null) 
        licenseeUrl=licenseeUrlTriple.getObject().toString();
      Triple syllabusTriple=query.selectSingle(pageid,"syllabus",null);
      if (syllabusTriple==null)
        syllabusTriple=query.selectSingle(pageid,"Property:SeminarTopic_syllabus",null);
      if (syllabusTriple!=null) 
        syllabus=syllabusTriple.getObject().toString();
      Triple syllabusPdfTriple=query.selectSingle(pageid,"syllabusPdf",null);
      if (syllabusPdfTriple==null)
        syllabusPdfTriple=query.selectSingle(pageid,"Property:SeminarTopic_syllabusPdf",null);
      if (syllabusPdfTriple!=null) 
        syllabusPdf=syllabusPdfTriple.getObject().toString();
      init(query);
    } // constructor for SeminarTopic
    
    // >>>{user defined topic code}{SeminarTopic}{SeminarTopic}
    // <<<{user defined topic code}{SeminarTopic}{SeminarTopic}
  } // class SeminarTopic
  /**
   * Manager for SeminarTopic
   */
  public static class SeminarTopicManager extends TopicBase {
 
    public String topicName="SeminarTopic";
    public transient List<SeminarTopic> mSeminarTopics=new ArrayList<SeminarTopic>();
    public transient Map<String,SeminarTopic> mSeminarTopicMap=new LinkedHashMap<String,SeminarTopic>();

    /**
     * get my SeminarTopics
     */
    public List<SeminarTopic> getSeminarTopics() {
      List<SeminarTopic> result=this.mSeminarTopics;
      return result;
    }

    /**
     *  add a new SeminarTopic 
     */
    public SeminarTopic add(SeminarTopic pSeminarTopic) {
      mSeminarTopics.add(pSeminarTopic);
      mSeminarTopicMap.put(pSeminarTopic.getPageid(),pSeminarTopic);
      return pSeminarTopic;
    }

    /**
     *  add a new SeminarTopic from the given triple
     */
    public SeminarTopic add(TripleQuery query,Triple pSeminarTopicTriple) {
      SeminarTopic lSeminarTopic=new SeminarTopic(query,pSeminarTopicTriple);
      add(lSeminarTopic);
      return lSeminarTopic;
    }

    // reinitialize my mSeminarTopic map
    public void reinit() {
      mSeminarTopicMap.clear();
      for (SeminarTopic lSeminarTopic:mSeminarTopics) {
        mSeminarTopicMap.put(lSeminarTopic.getPageid(),lSeminarTopic);
      }
    }

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

    // default constructor for SeminarTopic Manager
    public SeminarTopicManager() {}

    // add SeminarTopics from the given query
    public void addSeminarTopics(TripleQuery pSeminarTopicQuery,TripleQuery query) {
      if (pSeminarTopicQuery!=null) {
        for (Triple lSeminarTopicTriple:pSeminarTopicQuery.getTriples()) {
          add(query,lSeminarTopicTriple);
        }
      }
    }

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

}
Showing below 0 pages.

Retrieved from "https://wiki.bitplan.com/index.php?title=Concept:SeminarTopic/Java&oldid=4415#smw-result"