Java Code Examples for com.hp.hpl.jena.vocabulary.RDFS

The following examples show how to use com.hp.hpl.jena.vocabulary.RDFS. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may want to check out the right sidebar which shows the related API usage.
Example 1
Source Project: GeoTriples   Source File: GeneralMappingStyle.java    License: Apache License 2.0 6 votes vote down vote up
public GeneralMappingStyle(GeneralConnection connection, String baseIRI, String fileName) {
	this.baseIRI = baseIRI;
	this.fileName = fileName;
	if (this.baseIRI.endsWith("/")) {
		this.baseIRI = this.baseIRI.substring(0, this.baseIRI.length()-1);
	}
	this.vocabBaseIRI = this.baseIRI + "ontology#";
	this.geoBaseIRI = this.baseIRI;
	//this.geoBaseIRI = this.baseIRI + "/Geometry";
	if (fileName == null) {
		this.entityBaseIRI = this.baseIRI + "/Feature";
	}
	else {
		this.entityBaseIRI = this.baseIRI + "/" + fileName.substring(0, fileName.lastIndexOf('.'));
	}
	model.setNsPrefix("rdf", RDF.getURI());
	model.setNsPrefix("rdfs", RDFS.getURI());
	model.setNsPrefix("xsd", XSD.getURI());
	model.setNsPrefix("ogc", "http://www.opengis.net/ont/geosparql#");
	model.setNsPrefix("geof", "http://www.opengis.net/def/function/geosparql/");
	model.setNsPrefix("vocab", vocabBaseIRI);
	//model.setNsPrefix("tablename", vocabBaseIRI);
	generator = new GeneralMappingGenerator(this, connection);
}
 
Example 2
Source Project: GeoTriples   Source File: ClassMapServlet.java    License: Apache License 2.0 6 votes vote down vote up
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
	D2RServer server = D2RServer.fromServletContext(getServletContext());
	server.checkMappingFileChanged();
	if (request.getPathInfo() == null) {
		new ModelResponse(classMapListModel(), request, response).serve();
		return;
	}
	String classMapName = request.getPathInfo().substring(1);
	Model resourceList = server.getMapping().getResourceCollection(classMapName).getInventoryModel();
	if (resourceList == null) {
		response.sendError(404, "Sorry, class map '" + classMapName + "' not found.");
		return;
	}
   	Resource classMap = resourceList.getResource(server.baseURI() + "all/" + classMapName);
   	Resource directory = resourceList.createResource(server.baseURI() + "all");
   	classMap.addProperty(RDFS.seeAlso, directory);
   	classMap.addProperty(RDFS.label, "List of all instances: " + classMapName);
   	directory.addProperty(RDFS.label, "D2R Server contents");
   	server.addDocumentMetadata(resourceList, classMap);
	new ModelResponse(resourceList, request, response).serve();
}
 
Example 3
Source Project: GeoTriples   Source File: D2RQMappingStyle.java    License: Apache License 2.0 6 votes vote down vote up
public D2RQMappingStyle(SQLConnection connection, String baseIRI, String fileName) {
	this.baseIRI = baseIRI;
	if (this.baseIRI.endsWith("/")) {
		this.baseIRI = this.baseIRI.substring(0, this.baseIRI.length()-1);
	}
	this.vocabBaseIRI = this.baseIRI + "ontology#";
	this.geoBaseIRI = this.baseIRI;
	this.entityBaseIRI = this.baseIRI;
	model.setNsPrefix("rdf", RDF.getURI());
	model.setNsPrefix("rdfs", RDFS.getURI());
	model.setNsPrefix("xsd", XSD.getURI());
	model.setNsPrefix("ogc", "http://www.opengis.net/ont/geosparql#");
	model.setNsPrefix("geof", "http://www.opengis.net/def/function/geosparql/");
	model.setNsPrefix("vocab", vocabBaseIRI);
	generator = new MappingGenerator(this, connection);
	generator.setGenerateLabelBridges(false);
	generator.setHandleLinkTables(true);
	generator.setGenerateDefinitionLabels(false);
	generator.setServeVocabulary(true);
	generator.setSkipForeignKeyTargetColumns(true);
	generator.setUseUniqueKeysAsEntityID(true);
}
 
