com.hp.hpl.jena.vocabulary.RDF Java Examples

The following examples show how to use com.hp.hpl.jena.vocabulary.RDF. 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 check out the related API usage on the sidebar.
Example #1
Source File: DataWrapper.java    From Benchmark with GNU General Public License v3.0 6 votes vote down vote up
public static List<Statement> getAarhusPollutionStatement(SensorObservation so, EventDeclaration ed) {
	Model m = ModelFactory.createDefaultModel();
	if (ed != null)
		for (String s : ed.getPayloads()) {
			Resource observation = m
					.createResource(RDFFileManager.defaultPrefix + so.getObId() + UUID.randomUUID());
			// so.setObId(RDFFileManager.defaultPrefix + observation.toString());
			CityBench.obMap.put(observation.toString(), so);
			observation.addProperty(RDF.type, m.createResource(RDFFileManager.ssnPrefix + "Observation"));

			Resource serviceID = m.createResource(ed.getServiceId());
			observation.addProperty(m.createProperty(RDFFileManager.ssnPrefix + "observedBy"), serviceID);
			observation.addProperty(m.createProperty(RDFFileManager.ssnPrefix + "observedProperty"),
					m.createResource(s.split("\\|")[2]));
			Property hasValue = m.createProperty(RDFFileManager.saoPrefix + "hasValue");
			observation.addLiteral(hasValue, ((PollutionObservation) so).getApi());
		}
	return m.listStatements().toList();
}
 
Example #2
Source File: CQELSAarhusWeatherStream.java    From Benchmark with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected List<Statement> getStatements(SensorObservation wo) throws NumberFormatException, IOException {
	Model m = ModelFactory.createDefaultModel();
	if (ed != null)
		for (String s : ed.getPayloads()) {
			Resource observation = m
					.createResource(RDFFileManager.defaultPrefix + wo.getObId() + UUID.randomUUID());
			// wo.setObId(observation.toString());
			CityBench.obMap.put(observation.toString(), wo);
			observation.addProperty(RDF.type, m.createResource(RDFFileManager.ssnPrefix + "Observation"));
			Resource serviceID = m.createResource(ed.getServiceId());
			observation.addProperty(m.createProperty(RDFFileManager.ssnPrefix + "observedBy"), serviceID);
			observation.addProperty(m.createProperty(RDFFileManager.ssnPrefix + "observedProperty"),
					m.createResource(s.split("\\|")[2]));
			Property hasValue = m.createProperty(RDFFileManager.saoPrefix + "hasValue");
			if (s.contains("Temperature"))
				observation.addLiteral(hasValue, ((WeatherObservation) wo).getTemperature());
			else if (s.toString().contains("Humidity"))
				observation.addLiteral(hasValue, ((WeatherObservation) wo).getHumidity());
			else if (s.toString().contains("WindSpeed"))
				observation.addLiteral(hasValue, ((WeatherObservation) wo).getWindSpeed());
		}
	return m.listStatements().toList();
}
 
Example #3
Source File: RDFFileManager.java    From Benchmark with GNU General Public License v3.0 6 votes vote down vote up
private static void createSelections(Resource patternNode, Model m, EventPattern ep) {
	Property hasSelection = m.createProperty(cesPrefix + "hasSelection");
	Property hasNodeId = m.createProperty(cesPrefix + "hasNodeId");
	Property hasSelectedProperty = m.createProperty(cesPrefix + "selectedProperty");
	// System.out.p rintln("Creating selections:------------");
	for (Selection sel : ep.getSelections()) {
		// System.out.println("SEL: " + sel.toString());
		Resource pName = m.createResource(sel.getPropertyName());
		String nodeId = sel.getProvidedBy();
		// Resource pType = m.createResource(sel.getPropertyType());
		// EventDeclaration ed;
		// if (ep.isQuery() && sel.getOriginalED() != null)
		// ed = sel.getOriginalED();
		// Resource foi = m.createResource(sel.getFoi());
		patternNode.addProperty(
				hasSelection,
				m.createResource().addProperty(RDF.type, m.createResource(cesPrefix + "Selection"))
						.addProperty(hasNodeId, m.createLiteral(nodeId)).addProperty(hasSelectedProperty, pName));
		// if (ep.isQuery()) {// add property type and foi for query
		// pName.addProperty(RDF.type, pType).addProperty(m.createProperty(ssnPrefix + "isPropertyOf"), foi);
		// }
	}
}
 
