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

The following examples show how to use com.hp.hpl.jena.rdf.model.Property. 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 check out the related API usage on the sidebar.
Example 1
@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 Project: GeoTriples   Source File: D2RQTarget.java    License: Apache License 2.0 6 votes vote down vote up
public void generateColumnProperty(Property property,
		TableName table, Identifier column, DataType datatype) {
	PropertyBridge bridge = new PropertyBridge(getPropertyBridgeResource(table, column));
	bridge.setBelongsToClassMap(getClassMap(table));
	bridge.addProperty(property);
	if (generateDefinitionLabels) {
		bridge.addDefinitionLabel(model.createLiteral(
				table.getTable().getName() + " " + column.getName()));
	}
	bridge.setColumn(table.qualifyIdentifier(column));
	String datatypeURI = datatype.rdfType();
	if (datatypeURI != null && !XSD.xstring.getURI().equals(datatypeURI)) {
		// We use plain literals instead of xsd:strings, so skip
		// this if it's an xsd:string
		bridge.setDatatype(datatypeURI);
	}
	if (datatype.valueRegex() != null) {
		bridge.addValueRegex(datatype.valueRegex());
	}
}
 
Example 3
Source Project: GeoTriples   Source File: WP2N3JenaWriterPP.java    License: Apache License 2.0 6 votes vote down vote up
@Override
protected int countProperties(Resource r, Property p) 
{
	int numProp = 0 ;
	StmtIterator sIter = r.listProperties(p) ;
	for ( ; sIter.hasNext() ; )
	{
		Statement stmnt=sIter.nextStatement() ;
		if(! stmnt.getObject().toString().startsWith("null"))
		{
			numProp++ ;
		}
	}
	sIter.close() ;
	return numProp ;
}
 
Example 4
Source Project: GeoTriples   Source File: D2RQTarget.java    License: Apache License 2.0 6 votes vote down vote up
public void generateRefProperty(Property property, 
		TableName table, ForeignKey foreignKey) {
	Key localColumns = foreignKey.getLocalColumns();
	TableName referencedTable = foreignKey.getReferencedTable();
	PropertyBridge bridge = new PropertyBridge(
			getPropertyBridgeResource(table, localColumns));
	bridge.setBelongsToClassMap(getClassMap(table));
	bridge.addProperty(property);
	bridge.setRefersToClassMap(getClassMap(referencedTable));
	TableName target = referencedTable;
	if (referencedTable.equals(table)) {
		// Same-table join? Then we need to set up an alias for the table and join to that
		target = TableName.create(null, null, 
				Identifier.createDelimited( 
						Microsyntax.toString(referencedTable).replace('.', '_') + "__alias"));
		bridge.addAlias(new AliasDeclaration(referencedTable, target));
		foreignKey = new ForeignKey(foreignKey.getLocalColumns(), foreignKey.getReferencedColumns(), target);
	}
	for (Join join: Join.createFrom(table, foreignKey)) {
		bridge.addJoin(join);
	}
}
 
Example 5
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 6
@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 7
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 8
Source Project: LodView   Source File: SPARQLEndPoint.java    License: MIT License 6 votes vote down vote up
public Model extractLocalData(Model result, String IRI, Model m, List<String> queries) throws Exception {

		// System.out.println("executing query on IRI");
		Resource subject = result.createResource(IRI);
		for (String query : queries) {
			QueryExecution qe = QueryExecutionFactory.create(parseQuery(query, IRI, null, -1, null), m);
			try {
				ResultSet rs = qe.execSelect();
				List<Statement> sl = new ArrayList<Statement>();
				while (rs.hasNext()) {
					QuerySolution qs = rs.next();
					RDFNode subject2 = qs.get("s");
					RDFNode property = qs.get("p");
					RDFNode object = qs.get("o");
					result.add(result.createStatement(subject2 != null ? subject2.asResource() : subject, property.as(Property.class), object));
				}
				result.add(sl);
			} catch (Exception e) {
				e.printStackTrace();
				throw new Exception("error in query execution: " + e.getMessage());
			} finally {
				qe.close();
			}
		}
		return result;
	}
 
