* Transforms a site to a Representation that can be serialised
* @param context
* @return
*/
private Representation site2Representation(String id){
RdfValueFactory valueFactory = RdfValueFactory.getInstance();
RdfRepresentation rep = valueFactory.createRepresentation(id);
String namespace = NamespaceEnum.entityhub.getNamespace();
rep.add(namespace+"localMode", site.supportsLocalMode());
rep.add(namespace+"supportsSearch", site.supportsSearch());
SiteConfiguration config = site.getConfiguration();
rep.add("http://www.w3.org/2000/01/rdf-schema#label", config.getName());
rep.add("http://www.w3.org/1999/02/22-rdf-syntax-ns#type", valueFactory.createReference(namespace+"ReferencedSite"));
if(config.getDescription() != null){
rep.add("http://www.w3.org/2000/01/rdf-schema#description", config.getDescription());
}
if(config.getAttribution() != null){
rep.add("http://creativecommons.org/ns#attributionName", config.getAttribution());
}
if(config.getAttributionUrl() != null){
rep.add("http://creativecommons.org/ns#attributionURL", config.getAttributionUrl());
}
//add the licenses
if(config.getLicenses() != null){
int count = 0;
for(License license : config.getLicenses()){
String licenseUrl;
if(license.getUrl() != null){
licenseUrl = license.getUrl();
} else {
licenseUrl = id+(!id.endsWith("/")?"/":"")+
LICENSE_PATH+'/'+LICENSE_NAME+(count>0?count:"");
count++;
}
//if defined add the name to dc:license
if(license.getName() != null){
rep.add("http://purl.org/dc/terms/license", licenseUrl);
}
//link to the license via cc:license
rep.add("http://creativecommons.org/ns#license", licenseUrl);
}
}
if(config.getEntityPrefixes() != null){
for(String prefix : config.getEntityPrefixes()){
rep.add(namespace+"entityPrefix", prefix);
}
} else { //all entities are allowed/processed
rep.add(namespace+"entityPrefix", "*");
}
if(config instanceof ReferencedSiteConfiguration){
ReferencedSiteConfiguration refConfig = (ReferencedSiteConfiguration)config;
if(refConfig.getCacheStrategy() != null){
rep.add(namespace+"cacheStrategy", valueFactory.createReference(namespace+"cacheStrategy-"+refConfig.getCacheStrategy().name()));
}
//add the accessUri and queryUri
if(refConfig.getAccessUri() != null){
rep.add(namespace+"accessUri", valueFactory.createReference(refConfig.getAccessUri()));
}
if(refConfig.getQueryUri() != null){
rep.add(namespace+"queryUri", valueFactory.createReference(refConfig.getQueryUri()));
}
}
return rep;
}