[isidorus-cvs] r69 - in trunk/src: ajax/javascripts unit_tests

Author: lgiessmann Date: Thu Jun 25 15:07:40 2009 New Revision: 69 Log: ajax-client: fixed a bug by creating an association from existing contents. The problem occurred if there were more than one association type available and the existing content is not of the first type in the list - so there were used the constraints of the first type and not of the used type Modified: trunk/src/ajax/javascripts/datamodel.js trunk/src/unit_tests/poems.xtm Modified: trunk/src/ajax/javascripts/datamodel.js ============================================================================== --- trunk/src/ajax/javascripts/datamodel.js (original) +++ trunk/src/ajax/javascripts/datamodel.js Thu Jun 25 15:07:40 2009 @@ -3442,7 +3442,6 @@ if(!owner) throw "From NameC(): owner must be set but is null"; if(!owner.__frames__) owner.__frames__ = new Array(); owner.__frames__.push(this); - this.__frame__.writeAttribute({"class" : CLASSES.associationFrame()}); this.__table__ = new Element("table", {"class" : CLASSES.associationFrame()}); this.__frame__.insert({"top" : this.__table__}); @@ -3451,7 +3450,7 @@ this.__constraints__ = constraints; this.__owner__ = owner; this.__dblClickHandler__ = dblClickHandlerF; - + try{ var itemIdentityContent = null; var typeContent = null; @@ -3472,7 +3471,7 @@ }); // --- type - var types = makeTypes(this, typeContent, constraints); + var types = makeTypes(this, typeContent, constraints); // --- scopes var currentConstraint = this.getCurrentConstraint(); @@ -3480,11 +3479,14 @@ this.__table__.insert({"bottom" : newRow(CLASSES.scopeContainer(), "Scope", this.__scope__.getFrame())}); // --- roles - var _roleConstraints = _playerConstraints = _otherRoleConstraints = null; - if(this.__constraints__){ - _roleConstraints = this.__constraints__[0].associationRoleConstraints; - _playerConstraints = this.__constraints__[0].rolePlayerConstraints; - _otherRoleConstraints = this.__constraints__[0].otherRoleConstraints; + var _roleConstraints = null; + var _playerConstraints = null; + var _otherRoleConstraints = null; + var cc = this.getCurrentConstraint(); + if(cc){ + _roleConstraints = cc.associationRoleConstraints; + _playerConstraints = cc.rolePlayerConstraints; + _otherRoleConstraints = cc.otherRoleConstraints; } this.__roles__ = new RoleContainerC(rolesContent, _roleConstraints, _playerConstraints, _otherRoleConstraints, this); @@ -3505,26 +3507,16 @@ } }, "resetValues" : function(){ - // --- scope, depends only to the associationtype, roles can be ignored - // --- finds the scopes depending to the selected type - var foundIdx = -1; - for(var i = 0; this.__constraints__ && i != this.__constraints__.length; ++i) - { - if(foundIdx !== -1) break; - for(var j = 0; j != this.__constraints__[i].associationType.length; ++j){ - if(this.__type__.__frames__[0].getContent() === this.__constraints__[i].associationType[j]){ - foundIdx = i; - break; - } - } - } - this.__scope__.resetValues(null, (foundIdx === -1 ? null : this.__constraints__[foundIdx].scopeConstraints)); + var cc = this.getCurrentConstraint(); + this.__scope__.resetValues(null, (cc ? cc.scopeConstraints : null)); - var _roleConstraints = _playerConstraints = _otherRoleConstraints = null; - if(foundIdx !== -1){ - _roleConstraints = this.__constraints__[foundIdx].associationRoleConstraints; - _playerConstraints = this.__constraints__[foundIdx].rolePlayerConstraints; - _otherRoleConstraints = this.__constraints__[foundIdx].otherRoleConstraints; + var _roleConstraints = null; + var _playerConstraints = null; + var _otherRoleConstraints = null; + if(cc){ + _roleConstraints = cc.associationRoleConstraints; + _playerConstraints = cc.rolePlayerConstraints; + _otherRoleConstraints = cc.otherRoleConstraints; } this.__roles__.resetValues(_roleConstraints, _playerConstraints, _otherRoleConstraints); }, Modified: trunk/src/unit_tests/poems.xtm ============================================================================== --- trunk/src/unit_tests/poems.xtm (original) +++ trunk/src/unit_tests/poems.xtm Thu Jun 25 15:07:40 2009 @@ -1,5 +1,25 @@ <?xml version="1.0" encoding="UTF-8"?> <tm:topicMap version="2.0" xmlns:tm="http://www.topicmaps.org/xtm/"> + <!-- test: subtype for the roletype written --> + <tm:topic id="sub-written"> + <tm:subjectIdentifier href="sub-written-psi"/> + </tm:topic> + + <tm:association> + <tm:type><tm:topicRef href="#supertype-subtype"/></tm:type> + <tm:role> + <tm:type><tm:topicRef href="#subtype"/></tm:type> + <tm:topicRef href="#sub-written"/> + </tm:role> + <tm:role> + <tm:type><tm:topicRef href="#supertype"/></tm:type> + <tm:topicRef href="#written"/> + </tm:role> + </tm:association> + + <!-- end test --> + + <!-- test: defines some scopes constraints for associations of the type "born-in" --> <tm:topic id="scoped-born-in-constraint-1"> <tm:subjectIdentifier href="http://some.where/constraint-psis/scoped-born-in-constraint-1"/> @@ -637,6 +657,7 @@ <!-- available scopes --> <tm:topic id="de"> <tm:subjectIdentifier href="http://some.where/base-psis/de"/> + <tm:subjectIdentifier href="http://some.where/base-psis/ger"/> <tm:instanceOf><tm:topicRef href="#scopetype"/></tm:instanceOf> </tm:topic> @@ -924,7 +945,7 @@ </tm:occurrence> <tm:occurrence> <tm:type><tm:topicRef href="#card-max"/></tm:type> - <tm:resourceData datatype="http://www.w3.org/2001/XMLSchema#unsignedInt">2</tm:resourceData> + <tm:resourceData datatype="http://www.w3.org/2001/XMLSchema#unsignedInt">1</tm:resourceData> </tm:occurrence> <tm:occurrence> <tm:type><tm:topicRef href="#regexp"/></tm:type> @@ -2474,6 +2495,7 @@ </tm:topic> <tm:association> + <tm:itemIdentity href="born-in-frankfurt-goethe"/> <tm:type><tm:topicRef href="#born-in"/></tm:type> <tm:role> <tm:type><tm:topicRef href="#place"/></tm:type> @@ -2525,7 +2547,7 @@ </tm:name> <tm:occurrence> <tm:type><tm:topicRef href="#poem-content"/></tm:type> <!-- must have an occurrence of the type poem-content with the scope de or en --> - <tm:scope><tm:topicRef href="#de"/></tm:scope> + <tm:scope><tm:topicRef href="#en"/></tm:scope> <tm:resourceData datatype="http://www.w3.org/2001/XMLSchema#string">Hat der alte Hexenmeister sich doch einmal wegbegeben! Und nun sollen seine Geister @@ -2693,7 +2715,9 @@ </tm:topic> <tm:association> + <tm:itemIdentity href="wirtten-by-zauberlehrling-goethe"/> <tm:type><tm:topicRef href="#written-by"/></tm:type> + <tm:scope><tm:topicRef href="#de"/></tm:scope> <tm:role> <tm:type><tm:topicRef href="#writer"/></tm:type> <tm:topicRef href="#goethe"/> @@ -2705,7 +2729,9 @@ </tm:association> <tm:association> + <tm:itemIdentity href="wirtten-by-erlkoenig-goethe"/> <tm:type><tm:topicRef href="#written-by"/></tm:type> + <tm:scope><tm:topicRef href="#de"/></tm:scope> <tm:role> <tm:type><tm:topicRef href="#writer"/></tm:type> <tm:topicRef href="#goethe"/> @@ -2849,12 +2875,16 @@ </tm:topic> <tm:association> - <tm:type><tm:topicRef href="#written-by"/></tm:type> + <tm:itemIdentity href="written-by-association-shiller-resignation"/> + <tm:type><tm:topicRef href="#place"/></tm:type> + <tm:scope><tm:topicRef href="#de"/></tm:scope> <tm:role> + <tm:itemIdentity href="writer-role-schiller"/> <tm:type><tm:topicRef href="#writer"/></tm:type> <tm:topicRef href="#schiller"/> </tm:role> <tm:role> + <tm:itemIdentity href="written-role-resignation"/> <tm:type><tm:topicRef href="#written"/></tm:type> <tm:topicRef href="#resignation"/> </tm:role> @@ -2889,6 +2919,7 @@ <tm:association> <tm:type><tm:topicRef href="#written-by"/></tm:type> + <tm:scope><tm:topicRef href="#de"/></tm:scope> <tm:role> <tm:type><tm:topicRef href="#writer"/></tm:type> <tm:topicRef href="#eichendorff"/>
participants (1)
-
Lukas Giessmann