/** * Adds an association to the set of associations. */ protected void addAssociation(AssociationIF association) { // Check to see if association is already a member of this topic map if (association.getTopicMap() == this) return; // Check if used elsewhere. if (association.getTopicMap() != null) throw new ConstraintViolationException("Moving objects is not allowed."); // Notify listeners fireEvent(TopicMapIF.EVENT_ADD_ASSOCIATION, association, null); // Set topic map property ((Association)association).setTopicMap(this); }
/** * INTERNAL: Sets the association that the association role belongs to. [parent] */ protected void setAssociation(AssociationIF assoc) { // Set parent topic map setTopicMap((assoc == null ? null : (TopicMap)assoc.getTopicMap())); // Notify transaction valueChanged(LF_association, assoc, true); }
/** * Removes an associations from the set of associations. */ protected void removeAssociation(AssociationIF association) { // Check to see if association is not a member of this topic map if (association.getTopicMap() != this) return; // Notify listeners fireEvent(TopicMapIF.EVENT_REMOVE_ASSOCIATION, null, association); // Unset topic map property ((Association)association).setTopicMap(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 + "]"; } }
if (existing.getTopicMap() != null) { copySourceLocators(existing, assoc); assoc.remove();
TopicMapIF topicmap = a.getTopicMap();
public void testParentTopicMap() { assertTrue("parent topic map is not correct", assoc.getTopicMap() == topicmap); }
max = Integer.MAX_VALUE; TypeSpecification typeSpec = constraint.getTypeSpecification(); Collection types = this.getMatchingTopics(assoc.getTopicMap(), typeSpec); int curNumber = this.getObjectsOfType(assocRoleTypes, types).size();
@Override public void setPlayer(TopicIF player) { if (player == null) throw new NullPointerException("Association role player must not be null."); CrossTopicMapException.check(player, this); TopicIF oldplayer = getPlayer(); // Notify listeners fireEvent(AssociationRoleIF.EVENT_SET_PLAYER, player, oldplayer); // Notify transaction valueChanged(LF_player, player, true); // Unregister association role with topic AssociationIF assoc = getAssociation(); if (oldplayer != null && assoc != null && assoc.getTopicMap() != null) ((Topic)oldplayer).removeRole(this); // Register association role with topic if (player != null && assoc != null && assoc.getTopicMap() != null) ((Topic)player).addRole(this); }
TopicMapIF tm = association.getTopicMap(); TopicIF shortName = (tm == null ? null : tm.getTopicBySubjectIdentifier(VizUtils .makeLocator(SHORT_NAME)));
public void perform(ActionParametersIF params, ActionResponseIF response) { AssociationIF assoc = (AssociationIF) params.get(0); TopicIF player = (TopicIF) params.getTMObjectValue(); if (player == null) return; // nothing to be done TopicIF type = (TopicIF) params.get(1); TopicMapBuilderIF builder = assoc.getTopicMap().getBuilder(); builder.makeAssociationRole(assoc, type, player); }
AssociationIF a = r.getAssociation(); if (a != null) { if (a.getTopicMap() != null) { log.debug(" -R " + topic + " :" + r.getType()); a.remove();
AssociationIF a = r.getAssociation(); if (a != null) { if (a.getTopicMap() != null) { log.debug(" -R {} :{}", topic, r.getType()); a.remove();
@Override public void validate(AssociationIF association) throws SchemaViolationException { TopicMapIF tm = association.getTopicMap(); // find appropriate class AssociationClass klass = (AssociationClass) findClass(association, schema.getAssociationClasses()); if (klass == null) { if (schema.isStrict()) handler.violation("No matching rule for association", tm, association, null); return; } validateScope(tm, association, klass); // characteristics validate(association, klass.getRoleConstraints(), association.getRoles(), true); }
TopicMapIF topicmap = assoc.getTopicMap(); TopicIF preferredRoleType = getTopic(topicmap, "preferred-role"); TopicIF namePropertyType = getTopic(topicmap, "name-property");
public void testTopicRemovalPolicyRole() { TopicIF topic = builder.makeTopic(); TopicIF other = builder.makeTopic(); AssociationIF assoc = builder.makeAssociation(builder.makeTopic()); AssociationRoleIF role1 = builder.makeAssociationRole(assoc, builder.makeTopic(), topic); AssociationRoleIF role2 = builder.makeAssociationRole(assoc, builder.makeTopic(), other); topic.remove(); assertTrue("association not deleted", assoc.getTopicMap() == null); assertTrue("role1 not deleted", role1.getTopicMap() == null); assertTrue("role2 not deleted", role2.getTopicMap() == null); assertTrue("remaining topic has roles left", other.getRoles().size() == 0); }
public void testTopicAssociationDeletion() { TopicMapIF topicmap = makeTopicMap(); TopicMapBuilderIF builder = topicmap.getBuilder(); TopicIF morituri = builder.makeTopic(); TopicIF other = builder.makeTopic(); AssociationIF assoc = builder.makeAssociation(builder.makeTopic()); AssociationRoleIF role1 = builder.makeAssociationRole(assoc, builder.makeTopic(), morituri); AssociationRoleIF role2 = builder.makeAssociationRole(assoc, builder.makeTopic(), other); morituri.remove(); assertTrue("Topic still connected to topic map", morituri.getTopicMap() == null); assertTrue("Topic map has too many topics", topicmap.getTopics().size() == 4); assertTrue("Role 1 still connected to topic map", role1.getTopicMap() == null); assertTrue("Role 2 still connected to topic map", role2.getTopicMap() == null); assertTrue("Association still connected to topic map", assoc.getTopicMap() == null); assertTrue("Topic map still has association", topicmap.getAssociations().size() == 0); }
assertNull("Association bound to topicmap after removal", assoc.getTopicMap()); assertNull("Occurrence bound to topicmap after removal", occurrence.getTopicMap()); assertNull("Topic name bound to topicmap after removal", name.getTopicMap());