Example #4
Source File: CQELSAarhusPollutionStream.java    From Benchmark with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected List<Statement> getStatements(SensorObservation so) {
	Model m = ModelFactory.createDefaultModel();
	if (ed != null)
		for (String s : ed.getPayloads()) {
			Resource observation = m
					.createResource(RDFFileManager.defaultPrefix + so.getObId() + UUID.randomUUID());
			// so.setObId(RDFFileManager.defaultPrefix + observation.toString());
			CityBench.obMap.put(observation.toString(), so);
			observation.addProperty(RDF.type, m.createResource(RDFFileManager.ssnPrefix + "Observation"));

			Resource serviceID = m.createResource(ed.getServiceId());
			observation.addProperty(m.createProperty(RDFFileManager.ssnPrefix + "observedBy"), serviceID);
			observation.addProperty(m.createProperty(RDFFileManager.ssnPrefix + "observedProperty"),
					m.createResource(s.split("\\|")[2]));
			Property hasValue = m.createProperty(RDFFileManager.saoPrefix + "hasValue");
			observation.addLiteral(hasValue, ((PollutionObservation) so).getApi());
		}
	return m.listStatements().toList();
}
 
Example #5
Source File: DataWrapper.java    From Benchmark with GNU General Public License v3.0 6 votes vote down vote up
public static List<Statement> getAarhusParkingStatements(SensorObservation so, EventDeclaration ed) {
	Model m = ModelFactory.createDefaultModel();
	Resource observation = m.createResource(RDFFileManager.defaultPrefix + so.getObId() + UUID.randomUUID());
	CityBench.obMap.put(observation.toString(), so);
	observation.addProperty(RDF.type, m.createResource(RDFFileManager.ssnPrefix + "Observation"));
	// observation.addProperty(RDF.type,
	// m.createResource(RDFFileManager.saoPrefix + "StreamData"));
	Resource serviceID = m.createResource(ed.getServiceId());
	observation.addProperty(m.createProperty(RDFFileManager.ssnPrefix + "observedBy"), serviceID);
	// Resource property = m.createResource(s.split("\\|")[2]);
	// property.addProperty(RDF.type, m.createResource(s.split("\\|")[0]));
	observation.addProperty(m.createProperty(RDFFileManager.ssnPrefix + "observedProperty"),
			m.createResource(ed.getPayloads().get(0).split("\\|")[2]));
	Property hasValue = m.createProperty(RDFFileManager.saoPrefix + "hasValue");
	// Literal l;
	// System.out.println("Annotating: " + observedProperty.toString());
	// if (observedProperty.contains("AvgSpeed"))
	observation.addLiteral(hasValue, ((AarhusParkingObservation) so).getVacancies());
	// observation.addLiteral(m.createProperty(RDFFileManager.ssnPrefix + "featureOfInterest"),
	// ((AarhusParkingObservation) so).getGarageCode());
	return m.listStatements().toList();
}
 
Example #6
Source File: VocabularySummarizer.java    From GeoTriples with Apache License 2.0 6 votes vote down vote up
public Collection<Resource> getUndefinedResources(Model model) {
	Set<Resource> result = new HashSet<Resource>();
	StmtIterator it = model.listStatements();
	while (it.hasNext()) {
		Statement stmt = it.nextStatement();
		if (stmt.getSubject().isURIResource()
				&& stmt.getSubject().getURI().startsWith(namespace)
				&& !resources.contains(stmt.getSubject())) {
			result.add(stmt.getSubject());
		}
		if (stmt.getPredicate().equals(RDF.type)) continue;
		if (stmt.getObject().isURIResource()
				&& stmt.getResource().getURI().startsWith(namespace)
				&& !resources.contains(stmt.getResource())) {
			result.add(stmt.getResource());
		}
	}
	return result;
}
 
