Thesaurus { public synchronized URI addElement(KeywordBean keyword) throws IOException, AccessDeniedException, GraphException { Graph myGraph = new org.openrdf.model.impl.GraphImpl(); ValueFactory myFactory = myGraph.getValueFactory(); String namespaceSkos = "http: String namespaceGml = "http: URI mySubject = myFactory.createURI(keyword.getUriCode()); URI skosClass = myFactory.createURI(namespaceSkos, "Concept"); URI rdfType = myFactory.createURI(org.openrdf.vocabulary.RDF.TYPE); URI predicatePrefLabel = myFactory .createURI(namespaceSkos, "prefLabel"); URI predicateScopeNote = myFactory .createURI(namespaceSkos, "scopeNote"); URI predicateBoundedBy = myFactory.createURI(namespaceGml, "BoundedBy"); URI predicateEnvelope = myFactory.createURI(namespaceGml, "Envelope"); URI predicateSrsName = myFactory.createURI(namespaceGml, "srsName"); URI srsNameURI = myFactory .createURI("http: BNode gmlNode = myFactory.createBNode(); URI predicateLowerCorner = myFactory.createURI(namespaceGml, "lowerCorner"); URI predicateUpperCorner = myFactory.createURI(namespaceGml, "upperCorner"); Literal lowerCorner = myFactory.createLiteral(keyword.getCoordWest() + " " + keyword.getCoordSouth()); Literal upperCorner = myFactory.createLiteral(keyword.getCoordEast() + " " + keyword.getCoordNorth()); mySubject.addProperty(rdfType, skosClass); Set<Entry<String, String>> values = keyword.getValues().entrySet(); for (Entry<String, String> entry : values) { String language = toiso639_1_Lang(entry.getKey()); Value valueObj = myFactory.createLiteral(entry.getValue(), language); myGraph.add(mySubject, predicatePrefLabel, valueObj); } Set<Entry<String, String>> definitions = keyword.getDefinitions().entrySet(); for (Entry<String, String> entry : definitions) { String language = toiso639_1_Lang(entry.getKey()); Value definitionObj = myFactory.createLiteral(entry.getValue(), language); myGraph.add(mySubject, predicateScopeNote, definitionObj); } myGraph.add(mySubject, predicateBoundedBy, gmlNode); gmlNode.addProperty(rdfType, predicateEnvelope); myGraph.add(gmlNode, predicateLowerCorner, lowerCorner); myGraph.add(gmlNode, predicateUpperCorner, upperCorner); myGraph.add(gmlNode, predicateSrsName, srsNameURI); repository.addGraph(myGraph); return mySubject; } protected  Thesaurus();  Thesaurus(IsoLanguagesMapper isoLanguageMapper, String fname, String type, String dname, Path thesaurusFile, String siteUrl);  Thesaurus(IsoLanguagesMapper isoLanguageMapper, String fname, String tname, String tnamespace, String type, String dname, Path thesaurusFile, String siteUrl, boolean ignoreMissingError); static String buildThesaurusKey(String fname, String type, String dname); Map<String, String> getMultilingualTitles(); Map<String,Map<String, String>> getDublinCoreMultilingual(); String getKey(); String getDname(); String getFname(); Path getFile(); String getType(); String getTitle(); String getDate(); @Nonnull FileTime getLastModifiedTime(); String getDownloadUrl(); String getKeywordUrl(); void retrieveThesaurusTitle(); synchronized LocalRepository getRepository(); synchronized Thesaurus setRepository(LocalRepository repository); synchronized Thesaurus initRepository(); synchronized QueryResultsTable performRequest(String query); boolean hasConceptScheme(String uri); List<String> getConceptSchemes(); synchronized URI addElement(KeywordBean keyword); synchronized Thesaurus removeElement(KeywordBean keyword); synchronized Thesaurus removeElement(String namespace, String code); synchronized Thesaurus removeElement(String uri); synchronized URI updateElement(KeywordBean keyword, boolean replace); synchronized boolean isFreeCode(String namespace, String code); Thesaurus updateCode(KeywordBean bean, String newcode); synchronized Thesaurus updateCode(String namespace, String oldcode, String newcode); synchronized Thesaurus updateCodeByURI(String olduri, String newuri); void addTitleElement(String thesaurusTitle); IsoLanguagesMapper getIsoLanguageMapper(); synchronized void addRelation(String subject, KeywordRelation related, String relatedSubject); KeywordBean getKeyword(String uri, String... languages); List<KeywordBean> getTopConcepts(String... languages); boolean hasKeyword(String uri); List<KeywordBean> getBroader(String uri, String... languages); boolean hasBroader(String uri); List<KeywordBean> getRelated(String uri, KeywordRelation request, String... languages); boolean hasKeywordWithLabel(String label, String langCode); KeywordBean getKeywordWithLabel(String label, String langCode); synchronized void clear(); String getDefaultNamespace(); Map<String, String> getTitles(ApplicationContext context);  }
@SuppressWarnings("deprecation") @Test public void testAddElementStringStringStringString() throws Exception { String label = "Hello"; String note = "note"; String code = "http: writableThesaurus.addElement(code, label, note, "eng"); assertElement(1, code, label, note, "", "", "", ""); label = "Hello2"; note = "note2"; code = "http: writableThesaurus.addElement(code, label, note, "en"); assertElement(2, code, label, note, "", "", "", ""); }
@SuppressWarnings("deprecation") @Test public void testAddElementStringStringStringStringString() throws Exception { String label = "Hello"; String note = "note"; String code = "http: String coordEast = "12"; String coordWest = "5"; String coordNorth = "30"; String coordSouth = "20"; writableThesaurus.addElement(code, label, note, coordEast, coordWest, coordSouth, coordNorth, "eng"); assertElement(1, code, label, note, coordEast, coordWest, coordSouth, coordNorth); label = "Hello2"; note = "note2"; code = "http: writableThesaurus.addElement(code, label, note, coordEast, coordWest, coordSouth, coordNorth, "eng"); assertElement(2, code, label, note, coordEast, coordWest, coordSouth, coordNorth); }