Java Code Examples for com.hp.hpl.jena.rdf.model.Resource#addLiteral()
The following examples show how to use
com.hp.hpl.jena.rdf.model.Resource#addLiteral() .
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: CSPARQLAarhusParkingStream.java From Benchmark with GNU General Public License v3.0 | 6 votes |
@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 2
Source File: CSPARQLAarhusPollutionStream.java From Benchmark with GNU General Public License v3.0 | 6 votes |
@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 3
Source File: CSPARQLAarhusWeatherStream.java From Benchmark with GNU General Public License v3.0 | 6 votes |
@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 4
Source File: DataWrapper.java From Benchmark with GNU General Public License v3.0 | 6 votes |
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 5
Source File: DataWrapper.java From Benchmark with GNU General Public License v3.0 | 6 votes |
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 6
Source File: RDFFileManager.java From Benchmark with GNU General Public License v3.0 | 6 votes |
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 7
Source File: DataWrapper.java From Benchmark with GNU General Public License v3.0 | 6 votes |
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 8
Source File: CQELSAarhusWeatherStream.java From Benchmark with GNU General Public License v3.0 | 6 votes |
@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 9
Source File: CQELSAarhusParkingStream.java From Benchmark with GNU General Public License v3.0 | 6 votes |
@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 10
Source File: CQELSAarhusPollutionStream.java From Benchmark with GNU General Public License v3.0 | 6 votes |
@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 11
Source File: ShpConnector.java From TripleGeo with GNU General Public License v3.0 | 5 votes |
/** * * Handle triples for string literals */ private void insertLiteralTriplet(String s, String p, String o, String x) { Resource resourceGeometry = model.createResource(s); Property property = model.createProperty(p); if (x != null) { Literal literal = model.createTypedLiteral(o, x); resourceGeometry.addLiteral(property, literal); } else { resourceGeometry.addProperty(property, o); } }
Example 12
Source File: RdbToRdf.java From TripleGeo with GNU General Public License v3.0 | 5 votes |
/** * * Insert a triple for a literal value */ private void insertLiteralTriplet(String s, String p, String o, String x) { Resource resourceGeometry = model.createResource(s); Property property = model.createProperty(p); if (x != null) { Literal literal = model.createTypedLiteral(o, x); resourceGeometry.addLiteral(property, literal); } else { resourceGeometry.addProperty(property, o); } }
Example 13
Source File: ShpConnector.java From TripleGeo with GNU General Public License v3.0 | 5 votes |
/** * * Handle string literals for 'name' attribute */ private void insertResourceNameLiteral(String s, String p, String o, String lang) { Resource resource = model.createResource(s); Property property = model.createProperty(p); if (lang != null) { Literal literal = model.createLiteral(o, lang); resource.addLiteral(property, literal); } else { resource.addProperty(property, o); } }
Example 14
Source File: RDFFileManager.java From Benchmark with GNU General Public License v3.0 | 5 votes |
private static void createFilter(Resource bnode, Filter f, String cid, Model m) { Property hasFilter = m.createProperty(cesPrefix + "hasFilter"); Resource filter = m.createResource(); filter.addProperty(RDF.type, m.createResource(cesPrefix + "Filter")); filter.addProperty(m.createProperty(cesPrefix + "onPayload"), m.createResource(f.getVar())); if (cid != null) { // bnode = m.createResource(); filter.addProperty(m.createProperty(cesPrefix + "onEvent"), m.createResource(cid)); } bnode.addProperty(hasFilter, filter); Property op; if (f.getOp() == Filter.eq) op = m.createProperty(emvoPrefix + "equals"); else if (f.getOp() == Filter.lt) op = m.createProperty(emvoPrefix + "lessThan"); else if (f.getOp() == Filter.leq) op = m.createProperty(emvoPrefix + "lessOrEqualThan"); else if (f.getOp() == Filter.gt) op = m.createProperty(emvoPrefix + "greaterThan"); else { op = m.createProperty(emvoPrefix + "greaterOrEqualThan"); } // Literal val = m.(f.getVal()); if (f.getVal() instanceof String) filter.addLiteral(op, m.createTypedLiteral((String) f.getVal())); else if (f.getVal() instanceof Integer) filter.addLiteral(op, m.createTypedLiteral((Integer) f.getVal())); else filter.addLiteral(op, m.createTypedLiteral(Double.parseDouble(f.getVal().toString()))); }
Example 15
Source File: CQELSAarhusTrafficStream.java From Benchmark with GNU General Public License v3.0 | 5 votes |
@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); data = (AarhusTrafficObservation) data; 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 16
Source File: CQELSLocationStream.java From Benchmark with GNU General Public License v3.0 | 5 votes |
@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 17
Source File: DataWrapper.java From Benchmark with GNU General Public License v3.0 | 5 votes |
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 18
Source File: DataWrapper.java From Benchmark with GNU General Public License v3.0 | 5 votes |
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 19
Source File: CSPARQLLocationStream.java From Benchmark with GNU General Public License v3.0 | 5 votes |
@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 20
Source File: CSPARQLAarhusTrafficStream.java From Benchmark with GNU General Public License v3.0 | 5 votes |
@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(); }