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

The following examples show how to use com.hp.hpl.jena.rdf.model.Resource. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may want to check out the right sidebar which shows the related API usage.
Example 1
Source Project: wandora   Source File: SparqlExtractor.java    License: 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 2
Source Project: Benchmark   Source File: RDFFileManager.java    License: 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 3
@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 4
Source Project: GeoTriples   Source File: WP2N3JenaWriterPP.java    License: 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 5
Source Project: GeoTriples   Source File: D2RQReader.java    License: 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 6
Source Project: GeoTriples   Source File: R2RMLWriter.java    License: 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 Project: GeoTriples   Source File: Message.java    License: 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 Project: EventCoreference   Source File: SemTime.java    License: Apache License 2.0 6 votes vote down vote up
public void addToJenaModelDocTimeInterval(Model model) {
    if (this.getPhraseCounts().size() > 0) {
        OwlTime owlTime = new OwlTime();
        owlTime.parsePublicationDate(getPhrase());
        owlTime.addToJenaModelOwlTimeInstant(model);

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

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

        Resource value = model.createResource(owlTime.getDateStringURI());
        Property property = model.createProperty(ResourcesUri.owltime + "inDateTime");
        resource.addProperty(property, value);
    }
}
 
Example 9
Source Project: xcurator   Source File: Mapping.java    License: 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 10
Source Project: GeoTriples   Source File: VocabularySummarizer.java    License: 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 11
Source Project: Benchmark   Source File: DataWrapper.java    License: 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 12
Source Project: xcurator   Source File: Property.java    License: 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 13
Source Project: anno4j   Source File: JenaSesameUtils.java    License: 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 14
Source Project: GeoTriples   Source File: R2RMLReader.java    License: 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 15
Source Project: Benchmark   Source File: RDFFileManager.java    License: GNU General Public License v3.0 5 votes vote down vote up
private static void createEPModel(Resource profile, Model m, EventDeclaration ed) throws NodeRemovalException {
	if (ed.getEp() != null) {
		EventPattern ep = ed.getEp();
		String rootId = ep.getRootId();
		Resource bNode = m.createResource();
		if (profile == null)
			profile = m.createResource("DummyService-" + UUID.randomUUID() + "-Profile");
		profile.addProperty(m.createProperty(cesPrefix + "hasPattern"), bNode);
		createSelections(bNode, m, ep);
		traverseToCreate(rootId, bNode, ep, m);
	}

}
 
Example 16
Source Project: GeoTriples   Source File: PrettyPrinter.java    License: Apache License 2.0 5 votes vote down vote up
public static String toString(RDFNode n) {
	if (n == null) return "null";
	if (n.isURIResource()) {
		Resource r = (Resource) n;
		return toString(r.asNode(), r.getModel());
	}
	return toString(n.asNode());
}
 
Example 17
Source Project: aliada-tool   Source File: RDFStoreDAO.java    License: GNU General Public License v3.0 5 votes vote down vote up
/**
 * It executes a SELECT SPARQL query on the SPARQL endpoint, 
 * to get the ambiguous discovered links of a source URI.
 *
 * @param ambiguousLink			a {@link eu.aliada.shared.rdfstore.AmbiguousLink} that contains the source URI.  
 * @param localRes				the source resource of the link.  
 * @param extResBegin			the beginning string of the target link.  
 * @param sparqlEndpointURI		the SPARQL endpoint URI.  
 * @param graphName 			the graphName, null in case of default graph.
 * @param user					the user name for the SPARQl endpoint.
 * @param password				the password for the SPARQl endpoint.
 * @param offset				causes the solutions generated to start after 
 *                              the specified number of solutions.
 * @param limit					upper bound on the number of solutions returned.
 * @since 2.0
 */
public void getSourceURIAmbiguousLinks(final AmbiguousLink ambiguousLink, final Resource localRes, final String extResBegin, final String sparqlEndpointURI, final String graphName, final String user, final String password) {
	final String query = "SELECT ?rel ?extRes FROM <" + graphName + "> " + 
			" WHERE {<" + ambiguousLink.getSourceURI() + "> ?rel ?extRes ." +
			" FILTER regex(?extRes, \"^" + extResBegin + "\", \"i\")" +
			" }";
	try {
		// Execute the query and obtain results
		final QueryExecution qexec = QueryExecutionFactory.sparqlService(
				sparqlEndpointURI, 
				QueryFactory.create(query), 
				auth(sparqlEndpointURI, user, password));
		qexec.setTimeout(2000, 5000);
		final ResultSet results = qexec.execSelect() ;
		while (results.hasNext())
		{
			final QuerySolution soln = results.nextSolution() ;
	    	final Resource extRes = soln.getResource("extRes");
           	final Resource relResType = soln.getResource("rel");
           	final Triple triple = new Triple(localRes.asNode(), relResType.asNode(), extRes.asNode());
	    	ambiguousLink.addLink(triple);
	    }
	    qexec.close() ;
	  } catch (Exception exception) {
		LOGGER.error(MessageCatalog._00035_SPARQL_FAILED, exception, query);
	}
}
 
Example 18
Source Project: GeoTriples   Source File: GeneralR2RMLTarget.java    License: Apache License 2.0 5 votes vote down vote up
private ReferencingObjectMap createRefObjectMap(TableName tableName, ForeignKey foreignKey) {
	ReferencingObjectMap result = new ReferencingObjectMap();
	result.setParentTriplesMap(getTriplesMapResource(foreignKey.getReferencedTable()));
	for (int i = 0; i < foreignKey.getLocalColumns().size(); i++) {
		Join join = new Join();
		join.setChild(ColumnNameR2RML.create(
				foreignKey.getLocalColumns().get(i), vendor));
		join.setParent(ColumnNameR2RML.create(
				foreignKey.getReferencedColumns().get(i), vendor));
		Resource joinResource = model.createResource();
		mapping.joins().put(joinResource, join);
		result.getJoinConditions().add(joinResource);
	}
	return result;
}
 
Example 19
@Override
public ConceptualDomainRelationshipResource getDescribedByConceptualDomainRelationship() {
	Resource describedByConceptualDomainRelationship = getPropertyResourceValue(mdrDatabase
			.getVocabulary().describedByConceptualDomainRelationship);
	return new ConceptualDomainRelationshipImpl(
			describedByConceptualDomainRelationship, mdrDatabase);
}
 
Example 20
Source Project: GeoTriples   Source File: GeneralR2RMLTarget.java    License: 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 21
Source Project: Benchmark   Source File: DataWrapper.java    License: 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 22
Source Project: GeoTriples   Source File: R2RMLReader.java    License: 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 23
Source Project: GeoTriples   Source File: R2RMLReader.java    License: 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 24
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 25
Source Project: GeoTriples   Source File: GeneralMappingStyle.java    License: 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 26
Source Project: GeoTriples   Source File: OntologyTarget.java    License: 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;
}
 
Example 27
Source Project: TripleGeo   Source File: ShpConnector.java    License: 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 28
@Override
public DerivationRuleResource getApplyingDerivationRuleApplication() {
	Resource applyingDerivationRuleApplication = getPropertyResourceValue(mdrDatabase
			.getVocabulary().applyingDerivationRuleApplication);
	return new DerivationRuleImpl(applyingDerivationRuleApplication,
			mdrDatabase);
}
 
Example 29
Source Project: semweb4j   Source File: ModelImplJena.java    License: 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 30
Source Project: GeoTriples   Source File: AssemblerExample.java    License: 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();
}