Example 4
Source Project: semanticMDR   Source File: ConceptImpl.java    License: GNU General Public License v3.0 6 votes vote down vote up
@Override
public void setParentConcept(ObjectClass parent) {
	if (parent != null) {
		this.addProperty(RDFS.subClassOf, parent.asMDRResource());
	} else {
		ExtendedIterator<OntClass> l = this.listSuperClasses();
		OntClass found = null;
		while (l.hasNext()) {
			OntClass ontClass = l.next();
			if (ontClass.hasSuperClass(mdrDatabase.getVocabulary().Concept)) {
				found = ontClass;
			}
		}
		if (found != null) {
			this.removeProperty(RDFS.subClassOf, found);
		}
	}
}
 
Example 5
Source Project: EventCoreference   Source File: SemTime.java    License: Apache License 2.0 6 votes vote down vote up
public void addToJenaModelDocTimeInterval(Model model) {
    if (this.getPhraseCounts().size() > 0) {
        OwlTime owlTime = new OwlTime();
        owlTime.parsePublicationDate(getPhrase());
        owlTime.addToJenaModelOwlTimeInstant(model);

        Resource resource = model.createResource(this.getURI());
        for (int i = 0; i < this.getPhraseCounts().size(); i++) {
            PhraseCount phraseCount = this.getPhraseCounts().get(i);
            if (!phraseCount.getPhrase().isEmpty()) {
                resource.addProperty(RDFS.label, model.createLiteral(phraseCount.getPhrase()));
            }
        }

        resource.addProperty(RDF.type, Sem.Time);
        Resource interval = model.createResource(ResourcesUri.owltime + "Interval");
        resource.addProperty(RDF.type, interval);

        Resource value = model.createResource(owlTime.getDateStringURI());
        Property property = model.createProperty(ResourcesUri.owltime + "inDateTime");
        resource.addProperty(property, value);
    }
}
 
Example 6
Source Project: GeoTriples   Source File: GeneralResourceCollection.java    License: Apache License 2.0 5 votes vote down vote up
private Collection<GeneralTripleRelation> filterTripleRelations(Collection<GeneralTripleRelation> entityDescription) {
	List<GeneralTripleRelation> result = new ArrayList<GeneralTripleRelation>();
	for (GeneralTripleRelation triples: entityDescription) {
		triples = triples.orderBy(TripleRelation.SUBJECT, true);
		if (triples.selectTriple(new Triple(Node.ANY, RDF.Nodes.type, Node.ANY)) != null) {
			result.add(triples);
		}
		// TODO: The list of label properties is redundantly specified in PageServlet
		if (triples.selectTriple(new Triple(Node.ANY, RDFS.label.asNode(), Node.ANY)) != null) {
			result.add(triples);
		} else if (triples.selectTriple(new Triple(Node.ANY, SKOS.prefLabel.asNode(), Node.ANY)) != null) {
			result.add(triples);
		} else if (triples.selectTriple(new Triple(Node.ANY, DC.title.asNode(), Node.ANY)) != null) {
			result.add(triples);					
		} else if (triples.selectTriple(new Triple(Node.ANY, DCTerms.title.asNode(), Node.ANY)) != null) {
			result.add(triples);					
		} else if (triples.selectTriple(new Triple(Node.ANY, FOAF.name.asNode(), Node.ANY)) != null) {
			result.add(triples);					
		}
	}
	if (result.isEmpty()) {
		result.add(new GeneralTripleRelation(connection, entityTable, 
				entityMaker, 
				new FixedNodeMaker(RDF.type.asNode()), 
				new FixedNodeMaker(RDFS.Resource.asNode())));
	}
	return result;
}
 
