@Override public Collection<VariantNameIF> transform(TopicNameIF input) { return input.getVariants(); } });
private static void copyVariants(TopicNameIF target, TopicNameIF source) { Iterator<VariantNameIF> it = source.getVariants().iterator(); while (it.hasNext()) { VariantNameIF o = it.next(); copyVariant(target, o); } }
protected Object[] getObjects() { TopicIF[] topics = (TopicIF[]) topicmap.getTopics().toArray(new TopicIF[] {}); Collection objects = new ArrayList(topics.length * 3); for (int tix = 0; tix < topics.length; tix++) { Collection bns = topics[tix].getTopicNames(); objects.addAll(topics[tix].getOccurrences()); Iterator it = bns.iterator(); while (it.hasNext()) { TopicNameIF bn = (TopicNameIF) it.next(); objects.addAll(bn.getVariants()); } } return objects.toArray(); }
private Object[] getObjects() { TopicIF[] topics = (TopicIF[]) topicmap.getTopics().toArray(new TopicIF[] {}); Collection objects = new ArrayList(topics.length * 3); for (int tix = 0; tix < topics.length; tix++) { objects.addAll(topics[tix].getOccurrences()); Collection bns = topics[tix].getTopicNames(); Iterator it = bns.iterator(); while (it.hasNext()) { TopicNameIF bn = (TopicNameIF) it.next(); objects.addAll(bn.getVariants()); } } return objects.toArray(); }
@Override public void processEvent(Object object, String event, Object new_value, Object old_value) { TopicNameIF removed = (TopicNameIF)old_value; // Fire tree event treeRemoveEvent(object, TopicNameIF.EVENT_REMOVED, removed); // Remove variants Object[] variants = removed.getVariants().toArray(); for (int i=0; i < variants.length; i++) otree.processEvent(removed, TopicNameIF.EVENT_REMOVE_VARIANT, null, variants[i]); } }
@Override public void processEvent(Object object, String event, Object new_value, Object old_value) { TopicNameIF added = (TopicNameIF)new_value; // Fire object added event treeAddEvent(object, TopicNameIF.EVENT_ADDED, added); // Add variants Object[] variants = added.getVariants().toArray(); for (int i=0; i < variants.length; i++) otree.processEvent(added, TopicNameIF.EVENT_ADD_VARIANT, variants[i], null); } }
protected void validate(TopicNameIF basename, TopicNameConstraint constraint) throws SchemaViolationException { validate(basename, constraint.getVariantConstraints(), basename.getVariants()); }
@Get public Collection<VariantNameIF> getVariantNames() { TopicNameIF name = Parameters.TOPICNAME.required(this); return name.getVariants(); }
private void addVariantNames(List matches, String var, TopicIF topic) { Iterator it = topic.getTopicNames().iterator(); while (it.hasNext()) { TopicNameIF bn = (TopicNameIF) it.next(); Iterator it2 = bn.getVariants().iterator(); while (it2.hasNext()) { VariantNameIF vn = (VariantNameIF) it2.next(); addMatch(matches, var, vn); } } }
private static void copyVariants(TopicNameIF target, TopicNameIF source, Map<TopicIF, TopicIF> mergemap) { TopicMapBuilderIF builder = target.getTopicMap().getBuilder(); Iterator<VariantNameIF> it = source.getVariants().iterator(); while (it.hasNext()) { VariantNameIF sv = it.next(); VariantNameIF tv = builder.makeVariantName(target, sv.getValue(), sv.getDataType()); copyScope(tv, sv, mergemap); copyReifier(tv, sv, mergemap); copySourceLocators(tv, sv); } }
public void testBothBoundTrueVariant() throws InvalidQueryException, IOException { load("uri-vn.xtm"); TopicIF ontopia = getTopicById("ontopia"); TopicNameIF bn = (TopicNameIF) ontopia.getTopicNames().iterator().next(); VariantNameIF vn = (VariantNameIF) bn.getVariants().iterator().next(); List matches = new ArrayList(); matches.add(new HashMap()); verifyQuery(matches, "resource(@" + vn.getObjectId() +", \"http://www.ontopia.net/topicmaps/materials/logo.gif\")?"); closeStore(); }
public void testWithBothBoundTrue() throws InvalidQueryException, IOException { load("family.ltm"); List matches = new ArrayList(); TopicIF topic = getTopicById("petter"); TopicNameIF bn = (TopicNameIF) topic.getTopicNames().iterator().next(); VariantNameIF vn = (VariantNameIF) bn.getVariants().iterator().next(); matches.add(new HashMap()); verifyQuery(matches, "variant(@" + bn.getObjectId() + ", @" + vn.getObjectId() + ")?"); closeStore(); }
public void testLookupVariant() throws InvalidQueryException, IOException { load("uri-vn.xtm"); TopicIF ontopia = getTopicById("ontopia"); TopicNameIF bn = (TopicNameIF) ontopia.getTopicNames().iterator().next(); VariantNameIF vn = (VariantNameIF) bn.getVariants().iterator().next(); List matches = new ArrayList(); addMatch(matches, "OBJ", vn); verifyQuery(matches, "resource($OBJ, \"http://www.ontopia.net/topicmaps/materials/logo.gif\")?"); closeStore(); }
public void testBothBoundFalseVariant() throws InvalidQueryException, IOException { load("uri-vn.xtm"); TopicIF ontopia = getTopicById("ontopia"); TopicNameIF bn = (TopicNameIF) ontopia.getTopicNames().iterator().next(); VariantNameIF vn = (VariantNameIF) bn.getVariants().iterator().next(); List matches = new ArrayList(); verifyQuery(matches, "resource(@" + vn.getObjectId() +", \"http://www.ontopia.com/topicmaps/materials/logo.gif\")?"); closeStore(); }
public void testWithSpecificVariant() throws InvalidQueryException, IOException { load("family.ltm"); List matches = new ArrayList(); TopicIF topic = getTopicById("kfg"); TopicNameIF bn = (TopicNameIF) topic.getTopicNames().iterator().next(); VariantNameIF vn = (VariantNameIF) bn.getVariants().iterator().next(); addMatch(matches, "TN", bn); verifyQuery(matches, "variant($TN, @" + vn.getObjectId() + ")?"); closeStore(); }
public void testGetVariantLocator() throws InvalidQueryException, IOException { load("uri-vn.xtm"); TopicIF ontopia = getTopicById("ontopia"); TopicNameIF bn = (TopicNameIF) ontopia.getTopicNames().iterator().next(); VariantNameIF vn = (VariantNameIF) bn.getVariants().iterator().next(); List matches = new ArrayList(); addMatch(matches, "LOCATOR", "http://www.ontopia.net/topicmaps/materials/logo.gif"); verifyQuery(matches, "resource(@" + vn.getObjectId() +", $LOCATOR)?"); closeStore(); }
public void testWithBothBoundFalse() throws InvalidQueryException, IOException { load("family.ltm"); List matches = new ArrayList(); TopicIF topic1 = getTopicById("petter"); TopicNameIF bn1 = (TopicNameIF) topic1.getTopicNames().iterator().next(); TopicIF topic2 = getTopicById("asle"); TopicNameIF bn2 = (TopicNameIF) topic2.getTopicNames().iterator().next(); VariantNameIF vn = (VariantNameIF) bn2.getVariants().iterator().next(); verifyQuery(matches, "variant(@" + bn1.getObjectId() + ", @" + vn.getObjectId() + ")?"); closeStore(); }
private void verifySingleTopicName(TopicIF topic, String name) { Assert.assertTrue("topic has spurious children", topic.getTypes().size() == 0 && topic.getRoles().size() == 0 && topic.getOccurrences().size() == 0); Assert.assertTrue("topic has wrong number of base names", topic.getTopicNames() .size() == 1); TopicNameIF basename = (TopicNameIF) topic.getTopicNames().iterator() .next(); Assert.assertTrue("wrong basename value: '" + basename.getValue() + "'", basename .getValue().equals(name)); Assert.assertTrue("basename has spurious children", basename.getVariants().size() == 0); Assert.assertTrue("basename has spurious themes", basename.getScope().size() == 0); }
public void testVariantRemoval() { TopicIF topic = builder.makeTopic(); TopicNameIF bn = builder.makeTopicName(topic, ""); VariantNameIF vn = builder.makeVariantName(bn, "duplicate"); vn = builder.makeVariantName(bn, "duplicate"); DuplicateSuppressionUtils.removeDuplicates(bn); assertTrue("duplicate variant names were not removed", bn.getVariants().size() == 1); }
@Override public void run(MasterTest mt) { TopicNameIF bn = (TopicNameIF)topicmap.getObjectById(mt.objectId); assertTrue("Added base name not found", bn != null); if (testInitialProperties) { assertTrue("Source locators is set", bn.getItemIdentifiers().isEmpty()); assertTrue("Scope is set", bn.getScope().isEmpty()); assertTrue("Type is set", bn.getType() == null); assertTrue("Value is set", "".equals(bn.getValue())); assertTrue("Variants is set", bn.getVariants().isEmpty()); } } });