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

@ -13,5 +13,6 @@
## Can extend this to define what the constructor arguments should be if required, and then N3EditUtils.java should be modified ## 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 ## to know it can pull out parameters based on what is defined in the display model
## <java:edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.preprocessors.TestModelChangePreprocessor> # Testing to see if this will be read in BECAUSE this has changed and should be read in
## a <java:edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.preprocessors.ModelChangePreprocessor> . # <java:edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.preprocessors.TestModelChangePreprocessor>
# a <java:edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.preprocessors.ModelChangePreprocessor> .

View file

@ -98,6 +98,7 @@ public class GemetService implements ExternalConceptService {
concept.setUri(uri); concept.setUri(uri);
concept.setConceptId(stripConceptId(uri)); concept.setConceptId(stripConceptId(uri));
concept.setSchemeURI(schemeURI); concept.setSchemeURI(schemeURI);
concept.setType("");
if (json.has("preferredLabel")) { if (json.has("preferredLabel")) {
JSONObject preferredLabelObj = json JSONObject preferredLabelObj = json
.getJSONObject("preferredLabel"); .getJSONObject("preferredLabel");

View file

@ -146,6 +146,7 @@ public class LCSHService implements ExternalConceptService {
} }
log.debug("-" + uri + "-"); log.debug("-" + uri + "-");
String conceptUriString = getSKOSURI(uri); String conceptUriString = getSKOSURI(uri);
String baseConceptURI = getConceptURI(uri);
URI conceptURI = null; URI conceptURI = null;
try { try {
conceptURI = new URI(conceptUriString); conceptURI = new URI(conceptUriString);
@ -159,12 +160,14 @@ public class LCSHService implements ExternalConceptService {
log.debug("Number of skos concepts " + skosConcepts.size()); log.debug("Number of skos concepts " + skosConcepts.size());
for (SKOSConcept skosConcept : skosConcepts) { for (SKOSConcept skosConcept : skosConcepts) {
//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); Concept c = this.createConcept(sdf, bestMatch, skosConcept, dataset);
if(c != null) { if(c != null) {
conceptList.add(c); conceptList.add(c);
} }
}
} }
i++; i++;
@ -401,6 +404,15 @@ public class LCSHService implements ExternalConceptService {
return hostUri + skosURI; 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) { public List<String> getConceptURISFromJSON(String results) {
List<String> uris = new ArrayList<String>(); List<String> uris = new ArrayList<String>();
try { try {