/** * INTERNAL: Serialize the subject locators of a {@link TopicIF}. If the * object does not have a subject locator, nothing will be serialized. * * @param topic the {@link TopicIF} to be serialized. */ private void serializeSubjectLocators(TopicIF topic) throws IOException { Collection<LocatorIF> slocs = topic.getSubjectLocators(); serializeIdentifiers("subject_locators", slocs); }
@Override public Set<Locator> getSubjectLocators() { return topicMap.wrapSet(wrapped.getSubjectLocators()); }
public String getURI() { LocatorIF loc = topic.getSubjectLocators().iterator().next(); return loc.getAddress(); }
private AResource getResource(TopicIF topic) { LocatorIF locator = null; if (locator == null && !topic.getSubjectLocators().isEmpty()) locator = (LocatorIF) topic.getSubjectLocators().iterator().next(); if (locator == null && !topic.getSubjectIdentifiers().isEmpty()) locator = (LocatorIF) topic.getSubjectIdentifiers().iterator().next(); if (locator != null) return new AResourceWrapper(locator.getExternalForm()); return makeAnonymousNode(topic); }
private void addSubjectTreeNodeTo(DefaultMutableTreeNode parent) { LocatorIF subject = (LocatorIF)CollectionUtils.getFirst(target.getSubjectLocators()); // NOTE: gets only the first one if (subject == null) return; String subjectAddress = subject.getAddress(); if (subjectAddress != null) { DefaultMutableTreeNode root = new DefaultMutableTreeNode(Messages .getString("Viz.PropertiesSubject")); root.add(new DynamicUtilTreeNode(subjectAddress, null)); parent.add(root); } }
private static void copyTopic(TopicMapIF tm, TopicIF referenced) { TopicMapBuilderIF builder = tm.getBuilder(); TopicIF topic = builder.makeTopic(); // copy identity Iterator<LocatorIF> it = referenced.getSubjectLocators().iterator(); while (it.hasNext()) topic.addSubjectLocator(it.next()); it = referenced.getSubjectIdentifiers().iterator(); while (it.hasNext()) topic.addSubjectIdentifier(it.next()); it = referenced.getItemIdentifiers().iterator(); while (it.hasNext()) topic.addItemIdentifier(it.next()); // copy name builder.makeTopicName(topic, TopicStringifiers.toString(referenced)); }
private void transferLoadedTopics(Collection<TopicIF> loaded, TopicMapIF targetTopicMap) { Iterator<TopicIF> it = loaded.iterator(); while (it.hasNext()) { TopicIF sourceRelated = it.next(); TopicIF targetRelated = createTopic(targetTopicMap, sourceRelated.getSubjectIdentifiers(), sourceRelated.getItemIdentifiers(), sourceRelated.getSubjectLocators()); if (!isLoaded(targetRelated)) { setLoaded(targetRelated); TopicMapSynchronizer.update(targetTopicMap, sourceRelated); } } }
private void transferLoadedTopics(Collection<TopicIF> loaded, TopicMapIF targetTopicMap) { Iterator<TopicIF> it = loaded.iterator(); while (it.hasNext()) { TopicIF sourceRelated = it.next(); TopicIF targetRelated = createTopic(targetTopicMap, sourceRelated.getSubjectIdentifiers(), sourceRelated.getItemIdentifiers(), sourceRelated.getSubjectLocators()); if (!isLoaded(targetRelated)) { setLoaded(targetRelated); TopicMapSynchronizer.update(targetTopicMap, sourceRelated); } } }
@Override public int compare(Object o1, Object o2) { TopicIF t1 = (TopicIF) o1; TopicIF t2 = (TopicIF) o2; int cmp = compareLocatorSet(t1.getSubjectIdentifiers(), t2.getSubjectIdentifiers()); if (cmp == 0) cmp = compareLocatorSet(t1.getSubjectLocators(), t2.getSubjectLocators()); if (cmp == 0) cmp = compareLocatorSet(t1.getItemIdentifiers(), t2.getItemIdentifiers()); return cmp; }
public void testSLStatic() throws InvalidQueryException, IOException { load("instance-of.ltm"); TopicIF topic = getTopicById("type2"); LocatorIF sl = (LocatorIF) topic.getSubjectLocators().iterator().next(); update("delete subject-locator(type2, \"" + sl.getAddress() + "\")"); assertTrue("topic retains subject locator after delete", topic.getSubjectLocators().isEmpty()); }
public Collection getPagesFor(TopicIF topic) { TopicIndexIF ix = ((RemoteTopicMapStore) topicmap.getStore()) .getTopicIndex(); return ix.getTopicPages(topic.getSubjectIdentifiers(), topic.getItemIdentifiers(), topic.getSubjectLocators()); }
public void testCompletelyOpen() throws InvalidQueryException, IOException { load("instance-of.ltm"); List matches = new ArrayList(); Iterator it = topicmap.getTopics().iterator(); while (it.hasNext()) { TopicIF topic = (TopicIF) it.next(); Iterator it2 = topic.getSubjectLocators().iterator(); while (it2.hasNext()) addMatch(matches, "TOPIC", topic, "LOCATOR", ((LocatorIF) it2.next()).getAddress()); } verifyQuery(matches, "subject-locator($TOPIC, $LOCATOR)?"); }
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 testSLDynamic() throws InvalidQueryException, IOException { load("instance-of.ltm"); TopicIF topic = getTopicById("type2"); update("delete subject-locator(type2, $SL) from subject-locator(type2, $SL)"); assertTrue("topic retains subject locator after delete", topic.getSubjectLocators().isEmpty()); }
public void testEmptyInsert3() throws InvalidQueryException { makeEmpty(); update("insert = http://example.com . "); TopicIF topic = (TopicIF) topicmap.getTopics().iterator().next(); assertTrue("wrong number of topics after insert", topicmap.getTopics().size() == 1); assertTrue("topic not found after insert", topic != null); assertTrue("topic does not have subject locator", topic.getSubjectLocators().size() == 1); }
@Override public void run(MasterTest mt) { TopicIF t = (TopicIF)topicmap.getObjectById(mt.objectId); assertTrue("Subject locator is not set", t.getSubjectLocators().contains(URILocator.create("x:subject"))); assertTrue("Topic not found by subject locator", topicmap.getTopicBySubjectLocator(URILocator.create("x:subject")).equals(t)); } });
@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); } });
@Override public void run(MasterTest mt) { TopicIF t = (TopicIF)topicmap.getObjectById(mt.objectId); assertTrue("Added topic not found", t != null); if (testInitialProperties) { assertTrue("Subject locator is set", t.getSubjectLocators().isEmpty()); assertTrue("Source locators is set", t.getItemIdentifiers().isEmpty()); assertTrue("Subject identifiers is set", t.getSubjectIdentifiers().isEmpty()); assertTrue("Types is set", t.getTypes().isEmpty()); assertTrue("Base names is set", t.getTopicNames().isEmpty()); assertTrue("Occurrences is set", t.getOccurrences().isEmpty()); } } });
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 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()); } }