Example 9
Source Project: GeoTriples   Source File: MappingVisitor.java    License: Apache License 2.0 6 votes vote down vote up
public void visitComponentProperty(Property property, Resource resource, 
		ComponentType... types) { 
	// Do not recurse into parentTriplesMap to avoid cycles
	if (resource == null || RR.parentTriplesMap.equals(property)) return;
	for (ComponentType type: types) {
		MappingComponent component = mapping.getMappingComponent(resource, type);
		if (component == null) continue;
		switch (type) {
		case SUBJECT_MAP: ((TermMap) component).acceptAs(this, Position.SUBJECT_MAP); continue;
		case PREDICATE_MAP: ((TermMap) component).acceptAs(this, Position.PREDICATE_MAP); continue;
		case OBJECT_MAP: ((TermMap) component).acceptAs(this, Position.OBJECT_MAP); continue;
		case GRAPH_MAP: ((TermMap) component).acceptAs(this, Position.GRAPH_MAP); continue;
		default: component.accept(this);
		}
	}
}
 
Example 10
Source Project: GeoTriples   Source File: R2RMLWriter.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void visitTermProperty(Property property, List<TermMap> termMaps) {
	out.printProperty(property);
	out.printListStart();
	for(int i =0 ; i<termMaps.size(); ++i)
	{
		out.printPropertyStart();
		termMaps.get(i).accept(this);
		if(i<(termMaps.size()-1))
		{
			out.printComma();
		}
		out.printPropertyEndWithoutSemicolon();
	}
	out.printListEnd();
}
 
Example 11
@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 12
Source Project: GeoTriples   Source File: ConfigLoader.java    License: Apache License 2.0 6 votes vote down vote up
private Model loadMetadataTemplate(D2RServer server,
		ServletContext context, Property configurationFlag,
		String defaultTemplateName) {

	Model metadataTemplate;

	File userTemplateFile = MetadataCreator.findTemplateFile(server,
			configurationFlag);
	Model userResourceTemplate = MetadataCreator
			.loadTemplateFile(userTemplateFile);
	if (userResourceTemplate != null && userResourceTemplate.size() > 0) {
		metadataTemplate = userResourceTemplate;
		log.info("Using user-specified metadata template at '"
				+ userTemplateFile + "'");

	} else {
		// load default template
		InputStream drtStream = context.getResourceAsStream("/WEB-INF/"
				+ defaultTemplateName);
		log.info("Using default metadata template.");
		metadataTemplate = MetadataCreator.loadMetadataTemplate(drtStream);
	}

	return metadataTemplate;
}
 
Example 13
Source Project: GeoTriples   Source File: D2RQWriter.java    License: Apache License 2.0 6 votes vote down vote up
private void printTranslationTable(TranslationTable table) {
	printMapObject(table, D2RQ.TranslationTable);
	out.printURIProperty(D2RQ.href, table.getHref());
	out.printProperty(D2RQ.javaClass, table.getJavaClass());
	Iterator<Translation> it = table.getTranslations().iterator();
	List<Map<Property,RDFNode>> values = new ArrayList<Map<Property,RDFNode>>();
	while (it.hasNext()) {
		Translation translation = it.next();
		Map<Property,RDFNode> r = new LinkedHashMap<Property,RDFNode>();
		r.put(D2RQ.databaseValue, 
				ResourceFactory.createPlainLiteral(translation.dbValue()));
		r.put(D2RQ.rdfValue, 
				ResourceFactory.createPlainLiteral(translation.rdfValue()));
		values.add(r);
	}
	out.printCompactBlankNodeProperties(D2RQ.translation, values);
}
 