Example 7
Source Project: GeoTriples   Source File: John_BaseXMLWriter.java    License: Apache License 2.0 5 votes vote down vote up
void setupMaps() {
	nameSpaces.set11(RDF.getURI(), "rdf");
	nameSpaces.set11(RDFS.getURI(), "rdfs");
	nameSpaces.set11(DC.getURI(), "dc");
	nameSpaces.set11(RSS.getURI(), "rss");
	nameSpaces.set11("http://www.daml.org/2001/03/daml+oil.daml#", "daml");
	nameSpaces.set11(VCARD.getURI(), "vcard");
	nameSpaces.set11("http://www.w3.org/2002/07/owl#", "owl");
}
 
Example 8
Source Project: GeoTriples   Source File: PageServlet.java    License: Apache License 2.0 5 votes vote down vote up
public static Statement getBestLabel(Resource resource) {
	Statement label = resource.getProperty(RDFS.label);
	if (label == null)
		label = resource.getProperty(SKOS.prefLabel);
	if (label == null)
		label = resource.getProperty(DC.title);
	if (label == null)
		label = resource.getProperty(DCTerms.title);
	if (label == null)
		label = resource.getProperty(FOAF.name);
	return label;
}
 
Example 9
Source Project: GeoTriples   Source File: ClassMapServlet.java    License: Apache License 2.0 5 votes vote down vote up
private Model classMapListModel() {
	D2RServer server = D2RServer.fromServletContext(getServletContext());
	Model result = ModelFactory.createDefaultModel();
	Resource list = result.createResource(server.baseURI() + "all");
	list.addProperty(RDFS.label, "D2R Server contents");
	for (String name: server.getMapping().getResourceCollectionNames()) {
		Resource instances = result.createResource(server.baseURI() + "all/" + name);
		list.addProperty(RDFS.seeAlso, instances);
		instances.addProperty(RDFS.label, "List of all instances: " + name);
	}
	server.addDocumentMetadata(result, list);
	return result;
}
 
Example 10
Source Project: GeoTriples   Source File: Mapping.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Helper method to add definitions from a ResourceMap to its underlying resource
 * @param map
 * @param targetResource
 */
private void addDefinitions(ResourceMap map, Resource targetResource) {
	/* Infer rdfs:Class or rdf:Property type */
	Statement s = vocabularyModel.createStatement(targetResource, RDF.type, map instanceof ClassMap ? RDFS.Class : RDF.Property);
	if (!this.vocabularyModel.contains(s))
		this.vocabularyModel.add(s);

	/* Apply labels */
	for (Literal propertyLabel: map.getDefinitionLabels()) {
		s = vocabularyModel.createStatement(targetResource, RDFS.label, propertyLabel);
		if (!this.vocabularyModel.contains(s))
			this.vocabularyModel.add(s);
	}

	/* Apply comments */
	for (Literal propertyComment: map.getDefinitionComments()) {
		s = vocabularyModel.createStatement(targetResource, RDFS.comment, propertyComment);
		if (!this.vocabularyModel.contains(s))
			this.vocabularyModel.add(s);
	}

	/* Apply additional properties */
	for (Resource additionalProperty: map.getAdditionalDefinitionProperties()) {
		s = vocabularyModel.createStatement(targetResource, 
					(Property)(additionalProperty.getProperty(D2RQ.propertyName).getResource().as(Property.class)),
					additionalProperty.getProperty(D2RQ.propertyValue).getObject());
		if (!this.vocabularyModel.contains(s))
			this.vocabularyModel.add(s);				
	}
}
 
