com.hp.hpl.jena.rdf.model.Resource Java Examples

The following examples show how to use com.hp.hpl.jena.rdf.model.Resource. 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: Mapping.java    From xcurator with Apache License 2.0 6 votes vote down vote up
public static Set<String> getAllTypes(Model model, String typePrefix) {
    Resource rootResource = model.createResource(typePrefix);

    com.hp.hpl.jena.rdf.model.Property classProperty = model.createProperty("http://dblab.cs.toronto.edu/project/xcurator/0.1#classes");
    Bag classBag = model.createBag("http://dblab.cs.toronto.edu/project/xcurator/0.1#classBag");
    model.add(rootResource, classProperty, classBag);

    Set<String> ret = new HashSet<String>();

    NodeIterator iterator = classBag.iterator();
    while (iterator.hasNext()) {
        Resource resource = (Resource) iterator.next();
        ret.add(resource.getURI());
    }

    return ret;
}
 
Example #2
Source File: Property.java    From xcurator with Apache License 2.0 6 votes vote down vote up
public Resource createRDFProperty(
        Model model, Resource parentResource, Element item, Document dataDoc) throws XPathExpressionException {

    com.hp.hpl.jena.rdf.model.Property jenaProperty = getJenaProperty(model);
    Resource res = null;
    NodeList nodeList = XMLUtils.getNodesByPath(path, item, dataDoc);
    for (int i = 0; i < nodeList.getLength(); i++) {
        Node node = nodeList.item(i);
        String value = node.getTextContent();
        res = parentResource.addProperty(jenaProperty, value);
    }

    for (String uri : ontologyTypes) {
        jenaProperty.addProperty(OWL.equivalentProperty, model.createResource(uri));
    }

    return res;
}
 
Example #3
Source File: D2RQReader.java    From GeoTriples with Apache License 2.0 6 votes vote down vote up
private void parseConfiguration() {
	Iterator<Individual> it = this.model.listIndividuals(D2RQ.Configuration);
	if (it.hasNext()) {
		Resource configResource = it.next();
		Configuration configuration = new Configuration(configResource);
		StmtIterator stmts = configResource.listProperties(D2RQ.serveVocabulary);
		while (stmts.hasNext()) {
			configuration.setServeVocabulary(stmts.nextStatement().getBoolean());
		}			
		stmts = configResource.listProperties(D2RQ.useAllOptimizations);
		while (stmts.hasNext()) {
			configuration.setUseAllOptimizations(stmts.nextStatement().getBoolean());
		}			
		this.mapping.setConfiguration(configuration);

		if (it.hasNext())
			throw new D2RQException("Only one configuration block is allowed");
	}
}
 
Example #4
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 #5
Source File: SparqlExtractor.java    From wandora with GNU General Public License v3.0 6 votes vote down vote up
public Topic solveSubjectRoleFor(Property predicate, Resource subject, TopicMap map) {
    if(map == null) return null;
    RDF2TopicMapsMapping[] mappings = null; // getMappings();
    String predicateString = predicate.toString();
    String subjectString = subject.toString();
    String si = RDF2TopicMapsMapping.DEFAULT_SUBJECT_ROLE_SI;
    String bn = RDF2TopicMapsMapping.DEFAULT_SUBJECT_ROLE_BASENAME;
    T2<String, String> mapped = null;
    if(mappings != null) {
        for(int i=0; i<mappings.length; i++) {
            mapped = mappings[i].solveSubjectRoleFor(predicateString, subjectString);
            if(mapped.e1 != null && mapped.e2 != null) {
                si = mapped.e1;
                bn = mapped.e2;
                break;
            }
        }
    }
    return getOrCreateTopic(map, si, bn);
}
 
Example #6
Source File: R2RMLWriter.java    From GeoTriples with Apache License 2.0 6 votes vote down vote up
@Override
public void visitComponentProperty(Property property, Resource resource,
		ComponentType... types) {
	if (resource == null) return;
	if (property == null) {
		out.printResourceStart(resource);
		super.visitComponentProperty(property, resource, types);
		out.printResourceEnd();
	} else if (resource.isAnon()) {
		//boolean isRefObjectMap = property.equals(RR.objectMap) && 
		//		mapping.referencingObjectMaps().has(resource);
		//d2.1
		boolean isRefObjectMap = property.equals(RR.objectMap);
		out.printPropertyStart(property, 
				COMPACT_PROPERTIES.contains(property) && !isRefObjectMap);
		super.visitComponentProperty(property, resource, types);
		out.printPropertyEnd();
	} else {
		out.printProperty(property, resource);
	}
}
 