Example 14
Source Project: GeoTriples   Source File: D2RQValidator.java    License: Apache License 2.0 6 votes vote down vote up
protected void assertHasPrimarySpec(ResourceMap resourceMap, Property[] allowedSpecs) {
	List<Property> definedSpecs = new ArrayList<Property>();
	for (Property allowedProperty: Arrays.asList(allowedSpecs)) {
		if (hasPrimarySpec(resourceMap, allowedProperty)) {
			definedSpecs.add(allowedProperty);
		}
	}
	if (definedSpecs.isEmpty()) {
		StringBuffer error = new StringBuffer(resourceMap.toString());
		error.append(" needs one of ");
		for (int i = 0; i < allowedSpecs.length; i++) {
			if (i > 0) {
				error.append(", ");
			}
			error.append(PrettyPrinter.toString(allowedSpecs[i]));
		}
		error(error.toString(), D2RQException.RESOURCEMAP_MISSING_PRIMARYSPEC);
	}
	if (definedSpecs.size() > 1) {
		error(resourceMap + " can't have both " +
				PrettyPrinter.toString((Property) definedSpecs.get(0)) +
				" and " +
				PrettyPrinter.toString((Property) definedSpecs.get(1)),
				D2RQException.RESOURCEMAP_DUPLICATE_PRIMARYSPEC);
	}
}
 
Example 15
Source Project: GeoTriples   Source File: GeneralR2RMLTarget.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void generateHasGeometryPropertyWithTemplateTrick(Property property,
		TableName tableName, TemplateValueMaker iriTemplate) {
	TermMap subjectMap = (iriTemplate == null)
			? createTermMap(toTemplate(tableName, null), 
					TermType.BLANK_NODE) 
			: createTermMap(iriTemplate, null);
			
			if (iriTemplate != null) {
				iriTemplates.put(tableName, iriTemplate);
			}
			
	PredicateObjectMap objMap = createPredicateObjectMap(property, subjectMap);
	addPredicateObjectMap(tableName, objMap);
}
 
Example 16
Source Project: GeoTriples   Source File: GeneralR2RMLTarget.java    License: Apache License 2.0 5 votes vote down vote up
public void generateLinkProperty(Property property, TableName tableName,
		ForeignKey fk1, ForeignKey fk2) {
	TemplateValuedTermMap subjects = new TemplateValuedTermMap();
	incompleteLinkMaps.add(new IncompleteLinkMap(tableName, fk1, subjects));
	addTriplesMap(tableName, createBaseTableOrView(tableName), subjects);
	addPredicateObjectMap(tableName, 
			createPredicateObjectMap(property, 
					createRefObjectMap(tableName, fk2)));
}
 
Example 17
Source Project: EventCoreference   Source File: SemTime.java    License: 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 18
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 19
Source Project: GeoTriples   Source File: R2RMLWriter.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void visitSimpleProperty(Property property, Object value) {
	if (value instanceof TermType) {
		out.printProperty(property, ((TermType) value).asResource());
	} else if (value instanceof RDFNode) {
		out.printProperty(property, (RDFNode) value);
	}
}
 
Example 20
Source Project: EventCoreference   Source File: SemRelation.java    License: Apache License 2.0 5 votes vote down vote up
public void addToJenaDataSetSimpleWithoutName (HashMap<String, String> rename,  Model model) {

        if (rename.containsKey(this.getSubject())) { this.setSubject(rename.get(this.getSubject())); }
        if (rename.containsKey(this.getObject())) { this.setObject(rename.get(this.getObject())); }
        Resource subject = model.createResource(this.getSubject());
        Resource object = model.createResource(this.getObject());


        /// since we no longer distinguish places from actors, we now check the predicates for propbank AM-LOC
        /// if so we use sem:hasPlace otherwise we take the semType value from the hasSem predicate
        Property semProperty = null;
        for (int i = 0; i < predicates.size(); i++) {
            String predicate = predicates.get(i);
            semProperty = getSemRelationProperty(predicate);
            if (isTemporalSemRelationProperty(predicate)) {
                  //  subject.addProperty(semProperty, object);
            }
            else {
                if (!semProperty.getLocalName().equals(Sem.hasActor.getLocalName()) &&
                    !semProperty.getLocalName().equals(Sem.hasPlace.getLocalName())) {
                    predicate = getSimpleRoleRelation(predicate);
                    //System.err.println("predicate:"+predicate);
                    //predicate = getFramenetRoleRelation(predicates.get(i));
                    if (!predicate.isEmpty()) {
                        Property srlProperty = model.createProperty(predicate);
                        subject.addProperty(srlProperty, object);
                    }
                }
            }
        }

    }
 
