public TopicMapImpl(TopicMapSystemIF tmsystem, TopicMapStoreIF store) { super(null); this.tmsystem = tmsystem; wrapped = store.getTopicMap(); topicMap = this; }
protected TopicMapIF getTopicMap() { return store.getTopicMap(); }
@Override public void startDocument () { // Initialize variables parents.clear(); info.clear(); keep_content = false; content = new StringBuilder(); topicmap = stores.createStore().getTopicMap(); builder = topicmap.getBuilder(); makePSIs(); log.info("Processing document '" + doc_address + "'."); // Initialize list of accumulated processed documents this.processed_documents_accumulated = new HashSet(); }
/** * INTERNAL: Saves the topic map as an XTM document in the location * managed by the reference's source. */ public synchronized void save() throws IOException { if (store != null && source instanceof TMXMLPathTopicMapSource) { TMXMLPathTopicMapSource src = (TMXMLPathTopicMapSource) source; String path = src.getPath(); if (path != null) { File file = new File(path + File.separator + this.getId()); TopicMapWriterIF writer = new TMXMLWriter(file); writer.write(store.getTopicMap()); } } }
private static TopicMapIF doCommit(TopicMapIF topicmap) throws IOException { TopicMapStoreIF store = topicmap.getStore(); TopicMapReferenceIF reference = store.getReference(); store.commit(); if (!(store instanceof InMemoryTopicMapStore)) { store.close(); store = reference.createStore(false); } //never forget! topicmap = store.getTopicMap(); // force a GC System.gc(); return topicmap; }
@Override public synchronized void clear() throws IOException { // naive implementation that gets a store and clears it TopicMapStoreIF store = null; try { store = createStore(false); store.getTopicMap().clear(); } finally { if (store != null && store.isOpen()) store.close(); } }
@Override public void setUp() { TopicMapStoreIF store = new InMemoryTopicMapStore(); topicmap = store.getTopicMap(); builder = topicmap.getBuilder(); generator = DefaultTopicMapDocumentGenerator.INSTANCE; }
private static TopicMapIF doCommit(TopicMapIF topicmap) throws IOException { TopicMapStoreIF store = topicmap.getStore(); TopicMapReferenceIF reference = store.getReference(); store.commit(); if (!(store instanceof InMemoryTopicMapStore)) { store.close(); store = reference.createStore(false); } //never forget! topicmap = store.getTopicMap(); return topicmap; }
protected long importTopicMap(URL filename) throws IOException { // import sample topic map TopicMapStoreIF store = new RDBMSTopicMapStore(); // don't use storage TopicMapReaderIF importer = ImportExportUtils.getReader(filename.toString()); importer.importInto(store.getTopicMap()); long topicmap_id = Long.parseLong(store.getTopicMap().getObjectId().substring(1)); store.commit(); store.close(); return topicmap_id; }
@Override public void setTitle(String title) { super.setTitle(title); TopicMapStoreIF store = null; try { store = createStore(false); TopicMap topicmap = (TopicMap) store.getTopicMap(); topicmap.setTitle(title); store.commit(); } finally { if (store != null) { store.close(); } } }
protected long importTopicMap(String filename) throws IOException { // import sample topic map TopicMapStoreIF store = new RDBMSTopicMapStore(); // don't use storage TopicMapReaderIF importer = ImportExportUtils.getReader(filename); importer.importInto(store.getTopicMap()); long topicmap_id = Long.parseLong(store.getTopicMap().getObjectId().substring(1)); store.commit(); store.close(); return topicmap_id; }
private TopicMapIF getSystemTopicMap() { // open system topic map String systemTopicMapId = getSystemTopicMapId(); TopicMapReferenceIF topicMapReferenceIF = getTopicMapRepository().getReferenceByKey(systemTopicMapId); if (topicMapReferenceIF == null) throw new OntopiaRuntimeException("Cannot find topic map with id '" + systemTopicMapId); try { return topicMapReferenceIF.createStore(false).getTopicMap(); } catch(IOException e) { throw new OntopiaRuntimeException(e); } }
private TopicMapIF getSystemTopicMap() { // open system topic map String systemTopicMapId = getSystemTopicMapId(); TopicMapReferenceIF topicMapReferenceIF = getTopicMapRepository().getReferenceByKey(systemTopicMapId); if (topicMapReferenceIF == null) throw new OntopiaRuntimeException("Cannot find topic map with id '" + systemTopicMapId); try { return topicMapReferenceIF.createStore(false).getTopicMap(); } catch(IOException e) { throw new OntopiaRuntimeException(e); } }
@Override public synchronized void reindex() { deleteIndex(); try (TopicMapStoreIF store = reference.createStore(true)) { try (IndexWriter writer = getWriter()) { new TopicMapIteratorGenerator(store.getTopicMap(), new LuceneIndexer(writer), DefaultTopicMapDocumentGenerator.INSTANCE) .generate(); } closeReader(); } catch (IOException ioe) { throw new OntopiaRuntimeException("Could not fulltext reindex topicmap " + reference.getId() + ": " + ioe.getMessage(), ioe); } }
public static String convertNew(TopicMap oldTopicMap, String tmname, TopicMapSource tmsource) { TopicMapRepositoryIF repository = OntopolyContext.getOntopolyRepository().getTopicMapRepository(); try { String referenceId = OntopolyContext.getOntopolyRepository().createOntopolyTopicMap(tmsource.getId(), tmname); TopicMapIF topicMapIF = OntopolyContext.getOntopolyRepository().getTopicMapRepository() .getReferenceByKey(referenceId).createStore(false).getTopicMap(); TopicMap newTopicMap = new TopicMap(topicMapIF, referenceId); return inferAndCreateSchema(oldTopicMap, newTopicMap, tmname, repository); } catch (Exception e) { throw new OntopiaRuntimeException(e); } }
public static String convertNew(TopicMap oldTopicMap, String tmname, TopicMapSource tmsource) { TopicMapRepositoryIF repository = OntopolyContext.getOntopolyRepository().getTopicMapRepository(); try { String referenceId = OntopolyContext.getOntopolyRepository().createOntopolyTopicMap(tmsource.getId(), tmname); TopicMapIF topicMapIF = OntopolyContext.getOntopolyRepository().getTopicMapRepository() .getReferenceByKey(referenceId).createStore(false).getTopicMap(); TopicMap newTopicMap = new TopicMap(topicMapIF, referenceId); return inferAndCreateSchema(oldTopicMap, newTopicMap, tmname, repository); } catch (Exception e) { throw new OntopiaRuntimeException(e); } }
private void prepare() throws IOException { TopicMapStoreIF store = reference.createStore(false); TopicMapIF tm = store.getTopicMap(); tm.getBuilder().makeTopic().addSubjectIdentifier(psi); store.commit(); store.close(); }
@Override public void setUp() throws Exception { // Get a new topic map object from the factory. factory = getFactory(); topicmapRef = factory.makeTopicMapReference(); listener = new TesterListener(); TopicMapEvents.addTopicListener(topicmapRef, listener); topicmap = topicmapRef.createStore(false).getTopicMap(); // Get the builder of that topic map. builder = topicmap.getBuilder(); }
@Override protected void setUp() throws Exception { factory = getFactory(); // Get a new topic map object from the factory. topicmapRef = factory.makeTopicMapReference(); topicmap = topicmapRef.createStore(false).getTopicMap(); assertTrue("Null topic map!" , topicmap != null); // Get the builder of that topic map. builder = topicmap.getBuilder(); assertTrue("Null builder!", builder != null); }
@Override protected TopicMapIF exportAndReread(TopicMapIF topicmap, File outfile) throws IOException { // First we export TMXMLWriter writer = new TMXMLWriter(outfile); writer.write(topicmap); writer.close(); // Then we read back in TopicMapIF topicmap2 = getStoreFactory().createStore().getTopicMap(); TMXMLReader reader = new TMXMLReader(outfile); reader.importInto(topicmap2); return topicmap2; } }