Example #7
Source File: Message.java    From GeoTriples with Apache License 2.0 6 votes vote down vote up
/**
 * @param problem
 * @param subject May be null
 * @param predicates May be null
 * @param objects May be null
 */
public Message(Problem problem, Resource subject,
		Property[] predicates, RDFNode[] objects) {
	this.problem = problem;
	this.subject = subject;
	this.predicates = 
		predicates == null 
				? Collections.<Property>emptyList() 
				: Arrays.asList(predicates);
	Collections.sort(this.predicates, RDFComparator.getRDFNodeComparator());
	this.objects = 
		objects == null 
				? Collections.<RDFNode>emptyList() 
				: Arrays.asList(objects);
	Collections.sort(this.objects, RDFComparator.getRDFNodeComparator());
	this.detailCode = null;
	this.details = null;
}
 
Example #8
Source File: WP2N3JenaWriterPP.java    From GeoTriples with Apache License 2.0 6 votes vote down vote up
@Override
protected void writePropertiesForSubject(Resource subj, ClosableIterator<Property> iter)
   {
       // For each property.

	for (; iter.hasNext();)
       {
           Property property = iter.next();
           
           int size=countProperties(subj, property);
           if(size==0) //dimis
           {
           	continue;
           }

           // Object list
           writeObjectList(subj, property);
           
           
           if (iter.hasNext())
               out.println(" ;");
       }
       iter.close();
   }
 
Example #9
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 #10
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 #11
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 #12
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 #13
Source File: GeometryParametersTerms.java    From GeoTriples with Apache License 2.0 5 votes vote down vote up
public void acceptAs(MappingVisitor visitor, Position position) {
	visitor.visitComponent(this, position);
	if (position == Position.SUBJECT_MAP) {
		for (ConstantIRI iri: classes) {
			visitor.visitTermProperty(RR.class_, iri);
		}
		for (Resource graphMap: graphMaps) {
			visitor.visitComponentProperty(RR.graphMap, graphMap, ComponentType.GRAPH_MAP);
		}
		for (ConstantShortcut graph: graphs) {
			visitor.visitTermProperty(RR.graph, graph);
		}
	}
	
}
 
Example #14
Source File: GeneralMappingStyle.java    From GeoTriples with Apache License 2.0 5 votes vote down vote up
public Resource getTableClass(TableName tableName) {
		if (tableName.getTable().getCanonicalName().endsWith("geometry")) {
			return model.createResource("http://www.opengis.net/ont/geosparql#" + "Geometry");
			
		}
//		return model.createResource(vocabBaseIRI + 
//				IRIEncoder.encode(stringMaker.toString(tableName)));
		
		return model.createResource(vocabBaseIRI + tableName.getTable().getName());
	}
 
Example #15
Source File: ConceptualDomainRelationshipAssociationImpl.java    From semanticMDR with GNU General Public License v3.0 5 votes vote down vote up
@Override
public ConceptualDomainRelationshipResource getDescribedByConceptualDomainRelationship() {
	Resource describedByConceptualDomainRelationship = getPropertyResourceValue(mdrDatabase
			.getVocabulary().describedByConceptualDomainRelationship);
	return new ConceptualDomainRelationshipImpl(
			describedByConceptualDomainRelationship, mdrDatabase);
}
 
Example #16
Source File: JenaSesameUtils.java    From anno4j with Apache License 2.0 5 votes vote down vote up
/**
 * Convert the given Jena node as a Sesame Value
 * @param theNode the Jena node to convert
 * @return the jena node as a Sesame Value
 */
public static Value asSesameValue(RDFNode theNode) {
    if (theNode == null) {
        return null;
    }
    else if (theNode.canAs(Literal.class)) {
        return asSesameLiteral(theNode.as(Literal.class));
    }
    else {
        return asSesameResource(theNode.as(Resource.class));
    }
}
 
