@Override public void addItemIdentifier(ValueGeneratorIF locator) { topic.addItemIdentifier(locator.getLocator()); }
@Override public TopicIF getTopic() { TopicIF topic = context.makeTopicByItemIdentifier(locator); if (id != null && !context.getIncludeUris().isEmpty()) { Iterator it = context.getIncludeUris().iterator(); while (it.hasNext()) { LocatorIF loc = (LocatorIF) it.next(); topic.addItemIdentifier(loc.resolveAbsolute('#' + id)); } } return topic; }
@Override public TopicIF makeTopicByItemIdentifier(LocatorIF itemid) { TopicIF topic = (TopicIF) topicmap.getObjectByItemIdentifier(itemid); if (topic == null) { topic = builder.makeTopic(); topic.addItemIdentifier(itemid); } return topic; }
private void addItemIdentifier(TopicIF topic, LocatorIF ii) { seenIdentity = true; TMObjectIF obj = topicmap.getObjectByItemIdentifier(ii); if (obj == null) topic.addItemIdentifier(ii); else if (obj instanceof TopicIF) merge(topic, (TopicIF) obj); else // itemid collision throw new InvalidTopicMapException("Another object " + obj + " already " + "has item identifier " + ii); }
private TopicIF getTopicByIid(LocatorIF itemid) { if (!xtm21 && itemid.getAddress().indexOf('#') == -1) throw new InvalidTopicMapException("Topic references must have fragment identifiers; invalid reference: " + itemid.getAddress()); TMObjectIF obj = topicmap.getObjectByItemIdentifier(itemid); if (obj == null) { TopicIF topic = builder.makeTopic(); topic.addItemIdentifier(itemid); return topic; } else if (obj instanceof TopicIF) { return (TopicIF) obj; } throw new InvalidTopicMapException("Another Topic Maps construct " + obj + " has already the item identifier " + itemid.getAddress()); }
@Override public void run() { TopicIF t = getTopic(); t.addItemIdentifier(URILocator.create("x:source-locator")); this.objectId = t.getObjectId(); } });
public void testSimpleLookupFails2() throws MalformedURLException { URILocator loc = new URILocator("http://psi.example.org/test"); topic.addItemIdentifier(loc); registry.registerPrefix("tst", "http://psi.example.org/"); TopicIF found = q.lookup("tst:test"); assertTrue("lookup returned wrong topic: " + found, found == null); }
@Test public void testBug654OnRDBMS() throws IOException { // this test verifies that not are source locators of the form // id34234 not used to form IDs on export, but neither are those // of the form idT34234 prepareTopicMap(); String tid = "idT234212"; TopicIF topic = builder.makeTopic(); topic.addItemIdentifier(tmbase.resolveAbsolute("#" + tid)); XTMTopicMapExporter exp = new XTMTopicMapExporter(); String id = exp.getElementId(topic); Assert.assertTrue("unacceptable ID used", !id.equals(tid)); }
public void testSourceLocSubjIndConflict() { // used to have a bug on this, hence the test TopicIF t1 = builder1.makeTopic(); t1.addSubjectIdentifier(makeLocator("http://www.ontopia.net")); TopicIF t2 = builder2.makeTopic(); t2.addItemIdentifier(makeLocator("http://www.ontopia.net")); MergeUtils.mergeInto(topicmap1, topicmap2); assertTrue("incorrect number of topics in merged topic map", topicmap1.getTopics().size() == 1); }
public void testBug1790() { // test case for bug #1790 TopicIF t1 = builder1.makeTopic(); t1.addSubjectIdentifier(makeLocator("http://www.ontopia.net")); t1.addItemIdentifier(makeLocator("http://www.ontopia.net")); TopicIF t2 = builder1.makeTopic(); MergeUtils.mergeInto(t2, t1); assertTrue("topics merged incorrectly", topicmap1.getTopics().size() == 1); }
public void testGetObjectBySymbolicId() { String symbolicId = "foo"; TopicIF topic = builder.makeTopic(); LocatorIF base = topicmap.getStore().getBaseAddress(); LocatorIF loc = base.resolveAbsolute("#" + symbolicId); topic.addItemIdentifier(loc); TMObjectIF topic2 = IdentityUtils.getObjectBySymbolicId(topicmap, symbolicId); assertEquals("Topic not found by symbolic id", topic, topic2); }
@Test public void testPreservesTopicID() throws IOException { prepareTopicMap(); TopicIF topic = builder.makeTopic(); topic.addItemIdentifier(sourceLoc); reload(); check("topic", getTopicById(topicmap, "id")); }
public void testGetItemIdentifierCount() { assertEquals(0, stats.getItemIdentifierCount()); builder.makeTopic().addItemIdentifier(URILocator.create("foo:bar")); assertEquals(1, stats.getItemIdentifierCount()); }
public void testBug652c() { try { TopicIF t1 = builder.makeTopic(); URILocator loc = new URILocator("http://www.ontopia.net/B"); t1.addSubjectIdentifier(loc); TopicIF t2 = builder.makeTopic(); t2.addItemIdentifier(loc); fail("subject identifier of one topic allowed to be item identifier of " + "another"); } catch (MalformedURLException e) { fail("(INTERNAL) bad URL given" + e); } catch (UniquenessViolationException e) { // this is the expected outcome } }
public void testShouldTopicIsSubjectIndicatorReverse() { TopicIF t1 = builder1.makeTopic(); t1.addItemIdentifier(makeLocator("http://www.ontopia.net")); TopicIF t2 = builder2.makeTopic(); t2.addSubjectIdentifier(makeLocator("http://www.ontopia.net")); assertTrue("claims topics should not merge when one is subject indicator of other", MergeUtils.shouldMerge(t2, t1)); }
@Test public void testPreservesTopicID2() throws IOException { prepareTopicMap(); LocatorIF loc = tmbase.resolveAbsolute("#ide"); TopicIF topic = builder.makeTopic(); topic.addItemIdentifier(loc); reload(); check("topic", getTopicById(topicmap, "ide"), loc); }
public void testShouldTopicIsSubjectIndicator() { TopicIF t1 = builder1.makeTopic(); t1.addItemIdentifier(makeLocator("http://www.ontopia.net")); TopicIF t2 = builder2.makeTopic(); t2.addSubjectIdentifier(makeLocator("http://www.ontopia.net")); assertTrue("claims topics should not merge when one is subject indicator of other", MergeUtils.shouldMerge(t1, t2)); }
public void testBug652a() { try { TopicIF topic = builder.makeTopic(); URILocator loc = new URILocator("http://www.ontopia.net/A"); topic.addItemIdentifier(loc); topic.addSubjectIdentifier(loc); topic.removeSubjectIdentifier(loc); topic.removeItemIdentifier(loc); topic.remove(); } catch (MalformedURLException e) { fail("(INTERNAL) bad URL given" + e); } }
public void testBug652b() { try { TopicIF topic = builder.makeTopic(); URILocator loc = new URILocator("http://www.ontopia.net/B"); topic.addSubjectIdentifier(loc); topic.addItemIdentifier(loc); topic.removeItemIdentifier(loc); topic.removeSubjectIdentifier(loc); topic.remove(); } catch (MalformedURLException e) { fail("(INTERNAL) bad URL given" + e); } }
public void testTopicOtherObjectCollision() { TopicIF topic1 = builder1.makeTopic(); TopicNameIF bn = builder1.makeTopicName(topic1, ""); bn.addItemIdentifier(makeLocator("http://www.ontopia.com")); TopicIF topic2 = builder2.makeTopic(); topic2.addSubjectIdentifier(makeLocator("http://www.ontopia.net")); topic2.addSubjectLocator(makeLocator("http://www.example.com")); topic2.addItemIdentifier(makeLocator("http://www.ontopia.com")); try { MergeUtils.mergeInto(topicmap1, topic2); fail("collision not detected"); } catch (ConstraintViolationException e) { } }