Changeset 4545


Ignore:
Timestamp:
02/21/14 14:45:20 (10 years ago)
Author:
olof
Message:

base for GET, need to update conversion to OM_OBJECT

Location:
DASISH/t5.6/client/trunk/chrome/markingcollection/content/markingcollection/annotator-service
Files:
3 edited

Legend:

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

    r4357 r4545  
    2020            }
    2121        },
    22         getAnnotations: function(params, callback) {
     22        getAnnotations: function(url, callback) {
     23            annotationProxy.log('calling the annotation backend ');
     24           
    2325            $.ajax({
    2426                type: "GET",
    25                 url: this.getBackend() + '/annotations',
    26                 data: params,
     27                url: this.getBackend() + '/api/annotations?link='+url,
    2728                dataType: "xml",
    28                 success: function(xml) {
     29                beforeSend: function(xhr){xhr.setRequestHeader('Content-Type', 'application/xml');},
     30                success: function(xml, textStatus, jqXHR) {
     31                                   
     32                   
    2933                    var annotations = Array();
    30 
    31                     $xml = $(xml);
    32                     $xml.find('annotation').each(function() {
    33                         var annotation = $.xml2json(this);
    34 
    35                         annotations.push(annotation);
     34                   
     35                    $xml = $.parseXML(jqXHR.responseText);
     36                    annotationProxy.log($xml);
     37                   
     38                    jQuery($xml).find('annotationInfo').each(function() {
     39                        annotationProxy.log(this);
     40                        annotationProxy.log(this.getAttribute('ref'));
     41                       
     42                       
     43                        annotations.push(this.getAttribute('ref'));
    3644                    });
     45                   
    3746
    3847                    callback.call(undefined, annotations);
     48                },
     49                error: function(result){
     50                    annotationProxy.log('ERROR calling the annotation backend '+result);
     51                    Firebug.Console.log(result);
    3952                }
    4053            });
    4154        },
    42         getAnnotation: function(aid, callback) {
     55        getAnnotation: function(annotationURL, callback) {
     56            annotationProxy.log('getAnnotation '+annotationURL);
    4357            $.ajax({
    4458                type: "GET",
    45                 url: this.getBackend() + '/' + aid,
     59                url: annotationURL,
    4660                dataType: "xml",
    47                 success: function(xml) {
    48                     var annotation = $xml.find('annotation');
    49 
    50                     callback.call(undefined, annotation);
     61                success: function(xml, textStatus, jqXHR) {
     62                    $xml = $.parseXML(jqXHR.responseText);
     63                    annotationProxy.log('GOT annotation in getAnnotation ');   
     64                    annotationProxy.log($xml);
     65                    var om_object = annotation2om_object($xml);
     66                   
     67                    callback.call(undefined, om_object);
     68                },
     69                error: function(error) {
     70                    annotationProxy.log('ERROR in getAnnotation ');
     71                    annotationProxy.log(error);
    5172                }
    5273            });
    5374        },
    5475        deleteAnnotationByOid: function(oid) {
     76            Firebug.Console.log('entering DELETE for oid: '+oid);
    5577            var aid;
    5678            var aSql = 'select dasish_aid from om_object where oid="' + oid + '"';
    5779            var rtn = bitsObjectMng.Database.selectB("", aSql); // aMode = "" defaults to predefined value; aSql contains sql statement
    58 
     80           
    5981            aid = rtn[0].dasish_aid;
    60 
     82            Firebug.Console.log('Resolved the AID for DELETE for aid: '+aid);
    6183            if (aid) { // ajax request only for annotations posted to and available in backend database
    6284                return $.ajax({
     
    105127                        Firebug.Console.log("+ + + + + + + + + + + + + + + + + + + + + + + +");
    106128                    }
    107                     // Firebug.Console.log("OID: " + oid);
    108                     // Firebug.Console.log("AID: " + aid);
     129                    Firebug.Console.log("OID: " + oid);
     130                    Firebug.Console.log("AID: " + aid);
    109131                    // Firebug.Console.log(bitsObjectMng.Database.getObject({oid: oid}));
    110132
    111133                    var aSql = 'update om_object set dasish_aid = "' + aid + '" where oid="' + oid + '"';
     134                    Firebug.Console.log(aSql);
    112135                    // insert request to local sqlite database where aid gets inserted
    113                     rtn = bitsObjectMng.Database.cmd("", aSql); // aMode = "" defaults to predefined value; aSql contains sql statement
    114 
     136                    var rtn = bitsObjectMng.Database.cmd("", aSql); // aMode = "" defaults to predefined value; aSql contains sql statement
     137                    Firebug.Console.log('UPDATE of AID done');
     138                    Firebug.Console.log(rtn);
    115139                    // Database insert request is true if successful
    116140                    // Firebug.Console.log(rtn);
  • DASISH/t5.6/client/trunk/chrome/markingcollection/content/markingcollection/annotator-service/annotations.wired.marker.js

    r4544 r4545  
    55
    66
    7              
     7            annotationFramework.getAnnotations(url,
     8                function(annotations){
     9                    annotationProxy.log('got annotations ');
     10                    Firebug.Console.log(annotations);
     11                   
     12                    $.each(annotations, function(index, annotationURL){
     13                       annotationFramework.getAnnotation(annotationURL, function(result){
     14                           annotationProxy.log('got Annotation ');
     15                           annotationProxy.log(result);
     16                       });
     17                    });
     18                }
     19            );
    820
    921            //if (bitsObjectMng.Database.existsObject(tmp, undefined)) {
  • DASISH/t5.6/client/trunk/chrome/markingcollection/content/markingcollection/annotator-service/conversion.utils.js

    r4331 r4545  
    3131    var body = $(annotation).find('body').text().trim();
    3232    var style = $(annotation).find('body').find('xhtml\\:span').attr('style');
    33     var type = $(annotation).find('body').attr('type').toLowerCase();
     33    var type = $(annotation).find('mimeType').text();
    3434    var link = $(annotation).find('link').text();
    35     var time = $(annotation).attr('timeStamp');
     35    var time = $(annotation).find('lastModified').text();
    3636
    3737    var urlParts = link.split("#xpointer");
     
    6666    om_object.oid_property = "<PROPERTY><HYPER_ANCHOR>" + om_object.doc_url + hyperanchor + "</HYPER_ANCHOR><NOTE>" + body + "</NOTE></PROPERTY>";
    6767
    68     if (type === 'note') {
     68    if (type === 'application/xml+xhtml') { //TODO: better handeling of the body
    6969        om_object.oid_txt = body;
    7070        om_object.oid_type = 'text';
Note: See TracChangeset for help on using the changeset viewer.