private void validateComponentType(Property property, Resource resource, ComponentType... types) { if (resource == null) return; List<Resource> foundTypes = new ArrayList<Resource>(types.length); List<Resource> supportedTypes = new ArrayList<Resource>(types.length); for (ComponentType type: types) { supportedTypes.add(type.asResource()); MappingComponent value = mapping.getMappingComponent(resource, type); if (value != null) { foundTypes.add(type.asResource()); } } if (foundTypes.isEmpty()) { report.report(Problem.VALUE_NOT_OF_EXPECTED_TYPE, getContextResource(), property, supportedTypes.toArray(new Resource[supportedTypes.size()])); } else if (foundTypes.size() > 1) { report.report(Problem.CONFLICTING_TYPES, getContextResource(), property, foundTypes.toArray(new Resource[foundTypes.size()])); } }
public void generateEntities(Resource class_, TableName table, TemplateValueMaker iriTemplate, List<Identifier> blankNodeColumns) { log.info("Generating d2rq:ClassMap instance for table " + Microsyntax.toString(table)); ClassMap result = getClassMap(table); result.setComment("Table " + Microsyntax.toString(table)); if (iriTemplate == null) { result.setBNodeIdColumns(table.qualifyIdentifiers(blankNodeColumns)); } else { if (iriTemplate.columns().length == 0) { result.setComment(result.getComment() + "\nNOTE: Sorry, I don't know which columns to put into the d2rq:uriPattern\n" + "because the table doesn't have a primary key. Please specify it manually."); } result.setURIPattern(Microsyntax.toString(iriTemplate)); } if (class_ != null) { result.addClass(class_); if (generateDefinitionLabels) { result.addDefinitionLabel(model.createLiteral( Microsyntax.toString(table))); } } }
/** * Add to the model the decision statuses. * * @param Model the model we are currently working with */ public void addDecisionStatusToModel(Model model) { List<String> statusesList = Arrays.asList("Published", "Pending_Revocation", "Revoked", "Submitted"); for (String status : statusesList) { String[] statusDtls = hm.findDecisionStatusIndividual(status); /** statusResource **/ Resource statusResource = model.createResource(statusDtls[0], Ontology.decisionStatusResource); model.createResource(statusDtls[0], Ontology.conceptResource); /** configure prefLabel **/ statusResource.addProperty(Ontology.prefLabel, statusDtls[1], "el"); statusResource.addProperty(Ontology.prefLabel, statusDtls[2], "en"); } }
public Resource getAgentUri(VirtGraph graphOrgs, String vatId) { Resource agentUri = null; String queryUri = "PREFIX gr: <http://purl.org/goodrelations/v1#> " + "SELECT ?org ?vatId " + "FROM <" + QueryConfiguration.queryGraphOrganizations + "> " + "WHERE { " + "?org gr:vatID ?vatId . " + "FILTER ( ?vatId = \"" + vatId + "\"^^<http://www.w3.org/2001/XMLSchema#string> ) " + "}"; VirtuosoQueryExecution vqeUri = VirtuosoQueryExecutionFactory.create(queryUri, graphOrgs); ResultSet resultsUri = vqeUri.execSelect(); if (resultsUri.hasNext()) { QuerySolution result = resultsUri.nextSolution(); agentUri = result.getResource("org"); } vqeUri.close(); return agentUri; }
public Resource getAgentUriNoVat(VirtGraph graphOrgs, String vatId) { Resource agentUri = null; String queryUri = "PREFIX gr: <http://purl.org/goodrelations/v1#> " + "SELECT DISTINCT ?org " + "FROM <" + QueryConfiguration.queryGraphOrganizations + "> " + "WHERE { " + "?org rdf:type foaf:Organization . " + "FILTER (STR(?org) = \"http://linkedeconomy.org/resource/Organization/" + vatId + "\") . " + "}"; VirtuosoQueryExecution vqeUri = VirtuosoQueryExecutionFactory.create(queryUri, graphOrgs); ResultSet resultsUri = vqeUri.execSelect(); if (resultsUri.hasNext()) { QuerySolution result = resultsUri.nextSolution(); agentUri = result.getResource("org"); } vqeUri.close(); return agentUri; }
public Object open(Assembler ignore, Resource description, Mode ignore2) { if (!description.hasProperty(D2RQ.mappingFile)) { throw new D2RQException("Error in assembler specification " + description + ": missing property d2rq:mappingFile"); } if (!description.getProperty(D2RQ.mappingFile).getObject().isURIResource()) { throw new D2RQException("Error in assembler specification " + description + ": value of d2rq:mappingFile must be a URI"); } String mappingFileURI = ((Resource) description.getProperty(D2RQ.mappingFile).getObject()).getURI(); String resourceBaseURI = null; Statement stmt = description.getProperty(D2RQ.resourceBaseURI); if (stmt != null) { if (!stmt.getObject().isURIResource()) { throw new D2RQException("Error in assembler specification " + description + ": value of d2rq:resourceBaseURI must be a URI"); } resourceBaseURI = ((Resource) stmt.getObject()).getURI(); } return new ModelD2RQ(mappingFileURI, null, resourceBaseURI); }
/** * Add to the model the decision statuses. * * @param Model * the model we are currently working with */ public void addDecisionStatusToModel(Model model) { List<String> statusesList = Arrays.asList("Published", "Pending_Revocation", "Revoked", "Submitted"); for (String status : statusesList) { String[] statusDtls = hm.findDecisionStatusIndividual(status); /** statusResource **/ Resource statusResource = model.createResource(statusDtls[0], Ontology.decisionStatusResource); model.createResource(statusDtls[0], Ontology.conceptResource); /** configure prefLabel **/ statusResource.addProperty(Ontology.prefLabel, statusDtls[1], "el"); statusResource.addProperty(Ontology.prefLabel, statusDtls[2], "en"); } }
/** * Add to the model the Regular Acts. * * @param Model * the model we are currently working with */ public void addKanonistikiToModel(Model model) { List<String> regularList = Arrays.asList("Υπουργική Απόφαση", "Πράξη Γενικού Γραμματέα Αποκεντρωμένης Διοίκησης", "Πράξη Οργάνου Διοίκησης Ν.Π.Δ.Δ.", "Πράξη Οργάνου Διοίκησης ΟΤΑ Α’ και Β’ Βαθμού (και εποπτευόμενων φορέων τους)", "Λοιπές Κανονιστικές Πράξεις"); for (String regular : regularList) { String[] regularDtls = hm.findKanonistikiIndividual(regular); /** regulatoryResource **/ Resource regularResource = model.createResource(regularDtls[0], Ontology.regulatoryActResource); model.createResource(regularDtls[0], Ontology.conceptResource); /** configure prefLabel **/ regularResource.addProperty(Ontology.prefLabel, regularDtls[1], "el"); regularResource.addProperty(Ontology.prefLabel, regularDtls[2], "en"); } }
/** * Add to the model the Time Period. * * @param Model * the model we are currently working with */ public void addTimePeriodToModel(Model model) { List<String> timeList = Arrays.asList("Έτος", "ΝΟΕΜΒΡΙΟΣ", "ΟΚΤΩΒΡΙΟΣ", "Τρίμηνο"); for (String time : timeList) { String[] timeDtls = hm.findTimePeriodIndividual(time); /** timeResource **/ Resource timeResource = model.createResource(timeDtls[0], Ontology.timeResource); model.createResource(timeDtls[0], Ontology.conceptResource); /** configure prefLabel **/ timeResource.addProperty(Ontology.prefLabel, timeDtls[1], "el"); timeResource.addProperty(Ontology.prefLabel, timeDtls[2], "en"); } }
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { D2RServer server = D2RServer.fromServletContext(getServletContext()); server.checkMappingFileChanged(); if (request.getPathInfo() == null) { new ModelResponse(classMapListModel(), request, response).serve(); return; } String classMapName = request.getPathInfo().substring(1); Model resourceList = getClassMapLister().classMapInventory(classMapName); if (resourceList == null) { response.sendError(404, "Sorry, class map '" + classMapName + "' not found."); return; } Resource classMap = resourceList.getResource(server.baseURI() + "all/" + classMapName); Resource directory = resourceList.createResource(server.baseURI() + "all"); classMap.addProperty(RDFS.seeAlso, directory); classMap.addProperty(RDFS.label, "List of all instances: " + classMapName); directory.addProperty(RDFS.label, "D2R Server contents"); server.addDocumentMetadata(resourceList, classMap); new ModelResponse(resourceList, request, response).serve(); }
/** * Add to the model the budget types. * * @param Model * the model we are currently working with */ public void addBudgetTypeToModel(Model model) { List<String> budgetTypeList = Arrays.asList("Τακτικός Προϋπολογισμός", "Πρόγραμμα Δημοσίων Επενδύσεων", "Ίδια Έσοδα", "Συγχρηματοδοτούμενο Έργο"); for (String budgetType : budgetTypeList) { String[] budgetDtls = hm.findBudgetTypeIndividual(budgetType); /** statusResource **/ Resource statusResource = model.createResource(budgetDtls[0], Ontology.budgetCategoryResource); model.createResource(budgetDtls[0], Ontology.conceptResource); /** configure prefLabel **/ statusResource.addProperty(Ontology.prefLabel, budgetDtls[1], "el"); statusResource.addProperty(Ontology.prefLabel, budgetDtls[2], "en"); } }
private boolean handleDownload(String resourceURI, HttpServletResponse response, D2RServer server) throws IOException { Mapping m = D2RServer.retrieveSystemLoader(getServletContext()).getMapping(); for (Resource r: m.downloadMapResources()) { DownloadMap d = m.downloadMap(r); DownloadContentQuery q = new DownloadContentQuery(d, resourceURI); if (q.hasContent()) { response.setContentType(q.getMediaType() != null ? q.getMediaType() : "application/octet-stream"); InputStream is = q.getContentStream(); OutputStream os = response.getOutputStream(); final byte[] buffer = new byte[0x10000]; int read; do { read = is.read(buffer, 0, buffer.length); if (read>0) { os.write(buffer, 0, read); } } while (read >= 0); is.close(); q.close(); return true; } } return false; }
/** * @param problem * @param term * @param detailCode Optional error code; indicates a subclass of problems * @param details Optional string containing error details * @param contextResource May be null * @param contextProperty May be null */ public Message(Problem problem, MappingTerm term, String detailCode, String details, Resource contextResource, Property contextProperty) { this.problem = problem; this.subject = contextResource; this.predicates = contextProperty == null ? Collections.<Property>emptyList() : Collections.singletonList(contextProperty); this.objects = term == null ? Collections.<RDFNode>emptyList() : Collections.<RDFNode>singletonList(ResourceFactory.createPlainLiteral(term.toString())); this.detailCode = detailCode; this.details = details; this.cause = null; }
public static File findTemplateFile(D2RServer server, Property fileConfigurationProperty) { Resource config = server.getConfig().findServerResource(); if (config == null || !config.hasProperty(fileConfigurationProperty)) { return null; } String metadataTemplate = config.getProperty(fileConfigurationProperty) .getString(); String templatePath; if (metadataTemplate.startsWith(File.separator)) { templatePath = metadataTemplate; } else { File mappingFile = new File(server.getConfig() .getLocalMappingFilename()); String folder = mappingFile.getParent(); if (folder != null) { templatePath = folder + File.separator + metadataTemplate; } else { templatePath = metadataTemplate; } } File f = new File(templatePath); return f; }
@Test public void testContainment() { assertTrue(Containment.checkContainment(sampleCompany)); // add the manager of the research department also to the development // department (as employee) Resource craig = sampleCompany.getModel() .getResource(sampleCompany.NS_COMPANY + "craig"); sampleCompany.getModel() .getResource(sampleCompany.NS_COMPANY + "development") .getProperty(sampleCompany.EMPLOYEES) .getBag() .add(craig); assertFalse(Containment.checkContainment(sampleCompany)); }
public static boolean checkPrecedence(CompanyModel c) { StmtIterator stmtit = c.getModel().listStatements( new SimpleSelector(null, c.DEPTS, (RDFNode) null)); List<Resource> depts = new LinkedList<Resource>(); while (stmtit.hasNext()) { NodeIterator subDeptsIt = stmtit.next().getBag().iterator(); while (subDeptsIt.hasNext()) depts.add(subDeptsIt.next().asResource()); } for (Resource dept : depts) { // get manager's salary double managerSalary = dept.getProperty(c.MANAGER).getProperty( c.SALARY).getDouble(); NodeIterator employeeIt = dept.getProperty(c.EMPLOYEES).getBag() .iterator(); while (employeeIt.hasNext()) if (!(employeeIt.next().asResource().getProperty(c.SALARY) .getDouble() < managerSalary)) return false; } return true; }
private List<Statement> getUsage(Property property, Model model){ List<Statement> stmts = new ArrayList<Statement>(); String sparql = "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> " + "PREFIX owl: <http://www.w3.org/2002/07/owl#> " + "SELECT DISTINCT ?concept " + "WHERE{" + " {<" + property.getURI() + "> rdfs:domain ?concept} " + " UNION " + " { " + " ?concept rdfs:subClassOf|owl:equivalentClass ?restriction . " + " ?restriction a owl:Restriction; " + " owl:onProperty <" + property.getURI() + "> " + " } " + "}"; Query query = QueryFactory.create(sparql, Syntax.syntaxARQ); QueryExecution queryExecution = QueryExecutionFactory.create(query, model); ResultSet resultSet = queryExecution.execSelect(); while(resultSet.hasNext()){ QuerySolution querySolution = resultSet.next(); Resource concept = querySolution.getResource("concept"); stmts.add(new StatementImpl(property, usage, concept)); } return stmts; }
private List<Statement> getUsage(OntClass ontClass, Model model){ List<Statement> stmts = new ArrayList<Statement>(); try{ String sparql = "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> " + "PREFIX owl: <http://www.w3.org/2002/07/owl#> " + "SELECT DISTINCT ?concept " + "WHERE{" + " {?prop rdfs:range <" + ontClass.getURI() + ">; " + " rdfs:domain ?concept" + " }" + " UNION " + " { " + " ?concept rdfs:subClassOf|owl:equivalentClass ?restriction . " + " ?restriction a owl:Restriction; " + " ?p <" + ontClass.getURI() + "> " + " } " + "}"; Query query = QueryFactory.create(sparql, Syntax.syntaxARQ); QueryExecution queryExecution = QueryExecutionFactory.create(query, model); ResultSet resultSet = queryExecution.execSelect(); while(resultSet.hasNext()){ QuerySolution querySolution = resultSet.next(); Resource concept = querySolution.getResource("concept"); stmts.add(new StatementImpl(ontClass, usage, concept)); } } catch(Exception e){ log.error(e.getMessage(), e); } return stmts; }
public void testParseTranslationTable() { Resource r = addTranslationTableResource(); addTranslationResource(r, "foo", "bar"); Mapping mapping = new MapParser(this.model, null).parse(); TranslationTable table = mapping.translationTable(r); assertEquals(1, table.size()); Translator translator = table.translator(); assertEquals("bar", translator.toRDFValue("foo")); }
protected Resource findDatabaseResource() { ResIterator it = this.model.listSubjectsWithProperty(RDF.type, D2RQ.Database); if (!it.hasNext()) { return null; } return it.nextResource(); }
/** * Helper method to add definitions from a ResourceMap to its underlying resource * @param map * @param targetResource */ private void addDefinitions(ResourceMap map, Resource targetResource) { /* Infer rdfs:Class or rdf:Property type */ Statement s = vocabularyModel.createStatement(targetResource, RDF.type, map instanceof ClassMap ? RDFS.Class : RDF.Property); if (!this.vocabularyModel.contains(s)) this.vocabularyModel.add(s); /* Apply labels */ for (Literal propertyLabel: map.getDefinitionLabels()) { s = vocabularyModel.createStatement(targetResource, RDFS.label, propertyLabel); if (!this.vocabularyModel.contains(s)) this.vocabularyModel.add(s); } /* Apply comments */ for (Literal propertyComment: map.getDefinitionComments()) { s = vocabularyModel.createStatement(targetResource, RDFS.comment, propertyComment); if (!this.vocabularyModel.contains(s)) this.vocabularyModel.add(s); } /* Apply additional properties */ for (Resource additionalProperty: map.getAdditionalDefinitionProperties()) { s = vocabularyModel.createStatement(targetResource, (Property)(additionalProperty.getProperty(D2RQ.propertyName).getResource().as(Property.class)), additionalProperty.getProperty(D2RQ.propertyValue).getObject()); if (!this.vocabularyModel.contains(s)) this.vocabularyModel.add(s); } }
private void parseDownloadMaps() { Iterator<Individual> it = this.model.listIndividuals(D2RQ.DownloadMap); while (it.hasNext()) { Resource downloadMapResource = it.next(); DownloadMap downloadMap = new DownloadMap(downloadMapResource); parseResourceMap(downloadMap, downloadMapResource); parseDownloadMap(downloadMap, downloadMapResource); mapping.addDownloadMap(downloadMap); } }
protected Resource findServerResource() { ResIterator it = this.model.listSubjectsWithProperty(RDF.type, D2RConfig.Server); if (!it.hasNext()) { return null; } return it.nextResource(); }
private void readTermMap(TermMap termMap, Resource r) { termMap.getGraphMaps().addAll(getResources(r, RR.graphMap)); for (RDFNode graph: getRDFNodes(r, RR.graph)) { termMap.getGraphs().add(ConstantShortcut.create(graph)); } for (RDFNode class_: getRDFNodes(r, RR.class_, NodeType.IRI)) { termMap.getClasses().add(ConstantIRI.create(class_.asResource())); } checkTermMapType(r, RR.SubjectMap, RR.subjectMap); checkTermMapType(r, RR.PredicateMap, RR.predicateMap); checkTermMapType(r, RR.ObjectMap, RR.objectMap); checkTermMapType(r, RR.GraphMap, RR.graphMap); }
public long geometryTripleCount() throws FileNotFoundException{ HashSet<Statement> statements=new HashSet<Statement>(); for (Resource r:getAllGeometricResources()){ HashSet<Statement> sts=listRelatedStatements(r); statements.addAll(sts); } return statements.size(); }
@Test public void testEmptyTranslationTable() { Resource r = addTranslationTableResource(); Mapping mapping = new D2RQReader(this.model, null).getMapping(); TranslationTable table = mapping.translationTable(r); assertNotNull(table); assertEquals(0, table.size()); }
private void addListPropertyToGivenEntities(Resource r, OntProperty p, List<Resource> el) throws IOException { OntResource range = p.getRange(); if (range.isClass()) { OntResource listrange = getListContentType(range.asClass()); if (listrange.asClass().hasSuperClass(listModel.getOntClass(getListns() + "OWLList"))) { // if (logToFile) // bw.write("*OK 20*: Handling list of list" + "\r\n"); listrange = range; } for (int i = 0; i < el.size(); i++) { Resource r1 = el.get(i); Resource r2 = ResourceFactory.createResource(getBaseURI() + createLocalName(range.getLocalName() + "_" + IDcounter)); // Resource r2 = ResourceFactory.createResource(getBaseURI() + range.getLocalName() + "_" + IDcounter); // was // listrange getRdfWriter().triple(new Triple(r2.asNode(), RDF.type.asNode(), range.asNode())); // if (logToFile) // bw.write("*OK 14*: added property: " + r2.getLocalName() + " - rdf:type - " + range.getLocalName() + "\r\n"); IDcounter++; Resource r3 = ResourceFactory.createResource(getBaseURI() + createLocalName(range.getLocalName() + "_" + IDcounter)); // Resource r3 = ResourceFactory.createResource(getBaseURI() + range.getLocalName() + "_" + IDcounter); if (i == 0) { getRdfWriter().triple(new Triple(r.asNode(), p.asNode(), r2.asNode())); // if (logToFile) // bw.write("*OK 15*: added property: " + r.getLocalName() + " - " + p.getLocalName() + " - " + r2.getLocalName() + "\r\n"); } getRdfWriter().triple(new Triple(r2.asNode(), listModel.getOntProperty(getListns() + "hasContents").asNode(), r1.asNode())); // if (logToFile) // bw.write("*OK 16*: added property: " + r2.getLocalName() + " - " + "-hasContents-" + " - " + r1.getLocalName() + "\r\n"); if (i < el.size() - 1) { getRdfWriter().triple(new Triple(r2.asNode(), listModel.getOntProperty(getListns() + "hasNext").asNode(), r3.asNode())); // if (logToFile) // bw.write("*OK 17*: added property: " + r2.getLocalName() + " - " + "-hasNext-" + " - " + r3.getLocalName() + "\r\n"); } } } }
private void parsePropertyBridges() { StmtIterator stmts = this.model.listStatements(null, D2RQ.belongsToClassMap, (RDFNode) null); while (stmts.hasNext()) { Statement stmt = stmts.nextStatement(); ClassMap classMap = this.mapping.classMap(stmt.getResource()); Resource r = stmt.getSubject(); PropertyBridge bridge = new PropertyBridge(r); bridge.setBelongsToClassMap(classMap); parseResourceMap(bridge, r); parsePropertyBridge(bridge, r); } }
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; }
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); }
public void addDereferenceabilityMeasure(Model model, HttpResponse response) { Resource subject = model.createResource(response.getUri()); try { subject.addProperty(URI4URI.host, new URI(response.getUri()).getHost()); } catch (URISyntaxException e) { //We quietly ignore if we can't parse the URI } Resource measure = addMeasure(model, LDQM.IRIdereferenceability, subject); if (response.getStatusCode() >= 200 && response.getStatusCode() < 300 ) { measure.addLiteral(DQV.value, model.createTypedLiteral(true, XSDDatatype.XSDboolean)); measure.addLiteral(EVAL.hasLiteralValue, model.createTypedLiteral(true, XSDDatatype.XSDboolean)); } else { measure.addLiteral(DQV.value, model.createTypedLiteral(false, XSDDatatype.XSDboolean)); measure.addLiteral(EVAL.hasLiteralValue, model.createTypedLiteral(false, XSDDatatype.XSDboolean)); } Resource request = model.createResource(HTTP.Request); measure.addProperty(DCTerms.references, request); request.addLiteral(HTTP.methodName, response.getMethod()); request.addLiteral(HTTP.httpVersion, "1.1"); request.addLiteral(DCTerms.date, model.createTypedLiteral(DATE_FORMAT.format(response.getDate()),XSDDatatype.XSDdateTime)); Resource res = model.createResource(HTTP.Response); request.addProperty(HTTP.resp, res); if (response.getStatusCode() > 0) { res.addLiteral(HTTP.statusCodeValue, model.createTypedLiteral(response.getStatusCode(),XSDDatatype.XSDint)); } if (response.getReason() != null){ res.addLiteral(HTTP.reasonPhrase, response.getReason()); } }
public Resource addMeasure(Model model, Resource metric, Resource subject) { Resource measure = model.createResource(LDQM.MEASURE_PREFIX + UUID.randomUUID().toString()); measure.addProperty(RDF.type, DQV.QualityMeasurement); measure.addProperty(RDF.type, DAQ.Observation); measure.addProperty(RDF.type, EVAL.QualityValue); measure.addProperty(DQV.computedOn, subject); measure.addProperty(EVAL.obtainedFrom, evaluation); measure.addProperty(PROV.wasGeneratedBy, evaluation); measure.addProperty(DQV.isMeasurementOf, metric); measure.addProperty(EVAL.forMeasure, metric); measure.addLiteral(DAQ.isEstimate, false); return measure; }
public void testFindTwoUndefinedClasses() { final Model m = D2RQTestSuite.loadTurtle("vocab/two-undefined-types.ttl"); VocabularySummarizer vocab = new VocabularySummarizer(D2RQ.class); Collection<Resource> expected = new HashSet<Resource>() {{ this.add(m.createResource(D2RQ.NS + "Pint")); this.add(m.createResource(D2RQ.NS + "Shot")); }}; assertEquals(expected, vocab.getUndefinedClasses(m)); }
private Resource addTranslationResource(Resource table, String dbValue, String rdfValue) { Resource translation = this.model.createResource(); translation.addProperty(D2RQ.databaseValue, dbValue); translation.addProperty(D2RQ.rdfValue, rdfValue); table.addProperty(D2RQ.translation, translation); return translation; }
private void fillProperties(IFCVO ifcLineEntry, Resource r, OntClass cl) throws IOException, IfcDataFormatException { EntityVO evo = ent.get(ExpressReader.formatClassName(ifcLineEntry.getName())); if (evo == null) { throw IfcDataFormatException.nonExistingEntity(ifcLineEntry.getName(), "#"+ifcLineEntry.getLineNum()+"="+ifcLineEntry.getFullLineAfterNum()); } else { final String subject = createLocalName(evo.getName() + "_" + ifcLineEntry.getLineNum()); // final String subject = evo.getName() + "_" + // ifcLineEntry.getLineNum(); typeRemembrance = null; int attributePointer = 0; for (Object o : ifcLineEntry.getObjectList()) { if (Character.class.isInstance(o)) { if ((Character) o != ',') { LOGGER.log(Level.WARNING ,"We found a character that is not a comma in line: "+"#"+ifcLineEntry.getLineNum()+"="+ifcLineEntry.getFullLineAfterNum()); } } else if (String.class.isInstance(o)) { // if (logToFile) // bw.write("fillProperties 4 - fillPropertiesHandleStringObject(evo)" + "\r\n"); attributePointer = fillPropertiesHandleStringObject(r, evo, subject, attributePointer, o,ifcLineEntry); } else if (IFCVO.class.isInstance(o)) { // if (logToFile) // bw.write("fillProperties 5 - fillPropertiesHandleIfcObject(evo)" + "\r\n"); attributePointer = fillPropertiesHandleIfcObject(r, evo, attributePointer, o, ifcLineEntry); } else if (LinkedList.class.isInstance(o)) { // if (logToFile) // bw.write("fillProperties 6 - fillPropertiesHandleListObject(evo)" + "\r\n"); attributePointer = fillPropertiesHandleListObject(r, evo, attributePointer, o,ifcLineEntry); } // if (logToFile) // bw.flush(); } } // if (logToFile) // bw.flush(); }
public void generateEntities(Resource class_, TableName tableName, TemplateValueMaker iriTemplate, List<Identifier> blankNodeColumns) { TermMap subjectMap = (iriTemplate == null) ? createTermMap(toTemplate(tableName, blankNodeColumns), TermType.BLANK_NODE) : createTermMap(iriTemplate, null); if (class_ != null) { subjectMap.getClasses().add(ConstantIRI.create(class_)); } addTriplesMap(tableName, createBaseTableOrView(tableName), subjectMap); if (iriTemplate != null) { iriTemplates.put(tableName, iriTemplate); } }
private void initVocabularyModel() { this.vocabModel.setNsPrefix("rdf", RDF.getURI()); this.vocabModel.setNsPrefix("rdfs", RDFS.getURI()); this.vocabModel.setNsPrefix("owl", OWL.getURI()); this.vocabModel.setNsPrefix("dc", DC.getURI()); this.vocabModel.setNsPrefix("xsd", XSDDatatype.XSD + "#"); this.vocabModel.setNsPrefix("", this.vocabNamespaceURI); Resource r = ontologyResource(); r.addProperty(RDF.type, OWL.Ontology); r.addProperty(OWL.imports, this.vocabModel.getResource(dropTrailingHash(DC.getURI()))); r.addProperty(DC.creator, CREATOR); }
private void createVocabularyClass(RelationName tableName) { Resource r = classResource(tableName); r.addProperty(RDF.type, RDFS.Class); r.addProperty(RDF.type, OWL.Class); r.addProperty(RDFS.label, tableName.qualifiedName()); r.addProperty(RDFS.isDefinedBy, ontologyResource()); }
private Collection<Property> collectProperties(Model m, Resource r) { Collection<Property> result = new TreeSet<Property>(); StmtIterator it = r.listProperties(); while (it.hasNext()) { result.add(new Property(it.nextStatement(), false)); } it = m.listStatements(null, null, r); while (it.hasNext()) { result.add(new Property(it.nextStatement(), true)); } return result; }