Jump To …

Able.js

src/
VIE - Vienna IKS Editables
(c) 2011 Henri Bergius, IKS Consortium
(c) 2011 Sebastian Germesin, IKS Consortium
(c) 2011 Szaby Gr├╝nwald, IKS Consortium
VIE may be freely distributed under the MIT license.
For all details and documentation:
http://viejs.org/

VIE.Able

VIE implements asynchronius service methods through jQuery.Deferred objects. Loadable, Analysable, Savable, etc. are part of the VIE service API and are implemented with the generic VIE.Able class. Example:

 VIE.prototype.Loadable = function (options) {
     this.init(options,"load");
 };
 VIE.prototype.Loadable.prototype = new VIE.prototype.Able();

This defines

someVIEService.load(options)
.using(...)
.execute()
.success(...)
.fail(...)

which will run the asynchronius load function of the service with the created Loadable object.

VIE.Able()

This is the constructor of a VIE.Able. This should not be called globally but using the inherited classes below. Parameters: nothing Throws: nothing Returns: {VIE.Able} : A new VIE.Able object. Example:

 VIE.prototype.Loadable = function (options) {
     this.init(options,"load");
 };
 VIE.prototype.Loadable.prototype = new VIE.prototype.Able();
VIE.prototype.Able = function(){

init(options, methodName)

Internal method, called during initialization. Parameters: {object} options the able options coming from the API call {string} methodName the service method called on .execute. Throws: nothing Returns: {VIE.Able} : The current instance. Example usage:

 VIE.prototype.Loadable = function (options) {
     this.init(options,"load");
 };
 VIE.prototype.Loadable.prototype = new VIE.prototype.Able();
    this.init = function(options, methodName) {
        this.options = options;
        this.services = options.from || options.using || options.to || [];
        this.vie = options.vie;

        this.methodName = methodName;

Instantiate the deferred object

        this.deferred = jQuery.Deferred();

In order to get more information and documentation about the passed-through deferred methods and their synonyms, please see the documentation of the jQuery.Deferred object

Public deferred-methods

        this.resolve = this.deferred.resolve;
        this.resolveWith = this.deferred.resolveWith;
        this.reject = this.deferred.reject;
        this.rejectWith = this.deferred.rejectWith;
        this.success = this.done = this.deferred.done;
        this.fail = this.deferred.fail;
        this.then = this.deferred.then;
        this.always = this.deferred.always;
        this.from = this.using;
        this.to = this.using;

        return this;
    };

using(services)

This method registers services with the current able instance. Parameters: {string|array} services An id of a service or an array of strings. Throws: nothing Returns: {VIE.Able} : The current instance. Example usage:

var loadable = vie.load({id: "http://example.com/entity/1234"});
able.using("myService");
    this.using = function(services) {
        var self = this;
        services = (_.isArray(services))? services : [ services ];
        _.each (services, function (s) {
            var obj = (typeof s === "string")? self.vie.service(s) : s;
            self.services.push(obj);
        });
        return this;
    };

execute()

This method runs the actual method on all registered services. Parameters: nothing Throws: nothing ... Returns: {VIE.Able} : The current instance. Example usage:

var able = new vie.Able().init();
able.using("stanbol")
.done(function () {alert("finished");})
.execute();
    this.execute = function() {

call service[methodName]

        var able = this;
        _(this.services).each(function(service){
            service[able.methodName](able);
        });
        return this;
    };
};

VIE.Loadable

A VIE.Loadable is a wrapper around the deferred object to load semantic data from a semantic web service.

VIE.prototype.Loadable = function (options) {
    this.init(options,"load");
};
VIE.prototype.Loadable.prototype = new VIE.prototype.Able();

VIE.Savable

A VIE.Savable is a wrapper around the deferred object to save entities by a VIE service. The RDFaService would write the data in the HTML as RDFa, the StanbolService stores the data in its Entityhub, etc.

VIE.prototype.Savable = function(options){
    this.init(options, "save");
};
VIE.prototype.Savable.prototype = new VIE.prototype.Able();

VIE.Removable

A VIE.Removable is a wrapper around the deferred object to remove semantic data from a semantic web service.

VIE.prototype.Removable = function(options){
    this.init(options, "remove");
};
VIE.prototype.Removable.prototype = new VIE.prototype.Able();

VIE.Analyzable

A VIE.Analyzable is a wrapper around the deferred object to analyze data and extract semantic information with the help of a semantic web service.

VIE.prototype.Analyzable = function (options) {
    this.init(options, "analyze");
};
VIE.prototype.Analyzable.prototype = new VIE.prototype.Able();

VIE.Findable

A VIE.Findable is a wrapper around the deferred object to find semantic data on a semantic storage.

VIE.prototype.Findable = function (options) {
    this.init(options, "find");
};
VIE.prototype.Findable.prototype = new VIE.prototype.Able();

generated Wed Dec 05 2012 19:56:06 GMT+0100 (CET)
VIE