Example #7
Source File: RDFFileManager.java    From Benchmark with GNU General Public License v3.0 6 votes vote down vote up
private static Resource createTrafficLocation(Model m, EventDeclaration ed) {
	Resource foi = m.createResource(defaultPrefix + "FoI-" + UUID.randomUUID());
	foi.addProperty(RDF.type, m.createResource(ssnPrefix + "FeatureOfInterest"));
	Resource firstNode = m.createResource();
	firstNode.addProperty(RDF.type, m.createResource(ctPrefix + "Node"));
	foi.addProperty(m.createProperty(ctPrefix + "hasFirstNode"), firstNode);
	firstNode.addLiteral(m.createProperty(ctPrefix + "hasStreetNumber"),
			((TrafficReportService) ed).getNode1StreetNo());
	firstNode.addLiteral(m.createProperty(ctPrefix + "hasStreet"), ((TrafficReportService) ed).getNode1Street());
	firstNode.addLiteral(m.createProperty(ctPrefix + "hasCity"), ((TrafficReportService) ed).getNode1City());
	firstNode.addLiteral(m.createProperty(ctPrefix + "hasLatitude"), ((TrafficReportService) ed).getNode1Lat());
	firstNode.addLiteral(m.createProperty(ctPrefix + "hasLongtitude"), ((TrafficReportService) ed).getNode1Lon());
	firstNode.addLiteral(m.createProperty(ctPrefix + "hasNodeName"), ((TrafficReportService) ed).getNode1Name());

	Resource secNode = m.createResource();
	secNode.addProperty(RDF.type, ctPrefix + "Node");
	foi.addProperty(m.createProperty(ctPrefix + "hasSecondNode"), secNode);
	secNode.addLiteral(m.createProperty(ctPrefix + "hasStreetNumber"),
			((TrafficReportService) ed).getNode2StreetNo());
	secNode.addLiteral(m.createProperty(ctPrefix + "hasStreet"), ((TrafficReportService) ed).getNode2Street());
	secNode.addLiteral(m.createProperty(ctPrefix + "hasCity"), ((TrafficReportService) ed).getNode2City());
	secNode.addLiteral(m.createProperty(ctPrefix + "hasLatitude"), ((TrafficReportService) ed).getNode2Lat());
	secNode.addLiteral(m.createProperty(ctPrefix + "hasLongtitude"), ((TrafficReportService) ed).getNode2Lon());
	secNode.addLiteral(m.createProperty(ctPrefix + "hasNodeName"), ((TrafficReportService) ed).getNode2Name());
	return foi;
}
 
Example #8
Source File: JenaModelExample.java    From GeoTriples with Apache License 2.0 6 votes vote down vote up
public static void main(String[] args) {
	// Set up the ModelD2RQ using a mapping file
	ModelD2RQ m = new ModelD2RQ("file:doc/example/mapping-iswc.ttl");
	
	// Find anything with an rdf:type of iswc:InProceedings
	StmtIterator paperIt = m.listStatements(null, RDF.type, ISWC.InProceedings);
	
	// List found papers and print their titles
	while (paperIt.hasNext()) {
		Resource paper = paperIt.nextStatement().getSubject();
		System.out.println("Paper: " + paper.getProperty(DC.title).getString());
		
		// List authors of the paper and print their names
		StmtIterator authorIt = paper.listProperties(DC.creator);
		while (authorIt.hasNext()) {
			Resource author = authorIt.nextStatement().getResource();
			System.out.println("Author: " + author.getProperty(FOAF.name).getString());
		}
		System.out.println();
	}
	m.close();
}
 
Example #9
Source File: GeneralMappingStyle.java    From GeoTriples with 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 #10
Source File: CQELSAarhusParkingStream.java    From Benchmark with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected List<Statement> getStatements(SensorObservation so) {
	Model m = ModelFactory.createDefaultModel();
	Resource observation = m.createResource(RDFFileManager.defaultPrefix + so.getObId() + UUID.randomUUID());
	CityBench.obMap.put(observation.toString(), so);
	observation.addProperty(RDF.type, m.createResource(RDFFileManager.ssnPrefix + "Observation"));
	// observation.addProperty(RDF.type,
	// m.createResource(RDFFileManager.saoPrefix + "StreamData"));
	Resource serviceID = m.createResource(ed.getServiceId());
	observation.addProperty(m.createProperty(RDFFileManager.ssnPrefix + "observedBy"), serviceID);
	// Resource property = m.createResource(s.split("\\|")[2]);
	// property.addProperty(RDF.type, m.createResource(s.split("\\|")[0]));
	observation.addProperty(m.createProperty(RDFFileManager.ssnPrefix + "observedProperty"),
			m.createResource(ed.getPayloads().get(0).split("\\|")[2]));
	Property hasValue = m.createProperty(RDFFileManager.saoPrefix + "hasValue");
	// Literal l;
	// System.out.println("Annotating: " + observedProperty.toString());
	// if (observedProperty.contains("AvgSpeed"))
	observation.addLiteral(hasValue, ((AarhusParkingObservation) so).getVacancies());
	// observation.addLiteral(m.createProperty(RDFFileManager.ssnPrefix + "featureOfInterest"),
	// ((AarhusParkingObservation) so).getGarageCode());
	return m.listStatements().toList();
}
 
