KeywordsSearcher searcher = (KeywordsSearcher) session
.getProperty(Geonet.Session.SEARCH_KEYWORDS_RESULT);
kb = searcher.getKeywordFromResultsById(id);
}else{
GeonetContext gc = (GeonetContext) context.getHandlerContext(Geonet.CONTEXT_NAME);
ThesaurusManager thesaurusMan = gc.getBean(ThesaurusManager.class);
KeywordsSearcher searcher = new KeywordsSearcher(context, thesaurusMan);
kb = searcher.searchById(uri, ref, lang);
}
// Add info needed by thesaurus.edit
elResp.addContent(new Element("prefLab").setText(kb.getDefaultValue()));
elResp.addContent(new Element("definition").setText(kb.getDefaultDefinition()));
elResp.addContent(new Element("relCode").setText(kb.getRelativeCode()));
elResp.addContent(new Element("nsCode").setText(kb.getNameSpaceCode()));
if (kb.getCoordEast() != null) {
elResp.addContent(new Element("east").setText(kb.getCoordEast()));
}
if (kb.getCoordWest() != null) {
elResp.addContent(new Element("west").setText(kb.getCoordWest()));
}
if (kb.getCoordSouth() != null) {
elResp.addContent(new Element("south").setText(kb.getCoordSouth()));
}
if (kb.getCoordNorth() != null) {
elResp.addContent(new Element("north").setText(kb.getCoordNorth()));
}
modeType = "edit";
uri = kb.getRelativeCode();
} else {
elResp.addContent(new Element("nsCode").setText("#"));
}
// Only if consult (ie. external thesaurus) search for related concept
if (mode.equals("consult")){
ArrayList<KeywordRelation> reqType = new ArrayList<KeywordRelation>();
reqType.add(KeywordRelation.BROADER);
reqType.add(KeywordRelation.NARROWER);
reqType.add(KeywordRelation.RELATED);
GeonetContext gc = (GeonetContext) context.getHandlerContext(Geonet.CONTEXT_NAME);
ThesaurusManager thesaurusMan = gc.getBean(ThesaurusManager.class);
KeywordsSearcher searcherBNR = new KeywordsSearcher(context, thesaurusMan);
for (int i = 0; i <= reqType.size() - 1; i++) {
searcherBNR.searchForRelated(uri, ref, reqType.get(i), lang);