[isidorus-cvs] r837 - in branches/gdl-frontend/src: anaToMia/hosted_files/gdl_widgets/lib rest_interface
lgiessmann at common-lisp.net
lgiessmann at common-lisp.net
Wed Sep 7 06:55:08 UTC 2011
Author: lgiessmann
Date: Tue Sep 6 23:55:07 2011
New Revision: 837
Log:
gdl:frontend: finalised the ajax files that will be hosted to present the gdl-frontend
Added:
branches/gdl-frontend/src/anaToMia/hosted_files/gdl_widgets/lib/
branches/gdl-frontend/src/anaToMia/hosted_files/gdl_widgets/lib/tm.min.js
Modified:
branches/gdl-frontend/src/rest_interface/set-up-gdl-interface.lisp
Added: branches/gdl-frontend/src/anaToMia/hosted_files/gdl_widgets/lib/tm.min.js
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ branches/gdl-frontend/src/anaToMia/hosted_files/gdl_widgets/lib/tm.min.js Tue Sep 6 23:55:07 2011 (r837)
@@ -0,0 +1,115 @@
+// tmjs, version 0.4.0
+// http://github.com/jansc/tmjs
+// Copyright (c) 2010 Jan Schreiber <jans at ravn.no>
+// Licensed under the MIT-License.
+var TM,TopicMapSystemFactory;
+TM=function(){var n,C,h,g,e,f,i,l,m,o,t,u,p,D,x,A,B,v,y,w,z,O,E,J,H,s,q,P;Function.prototype.swiss=function(a){var b,c;for(b=1;b<arguments.length;b+=1){c=arguments[b];this.prototype[c]=a.prototype[c]}return this};n=function(){this.hash={};this.length=0};n.prototype={get:function(a){return this.hash[a]},contains:function(a){return this.get(a)!==undefined},put:function(a,b){this.hash[a]||(this.length+=1);return this.hash[a]=b},remove:function(a){delete this.hash[a];this.length-=1;return this},keys:function(){var a=
+[],b;for(b in this.hash)this.hash.hasOwnProperty(b)&&a.push(b);return a},values:function(){var a=[],b;for(b in this.hash)this.hash.hasOwnProperty(b)&&a.push(this.hash[b]);return a},empty:function(){this.hash={};this.length=0},size:function(){return this.length}};e={};e.ADD_ASSOCIATION=1;e.ADD_NAME=2;e.ADD_OCCURRENCE=3;e.ADD_ROLE=4;e.ADD_THEME=5;e.ADD_TOPIC=6;e.ADD_TYPE=7;e.REMOVE_ASSOCIATION=8;e.REMOVE_NAME=9;e.REMOVE_OCCURRENCE=10;e.REMOVE_ROLE=11;e.REMOVE_THEME=12;e.REMOVE_TOPIC=13;e.REMOVE_TYPE=
+14;e.SET_TYPE=15;C={string:"http://www.w3.org/2001/XMLSchema#string",integer:"http://www.w3.org/2001/XMLSchema#integer",anyURI:"http://www.w3.org/2001/XMLSchema#anyURI"};h={TYPE_INSTANCE:"http://psi.topicmaps.org/iso13250/model/type-instance",TYPE:"http://psi.topicmaps.org/iso13250/model/type",INSTANCE:"http://psi.topicmaps.org/iso13250/model/instance",TOPIC_NAME:"http://psi.topicmaps.org/iso13250/model/topic-name"};g=function(a,b){this.parnt=a;this.iri=b};g.prototype.getReference=function(){return this.iri};
+g.prototype.equals=function(a){return this.iri===a.getReference()};g.prototype.toExternalForm=function(){throw{name:"NotImplemented",message:"Locator.toExternalForm() not implemented"};};m=function(){};m.prototype.addItemIdentifier=function(a){var b;if(a===null)throw{name:"ModelConstraintException",message:"addItemIdentifier(null) is illegal"};if(b=this.getTopicMap()._ii2construct.get(a.getReference()))throw{name:"IdentityConstraintException",message:"Topic Maps constructs with the same item identifier are not allowed",
+reporter:this,existing:b,locator:a};this.itemIdentifiers.push(a);this.getTopicMap()._ii2construct.put(a.getReference(),this);return this};m.prototype.equals=function(a){return this.id===a.id};m.prototype.getId=function(){return this.id};m.prototype.getItemIdentifiers=function(){return this.itemIdentifiers};m.prototype.getParent=function(){return this.parnt};m.prototype.getTopicMap=function(){throw{name:"NotImplemented",message:"getTopicMap() not implemented"};};m.prototype.hashCode=function(){throw{name:"NotImplemented",
+message:"hashCode() not implemented"};};m.prototype.remove=function(){throw{name:"NotImplemented",message:"remove() not implemented"};};m.prototype.removeItemIdentifier=function(a){if(a!==null){for(var b=0;b<this.itemIdentifiers.length;b+=1)if(this.itemIdentifiers[b].getReference()===a.getReference()){this.itemIdentifiers.splice(b,1);break}this.getTopicMap()._ii2construct.remove(a.getReference());return this}};m.prototype.isTopicMap=function(){return false};m.prototype.isTopic=function(){return false};
+m.prototype.isAssociation=function(){return false};m.prototype.isRole=function(){return false};m.prototype.isName=function(){return false};m.prototype.isOccurrence=function(){return false};m.prototype.isVariant=function(){return false};o=function(){};o.prototype.getType=function(){return this.type};o.prototype.setType=function(a){if(a===null)throw{name:"ModelConstraintException",message:"Topic.setType cannot be called without type"};z.assertBelongsTo(this.getTopicMap(),a);this.getTopicMap().setTypeEvent.fire(this,
+{old:this.type,type:a});this.type=a;return this};l=function(){};l.prototype.addTheme=function(a){if(a===null)throw{name:"ModelConstraintException",message:"addTheme(null) is illegal"};for(var b=0;b<this.scope.length;b+=1)if(this.scope[b]===a)return false;z.assertBelongsTo(this.getTopicMap(),a);this.scope.push(a);this.getTopicMap().addThemeEvent.fire(this,{theme:a});if(this.isName())for(b=0;b<this.variants.length;b+=1)this.getTopicMap().addThemeEvent.fire(this.variants[b],{theme:a});return this};l.prototype.getScope=
+function(){if(this.isVariant()){var a,b=new n,c=this.parnt.getScope();for(a=0;a<c.length;a+=1)b.put(c[a].getId(),c[a]);for(a=0;a<this.scope.length;a+=1)b.put(this.scope[a].getId(),this.scope[a]);return b.values()}return this.scope};l.prototype.removeTheme=function(a){var b,c,d,j;for(b=0;b<this.scope.length;b+=1)if(this.scope[b]===a){this.getTopicMap().removeThemeEvent.fire(this,{theme:this.scope[b]});this.scope.splice(b,1);break}if(this.isName())for(b=0;b<this.variants.length;b+=1){d=this.variants[b].scope;
+j=false;for(c=0;c<d.length;c+=1)if(a.equals(d[c]))j=true;j||this.getTopicMap().removeThemeEvent.fire(this.variants[b],{theme:a})}return this};t=function(){};t.prototype.getReifier=function(){return this.reifier};t.prototype.setReifier=function(a){if(a&&a.getReified()!==null)throw{name:"ModelConstraintException",message:"Reifies already another construct"};z.assertBelongsTo(this.getTopicMap(),a);this.reifier&&this.reifier._setReified(null);a&&a._setReified(this);this.reifier=a;return this};u=function(){};
+u.prototype.decimalValue=function(){};u.prototype.floatValue=function(){var a=parseFloat(this.value);if(isNaN(a))throw{name:"NumberFormatException",message:'"'+this.value+'" is not a float'};return a};u.prototype.getDatatype=function(){return this.datatype};u.prototype.getValue=function(){if(typeof this.value==="object"&&this.value instanceof g)return this.value.getReference();return this.value.toString()};u.prototype.integerValue=function(){var a=parseInt(this.value,10);if(isNaN(a))throw{name:"NumberFormatException",
+message:'"'+this.value+'" is not an integer'};return a};u.prototype.locatorValue=function(){if(!(typeof this.value==="object"&&this.value instanceof g))throw{name:"ModelConstraintException",message:'"'+this.value+'" is not a locator'};return this.value};u.prototype.longValue=function(){};u.prototype.setValue=function(a,b){var c=this.getTopicMap();if(b===null)throw{name:"ModelConstraintException",message:"Invalid datatype"};if(a===null)throw{name:"ModelConstraintException",message:"Invalid value"};
+this.value=a;this.datatype=b||this.getTopicMap().createLocator(C.string);if(b&&b.getReference()===C.anyURI)this.value=c.createLocator(a);if(!b)if(typeof a==="number")this.datatype=c.createLocator(C.integer);if(typeof a==="object"&&a instanceof g)this.datatype=c.createLocator(C.anyURI)};TopicMapSystemFactory=function(){this.properties={};this.features={}};TopicMapSystemFactory.prototype.getFeature=function(){return this.features};TopicMapSystemFactory.prototype.getProperty=function(a){return this.properties[a]};
+TopicMapSystemFactory.prototype.hasFeature=function(){return false};TopicMapSystemFactory.newInstance=function(){return new TopicMapSystemFactory};TopicMapSystemFactory.prototype.newTopicMapSystem=function(){if((this.properties["com.semanticheadache.tmjs.backend"]||"memory")==="memory")return new v};TopicMapSystemFactory.prototype.setFeature=function(a,b){this.features[a]=b};TopicMapSystemFactory.prototype.setProperty=function(a,b){this.properties[a]=b};v=function(){this.topicmaps={}};v.prototype.createTopicMap=
+function(a){if(this.topicmaps[a.getReference()])throw{name:"TopicMapExistsException",message:"A topic map under the same IRI already exists"};var b=new p(this,a);return this.topicmaps[a.getReference()]=b};v.prototype.getLocators=function(){var a=[],b;for(b in this.topicmaps)this.topicmaps.hasOwnProperty(b)&&a.push(this.createLocator(b));return a};v.prototype.getTopicMap=function(a){a=a instanceof g?this.topicmaps[a.getReference()]:this.topicmaps[a];if(!a)return null;return a};v.prototype.createLocator=
+function(a){return new g(this,a)};v.prototype.getFeature=function(){return false};v.prototype._removeTopicMap=function(a){var b;for(b in this.topicmaps)this.topicmaps.hasOwnProperty(b)&&b===a.locator.getReference()&&delete this.topicmaps[b]};v.prototype.close=function(){this.topicmaps=null};p=function(a,b){this.topicmapsystem=a;this.itemIdentifiers=[];this.locator=b;this.topics=[];this.associations=[];this._constructId=1;this._si2topic=new n;this._sl2topic=new n;this._ii2construct=new n;this._id2construct=
+new n;this.id=0;this._id2construct.put(this.id,this);this.reifier=null;this.handlers=[];a=function(c){this.eventtype=c;this.handlers=[]};a.prototype={registerHandler:function(c){this.handlers.push(c)},removeHandler:function(c){for(var d=0;d<this.handlers.length;d+=1)c.toString()===this.handlers[d].toString()&&this.handlers.splice(d,1)},fire:function(c,d){d=d||{};for(var j=0;j<this.handlers.length;j+=1)this.handlers[j](this.eventtype,c,d)}};this.addAssociationEvent=new a(e.ADD_ASSOCIATION);this.addNameEvent=
+new a(e.ADD_NAME);this.addOccurrenceEvent=new a(e.ADD_OCCURRENCE);this.addRoleEvent=new a(e.ADD_ROLE);this.addThemeEvent=new a(e.ADD_THEME);this.addTopicEvent=new a(e.ADD_TOPIC);this.addTypeEvent=new a(e.ADD_TYPE);this.removeAssociationEvent=new a(e.REMOVE_ASSOCIATION);this.removeNameEvent=new a(e.REMOVE_NAME);this.removeOccurrenceEvent=new a(e.REMOVE_OCCURRENCE);this.removeRoleEvent=new a(e.REMOVE_ROLE);this.removeThemeEvent=new a(e.REMOVE_THEME);this.removeTopicEvent=new a(e.REMOVE_TOPIC);this.removeTypeEvent=
+new a(e.REMOVE_TYPE);this.setTypeEvent=new a(e.SET_TYPE);this.typeInstanceIndex=new y(this);this.scopedIndex=new w(this)};p.prototype.register_event_handler=function(a,b){switch(a){case e.ADD_ASSOCIATION:this.addAssociationEvent.registerHandler(b);break;case e.ADD_NAME:this.addNameEvent.registerHandler(b);break;case e.ADD_OCCURRENCE:this.addOccurrenceEvent.registerHandler(b);break;case e.ADD_ROLE:this.addRoleEvent.registerHandler(b);break;case e.ADD_THEME:this.addThemeEvent.registerHandler(b);break;
+case e.ADD_TOPIC:this.addTopicEvent.registerHandler(b);break;case e.ADD_TYPE:this.addTypeEvent.registerHandler(b);break;case e.REMOVE_ASSOCIATION:this.removeAssociationEvent.registerHandler(b);break;case e.REMOVE_NAME:this.removeNameEvent.registerHandler(b);break;case e.REMOVE_OCCURRENCE:this.removeOccurrenceEvent.registerHandler(b);break;case e.REMOVE_ROLE:this.removeRoleEvent.registerHandler(b);break;case e.REMOVE_THEME:this.removeThemeEvent.registerHandler(b);break;case e.REMOVE_TOPIC:this.removeTopicEvent.registerHandler(b);
+break;case e.REMOVE_TYPE:this.removeTypeEvent.registerHandler(b);break;case e.SET_TYPE:this.setTypeEvent.registerHandler(b);break}return this};p.swiss(t,"getReifier","setReifier");p.swiss(m,"addItemIdentifier","getItemIdentifiers","removeItemIdentifier","isTopic","isAssociation","isRole","isOccurrence","isName","isVariant","isTopicMap");p.prototype.sanitize=function(){H.removeTopicMapDuplicates(this);P.convertAssociationsToType(this);return this};p.prototype.isTopicMap=function(){return true};p.prototype._getConstructId=
+function(){this._constructId+=1;return this._constructId};p.prototype.remove=function(){if(this.topicmapsystem===null)return null;this.topicmapsystem._removeTopicMap(this);return this.typeInstanceIndex=this.id=this.reifier=this._id2construct=this._ii2construct=this._sl2topic=this._si2topic=this.associations=this.topics=this.locator=this.itemIdentifiers=this.topicmapsystem=null};p.prototype.createAssociation=function(a,b){var c;if(a===null)throw{name:"ModelConstraintException",message:"Creating an association with type == null is not allowed"};
+if(b===null)throw{name:"ModelConstraintException",message:"Creating an association with scope == null is not allowed"};z.assertBelongsTo(this,a);z.assertBelongsTo(this,b);c=new i(this);this.associations.push(c);a&&c.setType(a);J(c,b);this.addAssociationEvent.fire(c);return c};p.prototype.createLocator=function(a){return new g(this,a)};p.prototype._createEmptyTopic=function(){var a=new f(this);this.addTopicEvent.fire(a);this.topics.push(a);return a};p.prototype.createTopic=function(){var a=this._createEmptyTopic();
+a.addItemIdentifier(this.createLocator("urn:x-tmjs:"+a.getId()));return a};p.prototype.createTopicByItemIdentifier=function(a){if(!a)throw{name:"ModelConstraintException",message:"createTopicByItemIdentifier() needs an item identifier"};var b=this.getConstructByItemIdentifier(a);if(b){if(!b.isTopic())throw{name:"IdentityConstraintException",message:"Another construct with the specified item identifier exists which is not a Topic."};return b}b=this._createEmptyTopic();b.addItemIdentifier(a);return b};
+p.prototype.createTopicBySubjectIdentifier=function(a){if(!a)throw{name:"ModelConstraintException",message:"createTopicBySubjectIdentifier() needs a subject identifier"};var b=this.getTopicBySubjectIdentifier(a);if(b)return b;b=this._createEmptyTopic();b.addSubjectIdentifier(a);return b};p.prototype.createTopicBySubjectLocator=function(a){if(!a)throw{name:"ModelConstraintException",message:"createTopicBySubjectLocator() needs a subject locator"};var b=this.getTopicBySubjectLocator(a);if(b)return b;
+b=this._createEmptyTopic();b.addSubjectLocator(a);return b};p.prototype.getAssociations=function(){return this.associations};p.prototype.getConstructById=function(a){if(a===null)throw{name:"ModelConstraintException",message:"getConstructById(null) is illegal"};a=this._id2construct.get(a);if(!a)return null;return a};p.prototype.getConstructByItemIdentifier=function(a){if(a===null)throw{name:"ModelConstraintException",message:"getConstructByItemIdentifier(null) is illegal"};a=this._ii2construct.get(a.getReference());
+if(!a)return null;return a};p.prototype.getIndex=function(a){if(a==="TypeInstanceIndex")return a=this.typeInstanceIndex;else if(a==="ScopedIndex")return a=new w(this);throw{name:"UnsupportedOperationException",message:"getIndex ist not (yet) supported"};};p.prototype.getParent=function(){return null};p.prototype.getTopicBySubjectIdentifier=function(a){if(a=this._si2topic.get(a.getReference()))return a;return null};p.prototype.getTopicBySubjectLocator=function(a){if(a=this._sl2topic.get(a.getReference()))return a;
+return null};p.prototype.getLocator=function(){return this.locator};p.prototype.getTopics=function(){return this.topics};p.prototype.mergeIn=function(){throw{name:"NotImplemented",message:"TopicMap.mergeIn() not implemented"};};p.prototype.equals=function(a){return this.locator.equals(a.locator)};p.prototype.getId=function(){return this.id};p.prototype.getTopicMap=function(){return this};p.prototype._removeConstruct=function(a){var b=a.getItemIdentifiers(),c;for(c=0;c<b.length;c+=1)this._ii2construct.remove(b[c].getReference());
+this._id2construct.remove(a.getId())};p.prototype._removeTopic=function(a){var b,c=a.getSubjectIdentifiers(),d=a.getSubjectLocators();for(b=0;b<c.length;b+=1)this._si2topic.remove(c[b].getReference());for(b=0;b<d.length;b+=1)this._sl2topic.remove(d[b].getReference());this._removeConstruct(a);for(b=0;b<this.topics.length;b+=1)if(a.id===this.topics[b].id){this.topics.splice(b,1);break}};p.prototype._removeAssociation=function(a){var b;for(b=0;b<this.associations.length;b+=1)if(a.id===this.associations[b].id){this.associations.splice(b,
+1);break}this._removeConstruct(a);for(b=0;b<this.associations.length;b+=1)if(a.id===this.associations[b].id){this.associations.splice(b,1);break}};p.prototype._removeRole=function(a){this._removeConstruct(a)};p.prototype._removeOccurrence=function(a){this._removeConstruct(a)};p.prototype._removeName=function(a){this._removeConstruct(a)};p.prototype._removeVariant=function(a){this._removeConstruct(a)};f=function(a){this.subjectIdentifiers=[];this.subjectLocators=[];this.itemIdentifiers=[];this.parnt=
+a;this.id=a._getConstructId();this.getTopicMap()._id2construct.put(this.id,this);this.types=[];this.rolesPlayed=[];this.occurrences=[];this.names=[];this.reified=null};f.swiss(m,"addItemIdentifier","equals","getId","getItemIdentifiers","getParent","getTopicMap","hashCode","remove","removeItemIdentifier","isTopic","isAssociation","isRole","isOccurrence","isName","isVariant","isTopicMap");f.prototype.isTopic=function(){return true};f.prototype.getTopicMap=function(){return this.parnt};f.prototype.addSubjectIdentifier=
+function(a){if(!a)throw{name:"ModelConstraintException",message:"addSubjectIdentifier() needs subject identifier"};for(var b=0;b<this.subjectIdentifiers.length;b+=1)if(this.subjectIdentifiers[b].getReference()===a.getReference())return;this.subjectIdentifiers.push(a);this.parnt._si2topic.put(a.getReference(),this);return this};f.prototype.addSubjectLocator=function(a){if(!a)throw{name:"ModelConstraintException",message:"addSubjectLocator() needs subject locator"};for(var b=0;b<this.subjectLocators.length;b+=
+1)if(this.subjectLocators[b].getReference()===a.getReference())return;this.subjectLocators.push(a);this.parnt._sl2topic.put(a.getReference(),this);return this};f.prototype.addType=function(a){if(!a)throw{name:"ModelConstraintException",message:"addType() needs type"};z.assertBelongsTo(this.parnt,a);this.parnt.addTypeEvent.fire(this,{type:a});this.types.push(a);return this};f.prototype.createName=function(a,b,c){b&&z.assertBelongsTo(this.parnt,b);c&&z.assertBelongsTo(this.parnt,c);if(typeof c==="undefined")c=
+null;a=new x(this,a,b);J(a,c);this.names.push(a);return a};f.prototype.createOccurrence=function(a,b,c,d){z.assertBelongsTo(this.parnt,a);z.assertBelongsTo(this.parnt,d);c=new B(this,a,b,c);this.parnt.addOccurrenceEvent.fire(c,{type:a,value:b});J(c,d);this.occurrences.push(c);return c};f.prototype.getNames=function(a){var b=[],c;for(c=0;c<this.names.length;c+=1)if(a&&this.names[c].getType().equals(a))b.push(this.names[c]);else a||b.push(this.names[c]);return b};f.prototype.getOccurrences=function(a){var b=
+[],c;if(a===null)throw{name:"IllegalArgumentException",message:"Topic.getOccurrences cannot be called without type"};for(c=0;c<this.occurrences.length;c+=1)if(a&&this.occurrences[c].getType().equals(a))b.push(this.occurrences[c]);else a||b.push(this.occurrences[c]);return b};f.prototype._removeOccurrence=function(a){for(var b=0;b<this.occurrences.length;b+=1)if(this.occurrences[b].equals(a)){this.occurrences.splice(b,1);break}this.getTopicMap()._removeOccurrence(a)};f.prototype.getReified=function(){return this.reified};
+f.prototype._setReified=function(a){this.reified=a};f.prototype.getRolesPlayed=function(a,b){if(a===null)throw{name:"IllegalArgumentException",message:"Topic.getRolesPlayed cannot be called without type"};if(b===null)throw{name:"IllegalArgumentException",message:"Topic.getRolesPlayed cannot be called with assocType===null"};var c=[],d;for(d=0;d<this.rolesPlayed.length;d+=1)if(a){if(this.rolesPlayed[d].getType().equals(a))if(b&&this.rolesPlayed[d].getParent().getType().equals(b)||!b)c.push(this.rolesPlayed[d])}else c.push(this.rolesPlayed[d]);
+return c};f.prototype.addRolePlayed=function(a){this.rolesPlayed.push(a)};f.prototype.removeRolePlayed=function(a){for(var b=0;b<this.rolesPlayed.length;b+=1)this.rolesPlayed[b].id===a.id&&this.rolesPlayed.splice(b,1)};f.prototype.getSubjectIdentifiers=function(){return this.subjectIdentifiers};f.prototype.getSubjectLocators=function(){return this.subjectLocators};f.prototype.getTypes=function(){return this.types};f.prototype.mergeIn=function(a){var b,c,d,j,k;if(this.equals(a))return true;z.assertBelongsTo(this.getTopicMap(),
+a);if(this.getReified()&&a.getReified()&&!this.getReified().equals(a.getReified()))throw{name:"ModelConstraintException",message:"The topics reify different Topic Maps constructs and cannot be merged!"};if(!this.getReified()&&a.getReified()){d=a.getReified();d.setReifier(this)}b=this.parnt.typeInstanceIndex;q.moveTypes(b.getOccurrences(a),this);q.moveTypes(b.getNames(a),this);q.moveTypes(b.getAssociations(a),this);q.moveTypes(b.getRoles(a),this);b=b.getTopics(a);for(c=0;c<b.length;c+=1){b[c].removeType(a);
+b[c].addType(this)}b=this.parnt.scopedIndex;q.moveThemes(b.getAssociations(a),a,this);q.moveThemes(b.getOccurrences(a),a,this);q.moveThemes(b.getNames(a),a,this);q.moveThemes(b.getVariants(a),a,this);q.moveItemIdentifiers(a,this);for(b=a.getSubjectLocators();b.length;){d=b[b.length-1];a.removeSubjectLocator(d);this.addSubjectLocator(d)}for(b=a.getSubjectIdentifiers();b.length;){d=b[b.length-1];a.removeSubjectIdentifier(d);this.addSubjectIdentifier(d)}for(b=a.getTypes();b.length;){d=b[b.length-1];
+a.removeType(d);this.addType(d)}b=this.getRolesPlayed();k={};for(c=0;c<b.length;c+=1){j=b[c].getParent();k[s.makeAssociationSignature(j)]=j}b=a.getRolesPlayed();for(c=0;c<b.length;c+=1){d=b[c];d.setPlayer(this);if(j=k[s.makeAssociationSignature(d.getParent())]){q.moveItemIdentifiers(d.getParent(),j);q.moveReifier(d.getParent(),j);d.getParent().remove()}}b=this.getNames();k={};for(c=0;c<b.length;c+=1)k[s.makeNameSignature(b[c])]=b[c];b=a.getNames();for(c=0;c<b.length;c+=1){d=b[c];if(j=k[s.makeNameSignature(b[c])]){q.moveItemIdentifiers(d,
+j);q.moveReifier(d,j);q.moveVariants(d,j);d.remove()}else{j=this.createName(d.getValue(),d.getType(),d.getScope());q.moveVariants(d,j)}}b=this.getOccurrences();k={};for(c=0;c<b.length;c+=1)k[s.makeOccurrenceSignature(b[c])]=b[c];b=a.getOccurrences();for(c=0;c<b.length;c+=1){d=b[c];if(j=k[s.makeOccurrenceSignature(b[c])]){q.moveItemIdentifiers(d,j);q.moveReifier(d,j);d.remove()}else{j=this.createOccurrence(d.getType(),d.getValue(),d.getDatatype(),d.getScope());q.moveReifier(d,j)}}a.remove();return this};
+f.prototype.remove=function(){var a=this.parnt.typeInstanceIndex,b=this.parnt.scopedIndex;if(this.getReified()||a.getOccurrences(this).length||a.getNames(this).length||a.getAssociations(this).length||a.getRoles(this).length||a.getTopics(this).length||b.getAssociations(this).length||b.getOccurrences(this).length||b.getNames(this).length||b.getVariants(this).length||this.getRolesPlayed().length)throw{name:"TopicInUseException",message:"",reporter:this};this.parnt._removeTopic(this);this.parnt._id2construct.remove(this.id);
+this.parnt.removeTopicEvent.fire(this);this.id=null;return this.parnt};f.prototype.removeSubjectIdentifier=function(a){for(var b=0;b<this.subjectIdentifiers.length;b+=1)if(this.subjectIdentifiers[b].getReference()===a.getReference()){this.subjectIdentifiers.splice(b,1);break}this.parnt._sl2topic.remove(a.getReference());return this};f.prototype.removeSubjectLocator=function(a){for(var b=0;b<this.subjectLocators.length;b+=1)if(this.subjectLocators[b].getReference()===a.getReference()){this.subjectLocators.splice(b,
+1);break}this.parnt._sl2topic.remove(a.getReference());return this};f.prototype.removeType=function(a){for(var b=0;b<this.types.length;b+=1)if(this.types[b].equals(a)){this.types.splice(b,1);this.parnt.removeTypeEvent.fire(this,{type:a});break}};f.prototype._removeName=function(a){for(var b=0;b<this.names.length;b+=1)if(this.names[b].equals(a)){this.names.splice(b,1);break}this.getTopicMap()._removeName(a)};B=function(a,b,c,d){this.itemIdentifiers=[];this.parnt=a;this.type=b;this.value=c;this.datatype=
+d?d:this.getTopicMap().createLocator(C.string);this.scope=[];this.reifier=null;this.id=this.getTopicMap()._getConstructId();this.getTopicMap()._id2construct.put(this.id,this)};B.swiss(o,"getType","setType");B.swiss(u,"decimalValue","floatValue","getDatatype","getValue","integerValue","locatorValue","longValue","setValue");B.swiss(t,"getReifier","setReifier");B.swiss(l,"addTheme","getScope","removeTheme");B.swiss(m,"addItemIdentifier","equals","getId","getItemIdentifiers","getParent","getTopicMap",
+"hashCode","remove","removeItemIdentifier","isTopic","isAssociation","isRole","isOccurrence","isName","isVariant","isTopicMap");B.prototype.isOccurrence=function(){return true};B.prototype.getTopicMap=function(){return this.parnt.getParent()};B.prototype.remove=function(){var a;for(a=0;a<this.scope.length;a+=1)this.parnt.parnt.removeThemeEvent.fire(this,{theme:this.scope[a]});this.parnt.parnt.removeOccurrenceEvent.fire(this);this.parnt._removeOccurrence(this);this.id=null;return this.parnt};x=function(a,
+b,c){this.itemIdentifiers=[];this.parnt=a;this.value=b;this.scope=[];this.id=this.getTopicMap()._getConstructId();this.type=c||a.parnt.createTopicBySubjectIdentifier(a.parnt.createLocator("http://psi.topicmaps.org/iso13250/model/topic-name"));this.reifier=null;this.variants=[];this.getTopicMap()._id2construct.put(this.id,this);this.parnt.parnt.addNameEvent.fire(this,{type:this.type,value:b})};x.swiss(o,"getType","setType");x.swiss(t,"getReifier","setReifier");x.swiss(l,"addTheme","getScope","removeTheme");
+x.swiss(m,"addItemIdentifier","equals","getId","getItemIdentifiers","getParent","getTopicMap","hashCode","remove","removeItemIdentifier","isTopic","isAssociation","isRole","isOccurrence","isName","isVariant","isTopicMap");x.prototype.isName=function(){return true};x.prototype.getTopicMap=function(){return this.parnt.parnt};x.prototype.createVariant=function(a,b,c){if(typeof c==="undefined"||c===null)throw{name:"ModelConstraintException",message:"Creation of a variant with a null scope is not allowed"};
+a=new A(this,a,b);J(a,c);for(c=0;c<this.scope.length;c+=1)this.getTopicMap().addThemeEvent.fire(a,{theme:this.scope[c]});this.variants.push(a);return a};x.prototype.setValue=function(a){if(!a)throw{name:"ModelConstraintException",message:"Name.setValue(null) is not allowed"};this.value=a;return this};x.prototype.getValue=function(){return this.value};x.prototype.remove=function(){var a;for(a=0;a<this.scope.length;a+=1)this.parnt.parnt.removeThemeEvent.fire(this,{theme:this.scope[a]});this.parnt.parnt.removeNameEvent.fire(this);
+this.parnt._removeName(this);this.id=null;return this.parnt};x.prototype._removeVariant=function(a){for(var b=0;b<this.variants.length;b+=1)if(this.variants[b].equals(a)){this.variants.splice(b,1);break}this.getTopicMap()._removeVariant(a)};x.prototype.getVariants=function(){return this.variants};A=function(a,b,c){if(b===null)throw{name:"ModelConstraintException",message:"Creation of a variant with null value is not allowed"};if(c===null)throw{name:"ModelConstraintException",message:"Creation of a variant with datatype == null is not allowed"};
+this.itemIdentifiers=[];this.scope=[];this.parnt=a;this.datatype=typeof b==="object"&&b instanceof g?this.getTopicMap().createLocator("http://www.w3.org/2001/XMLSchema#anyURI"):this.getTopicMap().createLocator(C.string);this.datatype=c;this.reifier=null;this.value=b;this.id=this.getTopicMap()._getConstructId();this.getTopicMap()._id2construct.put(this.id,this)};A.swiss(t,"getReifier","setReifier");A.swiss(l,"addTheme","getScope","removeTheme");A.swiss(m,"addItemIdentifier","equals","getId","getItemIdentifiers",
+"getParent","getTopicMap","hashCode","remove","removeItemIdentifier","isTopic","isAssociation","isRole","isOccurrence","isName","isVariant","isTopicMap");A.swiss(u,"decimalValue","floatValue","getDatatype","getValue","integerValue","locatorValue","longValue","setValue");A.prototype.isVariant=function(){return true};A.prototype.getTopicMap=function(){return this.getParent().getParent().getParent()};A.prototype.remove=function(){var a;for(a=0;a<this.scope.length;a+=1)this.getTopicMap().removeThemeEvent.fire(this,
+{theme:this.scope[a]});this.getParent()._removeVariant(this);this.id=null;return this.parnt};D=function(a,b,c){this.itemIdentifiers=[];this.parnt=a;this.type=b;this.player=c;this.id=this.getTopicMap()._getConstructId();this.reifier=null;this.getTopicMap()._id2construct.put(this.id,this)};D.swiss(o,"getType","setType");D.swiss(t,"getReifier","setReifier");D.swiss(m,"addItemIdentifier","equals","getId","getItemIdentifiers","getParent","getTopicMap","hashCode","remove","removeItemIdentifier","isTopic",
+"isAssociation","isRole","isOccurrence","isName","isVariant","isTopicMap");D.prototype.isRole=function(){return true};D.prototype.getTopicMap=function(){return this.getParent().getParent()};D.prototype.remove=function(){var a=this.parnt;this.parnt.parnt.removeRoleEvent.fire(this);this.parnt._removeRole(this);this.id=this.reifier=this.player=this.type=this.parnt=this.itemIdentifiers=null;return a};D.prototype.getPlayer=function(){return this.player};D.prototype.setPlayer=function(a){if(!a)throw{name:"ModelConstraintException",
+message:"player i Role.setPlayer cannot be null"};z.assertBelongsTo(this.parnt.parnt,a);if(!this.player.equals(a)){this.player.removeRolePlayed(this);a.addRolePlayed(this);this.player=a;return this}};i=function(a){this.itemIdentifiers=[];this.parnt=a;this.id=this.getTopicMap()._getConstructId();this.getTopicMap()._id2construct.put(this.id,this);this.roles=[];this.scope=[];this.reifier=this.type=null};i.swiss(o,"getType","setType");i.swiss(t,"getReifier","setReifier");i.swiss(l,"addTheme","getScope",
+"removeTheme");i.swiss(m,"addItemIdentifier","equals","getId","getItemIdentifiers","getParent","getTopicMap","hashCode","remove","removeItemIdentifier","isTopic","isAssociation","isRole","isOccurrence","isName","isVariant","isTopicMap");i.prototype.isAssociation=function(){return true};i.prototype.getTopicMap=function(){return this.parnt};i.prototype.createRole=function(a,b){if(!a)throw{name:"ModelConstraintException",message:"type i Role.createPlayer cannot be null"};if(!b)throw{name:"ModelConstraintException",
+message:"player i Role.createRole cannot be null"};z.assertBelongsTo(this.parnt,a);z.assertBelongsTo(this.parnt,b);var c=new D(this,a,b);b.addRolePlayed(c);this.roles.push(c);this.parnt.addRoleEvent.fire(c,{type:a,player:b});return c};i.prototype._removeRole=function(a){for(var b=0;b<this.roles.length;b+=1)if(a.id===this.roles[b].id){this.roles.splice(b,1);break}a.getPlayer().removeRolePlayed(a);this.getTopicMap()._removeRole(a)};i.prototype.remove=function(){var a;for(a=0;a<this.scope.length;a+=
+1)this.parnt.removeThemeEvent.fire(this,{theme:this.scope[a]});for(this.parnt.removeAssociationEvent.fire(this);this.roles.length;)this.roles[0].remove();this.roles=this.id=null;this.parnt._removeAssociation(this);this.getTopicMap()._ii2construct.remove(this.id);this.reifier=this.type=this.scope=this.item_identifiers=null;return this.parnt};i.prototype.getRoles=function(a){if(a===null)throw{name:"IllegalArgumentException",message:"Topic.getRoles cannot be called with type null"};if(!a)return this.roles;
+var b=[],c;for(c=0;c<this.roles.length;c+=1)this.roles[c].getType().equals(a)&&b.push(this.roles[c]);return b};i.prototype.getRoleTypes=function(){var a={},b=[],c,d;for(c=0;c<this.roles.length;c+=1)a[this.roles[c].getType().getId()]=this.roles[c].getType();for(d in a)a.hasOwnProperty(d)&&b.push(a[d]);return b};l=function(){this.opened=false};l.prototype.close=function(){};l.prototype.isAutoUpdated=function(){return true};l.prototype.isOpen=function(){return this.opened};l.prototype.open=function(){this.opened=
+true};l.prototype.reindex=function(){};y=function(a){var b,c=this;this.tm=a;this.type2topics=new n;this.type2associations=new n;this.type2roles=new n;this.type2occurrences=new n;this.type2names=new n;this.type2variants=new n;this.opened=false;b=function(d,j,k){var r;switch(d){case e.ADD_ASSOCIATION:break;case e.ADD_NAME:d=c.type2names.get(k.type.getId());if(typeof d==="undefined")d=new n;d.put(j.getId(),j);c.type2names.put(k.type.getId(),d);break;case e.ADD_OCCURRENCE:d=c.type2occurrences.get(k.type.getId());
+if(typeof d==="undefined")d=new n;d.put(j.getId(),j);c.type2occurrences.put(k.type.getId(),d);break;case e.ADD_ROLE:d=c.type2roles.get(k.type.getId());if(typeof d==="undefined")d=new n;d.put(j.getId(),j);c.type2roles.put(k.type.getId(),d);break;case e.ADD_TOPIC:d=c.type2topics.get("null");if(typeof d==="undefined")d=new n;d.put(j.getId(),j);c.type2topics.put("null",d);break;case e.ADD_TYPE:if((d=c.type2topics.get("null"))&&d.get(j.getId())){d.remove(j.getId());c.type2topics.put("null",d)}d=c.type2topics.get(k.type.getId());
+if(typeof d==="undefined")d=new n;d.put(j.getId(),j);c.type2topics.put(k.type.getId(),d);break;case e.REMOVE_ASSOCIATION:k=j.getType();if(!k)break;d=c.type2associations.get(k.getId());for(r=0;r<d.length;r+=1)if(d[r].equals(j)){d.splice(r,1);break}d.length>0?c.type2associations.put(k.getId(),d):c.type2associations.remove(k.getId());break;case e.REMOVE_NAME:k=j.getType();d=c.type2names.get(k.getId());d.remove(j.getId());d.length>0?c.type2names.put(k.getId(),d):c.type2names.remove(k.getId());break;case e.REMOVE_OCCURRENCE:k=
+j.getType();d=c.type2occurrences.get(k.getId());d.remove(j.getId());d.length>0?c.type2occurrences.put(k.getId(),d):c.type2occurrences.remove(k.getId());break;case e.REMOVE_ROLE:k=j.getType();d=c.type2roles.get(k.getId());d.remove(j.getId());d.length>0?c.type2roles.put(k.getId(),d):c.type2roles.remove(k.getId());break;case e.REMOVE_TOPIC:k=j.getTypes();for(r=0;r<k.length;r+=1){d=c.type2topics.get(k[r].getId());d.remove(j.getId());d.size()||c.type2topics.remove(k[r].getId())}c.type2topics.remove(j.getId());
+c.type2associations.remove(j.getId());c.type2roles.remove(j.getId());c.type2occurrences.remove(j.getId());c.type2variants.remove(j.getId());break;case e.REMOVE_TYPE:d=c.type2topics.get(k.type.getId());d.remove(j.getId());d.size()||c.type2topics.remove(k.type.getId());if(j.getTypes().length===0){d=c.type2topics.get("null");if(typeof d==="undefined")d=new n;d.put(j.getId(),j)}break;case e.SET_TYPE:if(j.isAssociation()){if(k.old){d=c.type2associations.get(k.old.getId());for(r=0;r<d.length;r+=1)if(d[r].equals(j)){d.splice(r,
+1);break}d.length>0?c.type2associations.put(k.old.getId(),d):c.type2associations.remove(k.old.getId())}d=c.type2associations.get(k.type.getId());if(typeof d==="undefined")d=[];d.push(j);c.type2associations.put(k.type.getId(),d)}else if(j.isName()){if(d=c.type2names.get(k.old.getId())){d.remove(j.getId());d.length>0?c.type2names.put(k.old.getId(),d):c.type2names.remove(k.old.getId())}d=c.type2names.get(k.type.getId());if(typeof d==="undefined")d=new n;d.put(j.getId(),j);c.type2names.put(k.type.getId(),
+d)}else if(j.isOccurrence()){if(d=c.type2occurrences.get(k.old.getId())){d.remove(j.getId());d.length>0?c.type2occurrences.put(k.old.getId(),d):c.type2occurrences.remove(k.old.getId())}d=c.type2occurrences.get(k.type.getId());if(typeof d==="undefined")d=new n;d.put(j.getId(),j);c.type2occurrences.put(k.type.getId(),d)}else if(j.isRole()){if(d=c.type2roles.get(k.old.getId())){d.remove(j.getId());d.length>0?c.type2roles.put(k.old.getId(),d):c.type2roles.remove(k.old.getId())}d=c.type2roles.get(k.type.getId());
+if(typeof d==="undefined")d=new n;d.put(j.getId(),j);c.type2roles.put(k.type.getId(),d)}break}};a.addAssociationEvent.registerHandler(b);a.addNameEvent.registerHandler(b);a.addOccurrenceEvent.registerHandler(b);a.addRoleEvent.registerHandler(b);a.addTopicEvent.registerHandler(b);a.addTypeEvent.registerHandler(b);a.removeAssociationEvent.registerHandler(b);a.removeNameEvent.registerHandler(b);a.removeOccurrenceEvent.registerHandler(b);a.removeRoleEvent.registerHandler(b);a.removeTopicEvent.registerHandler(b);
+a.removeTypeEvent.registerHandler(b);a.setTypeEvent.registerHandler(b)};y.swiss(l,"close","isAutoUpdated","isOpen","open","reindex");y.prototype.getAssociations=function(a){a=this.type2associations.get(a.getId());if(!a)return[];return a};y.prototype.getAssociationTypes=function(){var a=[],b=this.type2associations.keys(),c;for(c=0;c<b.length;c+=1)a.push(this.tm.getConstructById(b[c]));return a};y.prototype.getNames=function(a){a=this.type2names.get(a.getId());if(!a)return[];return a.values()};y.prototype.getNameTypes=
+function(){var a=[],b=this.type2names.keys(),c;for(c=0;c<b.length;c+=1)a.push(this.tm.getConstructById(b[c]));return a};y.prototype.getOccurrences=function(a){a=this.type2occurrences.get(a.getId());if(!a)return[];return a.values()};y.prototype.getOccurrenceTypes=function(){var a=[],b=this.type2occurrences.keys(),c;for(c=0;c<b.length;c+=1)a.push(this.tm.getConstructById(b[c]));return a};y.prototype.getRoles=function(a){a=this.type2roles.get(a.getId());if(!a)return[];return a.values()};y.prototype.getRoleTypes=
+function(){var a=[],b=this.type2roles.keys(),c;for(c=0;c<b.length;c+=1)a.push(this.tm.getConstructById(b[c]));return a};y.prototype.getTopics=function(a){a=this.type2topics.get(a?a.getId():"null");if(!a)return[];return a.values()};y.prototype.getTopicsByTypes=function(a,b){var c,d;c=E.getForKeys(this.type2topics,a);if(!b)return c;for(b=0;b<c.length;b+=1)for(d=0;d<a.length;d+=1)if(!O.contains(c[b].getTypes(),a[d])){c.splice(b,1);b-=1;break}return c};y.prototype.getTopicTypes=function(){var a=[],b=
+this.type2topics.keys(),c;for(c=0;c<b.length;c+=1)b[c]!=="null"&&a.push(this.tm.getConstructById(b[c]));return a};y.prototype.close=function(){};w=function(a){var b=this,c;this.tm=a;this.theme2associations=new n;this.theme2names=new n;this.theme2occurrences=new n;this.theme2variants=new n;c=function(d,j,k){var r,I,M,K,L;L=function(F,G,N){I=N.theme?N.theme.getId():"null";if(G.getScope().length===1)if((M=F.get("null"))&&M.get(G.getId())){M.remove(G.getId());F.put("null",M)}r=F.get(I);if(typeof r===
+"undefined")r=new n;r.put(G.getId(),G);F.put(I,r)};K=function(F,G,N){I=N.theme.getId();r=F.get(I);if(typeof r!=="undefined"){r.remove(G.getId());r.size()||F.remove(I)}};switch(d){case e.ADD_THEME:if(j.isAssociation())L(b.theme2associations,j,k);else if(j.isName())L(b.theme2names,j,k);else if(j.isOccurrence())L(b.theme2occurrences,j,k);else j.isVariant()&&L(b.theme2variants,j,k);break;case e.REMOVE_THEME:if(j.isAssociation())K(b.theme2associations,j,k);else if(j.isName())K(b.theme2names,j,k);else if(j.isOccurrence())K(b.theme2occurrences,
+j,k);else j.isVariant()&&K(b.theme2variants,j,k);break}};a.addThemeEvent.registerHandler(c);a.removeThemeEvent.registerHandler(c)};w.swiss(l,"close","isAutoUpdated","isOpen","open","reindex");w.prototype.close=function(){};w.prototype.getAssociations=function(a){a=this.theme2associations.get(a?a.getId():"null");if(!a)return[];return a.values()};w.prototype.getAssociationsByThemes=function(a,b){if(a===null)throw{name:"IllegalArgumentException",message:"ScopedIndex.getAssociationsByThemes cannot be called without themes"};
+return E.getConstructsByThemes(this.theme2associations,a,b)};w.prototype.getAssociationThemes=function(){return E.getConstructThemes(this.tm,this.theme2associations)};w.prototype.getNames=function(a){a=this.theme2names.get(a?a.getId():"null");if(!a)return[];return a.values()};w.prototype.getNamesByThemes=function(a,b){if(a===null)throw{name:"IllegalArgumentException",message:"ScopedIndex.getNamesByThemes cannot be called without themes"};return E.getConstructsByThemes(this.theme2names,a,b)};w.prototype.getNameThemes=
+function(){return E.getConstructThemes(this.tm,this.theme2names)};w.prototype.getOccurrences=function(a){a=this.theme2occurrences.get(a?a.getId():"null");if(!a)return[];return a.values()};w.prototype.getOccurrencesByThemes=function(a,b){if(a===null)throw{name:"IllegalArgumentException",message:"ScopedIndex.getOccurrencesByThemes cannot be called without themes"};return E.getConstructsByThemes(this.theme2occurrences,a,b)};w.prototype.getOccurrenceThemes=function(){return E.getConstructThemes(this.tm,
+this.theme2occurrences)};w.prototype.getVariants=function(a){if(a===null)throw{name:"IllegalArgumentException",message:"ScopedIndex.getVariants cannot be called without themes"};a=this.theme2variants.get(a?a.getId():"null");if(!a)return[];return a.values()};w.prototype.getVariantsByThemes=function(a,b){if(a===null)throw{name:"IllegalArgumentException",message:"ScopedIndex.getVariantsByThemes cannot be called without themes"};return E.getConstructsByThemes(this.theme2variants,a,b)};w.prototype.getVariantThemes=
+function(){return E.getConstructThemes(this.tm,this.theme2variants)};z={assertBelongsTo:function(a,b){var c;if(!b)return false;if(b&&b instanceof f&&!a.equals(b.getTopicMap()))throw{name:"ModelConstraintException",message:"scope topic belongs to different topic map"};if(b&&b instanceof Array)for(c=0;c<b.length;c+=1)if(!a.equals(b[c].getTopicMap()))throw{name:"ModelConstraintException",message:"scope topic belong to different topic maps"};return true}};E={getForKeys:function(a,b){var c,d,j=new n,k,
+r;for(c=0;c<b.length;c+=1)if(k=a.get(b[c].getId())){r=k.keys();for(d=0;d<r.length;d+=1)j.put(k.get(r[d]).getId(),k.get(r[d]))}return j.values()},getConstructThemes:function(a,b){var c=[];b=b.keys();var d;for(d=0;d<b.length;d+=1)b[d]!=="null"&&c.push(a.getConstructById(b[d]));return c},getConstructsByThemes:function(a,b,c){var d;a=E.getForKeys(a,b);if(!c)return a;for(c=0;c<a.length;c+=1)for(d=0;d<b.length;d+=1)if(!O.contains(a[c].getScope(),b[d])){a.splice(c,1);c-=1;break}return a}};O={contains:function(a,
+b){for(var c in a)if(a.hasOwnProperty(c))if(a[c].equals(b))return true;return false}};J=function(a,b){var c;if(b&&typeof b==="object")if(b instanceof Array)for(c=0;c<b.length;c+=1)a.addTheme(b[c]);else b instanceof f&&a.addTheme(b);else a.getTopicMap().addThemeEvent.fire(a,{theme:null})};s={makeNameValueSignature:function(a){return a.getValue()},makeNameSignature:function(a){return s.makeNameValueSignature(a)+"#"+s.makeTypeSignature(a)+"#"+s.makeScopeSignature(a)},makeOccurrenceSignature:function(a){return s.makeOccurrenceValueSignature(a)+
+"#"+s.makeTypeSignature(a)+"#"+s.makeScopeSignature(a)},makeOccurrenceValueSignature:function(a){return"#"+a.getValue()+"#"+(a.getDatatype()?a.getDatatype().getReference():"null")},makeTypeSignature:function(a){return(a=a.getType())?a.getId():""},makeScopeSignature:function(a){var b,c=[];for(b=0;b<a.length;b+=1)c.push(a[b].getId());c.sort();return c.join("#")},makeAssociationSignature:function(a){var b,c,d=[];b=a.getRoles();for(c=0;c<b.length;c+=1)d.push(s.makeRoleSignature(b[c]));d.sort();return"#"+
+s.makeTypeSignature(a)+"#"+d.join("#")+s.makeScopeSignature(a)},makeRoleSignature:function(a){return s.makeTypeSignature(a)+"#"+a.getPlayer().getId()},makeVariantValueSignature:function(a){return"#"+a.getValue()+"#"+a.getDatatype().getReference()},makeVariantSignature:function(a){return s.makeVariantValueSignature(a)+"#"+s.makeScopeSignature(a)}};H={removeTopicMapDuplicates:function(a){var b,c,d=new n,j;c=a.getTopics();for(b=0;b<c.length;b+=1){H.removeOccurrencesDuplicates(c[b].getOccurrences());
+H.removeNamesDuplicates(c[b].getNames())}a=a.getAssociations();for(b=0;b<a.length;b+=1){H.removeAssociationDuplicates(a[b]);c=s.makeAssociationSignature(a[b]);if(j=d.get(c)){q.moveConstructCharacteristics(a[b],j);q.moveRoleCharacteristics(a[b],j);a[b].remove()}else d.put(c,a[b])}d.empty()},removeOccurrencesDuplicates:function(a){var b,c=new n,d,j,k;for(b=0;b<a.length;b+=1){d=a[b];j=s.makeOccurrenceSignature(d);if(k=c.get(j)){q.moveConstructCharacteristics(d,k);d.remove()}else c.put(j,d)}c.empty()},
+removeNamesDuplicates:function(a){var b,c=new n,d,j,k;for(b=0;b<a.length;b+=1){d=a[b];H.removeVariantsDuplicates(d.getVariants());j=s.makeNameSignature(d);if(k=c.get(j)){q.moveConstructCharacteristics(d,k);q.moveVariants(d,k);d.remove()}else c.put(j,d)}c.empty()},removeVariantsDuplicates:function(a){var b,c=new n,d,j,k;for(b=0;b<a.length;b+=1){d=a[b];j=s.makeVariantSignature(d);if(k=c.get(j)){q.moveConstructCharacteristics(d,k);d.remove()}else c.put(j,d)}c.empty()},removeAssociationDuplicates:function(a){var b=
+a.getRoles(),c=new n,d,j;for(a=0;a<b.length;a+=1){d=s.makeRoleSignature(b[a]);if(j=c.get(d)){q.moveConstructCharacteristics(b[a],j);b[a].remove()}else c.put(d,b[a])}}};q={moveTypes:function(a,b){var c;for(c=0;c<a.length;c+=1)a[c].setType(b)},moveThemes:function(a,b,c){for(var d=0;d<a.length;d+=1){a[d].removeTheme(b);a[d].addTheme(c)}},moveItemIdentifiers:function(a,b){var c,d;for(c=a.getItemIdentifiers();c.length;){d=c[c.length-1];a.removeItemIdentifier(d);b.addItemIdentifier(d)}},moveVariants:function(a,
+b){var c,d,j,k;c=b.getVariants();k={};for(d=0;d<c.length;d+=1)k[s.makeVariantSignature(c[d])]=c[d];c=a.getVariants();for(d=0;d<c.length;d+=1){a=c[d];if(j=k[s.makeVariantSignature(c[d])]){q.moveItemIdentifiers(a,j);q.moveReifier(a,j);a.remove()}else b.createVariant(a.getValue(),a.getDatatype(),a.getScope())}},moveReifier:function(a,b){var c;if(a.getReifier()!==null)if(b.getReifier()===null)b.setReifier(a.getReifier());else{c=a.getReifier();b=b.getReifier();a.setReifier(null);c.mergeIn(b)}},moveRoleCharacteristics:function(a,
+b){var c,d=new n;c=b.getRoles();for(b=0;b<c.length;b+=1)d.put(c[b],s.makeRoleSignature(c[b]));c=a.getRoles();for(b=0;b<c.length;b+=1){q.moveItemIdentifiers(c[b],d.get(s.makeRoleSignature(c[b])));c[b].remove()}},moveConstructCharacteristics:function(a,b){q.moveReifier(a,b);q.moveItemIdentifiers(a,b)}};P={convertAssociationsToType:function(a){var b,c,d,j,k;b=a.getTopicBySubjectIdentifier(a.createLocator(h.TYPE_INSTANCE));c=a.getTopicBySubjectIdentifier(a.createLocator(h.TYPE));d=a.getTopicBySubjectIdentifier(a.createLocator(h.INSTANCE));
+if(!(!b||!c||!d))if(a=a.getIndex("TypeInstanceIndex")){a.isAutoUpdated()||a.reindex();b=a.getAssociations(b);for(a=0;a<b.length;a+=1){j=b[a];if(!(j.getScope().length>0||j.getReifier()!==null||j.getItemIdentifiers().length>0)){k=j.getRoles();if(k.length===2){if(k[0].getType().equals(c)&&k[1].getType().equals(d))k[1].getPlayer().addType(k[0].getPlayer());else if(k[1].getType().equals(c)&&k[0].getType().equals(d))k[0].getPlayer().addType(k[1].getPlayer());else continue;j.remove()}}}}}};return{TopicMapSystemFactory:TopicMapSystemFactory,
+XSD:C,TMDM:h,Hash:n,Version:"0.4.0"}}();TopicMapSystemFactory=TM.TopicMapSystemFactory;if(typeof exports==="object"&&exports!==null){exports.TopicMapSystemFactory=TopicMapSystemFactory;exports.TM=TM}
+TM.JTM=function(){var n,C;n=function(h){var g=this;this.tm=h;this.version=null;this.prefixes={};this.defaultDatatype=this.tm.createLocator(TM.XSD.string);this.curieToLocator=function(e){var f,i;if(g.version==="1.1"&&e.substr(0,1)==="["){if(e.substr(e.length-1,1)!=="]")throw{name:"InvalidFormat",message:"Invaild CURIE: missing tailing bracket"};e=e.substr(1,e.length-2);i=e.indexOf(":");if(i!==-1){f=e.substr(0,i);if(g.prefixes[f])return e=g.prefixes[f]+e.substr(i+1,e.length-1);else throw{name:"InvalidFormat",
+message:"Missing prefix declaration: "+f};}else throw{name:"InvalidFormat",message:"Invaild CURIE: missing colon"};}return e};this.getTopicByReference=function(e){if(typeof e==="undefined"||e===null)return null;switch(e.substr(0,3)){case "si:":return this.tm.createTopicBySubjectIdentifier(this.tm.createLocator(this.curieToLocator(e.substr(3))));case "sl:":return this.tm.createTopicBySubjectLocator(this.tm.createLocator(this.curieToLocator(e.substr(3))));case "ii:":return this.tm.createTopicByItemIdentifier(this.tm.createLocator(this.curieToLocator(e.substr(3))))}throw{name:"InvalidFormat",
+message:"Invaild topic reference '"+e+"'"};}};n.prototype.fromString=function(h){return this.fromObject(JSON.parse(h))};n.prototype.fromObject=function(h,g){g=g||null;if(h.version!=="1.0"&&h.version!=="1.1")throw{name:"InvalidFormat",message:"Unknown version of JTM: "+h.version};this.version=h.version;if(h.version==="1.1"&&h.prefixes){if((this.prefixes=h.prefixes)&&h.prefixes.xsd&&h.prefixes.xsd!=="http://www.w3.org/2001/XMLSchema#")throw{name:"InvalidFormat",message:'The XSD prefix MUST have the value "http://www.w3.org/2001/XMLSchema#"'};
+}else if(h.prefixes)throw{name:"InvalidFormat",message:"Prefixes are invalid in JTM 1.0: "+h.version};if(!this.prefixes.xsd)this.prefixes.xsd="http://www.w3.org/2001/XMLSchema#";if(!h.item_type)throw{name:"InvalidFormat",message:"Missing item_type"};switch(h.item_type.toLowerCase()){case "topicmap":h=this.parseTopicMap(h);break;case "topic":h=this.parseTopic(h);break;case "name":h=this.parseName(g,h);break;case "variant":h=this.parseVariant(g,h);break;case "occurrence":h=this.parseOccurrence(g,h);
+break;case "association":h=this.parseAssociation(h);break;case "role":h=this.parseRole(g,h);break;default:throw{name:"InvalidFormat",message:"Unknown item_type property"};}return h};n.prototype.parseParentAsTopic=function(h){var g=null,e,f;if(h.parent){if(!(h.parent instanceof Array)||h.parent.length===0)throw{name:"InvalidFormat",message:"Missing parent topic reference in occurrence"};}else g=this.tm.createTopic();if(h.parent)for(f=0;f<h.parent.length;f+=1){e=this.getTopicByReference(h.parent[f]);
+if(g)g.mergeIn(e);else g=e}return g};n.prototype.parseTopicMap=function(h){var g,e,f;this.parseItemIdentifiers(this.tm,h.item_identifiers);this.parseReifier(this.tm,h.reifier);if(h.topics&&typeof h.topics==="object"&&h.topics instanceof Array){f=h.topics;e=f.length;for(g=0;g<e;g+=1)this.parseTopic(f[g])}if(h.associations&&typeof h.associations==="object"&&h.associations instanceof Array){f=h.associations;e=f.length;for(g=0;g<e;g+=1)this.parseAssociation(f[g])}this.tm.sanitize();return true};n.prototype.parseTopic=
+function(h){var g=this,e=null,f,i,l,m;f=function(o,t,u,p,D,x){var A,B,v;if(u&&typeof u==="object"&&u instanceof Array){B=u.length;for(A=0;A<B;A+=1){l=decodeURI(g.curieToLocator(u[A]));if(t)if((v=p.apply(o,[o.createLocator(l)]))&&v.isTopic()&&!t.equals(v))t.mergeIn(v);else v&&v.isTopic()&&t.equals(v)||t[x](o.createLocator(l));else t=D.apply(o,[o.createLocator(l)])}}return t};e=f(this.tm,e,h.subject_identifiers,this.tm.getTopicBySubjectIdentifier,this.tm.createTopicBySubjectIdentifier,"addSubjectIdentifier");
+e=f(this.tm,e,h.subject_locators,this.tm.getTopicBySubjectLocator,this.tm.createTopicBySubjectLocator,"addSubjectLocator");e=f(this.tm,e,h.item_identifiers,this.tm.getConstructByItemIdentifier,this.tm.createTopicByItemIdentifier,"addItemIdentifier");if((f=h.instance_of)&&this.version==="1.1")for(i=0;i<f.length;i+=1){m=this.getTopicByReference(f[i]);e.addType(m)}else if(h.instance_of&&this.version==="1.0")throw{name:"InvalidFormat",message:"instance_of is invalid in JTM 1.0"};if((f=h.names)&&typeof f===
+"object"&&f instanceof Array)for(i=0;i<f.length;i+=1)this.parseName(e,f[i]);if((f=h.occurrences)&&typeof f==="object"&&f instanceof Array)for(i=0;i<f.length;i+=1)this.parseOccurrence(e,f[i])};n.prototype.parseName=function(h,g){var e,f;h||(h=this.parseParentAsTopic(g));f=this.parseScope(g.scope);e=this.getTopicByReference(g.type);h=h.createName(g.value,e,f);if((e=g.variants)&&typeof e==="object"&&e instanceof Array)for(f=0;f<e.length;f+=1)this.parseVariant(h,e[f]);this.parseItemIdentifiers(h,g.item_identifiers);
+this.parseReifier(h,g.reifier)};n.prototype.parseVariant=function(h,g){var e;e=this.parseScope(g.scope);h=h.createVariant(g.value,g.datatype?this.tm.createLocator(this.curieToLocator(g.datatype)):this.defaultDatatype,e);this.parseItemIdentifiers(h,g.item_identifiers);this.parseReifier(h,g.reifier)};n.prototype.parseOccurrence=function(h,g){var e,f;h||(h=this.parseParentAsTopic(g));f=this.parseScope(g.scope);e=this.getTopicByReference(g.type);h=h.createOccurrence(e,g.value,g.datatype?this.tm.createLocator(this.curieToLocator(g.datatype)):
+this.defaultDatatype,f);this.parseItemIdentifiers(h,g.item_identifiers);this.parseReifier(h,g.reifier)};n.prototype.parseAssociation=function(h){var g,e,f;g=this.parseScope(h.scope);g=this.tm.createAssociation(this.getTopicByReference(h.type),g);if((e=h.roles)&&typeof e==="object"&&e instanceof Array){if(e.length===0)throw{name:"InvalidFormat",message:"Association needs roles"};for(f=0;f<e.length;f+=1)this.parseRole(g,e[f])}else throw{name:"InvalidFormat",message:"Association needs roles"};this.parseItemIdentifiers(g,
+h.item_identifiers);this.parseReifier(g,h.reifier)};n.prototype.parseRole=function(h,g){var e,f;e=this.getTopicByReference(g.type);f=this.getTopicByReference(g.player);h=h.createRole(e,f);this.parseItemIdentifiers(h,g.item_identifiers);this.parseReifier(h,g.reifier)};n.prototype.parseScope=function(h){var g,e=[];if(h&&typeof h==="object"&&h instanceof Array)for(g=0;g<h.length;g+=1)e.push(this.getTopicByReference(h[g]));return e};n.prototype.parseItemIdentifiers=function(h,g){var e,f,i;f=h.getTopicMap();
+if(g&&typeof g==="object"&&g instanceof Array)for(e=0;e<g.length;e+=1){i=this.curieToLocator(g[e]);f.getConstructByItemIdentifier(f.createLocator(i))||h.addItemIdentifier(f.createLocator(i))}};n.prototype.parseReifier=function(h,g){if((g=this.getTopicByReference(g))&&g.getReified()===null||!g)h.setReifier(g)};C=function(h){var g=this,e;this.defaultDatatype=TM.XSD.string;this.prefixes=new TM.Hash;this.version=h||"1.0";e=function(f){var i,l,m,o;if(g.version==="1.0")return f;l=g.prefixes.keys();for(m=
+0;m<l.length;m+=1){i=l[m];o=g.prefixes.get(i);if(f.substring(0,o.length)===o)return"["+i+":"+f.substr(o.length)+"]"}return f};this.setPrefixes=function(f){var i;for(i in f)f.hasOwnProperty(i)&&this.prefixes.put(i,f[i])};this.getTopicReference=function(f){var i;i=f.getSubjectIdentifiers();if(i.length>0)return"si:"+e(i[0].getReference());i=f.getSubjectLocators();if(i.length>0)return"sl:"+e(i[0].getReference());i=f.getItemIdentifiers();if(i.length>0)return"ii:"+e(i[0].getReference())};this.exportIdentifiers=
+function(f,i,l){var m,o=i.length;if(o>0){f[l]=[];for(m=0;m<o;m+=1)f[l].push(e(i[m].getReference()))}};this.exportScope=function(f,i){var l=i.getScope();if(l.length>0){f.scope=[];for(i=0;i<l.length;i+=1)f.scope.push(g.getTopicReference(l[i]))}};this.exportParent=function(f,i){i=i.getParent();g.exportIdentifiers(f,i.getItemIdentifiers(),"parent")};this.exportTopicMap=function(f){var i,l,m,o;o={topics:[],associations:[]};i=f.getTopics();m=i.length;for(l=0;l<m;l+=1)o.topics.push(g.exportTopic(i[l]));
+i=f.getAssociations();m=i.length;for(l=0;l<m;l+=1)o.associations.push(g.exportAssociation(i[l]));return o};this.exportTopic=function(f){var i,l,m,o;o={};g.exportIdentifiers(o,f.getSubjectIdentifiers(),"subject_identifiers");g.exportIdentifiers(o,f.getSubjectLocators(),"subject_locators");g.exportIdentifiers(o,f.getItemIdentifiers(),"item_identifiers");i=f.getNames();m=i.length;if(m>0){o.names=[];for(l=0;l<m;l+=1)o.names.push(g.exportName(i[l]))}i=f.getOccurrences();m=i.length;if(m>0){o.occurrences=
+[];for(l=0;l<m;l+=1)o.occurrences.push(g.exportOccurrence(i[l]))}i=f.getTypes();m=i.length;if(m>0){o.instance_of=[];for(l=0;l<m;l+=1)o.instance_of.push(g.getTopicReference(i[l]))}return o};this.exportName=function(f){var i,l,m;m={value:f.getValue()};if(i=f.getType())m.type=g.getTopicReference(i);if(i=f.getReifier())m.reifier=g.getTopicReference(i);g.exportIdentifiers(m,f.getItemIdentifiers(),"item_identifiers");g.exportScope(m,f);f=f.getVariants();l=f.length;if(l>0){m.variants=[];for(i=0;i<l;i+=1)m.variants.push(g.exportVariant(f[i]))}return m};
+this.exportVariant=function(f){var i,l;i={value:f.getValue()};if((l=f.getDatatype())&&l!==f.getTopicMap().createLocator(g.defaultDatatype))i.datatype=e(l.getReference());if(l=f.getReifier())i.reifier=g.getTopicReference(l);g.exportIdentifiers(i,f.getItemIdentifiers(),"item_identifiers");g.exportScope(i,f)};this.exportOccurrence=function(f){var i,l;i={value:f.getValue(),type:g.getTopicReference(f.getType())};if((l=f.getDatatype())&&l!==f.getTopicMap().createLocator(g.defaultDatatype))i.datatype=e(l.getReference());
+if(l=f.getReifier())i.reifier=g.getTopicReference(l);g.exportIdentifiers(i,f.getItemIdentifiers(),"item_identifiers");g.exportScope(i,f);return i};this.exportAssociation=function(f){var i,l;l={type:g.getTopicReference(f.getType()),roles:[]};if(i=f.getReifier())l.reifier=g.getTopicReference(i);g.exportIdentifiers(l,f.getItemIdentifiers(),"item_identifiers");g.exportScope(l,f);f=f.getRoles();for(i=0;i<f.length;i+=1)l.roles.push(g.exportRole(f[i]));return l};this.exportRole=function(f){var i,l;i={player:g.getTopicReference(f.getPlayer()),
+type:g.getTopicReference(f.getType())};if(l=f.getReifier())i.reifier=g.getTopicReference(l);g.exportIdentifiers(i,f.getItemIdentifiers(),"item_identifiers");return i}};C.prototype.toObject=function(h,g){var e,f,i;g=g||false;h.getTopicMap();if(h.isTopicMap()){e=this.exportTopicMap(h);e.item_type="topicmap"}else if(h.isRole()){e=this.exportRole(h);e.item_type="role"}else if(h.isTopic()){e=this.exportTopic(h);e.item_type="topic"}else if(h.isAssociation()){e=this.exportAssociation(h);e.item_type="association"}else if(h.isOccurrence()){e=
+this.exportOccurrence(h);e.item_type="occurrence"}else if(h.isName()){e=this.exportName(h);e.item_type="name"}else if(h.isVariant()){e=this.exportVariant(h);e.item_type="variant"}e.version=this.version;if(this.version==="1.1"&&this.prefixes)if(this.prefixes.size()){f=this.prefixes.keys();e.prefixes={};for(i=0;i<f.length;i+=1)e.prefixes[f[i]]=this.prefixes.get(f[i])}if(!h.isTopic()&&h.getReifier())e.reifier=this.getTopicReference(h.getReifier());g&&!h.isTopicMap()&&this.exportParent(e,h);return e};
+return{Reader:n,Writer:C}}();
Modified: branches/gdl-frontend/src/rest_interface/set-up-gdl-interface.lisp
==============================================================================
--- branches/gdl-frontend/src/rest_interface/set-up-gdl-interface.lisp Tue Sep 6 23:48:57 2011 (r836)
+++ branches/gdl-frontend/src/rest_interface/set-up-gdl-interface.lisp Tue Sep 6 23:55:07 2011 (r837)
@@ -9,7 +9,7 @@
(in-package :rest-interface)
-(defparameter *base-address* "");"/gdl/")
+(defparameter *base-address* "/");"/gdl/")
(defparameter *get-fragment* (concat *base-address* "fragment/(.+)$"))
(defparameter *get-schema* (concat *base-address* "schema/?$"))
(defparameter *commit-fragment* (concat *base-address* "commit/?"))
More information about the Isidorus-cvs
mailing list