Example #11
Source File: John_Unparser.java    From GeoTriples with Apache License 2.0 6 votes vote down vote up
/**
 * @return A statement that is suitable for a typed node construction or
 *         null.
 */
private Statement getType(Resource r) {
    Statement rslt;
    try {
        if (r instanceof Statement) {
            rslt = ((Statement) r).getStatementProperty(RDF.type);
            if (rslt == null || (!rslt.getObject().equals(RDF.Statement)))
                error("Statement type problem");
        } else {
            rslt = r.getRequiredProperty(RDF.type);
        }
    } catch (PropertyNotFoundException rdfe) {
        if (r instanceof Statement)
            error("Statement type problem");
        rslt = null;
    }
    if (rslt == null || isOKType(rslt.getObject()) == -1)
        return null;

    return rslt;
}
 
Example #12
Source File: DataWrapper.java    From Benchmark with GNU General Public License v3.0 6 votes vote down vote up
public static List<Statement> getAarhusWeatherStatements(SensorObservation wo, EventDeclaration ed) {
	Model m = ModelFactory.createDefaultModel();
	if (ed != null)
		for (String s : ed.getPayloads()) {
			Resource observation = m
					.createResource(RDFFileManager.defaultPrefix + wo.getObId() + UUID.randomUUID());
			// wo.setObId(observation.toString());
			CityBench.obMap.put(observation.toString(), wo);
			observation.addProperty(RDF.type, m.createResource(RDFFileManager.ssnPrefix + "Observation"));
			Resource serviceID = m.createResource(ed.getServiceId());
			observation.addProperty(m.createProperty(RDFFileManager.ssnPrefix + "observedBy"), serviceID);
			observation.addProperty(m.createProperty(RDFFileManager.ssnPrefix + "observedProperty"),
					m.createResource(s.split("\\|")[2]));
			Property hasValue = m.createProperty(RDFFileManager.saoPrefix + "hasValue");
			if (s.contains("Temperature"))
				observation.addLiteral(hasValue, ((WeatherObservation) wo).getTemperature());
			else if (s.toString().contains("Humidity"))
				observation.addLiteral(hasValue, ((WeatherObservation) wo).getHumidity());
			else if (s.toString().contains("WindSpeed"))
				observation.addLiteral(hasValue, ((WeatherObservation) wo).getWindSpeed());
		}
	return m.listStatements().toList();
}
 
Example #13
Source File: John_Unparser.java    From GeoTriples with Apache License 2.0 6 votes vote down vote up
private boolean hasProperties(Resource r) {
    ExtendedIterator<Statement> ss = listProperties(r);
    if (avoidExplicitReification && // ( r instanceof Statement ) &&
            (!r.isAnon()) && isLocalReference(r)
            && res2statement.containsKey(r)) {
        ss = new MapFilterIterator<Statement, Statement>(new MapFilter<Statement, Statement>() {
            @Override
            public Statement accept(Statement o) {
                Statement s = o;
                Property p = s.getPredicate();
                return ((!p.getNameSpace().equals(rdfns)) || !((RDF.type
                        .equals(p) && s.getObject().equals(RDF.Statement))
                        || RDF.object.equals(p) || RDF.predicate.equals(p) || RDF.subject
                        .equals(p))) ? o : null;
            }
        }, ss);
    }
    try {
        return ss.hasNext();
    } finally {
        ss.close();
    }
}
 
Example #14
Source File: CSPARQLAarhusPollutionStream.java    From Benchmark with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected List<Statement> getStatements(SensorObservation so) {
	Model m = ModelFactory.createDefaultModel();
	if (ed != null)
		for (String s : ed.getPayloads()) {
			Resource observation = m
					.createResource(RDFFileManager.defaultPrefix + so.getObId() + UUID.randomUUID());
			// so.setObId(RDFFileManager.defaultPrefix + observation.toString());
			CityBench.obMap.put(observation.toString(), so);
			observation.addProperty(RDF.type, m.createResource(RDFFileManager.ssnPrefix + "Observation"));

			Resource serviceID = m.createResource(ed.getServiceId());
			observation.addProperty(m.createProperty(RDFFileManager.ssnPrefix + "observedBy"), serviceID);
			observation.addProperty(m.createProperty(RDFFileManager.ssnPrefix + "observedProperty"),
					m.createResource(s.split("\\|")[2]));
			Property hasValue = m.createProperty(RDFFileManager.saoPrefix + "hasValue");
			observation.addLiteral(hasValue, ((PollutionObservation) so).getApi());
		}
	return m.listStatements().toList();
}
 
