Skip to content

Commit

Permalink
Delegate class URI minting to FacadeXNodeBuilder (see #380)
Browse files Browse the repository at this point in the history
Some code cleanup #373
  • Loading branch information
luigi-asprino committed Jun 21, 2023
1 parent 967b964 commit 8d6ede4
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public void triplify(Properties properties, FacadeXGraphBuilder builder) throws
try (XWPFDocument document = new XWPFDocument(is)) {
List<XWPFParagraph> paragraphs = document.getParagraphs();

builder.addType(dataSourceId, SPARQLAnythingConstants.ROOT_ID, namespace + "Document");
builder.addType(dataSourceId, SPARQLAnythingConstants.ROOT_ID, "Document");

int count = 1;
if (!mergeParagraphs) {
Expand All @@ -72,10 +72,10 @@ public void triplify(Properties properties, FacadeXGraphBuilder builder) throws
if (para.getStyle() != null) {
paragraphId = "/".concat(Triplifier.toSafeURIString(para.getStyle())).concat("/").concat(String.valueOf(count)) ;
builder.addType(dataSourceId, paragraphId,
namespace + Triplifier.toSafeURIString(para.getStyle()));
Triplifier.toSafeURIString(para.getStyle()));
} else {
paragraphId ="/paragraph/".concat(String.valueOf(count));
builder.addType(dataSourceId, paragraphId, namespace + "Paragraph");
builder.addType(dataSourceId, paragraphId, "Paragraph");
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ private String handleContainer(Node node){
String containerId = String.join("/", parentId , node.getClass().getSimpleName().toLowerCase() , Integer.toString(counter));
this.typeCounter.put(node.getClass(), counter);
this.builder.addContainer(dataSourceId, parentId, slot, containerId);
this.builder.addType(dataSourceId, containerId, XYZ_NS + node.getClass().getSimpleName());
this.builder.addType(dataSourceId, containerId, node.getClass().getSimpleName());
this.lastSlot.put(parentId, slot);
this.containers.put(node, containerId);
this.lastSlot.put(containerId, 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public boolean addContainer(String dataSourceId, String containerId, Integer slo
}

public boolean addType(String dataSourceId, String containerId, String typeId) {
return add(dataSourceId2node(dataSourceId), container2node(containerId, dataSourceId), RDF.type.asNode(), NodeFactory.createURI(typeId));
return add(dataSourceId2node(dataSourceId), container2node(containerId, dataSourceId), RDF.type.asNode(), key2predicate(typeId));
}

public boolean addType(String dataSourceId, String containerId, URI type) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ private Object extractCellValue(Cell cell, boolean evaluateFormulas) {

private void extractCompositeCellValue(String dataSourceId, String containerId, Cell cell, boolean evaluateFormulas, FacadeXGraphBuilder builder, String namespace) {
if (cell == null) return;
builder.addType(dataSourceId, containerId, namespace + cell.getCellType().toString());
builder.addType(dataSourceId, containerId, cell.getCellType().toString());
switch (cell.getCellType()) {
case BOOLEAN:
builder.addValue(dataSourceId, containerId, 1, cell.getBooleanCellValue());
Expand Down

0 comments on commit 8d6ede4

Please sign in to comment.