Skip to content

Commit

Permalink
Dev: small fixes to acceptable prefix definition and automatic correl…
Browse files Browse the repository at this point in the history
…ation of .csv headers and .ttl classes.
  • Loading branch information
CodeGat committed Feb 9, 2019
2 parents 93ba2f8 + 90ba5ae commit cbb6ad2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
18 changes: 10 additions & 8 deletions src/controller/PrefixMenuController.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,10 @@ public class PrefixMenuController extends AbstractDataSharingController<Map<Stri
String[] newPrefixes = prefixResult.split(", ");

for (String prefix : newPrefixes){
if (prefix.matches("[a-z]* : .*")) {
String[] prefixParts = prefix.split(" : ");
String acronym = prefixParts[0];
String expansion = prefixParts[1];
if (prefix.matches("[a-z]* ?: ?.*")) {
String[] prefixParts = prefix.split(":", 2);
String acronym = prefixParts[0].trim();
String expansion = prefixParts[1].trim();

prefixes.put(acronym, expansion);
prefixList.getItems().add(prefix);
Expand All @@ -89,7 +89,7 @@ public class PrefixMenuController extends AbstractDataSharingController<Map<Stri
*/
@FXML void removePrefixAction() {
String prefix = prefixList.getSelectionModel().getSelectedItem();
prefixes.remove(prefix.split(" : ")[0]);
prefixes.remove(prefix.split(":", 1)[0].trim());
prefixList.getItems().remove(prefix);
prefixList.getSelectionModel().clearSelection();
}
Expand Down Expand Up @@ -146,10 +146,12 @@ public class PrefixMenuController extends AbstractDataSharingController<Map<Stri
if (reader.read(rawPrefixes) == 0) LOGGER.warning("Nothing in prefix file. ");
String[] strPrefixes = new String(rawPrefixes).trim().split("\\n");
for (String strPrefix : strPrefixes) {
String[] prefixParts = strPrefix.split(" : ");
String[] prefixParts = strPrefix.split(":", 2);
String acronym = prefixParts[0].trim();
String expansion = prefixParts[1].trim();

if (!prefixes.containsKey(prefixParts[0])) {
prefixes.put(prefixParts[0], prefixParts[1]);
if (!prefixes.containsKey(acronym)) {
prefixes.put(acronym, expansion);
prefixList.getItems().add(strPrefix);
}
}
Expand Down
7 changes: 5 additions & 2 deletions src/model/dataintegration/DataIntegrator.java
Original file line number Diff line number Diff line change
Expand Up @@ -245,10 +245,13 @@ public void attemptCorrelationOfHeaders(){

for (Entry<String, Integer> header : headers.entrySet()){
for (Vertex klass : classes){
boolean isExactMatch = header.getKey().equals(klass.getName());
String headerComparable =
header.getKey().charAt(0) == '\uFEFF' ? header.getKey().substring(1) : header.getKey();

boolean isExactMatch = headerComparable.equals(klass.getName());
boolean isCloseMatch = !klass.isIri()
&& klass.getElementType() == CLASS
&& header.getKey().equalsIgnoreCase(klass.getName().split(":", 2)[1]);
&& headerComparable.equalsIgnoreCase(klass.getName().split(":", 2)[1]);

if (isExactMatch || isCloseMatch){
csvTtlCorrelations.add(new Correlation(header.getValue(), header.getKey(), klass));
Expand Down

0 comments on commit cbb6ad2

Please sign in to comment.