Example #15
Source File: John_BaseXMLWriter.java    From GeoTriples with Apache License 2.0 6 votes vote down vote up
private void generateDoctypeDeclaration(Model model, PrintWriter pw) {
	String rdfns = RDF.getURI();
	String rdfRDF = model.qnameFor(rdfns + "RDF");
	if (rdfRDF == null) {
		model.setNsPrefix("rdf", rdfns);
		rdfRDF = "rdf:RDF";
	}
	Map<String, String> prefixes = model.getNsPrefixMap();
	pw.print("<!DOCTYPE " + rdfRDF + " [");
	for (Iterator<String> it = prefixes.keySet().iterator(); it.hasNext();) {
		String prefix = it.next();
		if (isPredefinedEntityName(prefix))
			continue;
		pw.print(newline
				+ "  <!ENTITY "
				+ strForPrefix(prefix)
				+ " '"
				+ Util.substituteEntitiesInEntityValue(prefixes.get(prefix))
				+ "'>");
	}
	pw.print("]>" + newline);
}
 
Example #16
Source File: CSPARQLAarhusParkingStream.java    From Benchmark with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected List<Statement> getStatements(SensorObservation so) throws NumberFormatException, IOException {
	Model m = ModelFactory.createDefaultModel();
	Resource observation = m.createResource(RDFFileManager.defaultPrefix + so.getObId() + UUID.randomUUID());
	CityBench.obMap.put(observation.toString(), so);
	observation.addProperty(RDF.type, m.createResource(RDFFileManager.ssnPrefix + "Observation"));
	// observation.addProperty(RDF.type,
	// m.createResource(RDFFileManager.saoPrefix + "StreamData"));
	Resource serviceID = m.createResource(ed.getServiceId());
	observation.addProperty(m.createProperty(RDFFileManager.ssnPrefix + "observedBy"), serviceID);
	// Resource property = m.createResource(s.split("\\|")[2]);
	// property.addProperty(RDF.type, m.createResource(s.split("\\|")[0]));
	observation.addProperty(m.createProperty(RDFFileManager.ssnPrefix + "observedProperty"),
			m.createResource(ed.getPayloads().get(0).split("\\|")[2]));
	Property hasValue = m.createProperty(RDFFileManager.saoPrefix + "hasValue");
	// Literal l;
	// System.out.println("Annotating: " + observedProperty.toString());
	// if (observedProperty.contains("AvgSpeed"))
	observation.addLiteral(hasValue, ((AarhusParkingObservation) so).getVacancies());
	// observation.addLiteral(m.createProperty(RDFFileManager.ssnPrefix + "featureOfInterest"),
	// ((AarhusParkingObservation) so).getGarageCode());
	return m.listStatements().toList();
}
 
Example #17
Source File: CSPARQLAarhusWeatherStream.java    From Benchmark with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected List<Statement> getStatements(SensorObservation wo) throws NumberFormatException, IOException {
	Model m = ModelFactory.createDefaultModel();
	if (ed != null)
		for (String s : ed.getPayloads()) {
			Resource observation = m
					.createResource(RDFFileManager.defaultPrefix + wo.getObId() + UUID.randomUUID());
			// wo.setObId(observation.toString());
			CityBench.obMap.put(observation.toString(), wo);
			observation.addProperty(RDF.type, m.createResource(RDFFileManager.ssnPrefix + "Observation"));
			Resource serviceID = m.createResource(ed.getServiceId());
			observation.addProperty(m.createProperty(RDFFileManager.ssnPrefix + "observedBy"), serviceID);
			observation.addProperty(m.createProperty(RDFFileManager.ssnPrefix + "observedProperty"),
					m.createResource(s.split("\\|")[2]));
			Property hasValue = m.createProperty(RDFFileManager.saoPrefix + "hasValue");
			if (s.contains("Temperature"))
				observation.addLiteral(hasValue, ((WeatherObservation) wo).getTemperature());
			else if (s.toString().contains("Humidity"))
				observation.addLiteral(hasValue, ((WeatherObservation) wo).getHumidity());
			else if (s.toString().contains("WindSpeed"))
				observation.addLiteral(hasValue, ((WeatherObservation) wo).getWindSpeed());
		}
	return m.listStatements().toList();
}
 
Example #18
Source File: SemTime.java    From EventCoreference with 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 #19
Source File: D2RQMappingStyle.java    From GeoTriples with 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 #20
Source File: RdbToRdf.java    From TripleGeo with GNU General Public License v3.0 5 votes vote down vote up
/**
 * 
 * Insert a triple for the 'type' (i.e., class or characterization attribute) of a feature
 */