Example #17
Source File: R2RMLReader.java    From GeoTriples with Apache License 2.0 5 votes vote down vote up
private PredicateObjectMap createPredicateObjectMap(Resource r) {
	PredicateObjectMap result = new PredicateObjectMap();
	result.getPredicateMaps().addAll(getResources(r, RR.predicateMap));
	for (RDFNode predicate: getRDFNodes(r, RR.predicate)) {
		result.getPredicates().add(ConstantShortcut.create(predicate));
	}
	result.getObjectMaps().addAll(getResources(r, RR.objectMap));
	//d2.1
	//create the transformation
	/*for(Resource x:result.getObjectMaps())
	{
		for(Resource fun:getResources(x,RRX.function))
		{
			GeometryFunction gf = new GeometryFunction();
			
			List<Resource> temp=getResources(fun, RRX.function);
			List<Resource> temp2=getResources(fun, RRX.argumentMap);
			
			gf.setFunction(ConstantIRI.create(getResources(fun, RRX.function).get(0).getURI()));
			
			gf.getObjectMaps().addAll(getResources(fun, RRX.argumentMap));
			mapping.gfunctions().put(fun, gf);
		}
	}*/
			
	
	
	for (RDFNode object: getRDFNodes(r, RR.object)) {
		result.getObjects().add(ConstantShortcut.create(object));
	}
	result.getGraphMaps().addAll(getResources(r, RR.graphMap));
	for (RDFNode graph: getRDFNodes(r, RR.graph)) {
		result.getGraphs().add(ConstantShortcut.create(graph));
	}
	
	
	return result;
}
 
Example #18
Source File: DecompositionRDFWriter.java    From TableDisentangler with GNU General Public License v3.0 5 votes vote down vote up
public void AddCell(String StubValueS,String[] SubHeadings,String valueS, String CellTypeS,String[] HeaderS,String Head00S, int Row, int Columnt )
{
	String CellID = UUID.randomUUID().toString();
	Resource CellS = model.createResource(ArticleDefault+"Cell-"+CellID);
	model.add(CellS,CellValue,valueS);
	model.add(CellS,CellType,CellTypeS);
	Resource NavigationalPath = model.createResource();
	try{
	model.add(NavigationalPath,Head00,Head00S);
	}catch(Exception ex)
	{
		ex.printStackTrace();
	}
	if(HeaderS!=null)
	for(int i = 0;i<HeaderS.length;i++)
	{
		if(HeaderS[i]!=null)
			model.add(NavigationalPath,CellHeader,HeaderS[i]);
	}
	Resource Stub = model.createResource();
	model.add(Stub,CellStubValue,StubValueS);
	if(SubHeadings!=null)
	for(int i=0;i<SubHeadings.length;i++)
	{
		if(SubHeadings[i]!=null)
			model.add(Stub,CellSubheadeing,SubHeadings[i]);
	}
	model.add(NavigationalPath,CellStub,Stub);
	model.add(CellS,HasNavigationalPath,NavigationalPath);
	model.add(CellS,CellColumn,Columnt+"");
	model.add(CellS,CellRow,Row+"");
	model.add(currentTable,Cell,CellS);
	currentCell = CellS;
}
 
Example #19
Source File: QueryHelper.java    From ldp4j with Apache License 2.0 5 votes vote down vote up
public Resource resource(String binding) {
	if(!this.solution.contains(binding)) {
		return null;
	}
	RDFNode node = this.solution.get(binding);
	if(!node.canAs(Resource.class)) {
		throw new IllegalStateException("Binding '"+binding+"' is not a resource");
	}
	return node.asResource();
}
 
Example #20
Source File: PageServlet.java    From GeoTriples with Apache License 2.0 5 votes vote down vote up
private Map<String, String> classmapLinks(Resource resource) {
	Map<String, String> result = new HashMap<String, String>();
	D2RServer server = D2RServer.fromServletContext(getServletContext());
	for (String name: server.getMapping().getResourceCollectionNames(resource.asNode())) {
		result.put(name, server.baseURI() + "directory/" + name);
	}
	return result;
}
 
