@Override public void addSubjectLocator(ValueGeneratorIF locator) { topic.addSubjectLocator(locator.getLocator()); }
protected TopicIF registerSubjectLocator(TopicIF topic, LocatorIF locator) { // merge with existing, if any TopicIF existing = topicmap.getTopicBySubjectLocator(locator); if (existing != null && !Objects.equals(existing, topic)) { existing.merge(topic); topic = existing; } // add subject locator topic.addSubjectLocator(locator); return topic; }
protected TopicIF resolveResourceRef(LocatorIF locator) { // Look up in the topic map to see if a topic with the identity already exist TopicIF topic = topicmap.getTopicBySubjectLocator(locator); if (topic != null) return topic; // If there is no such topic create a new one with the given subject indicator. topic = builder.makeTopic(); // log.debug("New topic (resourceRef): " + locator); // Set addressable subject topic.addSubjectLocator(locator); return topic; }
protected void registerSubjectLocator(TopicIF topic, LocatorIF loc) { TopicIF other = topicmap.getTopicBySubjectLocator(loc); if (other == null) { topic.addSubjectLocator(loc); return; } if (other != topic) MergeUtils.mergeInto(topic, other); }
@Override public TopicIF makeTopicBySubjectLocator(LocatorIF subjloc) { TopicIF topic = topicmap.getTopicBySubjectLocator(subjloc); if (topic == null) { topic = builder.makeTopic(); topic.addSubjectLocator(subjloc); } return topic; }
private TopicIF createRecentFile(File aFile) { TopicIF file = builder.makeTopic(recentLoaded); file.addSubjectLocator(VizUtils.makeLocator(aFile)); builder.makeOccurrence(file, timestamp, ""); return file; }
@Override public void addSubjectLocator(Locator slo) { try { wrapped.addSubjectLocator(topicMap.unwrapLocator(slo)); } catch (ConstraintViolationException ex) { throw new IdentityConstraintException(this, topicMap .getTopicBySubjectLocator(slo), slo, "A topic with the subject locator " + slo.getReference() + " exists"); } catch (NullPointerException ex) { throw new ModelConstraintException(this, "The subject locator must not be null"); } }
public void setSubjectLocators(TopicIF object, Topic pojo) { if (pojo.getSubjectLocators() != null) { Collection<LocatorIF> toRemove = CollectionUtils.subtract(object.getSubjectLocators(), pojo.getSubjectLocators()); for (LocatorIF sl : pojo.getSubjectLocators()) { object.addSubjectLocator(sl); } for (LocatorIF sl : toRemove) { object.removeSubjectLocator(sl); } } }
public void testMergeDifferentSubjects3() { try { TopicIF t1 = builder1.makeTopic(); t1.addSubjectLocator(makeLocator("http://www.ontopia.net")); TopicIF t2 = builder1.makeTopic(); t2.addSubjectLocator(makeLocator("ftp://www.ontopia.net")); MergeUtils.mergeInto(t1, t2); } catch (ConstraintViolationException e) { fail("merge of topics with different subjects not accepted"); } }
@Override public void run() { TopicIF t = getTopic(); t.addSubjectLocator(URILocator.create("x:subject")); this.objectId = t.getObjectId(); } });
public void testSimpleLookupFails3() throws MalformedURLException { URILocator loc = new URILocator("http://psi.example.org/test"); topic.addSubjectLocator(loc); registry.registerPrefix("tst", "http://psi.example.org/"); TopicIF found = q.lookup("tst:test"); assertTrue("lookup returned wrong topic: " + found, found == null); }
public void testShouldSameSubject() { try { TopicIF t1 = builder1.makeTopic(); t1.addSubjectLocator(makeLocator("http://www.ontopia.net")); TopicIF t2 = builder2.makeTopic(); t2.addSubjectLocator(makeLocator("http://www.ontopia.net")); assertTrue("claims topics with same subjects should not merge", MergeUtils.shouldMerge(t1, t2)); } catch (ConstraintViolationException e) { fail("(INTERNAL) " + e.getMessage()); } }
public void testSubjectAddresses() { LocatorIF locA = makeLocator("A"); TopicIF topic = builder.makeTopic(); topic.addSubjectLocator(locA); SubjectIdentityDecider decider = new SubjectIdentityDecider(locA); assertTrue("Decider recognized topic which had locator as subject address", !decider.ok(topic)); }
public void testSubjectUnassignable() { TopicIF topic = builder.makeTopic(); topic.remove(); try { URILocator loc = new URILocator("http://www.ontopia.net"); topic.addSubjectLocator(loc); fail("subject assigned when not attached to topic map"); } catch (MalformedURLException e) { fail("(INTERNAL) URL malformed"); } catch (ConstraintViolationException e) { } }
public void testNoSubjectConflict() { try { TopicIF t1 = builder1.makeTopic(); t1.addSubjectLocator(makeLocator("ftp://www.ontopia.net")); t1.addSubjectIdentifier(makeLocator("http://www.ikke.no")); TopicIF t2 = builder2.makeTopic(); t2.addSubjectLocator(makeLocator("http://www.ontopia.net")); t2.addSubjectIdentifier(makeLocator("http://www.ikke.no")); MergeUtils.mergeInto(topicmap1, topicmap2); } catch (ConstraintViolationException e) { fail("subject conflict should not have been detected" + e.getMessage()); } }
public void testGetSubjectLocatorCount() { assertEquals(0, stats.getSubjectLocatorCount()); builder.makeTopic().addSubjectLocator(URILocator.create("foo:bar")); assertEquals(1, stats.getSubjectLocatorCount()); }
public void testMergeDifferentSubjects2() { // F.5.1, 4 try { TopicIF t1 = builder1.makeTopic(); TopicIF t2 = builder1.makeTopic(); t2.addSubjectLocator(makeLocator("http://www.ontopia.net")); MergeUtils.mergeInto(t1, t2); assertTrue("subject was lost during merge", t1.getSubjectLocators().contains(makeLocator("http://www.ontopia.net"))); } catch (ConstraintViolationException e) { fail("didn't accept merging when only one topic had a subject" + e.getMessage()); } }
public void testMergeDifferentSubjects1() { try { TopicIF t1 = builder1.makeTopic(); t1.addSubjectLocator(makeLocator("http://www.ontopia.net")); TopicIF t2 = builder1.makeTopic(); MergeUtils.mergeInto(t1, t2); assertTrue("subject was lost during merge", t1.getSubjectLocators().contains(makeLocator("http://www.ontopia.net"))); } catch (ConstraintViolationException e) { fail("didn't accept merging when only one topic had a subject" + e.getMessage()); } }
public void testShouldNullSubject() { try { TopicIF t1 = builder1.makeTopic(); t1.addSubjectLocator(makeLocator("http://www.ontopia.net")); TopicIF t2 = builder2.makeTopic(); assertTrue("claims topics with different subjects should merge", !MergeUtils.shouldMerge(t1, t2)); } catch (ConstraintViolationException e) { fail("(INTERNAL) " + e.getMessage()); } }
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) { } }