@Override public Collection<AssociationIF> getAssociations() { Set<AssociationIF> assocs = new HashSet<AssociationIF>(); for (AssociationRoleIF role : roles) { assocs.add(role.getAssociation()); } return Collections.unmodifiableSet(assocs); }
@Override public boolean evaluate(AssociationRoleIF role) { return role.getAssociation().getType().equals(association_type); } });
public boolean isVisible(AssociationRoleIF role) { // A role is only visible if it is not part of an optimized // association, and the association object it is part of // is itself visible. The visibility of the roles is taken // care of in #assertNode() if (role.getAssociation().getRoles().size() == 2) return false; return isVisible(role.getAssociation()); }
@Override public Collection<AssociationIF> getAssociationsByType(TopicIF type) { Set<AssociationIF> assocs = new HashSet<AssociationIF>(); for (AssociationRoleIF role : roles) { AssociationIF assoc = role.getAssociation(); if (assoc.getType().equals(type)) { assocs.add(assoc); } } return Collections.unmodifiableSet(assocs); }
@Override public TopicIF getTopicMapType() { // For display purposes we show the associated association type return role.getAssociation().getType(); }
@Override public Association getParent() { return topicMap.wrapAssociation(wrapped.getAssociation()); }
public static List<AssociationRoleIF> findRoles(TopicIF aType, TopicIF rType, TopicIF player) { List<AssociationRoleIF> result = new ArrayList<AssociationRoleIF>(); Iterator<AssociationRoleIF> it = player.getRoles().iterator(); while (it.hasNext()) { AssociationRoleIF role = it.next(); AssociationIF association = role.getAssociation(); if (Objects.equals(role.getType(), rType) && Objects.equals(association.getType(), aType)) result.add(role); } return result; }
public static AssociationIF findUnaryAssociation( TopicMap tm, TopicIF aType, TopicIF player, TopicIF rType) { Iterator<AssociationRoleIF> iter = player.getRoles().iterator(); while (iter.hasNext()) { AssociationRoleIF role = iter.next(); AssociationIF assoc = role.getAssociation(); if (Objects.equals(role.getType(), rType) && Objects.equals(assoc.getType(), aType)) return assoc; } return null; }
public static List<AssociationRoleIF> findRoles(TopicIF aType, TopicIF rType, TopicIF player, Collection<TopicIF> scope) { List<AssociationRoleIF> result = new ArrayList<AssociationRoleIF>(); Iterator<AssociationRoleIF> it = player.getRoles().iterator(); while (it.hasNext()) { AssociationRoleIF role = it.next(); AssociationIF association = role.getAssociation(); if (Objects.equals(role.getType(), rType) && Objects.equals(association.getType(), aType) && CollectionUtils.equalsUnorderedSet(association.getScope(), scope)) result.add(role); } return result; }
public static boolean hasBinaryAssociation(TopicIF player1, TopicIF aType, TopicIF rType1, TopicIF rType2) { for (AssociationRoleIF role : player1.getRolesByType(rType1, aType)) { AssociationIF assoc = role.getAssociation(); for (AssociationRoleIF role2 : assoc.getRoles()) if (!Objects.equals(role2, role) && role2.getType().equals(rType2)) return true; } return false; }
public static List<AssociationRoleIF> findRoles(TopicIF aType, TopicIF rType, TopicIF player) { List<AssociationRoleIF> result = new ArrayList<AssociationRoleIF>(); Iterator<AssociationRoleIF> it = player.getRoles().iterator(); while (it.hasNext()) { AssociationRoleIF role = it.next(); AssociationIF association = role.getAssociation(); if (ObjectUtils.equals(role.getType(), rType) && ObjectUtils.equals(association.getType(), aType)) result.add(role); } return result; }
public static AssociationIF findUnaryAssociation( TopicMap tm, TopicIF aType, TopicIF player, TopicIF rType) { Iterator<AssociationRoleIF> iter = player.getRoles().iterator(); while (iter.hasNext()) { AssociationRoleIF role = iter.next(); AssociationIF assoc = role.getAssociation(); if (ObjectUtils.equals(role.getType(), rType) && ObjectUtils.equals(assoc.getType(), aType)) return assoc; } return null; }
public static List<AssociationRoleIF> findRoles(TopicIF aType, TopicIF rType, TopicIF player, Collection<TopicIF> scope) { List<AssociationRoleIF> result = new ArrayList<AssociationRoleIF>(); Iterator<AssociationRoleIF> it = player.getRoles().iterator(); while (it.hasNext()) { AssociationRoleIF role = it.next(); AssociationIF association = role.getAssociation(); if (ObjectUtils.equals(role.getType(), rType) && ObjectUtils.equals(association.getType(), aType) && CollectionUtils.equalsUnorderedSet(association.getScope(), scope)) result.add(role); } return result; }
public static boolean hasBinaryAssociation(TopicIF player1, TopicIF aType, TopicIF rType1, TopicIF rType2) { for (AssociationRoleIF role : player1.getRolesByType(rType1, aType)) { AssociationIF assoc = role.getAssociation(); for (AssociationRoleIF role2 : assoc.getRoles()) if (ObjectUtils.different(role2, role) && role2.getType().equals(rType2)) return true; } return false; }
public void testParentAssociation() { assertTrue("parent not set to right object", role.getAssociation().equals(parent)); }
public void testAssociation() { LocatorIF loc = base.resolveAbsolute("#topic-1"); TopicIF topic = (TopicIF)tm.getObjectByItemIdentifier(loc); AssociationRoleIF assocrl = (AssociationRoleIF)topic.getRoles().iterator().next(); AssociationIF association = assocrl.getAssociation(); tmobjectTest(association, true, true); }
public void testBothBoundTrue() throws InvalidQueryException, IOException { load("bb-test.ltm"); List matches = new ArrayList(); TopicIF teacher = getTopicById("larer"); AssociationRoleIF role = (AssociationRoleIF) teacher.getRoles().iterator().next(); AssociationIF assoc = role.getAssociation(); matches.add(new HashMap()); verifyQuery(matches, "association-role(@" + assoc.getObjectId() + ", @" + role.getObjectId() + ")?"); closeStore(); }
public void testBothBoundFalse() throws InvalidQueryException, IOException { load("bb-test.ltm"); List matches = new ArrayList(); TopicIF teacher = getTopicById("gdm"); Iterator it = teacher.getRoles().iterator(); AssociationRoleIF role = (AssociationRoleIF) it.next(); AssociationRoleIF role2 = (AssociationRoleIF) it.next(); AssociationIF assoc = role2.getAssociation(); verifyQuery(matches, "association-role(@" + assoc.getObjectId() + ", @" + role.getObjectId() + ")?"); closeStore(); }
public void testSpecificRole() throws InvalidQueryException, IOException { load("bb-test.ltm"); List matches = new ArrayList(); TopicIF teacher = getTopicById("larer"); AssociationRoleIF role = (AssociationRoleIF) teacher.getRoles().iterator().next(); AssociationIF assoc = role.getAssociation(); addMatch(matches, "ASSOC", assoc); verifyQuery(matches, "association-role($ASSOC, @" + role.getObjectId() + ")?"); closeStore(); }
@Override public void processEvent(Object object, String event, Object new_value, Object old_value) { AssociationRoleIF removed = (AssociationRoleIF)old_value; // ignore event if player is null TopicIF player = removed.getPlayer(); if (player == null) return; // get association type AssociationIF assoc = removed.getAssociation(); TopicIF atype = (assoc == null ? null : assoc.getType()); // unregister entry removeEntry(new ParameterArray(new Object[] { i(player), i(removed.getType()), i(atype) }), removed); } }