Class: Resource

Resource

new Resource()

Generic class that is inherited in other classes to load, save and manage data.
Properties:
Name Type Description
url String The url used for requests and posts
object object Holds the information as is returned by the server
id String The id asociated with the an instance of Resource
xml String A string representation of the xml to be posted to the server
categories Array an array representing the category tag of a returned request
entries Array an array representing the entries tag of a returned request
links Array an array representing the links tag of a returned request
rights String the rights asociated with an instance of resource
selfUrl String The url asociated with an instance of Resource
contentType String the expected return content of a request ("json" or "xml")
pagination String a string that holds the pagination structure to me added to the url
hasNext Boolean boolean
hasPrevious Boolean a string that holds the pagination structure to me added to the
filters Array a list of filters
defaultFilters Array a list of filters that are set as default
version String the version for server resources
orderBy Array a list of orderBy objects FE: [{orderBy:orderBy1,order:order1},{orderBy:orderBy2,order:order2}]
mode String The request mode
parameters Array additional parameters that may be added to the request
Source:

Methods

<static> decodeBase64(s) → {String}

returns the base 64 decoded string
Parameters:
Name Type Description
s String The base 64 string
Source:
Returns:
Decoded string
Type
String

<static> encodeBase64(input) → {String}

returns the base 64 encoded string
Parameters:
Name Type Description
input String The string to encode.
Source:
Returns:
encoded string
Type
String
returns the object containing the link searched
Parameters:
Name Type Description
needle String The searched term
haystack Array The values to be searched
Source:
Returns:
string representation of the link url
Type
String

<static> findLinkObject(needle, haystack) → {Object}

returns the object containing the term searched
Parameters:
Name Type Description
needle String The searched term
haystack Array The values to be searched
Source:
Returns:
Object found
Type
Object

<static> findTerm(needle, haystack) → {Object}

returns the object containing the term searched
Parameters:
Name Type Description
needle String The searched term
haystack Array The values to be searched
Source:
Returns:
Object found
Type
Object

<static> removeDecimalsFromDateString() → {String}

Remove date decimals
Source:
Returns:
string date without decimals
Type
String

<static> removeEscNotation(input) → {String}

removes the u0000 escape notation from string
Parameters:
Name Type Description
input String The string to clean.
Source:
Returns:
clean string
Type
String

addFilter(options)

adds a filter to the stack
Parameters:
Name Type Description
options object an object with the following parameters
Properties
Name Type Description
filter String the name of the filter to be used
operator String the filter's operator
value String the value of the filter
Source:

ajaxLoad(options)

Gets json values without a standard xml Resource structure
Parameters:
Name Type Description
options object options to be used during the call
Properties
Name Type Argument Description
onSuccess Resource~onSuccess a callback function called in case of a success
onFailure Resource~onFailure <optional>
a callback function called in case of a failure
baseUrl String <optional>
base URL. If not set the current base URL will be used
Source:

clearFilters()

Clears the filter array
Source:

dataLoad(options)

Requests json values with the standard xml Resource structure. Will run context.init() if the context is not loaded
Parameters:
Name Type Description
options object options to be used during the call
Properties
Name Type Argument Description
onSuccess Resource~onSuccess a callback function called in case of a success
onFailure Resource~onFailure <optional>
a callback function called in case of a failure
baseUrl String <optional>
base URL. If not set the current base URL will be used
Source:

dataLoader(options)

Places Ajax request to the server with the defined url
Parameters:
Name Type Description
options object options to be used during the call
Properties
Name Type Argument Description
onSuccess Resource~onSuccess a callback function called in case of a success
onFailure Resource~onFailure <optional>
a callback function called in case of a failure
baseUrl String <optional>
base URL. If not set the current base URL will be used
Source:

dataLoaderOffline(options)

