/** * PUBLIC: Create a unary association of the configured type, where * player is the role player. * @since 4.0 */ public AssociationIF makeAssociation(TopicIF player) { AssociationIF assoc = builder.makeAssociation(assoctype); builder.makeAssociationRole(assoc, role1type, player); if (scope != null) { Iterator<TopicIF> it = scope.iterator(); while (it.hasNext()) assoc.addTheme(it.next()); } return assoc; }
/** * PUBLIC: Create a binary association of the configured type, where * player1 plays the first role and player2 the second. */ public AssociationIF makeAssociation(TopicIF player1, TopicIF player2) { AssociationIF assoc = builder.makeAssociation(assoctype); builder.makeAssociationRole(assoc, role1type, player1); builder.makeAssociationRole(assoc, role2type, player2); if (scope != null) { Iterator<TopicIF> it = scope.iterator(); while (it.hasNext()) assoc.addTheme(it.next()); } return assoc; }
/** * PUBLIC: Create a ternary association of the configured type, where * player1 plays the first role, player2 the second, and player3 the * third. * @throws IllegalArgumentException if the builder is only configured * for binary associations. * @since 1.3 */ public AssociationIF makeAssociation(TopicIF player1, TopicIF player2, TopicIF player3) { if (role3type == null) throw new IllegalArgumentException("Builder only configured for binary associations!"); AssociationIF assoc = builder.makeAssociation(assoctype); builder.makeAssociationRole(assoc, role1type, player1); builder.makeAssociationRole(assoc, role2type, player2); builder.makeAssociationRole(assoc, role3type, player3); if (scope != null) { Iterator<TopicIF> it = scope.iterator(); while (it.hasNext()) assoc.addTheme(it.next()); } return assoc; }
Iterator<TopicIF> it = scope.iterator(); while (it.hasNext()) assoc.addTheme(it.next());
public void perform(ActionParametersIF params, ActionResponseIF response) { // create new association //test params ActionSignature paramsType = ActionSignature.getSignature("m t? t?"); paramsType.validateArguments(params, this); TopicMapIF topicmap = (TopicMapIF) params.get(0); TopicMapBuilderIF builder = topicmap.getBuilder(); TopicIF assocType = (TopicIF) params.get(1); if (assocType == null) assocType = builder.makeTopic(); AssociationIF assoc = builder.makeAssociation(assocType); Collection scope = params.getCollection(2); if (scope != null) { Iterator it = scope.iterator(); while (it.hasNext()) { TopicIF theme = (TopicIF) it.next(); assoc.addTheme(theme); } } response.addParameter(Constants.RP_ASSOC_ID, assoc.getObjectId()); }
@Override public void run() { AssociationIF a = getAssociation(); TopicIF theme = builder.makeTopic(); this.data.put("scope", theme); a.addTheme(theme); this.objectId = a.getObjectId(); this.value = theme.getObjectId(); } });
@Override public Association createAssociation(Topic type, Topic... scope) { Check.typeNotNull(this, type); Check.scopeNotNull(this, scope); Check.scopeInTopicMap(this, scope); Check.typeInTopicMap(this, type); AssociationIF assoc = wrapped.getBuilder().makeAssociation( unwrapTopic(type)); for (Topic theme : scope) { assoc.addTheme(unwrapTopic(theme)); } return wrapAssociation(assoc); }
/** * PUBLIC: Merges the source association into the target topic * map. Makes no attempt to verify that the source association is * not already present. * @return The new association in the target topic map. * @since 5.1.3 */ public static AssociationIF mergeInto(TopicMapIF topicmap, AssociationIF source) { TopicMapBuilderIF builder = topicmap.getBuilder(); TopicIF type = findTopic(topicmap, source.getType()); AssociationIF newa = builder.makeAssociation(type); for (TopicIF theme : source.getScope()) newa.addTheme(findTopic(topicmap, theme)); for (AssociationRoleIF role : source.getRoles()) { type = findTopic(topicmap, role.getType()); TopicIF player = findTopic(topicmap, role.getPlayer()); builder.makeAssociationRole(newa, type, player); } return newa; }
public void testMergeAssociationScopeUse() { try { TopicIF atype = builder1.makeTopic(); TopicIF t1 = builder1.makeTopic(); TopicIF t2 = builder1.makeTopic(); AssociationIF assoc = builder1.makeAssociation(atype); assoc.addTheme(t2); MergeUtils.mergeInto(t1, t2); assertTrue("association scope corrupted", assoc.getScope().size() == 1); assertTrue("association theme replacement not done correctly", assoc.getScope().contains(t1)); } catch (ConstraintViolationException e) { fail("merge of topics unaccountably failed" + e.getMessage()); } }
assoc.addTheme(morituri); occurrence.addTheme(morituri); name.addTheme(morituri);
as.addTheme(as_theme);
as.addTheme(other); afterTest();