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

The following examples show how to use com.hp.hpl.jena.rdf.model.Property. 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: CQELSAarhusWeatherStream.java    From Benchmark with GNU General Public License v3.0 6 votes vote down vote up
@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 #2
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 #3
Source File: ConfigLoader.java    From GeoTriples with 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 #4
Source File: R2RMLWriter.java    From GeoTriples with 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 #5
Source File: D2RQWriter.java    From GeoTriples with 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 #6
Source File: MappingVisitor.java    From GeoTriples with 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 #7
Source File: WP2N3JenaWriterPP.java    From GeoTriples with 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 #8
Source File: D2RQTarget.java    From GeoTriples with 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 #9
Source File: D2RQValidator.java    From GeoTriples with 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 #10
Source File: D2RQTarget.java    From GeoTriples with 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 #11
Source File: SPARQLEndPoint.java    From LodView with 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 #12
Source File: CQELSAarhusParkingStream.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();
	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 #13
Source File: CSPARQLAarhusParkingStream.java    From Benchmark with GNU General Public License v3.0 6 votes vote down vote up
@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 #14
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 #15
Source File: OntologyTarget.java    From GeoTriples with 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 #16
Source File: MappingValidator.java    From GeoTriples with 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 #17
Source File: MapObject.java    From GeoTriples with Apache License 2.0 5 votes vote down vote up
protected void assertArgumentNotNull(Object object, Property property, int errorCode) {
	if (object != null) {
		return;
	}
	throw new D2RQException("Object for " + PrettyPrinter.toString(property) + 
			" not found at " + this, errorCode);
}
 
Example #18
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 #19
Source File: MapObject.java    From GeoTriples with Apache License 2.0 5 votes vote down vote up
protected void assertNotYetDefined(Object object, Property property, int errorCode) {
	if (object == null) {
		return;
	}
	throw new D2RQException("Duplicate " + PrettyPrinter.toString(property) + 
			" for " + this, errorCode);
}
 
Example #20
Source File: GeneralR2RMLTarget.java    From GeoTriples with 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 #21
Source File: SemTime.java    From EventCoreference with 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 #22
Source File: GeneralR2RMLTarget.java    From GeoTriples with 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 #23
Source File: D2RQWriter.java    From GeoTriples with Apache License 2.0 5 votes vote down vote up
private void printDatabase(Database db) {
	printMapObject(db, D2RQ.Database);
	out.printProperty(D2RQ.jdbcURL, db.getJdbcURL());
	out.printProperty(D2RQ.jdbcDriver, db.getJDBCDriver());
	out.printProperty(D2RQ.username, db.getUsername());
	out.printProperty(D2RQ.password, db.getPassword());
	for (String jdbcProperty: db.getConnectionProperties().stringPropertyNames()) {
		out.printProperty(
				JDBC.getProperty(jdbcProperty), 
				db.getConnectionProperties().getProperty(jdbcProperty));
	}
	out.printProperty(db.getResultSizeLimit() != Database.NO_LIMIT,
			D2RQ.resultSizeLimit, db.getResultSizeLimit());
	out.printProperty(db.getFetchSize() != Database.NO_FETCH_SIZE, 
			D2RQ.fetchSize, db.getFetchSize());
	out.printURIProperty(D2RQ.startupSQLScript, db.getStartupSQLScript());
	List<ColumnName> overriddenColumns = new ArrayList<ColumnName>(db.getColumnTypes().keySet());
	Collections.sort(overriddenColumns);
	for (ColumnName column: overriddenColumns) {
		Property property = null;
		switch (db.getColumnTypes().get(column)) {
			case CHARACTER: property = D2RQ.textColumn; break;
			case NUMERIC: property = D2RQ.numericColumn; break;
			case BOOLEAN: property = D2RQ.booleanColumn; break;
			case DATE: property = D2RQ.dateColumn; break;
			case TIMESTAMP: property = D2RQ.timestampColumn; break;
			case TIME: property = D2RQ.timeColumn; break;
			case BINARY: property = D2RQ.binaryColumn; break;
			case BIT: property = D2RQ.bitColumn; break;
			case INTERVAL: property = D2RQ.intervalColumn; break;
			default: continue;
		}
		out.printProperty(property, Microsyntax.toString(column));
	}
	out.printResourceEnd();
}
 
Example #24
Source File: PrettyTurtleWriter.java    From GeoTriples with Apache License 2.0 5 votes vote down vote up
private String toTurtleCompact(Map<Property, RDFNode> resource) {
	if (resource.isEmpty()) return "[]";
	StringBuilder result = new StringBuilder("[ ");
	for (Property property: resource.keySet()) {
		result.append(toTurtle(property));
		result.append(" ");
		result.append(toTurtle(resource.get(property)));
		result.append("; ");
	}
	result.append("]");
	return result.toString();
}
 
Example #25
Source File: R2RMLTarget.java    From GeoTriples with 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 #26
Source File: VocabularySummarizer.java    From GeoTriples with Apache License 2.0 5 votes vote down vote up
public Collection<Property> getUndefinedProperties(Model model) {
	Set<Property> result = new HashSet<Property>();
	StmtIterator it = model.listStatements();
	while (it.hasNext()) {
		Statement stmt = it.nextStatement();
		if (stmt.getPredicate().getURI().startsWith(namespace)
				&& !properties.contains(stmt.getPredicate())) {
			result.add(stmt.getPredicate());
		}
	}
	return result;
}
 
Example #27
Source File: R2RMLTarget.java    From GeoTriples with 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 #28
Source File: MappingVisitor.java    From GeoTriples with 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 #29
Source File: MappingValidator.java    From GeoTriples with 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 #30
Source File: SemObject.java    From EventCoreference with 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);
        }
    }