private void insertResourceTypeResource(String r1, String r2) 
{
  Resource resource1 = model.createResource(r1);
  Resource resource2 = model.createResource(r2);
  model.add(resource1, RDF.type, resource2);
}
 
Example #21
Source File: ShpConnector.java    From TripleGeo with GNU General Public License v3.0 5 votes vote down vote up
/**
 * 
 * Handle resource type
 */
private void insertResourceTypeResource(String r1, String r2) 
{
  Resource resource1 = model.createResource(r1);
  Resource resource2 = model.createResource(r2);
  model.add(resource1, RDF.type, resource2);
}
 
Example #22
Source File: SemTime.java    From EventCoreference with 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 #23
Source File: SemTime.java    From EventCoreference with 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 #24
Source File: RDFFileManager.java    From Benchmark with GNU General Public License v3.0 5 votes vote down vote up
private static void createQosParam(Resource profile, String pName, Object pValue, Model m) {
	profile.addProperty(
			m.createProperty(cesPrefix + "has" + pName),
			m.createResource()
					.addProperty(RDF.type, m.createResource(cesPrefix + pName))
					.addProperty(m.createProperty(owlsspPrefix + "serviceParameterName"), pName)
					.addProperty(
							m.createProperty(owlsspPrefix + "sParameter"),
							m.createResource()
									.addLiteral(m.createProperty(emvoPrefix + "hasQuantityValue"), pValue)));
}
 
Example #25
Source File: CQELSLocationStream.java    From Benchmark with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected List<Statement> getStatements(SensorObservation so) throws NumberFormatException, IOException {
	String userStr = so.getFoi();
	String coordinatesStr = so.getValue().toString();
	Model m = ModelFactory.createDefaultModel();
	double lat = Double.parseDouble(coordinatesStr.split(",")[0]);
	double lon = Double.parseDouble(coordinatesStr.split(",")[1]);
	Resource serviceID = m.createResource(ed.getServiceId());
	//
	// Resource user = m.createResource(userStr);

	Resource observation = m.createResource(RDFFileManager.defaultPrefix + so.getObId() + UUID.randomUUID());
	CityBench.obMap.put(observation.toString(), so);
	observation.addProperty(RDF.type, m.createResource(RDFFileManager.ssnPrefix + "Observation"));
	// observation.addProperty(RDF.type, m.createResource(RDFFileManager.saoPrefix + "StreamData"));

	// location.addProperty(RDF.type, m.createResource(RDFFileManager.ctPrefix + "Location"));

	Resource coordinates = m.createResource();
	coordinates.addLiteral(m.createProperty(RDFFileManager.ctPrefix + "hasLatitude"), lat);
	coordinates.addLiteral(m.createProperty(RDFFileManager.ctPrefix + "hasLongitude"), lon);

	// observation.addProperty(m.createProperty(RDFFileManager.ssnPrefix + "featureOfInterest"), user);
	observation.addProperty(m.createProperty(RDFFileManager.ssnPrefix + "observedProperty"),
			m.createResource(ed.getPayloads().get(0).split("\\|")[2]));
	observation.addProperty(m.createProperty(RDFFileManager.ssnPrefix + "observedBy"), serviceID);
	// fake fixed foi
	observation
			.addProperty(
					m.createProperty(RDFFileManager.ssnPrefix + "featureOfInterest"),
					m.createResource("http://iot.ee.surrey.ac.uk/citypulse/datasets/aarhusculturalevents/culturalEvents_aarhus#context_do63jk2t8c3bjkfb119ojgkhs7"));

	observation.addProperty(m.createProperty(RDFFileManager.saoPrefix + "hasValue"), coordinates);
	// System.out.println("transformed: " + m.listStatements().toList().size());s
	return m.listStatements().toList();
}
 
