public Collection<LocatorIF> getItemIdentifiers() { return tm.getItemIdentifiers(); }
@Test public void testMultipleTopicMaps() throws IOException { Collection tms = readTopicMaps("multiple-tms-read.xtm"); Assert.assertTrue("reader doesn't recognize correct number of topic maps", tms .size() == 2); Iterator iter = tms.iterator(); while (iter.hasNext()) { TopicMapIF tm = (TopicMapIF) iter.next(); Assert.assertTrue("topic map has't got exactly two topics" + tm.getItemIdentifiers(), tm.getTopics().size() == 2); } }
@Test public void testMergedInReifiedTopicMap() throws IOException { TopicMapIF tm = read("tmreify-mergemap.ltm"); Assert.assertTrue("Source locator of merged-in TM applied to master TM", tm.getItemIdentifiers().isEmpty()); }
protected TopicIF makeReifier() { TopicIF reifier = getTopicMapIF().getReifier(); if (reifier == null) { // IMPORTANT: check old-style reification TopicMapIF tm = getTopicMapIF(); Iterator<LocatorIF> iter = tm.getItemIdentifiers().iterator(); while (iter.hasNext()) { LocatorIF srcloc = iter.next(); TopicIF _reifier = tm.getTopicBySubjectIdentifier(srcloc); if (_reifier != null) { if (reifier != null) MergeUtils.mergeInto(reifier, _reifier); else reifier = _reifier; } } if (reifier == null) reifier = tm.getBuilder().makeTopic(); tm.setReifier(reifier); reifier.addType(tm.getTopicBySubjectIdentifier(PSI.ON_TOPIC_MAP)); } return reifier; }
public void testBug2003() throws InvalidQueryException, IOException { load("jill.xtm"); List matches = new ArrayList(); // should not match anything LocatorIF loc = topicmap.getItemIdentifiers().iterator().next(); addMatch(matches, "SRCLOC", loc.getAddress()); verifyQuery(matches, "select $SRCLOC from topicmap($TM), item-identifier($TM, $SRCLOC)?"); closeStore(); }
protected TopicIF makeReifier() { TopicIF reifier = getTopicMapIF().getReifier(); if (reifier == null) { // IMPORTANT: check old-style reification TopicMapIF tm = getTopicMapIF(); Iterator<LocatorIF> iter = tm.getItemIdentifiers().iterator(); while (iter.hasNext()) { LocatorIF srcloc = iter.next(); TopicIF _reifier = tm.getTopicBySubjectIdentifier(srcloc); if (_reifier != null) { if (reifier != null) MergeUtils.mergeInto(reifier, _reifier); else reifier = _reifier; } } if (reifier == null) reifier = tm.getBuilder().makeTopic(); tm.setReifier(reifier); reifier.addType(tm.getTopicBySubjectIdentifier(PSI.ON_TOPIC_MAP)); } return reifier; }
@Override public void run(MasterTest mt) { TopicMapIF m = (TopicMapIF)topicmap.getObjectById(mt.objectId); assertTrue("Topic map source locator is not set", m.getItemIdentifiers().contains(URILocator.create("x:source-locator"))); assertTrue("Topic map not found by source locator", topicmap.getObjectByItemIdentifier(URILocator.create("x:source-locator")).equals(m)); } });
@Test public void testOmittingIDs3() throws IOException { prepareTopicMap(); sourceLoc = tmbase.resolveAbsolute("#--reified--id"); topicmap.addItemIdentifier(sourceLoc); reload(); // screwup most likely causes crash here Assert.assertTrue("topic map retained syntactically invalid id", !topicmap.getItemIdentifiers().contains(sourceLoc)); }
@Override public void run(MasterTest mt) { TopicMapIF m = (TopicMapIF)topicmap.getObjectById(mt.objectId); assertTrue("Topic map source locator is set", !m.getItemIdentifiers().contains(URILocator.create("x:source-locator"))); assertTrue("Topic map found by source locator", topicmap.getObjectByItemIdentifier(URILocator.create("x:source-locator")) == null); } });
public void testTMSourceLocators() { URILocator orig = makeLocator("http://www.ontopia.net"); URILocator extra = makeLocator("ftp://ftp.ontopia.net"); topicmap1.addItemIdentifier(orig); topicmap2.addItemIdentifier(orig); topicmap2.addItemIdentifier(extra); MergeUtils.mergeInto(topicmap1, topicmap2); assertTrue("wrong number of source locators after merge", topicmap1.getItemIdentifiers().size() == 1); }
Iterator iter = new ArrayList(topicmap.getItemIdentifiers()).iterator(); while (iter.hasNext()) { LocatorIF loc = (LocatorIF)iter.next();
@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); }
@Override public void write(TopicMapIF topicmap) { DuplicateSuppressionUtils.removeDuplicates(topicmap); tmForFake = topicmap; base = topicmap.getStore().getBaseAddress().getAddress(); strippedBase = stripLocator(base); Object[] topics = getTopics(topicmap); Object[] associations = getAssociations(topicmap); recordIndexes(topics, associations); out.startDocument(); startElement(EL_TOPICMAP, reifier(topicmap)); writeLocators(topicmap.getItemIdentifiers(), EL_ITEMIDENTIFIERS); for (int ix = 0; ix < topics.length; ix++) write((TopicIF) topics[ix]); for (int ix = 0; ix < associations.length; ix++) write((AssociationIF) associations[ix], ix + 1); endElement(EL_TOPICMAP); out.endDocument(); }