public void perform(ActionParametersIF params, ActionResponseIF response) { AssociationRoleIF role = (AssociationRoleIF) params.get(0); //! TopicIF player = (TopicIF) params.get(1); role.setPlayer(null); // don't really need the topic, actually }
public void changeRank(TopicIF realTopic, boolean up) { TopicIF topic = tmConfig.getConfigTopic(realTopic); // Get the relevant roles played by 'topic' and 'swappedTopic', i.e. the // topic is should be swapped with. AssociationRoleIF outerRole = getRankRole(topic, !up); AssociationRoleIF innerRole = getRankRole(topic, up); AssociationIF association = getRankAssociation(innerRole); AssociationRoleIF newInnerRole = getRankRole(association, up); TopicIF swappedTopic = newInnerRole.getPlayer(); AssociationRoleIF newOuterRole = getRankRole(swappedTopic, up); // Replace 'topic's position by 'swappedTopic'. outerRole.setPlayer(swappedTopic); innerRole.setPlayer(swappedTopic); // Replace 'swappedTopic's position by 'topic'. newOuterRole.setPlayer(topic); newInnerRole.setPlayer(topic); }
@Override public AssociationRoleIF makeAssociationRole(AssociationIF assoc, TopicIF role_type, TopicIF player) { if (assoc == null) throw new NullPointerException(MSG_ASSOCATION_NOT_NULL); if (role_type == null) throw new NullPointerException(MSG_ASSOCIATION_ROLE_TYPE_NOT_NULL); if (player == null) throw new NullPointerException(MSG_ASSOCIATION_ROLE_PLAYER_NOT_NULL); CrossTopicMapException.check(assoc, this.tm); CrossTopicMapException.check(role_type, this.tm); CrossTopicMapException.check(player, this.tm); AssociationRoleIF assocrl = new AssociationRole(tm); ((Association)assoc).addRole(assocrl); assocrl.setType(role_type); assocrl.setPlayer(player); return assocrl; }
@Override public AssociationRoleIF makeAssociationRole(AssociationIF assoc, TopicIF role_type, TopicIF player) { if (assoc == null) throw new NullPointerException(MSG_ASSOCATION_NOT_NULL); if (role_type == null) throw new NullPointerException(MSG_ASSOCIATION_ROLE_TYPE_NOT_NULL); if (player == null) throw new NullPointerException(MSG_ASSOCIATION_ROLE_PLAYER_NOT_NULL); CrossTopicMapException.check(assoc, this.tm); CrossTopicMapException.check(role_type, this.tm); CrossTopicMapException.check(player, this.tm); AssociationRoleIF assocrl = new AssociationRole(txn); ((Association)assoc).addRole(assocrl); assocrl.setType(role_type); assocrl.setPlayer(player); return assocrl; }
@Override public void setPlayer(Topic player) { Check.playerNotNull(this, player); Check.playerInTopicMap(getTopicMap(), player); wrapped.setPlayer(topicMap.unwrapTopic(player)); }
public void rankNextTo(TopicIF ranked, TopicIF toRank, boolean before) { // NOTE: The rank is a circuit, with rankTopic ranked aboved the topic // with the highest rank and below the topic with the lowest rank. // Get the rank-role on the side where 'toRank' should be inserted. AssociationRoleIF nextToRole = getRankRole(ranked, before); // Attach 'toRank' to to the topic next to 'ranked'. nextToRole.setPlayer(toRank); // Now attach 'toRank' to 'ranked'. AssociationIF newRankAssociation = tmConfig.builder.makeAssociation(rankAssociationType); tmConfig.builder.makeAssociationRole(newRankAssociation, rankAboveRoleType, before ? toRank : ranked); tmConfig.builder.makeAssociationRole(newRankAssociation, rankBelowRoleType, before ? ranked : toRank); }
builder.makeAssociationRole(association, roleType, topic); else ((AssociationRoleIF) roles.iterator().next()).setPlayer(topic);
/** * Add source to the end of the ranking list. * @param source The topic to be added to the end of the ranking list. */ public void rankLast(TopicIF source) { // NOTE: The rank is a circuit, with rankTopic ranked aboved the topic // with the highest rank and below the topic with the lowest rank. // Get the rank-below role played by 'rankTopic'. AssociationRoleIF role = getRankRole(rankTopic, true); // Let 'source' take the place of 'rankTopic' as the lowest ranked. role.setPlayer(source); // Now rank 'rankTopic' below 'source' to maintain the circuit. AssociationIF newRankAssociation = tmConfig.builder.makeAssociation(rankAssociationType); tmConfig.builder.makeAssociationRole(newRankAssociation, rankBelowRoleType, rankTopic); tmConfig.builder.makeAssociationRole(newRankAssociation, rankAboveRoleType, source); }
@Override public AssociationIF makeAssociation(TopicIF assoc_type, TopicIF role_type, TopicIF player) { if (assoc_type == null) throw new NullPointerException(MSG_ASSOCIATION_TYPE_NOT_NULL); if (role_type == null) throw new NullPointerException(MSG_ASSOCIATION_ROLE_TYPE_NOT_NULL); if (player == null) throw new NullPointerException(MSG_ASSOCIATION_ROLE_PLAYER_NOT_NULL); CrossTopicMapException.check(assoc_type, this.tm); CrossTopicMapException.check(role_type, this.tm); CrossTopicMapException.check(player, this.tm); AssociationIF assoc = new Association(tm); tm.addAssociation(assoc); assoc.setType(assoc_type); AssociationRoleIF assocrl = new AssociationRole(tm); ((Association)assoc).addRole(assocrl); assocrl.setType(role_type); assocrl.setPlayer(player); return assoc; }
@Override public AssociationIF makeAssociation(TopicIF assoc_type, TopicIF role_type, TopicIF player) { if (assoc_type == null) throw new NullPointerException(MSG_ASSOCIATION_TYPE_NOT_NULL); if (role_type == null) throw new NullPointerException(MSG_ASSOCIATION_ROLE_TYPE_NOT_NULL); if (player == null) throw new NullPointerException(MSG_ASSOCIATION_ROLE_PLAYER_NOT_NULL); CrossTopicMapException.check(assoc_type, this.tm); CrossTopicMapException.check(role_type, this.tm); CrossTopicMapException.check(player, this.tm); AssociationIF assoc = new Association(txn); ((TopicMap)tm).addAssociation(assoc); assoc.setType(assoc_type); AssociationRoleIF assocrl = new AssociationRole(txn); ((Association)assoc).addRole(assocrl); assocrl.setType(role_type); assocrl.setPlayer(player); return assoc; }
public void testPlayer() { assertTrue("player null initially", role.getPlayer() != null); TopicIF player = builder.makeTopic(); role.setPlayer(player); assertTrue("player not set properly", role.getPlayer().equals(player)); try { role.setPlayer(null); fail("player could be set to null"); } catch (NullPointerException e) { } assertTrue("player not retained", role.getPlayer().equals(player)); }
public void perform(ActionParametersIF params, ActionResponseIF response) { //test params ActionSignature paramsType = ActionSignature.getSignature("r t?"); paramsType.validateArguments(params, this); AssociationRoleIF role = (AssociationRoleIF) params.get(0); if (role == null) throw new ActionRuntimeException("No role given to SetPlayer action"); TopicIF player = (TopicIF) params.get(1); if (player == null) { player = (TopicIF) params.getTMObjectValue(); if (player == null) throw new ActionRuntimeException("No player to be set given to SetPlayer action"); } role.setPlayer(player); }
public AssociationRoleIF change(TopicMapIF tm, AssociationRoleIF result, AssociationRole role) { // AssociationRoleIF if (role.getPlayer() != null) { result.setPlayer(topics.resolve(tm, role.getPlayer())); } // TypedIF typed.setType(result, role.getType()); // ReifiableIF reifiable.setReifier(result, role.getReifier()); // TMObjectIF tmobject.setItemIdentifiers(result, role); return result; }
assocRoleB.setPlayer(playerB);
@Override public void run() { AssociationRoleIF r = getAssociationRole(); TopicIF player = getTopic(); r.setPlayer(player); this.objectId = r.getObjectId(); this.value = player.getObjectId(); } });
public void testRoles() { // STATE 1 assertTrue("role set not empty initially", topic.getRoles().size() == 0); // STATE 2 AssociationIF assoc = builder.makeAssociation(builder.makeTopic()); AssociationRoleIF role = builder.makeAssociationRole(assoc, builder.makeTopic(), topic); assertTrue("role not added", topic.getRoles().size() == 1); assertTrue("role identity not retained", topic.getRoles().iterator().next().equals(role)); role.setPlayer(topic); assertTrue("duplicate not rejected", topic.getRoles().size() == 1); try { role.setPlayer(null); fail("player could be set to null"); } catch (NullPointerException e) { } assertTrue("player not retained", role.getPlayer().equals(topic)); }
if (or != null) { if (ObjectUtils.different(or.getPlayer(), players[i])) or.setPlayer(players[i]); log.trace(" =R " + players[i] + " :" + rtypes[i]); } else {
public void testAssociationRole() { LocatorIF loc = base.resolveAbsolute("#topic-1"); LocatorIF loc2 = base.resolveAbsolute("#topic-2"); TopicIF topic = (TopicIF)tm.getObjectByItemIdentifier(loc); AssociationRoleIF assocrl = (AssociationRoleIF)topic.getRoles().iterator().next(); tmobjectTest(assocrl, true, false); // Properties assertTrue("getPlayer (equal topic-1 before set)", assocrl.getPlayer() == tm.getObjectByItemIdentifier(loc)); assocrl.setPlayer((TopicIF)tm.getObjectByItemIdentifier(loc2)); assertTrue("getPlayer (equal topic-2 after set)", assocrl.getPlayer() == tm.getObjectByItemIdentifier(loc2)); assocrl.setPlayer((TopicIF)tm.getObjectByItemIdentifier(loc)); assertTrue("getPlayer (equal topic-1 after set)", assocrl.getPlayer() == tm.getObjectByItemIdentifier(loc)); }
@Override public void run() { AssociationRoleIF r = getAssociationRole(); TopicIF oldPlayer = r.getPlayer(); TopicIF player = builder.makeTopic(); // create player player.addSubjectIdentifier(URILocator.create("player:cleared")); r.setPlayer(player); this.objectId = r.getObjectId(); this.value = oldPlayer.getObjectId(); } });