Example 21
Source Project: GeoTriples   Source File: GeneralMappingStyle.java    License: Apache License 2.0 5 votes vote down vote up
public Property getColumnProperty(TableName tableName, Identifier column) {
	if (tableName.getTable().getCanonicalName().toString().endsWith("geometry")) {
		return model.createProperty("http://www.opengis.net/ont/geosparql#" + column.getCanonicalName());
		
	}
	return model.createProperty(vocabBaseIRI + 
			IRIEncoder.encode("has_" + column.getCanonicalName()));
}
 
Example 22
Source Project: GeoTriples   Source File: GeneralMappingStyle.java    License: Apache License 2.0 5 votes vote down vote up
public Property getCustomColumnProperty(TableName tableName, Identifier column,boolean isgeosparql_property) { //d2.1
	if (tableName.getTable().getCanonicalName().toString().endsWith("geometry") || isgeosparql_property) {
		return model.createProperty("http://www.opengis.net/ont/geosparql#" + column.getName());
		
	}
	//System.out.println(column.getName());
	return model.createProperty(vocabBaseIRI + 
			IRIEncoder.encode(column.getName()));
}
 
Example 23
Source Project: GeoTriples   Source File: R2RMLTarget.java    License: Apache License 2.0 5 votes vote down vote up
public void generateGeometryProperty(Property property, TableName tableName,
		Identifier column, DataType datatype){
	
	addPredicateObjectMap(tableName, 
			createPredicateObjectMap(property, 
					createTermMap(column, datatype)));
}
 
Example 24
Source Project: GeoTriples   Source File: MappingVisitor.java    License: Apache License 2.0 5 votes vote down vote up
public void visitTermProperty(Property property, MappingTerm term) {
	if (term == null) return;
	if (RR.subject.equals(property)) {
		((ConstantShortcut) term).acceptAs(this, Position.SUBJECT_MAP);
	} else if (RR.predicate.equals(property)) {
		((ConstantShortcut) term).acceptAs(this, Position.PREDICATE_MAP);
	} else if (RR.object.equals(property)) {
		((ConstantShortcut) term).acceptAs(this, Position.OBJECT_MAP);
	} else if (RR.graph.equals(property)) {
		((ConstantShortcut) term).acceptAs(this, Position.GRAPH_MAP);
	} else {
		term.accept(this);
	}
}
 