Example #26
Source File: DataWrapper.java    From Benchmark with GNU General Public License v3.0 5 votes vote down vote up
public static List<Statement> getUserLocationStatements(SensorObservation so, EventDeclaration ed) {
	String userStr = so.getFoi();
	String coordinatesStr = so.getValue().toString();
	Model m = ModelFactory.createDefaultModel();
	double lat = Double.parseDouble(coordinatesStr.split(",")[0]);
	double lon = Double.parseDouble(coordinatesStr.split(",")[1]);
	Resource serviceID = m.createResource(ed.getServiceId());
	//
	// Resource user = m.createResource(userStr);

	Resource observation = m.createResource(RDFFileManager.defaultPrefix + so.getObId() + UUID.randomUUID());
	CityBench.obMap.put(observation.toString(), so);
	observation.addProperty(RDF.type, m.createResource(RDFFileManager.ssnPrefix + "Observation"));
	// observation.addProperty(RDF.type, m.createResource(RDFFileManager.saoPrefix + "StreamData"));

	// location.addProperty(RDF.type, m.createResource(RDFFileManager.ctPrefix + "Location"));

	Resource coordinates = m.createResource();
	coordinates.addLiteral(m.createProperty(RDFFileManager.ctPrefix + "hasLatitude"), lat);
	coordinates.addLiteral(m.createProperty(RDFFileManager.ctPrefix + "hasLongitude"), lon);

	// observation.addProperty(m.createProperty(RDFFileManager.ssnPrefix + "featureOfInterest"), user);
	observation.addProperty(m.createProperty(RDFFileManager.ssnPrefix + "observedProperty"),
			m.createResource(ed.getPayloads().get(0).split("\\|")[2]));
	observation.addProperty(m.createProperty(RDFFileManager.ssnPrefix + "observedBy"), serviceID);
	// fake fixed foi
	observation
			.addProperty(
					m.createProperty(RDFFileManager.ssnPrefix + "featureOfInterest"),
					m.createResource("http://iot.ee.surrey.ac.uk/citypulse/datasets/aarhusculturalevents/culturalEvents_aarhus#context_do63jk2t8c3bjkfb119ojgkhs7"));

	observation.addProperty(m.createProperty(RDFFileManager.saoPrefix + "hasValue"), coordinates);
	// System.out.println("transformed: " + m.listStatements().toList().size());s
	return m.listStatements().toList();
}
 
Example #27
Source File: DataWrapper.java    From Benchmark with GNU General Public License v3.0 5 votes vote down vote up
public static List<Statement> getAarhusTrafficStatements(AarhusTrafficObservation data, EventDeclaration ed) {
	Model m = ModelFactory.createDefaultModel();
	if (ed != null)
		for (String pStr : ed.getPayloads()) {
			// if (s.contains("EstimatedTime")) {
			// Resource observedProperty = m.createResource(s);
			String obId = data.getObId();
			Resource observation = m.createResource(RDFFileManager.defaultPrefix + obId + UUID.randomUUID());
			CityBench.obMap.put(observation.toString(), data);
			// data.setObId(observation.toString());
			// System.out.println("OB: " + observation.toString());
			observation.addProperty(RDF.type, m.createResource(RDFFileManager.ssnPrefix + "Observation"));

			Resource serviceID = m.createResource(ed.getServiceId());
			observation.addProperty(m.createProperty(RDFFileManager.ssnPrefix + "observedBy"), serviceID);
			observation.addProperty(m.createProperty(RDFFileManager.ssnPrefix + "observedProperty"),
					m.createResource(pStr.split("\\|")[2]));
			Property hasValue = m.createProperty(RDFFileManager.saoPrefix + "hasValue");
			// System.out.println("Annotating: " + observedProperty.toString());
			if (pStr.contains("AvgSpeed"))
				observation.addLiteral(hasValue, data.getAverageSpeed());
			else if (pStr.contains("VehicleCount")) {
				double value = data.getVehicle_count();
				observation.addLiteral(hasValue, value);
			} else if (pStr.contains("MeasuredTime"))
				observation.addLiteral(hasValue, data.getAvgMeasuredTime());
			else if (pStr.contains("EstimatedTime"))
				observation.addLiteral(hasValue, data.getEstimatedTime());
			else if (pStr.contains("CongestionLevel"))
				observation.addLiteral(hasValue, data.getCongestionLevel());
			// break;
			// }
		}
	return m.listStatements().toList();
	// return null;

}
 
