@Override public TopicIF getTopicMapType() { return association.getType(); }
protected TMAssociationNode getNode(AssociationIF association) { TopicIF type = association.getType(); TMAssociationNode node = getAssociationNode(association, type); if (node != null) return node; return null; }
@Override public boolean evaluate(AssociationRoleIF role) { return role.getAssociation().getType().equals(association_type); } });
InternalAssociation(AssociationIF association) { this.associationtype = association.getType(); this.association = association; roleTypes = addAssocRoleTypes(association); number_of_assocs = 1; assocRoles = new HashMap(); associations = new ArrayList(); //roles = getAssociationRoleTypesOrdered(); }
@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(); }
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 String toString(String impl, AssociationIF assoc) { String id = UNASSIGNED; try { if (assoc.getTopicMap() != null) id = assoc.getObjectId(); return "[" + impl + ", " + id + ", type: " + assoc.getType() + "]"; } catch (Throwable t) { return "[" + impl + ", " + id + "]"; } }
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 boolean isVisible(AssociationIF assoc) { // Only check the visibility of the association // The visibility of the roles is taken care of in #assertNode() return isAssociationTypeVisible(assoc.getType()) && matchesFilter(assoc.getScope()); }
@Override public void run(MasterTest mt) { AssociationIF a = (AssociationIF)topicmap.getObjectById(mt.objectId); TopicIF type = (TopicIF)topicmap.getObjectById(mt.value); assertTrue("Association type is not set", type.equals(a.getType())); } });
public boolean ok(Object object) { if (object instanceof TopicIF) { return includeTopic((TopicIF)object); } else if (object instanceof AssociationIF) { return includeTopic(((AssociationIF)object).getType()); } else if (object instanceof OccurrenceIF) { return includeTopic(((OccurrenceIF)object).getType()); } else if (object instanceof TopicNameIF) { TopicIF type = ((TopicNameIF)object).getType(); return type == null ? true : includeTopic(type); } return true; }
@Override public void run(MasterTest mt) { AssociationIF a = (AssociationIF)topicmap.getObjectById(mt.objectId); assertTrue("Association type is set", a.getType().getSubjectIdentifiers().contains(URILocator.create("type:cleared"))); } });
@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); } }
@Override public void run(MasterTest mt) { AssociationIF a = (AssociationIF)topicmap.getObjectById(mt.objectId); assertTrue("Added association not found", a != null); if (testInitialProperties) { assertTrue("Source locators is set", a.getItemIdentifiers().isEmpty()); assertTrue("Scope is set", a.getScope().isEmpty()); assertTrue("Type is set", a.getType() == null); assertTrue("Roles is set", a.getRoles().isEmpty()); } } });
@Test public void testAssociation() throws Exception { AssociationIF assoc = tm1.getBuilder().makeAssociation(foo1); tm1.getBuilder().makeAssociationRole(assoc, tm1.getBuilder().makeTopic(), tm1.getBuilder().makeTopic()); assoc.setReifier(foo1); // todo: assoc.addTheme(foo1); pending #265 concurrentCommit(); // verify no inconsistenties were created check(tm1, assoc.getType(), "Association", "type"); check(tm1, assoc.getReifier(), "Association", "reifier"); // todo: check(tm1, assoc.getScope().iterator().next().getObjectId(), "Association", "scope"); pending #265 }