@Override public void processPropertyDocument(PropertyDocument propertyDocument) { try { this.rdfConverter.writePropertyDocument(propertyDocument); } catch (RDFHandlerException e) { // we cannot recover here throw new RuntimeException(e.toString(), e); } }
@Override public void close() { try { this.rdfWriter.finish(); } catch (RDFHandlerException e) { // we cannot recover here throw new RuntimeException(e.toString(), e); } try { this.output.close(); } catch (IOException e) { throw new RuntimeException(e.toString(), e); } }
@Override public void processItemDocument(ItemDocument itemDocument) { try { this.rdfConverter.writeItemDocument(itemDocument); } catch (RDFHandlerException e) { // we cannot recover here throw new RuntimeException(e.toString(), e); } }
@Override public Void visit(StringValue value) { ValueExportExtension<StringValue> vee = this.stringExportExtensions .get(this.currentPropertyIdValue.getIri()); if (vee != null) { try { vee.writeExtensionData(this.currentResource, this.currentPropertyIdValue, value, this.rdfWriter, this.owlDeclarationBuffer); } catch (RDFHandlerException e) { // give up; it's probably // impossible to continue anyway throw new RuntimeException(e.toString(), e); } } return null; }
@Override public void start() { try { this.rdfWriter.start(); this.rdfConverter.writeNamespaceDeclarations(); this.rdfConverter.writeBasicDeclarations(); } catch (RDFHandlerException e) { // we cannot recover here throw new RuntimeException(e.toString(), e); } }
throw new IOException(e.toString()); // Java 5 / Android compatibility
throw new IOException(e.toString()); // Java 5/Android compatibility
@Override public Void visit(ValueSnak snak) { String propertyUri = Vocabulary.getPropertyUri(snak.getPropertyId(), this.currentPropertyContext); URI property = this.rdfWriter.getUri(propertyUri); Value value = valueRdfConverter.getRdfValue(snak.getValue(), snak.getPropertyId(), this.simple); if (value == null) { logger.error("Could not serialize snak: missing value (Snak: " + snak.toString() + ")"); return null; } try { this.rdfWriter.writeTripleValueObject(this.currentSubject, property, value); } catch (RDFHandlerException e) { throw new RuntimeException(e.toString(), e); } this.exportExtensions.writeValueSnakExtensions(snak, this.currentSubject); return null; }
@Override public Void visit(NoValueSnak snak) { String rangeUri = getRangeUri(snak.getPropertyId()); if (rangeUri == null) { logger.error("Count not export NoValueSnak for property " + snak.getPropertyId().getId() + ": OWL range not known."); return null; } else if (!Vocabulary.OWL_THING.equals(rangeUri)) { rangeUri = Vocabulary.RDFS_LITERAL; } String propertyUri = Vocabulary.getPropertyUri(snak.getPropertyId(), this.currentPropertyContext); Resource bnode = this.rdfWriter.getFreshBNode(); addNoValuesRestriction(bnode, propertyUri, rangeUri); try { this.rdfWriter.writeTripleValueObject(this.currentSubject, RdfWriter.RDF_TYPE, bnode); } catch (RDFHandlerException e) { throw new RuntimeException(e.toString(), e); } return null; }
@Override public Void visit(SomeValueSnak snak) { String rangeUri = getRangeUri(snak.getPropertyId()); if (rangeUri == null) { logger.error("Count not export SomeValueSnak for property " + snak.getPropertyId().getId() + ": OWL range not known."); return null; } String propertyUri = Vocabulary.getPropertyUri(snak.getPropertyId(), this.currentPropertyContext); Resource bnode = this.rdfWriter.getFreshBNode(); addSomeValuesRestriction(bnode, propertyUri, rangeUri); try { this.rdfWriter.writeTripleValueObject(this.currentSubject, RdfWriter.RDF_TYPE, bnode); } catch (RDFHandlerException e) { throw new RuntimeException(e.toString(), e); } return null; }
void writeInstanceOfStatements(Resource subject, ItemDocument itemDocument) { for (StatementGroup statementGroup : itemDocument.getStatementGroups()) { if (!"P31".equals(statementGroup.getProperty().getId())) { continue; } for (Statement statement : statementGroup.getStatements()) { if (statement.getClaim().getMainSnak() instanceof ValueSnak && statement.getClaim().getQualifiers().size() == 0) { ValueSnak mainSnak = (ValueSnak) statement.getClaim() .getMainSnak(); Value value = this.valueRdfConverter .getRdfValue(mainSnak.getValue(), mainSnak.getPropertyId(), true); if (value == null) { logger.error("Could not serialize instance of snak: missing value (Snak: " + mainSnak.toString() + ")"); continue; } try { this.rdfWriter.writeTripleValueObject(subject, RdfWriter.RDF_TYPE, value); } catch (RDFHandlerException e) { throw new RuntimeException(e.toString(), e); } } } } }
RdfWriter.RDFS_SUBCLASS_OF, value); } catch (RDFHandlerException e) { throw new RuntimeException(e.toString(), e);