Example 11
Source Project: GeoTriples   Source File: ResourceCollection.java    License: Apache License 2.0 5 votes vote down vote up
private Collection<TripleRelation> filterTripleRelations(Collection<TripleRelation> entityDescription) {
	List<TripleRelation> result = new ArrayList<TripleRelation>();
	for (TripleRelation triples: entityDescription) {
		triples = triples.orderBy(TripleRelation.SUBJECT, true);
		if (triples.selectTriple(new Triple(Node.ANY, RDF.Nodes.type, Node.ANY)) != null) {
			result.add(triples);
		}
		// TODO: The list of label properties is redundantly specified in PageServlet
		if (triples.selectTriple(new Triple(Node.ANY, RDFS.label.asNode(), Node.ANY)) != null) {
			result.add(triples);
		} else if (triples.selectTriple(new Triple(Node.ANY, SKOS.prefLabel.asNode(), Node.ANY)) != null) {
			result.add(triples);
		} else if (triples.selectTriple(new Triple(Node.ANY, DC.title.asNode(), Node.ANY)) != null) {
			result.add(triples);					
		} else if (triples.selectTriple(new Triple(Node.ANY, DCTerms.title.asNode(), Node.ANY)) != null) {
			result.add(triples);					
		} else if (triples.selectTriple(new Triple(Node.ANY, FOAF.name.asNode(), Node.ANY)) != null) {
			result.add(triples);					
		}
	}
	if (result.isEmpty()) {
		result.add(new TripleRelation(sqlConnection, entityTable, 
				entityMaker, 
				new FixedNodeMaker(RDF.type.asNode()), 
				new FixedNodeMaker(RDFS.Resource.asNode())));
	}
	return result;
}
 
Example 12
Source Project: GeoTriples   Source File: OntologyTarget.java    License: Apache License 2.0 5 votes vote down vote up
public OntologyTarget() {
	model.setNsPrefix("rdf", RDF.getURI());
	model.setNsPrefix("rdfs", RDFS.getURI());
	model.setNsPrefix("owl", OWL.getURI());
	model.setNsPrefix("dc", DC.getURI());
	model.setNsPrefix("xsd", XSD.getURI());
}
 
Example 13
Source Project: GeoTriples   Source File: OntologyTarget.java    License: Apache License 2.0 5 votes vote down vote up
public void generateEntities(Resource class_, TableName table,
		TemplateValueMaker iriTemplate, List<Identifier> blankNodeColumns, boolean isGeometryTable) {
	if (class_ == null) return;
	Resource c = class_.inModel(model);
	c.addProperty(RDF.type, RDFS.Class);
	c.addProperty(RDF.type, OWL.Class);
	c.addProperty(RDFS.label, getLabel(table));
	if (generatedOntology != null) {
		c.addProperty(RDFS.isDefinedBy, generatedOntology);
	}
	classes.put(table, c);
}
 
Example 14
Source Project: GeoTriples   Source File: OntologyTarget.java    License: Apache License 2.0 5 votes vote down vote up
public void generateColumnProperty(Property property, TableName table,
		Identifier column, DataType datatype) {
	Property p = property.inModel(model);
	p.addProperty(RDF.type, RDF.Property);
	p.addProperty(RDF.type, OWL.DatatypeProperty);
	p.addProperty(RDFS.label, getLabel(table, column));
	domains.put(p, table);
	if (datatype.rdfType() != null && XSD.xstring.getURI().equals(datatype.rdfType())) {
		p.addProperty(RDFS.range, model.getResource(datatype.rdfType()));
	}
	if (generatedOntology != null) {
		p.addProperty(RDFS.isDefinedBy, generatedOntology);
	}
}
 
Example 15
Source Project: GeoTriples   Source File: OntologyTarget.java    License: Apache License 2.0 5 votes vote down vote up
public void generateRefProperty(Property property, TableName table,
		ForeignKey foreignKey) {
	Property p = property.inModel(model);
	p.addProperty(RDF.type, RDF.Property);
	p.addProperty(RDF.type, OWL.ObjectProperty);
	p.addProperty(RDFS.label, getLabel(table, foreignKey.getLocalColumns()));
	domains.put(p, table);
	ranges.put(p, foreignKey.getReferencedTable());
	if (generatedOntology != null) {
		p.addProperty(RDFS.isDefinedBy, generatedOntology);
	}
}
 
