Changeset 33


Ignore:
Timestamp:
06/05/09 10:42:59 (16 years ago)
Author:
lgiessmann
Message:

client ajax: added the basic handling for roleplayer-constraints and associationrole-constraints

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified trunk/docs/xtm_json.txt

    r32 r33  
    342342{
    343343  "players" : [ [ "topic-psi-1", "topic-psi-2", "..." ], [ "topic-2-psi-1", "..."], <...> ]
    344   "roleTypes" : [ [ "topic-psi-1", "topic-psi-2", "..." ], [ "subtype-psi-1", "..." ], <...> ],
     344  "roleType" : [ [ "topic-psi-1", "topic-psi-2", "..." ], [ "subtype-psi-1", "..." ], <...> ],
    345345  "cardMin" : "unsigned integer in string representation",
    346346  "cardMax" : "unsigned integer in string representation or the string MAX_INT"
     
    357357//+-----------------------------------------------------------------------------
    358358{
    359   "playerType" : [ "topic-psi-1", "topic-psi-2", "..." ],
    360   "roleType" : [ "topic-psi-1", "topic-psi-2", "..." ],
    361   "otherRoleType" : [ "topic-psi-1", "topic-psi-2", "..." ],
    362   "otherPlayerType" : [ "topic-psi-1", "topic-psi-2", "..." ],
     359  "players" : [ [ "topic-psi-1", "topic-psi-2", "..." ], [ "topic-2-psi-1", "..."], <...> ] ],
     360  "roleType" : [ [ "topic-psi-1", "topic-psi-2", "..." ], [ "subtype-psi-1", "..." ], <...> ],
     361  "otherPlayers" : [ "topic-psi-1", "topic-psi-2", "..." ], [ "topic-2-psi-1", "..."], <...> ] ],
     362  "otherRoleType" : [ "topic-psi-1", "topic-psi-2", "..." ], [ "subtype-psi-1", "..." ], <...> ],
    363363  "cardMin" : "unsigned integer in string representation",
    364364  "cardMax" : "unsigned integer in string representation or the string MAX_INT"
  • TabularUnified trunk/src/ajax/javascripts/datamodel.js

    r32 r33  
    12771277
    12781278// --- representation of a role element.
    1279 var RoleC = Class.create(ContainerC, {"initialize" : function($super, itemIdentities, roleTypes, rolePlayers, owner, min, max){
     1279var RoleC = Class.create(ContainerC, {"initialize" : function($super, itemIdentities, roleTypes, rolePlayers, owner, removeFunction, addFunction){
    12801280                                          $super();
    12811281                                          if(!owner.__frames__) owner.__frames__ = new Array();
    12821282                                          if(!roleTypes || roleTypes.length === 0) throw "From RoleC(): roleTypes must be set!";
    1283                                           if(!rolePlayers || rolePlayers.length === 0) throw "From RoleC(): rolePalyers must be set";
     1283                                          if(!rolePlayers || rolePlayers.length === 0) throw "From RoleC(): rolePlayers must be set";
     1284                                          if(!removeFunction || !addFunction) throw "From RoleC(): removeFunction and addFunction must be set!";
    12841285                                          owner.__frames__.push(this);
    12851286                                          this.__frame__.writeAttribute({"class" : CLASSES.roleFrame()});
     
    12921293                                              // --- control row + itemIdentity
    12931294                                              makeControlRow(this, 3, itemIdentities); // make control row have to be changed to a separate control row for roles
    1294                                               checkRemoveAddButtons(owner, 1, max);
    1295                                               setRemoveAddHandler(this, owner, 1, max, function(){
    1296                                                   return new RoleC(null, roleTypes, rolePlayers, owner, min, max);
    1297                                               });
     1295                                              checkRemoveAddButtons(owner, 1, -1);
     1296                                              setRemoveAddHandler(this, owner, 1, -1, function(){ /*do nothing*/ });
     1297                                              // --- resets the add and remove handlers
     1298                                              var cTd = this.__table__.select("tr." + CLASSES.itemIdentityFrame())[0].select("td." + CLASSES.controlColumn())[0].select("span." + CLASSES.clickable());
     1299                                              var removeButton = cTd[1];
     1300                                              var addButton = cTd[2];
     1301                                              removeButton.show();
     1302                                              addButton.show();
     1303                                              removeButton.stopObserving();
     1304                                              addButton.stopObserving();
     1305                                              removeButton.observe("click", removeFunction);
     1306                                              addButton.observe("click", addFunction);
    12981307
    12991308                                              // --- type
     
    13021311                                              var tr = newRow(CLASSES.typeFrame(), "Type", new SelectrowC(types, this.__type__, 1, 1).getFrame());
    13031312                                              this.__table__.insert({"bottom" : tr});
     1313                                              // TODO: implement a onTypeChangeHandler
    13041314
    13051315                                              // --- player
     
    13111321                                          catch(err){
    13121322                                              alert("From RoleC(): " + err);
     1323                                          }
     1324                                      },
     1325                                      "addPlayer" : function(player){
     1326                                          if(!player || player.length === 0) return;
     1327                                          var selected = this.__player__.__frames__[0].getContent();
     1328                                          var select = this.__player__.__frames__[0].getFrame().select("select")[0];
     1329                                          select.update("");
     1330                                          if(this.__rolePlayers__){
     1331                                              var j = 0;
     1332                                              for(var i = 0; i !== player.length; ++i){
     1333                                                  j = 0;
     1334                                                  for( ; j !== this.__rolePlayers__.length; ++j){
     1335                                                      if(this.__rolePlayers__[j].indexOf(player[i]) !== -1) break;
     1336                                                  }
     1337                                                  if(j !== this.__rolePlayers__.length){
     1338                                                      this.__rolePlayers__[j] = player;
     1339                                                      alert("test");
     1340                                                      break;
     1341                                                  }
     1342                                              }
     1343                                              if(j === this.__rolePlayers__.length)this.__rolePlayers__.push(player);
     1344                                          }
     1345                                          else {
     1346                                              this.__rolePlayers__ = new Array(player);
     1347                                          }
     1348                                          for(var i = 0; i !== this.__rolePlayers__.length; ++i){
     1349                                              for(var j = 0; j !== this.__rolePlayers__[i].length; ++j){
     1350                                                  var opt = new Element("option", {"value" : this.__rolePlayers__[i][j]}).update(this.__rolePlayers__[i][j]);
     1351                                                  if(this.__rolePlayers__[i][j] !== selected){
     1352                                                      select.insert({"bottom" : opt});
     1353                                                  }
     1354                                                  else {
     1355                                                      select.insert({"top" : opt});
     1356                                                  }
     1357                                              }
     1358                                          }
     1359                                      },
     1360                                      "removePlayer" : function(player){
     1361                                          if(!player || player.length === 0 || !this.__rolePlayers__ || this.__rolePlayers__.length === 0) return;
     1362                                          var selected = this.__player__.__frames__[0].getContent();
     1363                                          var select = this.__player__.__frames__[0].getFrame().select("select")[0];
     1364                                          select.update("");
     1365                                          var j = 0;
     1366                                          for(var i = 0; i !== player.length; ++i){
     1367                                              j = 0;
     1368                                              for( ; j !== this.__rolePlayers__.length; ++j){
     1369                                                  if(this.__rolePlayers__[j].indexOf(player[i]) !== -1) break;
     1370                                              }
     1371                                              if(j !== this.__rolePlayers__.length) break;
     1372                                          }
     1373                                          this.__rolePlayers__ = this.__rolePlayers__.slice(0, j).concat(this.__rolePlayers__.slice(j + 1, this.__rolePlayers__.length));
     1374                                          for(var i = 0; i !== this.__rolePlayers__.length; ++i){
     1375                                              for(var j = 0; j !== this.__rolePlayers__[i].length; ++j){
     1376                                                  var opt = new Element("option", {"value" : this.__rolePlayers__[i][j]}).update(this.__rolePlayers__[i][j]);
     1377                                                  if(this.__rolePlayers__[i][j] !== selected){
     1378                                                      select.insert({"bottom" : opt});
     1379                                                  }
     1380                                                  else {
     1381                                                      select.insert({"top" : opt});
     1382                                                  }
     1383                                              }
    13131384                                          }
    13141385                                      },
     
    13461417
    13471418// --- contains all roles of an association
    1348 var RoleContainerC = Class.create(ContainerC, {"initialize" : function($super, contents, roleConstraints, playerConstraints, otherRoleConstraints){
     1419var RoleContainerC = Class.create(ContainerC, {"initialize" : function($super, contents, associationRoleConstraints, rolePlayerConstraints, otherRoleConstraints){
    13491420                                                  $super();
    13501421                                                   this.__frame__.writeAttribute({"class" : CLASSES.roleContainer()});
    1351                                                    this.__container__ = new Object();
     1422                                                   this.__arContainer__ = new Object();
     1423                                                   this.__orContainer__ = new Object();
     1424
     1425    /*
     1426
     1427    *associationrole-constraints: A association role constraint defines how many and of what type the roles in associations of given a type must be.
     1428        *min: card-min indicating the minimum number of times the role can appear in the association
     1429        *max: card-max indicating the maximum number of times the role can appear in the association
     1430    *roleplayer-constraints: A role player constraint defines a way to constrain the type of allowed role players of a given role with a given type
     1431                             in an association of a given type.
     1432        *min: card-min indicating the minimum number of times a topic can play the role with the given type in the given
     1433              association of the given type
     1434        *max: card-max indicating the maximum number of times a topic can play the role with the given type in the given
     1435              association of the given type
     1436    *otherrole-constraints: A other role constraint defines a way to constrain the allowed type of role player given the existence of another role
     1437                            player type in an association.
     1438        *min: card-min indicating the minimum number of times the other role can occur
     1439        *max: card-max indicating the maximum number of times the other role can occur
     1440
     1441
     1442algorithmus:
     1443OK *alle rollen aus associationroleconstraints erstellen in einem __arContainer__
     1444OK *ÃŒberprÃŒfen, ob die kardinalitÀten der roleplayer mit den kardinalitÀten der associationrole ÃŒbereinstimmen
     1445OK   *card-min rp < card-min ar -> fehler
     1446OK   *card-max rp > card-max ar -> fehler
     1447OK   *card-min rp > card-max ar -> fehler
     1448OK   *card-max rp < card-min ar -> fehler
     1449OK *zu allen gefundenen roles vorhandene roleplayer-constraints suchen
     1450OK   *alle roleplayer sammeln und an eine leere option anhÀngen, anschließend in RoleC anhÀngen
     1451*__orContainer__ fÃŒr otherrole-constraints initialisieren
     1452*handler hinzufÃŒgen
     1453    */
     1454   
    13521455
    13531456                                                   try{
    1354                                                        if((!contents || contents.length === 0) && roleConstraints && playerConstraints){
    1355                                                            for(var i = 0; playerConstraints && i !== playerConstraints.length; ++i){
    1356                                                                //new RoleC(new Array("itemIdentity " + i), playerConstraints[i].roleTypes, playerConstraints[i].players, this.__container__, 1, 4);
    1357                                                                //this.__error__.insert({"before" : this.__container__.__frames__[i].getFrame()});
    1358                                                            }
     1457                                                       if((!contents || contents.length === 0) && associationRoleConstraints){
     1458                                                           this.resetValues(associationRoleConstraints, rolePlayerConstraints, otherRoleConstraints);
    13591459                                                       }
    13601460                                                       else {
    13611461                                                           // TODO: check already existing contents and order them to the corresponding fields
    13621462                                                       }
    1363 
    1364 
    1365                                                        
    13661463                                                   }
    13671464                                                   catch(err){
     
    13691466                                                   }
    13701467                                               },
    1371                                                "resetValues" : function(roleConstraints, playerConstraints, otherRoleConstraints){
     1468                                               "resetValues" : function(associationRoleConstraints, rolePlayerConstraints, otherRoleConstraints){
     1469                                                   this.__associationRoleConstraints__ = associationRoleConstraints;
     1470                                                   this.__rolePlayerConstraints__ = rolePlayerConstraints;
     1471                                                   this.__otherRoleConstraints__ = otherRoleConstraints;
     1472
     1473                                                   try{
     1474                                                       for(var i = 0; this.__arContainer__.__frames__ && i !== this.__arContainer__.__frames__.length; ++i){
     1475                                                           this.__arContainer__.__frames__[i].remove();
     1476                                                       }
     1477                                                       this.__arContainer__ = new Object();
     1478                                                   }
     1479                                                   catch(err){
     1480                                                       this.__arContainer__ = new Object();
     1481                                                   }
     1482                                                   try{
     1483                                                       for(var i = 0; this.__orContainer__.__frames__ && i !== this.__orContainer__.__frames__.length; ++i){
     1484                                                           this.__orContainer__.__frames__[i].remove();
     1485                                                       }
     1486                                                       this.__orContainer__ = new Object();
     1487                                                   }
     1488                                                   catch(err){
     1489                                                       this.__orContainer__ = new Object();
     1490                                                   }
     1491
     1492
     1493                                                   // --- creates all roles from existing associationroleconstraints and roleplayerConstraints
     1494                                                   // TODO: insert existing contents to the corresponding constraints
     1495                                                   for(var i = 0; this.__associationRoleConstraints__ && i !== this.__associationRoleConstraints__.length; ++i){
     1496                                                       var arc = this.__associationRoleConstraints__[i];
     1497                                                       var foundRpcs = getRolePlayerConstraintsForRole(arc.roleType, this.__rolePlayerConstraints__);
     1498                                                       this.__makeRolesFromARC__(arc, foundRpcs);
     1499                                                   }
     1500                                               },
     1501                                               "__makeRolesFromARC__" : function(associationRoleConstraint, rolePlayerConstraints){
     1502                                                   if(!associationRoleConstraint || !rolePlayerConstraints || rolePlayerConstraints.length === 0) return;
     1503                                                   checkCardinalitiesARC_RPC(associationRoleConstraint, rolePlayerConstraints);
     1504
     1505                                                   // --- creates all roles with all needed players
     1506                                                   var rolesCreated = 0;
     1507                                                   var allAvailablePlayers = extractPlayersOfConstraints(rolePlayerConstraints);
     1508                                                   var roleType = associationRoleConstraint.roleType;
     1509                                                   var roleMin = associationRoleConstraint.cardMin;
     1510                                                   for(var i = 0; i !== rolePlayerConstraints.length; ++i){
     1511                                                       var playerMin = rolePlayerConstraints[i].cardMin;
     1512                                                       var currentAvailablePlayers = rolePlayerConstraints[i].players;
     1513                                                       var cleanedPlayers = cleanPlayers(allAvailablePlayers, currentAvailablePlayers);
     1514                                                       for(var j = playerMin; j < currentAvailablePlayers.length; ++j){
     1515                                                           cleanedPlayers.push(currentAvailablePlayers[j]);
     1516                                                       }
     1517                                                       if(currentAvailablePlayers.length < playerMin) throw "From __makeRolesFromARC__(): not enough players(=" + currentAvailablePlayers.length + ") to reach card-min(=" + playerMin + ") of roletype\"" + roleType.flatten()[0] + "\"!";
     1518                                                       for(var j = 0; j !== playerMin; ++j){
     1519                                                           var removeFunction = function(event){ alert("removeFunction"); };
     1520                                                           var addFunction = function(event){ alert("addFunction"); };
     1521                                                           var selectedPlayer = currentAvailablePlayers[j];
     1522                                                           var _players = cleanedPlayers;
     1523                                                           _players.unshift(selectedPlayer);
     1524                                                           var role = new RoleC(null, roleType, _players, this.__arContainer__, removeFunction, addFunction);
     1525                                                           this.__setRoleChangePlayerHandler__(role);
     1526                                                           this.__error__.insert({"before" : role.getFrame()});
     1527                                                           ++rolesCreated;
     1528                                                       }
     1529                                                   }
     1530
     1531                                                   // --- creates all further needed roles with players that owns a card-max > existing players
     1532                                                   while(rolesCreated < roleMin){
     1533                                                       var currentlyCreated = 0;
     1534                                                       for(var i= 0; i !== rolePlayerConstraints.length; ++i){
     1535                                                           // existing roles --> all roles that owns a player which is selected of those listed in the roleplayer-constraint
     1536                                                           var existingRoles = this.getExistingRoles(roleType, rolePlayerConstraints[i].players, this.__arContainer__.__frames__);
     1537                                                           var availablePlayers = rolePlayerConstraints[i].players;
     1538                                                           if(existingRoles.length < rolePlayerConstraints[i].cardMax && availablePlayers.length > existingRoles.length){
     1539                                                               var currentAvailablePlayers = rolePlayerConstraints[i].players;
     1540                                                               var cleanedPlayers = cleanPlayers(allAvailablePlayers, currentAvailablePlayers);
     1541
     1542                                                               // --- adds players that are not selected yet
     1543                                                               for(var j = 0; j !== currentAvailablePlayers.length; ++j){
     1544                                                                   if(this.getExistingRoles(roleType, currentAvailablePlayers[j], this.__arContainer__.__frames__).length === 0){
     1545                                                                       cleanedPlayers.push(currentAvailablePlayers[j]);
     1546                                                                   }
     1547                                                               }
     1548                                                               
     1549                                                               // --- removes the player which will be seleted by the new created role of all other select-elements
     1550                                                               for(var j = 0; j !== this.__arContainer__.__frames__.length; ++j){
     1551                                                                   this.__arContainer__.__frames__[j].removePlayer(cleanedPlayers[0]);
     1552                                                               }
     1553                                                               
     1554                                                               var role = new RoleC(null, roleType, cleanedPlayers, this.__arContainer__, removeFunction, addFunction);
     1555                                                               this.__setRoleChangePlayerHandler__(role);
     1556                                                               this.__error__.insert({"before" : role.getFrame()});
     1557                                                               ++rolesCreated;
     1558                                                               ++currentlyCreated;
     1559                                                           }
     1560                                                       }
     1561                                                       if(currentlyCreated === 0) throw "Not enough players to create all needed roles of the type \"" + roleType.flatten()[0] + "\"!";
     1562                                                   }
     1563                                               },
     1564                                               "__makeRolesFromORC__" : function(roleType, player){
     1565
     1566                                               },
     1567                                               "getExistingRoles" : function(roleType, players, roles){
     1568                                                   var rolesFound = new Array();
     1569                                                   if(!roles || roles.length === 0) return rolesFound;
    13721570                                                   
    1373                                                    // TODO: implement
     1571                                                   var allTypes = roleType && roleType.length !== 0 ? roleType.flatten() : new Array();
     1572                                                   var allPlayers = players && players.length !== 0 ? players.flatten() : new Array();
     1573                                                   for(var i = 0; i !== roles.length; ++i){
     1574                                                       if(allTypes.indexOf(roles[i].getType()) !== -1 && allPlayers.indexOf(roles[i].getPlayer()) !== -1) rolesFound.push(roles[i]);
     1575                                                   }
     1576
     1577                                                   return rolesFound;
     1578                                               },
     1579                                               "__setRoleChangePlayerHandler__" : function(role){
     1580                                                   var select = role.__table__.select("tr." + CLASSES.playerFrame())[0].select("td." + CLASSES.content())[0].select("select")[0];
     1581                                                   select.observe("change", function(event){ alert("changed!"); });
     1582
    13741583                                               },
    13751584                                               "getContent" : function(){
     
    13801589                                               },
    13811590                                               "isValid" : function(){
    1382                                                    // TODO: implement
    1383                                                },
    1384                                                "isUsed" : function(){
    13851591                                                   // TODO: implement
    13861592                                               }});
  • TabularUnified trunk/src/ajax/javascripts/tmcl_tools.js

    r31 r33  
    6565    return true;
    6666}
     67
     68
     69// --- Returns an array of rolePlayerConstraints belonging to the given type in roleType.
     70// --- roleType is of the form [["psi-1", "psi-2", "..."], ["sub-psi-1", "..."], <...>]
     71function getRolePlayerConstraintsForRole(roleType, rolePlayerConstraints){
     72    if(!roleType || roleType.length === 0 || !rolePlayerConstraints || rolePlayerConstraints.length === 0) return new Array();
     73   
     74    var foundConstraints = new Array();
     75    var allRoleTypes = roleType.flatten();
     76    for(var i = 0; i !== rolePlayerConstraints.length; ++i){
     77        var allCRoleTypes = rolePlayerConstraints[i].roleType.flatten();
     78        for(var j = 0; j !== allRoleTypes.length; ++j){
     79            if(allCRoleTypes.indexOf(allRoleTypes[j]) !== -1){
     80                foundConstraints.push(rolePlayerConstraints[i]);
     81                break;
     82            }
     83        }
     84    }
     85    return foundConstraints;
     86}
     87
     88
     89// --- Returns an array of otherRoleConstraints belonging to the given roleType and players.
     90// --- roleType is of the form [["psi-1", "psi-2", "..."], ["sub-psi-1", "..."], <...>]
     91// --- players is of the form [["t1-psi-1", "t1-psi-2", "..."], ["t2-psi-1", "..."], <...>]
     92function getOtherRoleConstraintsForRole(roleType, players, otherRoleConstraints){
     93    if(!roleType || roleType.length === 0 || !players || players.length === 0 || !otherRoleConstraints || otherRoleConstraints.length === 0) return new Array();
     94       
     95    var foundConstraints = new Array();
     96    var allRoleTypes = roleType.flatten();
     97    var allPlayers = players.flatten();
     98    for(var i = 0; i !== otherRoleConstraints.length; ++i){
     99        var roleTypeMatches = false;
     100        var allCRoleTypes = otherRoleConstraints[i].roleType.flatten();
     101        for(var j = 0; j !== allPlayers.length; ++j){
     102            if(allCRoleTypes.indexOf(allRoleTypes[j]) !== -1){
     103                var allCPlayers = otherRoleConstraints[i].players.flatten();
     104                for(var k = 0; k !== allPlayers.length; ++k){
     105                    if(allCPlayers.indexOf(allPlayers[k]) !== -1){
     106                        foundConstraints.push(otherRoleConstraints[i]);
     107                        break;
     108                    }
     109                }
     110                break;
     111            }
     112        }
     113    }
     114    return foundConstraints;
     115}
     116
     117
     118// --- Returns the sum of all cardMin values of all rolePlayerConstraints.
     119function getRolePlayerMinForRole(anyRoleConstraints){
     120    if(!anyRoleConstraints || anyRoleConstraints === 0) return 0;
     121    var min = 0;
     122    for(var i = 0; i !== anyRoleConstraints.length; ++i){
     123        min += parseInt(anyRoleConstraints[i].cardMin);
     124    }
     125    return min;
     126}
     127
     128
     129// --- Returns the sum of all cardMax values of all rolePlayerConstraints.
     130function getRolePlayerMaxForRole(anyRoleConstraints){
     131    if(!anyRoleConstraints || anyRoleConstraints === 0) return 0;
     132    var max = 0;
     133    for(var i = 0; i !== anyRoleConstraints.length; ++i){
     134        if(anyRoleConstraints[i].cardMax === "MAX_INT") return "*";
     135        else max += parseInt(anyRoleConstraints[i].cardMax);
     136    }
     137    return max;
     138}
     139
     140
     141// --- checks the cardinalities of all rolePlayerconstraints depending on a
     142// --- given associationRoleConstraint
     143function checkCardinalitiesARC_RPC(associationRoleConstraint, rolePlayerConstraints){
     144    if(!associationRoleConstraint) throw "From checkCardinalitiesARC(): associationRoleConstraint is not set!";
     145    if(!rolePlayerConstraints || rolePlayerConstraints.length === 0) throw "From checkCardinalitiesARC(): rolePlayerConstraints is not set!";
     146    var arMin = parseInt(associationRoleConstraint.cardMin);
     147    var arMax = associationRoleConstraint.cardMax === "MAX_INT" ? "*" : parseInt(associationRoleConstraint.cardMax);
     148    var rpcs = getRolePlayerConstraintsForRole(associationRoleConstraint.roleType, rolePlayerConstraints);
     149    var rpMin = getRolePlayerMinForRole(rpcs);
     150    var rpMax = getRolePlayerMaxForRole(rpcs);
     151    var type = associationRoleConstraint.roleType.flatten()[0];
     152
     153    if(rpMax !== "*" && rpMax < arMin) throw "Not enough players available for roletype \"" + type + "\" (rpMax=" + rpMax + ", arMin=" + arMin + ")";
     154    if(arMax !== "*" && rpMin > arMax) throw "Too much players for the roletype \"" + type + "\" (rpMin=" + rpMin + ", arMax=" + arMax + ")";
     155    /*
     156    if(rpMin < arMin) throw "sum of card-min(=" + rpMin + ") of all roleplayer-constraints < card-min(=" + arMin + ") of associationrole-constraint for the role \"" + type + "\"! not enough players";
     157    if(arMax !== "*" && (rpMax === "*" || rpMax > arMax)) throw "sum of card-max(=" + rpMax + ") of all roleplayer-constraints > card-max(=" + arMax + ") of associationrole-constraint for the role \"" + type + "\"! too much players"
     158    if(arMax !== "*" && rpMin > arMax) throw "sum of card-min(=" + rpMin + ") of all roleplayer-constraints > card-max(=" + arMax + ") of associationrole-constraint for the role \"" + type + "\"! too much players";
     159    if(rpMax !== "*" && rpMax < arMin) throw "sum of card-max(=" + rpMax + ") of all roleplayer-constraints > card-min(=" + arMin + ") of associationrole-constraint for the role \"" + type + "\"! not enough players";
     160    */
     161}
     162
     163
     164// --- Returns all listed players of a constraint of the type
     165// --- roleplayer-constraint or otherrole-constraint and returns them
     166// --- as an array.
     167function extractPlayersOfConstraints(anyConstraints){
     168    var players = new Array();
     169    if(!anyConstraints || anyConstraints.length === 0) return players;
     170
     171    for(var i = 0; i !== anyConstraints.length; ++i){
     172        for(var j = 0; j !== anyConstraints[i].players.length; ++j){
     173            players.push(anyConstraints[i].players[j])
     174        }
     175    }
     176
     177    return players;
     178}
     179
     180
     181// --- Returns an array of players where the players from playersToClean will
     182// --- be deleted from allPlayers.
     183function cleanPlayers(allPlayers, playersToClean){
     184    var cleanedPlayers = new Array();
     185    if(!allPlayers) return cleanedPlayers;
     186    if(!playersToClean) return allPlayers;
     187
     188    for(var i = 0; i !== allPlayers.length; ++i){
     189        var toDel = false;
     190        for(var j = 0; j !== allPlayers[i].length; ++j){
     191            for(var k = 0; k !== playersToClean.length; ++k){
     192                if(playersToClean[k].indexOf(allPlayers[i][j]) !== -1){
     193                    toDel = true;
     194                    break;
     195                }
     196            }
     197            if(toDel === true) break;
     198        }
     199        if(toDel === false) cleanedPlayers.push(allPlayers[i]);
     200    }
     201    return cleanedPlayers;
     202}
  • TabularUnified trunk/src/json/json_tmcl.lisp

    r32 r33  
    193193                                       (list-instances (getf involved-topic-tupple :player) topictype topictype-constraint))))
    194194                        (json-role
    195                          (concatenate 'string "\"roleTypes\":"
     195                         (concatenate 'string "\"roleType\":"
    196196                                      (topics-to-json-list
    197197                                       (getf (list-subtypes (getf involved-topic-tupple :role) roletype roletype-constraint) :subtypes))))
     
    292292                                       (list-instances (getf role-player-tupple :player) topictype topictype-constraint))))
    293293                        (json-role
    294                          (concatenate 'string "\"roleTypes\":"
     294                         (concatenate 'string "\"roleType\":"
    295295                                      (topics-to-json-list
    296296                                       (getf (list-subtypes (getf role-player-tupple :role) roletype roletype-constraint) :subtypes))))
  • TabularUnified trunk/src/unit_tests/poems.xtm

    r32 r33  
    11<?xml version="1.0" encoding="UTF-8"?>
    22<tm:topicMap version="2.0" xmlns:tm="http://www.topicmaps.org/xtm/">
     3  <!-- test: defines some scopse constraints for associations of the type "born-in" -->
     4  <tm:topic id="scoped-born-in-constraint-1">
     5    <tm:subjectIdentifier href="http://some.where/constraint-psis/scoped-born-in-constraint-1"/>
     6    <tm:instanceOf><tm:topicRef href="#associationtypescope-constraint"/></tm:instanceOf>
     7    <tm:occurrence>
     8      <tm:type><tm:topicRef href="#card-min"/></tm:type>
     9      <tm:resourceData datatype="http://www.w3.org/2001/XMLSchema#unsignedInt">1</tm:resourceData>
     10    </tm:occurrence>
     11    <tm:occurrence>
     12      <tm:type><tm:topicRef href="#card-max"/></tm:type>
     13      <tm:resourceData datatype="http://www.w3.org/2001/XMLSchema#unsignedInt">2</tm:resourceData>
     14    </tm:occurrence>
     15  </tm:topic>
     16
     17  <tm:association>
     18    <tm:type><tm:topicRef href="#applies-to"/></tm:type>
     19    <tm:role>
     20      <tm:type><tm:topicRef href="#constraint-role"/></tm:type>
     21      <tm:topicRef href="#scoped-born-in-constraint-1"/>
     22    </tm:role>
     23    <tm:role>
     24      <tm:type><tm:topicRef href="#associationtype-role"/></tm:type>
     25      <tm:topicRef href="#written-by"/>
     26    </tm:role>
     27  </tm:association>
     28
     29  <tm:association>
     30    <tm:type><tm:topicRef href="#applies-to"/></tm:type>
     31    <tm:role>
     32      <tm:type><tm:topicRef href="#constraint-role"/></tm:type>
     33      <tm:topicRef href="#scoped-born-in-constraint-1"/>
     34    </tm:role>
     35    <tm:role>
     36      <tm:type><tm:topicRef href="#scopetype-role"/></tm:type>
     37      <tm:topicRef href="#en"/>
     38    </tm:role>
     39  </tm:association>
     40
     41  <tm:association>
     42    <tm:type><tm:topicRef href="#applies-to"/></tm:type>
     43    <tm:role>
     44      <tm:type><tm:topicRef href="#constraint-role"/></tm:type>
     45      <tm:topicRef href="#scoped-born-in-constraint-1"/>
     46    </tm:role>
     47    <tm:role>
     48      <tm:type><tm:topicRef href="#scopetype-role"/></tm:type>
     49      <tm:topicRef href="#de"/>
     50    </tm:role>
     51  </tm:association>
     52  <!-- end test -->
     53
     54
    355  <!-- ===================================================================== -->
    456  <!-- === TMCL meta-model topics ========================================== -->
     
    15671619  </tm:association>
    15681620
     1621
     1622  <!-- a subtype of poem-content with another datatype as the original type -->
     1623  <tm:topic id="sub-poem-content">
     1624    <tm:subjectIdentifier href="http://some.where/base-psis/sub-poem-content"/>
     1625  </tm:topic>
     1626
     1627  <tm:association>
     1628    <tm:type><tm:topicRef href="#supertype-subtype"/></tm:type>
     1629    <tm:role>
     1630      <tm:type><tm:topicRef href="#subtype"/></tm:type>
     1631      <tm:topicRef href="#sub-poem-content"/>
     1632    </tm:role>
     1633    <tm:role>
     1634      <tm:type><tm:topicRef href="#supertype"/></tm:type>
     1635      <tm:topicRef href="#poem-content"/>
     1636    </tm:role>
     1637  </tm:association>
     1638
     1639  <tm:topic id="sub-poem-content-occurrence-datatype-constraint">
     1640    <tm:subjectIdentifier href="http://some.where/constraint-psis/sub-poem-content-occurrence-datatype-constraint"/>
     1641    <tm:instanceOf><tm:topicRef href="#occurrencedatatype-constraint"/></tm:instanceOf>
     1642    <tm:occurrence>
     1643      <tm:type><tm:topicRef href="#datatype"/></tm:type>
     1644      <tm:resourceData datatype="http://www.w3.org/2001/XMLSchema#string">http://www.w3.org/2001/XMLSchema#float</tm:resourceData>
     1645    </tm:occurrence>
     1646  </tm:topic>
     1647
     1648  <tm:association>
     1649    <tm:type><tm:topicRef href="#applies-to"/></tm:type>
     1650    <tm:role>
     1651      <tm:type><tm:topicRef href="#constraint-role"/></tm:type>
     1652      <tm:topicRef href="#sub-poem-content-occurrence-datatype-constraint"/>
     1653    </tm:role>
     1654    <tm:role>
     1655      <tm:type><tm:topicRef href="#occurrencetype-role"/></tm:type>
     1656      <tm:topicRef href="#sub-poem-content"/>
     1657    </tm:role>
     1658  </tm:association>
     1659
     1660
    15691661  <!-- the poem-content-occurrence can only appear once per topictype,
    15701662       so all topic with this occurrence type must have different
     
    17331825       type poem -->
    17341826
    1735   <!-- the writer role has to appear exactly once in an association of type
    1736        written-by -->
    1737   <tm:topic id="written-by-writer-role-constraint">
    1738     <tm:subjectIdentifier href="http://some.where/constraint-psis/written-by-writer-role-constraint"/>
    1739     <tm:instanceOf><tm:topicRef href="#associationrole-constraint"/></tm:instanceOf>
    1740     <tm:occurrence>
    1741       <tm:type><tm:topicRef href="#card-min"/></tm:type>
    1742       <tm:resourceData datatype="http://www.w3.org/2001/XMLSchema#unsignedInt">1</tm:resourceData>
    1743     </tm:occurrence>
    1744     <tm:occurrence>
    1745       <tm:type><tm:topicRef href="#card-max"/></tm:type>
    1746       <tm:resourceData datatype="http://www.w3.org/2001/XMLSchema#unsignedInt">1</tm:resourceData>
    1747     </tm:occurrence>
    1748   </tm:topic>
    1749 
    1750   <tm:association>
    1751     <tm:type><tm:topicRef href="#applies-to"/></tm:type>
    1752     <tm:role>
    1753       <tm:type><tm:topicRef href="#constraint-role"/></tm:type>
    1754       <tm:topicRef href="#written-by-writer-role-constraint"/>
    1755     </tm:role>
    1756     <tm:role>
    1757       <tm:type><tm:topicRef href="#associationtype-role"/></tm:type>
    1758       <tm:topicRef href="#written-by"/>
    1759     </tm:role>
    1760   </tm:association>
    1761 
    1762   <tm:association>
    1763     <tm:type><tm:topicRef href="#applies-to"/></tm:type>
    1764     <tm:role>
    1765       <tm:type><tm:topicRef href="#constraint-role"/></tm:type>
    1766       <tm:topicRef href="#written-by-writer-role-constraint"/>
    1767     </tm:role>
    1768     <tm:role>
    1769       <tm:type><tm:topicRef href="#roletype-role"/></tm:type>
    1770       <tm:topicRef href="#writer"/>
    1771     </tm:role>
    1772   </tm:association>
    1773 
    1774   <!-- the writer role owns a player of the type author -->
    1775   <tm:topic id="written-by-writer-role-player-constraint">
    1776     <tm:subjectIdentifier href="http://some.where/constraint-psis/written-by-writer-role-player-constraint"/>
    1777     <tm:instanceOf><tm:topicRef href="#roleplayer-constraint"/></tm:instanceOf>
    1778     <tm:occurrence>
    1779       <tm:type><tm:topicRef href="#card-min"/></tm:type>
    1780       <tm:resourceData datatype="http://www.w3.org/2001/XMLSchema#unsignedInt">1</tm:resourceData>
    1781     </tm:occurrence>
    1782     <tm:occurrence>
    1783       <tm:type><tm:topicRef href="#card-max"/></tm:type>
    1784       <tm:resourceData datatype="http://www.w3.org/2001/XMLSchema#unsignedInt">1</tm:resourceData>
    1785     </tm:occurrence>
    1786   </tm:topic>
    1787 
    1788   <tm:association>
    1789     <tm:type><tm:topicRef href="#applies-to"/></tm:type>
    1790     <tm:role>
    1791       <tm:type><tm:topicRef href="#constraint-role"/></tm:type>
    1792       <tm:topicRef href="#written-by-writer-role-player-constraint"/>
    1793     </tm:role>
    1794     <tm:role>
    1795       <tm:type><tm:topicRef href="#topictype-role"/></tm:type>
    1796       <tm:topicRef href="#author"/>
    1797     </tm:role>
    1798   </tm:association>
    1799 
    1800   <tm:association>
    1801     <tm:type><tm:topicRef href="#applies-to"/></tm:type>
    1802     <tm:role>
    1803       <tm:type><tm:topicRef href="#constraint-role"/></tm:type>
    1804       <tm:topicRef href="#written-by-writer-role-player-constraint"/>
    1805     </tm:role>
    1806     <tm:role>
    1807       <tm:type><tm:topicRef href="#associationtype-role"/></tm:type>
    1808       <tm:topicRef href="#written-by"/>
    1809     </tm:role>
    1810   </tm:association>
    1811 
    1812   <tm:association>
    1813     <tm:type><tm:topicRef href="#applies-to"/></tm:type>
    1814     <tm:role>
    1815       <tm:type><tm:topicRef href="#constraint-role"/></tm:type>
    1816       <tm:topicRef href="#written-by-writer-role-player-constraint"/>
    1817     </tm:role>
    1818     <tm:role>
    1819       <tm:type><tm:topicRef href="#roletype-role"/></tm:type>
    1820       <tm:topicRef href="#writer"/>
    1821     </tm:role>
    1822   </tm:association>
    1823 
    1824 
    18251827  <!-- the written role has to appear exactly once in an association of type
    18261828       written-by -->
     
    19161918       If there is a role of the type written with a player of the type poem
    19171919       there must be another role of the type writer with a player of the
    1918        type author.
    1919        In contrast if there is a role of the type writer with a player of the
    1920        type author there must be a role of the type written with a player of
    1921        the type poem.
    1922        So for this case there are two otherrole-constraints which handle this
    1923        both cases. -->
    1924 
    1925   <tm:topic id="written-by-otherrole-constraint-for-writer">
    1926     <tm:subjectIdentifier href="http://some.where/contraint-psis/written-by-otherrole-constraint-for-writer"/>
     1920       type author. -->
     1921  <tm:topic id="written-by-otherrole-constraint-for-written">
     1922    <tm:subjectIdentifier href="http://some.where/contraint-psis/written-by-otherrole-constraint-for-written"/>
    19271923    <tm:instanceOf><tm:topicRef href="#otherrole-constraint"/></tm:instanceOf>
    19281924    <tm:occurrence>
     
    19441940    <tm:role>
    19451941      <tm:type><tm:topicRef href="#constraint-role"/></tm:type>
    1946       <tm:topicRef href="#written-by-otherrole-constraint-for-writer"/>
     1942      <tm:topicRef href="#written-by-otherrole-constraint-for-written"/>
    19471943    </tm:role>
    19481944    <tm:role>
     
    19561952    <tm:role>
    19571953      <tm:type><tm:topicRef href="#constraint-role"/></tm:type>
    1958       <tm:topicRef href="#written-by-otherrole-constraint-for-writer"/>
    1959     </tm:role>
    1960     <tm:role>
    1961       <tm:type><tm:topicRef href="#roletype-role"/></tm:type>
    1962       <tm:topicRef href="#writer"/>
    1963     </tm:role>
    1964   </tm:association>
    1965 
    1966   <tm:association>
    1967     <tm:type><tm:topicRef href="#applies-to"/></tm:type>
    1968     <tm:role>
    1969       <tm:type><tm:topicRef href="#constraint-role"/></tm:type>
    1970       <tm:topicRef href="#written-by-otherrole-constraint-for-writer"/>
    1971     </tm:role>
    1972     <tm:role>
    1973       <tm:type><tm:topicRef href="#topictype-role"/></tm:type>
    1974       <tm:topicRef href="#author"/>
    1975     </tm:role>
    1976   </tm:association>
    1977 
    1978   <tm:association>
    1979     <tm:type><tm:topicRef href="#applies-to"/></tm:type>
    1980     <tm:role>
    1981       <tm:type><tm:topicRef href="#constraint-role"/></tm:type>
    1982       <tm:topicRef href="#written-by-otherrole-constraint-for-writer"/>
    1983     </tm:role>
    1984     <tm:role>
    1985       <tm:type><tm:topicRef href="#otherroletype-role"/></tm:type>
    1986       <tm:topicRef href="#written"/>
    1987     </tm:role>
    1988   </tm:association>
    1989 
    1990   <tm:association>
    1991     <tm:type><tm:topicRef href="#applies-to"/></tm:type>
    1992     <tm:role>
    1993       <tm:type><tm:topicRef href="#constraint-role"/></tm:type>
    1994       <tm:topicRef href="#written-by-otherrole-constraint-for-writer"/>
    1995     </tm:role>
    1996     <tm:role>
    1997       <tm:type><tm:topicRef href="#othertopictype-role"/></tm:type>
    1998       <tm:topicRef href="#poem"/>
    1999     </tm:role>
    2000   </tm:association>
    2001 
    2002   <tm:topic id="written-by-otherrole-constraint-for-written">
    2003     <tm:subjectIdentifier href="http://some.where/contraint-psis/written-by-otherrole-constraint-for-written"/>
    2004     <tm:instanceOf><tm:topicRef href="#otherrole-constraint"/></tm:instanceOf>
    2005     <tm:occurrence>
    2006       <tm:type>
    2007         <tm:topicRef href="#card-min"/>
    2008       </tm:type>
    2009       <tm:resourceData datatype="http://www.w3.org/2001/XMLSchema#unsignedInt">1</tm:resourceData>
    2010     </tm:occurrence>
    2011     <tm:occurrence>
    2012       <tm:type>
    2013         <tm:topicRef href="#card-max"/>
    2014       </tm:type>
    2015       <tm:resourceData datatype="http://www.w3.org/2001/XMLSchema#unsignedInt">1</tm:resourceData>
    2016     </tm:occurrence>
    2017   </tm:topic>
    2018 
    2019   <tm:association>
    2020     <tm:type><tm:topicRef href="#applies-to"/></tm:type>
    2021     <tm:role>
    2022       <tm:type><tm:topicRef href="#constraint-role"/></tm:type>
    2023       <tm:topicRef href="#written-by-otherrole-constraint-for-written"/>
    2024     </tm:role>
    2025     <tm:role>
    2026       <tm:type><tm:topicRef href="#associationtype-role"/></tm:type>
    2027       <tm:topicRef href="#written-by"/>
    2028     </tm:role>
    2029   </tm:association>
    2030 
    2031   <tm:association>
    2032     <tm:type><tm:topicRef href="#applies-to"/></tm:type>
    2033     <tm:role>
    2034       <tm:type><tm:topicRef href="#constraint-role"/></tm:type>
    20351954      <tm:topicRef href="#written-by-otherrole-constraint-for-written"/>
    20361955    </tm:role>
     
    20791998  <!-- born-in associations have to have one role of the type writer with a
    20801999       player of the type author. The other role is of type place with the
    2081        player of the type city. -->
     2000       player of the type region. -->
    20822001  <!-- place associationrole-constraint -->
    2083   <tm:topic id="born-in-place-role-constraint">
    2084     <tm:subjectIdentifier href="http://some.where/constraint-psis/born-in-place-role-constraint"/>
    2085     <tm:instanceOf><tm:topicRef href="#associationrole-constraint"/></tm:instanceOf>
    2086     <tm:occurrence>
    2087       <tm:type><tm:topicRef href="#card-min"/></tm:type>
    2088       <tm:resourceData datatype="http://www.w3.org/2001/XMLSchema#unsignedInt">1</tm:resourceData>
    2089     </tm:occurrence>
    2090     <tm:occurrence>
    2091       <tm:type><tm:topicRef href="#card-max"/></tm:type>
    2092       <tm:resourceData datatype="http://www.w3.org/2001/XMLSchema#unsignedInt">1</tm:resourceData>
    2093     </tm:occurrence>
    2094   </tm:topic>
    2095 
    2096   <tm:association>
    2097     <tm:type><tm:topicRef href="#applies-to"/></tm:type>
    2098     <tm:role>
    2099       <tm:type><tm:topicRef href="#constraint-role"/></tm:type>
    2100       <tm:topicRef href="#born-in-place-role-constraint"/>
    2101     </tm:role>
    2102     <tm:role>
    2103       <tm:type><tm:topicRef href="#associationtype-role"/></tm:type>
    2104       <tm:topicRef href="#born-in"/>
    2105     </tm:role>
    2106   </tm:association>
    2107 
    2108   <tm:association>
    2109     <tm:type><tm:topicRef href="#applies-to"/></tm:type>
    2110     <tm:role>
    2111       <tm:type><tm:topicRef href="#constraint-role"/></tm:type>
    2112       <tm:topicRef href="#born-in-place-role-constraint"/>
    2113     </tm:role>
    2114     <tm:role>
    2115       <tm:type><tm:topicRef href="#roletype-role"/></tm:type>
    2116       <tm:topicRef href="#place"/>
    2117     </tm:role>
    2118   </tm:association>
    2119 
    2120   <!-- place-role roleplayer-constraint -->
    2121   <tm:topic id="born-in-place-role-player-constraint">
    2122     <tm:subjectIdentifier href="http://some.where/constraint-psis/born-in-place-role-player-constraint"/>
    2123     <tm:instanceOf><tm:topicRef href="#roleplayer-constraint"/></tm:instanceOf>
    2124     <tm:occurrence>
    2125       <tm:type><tm:topicRef href="#card-min"/></tm:type>
    2126       <tm:resourceData datatype="http://www.w3.org/2001/XMLSchema#unsignedInt">1</tm:resourceData>
    2127     </tm:occurrence>
    2128     <tm:occurrence>
    2129       <tm:type><tm:topicRef href="#card-max"/></tm:type>
    2130       <tm:resourceData datatype="http://www.w3.org/2001/XMLSchema#unsignedInt">1</tm:resourceData>
    2131     </tm:occurrence>
    2132   </tm:topic>
    2133 
    2134   <tm:association>
    2135     <tm:type><tm:topicRef href="#applies-to"/></tm:type>
    2136     <tm:role>
    2137       <tm:type><tm:topicRef href="#constraint-role"/></tm:type>
    2138       <tm:topicRef href="#born-in-place-role-player-constraint"/>
    2139     </tm:role>
    2140     <tm:role>
    2141       <tm:type><tm:topicRef href="#topictype-role"/></tm:type>
    2142       <tm:topicRef href="#region"/>
    2143     </tm:role>
    2144   </tm:association>
    2145 
    2146   <tm:association>
    2147     <tm:type><tm:topicRef href="#applies-to"/></tm:type>
    2148     <tm:role>
    2149       <tm:type><tm:topicRef href="#constraint-role"/></tm:type>
    2150       <tm:topicRef href="#born-in-place-role-player-constraint"/>
    2151     </tm:role>
    2152     <tm:role>
    2153       <tm:type><tm:topicRef href="#associationtype-role"/></tm:type>
    2154       <tm:topicRef href="#born-in"/>
    2155     </tm:role>
    2156   </tm:association>
    2157 
    2158   <tm:association>
    2159     <tm:type><tm:topicRef href="#applies-to"/></tm:type>
    2160     <tm:role>
    2161       <tm:type><tm:topicRef href="#constraint-role"/></tm:type>
    2162       <tm:topicRef href="#born-in-place-role-player-constraint"/>
    2163     </tm:role>
    2164     <tm:role>
    2165       <tm:type><tm:topicRef href="#roletype-role"/></tm:type>
    2166       <tm:topicRef href="#place"/>
    2167     </tm:role>
    2168   </tm:association>
    21692002
    21702003  <!-- writer associationrole-constraint -->
     
    23372170  </tm:association>
    23382171
    2339   <tm:topic id="born-in-otherrole-constraint-for-place">
    2340     <tm:subjectIdentifier href="http://some.where/contraint-psis/born-in-otherrole-constraint-for-place"/>
    2341     <tm:instanceOf><tm:topicRef href="#otherrole-constraint"/></tm:instanceOf>
    2342     <tm:occurrence>
    2343       <tm:type>
    2344         <tm:topicRef href="#card-min"/>
    2345       </tm:type>
    2346       <tm:resourceData datatype="http://www.w3.org/2001/XMLSchema#unsignedInt">1</tm:resourceData>
    2347     </tm:occurrence>
    2348     <tm:occurrence>
    2349       <tm:type>
    2350         <tm:topicRef href="#card-max"/>
    2351       </tm:type>
    2352       <tm:resourceData datatype="http://www.w3.org/2001/XMLSchema#unsignedInt">1</tm:resourceData>
    2353     </tm:occurrence>
    2354   </tm:topic>
    2355 
    2356   <tm:association>
    2357     <tm:type><tm:topicRef href="#applies-to"/></tm:type>
    2358     <tm:role>
    2359       <tm:type><tm:topicRef href="#constraint-role"/></tm:type>
    2360       <tm:topicRef href="#born-in-otherrole-constraint-for-place"/>
    2361     </tm:role>
    2362     <tm:role>
    2363       <tm:type><tm:topicRef href="#associationtype-role"/></tm:type>
    2364       <tm:topicRef href="#born-in"/>
    2365     </tm:role>
    2366   </tm:association>
    2367 
    2368   <tm:association>
    2369     <tm:type><tm:topicRef href="#applies-to"/></tm:type>
    2370     <tm:role>
    2371       <tm:type><tm:topicRef href="#constraint-role"/></tm:type>
    2372       <tm:topicRef href="#born-in-otherrole-constraint-for-place"/>
    2373     </tm:role>
    2374     <tm:role>
    2375       <tm:type><tm:topicRef href="#roletype-role"/></tm:type>
    2376       <tm:topicRef href="#place"/>
    2377     </tm:role>
    2378   </tm:association>
    2379 
    2380   <tm:association>
    2381     <tm:type><tm:topicRef href="#applies-to"/></tm:type>
    2382     <tm:role>
    2383       <tm:type><tm:topicRef href="#constraint-role"/></tm:type>
    2384       <tm:topicRef href="#born-in-otherrole-constraint-for-place"/>
    2385     </tm:role>
    2386     <tm:role>
    2387       <tm:type><tm:topicRef href="#topictype-role"/></tm:type>
    2388       <tm:topicRef href="#region"/>
    2389     </tm:role>
    2390   </tm:association>
    2391 
    2392   <tm:association>
    2393     <tm:type><tm:topicRef href="#applies-to"/></tm:type>
    2394     <tm:role>
    2395       <tm:type><tm:topicRef href="#constraint-role"/></tm:type>
    2396       <tm:topicRef href="#born-in-otherrole-constraint-for-place"/>
    2397     </tm:role>
    2398     <tm:role>
    2399       <tm:type><tm:topicRef href="#otherroletype-role"/></tm:type>
    2400       <tm:topicRef href="#writer"/>
    2401     </tm:role>
    2402   </tm:association>
    2403 
    2404   <tm:association>
    2405     <tm:type><tm:topicRef href="#applies-to"/></tm:type>
    2406     <tm:role>
    2407       <tm:type><tm:topicRef href="#constraint-role"/></tm:type>
    2408       <tm:topicRef href="#born-in-otherrole-constraint-for-place"/>
    2409     </tm:role>
    2410     <tm:role>
    2411       <tm:type><tm:topicRef href="#othertopictype-role"/></tm:type>
    2412       <tm:topicRef href="#author"/>
    2413     </tm:role>
    2414   </tm:association>
    24152172
    24162173  <!-- located-in associations have to have one role of the type container with
     
    24772234    <tm:role>
    24782235      <tm:type><tm:topicRef href="#topictype-role"/></tm:type>
    2479       <tm:topicRef href="#region"/>
     2236      <tm:topicRef href="#country"/>
    24802237    </tm:role>
    24812238  </tm:association>
     
    25052262  </tm:association>
    25062263
    2507   <!-- writer associationrole-constraint -->
    2508   <tm:topic id="located-in-containee-role-constraint">
    2509     <tm:subjectIdentifier href="http://some.where/constraint-psis/located-in-containee-role-constraint"/>
    2510     <tm:instanceOf><tm:topicRef href="#associationrole-constraint"/></tm:instanceOf>
    2511     <tm:occurrence>
    2512       <tm:type><tm:topicRef href="#card-min"/></tm:type>
    2513       <tm:resourceData datatype="http://www.w3.org/2001/XMLSchema#unsignedInt">1</tm:resourceData>
    2514     </tm:occurrence>
    2515     <tm:occurrence>
    2516       <tm:type><tm:topicRef href="#card-max"/></tm:type>
    2517       <tm:resourceData datatype="http://www.w3.org/2001/XMLSchema#unsignedInt">1</tm:resourceData>
    2518     </tm:occurrence>
    2519   </tm:topic>
    2520 
    2521   <tm:association>
    2522     <tm:type><tm:topicRef href="#applies-to"/></tm:type>
    2523     <tm:role>
    2524       <tm:type><tm:topicRef href="#constraint-role"/></tm:type>
    2525       <tm:topicRef href="#located-in-containee-role-constraint"/>
    2526     </tm:role>
    2527     <tm:role>
    2528       <tm:type><tm:topicRef href="#associationtype-role"/></tm:type>
    2529       <tm:topicRef href="#located-in"/>
    2530     </tm:role>
    2531   </tm:association>
    2532 
    2533   <tm:association>
    2534     <tm:type><tm:topicRef href="#applies-to"/></tm:type>
    2535     <tm:role>
    2536       <tm:type><tm:topicRef href="#constraint-role"/></tm:type>
    2537       <tm:topicRef href="#located-in-containee-role-constraint"/>
    2538     </tm:role>
    2539     <tm:role>
    2540       <tm:type><tm:topicRef href="#roletype-role"/></tm:type>
    2541       <tm:topicRef href="#containee"/>
    2542     </tm:role>
    2543   </tm:association>
    2544 
    2545   <!-- place-role roleplayer-constraint -->
    2546   <tm:topic id="located-in-containee-role-player-constraint">
    2547     <tm:subjectIdentifier href="http://some.where/constraint-psis/located-in-containee-role-player-constraint"/>
    2548     <tm:instanceOf><tm:topicRef href="#roleplayer-constraint"/></tm:instanceOf>
    2549     <tm:occurrence>
    2550       <tm:type><tm:topicRef href="#card-min"/></tm:type>
    2551       <tm:resourceData datatype="http://www.w3.org/2001/XMLSchema#unsignedInt">1</tm:resourceData>
    2552     </tm:occurrence>
    2553     <tm:occurrence>
    2554       <tm:type><tm:topicRef href="#card-max"/></tm:type>
    2555       <tm:resourceData datatype="http://www.w3.org/2001/XMLSchema#unsignedInt">1</tm:resourceData>
    2556     </tm:occurrence>
    2557   </tm:topic>
    2558 
    2559   <tm:association>
    2560     <tm:type><tm:topicRef href="#applies-to"/></tm:type>
    2561     <tm:role>
    2562       <tm:type><tm:topicRef href="#constraint-role"/></tm:type>
    2563       <tm:topicRef href="#located-in-containee-role-player-constraint"/>
    2564     </tm:role>
    2565     <tm:role>
    2566       <tm:type><tm:topicRef href="#topictype-role"/></tm:type>
    2567       <tm:topicRef href="#region"/>
    2568     </tm:role>
    2569   </tm:association>
    2570 
    2571   <tm:association>
    2572     <tm:type><tm:topicRef href="#applies-to"/></tm:type>
    2573     <tm:role>
    2574       <tm:type><tm:topicRef href="#constraint-role"/></tm:type>
    2575       <tm:topicRef href="#located-in-containee-role-player-constraint"/>
    2576     </tm:role>
    2577     <tm:role>
    2578       <tm:type><tm:topicRef href="#associationtype-role"/></tm:type>
    2579       <tm:topicRef href="#located-in"/>
    2580     </tm:role>
    2581   </tm:association>
    2582 
    2583   <tm:association>
    2584     <tm:type><tm:topicRef href="#applies-to"/></tm:type>
    2585     <tm:role>
    2586       <tm:type><tm:topicRef href="#constraint-role"/></tm:type>
    2587       <tm:topicRef href="#located-in-containee-role-player-constraint"/>
    2588     </tm:role>
    2589     <tm:role>
    2590       <tm:type><tm:topicRef href="#roletype-role"/></tm:type>
    2591       <tm:topicRef href="#containee"/>
    2592     </tm:role>
    2593   </tm:association>
    25942264
    25952265  <!-- otherplayer-constraints:
    2596        A "born-in" association must have exactly one writer-role with a
    2597        player of the type author and one place-role with a player of the
    2598        type city. -->
     2266       A "located-in" association must have exactly one container-role with a
     2267       player of the type country and one containee-role with a player of the
     2268       type region. -->
    25992269  <tm:topic id="located-in-otherrole-constraint-for-container">
    26002270    <tm:subjectIdentifier href="http://some.where/contraint-psis/located-in-otherrole-constraint-for-container"/>
     
    26742344  </tm:association>
    26752345
    2676   <tm:topic id="located-in-otherrole-constraint-for-containee">
    2677     <tm:subjectIdentifier href="http://some.where/contraint-psis/located-in-otherrole-constraint-for-containee"/>
    2678     <tm:instanceOf><tm:topicRef href="#otherrole-constraint"/></tm:instanceOf>
    2679     <tm:occurrence>
    2680       <tm:type>
    2681         <tm:topicRef href="#card-min"/>
    2682       </tm:type>
    2683       <tm:resourceData datatype="http://www.w3.org/2001/XMLSchema#unsignedInt">1</tm:resourceData>
    2684     </tm:occurrence>
    2685     <tm:occurrence>
    2686       <tm:type>
    2687         <tm:topicRef href="#card-max"/>
    2688       </tm:type>
    2689       <tm:resourceData datatype="http://www.w3.org/2001/XMLSchema#unsignedInt">1</tm:resourceData>
    2690     </tm:occurrence>
    2691   </tm:topic>
    2692 
    2693   <tm:association>
    2694     <tm:type><tm:topicRef href="#applies-to"/></tm:type>
    2695     <tm:role>
    2696       <tm:type><tm:topicRef href="#constraint-role"/></tm:type>
    2697       <tm:topicRef href="#located-in-otherrole-constraint-for-containee"/>
    2698     </tm:role>
    2699     <tm:role>
    2700       <tm:type><tm:topicRef href="#associationtype-role"/></tm:type>
    2701       <tm:topicRef href="#born-in"/>
    2702     </tm:role>
    2703   </tm:association>
    2704 
    2705   <tm:association>
    2706     <tm:type><tm:topicRef href="#applies-to"/></tm:type>
    2707     <tm:role>
    2708       <tm:type><tm:topicRef href="#constraint-role"/></tm:type>
    2709       <tm:topicRef href="#located-in-otherrole-constraint-for-containee"/>
    2710     </tm:role>
    2711     <tm:role>
    2712       <tm:type><tm:topicRef href="#roletype-role"/></tm:type>
    2713       <tm:topicRef href="#containee"/>
    2714     </tm:role>
    2715   </tm:association>
    2716 
    2717   <tm:association>
    2718     <tm:type><tm:topicRef href="#applies-to"/></tm:type>
    2719     <tm:role>
    2720       <tm:type><tm:topicRef href="#constraint-role"/></tm:type>
    2721       <tm:topicRef href="#located-in-otherrole-constraint-for-containee"/>
    2722     </tm:role>
    2723     <tm:role>
    2724       <tm:type><tm:topicRef href="#topictype-role"/></tm:type>
    2725       <tm:topicRef href="#region"/>
    2726     </tm:role>
    2727   </tm:association>
    2728 
    2729   <tm:association>
    2730     <tm:type><tm:topicRef href="#applies-to"/></tm:type>
    2731     <tm:role>
    2732       <tm:type><tm:topicRef href="#constraint-role"/></tm:type>
    2733       <tm:topicRef href="#located-in-otherrole-constraint-for-containee"/>
    2734     </tm:role>
    2735     <tm:role>
    2736       <tm:type><tm:topicRef href="#otherroletype-role"/></tm:type>
    2737       <tm:topicRef href="#container"/>
    2738     </tm:role>
    2739   </tm:association>
    2740 
    2741   <tm:association>
    2742     <tm:type><tm:topicRef href="#applies-to"/></tm:type>
    2743     <tm:role>
    2744       <tm:type><tm:topicRef href="#constraint-role"/></tm:type>
    2745       <tm:topicRef href="#located-in-otherrole-constraint-for-containee"/>
    2746     </tm:role>
    2747     <tm:role>
    2748       <tm:type><tm:topicRef href="#othertopictype-role"/></tm:type>
    2749       <tm:topicRef href="#country"/>
    2750     </tm:role>
    2751   </tm:association>
    27522346
    27532347  <!-- ===================================================================== -->
Note: See TracChangeset for help on using the changeset viewer.