private TopicIF getTopicById(TopicMapIF topicmap, String id) { LocatorIF base = topicmap.getStore().getBaseAddress(); LocatorIF srcloc = base.resolveAbsolute('#' + id); return (TopicIF) topicmap.getObjectByItemIdentifier(srcloc); }
/** * INTERNAL: Sets the current topic map. */ public void setTopicMap(TopicMapIF topicmap) { this.topicmap = topicmap; this.builder = topicmap.getBuilder(); this.qp = null; this.dc = null; }
private TMObjectIF resolveAsLocator(TopicMapIF topicmap, LocatorIF locator) { TMObjectIF o = topicmap.getTopicBySubjectIdentifier(locator); if (o == null) { o = topicmap.getTopicBySubjectLocator(locator); } if (o == null) { o = topicmap.getObjectByItemIdentifier(locator); } return o; } }
public void count() throws NullPointerException { Collection topics, assocs, occurs; topics = tm.getTopics(); assocs = tm.getAssociations(); Iterator it = topics.iterator(); while (it.hasNext()) { TopicIF topic = (TopicIF)it.next(); occurs = topic.getOccurrences(); numberOfOccurrences += occurs.size(); } numberOfAssociations = assocs.size(); numberOfTopics = topics.size(); }
public TopicIF getTopicIFById(String id) { // look up topic by object id or subject identifier TopicIF topic = (TopicIF)getTopicMapIF().getObjectById(id); if (topic == null) { try { return topicMapIF.getTopicBySubjectIdentifier(URILocator.create(id)); } catch (Exception e) { return null; } } return topic; }
@Override public void run(MasterTest mt) { VariantNameIF vn = (VariantNameIF)topicmap.getObjectById(mt.objectId); assertTrue("Variant name source locator is not set", vn.getItemIdentifiers().contains(URILocator.create("x:source-locator"))); assertTrue("Variant name not found by source locator", topicmap.getObjectByItemIdentifier(URILocator.create("x:source-locator")).equals(vn)); } });
@Test public void testURN() throws URISyntaxException { TopicIF t1 = builder.makeTopic(); TopicIF t2 = builder.makeTopic(); t1.addSubjectIdentifier(URILocator.create("urn:test1")); t2.addSubjectIdentifier(URILocator.create("urn:TEST1")); topicmap.getStore().commit(); Assert.assertEquals(2, topicmap.getTopics().size()); topicmap.getTopicBySubjectIdentifier(URILocator.create("urn:test1")).remove(); topicmap.getStore().commit(); Assert.assertEquals(1, topicmap.getTopics().size()); }
public PumpPredicate(TopicMapIF topicmap, List subclauses, int limit, Variable valuevar, Variable objectvar, Object literal, boolean equals, boolean bigger) { this.index = (OccurrenceIndexIF) topicmap.getIndex("net.ontopia.topicmaps.core.index.OccurrenceIndexIF"); this.subclauses = subclauses; this.limit = limit; this.valuevar = valuevar; this.objectvar = objectvar; this.literal = literal; this.equals = equals; this.bigger = bigger; }
private TopicIF getLastModifiedTopic(TopicMapIF topicmap) { TopicIF lastmod = topicmap.getTopicBySubjectIdentifier(psi); if (lastmod == null) { lastmod = topicmap.getBuilder().makeTopic(); lastmod.addSubjectIdentifier(psi); } return lastmod; }
/** * Tests whether this topic is a topic type. * * @return true if this is a topic type. */ public boolean isTopicType() { TopicIF type = topicIF.getTopicMap().getTopicBySubjectIdentifier(PSI.ON_TOPIC_TYPE); return topicIF.getTypes().contains(type); }
@Test public void testEmptyTopicMap() throws IOException { TopicMapIF tm = readTopicMap("empty.xtm"); Assert.assertTrue("empty topic map not empty after import", tm.getTopics().size() == 0 && tm.getAssociations().size() == 0); Assert.assertTrue("topic map has no base address", tm.getStore().getBaseAddress() != null); }
@Test public void testReifiedTopicMap() throws IOException { TopicMapIF tm = read("tmreify.ltm"); LocatorIF loc = tm.getStore().getBaseAddress(). resolveAbsolute("#example"); Assert.assertTrue("Topic map does not have correct source locator", tm.getItemIdentifiers().contains(loc)); TopicIF reifier = tm.getTopicBySubjectIdentifier(loc); Assert.assertTrue("No topic reifying topic map", reifier != null); }
private void importFragment(String fragment, TopicMapIF topicmap) { log.debug("Importing fragment " + fragment); LocatorIF base = topicmap.getStore().getBaseAddress(); LTMTopicMapReader reader = new LTMTopicMapReader(new StringReader(fragment), base); try { reader.importInto(topicmap); } catch (java.io.IOException e) { log.error("Syntax error in LTM fragment", e); throw new ActionRuntimeException(e); } }
public static void removeNullTopic(TopicMapIF topicmap) { TopicIF topic = topicmap.getTopicBySubjectIdentifier(nullPSI); if (topic != null) { if (topic.getReified() != null) return; ClassInstanceIndexIF cindex = (ClassInstanceIndexIF)topicmap.getIndex(ClassInstanceIndexIF.class.getName()); if (cindex.usedAsType(topic)) return; ScopeIndexIF sindex = (ScopeIndexIF)topicmap.getIndex(ScopeIndexIF.class.getName()); if (sindex.usedAsTheme(topic)) return; topic.remove(); } }
private TopicIF getRecentFile(File aFile) { return topicmap.getTopicBySubjectLocator(VizUtils.makeLocator(aFile)); }
@Override public void run(MasterTest mt) { TopicIF t = (TopicIF)topicmap.getObjectById(mt.objectId); assertTrue("Subject locator is not null", t.getSubjectLocators().isEmpty()); assertTrue("Topic found by subject locator", topicmap.getTopicBySubjectLocator(URILocator.create("x:subject")) == null); } });
public void testQName() throws InvalidQueryException, IOException { load("subclasses.ltm"); int topics = topicmap.getTopics().size(); update("using xtm for i\"http://www.topicmaps.org/xtm/1.0/core.xtm#\" " + "insert xtm:test . "); assertTrue("wrong number of topics after insert", topicmap.getTopics().size() == (topics + 1)); TopicIF test = topicmap.getTopicBySubjectIdentifier(new URILocator("http://www.topicmaps.org/xtm/1.0/core.xtm#test")); assertTrue("no xtm:test after insert", test != null); }
public void testTopicTypeDeletion() { TopicMapIF topicmap = makeTopicMap(); TopicMapBuilderIF builder = topicmap.getBuilder(); TopicIF morituri = builder.makeTopic(); TopicIF instance = builder.makeTopic(morituri); morituri.remove(); assertTrue("Topic still connected to topic map", morituri.getTopicMap() == null); assertTrue("Topic map not empty", topicmap.getTopics().size() == 0); }
@Override protected void onValidate(IValidatable<String> validatable) { String value = validatable.getValue(); if (value == null) return; LocatorIF locator; try { locator = new URILocator(value); } catch (Exception e) { reportError("validators.IdentityValidator.invalidURI", value); return; } Topic topic = fieldInstanceModel.getFieldInstance().getInstance(); TopicMap topicMap = topic.getTopicMap(); TopicMapIF topicMapIf = topicMap.getTopicMapIF(); TopicIF topicIf = topic.getTopicIF(); TopicIF otopic = topicMapIf.getTopicBySubjectIdentifier(locator); if (otopic != null && ObjectUtils.different(topicIf, otopic)) reportError("validators.IdentityValidator.subjectIdentifierClash", value); otopic = topicMapIf.getTopicBySubjectLocator(locator); if (otopic != null && ObjectUtils.different(topicIf, otopic)) reportError("validators.IdentityValidator.subjectLocatorClash", value); }
public TMObjectIFHandle(TMObjectIF o) { this.objectId = o.getObjectId(); TopicMapIF tm = o.getTopicMap(); this.topicmapId = tm.getObjectId(); TopicMapReferenceIF ref = tm.getStore().getReference(); if (ref != null) this.referenceId = ref.getId(); }