/** * INTERNAL: Grabs the association roles of the given association * * @param object the given object; AssociationIF * @return object which is a collection of AssociationRoleIF objects */ @Override public Collection<AssociationRoleIF> grab(AssociationIF object) { return object.getRoles(); }
private Collection<AssociationRoleIF> getAssociationRoles(AssociationIF association, TopicIF roleType) { addMixInAnnotations(AssociationRoleIF.class, MAssociationRoleWithoutAssociation.class); if (roleType != null) { return association.getRolesByType(roleType); } else { return association.getRoles(); } }
public int getArity() { if (assoctype) return assoc.getRoles().size(); else return 2; }
private static AssociationRoleIF getOtherRole(AssociationIF assoc, AssociationRoleIF role) { // INV: assoc.getRoles().size() == 2 Iterator it = assoc.getRoles().iterator(); AssociationRoleIF other = (AssociationRoleIF) it.next(); if (other == role) other = (AssociationRoleIF) it.next(); return other; }
@Override public Set<Role> getRoles() { return topicMap.wrapSet(wrapped.getRoles()); }
private boolean arePlayersVisible(AssociationIF association, TopicIF source) { for (Iterator rolesIt = association.getRoles().iterator(); rolesIt.hasNext();) { TopicIF player = ((AssociationRoleIF) rolesIt.next()).getPlayer(); if (player == null) continue; if (!source.equals(player) && configman.isVisible(player)) return true; } return false; }
/** * Gets the assoc types ordered. */ protected String[] getAssociationRoleTypesOrdered() { Collection roletypes = new ArrayList(); Iterator it = association.getRoles().iterator(); while (it.hasNext()) { String name = getName(((AssociationRoleIF)it.next()).getType()); roletypes.add(name); } return sortAlpha(roletypes); }
protected TopicIF getPlayer(AssociationIF assoc, TopicIF roleType) { Iterator<AssociationRoleIF> it = assoc.getRoles().iterator(); while (it.hasNext()) { AssociationRoleIF role = it.next(); if (roleType.equals(role.getType())) return role.getPlayer(); } return null; }
@Override public void processEvent(Object object, String event, Object new_value, Object old_value) { AssociationIF assoc = (AssociationIF)object; Iterator<AssociationRoleIF> iter = assoc.getRoles().iterator(); while (iter.hasNext()) { AssociationRoleIF role = iter.next(); TopicIF topic = role.getPlayer(); if (topic != null) topicModified(topic); } } }
private void countMaxRolesOf(AssociationIF association) { int newCount = association.getRoles().size(); int oldCount = maxRolesOf(association); if (oldCount < newCount) roleCounter.put(lazyTypeElementId(association), new Integer(newCount)); }
@Override public void processEvent(Object object, String event, Object new_value, Object old_value) { AssociationIF removed = (AssociationIF)old_value; // Fire tree event treeRemoveEvent(object, AssociationIF.EVENT_REMOVED, removed); // Remove association roles Object[] roles = removed.getRoles().toArray(); for (int i=0; i < roles.length; i++) otree.processEvent(removed, AssociationIF.EVENT_REMOVE_ROLE, null, roles[i]); } }
@Override public void processEvent(Object object, String event, Object new_value, Object old_value) { AssociationIF added = (AssociationIF)new_value; // Fire object added event treeAddEvent(object, AssociationIF.EVENT_ADDED, added); // Add association roles Object[] roles = added.getRoles().toArray(); for (int i=0; i < roles.length; i++) otree.processEvent(added, AssociationIF.EVENT_ADD_ROLE, roles[i], null); } }
protected boolean includeAssociation(AssociationIF assoc) { for (AssociationRoleIF role : assoc.getRoles()) if (includeTopic(role.getPlayer())) return true; return false; // not keeping any of the players, so... }
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; }
protected boolean includeAssociation(AssociationIF assoc) { for (AssociationRoleIF role : assoc.getRoles()) if (includeTopic(role.getPlayer())) return true; return false; // not keeping any of the players, so... }
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()); }
protected void writeMembers(AssociationIF assoc, ContentHandler dh) throws SAXException { Iterator iter = assoc.getRoles().iterator(); while (iter.hasNext()){ AssociationRoleIF role = (AssociationRoleIF)iter.next(); dh.startElement(EMPTY_NAMESPACE, EMPTY_LOCALNAME, "member", EMPTY_ATTR_LIST); if (role.getType() != null) writeRoleSpec(role.getType(), dh); if (role.getPlayer() != null) writeTopicRef(role.getPlayer(), dh); dh.endElement(EMPTY_NAMESPACE, EMPTY_LOCALNAME, "member"); } }
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; }
@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()); } } });