fixing Gemet null type and LCSC null concepts

This commit is contained in:
hudajkhan 2014-09-04 16:46:04 -04:00
parent 2983cf69b0
commit 47c7e3746f
3 changed files with 21 additions and 7 deletions

View file

@ -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");

View file

@ -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<String> getConceptURISFromJSON(String results) {
List<String> uris = new ArrayList<String>();