@Override public void processEvent(Object object, String event, TopicNameIF new_value, TopicNameIF old_value) { objects.add(new_value.getValue(), new_value); } }
private static String getTopicName(TopicIF topic) { if (topic == null) return null; Iterator<TopicNameIF> it = topic.getTopicNames().iterator(); if (it.hasNext()) { TopicNameIF name = it.next(); return name.getValue(); } return null; } }
@Override public int compare(TopicNameIF bn1, TopicNameIF bn2) { if (Objects.equals(bn1, bn2)) return 0; int retVal = scopeComparator.compare(filterCollection(bn1.getScope()), filterCollection(bn2.getScope())); if (retVal == 0) retVal = lazyStringCompare(bn1.getValue(), bn2.getValue()); return retVal; }
@Override public void processEvent(Object object, String event, TopicNameIF new_value, TopicNameIF old_value) { objects.remove(old_value.getValue(), old_value); } }
public static List<TopicNameIF> findTopicNames(TopicIF nType, TopicIF topicIF, String value) { List<TopicNameIF> result = new ArrayList<TopicNameIF>(); Iterator<TopicNameIF> it = topicIF.getTopicNames().iterator(); while (it.hasNext()) { TopicNameIF nameIF = it.next(); if (Objects.equals(nameIF.getValue(), value) && Objects.equals(nameIF.getType(), nType)) result.add(nameIF); } return result; }
public static String toString(String impl, TopicNameIF basename) { String id = UNASSIGNED; try { if (basename.getTopicMap() != null) id = basename.getObjectId(); if (basename.getValue() != null) return "[" + impl + ", " + id + ", '" + basename.getValue() + "']"; else return "[" + impl + ", " + id + "]"; } catch (Throwable t) { return "[" + impl + ", " + basename.getObjectId() + "!]"; } }
public static List<TopicNameIF> findTopicNames(TopicIF nType, TopicIF topicIF, String value, Collection<TopicIF> scope) { List<TopicNameIF> result = new ArrayList<TopicNameIF>(); Iterator<TopicNameIF> it = topicIF.getTopicNames().iterator(); while (it.hasNext()) { TopicNameIF nameIF = it.next(); if (Objects.equals(nameIF.getValue(), value) && Objects.equals(nameIF.getType(), nType) && CollectionUtils.equalsUnorderedSet(nameIF.getScope(), scope)) result.add(nameIF); } return result; }
protected static void normalizeTopicNames(TopicMapIF tm) { Iterator it = tm.getTopics().iterator(); while (it.hasNext()) { TopicIF topic = (TopicIF) it.next(); Iterator it2 = topic.getTopicNames().iterator(); while (it2.hasNext()) { TopicNameIF bn = (TopicNameIF) it2.next(); bn.setValue(StringUtils.normalizeSpace(bn.getValue())); } } }
public static List<TopicNameIF> findTopicNames(TopicIF nType, TopicIF topicIF, String value) { List<TopicNameIF> result = new ArrayList<TopicNameIF>(); Iterator<TopicNameIF> it = topicIF.getTopicNames().iterator(); while (it.hasNext()) { TopicNameIF nameIF = it.next(); if (ObjectUtils.equals(nameIF.getValue(), value) && ObjectUtils.equals(nameIF.getType(), nType)) result.add(nameIF); } return result; }
/** * PUBLIC: Makes a key for a topic name. The key is made up of * a scope key and a value key. * * @return string containing key */ public static String makeTopicNameKey(TopicNameIF bn) { return makeScopeKey(bn) + SPACER + makeTypedKey(bn) + "$$" + bn.getValue(); }
/** * PUBLIC: Makes a key for a topic name, as it would look in another * topic map. * * @since 5.1.3 * @return string containing key */ public static String makeTopicNameKey(TopicNameIF bn, TopicMapIF othertm) { return makeScopeKey(bn, othertm) + SPACER + makeTypedKey(bn, othertm) + "$$" + bn.getValue(); }
public static List<TopicNameIF> findTopicNames(TopicIF nType, TopicIF topicIF, String value, Collection<TopicIF> scope) { List<TopicNameIF> result = new ArrayList<TopicNameIF>(); Iterator<TopicNameIF> it = topicIF.getTopicNames().iterator(); while (it.hasNext()) { TopicNameIF nameIF = it.next(); if (ObjectUtils.equals(nameIF.getValue(), value) && ObjectUtils.equals(nameIF.getType(), nType) && CollectionUtils.equalsUnorderedSet(nameIF.getScope(), scope)) result.add(nameIF); } return result; }
@Override public DocumentIF generate(TopicNameIF basename) { // Create document DocumentIF doc = createDocument(); // Add fields addObjectFields(doc, basename, "B"); addContentField(doc, basename.getValue()); return doc; }
@Override public void run(MasterTest mt) { TopicNameIF bn = (TopicNameIF)topicmap.getObjectById(mt.objectId); assertTrue("Base name value is not set", "New name".equals(bn.getValue())); } });
public void testParam2() throws InvalidQueryException, IOException { load("subclasses.ltm"); TopicIF subclass = getTopicById("subclass"); TopicNameIF name = subclass.getTopicNames().iterator().next(); Map params = new HashMap(); params.put("v", "SUBCLASS"); update("update value(@" + name.getObjectId() + ", %v%)", params); assertTrue("name value not changed", name.getValue().equals("SUBCLASS")); }
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 testParam() throws InvalidQueryException, IOException { load("subclasses.ltm"); TopicIF subclass = getTopicById("subclass"); TopicNameIF name = subclass.getTopicNames().iterator().next(); Map params = makeArguments("name", name); update("update value(%name%, \"SUBCLASS\")", params); assertTrue("name value not changed", name.getValue().equals("SUBCLASS")); }
public void testParam3() throws InvalidQueryException, IOException { load("subclasses.ltm"); TopicIF subclass = getTopicById("subclass"); TopicNameIF name = subclass.getTopicNames().iterator().next(); Map params = makeArguments("name", name); update("update value($N, \"SUBCLASS\") from $N = %name%", params); assertTrue("name value not changed", name.getValue().equals("SUBCLASS")); }