Example #28
Source File: CSPARQLLocationStream.java    From Benchmark with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected List<Statement> getStatements(SensorObservation so) throws NumberFormatException, IOException {
	String userStr = so.getFoi();
	String coordinatesStr = so.getValue().toString();
	Model m = ModelFactory.createDefaultModel();
	double lat = Double.parseDouble(coordinatesStr.split(",")[0]);
	double lon = Double.parseDouble(coordinatesStr.split(",")[1]);
	Resource serviceID = m.createResource(ed.getServiceId());
	//
	// Resource user = m.createResource(userStr);

	Resource observation = m.createResource(RDFFileManager.defaultPrefix + so.getObId() + UUID.randomUUID());
	CityBench.obMap.put(observation.toString(), so);
	observation.addProperty(RDF.type, m.createResource(RDFFileManager.ssnPrefix + "Observation"));
	// observation.addProperty(RDF.type, m.createResource(RDFFileManager.saoPrefix + "StreamData"));

	// location.addProperty(RDF.type, m.createResource(RDFFileManager.ctPrefix + "Location"));

	Resource coordinates = m.createResource();
	coordinates.addLiteral(m.createProperty(RDFFileManager.ctPrefix + "hasLatitude"), lat);
	coordinates.addLiteral(m.createProperty(RDFFileManager.ctPrefix + "hasLongitude"), lon);

	// observation.addProperty(m.createProperty(RDFFileManager.ssnPrefix + "featureOfInterest"), user);
	observation.addProperty(m.createProperty(RDFFileManager.ssnPrefix + "observedProperty"),
			m.createResource(ed.getPayloads().get(0).split("\\|")[2]));
	observation.addProperty(m.createProperty(RDFFileManager.ssnPrefix + "observedBy"), serviceID);
	// fake fixed foi
	observation
			.addProperty(
					m.createProperty(RDFFileManager.ssnPrefix + "featureOfInterest"),
					m.createResource("http://iot.ee.surrey.ac.uk/citypulse/datasets/aarhusculturalevents/culturalEvents_aarhus#context_do63jk2t8c3bjkfb119ojgkhs7"));

	observation.addProperty(m.createProperty(RDFFileManager.saoPrefix + "hasValue"), coordinates);
	// System.out.println("transformed: " + m.listStatements().toList().size());s
	return m.listStatements().toList();
}
 
Example #29
Source File: CSPARQLAarhusTrafficStream.java    From Benchmark with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected List<Statement> getStatements(SensorObservation data) throws NumberFormatException, IOException {
	// return DataWrapper.getAarhusTrafficStatements((AarhusTrafficObservation) data, ed);
	Model m = ModelFactory.createDefaultModel();
	if (ed != null)
		for (String pStr : ed.getPayloads()) {
			// if (s.contains("EstimatedTime")) {
			// Resource observedProperty = m.createResource(s);
			String obId = data.getObId();
			Resource observation = m.createResource(RDFFileManager.defaultPrefix + obId + UUID.randomUUID());
			CityBench.obMap.put(observation.toString(), data);
			// data.setObId(observation.toString());
			// System.out.println("OB: " + observation.toString());
			observation.addProperty(RDF.type, m.createResource(RDFFileManager.ssnPrefix + "Observation"));

			Resource serviceID = m.createResource(ed.getServiceId());
			observation.addProperty(m.createProperty(RDFFileManager.ssnPrefix + "observedBy"), serviceID);
			observation.addProperty(m.createProperty(RDFFileManager.ssnPrefix + "observedProperty"),
					m.createResource(pStr.split("\\|")[2]));
			Property hasValue = m.createProperty(RDFFileManager.saoPrefix + "hasValue");
			// System.out.println("Annotating: " + observedProperty.toString());
			if (pStr.contains("AvgSpeed"))
				observation.addLiteral(hasValue, ((AarhusTrafficObservation) data).getAverageSpeed());
			else if (pStr.contains("VehicleCount")) {
				double value = ((AarhusTrafficObservation) data).getVehicle_count();
				observation.addLiteral(hasValue, value);
			} else if (pStr.contains("MeasuredTime"))
				observation.addLiteral(hasValue, ((AarhusTrafficObservation) data).getAvgMeasuredTime());
			else if (pStr.contains("EstimatedTime"))
				observation.addLiteral(hasValue, ((AarhusTrafficObservation) data).getEstimatedTime());
			else if (pStr.contains("CongestionLevel"))
				observation.addLiteral(hasValue, ((AarhusTrafficObservation) data).getCongestionLevel());
			// break;
			// }
		}
	return m.listStatements().toList();
}
 
Example #30
Source File: DirectMappingStyle.java    From GeoTriples with Apache License 2.0 5 votes vote down vote up
public DirectMappingStyle(SQLConnection connection, String baseIRI) {
	this.generator = new MappingGenerator(this, connection);
	this.baseIRI = baseIRI;
	model.setNsPrefix("rdf", RDF.getURI());
	model.setNsPrefix("xsd", XSD.getURI());
	generator.setGenerateLabelBridges(false);
	generator.setHandleLinkTables(false);
	generator.setGenerateDefinitionLabels(false);
	generator.setServeVocabulary(false);
	generator.setSkipForeignKeyTargetColumns(false);
	generator.setUseUniqueKeysAsEntityID(false);
}