Example 16
Source Project: GeoTriples   Source File: OntologyTarget.java    License: Apache License 2.0 5 votes vote down vote up
public void generateLinkProperty(Property property, TableName table,
		ForeignKey fk1, ForeignKey fk2) {
	Property p = property.inModel(model);
	p.addProperty(RDF.type, RDF.Property);
	p.addProperty(RDF.type, OWL.ObjectProperty);
	p.addProperty(RDFS.label, getLabel(table));
	domains.put(p, fk1.getReferencedTable());
	ranges.put(p, fk2.getReferencedTable());
	if (generatedOntology != null) {
		p.addProperty(RDFS.isDefinedBy, generatedOntology);
	}
}
 
Example 17
Source Project: neo4jena   Source File: NeoGraph.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public PrefixMapping getPrefixMapping() {
	if(mapping==null)  {
		PrefixMapping standard = PrefixMapping.Factory.create()
			.setNsPrefix( "rdfs", RDFS.getURI() )
			.setNsPrefix( "rdf", RDF.getURI() )
			.setNsPrefix( "dc", DC_11.getURI() )
			.setNsPrefix( "owl", OWL.getURI() )
			.setNsPrefix( "xsd", XSD.getURI() );
		mapping = new NeoPrefixMapping(null, standard);
	}
	return mapping;
}
 
Example 18
Source Project: xcurator   Source File: OpenCycOntology.java    License: Apache License 2.0 5 votes vote down vote up
public String getLabelForResource(String uri) {
    Resource subject = model.createResource(uri);
    Statement stmt = subject.getProperty(RDFS.label);
    if (stmt != null) {
        RDFNode object = stmt.getObject();
        return object == null ? "" : object.asLiteral().getString();
    } else {
        return "";
    }
}
 
Example 19
Source Project: xcurator   Source File: JenaUtils.java    License: Apache License 2.0 5 votes vote down vote up
public static List<Statement> getBestMatchingStatements(OntModel ontology, StringMetric metric, String term) {
    StmtIterator iter
            = ontology.listStatements(new SimpleSelector(null, RDFS.label, (RDFNode) null));

    double maxSimilarity = Double.MIN_VALUE;
    List<Statement> bestChoices = new LinkedList<Statement>();

    while (iter.hasNext()) {
        Statement st = iter.next();
        String objectStr = st.getObject().asLiteral().getString();

        double similarity = metric.getSimilarity(term, objectStr);

        if (similarity <= 0) {
            continue;
        }

        if (similarity > maxSimilarity) {
            maxSimilarity = similarity;
            bestChoices.clear();
        } else if (similarity == maxSimilarity) {
            bestChoices.add(st);
        }
    }

    return bestChoices;
}
 
Example 20
Source Project: semanticMDR   Source File: ConceptImpl.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Override
public ObjectClass getParentConcept() {
	NodeIterator l = this.listPropertyValues(RDFS.subClassOf);

	while (l.hasNext()) {
		RDFNode res = l.nextNode();
		if (res.canAs(OntClass.class)) {
			OntClass ontClass = res.as(OntClass.class);
			if (ontClass.hasSuperClass(mdrDatabase.getVocabulary().Concept)) {
				return new ConceptImpl(res.asResource(), mdrDatabase);
			}
		}
	}
	return null;
}
 
Example 21
Source Project: EventCoreference   Source File: SemTime.java    License: Apache License 2.0 5 votes vote down vote up
public void addToJenaModelTimeInstant(Model model, OwlTime owlTime) {
    this.getOwlTime().addToJenaModelOwlTimeInstant(model);

    Resource resource = model.createResource(this.getURI());
    for (int i = 0; i < this.getPhraseCounts().size(); i++) {
        PhraseCount phraseCount = this.getPhraseCounts().get(i);
        if (!phraseCount.getPhrase().isEmpty()) {
            resource.addProperty(RDFS.label, model.createLiteral(phraseCount.getPhrase()));
        }
    }

    resource.addProperty(RDF.type, Sem.Time);

    Resource aResource = model.createResource(ResourcesUri.owltime + "Instant");
    resource.addProperty(RDF.type, aResource);

    Resource value = model.createResource(owlTime.getDateStringURI());
    Property property = model.createProperty(ResourcesUri.owltime + "inDateTime");
    resource.addProperty(property, value);

    for (int i = 0; i < this.getNafMentions().size(); i++) {
        NafMention nafMention = this.getNafMentions().get(i);
        Property gaf = model.createProperty(ResourcesUri.gaf + "denotedBy");
        Resource targetResource = model.createResource(nafMention.toString());
        resource.addProperty(gaf, targetResource);
    }
}
 