Example #21
Source File: ShpConnector.java    From TripleGeo with GNU General Public License v3.0 5 votes vote down vote up
/**
 * 
 * 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 #22
Source File: GeneralR2RMLTarget.java    From GeoTriples with Apache License 2.0 5 votes vote down vote up
private void addTriplesMap(TableName tableName, LogicalTable table, TermMap subjectMap) {
	Resource tableResource = model.createResource();
	mapping.logicalTables().put(tableResource, table);

	Resource subjectMapResource = model.createResource();
	mapping.termMaps().put(subjectMapResource, subjectMap);

	Resource triplesMapResource = getTriplesMapResource(tableName);
	TriplesMap map = new TriplesMap();
	map.setLogicalTable(tableResource);
	map.setSubjectMap(subjectMapResource);
	mapping.triplesMaps().put(triplesMapResource, map);
}
 
Example #23
Source File: ClassMapServlet.java    From GeoTriples with 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 #24
Source File: AssemblerExample.java    From GeoTriples with Apache License 2.0 5 votes vote down vote up
public static void main(String[] args) {
	// Load assembler specification from file
	Model assemblerSpec = FileManager.get().loadModel("doc/example/assembler.ttl");
	
	// Get the model resource
	Resource modelSpec = assemblerSpec.createResource(assemblerSpec.expandPrefix(":myModel"));
	
	// Assemble a model
	Model m = Assembler.general.openModel(modelSpec);
	
	// Write it to System.out
	m.write(System.out);

	m.close();
}
 
Example #25
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 #26
Source File: ModelImplJena.java    From semweb4j with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public void addStatement(org.ontoware.rdf2go.model.node.Resource subject, URI predicate,
        org.ontoware.rdf2go.model.node.Node object) throws ModelRuntimeException {
	assertModel();
	try {
		log.debug("adding a statement (" + subject + "," + predicate + "," + object + ")");
		this.modificationCount++;
		if(!(object instanceof DatatypeLiteral)) {
			this.jenaModel.getGraph().add(
			        new Triple(TypeConversion.toJenaNode(subject, this.jenaModel),
			                TypeConversion.toJenaNode(predicate, this.jenaModel),
			                TypeConversion.toJenaNode(object, this.jenaModel)));
		} else
		// DatatypeLiteral
		{
			// build Resources/Literals
			Resource s = null;
			if(subject instanceof URI) {
				s = this.jenaModel.createResource(subject.toString());
			} else
			// subject is a BlankNode
			{
				s = this.jenaModel.createResource(((Node)((AbstractBlankNodeImpl)subject)
				        .getUnderlyingBlankNode()).getBlankNodeId());
			}
			
			Property p = this.jenaModel.createProperty(predicate.toString());
			
			String datatypeValue = ((DatatypeLiteral)object).getValue();
			String datatypeURI = ((DatatypeLiteral)object).getDatatype().toString();
			Literal o = this.jenaModel.createTypedLiteral(datatypeValue, datatypeURI);
			
			// Add the statement to the model
			this.jenaModel.add(s, p, o);
		}
	} catch(BadURIException e) {
		throw new ModelRuntimeException(e);
	}
}
 
Example #27
Source File: DataElementDerivationImpl.java    From semanticMDR with GNU General Public License v3.0 5 votes vote down vote up
@Override
public DerivationRuleResource getApplyingDerivationRuleApplication() {
	Resource applyingDerivationRuleApplication = getPropertyResourceValue(mdrDatabase
			.getVocabulary().applyingDerivationRuleApplication);
	return new DerivationRuleImpl(applyingDerivationRuleApplication,
			mdrDatabase);
}
 
Example #28
Source File: R2RMLReader.java    From GeoTriples with Apache License 2.0 5 votes vote down vote up
public List<Resource> getResources(Resource r, Property p, NodeType acceptableNodeTypes) {
	List<Resource> result = new ArrayList<Resource>();
	for (RDFNode node: getRDFNodes(r, p, acceptableNodeTypes)) {
		result.add(node.asResource());
	}
	return result;
}
 
Example #29
Source File: R2RMLReader.java    From GeoTriples with Apache License 2.0 5 votes vote down vote up
public List<String> getStrings(Resource r, Property p) {
	List<String> result = new ArrayList<String>();
	for (RDFNode node: getRDFNodes(r, p, NodeType.STRING_LITERAL)) {
		result.add(node.asLiteral().getLexicalForm());
	}
	return result;
}
 
Example #30
Source File: OntologyTarget.java    From GeoTriples with Apache License 2.0 5 votes vote down vote up
public 	void init(String baseIRI, Resource generatedOntology, 
		boolean serveVocabulary, boolean generateDefinitionLabels) {
	Resource ont = generatedOntology.inModel(model);
	ont.addProperty(RDF.type, OWL.Ontology);
	ont.addProperty(OWL.imports, 
			model.getResource(MappingGenerator.dropTrailingHash(DC.getURI())));
	ont.addProperty(DC.creator, CREATOR);
	this.generatedOntology = ont;
}