Parameters:
Name Type Description
options object options to be used during the call
Properties
Name Type Argument Description
onSuccess Resource~onSuccess a callback function called in case of a success
onFailure Resource~onFailure <optional>
a callback function called in case of a failure
cachedCallback Resource~cachedCallback <optional>
a callback function that returns the cached data
baseUrl String <optional>
base URL. If not set the current base URL will be used
Deprecated:
  • Places Ajax request to the server with the defined url with Offline capabilities
    Source:

    dataPost(options)

    Places Ajax request to the server as Put, Delete or Post
    Parameters:
    Name Type Description
    options object options to be used during the call
    Properties
    Name Type Argument Description
    onSuccess Resource~onSuccess a callback function called in case of a success
    onFailure Resource~onFailure <optional>
    a callback function called in case of a failure
    baseUrl String <optional>
    base URL. If not set the current base URL will be used
    method String method of request (PUT, DELETE or POST)
    xml String xml string to be posted to the server
    Source:

    decode_base64(s) → {String}

    DEPRECATED returns the base 64 decoded string
    Parameters:
    Name Type Description
    s String The base 64 string
    Deprecated:
    • since version 1.5
      Source:
      Returns:
      Decoded string
      Type
      String

      deletePreset()

      Runs before Delete request
      Source:

      encode_base64(input) → {String}

      DEPRECATED returns the base 64 encoded string
      Parameters:
      Name Type Description
      input String The string to encode.
      Deprecated:
      • since version 1.5
        Source:
        Returns:
        encoded string
        Type
        String

        encodeHTML(text) → {String}

        encode to HTML string for special characters
        Parameters:
        Name Type Description
        text String The html string to transform
        Source:
        Returns:
        the transformed html
        Type
        String
        returns an array of all "link" object list found in an array
        Parameters:
        Name Type Description
        entries Array Array containing all entries
        Source:
        Returns:
        Array of links
        Type
        Array

        errorManager(options)

        Manages errors and failures during the run process.
        Parameters:
        Name Type Description
        options object options to be used during the call
        Properties
        Name Type Argument Description
        eObject Object error object
        message String <optional>
        error message
        onFailure Resource~onFailure <optional>
        a callback function called in case of a failure
        Source:

        flatPoolTree(lArray) → {Array}

        returns an array of all "link" object list found in an array
        Parameters:
        Name Type Description
        lArray Array array of Values
        Source:
        Returns:
        flattened array
        Type
        Array

        generate_xml() → {String}

        Runs to generate a Post xml for saving or updating a registry
        Source:
        Returns:
        xml - string to be posted
        Type
        String

        generateFilterStr()

        Generates the filter string to be posted to the server
        Source:

        generateModeStr()

        Generates the Mode string for the request Url
        Source:

        generateOrderByStr()

        Generates the orderBy string for the request Url
        Source:

        generatePaginationStr()

        Generates the pagination string for the request Url
        Source:

        generateParametersStr()

        Generates the parameters string for the request Url
        Source:

        generateUrl() → {String}

        Runs to retrieve the url before a request
        Source:
        Returns:
        url - for request
        Type
        String

        getArray(my_father, my_son) → {Array}

        returns an array from a object list
        Parameters:
        Name Type Description
        my_father Object object where the list is located
        my_son String searched list
        Source:
        Returns:
        Array of registries
        Type
        Array

        getUrlAggregates() → {String}

        Runs to retrieve the url filters and pagination
        Source:
        Returns:
        string to agregate to url
        Type
        String

        idSearch(needle, haystack) → {Object}

        returns the object containing the id searched
        Parameters:
        Name Type Description
        needle String The searched term
        haystack Array The values to be searched
        Source:
        Returns:
        Object found
        Type
        Object

        jsonDataPost(options)

        Places Ajax request to the server as Put, Delete or Post for JSON objects
        Parameters:
        Name Type Description
        options object options to be used during the call
        Properties
        Name Type Argument Description
        onSuccess Resource~onSuccess a callback function called in case of a success
        onFailure Resource~onFailure <optional>
        a callback function called in case of a failure
        baseUrl String <optional>
        base URL. If not set the current base URL will be used
        method String method of request (PUT, DELETE or POST)
        xml String xml string to be posted to the server
        Source:

        JSONLoad(options)

        Loads a resource setting JSON variables from v2 values
        Parameters:
        Name Type Description
        options object options to be used during the call
        Properties
        Name Type Argument Description
        onSuccess Resource~onSuccess a callback function called in case of a success
        onFailure Resource~onFailure <optional>
        a callback function called in case of a failure
        baseUrl String <optional>
        base URL. If not set the current base URL will be used
        Source:

        linkObjectSearch(needle, haystack) → {Object}

        returns the object containing the term searched
        Parameters:
        Name Type Description
        needle String The searched term
        haystack Array The values to be searched
        Deprecated:
        • Yes
        Source:
        Returns:
        Object found
        Type
        Object

        linkSearch(needle, haystack) → {String}

        returns the object containing the link searched
        Parameters:
        Name Type Description
        needle String The searched term
        haystack Array The values to be searched
        Deprecated:
        • Yes
        Source:
        Returns:
        string representation of the link url
        Type
        String

        load(options)

        Requests json values with the standard xml Resource structure and sets the generic variable values
        Parameters:
        Name Type Description
        options object options to be used during the call
        Properties
        Name Type Argument Description
        onSuccess Resource~onSuccess a callback function called in case of a success
        onFailure Resource~onFailure <optional>
        a callback function called in case of a failure
        baseUrl String <optional>
        base URL. If not set the current base URL will be used
        pagination Object <optional>
        an Object with pagination variables (nb and first)
        Source:
        Example
        Load Resource
        	var r = new Resource();
        	r.load({
        		onSuccess:function(){
        			alert("Resource loaded!");
        		}
        	});

        loadNext(options)

        Gets json values with the standard xml Resource prom the next page in pagination
        Parameters:
        Name Type Description
        options object options to be used during the call
        Properties
        Name Type Argument Description
        onSuccess Resource~onSuccess a callback function called in case of a success
        onFailure Resource~onFailure <optional>
        a callback function called in case of a failure
        baseUrl String <optional>
        base URL. If not set the current base URL will be used
        Source:

        loadPreset()

        Runs before Get request
        Source:

        loadPrevious(options)

        Gets json values with the standard xml Resource prom the previous page in pagination
        Parameters:
        Name Type Description
        options object options to be used during the call
        Properties
        Name Type Argument Description
        onSuccess Resource~onSuccess a callback function called in case of a success
        onFailure Resource~onFailure <optional>
        a callback function called in case of a failure
        baseUrl String <optional>
        base URL. If not set the current base URL will be used
        Source:

        loadSet(dataObject)

        Runs after sucessful Post
        Parameters:
        Name Type Description
        dataObject Object success callback function
        Source:

        noLoadSave(options)

        Save/Posts data loaded in the xml variable of the Resource constructor without loading any data to the resource
        Parameters:
        Name Type Description
        options object options to be used during the call
        Properties
        Name Type Argument Description
        onSuccess Resource~onSuccess a callback function called in case of a success
        onFailure Resource~onFailure <optional>
        a callback function called in case of a failure
        baseUrl String <optional>
        base URL. If not set the current base URL will be used
        Source:

        padzero(n) → {Number}

        Pads to 0 the int values
        Parameters:
        Name Type Description
        n Number the number to pad
        Source:
        Returns:
        the padded number
        Type
        Number

        reconstructedLinkSearch(needle, haystack) → {String}

        returns the object containing the link searched with url reconstruction
        Parameters:
        Name Type Description
        needle String The searched term
        haystack Array The values to be searched
        Source:
        Returns:
        string representation of the link url
        Type
        String

        reconstructUrl(url)

        Generates a URL without pagination or filters and generates Resource Filters and Pagination
        Parameters:
        Name Type Description
        url String the url to reconstruct
        Source:

        remove(options)

        Calls post funtions to soft delete an existing registry
        Parameters:
        Name Type Description
        options object options to be used during the call
        Properties
        Name Type Argument Description
        onSuccess Resource~onSuccess a callback function called in case of a success
        onFailure Resource~onFailure <optional>
        a callback function called in case of a failure
        baseUrl String <optional>
        base URL. If not set the current base URL will be used
        Source:

        removeFilter(key)

        Finds and removes a filter from the stack
        Parameters:
        Name Type Description
        key String the filter to be removed
        Source:

        removeUnicodeEscNotation(input) → {String}

        removes the u0000 escape notation from string
        Parameters:
        Name Type Description
        input String The string to clean.
        Source:
        Returns:
        clean string
        Type
        String

        resourceSave(options)

        Save/Posts data loaded in the xml variable of the Resource constructor
        Parameters:
        Name Type Description
        options object options to be used during the call
        Properties
        Name Type Argument Description
        onSuccess Resource~onSuccess a callback function called in case of a success
        onFailure Resource~onFailure <optional>
        a callback function called in case of a failure
        baseUrl String <optional>
        base URL. If not set the current base URL will be used
        Source:

        resourceUpdate(options)

        Calls post funtions to update an existing registry data loaded in the xml variable
        Parameters:
        Name Type Description
        options object options to be used during the call
        Properties
        Name Type Argument Description
        onSuccess Resource~onSuccess a callback function called in case of a success
        onFailure Resource~onFailure <optional>
        a callback function called in case of a failure
        baseUrl String <optional>
        base URL. If not set the current base URL will be used
        Source:

        save(options)

        If not overritten, it calls the resourceSave function to save/post data
        Parameters:
        Name Type Description
        options object options to be used during the call
        Properties
        Name Type Argument Description
        onSuccess Resource~onSuccess a callback function called in case of a success
        onFailure Resource~onFailure <optional>
        a callback function called in case of a failure
        baseUrl String <optional>
        base URL. If not set the current base URL will be used
        Source:

        savePreset()

        Runs before Post request to create a registry
        Source:

        saveSet()

        Runs after Post request to create a registry
        Source:

        sort_unique(arr) → {Array}

        Sorts array and removes duplicated values
        Parameters:
        Name Type Description
        arr Array The unsorted array
        Source:
        Returns:
        Sorted array with no duplicate values
        Type
        Array

        straightLoad(options)

        Loads a resource without setting any variables values
        Parameters:
        Name Type Description
        options object options to be used during the call
        Properties
        Name Type Argument Description
        onSuccess Resource~onSuccess a callback function called in case of a success
        onFailure Resource~onFailure <optional>
        a callback function called in case of a failure
        baseUrl String <optional>
        base URL. If not set the current base URL will be used
        Source:

        stringtoXML(text) → {XMLDOM}

        Correctly transforms a string to an xml document
        Parameters:
        Name Type Description
        text String The xml string to transform
        Source:
        Returns:
        a xml document
        Type
        XMLDOM

        termSearch(needle, haystack) → {Object}

        returns the object containing the term searched
        Parameters:
        Name Type Description
        needle String The searched term
        haystack Array The values to be searched
        Deprecated:
        • since version 1.6
          Source:
          Returns:
          Object found
          Type
          Object

          titleSearch(needle, haystack) → {Object}

          returns the object containing the title searched
          Parameters:
          Name Type Description
          needle String The searched title
          haystack Array The values to be searched
          Source:
          Returns:
          Object found
          Type
          Object

          toISOString(d) → {String}

          returns an iso string from a date object
          Parameters:
          Name Type Description
          d date The date to transform
          Source:
          Returns:
          iso string
          Type
          String

          update(options)

          Calls the resourceUpdate function to post data with predefined set of values
          Parameters:
          Name Type Description
          options object options to be used during the call
          Properties
          Name Type Argument Description
          onSuccess Resource~onSuccess a callback function called in case of a success
          onFailure Resource~onFailure <optional>
          a callback function called in case of a failure
          baseUrl String <optional>
          base URL. If not set the current base URL will be used
          Source:

          updatePreset()

          Runs before Post request to update a registry
          Source:

          urlLoader(options)

          Loads Resource data for a given url
          Parameters:
          Name Type Description
          options object options to be used during the call
          Properties
          Name Type Argument Description
          onSuccess Resource~onSuccess a callback function called in case of a success
          onFailure Resource~onFailure <optional>
          a callback function called in case of a failure
          baseUrl String <optional>
          base URL. If not set the current base URL will be used
          url String url for loading
          Source:

          xmlToJson(xml) → {Object}

          Transforms an xml string to a JSON object
          Parameters:
          Name Type Description
          xml String The xml string to transform
          Source:
          Returns:
          JSON object
          Type
          Object

          Type Definitions

          onFailure(response)

          Resource failure callback
          Parameters:
          Name Type Description
          response object an object with the standard browser's error properties
          Source:

          onSuccess(rData)

          Resource success callback
          Parameters:
          Name Type Argument Description
          rData object <optional>
          the raw sata of the request
          Source: