/** * {@inheritDoc} */ @Override public Property getProperty(String uri) { return super.object.getProperty(uri); }
/** * {@inheritDoc} */ @Override public Property getProperty(String nameSpace, String localName) { return super.object.getProperty(nameSpace, localName); }
/** * {@inheritDoc} */ @Override public Statement getProperty(Resource s, Property p) { return super.object.getProperty(s, p); }
/** Get the corresponding RDF property, may cache */ public Property getProperty(Model m) { if (p == null) { p = m.getProperty(uri); } return p; }
public Property getProperty(String uri) { return model.getProperty(uri); }
public Property getProperty(String nameSpace, String localName) { return model.getProperty(nameSpace, localName); }
public Statement getProperty(Resource s, Property p) { return model.getProperty(s, p); }
/** * Convert the Sesame URI to a Jena Property * @param theURI the sesame URI * @return the URI as a Jena property */ public static Property asJenaURI(URI theURI) { if (theURI == null) { return null; } else { return mInternalModel.getProperty(theURI.toString()); } }
private JSONArray getWorksheetHistory(Resource mappingResource) throws JSONException { Property hasTransformation = model.getProperty(Uris.KM_HAS_WORKSHEET_HISTORY_URI); NodeIterator transItr = model.listObjectsOfProperty(mappingResource, hasTransformation); while (transItr.hasNext()) { String commands = transItr.next().toString(); return new JSONArray(commands); } return new JSONArray(); }
public static boolean parseAskResult(final String resultURI) throws FileNotFoundException { if( resultURI.endsWith( "srx" ) ) { return XMLInput.booleanFromXML( new FileInputStream( resultURI.substring( 5 ) ) ); } else if( resultURI.endsWith( "ttl" ) || resultURI.endsWith( "rdf" ) ) { return FileManager .get() .loadModel( resultURI.substring( 5 ) ) .getProperty( null, ResourceFactory .createProperty( "http://www.w3.org/2001/sw/DataAccess/tests/result-set#boolean" ) ) .getBoolean(); } else { throw new RuntimeException( "Unknown format." ); } }
private SourceTypes getSourceType(Resource mappingResource) { Property sourceNameProp = model.getProperty(Uris.KM_SOURCE_TYPE_URI); Statement s = model.getProperty(mappingResource, sourceNameProp); String sourceType; if(s != null) { RDFNode node = s.getObject(); if(node != null && node.isLiteral()) { sourceType = node.asLiteral().getString(); return SourceTypes.valueOf(sourceType); } } return SourceTypes.CSV; }
private ATermList createList(Resource r) { if(r.equals(RDF.nil)) return ATermUtils.EMPTY_LIST; else if(!rawModel.contains(r, RDF.first)) { System.err.println("Invalid list structure: List " + r + " does not have a rdf:first property. Ignoring rest of the list."); return ATermUtils.EMPTY_LIST; } ATerm first = node2term(rawModel.getProperty(r, RDF.first).getObject()); Resource rest = rawModel.getProperty(r, RDF.rest).getResource(); return ATermUtils.makeList(first, createList(rest)); } // createList
private List<String> getVariables(Model model, Resource service_resource) { Property has_variable_property = model.getProperty(Namespaces.KARMA + "hasVariable"); List<String> variables = new ArrayList<>(); NodeIterator nodeIterator; RDFNode node; // hasAttribute nodeIterator = model.listObjectsOfProperty(service_resource, has_variable_property); while ( nodeIterator.hasNext()) { node = nodeIterator.next(); if (!node.isResource()) { logger.info("object of the hasAttribute property is not a resource."); continue; } variables.add(node.asResource().getLocalName()); } return variables; }
private List<String> getVariables(Model model, Resource source_resource) { Property has_variable_property = model.getProperty(Namespaces.KARMA + "hasVariable"); List<String> variables = new ArrayList<>(); NodeIterator nodeIterator = null; RDFNode node = null; // hasAttribute nodeIterator = model.listObjectsOfProperty(source_resource, has_variable_property); while ( nodeIterator.hasNext()) { node = nodeIterator.next(); if (!node.isResource()) { logger.info("object of the hasAttribute property is not a resource."); continue; } variables.add(node.asResource().getLocalName()); } return variables; }
private List<Attribute> getAttributes(Model model, Resource source_resource) { Property has_attribute_property = model.getProperty(Namespaces.KARMA + "hasAttribute"); List<Attribute> attList = new ArrayList<>(); NodeIterator nodeIterator = null; RDFNode node = null; // hasAttribute nodeIterator = model.listObjectsOfProperty(source_resource, has_attribute_property); while ( nodeIterator.hasNext()) { node = nodeIterator.next(); if (!node.isResource()) { logger.info("object of the hasAttribute property is not a resource."); continue; } attList.add(getSingleAttribute(model, node.asResource())); } return attList; }
private void createPredicateObjectMaps(Resource mappingResource, KR2RMLMapping kr2rmlMapping) throws JSONException { Property hasTrMapUri = model.getProperty(Uris.KM_HAS_TRIPLES_MAP_URI); // Get all the triple maps NodeIterator trMapsResItr = model.listObjectsOfProperty(mappingResource, hasTrMapUri); while (trMapsResItr.hasNext()) { // Add the predicate object maps addPredicateObjectMapsForTripleMap(trMapsResItr.next().asResource(), kr2rmlMapping); } }
private Attribute getSingleAttribute(Model model, Resource att_resource) { String att_id = ""; String att_name = ""; Property has_name_property = model.getProperty(Namespaces.KARMA + "hasName"); // attribute id att_id = att_resource.getLocalName(); logger.debug("attribute id: " + att_id); NodeIterator nodeIterator = null; RDFNode node = null; // attribute name nodeIterator = model.listObjectsOfProperty(att_resource, has_name_property); if (nodeIterator.hasNext() && (node = nodeIterator.next()).isLiteral()) { att_name = node.asLiteral().getString(); logger.debug("attribute name: " + att_name); } else logger.debug("attribute does not have a name."); Attribute att = new Attribute(att_id, att_resource.getNameSpace(), att_name, IOType.NONE, AttributeRequirement.NONE); return att; }
private void createGraphNodeToTriplesNodeMap(KR2RMLMapping kr2rmlMapping) throws FileNotFoundException, UnsupportedEncodingException{ StmtIterator itr = model.listStatements(null, model.getProperty(Uris.KM_NODE_ID_URI), (RDFNode)null); Resource subject; Map<String,String> graphNodeIdToTriplesMapIdMap = kr2rmlMapping.getAuxInfo().getGraphNodeIdToTriplesMapIdMap(); while (itr.hasNext()) { Statement subjMapToNodeIdStmt = itr.next(); String nodeId = subjMapToNodeIdStmt.getObject().toString(); subject = subjMapToNodeIdStmt.getSubject(); if (subject != null) { StmtIterator itr2 = model.listStatements(null, model.getProperty(Uris.RR_SUBJECTMAP_URI), subject); while (itr2.hasNext()) { String triplesMapId = itr2.next().getSubject().toString(); graphNodeIdToTriplesMapIdMap.put(nodeId, triplesMapId); } } } }
private List<Resource> createSubjectMaps(Resource mappingResource, KR2RMLMapping kr2rmlMapping) throws JSONException { List<Resource> subjectMapResources = new ArrayList<>(); Property hasTrMapUri = model.getProperty(Uris.KM_HAS_TRIPLES_MAP_URI); // Get all the triple maps NodeIterator trMapsResItr = model.listObjectsOfProperty(mappingResource, hasTrMapUri); while (trMapsResItr.hasNext()) { Resource trMapRes = trMapsResItr.next().asResource(); SubjectMap subjMap = addSubjectMapForTripleMap(trMapRes, kr2rmlMapping, subjectMapResources); // Add the Triples map TriplesMap trMap = new TriplesMap(trMapRes.getURI(), subjMap); kr2rmlMapping.getTriplesMapIndex().put(trMapRes.getURI(), trMap); kr2rmlMapping.addTriplesMap(trMap); kr2rmlMapping.getAuxInfo().getTriplesMapGraph().addTriplesMap(trMap); } return subjectMapResources; }
/***********************************/ @Test public void testGetInt() { String ns = "http://example/foo#"; ModelWrapper mw = modelWrapperFixture(); Resource foo = mw.getModel().getResource( ns + "foo" ); CommonNodeWrapper n = new CommonNodeWrapper( mw, foo ); // various ways of specifying p assertEquals( 42, n.getInt( mw.getModel().getProperty( ns+"p" ), -1 ) ); assertEquals( 42, n.getInt( ns+"p", -1 ) ); assertEquals( 42, n.getInt( "example:p", -1 ) ); // missing property assertEquals( -123, n.getInt( "example:not-here", -123 ) ); // node is not a resource CommonNodeWrapper l = new CommonNodeWrapper( mw, mw.getModel().createLiteral( "kermit" ) ); assertEquals( -1, l.getInt( "example:foo", -1 )); // value is not an int assertEquals( -111, n.getInt( "example:q", -111 )); }