From 47c7e3746fe0f0b5d325b4569458a8311075fe18 Mon Sep 17 00:00:00 2001 From: hudajkhan Date: Thu, 4 Sep 2014 16:46:04 -0400 Subject: [PATCH] fixing Gemet null type and LCSC null concepts --- .../everytime/n3ModelChangePreprocessors.n3 | 5 +++-- .../service/impl/GemetService.java | 1 + .../semservices/service/impl/LCSHService.java | 22 ++++++++++++++----- 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/rdf/display/everytime/n3ModelChangePreprocessors.n3 b/rdf/display/everytime/n3ModelChangePreprocessors.n3 index 3d9afdf4..a1f5403f 100644 --- a/rdf/display/everytime/n3ModelChangePreprocessors.n3 +++ b/rdf/display/everytime/n3ModelChangePreprocessors.n3 @@ -13,5 +13,6 @@ ## Can extend this to define what the constructor arguments should be if required, and then N3EditUtils.java should be modified ## to know it can pull out parameters based on what is defined in the display model -## -## a . \ No newline at end of file +# Testing to see if this will be read in BECAUSE this has changed and should be read in +# +# a . \ No newline at end of file diff --git a/src/edu/cornell/mannlib/semservices/service/impl/GemetService.java b/src/edu/cornell/mannlib/semservices/service/impl/GemetService.java index 82399ad2..6f78ba2d 100644 --- a/src/edu/cornell/mannlib/semservices/service/impl/GemetService.java +++ b/src/edu/cornell/mannlib/semservices/service/impl/GemetService.java @@ -98,6 +98,7 @@ public class GemetService implements ExternalConceptService { concept.setUri(uri); concept.setConceptId(stripConceptId(uri)); concept.setSchemeURI(schemeURI); + concept.setType(""); if (json.has("preferredLabel")) { JSONObject preferredLabelObj = json .getJSONObject("preferredLabel"); diff --git a/src/edu/cornell/mannlib/semservices/service/impl/LCSHService.java b/src/edu/cornell/mannlib/semservices/service/impl/LCSHService.java index 614bd356..991f2ebc 100644 --- a/src/edu/cornell/mannlib/semservices/service/impl/LCSHService.java +++ b/src/edu/cornell/mannlib/semservices/service/impl/LCSHService.java @@ -146,6 +146,7 @@ public class LCSHService implements ExternalConceptService { } log.debug("-" + uri + "-"); String conceptUriString = getSKOSURI(uri); + String baseConceptURI = getConceptURI(uri); URI conceptURI = null; try { conceptURI = new URI(conceptUriString); @@ -159,12 +160,14 @@ public class LCSHService implements ExternalConceptService { log.debug("Number of skos concepts " + skosConcepts.size()); for (SKOSConcept skosConcept : skosConcepts) { - - Concept c = this.createConcept(sdf, bestMatch, skosConcept, dataset); - if(c != null) { - conceptList.add(c); + //Close matches are also being returned in list of skos concepts and + //we are interested in getting the main concept we requested only + if(skosConcept.getURI().toString().equals(baseConceptURI)) { + Concept c = this.createConcept(sdf, bestMatch, skosConcept, dataset); + if(c != null) { + conceptList.add(c); + } } - } i++; @@ -400,6 +403,15 @@ public class LCSHService implements ExternalConceptService { } return hostUri + skosURI; } + + //Given the URI from the xml, get just the base URI + private String getConceptURI(String uri) { + String skosURI = uri; + if (uri.endsWith(".xml")) { + skosURI = uri.substring(0, uri.length() - 4); + } + return hostUri + skosURI; + } public List getConceptURISFromJSON(String results) { List uris = new ArrayList();