Example 25
Source Project: EventCoreference   Source File: SemObject.java    License: Apache License 2.0 5 votes vote down vote up
public void addToJenaOldBaileySimpleModel(SimpleTaxonomy simpleTaxonomy, HashMap<String, String> rename, Model model, Resource type) {
        Resource resource = model.createResource(this.getURI());
        Resource conceptResource = model.createResource(ResourcesUri.nwrontology+this.type);
        resource.addProperty(RDF.type, conceptResource);

        //// Top phrase
        String topLabel = this.getTopPhraseAsLabel();
        if (!topLabel.isEmpty()) {
            //Property property = model.createProperty(ResourcesUri.skos+SKOS.PREF_LABEL.getLocalName());
            //resource.addProperty(property, model.createLiteral(this.getTopPhraseAsLabel()));
            //// instead of

            if (type.equals(SemObject.EVENT) ) {
                resource = model.createResource(this.getURI() + "_" + topLabel);
                rename.put(this.getURI(), this.getURI() + "_" + topLabel);
            }
            for (int i = 0; i < phraseCounts.size(); i++) {
                PhraseCount phraseCount = phraseCounts.get(i);
                // resource.addProperty(RDFS.label, model.createLiteral(phraseCount.getPhraseCount()));
/*                if (!phraseCount.getPhrase().equalsIgnoreCase(getTopPhraseAsLabel()) && goodPhrase(phraseCount)) {
                    resource.addProperty(RDFS.label, model.createLiteral(phraseCount.getPhrase()));
                }*/
                if (goodPhrase(phraseCount)) {
                    resource.addProperty(RDFS.label, model.createLiteral(phraseCount.getPhrase()));
                }
            }
        }

        addAllConceptsToResourceForOldBailey(simpleTaxonomy, rename, resource, model);
        for (int i = 0; i < nafMentions.size(); i++) {
           NafMention nafMention = nafMentions.get(i);
           Property property = model.createProperty(ResourcesUri.gaf + "denotedBy");
           Resource targetResource = null;
           targetResource = model.createResource(nafMention.toStringFull());
           resource.addProperty(property, targetResource);
        }
    }
 
Example 26
Source Project: GeoTriples   Source File: R2RMLTarget.java    License: Apache License 2.0 5 votes vote down vote up
public void generateLinkProperty(Property property, TableName tableName,
		ForeignKey fk1, ForeignKey fk2) {
	TemplateValuedTermMap subjects = new TemplateValuedTermMap();
	incompleteLinkMaps.add(new IncompleteLinkMap(tableName, fk1, subjects));
	addTriplesMap(tableName, createBaseTableOrView(tableName), subjects);
	addPredicateObjectMap(tableName, 
			createPredicateObjectMap(property, 
					createRefObjectMap(tableName, fk2)));
}
 
Example 27
Source Project: GeoTriples   Source File: MappingValidator.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void visitComponent(PredicateObjectMap poMap) {
	if (poMap.getPredicateMaps().isEmpty() && poMap.getPredicates().isEmpty()) {
		report.report(Problem.REQUIRED_VALUE_MISSING,
				getContextResource(),
				new Property[]{RR.predicate, RR.predicateMap});
	}
	if (poMap.getObjectMaps().isEmpty() && poMap.getObjects().isEmpty()) { 
		report.report(Problem.REQUIRED_VALUE_MISSING,
				getContextResource(),
				new Property[]{RR.object, RR.objectMap});
	}
}
 
Example 28
Source Project: GeoTriples   Source File: OntologyTarget.java    License: Apache License 2.0 5 votes vote down vote up
public void generateColumnProperty(Property property, TableName table,
		Identifier column, DataType datatype) {
	Property p = property.inModel(model);
	p.addProperty(RDF.type, RDF.Property);
	p.addProperty(RDF.type, OWL.DatatypeProperty);
	p.addProperty(RDFS.label, getLabel(table, column));
	domains.put(p, table);
	if (datatype.rdfType() != null && XSD.xstring.getURI().equals(datatype.rdfType())) {
		p.addProperty(RDFS.range, model.getResource(datatype.rdfType()));
	}
	if (generatedOntology != null) {
		p.addProperty(RDFS.isDefinedBy, generatedOntology);
	}
}
 
Example 29
Source Project: GeoTriples   Source File: MappingValidator.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void visitComponentProperty(Property property, Resource resource, 
		ComponentType... types) {
	validateComponentType(property, resource, types);
	propertyStack.push(property);
	resourceStack.push(resource);
	super.visitComponentProperty(property, resource, types);
	resourceStack.pop();
	propertyStack.pop();
}
 
Example 30
Source Project: TripleGeo   Source File: RdbToRdf.java    License: GNU General Public License v3.0 5 votes vote down vote up
/**
 * 
 * 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);
  }
}