con.add(rfUri, repoURIs.get(Uris.KM_IS_PART_OF_MAPPING_URI), mappingRes);
con.add(mappingRes, repoURIs.get(Uris.KM_HAS_OBJECT_MAP_URI), rfUri);
// Add the RefObjectMap as the object map of current POMap
con.add(pomUri, repoURIs.get(Uris.RR_OBJECTMAP_URI), rfUri);
} else {
TemplateTermSet objTermSet = pom.getObject().getTemplate();
TemplateTermSet rdfLiteralTypeTermSet = pom.getObject().getRdfLiteralType();
if (objTermSet.isSingleColumnTerm()) {
BNode cnBnode = f.createBNode();
Value cnVal = f.createLiteral(objTermSet.
getColumnNameR2RMLRepresentation(factory, columnNameFormatter));
con.add(cnBnode, repoURIs.get(Uris.RR_COLUMN_URI), cnVal);
con.add(cnBnode, RDF.TYPE, repoURIs.get(Uris.RR_OBJECTMAP_CLASS_URI));
if (rdfLiteralTypeTermSet != null && rdfLiteralTypeTermSet.isSingleUriString()) {
String rdfLiteralTypeString = rdfLiteralTypeTermSet.
getR2rmlTemplateString(factory);
if(!rdfLiteralTypeString.isEmpty())
{
Value cnRdfLiteralType = f.createLiteral(rdfLiteralTypeString);
con.add(cnBnode, repoURIs.get(Uris.RR_DATATYPE_URI), cnRdfLiteralType);
}
}
con.add(cnBnode, repoURIs.get(Uris.KM_IS_PART_OF_MAPPING_URI), mappingRes);
con.add(mappingRes, repoURIs.get(Uris.KM_HAS_OBJECT_MAP_URI), cnBnode);
// Add the link b/w blank node and object map
con.add(pomUri, repoURIs.get(Uris.RR_OBJECTMAP_URI), cnBnode);
}
else if(!objTermSet.isEmpty())
{
BNode cnBnode = f.createBNode();
// Print out the template for anything that isn't a blank node
boolean isUri = false;
for (TemplateTerm term:objTermSet.getAllTerms()) {
if (term instanceof StringTemplateTerm) {
if(((StringTemplateTerm)term).hasFullUri())
isUri = true;
}
}
String value = objTermSet
.getR2rmlTemplateString(factory, columnNameFormatter);
Value templVal;
if(isUri) {
try {
templVal = f.createURI(value);
}catch(IllegalArgumentException e) {
String baseURI = worksheet.getMetadataContainer().getWorksheetProperties().getPropertyValue(
Property.baseURI);
templVal = f.createURI(baseURI + value);
}
} else {
templVal = f.createLiteral(value);
}
con.add(cnBnode, repoURIs.get(Uris.RR_CONSTANT), templVal);
if (rdfLiteralTypeTermSet != null && rdfLiteralTypeTermSet.isSingleUriString()) {
String rdfLiteralTypeString = rdfLiteralTypeTermSet.
getR2rmlTemplateString(factory);
if(!rdfLiteralTypeString.isEmpty())
{
Value cnRdfLiteralType = f.createLiteral(rdfLiteralTypeString);
con.add(cnBnode, repoURIs.get(Uris.RR_DATATYPE_URI), cnRdfLiteralType);