Skip to content

Commit

Permalink
eclipse-rdf4jGH-5058: additional parser code (WIP)
Browse files Browse the repository at this point in the history
  • Loading branch information
barthanssens committed Jul 15, 2024
1 parent 489756f commit b486a02
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ private int getAboutIndex(String aboutURL, CellParser[] cellParsers) {
}

/**
* Return root node for standard mode
* Create tablegroup statement and return root node
*
* @param handler
* @return
Expand All @@ -355,7 +355,7 @@ private Resource generateTablegroupNode(RDFHandler handler) {
}

/**
* Return root node for standard mode
* Create table statements and return table node
*
* @param handler
* @return
Expand All @@ -368,7 +368,7 @@ private Resource generateTableNode(RDFHandler handler, Resource rootNode) {
}

/**
* Return root node for standard mode
* Create row statements and return row node
*
* @param handler
* @return
Expand All @@ -382,6 +382,22 @@ private Resource generateRowNode(RDFHandler handler, Resource tableNode, Resourc
return node;
}

/**
* Check which cellparsers have placeholders that need to be replaced
*
* @param cellParsers
* @return
*/
private boolean[] havePlaceholders(CellParser[] cellParsers) {
boolean[] placeholders = new boolean[cellParsers.length];

for (int i = 0; i < cellParsers.length; i++) {
placeholders[i] &= (cellParsers[i].getAboutPlaceholders() != null);
placeholders[i] &= (cellParsers[i].getValuePlaceholders() != null);
}
return null;
}

/**
* Parse a CSV file
*
Expand All @@ -398,6 +414,8 @@ private void parseCSV(Model metadata, RDFHandler handler, URI csvFile, CellParse
int aboutIndex = getAboutIndex(aboutURL, cellParsers);
String placeholder = (aboutIndex > -1) ? "{" + cellParsers[aboutIndex].getName() + "}" : null;

boolean[] placeholders = havePlaceholders(cellParsers);

LOGGER.info("Parsing {}", csvFile);

Charset encoding = getEncoding(metadata, table);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,15 @@ public void setAboutUrl(String aboutUrl) {
this.aboutPlaceholders = getPlaceholders(aboutUrl);
}

/**
* Get about placeholders
*
* @return
*/
public String[] getAboutPlaceholders() {
return aboutPlaceholders;
}

/**
* Get propertyUrl as IRI
*
Expand Down Expand Up @@ -272,6 +281,15 @@ public void setValueUrl(String valueUrl) {
this.valuePlaceholders = getPlaceholders(valueUrl);
}

/**
* Get value placeholders
*
* @return
*/
public String[] getValuePlaceholders() {
return valuePlaceholders;
}

/**
* Get format
*
Expand Down

0 comments on commit b486a02

Please sign in to comment.