Example 22
Source Project: EventCoreference   Source File: SemTime.java    License: Apache License 2.0 5 votes vote down vote up
public void addToJenaModelDocTimeInstant(Model model) {

        this.getOwlTime().addToJenaModelOwlTimeInstant(model);

        Resource resource = model.createResource(this.getURI());
        if (!this.getTopPhraseAsLabel().isEmpty()) {
            resource.addProperty(RDFS.label, model.createLiteral(this.getTopPhraseAsLabel()));
        }

        /*for (int i = 0; i < phraseCounts.size(); i++) {
            PhraseCount phraseCount = phraseCounts.get(i);
            resource.addProperty(RDFS.label, model.createLiteral(phraseCount.getPhrase()));
        }*/

        //resource.addProperty(RDF.type, Sem.Time);
        // System.out.println("this.getOwlTime().toString() = " + this.getOwlTime().toString());
        Resource interval = model.createResource(ResourcesUri.owltime + "Instant");
        resource.addProperty(RDF.type, interval);

        Resource value = model.createResource(this.getOwlTime().getDateStringURI());
        Property property = model.createProperty(ResourcesUri.owltime + "inDateTime");
        resource.addProperty(property, value);

        for (int i = 0; i < this.getNafMentions().size(); i++) {
            NafMention nafMention = this.getNafMentions().get(i);
            Property gaf = model.createProperty(ResourcesUri.gaf + "denotedBy");
            Resource targetResource = model.createResource(nafMention.toString());
            resource.addProperty(gaf, targetResource);

        }
    }
 
Example 23
Source Project: EventCoreference   Source File: SemTime.java    License: Apache License 2.0 5 votes vote down vote up
public void addToJenaModelSimpleDocTimeInstant(Model model, SemObject semEvent) {

        this.getOwlTime().addToJenaModelOwlTimeInstant(model);

        Resource event = model.createResource(semEvent.getURI());
        Resource resource = model.createResource(this.getOwlTime().getDateStringURI());
        event.addProperty(Sem.hasTime, resource);

       // Resource resource = model.createResource(this.getURI());
        if (!this.getTopPhraseAsLabel().isEmpty()) {
            resource.addProperty(RDFS.label, model.createLiteral(this.getTopPhraseAsLabel()));
        }

        //resource.addProperty(RDF.type, Sem.Time);
        // System.out.println("this.getOwlTime().toString() = " + this.getOwlTime().toString());
/*
        Resource interval = model.createResource(ResourcesUri.owltime + "Instant");
        resource.addProperty(RDF.type, interval);
*/

/*
        Resource value = model.createResource(this.getOwlTime().getDateStringURI());
        Property property = model.createProperty(ResourcesUri.owltime + "inDateTime");
        resource.addProperty(property, value);
*/

    }
 
Example 24
Source Project: EventCoreference   Source File: SemTime.java    License: Apache License 2.0 5 votes vote down vote up
public void addToJenaModelTimeInterval(Model model) {
    this.getOwlTime().addToJenaModelOwlTimeInstant(model);

    Resource resource = model.createResource(this.getURI());
    for (int i = 0; i < this.getPhraseCounts().size(); i++) {
        PhraseCount phraseCount = this.getPhraseCounts().get(i);
        if (!phraseCount.getPhrase().isEmpty()) {
            resource.addProperty(RDFS.label, model.createLiteral(phraseCount.getPhrase()));
        }
    }

    resource.addProperty(RDF.type, Sem.Time);

    Resource interval = model.createResource(ResourcesUri.owltime + "Interval");
    resource.addProperty(RDF.type, interval);

    Resource value = model.createResource(this.getOwlTime().getDateStringURI());
    Property property = model.createProperty(ResourcesUri.owltime + "inDateTime");
    resource.addProperty(property, value);

    for (int i = 0; i < this.getNafMentions().size(); i++) {
        NafMention nafMention = this.getNafMentions().get(i);
        Property gaf = model.createProperty(ResourcesUri.gaf + "denotedBy");
        Resource targetResource = model.createResource(nafMention.toString());
        resource.addProperty(gaf, targetResource);

    }

}
 
Example 25
Source Project: EventCoreference   Source File: SemObject.java    License: Apache License 2.0 5 votes vote down vote up
public void addToJenaOldBaileySimpleModel(SimpleTaxonomy simpleTaxonomy, HashMap<String, String> rename, Model model, Resource type) {
        Resource resource = model.createResource(this.getURI());
        Resource conceptResource = model.createResource(ResourcesUri.nwrontology+this.type);
        resource.addProperty(RDF.type, conceptResource);

        //// Top phrase
        String topLabel = this.getTopPhraseAsLabel();
        if (!topLabel.isEmpty()) {
            //Property property = model.createProperty(ResourcesUri.skos+SKOS.PREF_LABEL.getLocalName());
            //resource.addProperty(property, model.createLiteral(this.getTopPhraseAsLabel()));
            //// instead of

            if (type.equals(SemObject.EVENT) ) {
                resource = model.createResource(this.getURI() + "_" + topLabel);
                rename.put(this.getURI(), this.getURI() + "_" + topLabel);
            }
            for (int i = 0; i < phraseCounts.size(); i++) {
                PhraseCount phraseCount = phraseCounts.get(i);
                // resource.addProperty(RDFS.label, model.createLiteral(phraseCount.getPhraseCount()));
/*                if (!phraseCount.getPhrase().equalsIgnoreCase(getTopPhraseAsLabel()) && goodPhrase(phraseCount)) {
                    resource.addProperty(RDFS.label, model.createLiteral(phraseCount.getPhrase()));
                }*/
                if (goodPhrase(phraseCount)) {
                    resource.addProperty(RDFS.label, model.createLiteral(phraseCount.getPhrase()));
                }
            }
        }

        addAllConceptsToResourceForOldBailey(simpleTaxonomy, rename, resource, model);
        for (int i = 0; i < nafMentions.size(); i++) {
           NafMention nafMention = nafMentions.get(i);
           Property property = model.createProperty(ResourcesUri.gaf + "denotedBy");
           Resource targetResource = null;
           targetResource = model.createResource(nafMention.toStringFull());
           resource.addProperty(property, targetResource);
        }
    }
 
Example 26
Source Project: GeoTriples   Source File: GeneralR2RMLTarget.java    License: Apache License 2.0 4 votes vote down vote up
public void generateEntityLabels(TemplateValueMaker labelTemplate,
		TableName tableName) {
	addPredicateObjectMap(tableName, 
			createPredicateObjectMap(RDFS.label, 
					createTermMap(labelTemplate, TermType.LITERAL)));
}
 
