Changeset 4357


Ignore:
Timestamp:
01/27/14 19:20:38 (10 years ago)
Author:
sroth
Message:

Added DELETE function for annotations on REST server. Updated POST function.

File:
1 edited

Legend:

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

    r4330 r4357  
    5252            });
    5353        },
    54         postAnnotation: function(annotation) {
     54        deleteAnnotationByOid: function(oid) {
     55            var aid;
     56            var aSql = 'select dasish_aid from om_object where oid="' + oid + '"';
     57            var rtn = bitsObjectMng.Database.selectB("", aSql); // aMode = "" defaults to predefined value; aSql contains sql statement
     58
     59            aid = rtn[0].dasish_aid;
     60
     61            if (aid) { // ajax request only for annotations posted to and available in backend database
     62                return $.ajax({
     63                    url: this.getBackend() + '/api/annotations/' + aid,
     64                    type: 'DELETE',
     65                    error: function(jqXHR, status, thrownError) {
     66                        // Handle any errors
     67                        if (typeof Firebug !== 'undefined' && Firebug.Console) {
     68                            Firebug.Console.log("+ + + + + + + + + + + + + + + + + + + + + + + +");
     69                            Firebug.Console.log("Status Code (DELETE request): " + jqXHR.status);
     70                            Firebug.Console.log("Error DELETE request: " + thrownError);
     71                        }
     72                    },
     73                    success: function(result) {
     74                        if (typeof Firebug !== 'undefined' && Firebug.Console) {
     75                            Firebug.Console.log("DELETE request was successful.");
     76                            Firebug.Console.log(result);
     77                        }
     78                    }
     79                });
     80            }
     81        },
     82        postAnnotation: function(annotation, oid) {
    5583            return $.ajax({
    5684                type: "POST",
     
    73101                    if (typeof Firebug !== 'undefined' && Firebug.Console) {
    74102                        Firebug.Console.log("+ + + + + + + + + + + + + + + + + + + + + + + +");
    75                         Firebug.Console.log("Status Code: " + jqXHR.status);
     103                        Firebug.Console.log("Status Code POST request: " + jqXHR.status);
    76104                        Firebug.Console.log("Response Body: " + jqXHR.responseText);
    77105                        Firebug.Console.log("+ + + + + + + + + + + + + + + + + + + + + + + +");
    78                         Firebug.Console.log("AID: " + aid);
    79106                    }
     107                    // Firebug.Console.log("OID: " + oid);
     108                    // Firebug.Console.log("AID: " + aid);
     109                    // Firebug.Console.log(bitsObjectMng.Database.getObject({oid: oid}));
     110
     111                    var aSql = 'update om_object set dasish_aid = "' + aid + '" where oid="' + oid + '"';
     112                    // 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
     115                    // Database insert request is true if successful
     116                    // Firebug.Console.log(rtn);
     117
    80118                }
    81119            });
Note: See TracChangeset for help on using the changeset viewer.