Changeset 4716 for DASISH


Ignore:
Timestamp:
03/16/14 12:27:31 (10 years ago)
Author:
stephanie.roth@snd.gu.se
Message:

Callback function updates for 401.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • DASISH/t5.6/client/trunk/chrome/markingcollection/content/markingcollection/annotator-service/annotations.wired.marker.js

    r4714 r4716  
    55         * @returns {undefined} false if user in not loged in. user object if loged in
    66         */
    7         getLoggedInInfo: function(){
     7        getLoggedInInfo: function(callback) { 
     8            var authURL = annotationFramework.getBackend() + "/api/authentication/user";
     9            $.ajax({
     10                type: 'GET',
     11                url: authURL,
     12                dataType: "xml",
     13                success: function(xml ,textStatus, jqXHR) {
     14                   $xml = $.parseXML(jqXHR.responseText);
     15                   // alert(JSON.stringify($xml));
     16                },
     17                error: function(jqXHR, status, thrownError) {
     18                    // alert("statusCode in ajax error method: " + jqXHR.status);
     19                    callback.call(undefined, jqXHR.status);
     20                }
     21            });
     22           
    823            var user_placeholder = {
    9                 URI : 'https://lux17.mpi.nl/ds/webannotator/api/users/00000000-0000-0000-0000-0000000009999',
    10                 uid : '00000000-0000-0000-0000-0000000009999',
    11                 dislayName : 'Test Testsson',
    12                 eMail : 'test@test.com'
    13             };
    14            
     24                URI: 'https://lux17.mpi.nl/ds/webannotator/api/users/00000000-0000-0000-0000-0000000009999',
     25                uid: '00000000-0000-0000-0000-0000000009999',
     26                dislayName: 'Test Testsson',
     27                eMail: 'test@test.com'
     28            }; 
     29
    1530            return user_placeholder;
    1631        },
     
    1833            annotationProxy.log('getAnnotations for: ' + url);
    1934
    20             annotationFramework.getAnnotations(url, 
    21                 function(annotations){
    22                     annotationProxy.log('got annotations ');
    23                     annotationProxy.log(annotations);
    24                    
    25                     $.each(annotations, function(index, annotationURL){
    26                        annotationFramework.getAnnotation(annotationURL, function(result){
    27                            annotationProxy.log('checking if annotation exist in DB:');
    28                            annotationProxy.log(result);
    29                            if(bitsObjectMng.Database._dasish_aid_exists('', result.dasish_aid, true)){
    30                                 annotationProxy.log('AID already in database : ' + result.dasish_aid);
    31                             }else{
    32                                 annotationProxy.log('Adding annotation to database : ' + result.dasish_aid);
    33                                 bitsObjectMng.Database.addObject(result, '', undefined); 
    34                             }   
    35                        });
    36                     });
    37                 }
     35            annotationFramework.getAnnotations(url,
     36                    function(annotations) {
     37                        annotationProxy.log('got annotations ');
     38                        annotationProxy.log(annotations);
     39
     40                        $.each(annotations, function(index, annotationURL) {
     41                            annotationFramework.getAnnotation(annotationURL, function(result) {
     42                                annotationProxy.log('checking if annotation exist in DB:');
     43                                annotationProxy.log(result);
     44                                if (bitsObjectMng.Database._dasish_aid_exists('', result.dasish_aid, true)) {
     45                                    annotationProxy.log('AID already in database : ' + result.dasish_aid);
     46                                } else {
     47                                    annotationProxy.log('Adding annotation to database : ' + result.dasish_aid);
     48                                    bitsObjectMng.Database.addObject(result, '', undefined);
     49                                }
     50                            });
     51                        });
     52                    }
    3853            );
    3954
     
    91106            var aid = this.getAidFromOid(om_object.oid);
    92107            this.log('updateAnnotation : ' + JSON.stringify(om_object));
    93             this.log('UPDATED ANNOTATION AS XML (aid: '+aid+')');
     108            this.log('UPDATED ANNOTATION AS XML (aid: ' + aid + ')');
    94109            var xml = om_object_annotation_body(om_object);
    95            
     110
    96111            this.log(xml);
    97            
     112
    98113            annotationFramework.putAnnotation(aid, xml);
    99114        },
    100         getAidFromOid: function(oid){
     115        getAidFromOid: function(oid) {
    101116            var aSql = 'SELECT dasish_aid FROM om_object WHERE oid="' + oid + '"';
    102117            var rtn = bitsObjectMng.Database.selectB('_uncategorized', aSql); // aMode = "" defaults to predefined value; aSql contains sql statement
    103            
     118
    104119            return rtn[0].dasish_aid;
    105120        },
     
    112127        log: function(message) {
    113128            //log to console
    114             if (typeof Firebug!='undefined' && Firebug.Console) {
     129            if (typeof Firebug != 'undefined' && Firebug.Console) {
    115130                Firebug.Console.log(message);
    116131            }
    117132            //log this to the local proxy
    118133            /*
    119             $.ajax({
    120                 type: "POST",
    121                 url: 'http://localhost/annotations/annotator-service/test/proxy.php',
    122                 data: {log: 'true', message: message}
    123             });
    124             */
     134             $.ajax({
     135             type: "POST",
     136             url: 'http://localhost/annotations/annotator-service/test/proxy.php',
     137             data: {log: 'true', message: message}
     138             });
     139             */
    125140        }
    126141    }
Note: See TracChangeset for help on using the changeset viewer.