Example 27
Source Project: GeoTriples   Source File: ResourceDescriptionServlet.java    License: Apache License 2.0 4 votes vote down vote up
protected void doGet(HttpServletRequest request,
		HttpServletResponse response) throws IOException, ServletException {
	D2RServer server = D2RServer.fromServletContext(getServletContext());
	server.checkMappingFileChanged();
	String relativeResourceURI = request.getRequestURI().substring(
			request.getContextPath().length()
					+ request.getServletPath().length());
	// Some servlet containers keep the leading slash, some don't
	if (!"".equals(relativeResourceURI)
			&& "/".equals(relativeResourceURI.substring(0, 1))) {
		relativeResourceURI = relativeResourceURI.substring(1);
	}
	if (request.getQueryString() != null) {
		relativeResourceURI = relativeResourceURI + "?"
				+ request.getQueryString();
	}

	/* Determine service stem, i.e. vocab/ in /[vocab/]data */
	int servicePos;
	if (-1 == (servicePos = request.getServletPath().indexOf(
			"/" + D2RServer.getDataServiceName())))
		throw new ServletException("Expected to find service path /"
				+ D2RServer.getDataServiceName());
	String serviceStem = request.getServletPath().substring(1,
			servicePos + 1);

	String resourceURI = RequestParamHandler
			.removeOutputRequestParam(server.resourceBaseURI(serviceStem)
					+ relativeResourceURI);
	String documentURL = server.dataURL(serviceStem, relativeResourceURI);

	String pageURL = server.pageURL(serviceStem, relativeResourceURI);

	String sparqlQuery = "DESCRIBE <" + resourceURI + ">";
	QueryExecution qe = QueryExecutionFactory.create(sparqlQuery,
			server.dataset());
	if (server.getConfig().getPageTimeout() > 0) {
		qe.setTimeout(Math.round(server.getConfig().getPageTimeout() * 1000));
	}
	Model description = qe.execDescribe();
	qe.close();
	
	if (description.size() == 0) {
		response.sendError(404);
	}
	if (description.qnameFor(FOAF.primaryTopic.getURI()) == null
			&& description.getNsPrefixURI("foaf") == null) {
		description.setNsPrefix("foaf", FOAF.NS);
	}
	Resource resource = description.getResource(resourceURI);

	Resource document = description.getResource(documentURL);
	document.addProperty(FOAF.primaryTopic, resource);

	Statement label = resource.getProperty(RDFS.label);
	if (label != null) {
		document.addProperty(RDFS.label,
				"RDF Description of " + label.getString());
	}
	server.addDocumentMetadata(description, document);
	if (server.getConfig().serveMetadata()) {
		// add document metadata from template
		Model resourceMetadataTemplate = server.getConfig().getResourceMetadataTemplate(
				server, getServletContext());
		MetadataCreator resourceMetadataCreator = new MetadataCreator(
				server, resourceMetadataTemplate);
		description.add(resourceMetadataCreator.addMetadataFromTemplate(
				resourceURI, documentURL, pageURL));
		
		Map<String, String> descPrefixes = description.getNsPrefixMap();
		descPrefixes.putAll(resourceMetadataTemplate.getNsPrefixMap());
		description.setNsPrefixes(descPrefixes);
	}
	// TODO: Add a Content-Location header
	new ModelResponse(description, request, response).serve();
}
 
Example 28
Source Project: GeoTriples   Source File: D2RQTarget.java    License: Apache License 2.0 4 votes vote down vote up
public void generateEntityLabels(TemplateValueMaker labelTemplate, TableName table) {
	PropertyBridge bridge = new PropertyBridge(getLabelBridgeResource(table));
	bridge.setBelongsToClassMap(getClassMap(table));
	bridge.addProperty(RDFS.label);
	bridge.setPattern(Microsyntax.toString(labelTemplate));
}
 
Example 29
Source Project: GeoTriples   Source File: OntologyTarget.java    License: Apache License 2.0 4 votes vote down vote up
public void generateEntityLabels(TemplateValueMaker labelTemplate,
		TableName table) {
	model.add(RDFS.label, RDF.type, RDF.Property);
}
 
Example 30
Source Project: GeoTriples   Source File: R2RMLTarget.java    License: Apache License 2.0 4 votes vote down vote up
public void generateEntityLabels(TemplateValueMaker labelTemplate,
		TableName tableName) {
	addPredicateObjectMap(tableName, 
			createPredicateObjectMap(RDFS.label, 
					createTermMap(labelTemplate, TermType.LITERAL)));
}