Changeset 44


Ignore:
Timestamp:
06/16/09 12:17:10 (16 years ago)
Author:
lgiessmann
Message:

ajax-client: a fragment commit without validation is implemented; json-importer: to import a topic or a topicStub it is necessary to define a psi for this element - this is difference between the xtm-importer \(there must be one of the elements psi, itemidentity, subjectlocator defined\), because all topics are referenced via psis and not topicid\'s

Location:
trunk/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified trunk/src/ajax/javascripts/create.js

    r43 r44  
    3737                }
    3838
     39                items = $$("li." + CLASSES.tmIdFrame());
     40                for(var i = 0; i !== items.length; ++i){
     41                    items[i].remove();
     42                }
     43
    3944                items = $$("li." + CLASSES.commitButton());
    4045                for(var i = 0; i !== items.length; ++i){
     
    5055                context.insert({"after" : liT});
    5156
    52                 addTopicAsPlayer((constraints ? constraints.associationsConstraints : null), topic.getContent().instanceOfs);
    53                 var associations = new AssociationContainerC(null, (constraints ? constraints.associationsConstraints : null));
    54                 var liA = new Element("li", {"class" : CLASSES.associationContainer()}).update(associations.getFrame());
    55                 liT.insert({"after" : liA});
     57                var liA = null;
     58                var associations = null;
     59                if(constraints && constraints.associationsConstraints && constraints.associationsConstraints.length !== 0){
     60                    addTopicAsPlayer((constraints ? constraints.associationsConstraints : null), topic.getContent().instanceOfs);
     61                    associations = new AssociationContainerC(null, (constraints ? constraints.associationsConstraints : null));
     62                    liA = new Element("li", {"class" : CLASSES.associationContainer()}).update(associations.getFrame());
     63                    liT.insert({"after" : liA});
     64                }
     65                else {
     66                    liA = liT;
     67                }
    5668
    5769                var tmId = new tmIdC(null);
     
    6173                var commitButton = new Element("input", {"type" : "button", "value" : "commit fragment", "style" : "float: right; margin-top: -10px;"})
    6274                commitButton.observe("click", function(event){
    63                     try{
    6475                    var tPsis = topic.getContent().subjectIdentifiers;
    65                     var referencedTopics = topic.getReferencedTopics().concat(associations.getReferencedTopics()).without(CURRENT_TOPIC).uniq();
    66 
     76                    var referencedTopics = topic.getReferencedTopics();
     77                    if(associations){
     78                        referencedTopics = referencedTopics.concat(associations.getReferencedTopics()).without(CURRENT_TOPIC).uniq();
     79                    }
     80                   
    6781                    function onSuccessHandler(topicStubs){
    6882                        var tsStr = "null";
     
    7791                        var jTopic = "\"topic\":" + topic.toJSON();
    7892                        var jTopicStubs = "\"topicStubs\":" + tsStr;
    79                         var jAssociations = "\"associations\":" + associations.toJSON().gsub(CURRENT_TOPIC_ESCAPED, tPsis)
     93                        var jAssociations = "\"associations\":" + (associations ? associations.toJSON().gsub(CURRENT_TOPIC_ESCAPED, tPsis) : "null");
    8094                        var jTmId = "\"tmIds\":" + tmId.toJSON();
    8195                        var json = "{" + jTopic + "," + jTopicStubs + "," + jAssociations + "," + jTmId + "}";
    82                         alert(json);
     96                        commitFragment(json, function(xhr){ alert("The fragment was committed succesfully!"); }, null);
    8397                    }
    84 
     98                   
    8599                    function onErrorHandler(){
    86                         // --- currently there is not neede a special handling for errors
     100                        // --- currently there is not needed a special handling for errors
    87101                        // --- occurred during this operation
    88102                    }
    89 
     103                   
    90104                    getTopicStubs(referencedTopics, onSuccessHandler, onErrorHandler);
    91                     }catch(err){ alert("test: " + err); }
    92105                });
    93106                var liCB = new Element("li", {"class" : CLASSES.commitButton()});
  • TabularUnified trunk/src/ajax/javascripts/datamodel.js

    r43 r44  
    651651                                               return new Array();
    652652                                           }
     653
     654                                           for(var i = 0; i !== values.length; ++i)
     655                                               values[i] = new Array(values[i]);
    653656                                           return values;
    654657                                       },
     
    14871490                                                   if(scopes){
    14881491                                                       for(var j = 0; j !== scopes.length; ++j){
    1489                                                            if(referencedTopics.indexOf(scopes[j]) === -1) referencedTopics.push(scopes[j]);
     1492                                                           if(referencedTopics.indexOf(scopes[j][0]) === -1) referencedTopics.push(scopes[j][0]);
    14901493                                                       }
    14911494                                                   }
     
    15031506                                                   if(scopes){
    15041507                                                       for(var j = 0; j !== scopes.length; ++j){
    1505                                                            if(referencedTopics.indexOf(scopes[j]) === -1) referencedTopics.push(scopes[j]);
     1508                                                           if(referencedTopics.indexOf(scopes[j][0]) === -1) referencedTopics.push(scopes[j][0]);
    15061509                                                       }
    15071510                                                   }
     
    24622465                                                                  if(scopes){
    24632466                                                                      for(var j = 0; j !== scopes.length; ++j){
    2464                                                                           if(referencedTopics.indexOf(scopes[j]) === -1) referencedTopics.push(scopes[j]);
     2467                                                                          if(referencedTopics.indexOf(scopes[j][0]) === -1) referencedTopics.push(scopes[j][0]);
    24652468                                                                      }
    24662469                                                                  }
  • TabularUnified trunk/src/ajax/javascripts/requests.js

    r42 r44  
    9090            var delta = 100;
    9191            neededTime += delta;
    92             if(delta > maxTimeout){
     92            if(delta > maxTimeout && psis && psis.length !== 0){
    9393                alert("From getTopicStubs(): Please check your network-connection - the request timed out!!!");
    9494                onFailureHandler();
     
    107107    }
    108108}
     109
     110
     111function commitFragment(json, onSuccessHandler, onFailureHandler)
     112{
     113    if(!json || !onSuccessHandler) throw "From commitFragment(): json and onSuccessHandler must be set!";
     114    try{
     115        var onFailure = onFailureHandler ? onFailureHandler : defaultFailureHandler;
     116       
     117        new Ajax.Request(COMMIT_URL, {
     118            "method" : "post",
     119            "postBody" : json,
     120            "onSuccess" : onSuccessHandler,
     121            "onFailure" : onFailure});
     122    }
     123    catch(err){
     124        alert("From commitFragment(): " + err);
     125    }
     126}
  • TabularUnified trunk/src/json/json_importer.lisp

    r26 r44  
    392392               (error "json-importer:get-topicStub-values-from-json-string:
    393393                       bad item-specifier found in json-list"))))
    394        (unless (or itemIdentities subjectLocators subjectIdentifiers)
    395         (error "json-importer:get-topicStub-values-from-json-string: one of the elements
    396                   itemIdentity, sbjectLocator or subjectIdentifier must be set"))
     394       (unless subjectIdentifiers
     395        (error "json-importer:get-topicStub-values-from-json-string: the element subjectIdentifiers mus be set!"))
    397396      (unless id
    398397        (error "json-importer:get-topic-valuesStub-from-json-string: the element id must be set"))
     
    434433               (error "json-importer:get-topic-values-from-json-string:
    435434                       bad item-specifier found in json-list ~a" (car j-elem)))))
    436       (unless (or itemIdentities subjectLocators subjectIdentifiers)
    437         (error "json-importer:get-topic-values-from-json-string: one of the elements
    438                   itemIdentity, sbjectLocator or subjectIdentifier must be set"))
     435      (unless subjectIdentifiers
     436        (error "json-importer:get-topic-values-from-json-string: the element subjectIdentifiers must be set!"))
    439437      (unless id
    440438        (error "json-importer:get-topic-values-from-json-string: the element id must be set"))
Note: See TracChangeset for help on using the changeset viewer.