Concept:Seminar/Java: Difference between revisions
Jump to navigation
Jump to search
(created by WikiTask 2017-09-14T13:05:45Z) |
m (created by WikiTask 2017-11-05T16:11:28Z) |
||
| Line 37: | Line 37: | ||
/** | /** | ||
* get the | * get the SiDIF representation of the given property | ||
* | * | ||
* @param name | * @param name - the name of the property | ||
* @param value | * @param value - the value of the property | ||
* @return | * @param type - the type of the property | ||
* @return - the SiDIF Sting representation of the property | |||
*/ | */ | ||
public static String propertySiDIF(String name, String value, String type) { | public static String propertySiDIF(String name, String value, String type) { | ||
// default is | // default is a comment line which can be filled by uncommenting | ||
String result = ""; | String result = String.format("# is is %s of it\n",name);; | ||
// if the value is not empty | // if the value is not empty | ||
if ((value != null) && (!("".equals(value.trim())))) { | if ((value != null) && (!("".equals(value.trim())))) { | ||
| Line 56: | Line 57: | ||
// create a SIDIF Property line like | // create a SIDIF Property line like | ||
// "John" is lastname of it | // "John" is lastname of it | ||
// convert double quotes to single quotes - FIXME - should we escape instead? | |||
value=value.replace("\"","'"); | |||
result = String.format("%s%s%s is %s of it\n",quote,value,quote,name); | |||
} | } | ||
// return the SiDIF property line | // return the SiDIF property line | ||
| Line 95: | Line 98: | ||
} | } | ||
} // TopicBase | } // TopicBase | ||
/** | /** | ||
* Seminar | * Seminar | ||
| Line 1,436: | Line 116: | ||
public String contact; | public String contact; | ||
public String customer; | public String customer; | ||
public String documentation; | |||
public String getKind() { return kind; } | public String getKind() { return kind; } | ||
| Line 1,461: | Line 142: | ||
public String getCustomer() { return customer; } | public String getCustomer() { return customer; } | ||
public void setCustomer(String pCustomer) { customer=pCustomer; } | public void setCustomer(String pCustomer) { customer=pCustomer; } | ||
public String getDocumentation() { return documentation; } | |||
public void setDocumentation(String pDocumentation) { documentation=pDocumentation; } | |||
/** | /** | ||
* convert this Seminar to a JSON string | * convert this Seminar to a JSON string | ||
| Line 1,468: | Line 151: | ||
/** | /** | ||
* convert this Seminar to a WikiSon string | * convert this Seminar to a WikiSon string | ||
* @return the WikiSon representation of this Seminar | |||
*/ | */ | ||
public String toWikiSon() { | public String toWikiSon() { | ||
| Line 1,483: | Line 167: | ||
wikison+=toWikiSon("contact",contact); | wikison+=toWikiSon("contact",contact); | ||
wikison+=toWikiSon("customer",customer); | wikison+=toWikiSon("customer",customer); | ||
wikison+=toWikiSon("documentation",documentation); | |||
wikison+="}}\n"; | wikison+="}}\n"; | ||
return wikison; | 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("thema",thema,"Text"); | |||
siDIF+=propertySiDIF("year",year,"Text"); | |||
siDIF+=propertySiDIF("month",month,"Text"); | |||
siDIF+=propertySiDIF("inHouse",inHouse,"Boolean"); | |||
siDIF+=propertySiDIF("city",city,"Page"); | |||
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"); | |||
return siDIF; | |||
} | } | ||
| Line 1,573: | Line 280: | ||
if (customerTriple!=null) | if (customerTriple!=null) | ||
customer=customerTriple.getObject().toString(); | 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(); | |||
init(query); | init(query); | ||
} // constructor for Seminar | } // constructor for Seminar | ||
| Line 1,659: | Line 371: | ||
} // class Seminar Manager | } // class Seminar Manager | ||
/** | /** | ||
* | * Traininglocation | ||
* A | * A location for a training | ||
*/ | */ | ||
public static class | public static class Traininglocation extends TopicBase { | ||
public String | public String name; | ||
public String | public String lat; | ||
public String | public String url; | ||
public String | public String lon; | ||
public String | public String getName() { return name; } | ||
public void | public void setName(String pName) { name=pName; } | ||
public String | public String getLat() { return lat; } | ||
public void | public void setLat(String pLat) { lat=pLat; } | ||
public String | public String getUrl() { return url; } | ||
public void | public void setUrl(String pUrl) { url=pUrl; } | ||
public String | public String getLon() { return lon; } | ||
public void | public void setLon(String pLon) { lon=pLon; } | ||
/** | /** | ||
* convert this | * convert this Traininglocation to a JSON string | ||
*/ | */ | ||
public String toJson() { return JSON.toJSONString(this); } | public String toJson() { return JSON.toJSONString(this); } | ||
/** | /** | ||
* convert this | * convert this Traininglocation to a WikiSon string | ||
* @return the WikiSon representation of this Traininglocation | |||
*/ | */ | ||
public String toWikiSon() { | public String toWikiSon() { | ||
String wikison= "{{ | String wikison= "{{Traininglocation\n"; | ||
wikison+=toWikiSon(" | wikison+=toWikiSon("name",name); | ||
wikison+=toWikiSon(" | wikison+=toWikiSon("lat",lat); | ||
wikison+=toWikiSon(" | wikison+=toWikiSon("url",url); | ||
wikison+=toWikiSon(" | wikison+=toWikiSon("lon",lon); | ||
wikison+="}}\n"; | wikison+="}}\n"; | ||
return wikison; | 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("lat",lat,"Text"); | |||
siDIF+=propertySiDIF("url",url,"URL"); | |||
siDIF+=propertySiDIF("lon",lon,"Text"); | |||
return siDIF; | |||
} | } | ||
| Line 1,733: | Line 427: | ||
/** | /** | ||
* default constructor for | * default constructor for Traininglocation | ||
*/ | */ | ||
public | public Traininglocation() {} | ||
/** | /** | ||
* construct a | * construct a Traininglocation from the given Triple | ||
* @param query - the TripleQuery to get the triples from | * @param query - the TripleQuery to get the triples from | ||
* @param | * @param pTraininglocationTriple - the triple to construct me from | ||
*/ | */ | ||
public | public Traininglocation(TripleQuery query,Triple pTraininglocationTriple) { | ||
this(query, | this(query,pTraininglocationTriple.getSubject().toString()); | ||
} // constructor | } // constructor | ||
/** | /** | ||
* construct a | * construct a Traininglocation from the given pageId | ||
* @param query - the TripleQuery to get the triples from | * @param query - the TripleQuery to get the triples from | ||
* @param pageid - pageid | * @param pageid - pageid | ||
*/ | */ | ||
public | public Traininglocation(TripleQuery query,String pageid) { | ||
this.pageid=pageid; | this.pageid=pageid; | ||
Triple | Triple nameTriple=query.selectSingle(pageid,"name",null); | ||
if ( | if (nameTriple==null) | ||
nameTriple=query.selectSingle(pageid,"Property:Traininglocation_name",null); | |||
if ( | if (nameTriple!=null) | ||
name=nameTriple.getObject().toString(); | |||
Triple | Triple latTriple=query.selectSingle(pageid,"lat",null); | ||
if ( | if (latTriple==null) | ||
latTriple=query.selectSingle(pageid,"Property:Traininglocation_lat",null); | |||
if ( | if (latTriple!=null) | ||
lat=latTriple.getObject().toString(); | |||
Triple | Triple urlTriple=query.selectSingle(pageid,"url",null); | ||
if ( | if (urlTriple==null) | ||
urlTriple=query.selectSingle(pageid,"Property:Traininglocation_url",null); | |||
if ( | if (urlTriple!=null) | ||
url=urlTriple.getObject().toString(); | |||
Triple | Triple lonTriple=query.selectSingle(pageid,"lon",null); | ||
if ( | if (lonTriple==null) | ||
lonTriple=query.selectSingle(pageid,"Property:Traininglocation_lon",null); | |||
if ( | if (lonTriple!=null) | ||
lon=lonTriple.getObject().toString(); | |||
init(query); | |||
} // constructor for Traininglocation | |||
// >>>{user defined topic code}{Traininglocation}{Traininglocation} | |||
// <<<{user defined topic code}{Traininglocation}{Traininglocation} | |||
} // class Traininglocation | |||
/** | |||
* Manager for Traininglocation | |||
if ( | */ | ||
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 | |||
Triple | */ | ||
if ( | public Traininglocation add(Traininglocation pTraininglocation) { | ||
mTraininglocations.add(pTraininglocation); | |||
if ( | mTraininglocationMap.put(pTraininglocation.getPageid(),pTraininglocation); | ||
return pTraininglocation; | |||
Triple | } | ||
if ( | |||
/** | |||
if ( | * add a new Traininglocation from the given triple | ||
*/ | |||
Triple | public Traininglocation add(TripleQuery query,Triple pTraininglocationTriple) { | ||
if ( | Traininglocation lTraininglocation=new Traininglocation(query,pTraininglocationTriple); | ||
add(lTraininglocation); | |||
if ( | 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 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; } | |||
/** | |||
* 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+="}}\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"); | |||
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(); | |||
init(query); | init(query); | ||
} // constructor for | } // constructor for Trainer | ||
// >>>{user defined topic code}{ | // >>>{user defined topic code}{Trainer}{Trainer} | ||
// <<<{user defined topic code}{ | // <<<{user defined topic code}{Trainer}{Trainer} | ||
} // class | } // class Trainer | ||
/** | /** | ||
* Manager for | * Manager for Trainer | ||
*/ | */ | ||
public static class | public static class TrainerManager extends TopicBase { | ||
public String topicName=" | public String topicName="Trainer"; | ||
public transient List< | public transient List<Trainer> mTrainers=new ArrayList<Trainer>(); | ||
public transient Map<String, | public transient Map<String,Trainer> mTrainerMap=new LinkedHashMap<String,Trainer>(); | ||
/** | /** | ||
* get my | * get my Trainers | ||
*/ | */ | ||
public List< | public List<Trainer> getTrainers() { | ||
List< | List<Trainer> result=this.mTrainers; | ||
return result; | return result; | ||
} | } | ||
/** | /** | ||
* add a new | * add a new Trainer | ||
*/ | */ | ||
public | public Trainer add(Trainer pTrainer) { | ||
mTrainers.add(pTrainer); | |||
mTrainerMap.put(pTrainer.getPageid(),pTrainer); | |||
return | return pTrainer; | ||
} | } | ||
/** | /** | ||
* add a new | * add a new Trainer from the given triple | ||
*/ | */ | ||
public | public Trainer add(TripleQuery query,Triple pTrainerTriple) { | ||
Trainer lTrainer=new Trainer(query,pTrainerTriple); | |||
add( | add(lTrainer); | ||
return | return lTrainer; | ||
} | } | ||
// reinitialize my | // reinitialize my mTrainer map | ||
public void reinit() { | public void reinit() { | ||
mTrainerMap.clear(); | |||
for ( | for (Trainer lTrainer:mTrainers) { | ||
mTrainerMap.put(lTrainer.getPageid(),lTrainer); | |||
} | } | ||
} | } | ||
| Line 1,866: | Line 692: | ||
// get a new manager from the given json string | // get a new manager from the given json string | ||
public static | public static TrainerManager fromJson(String json) { | ||
TrainerManager result=JSON.parseObject(json, TrainerManager.class); | |||
result.reinit(); | result.reinit(); | ||
return result; | return result; | ||
} | } | ||
// default constructor for | // default constructor for Trainer Manager | ||
public | public TrainerManager() {} | ||
// add | // add Trainers from the given query | ||
public void | public void addTrainers(TripleQuery pTrainerQuery,TripleQuery query) { | ||
if ( | if (pTrainerQuery!=null) { | ||
for (Triple | for (Triple lTrainerTriple:pTrainerQuery.getTriples()) { | ||
add(query, | add(query,lTrainerTriple); | ||
} | } | ||
} | } | ||
| Line 1,885: | Line 711: | ||
// construct me from the given triple Query query | // construct me from the given triple Query query | ||
public | public TrainerManager(TripleQuery query) { | ||
// first query the SiDIF bases triplestore | // first query the SiDIF bases triplestore | ||
TripleQuery | TripleQuery lTrainerQuery=query.query(null,"isA","Trainer"); | ||
addTrainers(lTrainerQuery,query); | |||
// then the SMW triplestore | // then the SMW triplestore | ||
lTrainerQuery=query.query(null,"Property:IsA","Trainer"); | |||
addTrainers(lTrainerQuery,query); | |||
init(query); | init(query); | ||
} // constructor for | } // constructor for Trainer Manager | ||
// >>>{user defined topicmanager code}{ | // >>>{user defined topicmanager code}{Trainer}{Trainer} | ||
// <<<{user defined topicmanager code}{ | // <<<{user defined topicmanager code}{Trainer}{Trainer} | ||
} // class | } // class Trainer Manager | ||
} | } | ||
</source> | |||
Revision as of 16:11, 5 November 2017
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 thema;
public String year;
public String month;
public String inHouse;
public String city;
public String from;
public String to;
public String title;
public String contact;
public String customer;
public String documentation;
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 getThema() { return thema; }
public void setThema(String pThema) { thema=pThema; }
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 getCity() { return city; }
public void setCity(String pCity) { city=pCity; }
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; }
/**
* 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("thema",thema);
wikison+=toWikiSon("year",year);
wikison+=toWikiSon("month",month);
wikison+=toWikiSon("inHouse",inHouse);
wikison+=toWikiSon("city",city);
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+="}}\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("thema",thema,"Text");
siDIF+=propertySiDIF("year",year,"Text");
siDIF+=propertySiDIF("month",month,"Text");
siDIF+=propertySiDIF("inHouse",inHouse,"Boolean");
siDIF+=propertySiDIF("city",city,"Page");
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");
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 themaTriple=query.selectSingle(pageid,"thema",null);
if (themaTriple==null)
themaTriple=query.selectSingle(pageid,"Property:Seminar_thema",null);
if (themaTriple!=null)
thema=themaTriple.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 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 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();
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 lat;
public String url;
public String lon;
public String getName() { return name; }
public void setName(String pName) { name=pName; }
public String getLat() { return lat; }
public void setLat(String pLat) { lat=pLat; }
public String getUrl() { return url; }
public void setUrl(String pUrl) { url=pUrl; }
public String getLon() { return lon; }
public void setLon(String pLon) { lon=pLon; }
/**
* 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("lat",lat);
wikison+=toWikiSon("url",url);
wikison+=toWikiSon("lon",lon);
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("lat",lat,"Text");
siDIF+=propertySiDIF("url",url,"URL");
siDIF+=propertySiDIF("lon",lon,"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 latTriple=query.selectSingle(pageid,"lat",null);
if (latTriple==null)
latTriple=query.selectSingle(pageid,"Property:Traininglocation_lat",null);
if (latTriple!=null)
lat=latTriple.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 lonTriple=query.selectSingle(pageid,"lon",null);
if (lonTriple==null)
lonTriple=query.selectSingle(pageid,"Property:Traininglocation_lon",null);
if (lonTriple!=null)
lon=lonTriple.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 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; }
/**
* 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+="}}\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");
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();
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
}