new Resource()
Generic class that is inherited in other classes to load, save and manage data.
- Source:
- Resources/Resource.js, line 56
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 |
Methods
-
<static> decodeBase64(s) → {String}
-
returns the base 64 decoded string
Parameters:
Name Type Description s
String The base 64 string - Source:
- Resources/Resource.js, line 1016
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:
- Resources/Resource.js, line 1026
Returns:
encoded string- Type
- String
-
<static> findLink(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 - Source:
- Resources/Resource.js, line 886
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:
- Resources/Resource.js, line 939
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:
- Resources/Resource.js, line 810
Returns:
Object found- Type
- Object
-
<static> removeDecimalsFromDateString() → {String}
-
Remove date decimals
- Source:
- Resources/Resource.js, line 1447
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:
- Resources/Resource.js, line 1198
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:
- Resources/Resource.js, line 673
-
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:
- Resources/Resource.js, line 109
-
clearFilters()
-
Clears the filter array
- Source:
- Resources/Resource.js, line 692
-
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:
- Resources/Resource.js, line 1466
-
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:
- Resources/Resource.js, line 1536
-
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:
- Resources/Resource.js, line 1593
-
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:
- Resources/Resource.js, line 1632
-
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:
- Resources/Resource.js, line 960
Returns:
Decoded string- Type
- String
-
deletePreset()
-
Runs before Delete request
- Source:
- Resources/Resource.js, line 546
-
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:
- Resources/Resource.js, line 983
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:
- Resources/Resource.js, line 1240
Returns:
the transformed html- Type
- String
-
entryLinks(entries) → {Array}
-
returns an array of all "link" object list found in an array
Parameters:
Name Type Description entries
Array Array containing all entries - Source:
- Resources/Resource.js, line 721
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:
- Resources/Resource.js, line 1319
-
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:
- Resources/Resource.js, line 741
Returns:
flattened array- Type
- Array
-
generate_xml() → {String}
-
Runs to generate a Post xml for saving or updating a registry
- Source:
- Resources/Resource.js, line 559
Returns:
xml - string to be posted- Type
- String
-
generateFilterStr()
-
Generates the filter string to be posted to the server
- Source:
- Resources/Resource.js, line 575
-
generateModeStr()
-
Generates the Mode string for the request Url
- Source:
- Resources/Resource.js, line 642
-
generateOrderByStr()
-
Generates the orderBy string for the request Url
- Source:
- Resources/Resource.js, line 618
-
generatePaginationStr()
-
Generates the pagination string for the request Url
- Source:
- Resources/Resource.js, line 609
-
generateParametersStr()
-
Generates the parameters string for the request Url
- Source:
- Resources/Resource.js, line 653
-
generateUrl() → {String}
-
Runs to retrieve the url before a request
- Source:
- Resources/Resource.js, line 567
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:
- Resources/Resource.js, line 702
Returns:
Array of registries- Type
- Array
-
getUrlAggregates() → {String}
-
Runs to retrieve the url filters and pagination
- Source:
- Resources/Resource.js, line 1422
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:
- Resources/Resource.js, line 848
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:
- Resources/Resource.js, line 1754
-
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:
- Resources/Resource.js, line 181
-
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:
- Resources/Resource.js, line 918
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:
- Resources/Resource.js, line 864
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:
- Resources/Resource.js, line 223
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:
- Resources/Resource.js, line 280
-
loadPreset()
-
Runs before Get request
- Source:
- Resources/Resource.js, line 534
-
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:
- Resources/Resource.js, line 320
-
loadSet(dataObject)
-
Runs after sucessful Post
Parameters:
Name Type Description dataObject
Object success callback function - Source:
- Resources/Resource.js, line 522
-
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:
- Resources/Resource.js, line 370
-
padzero(n) → {Number}
-
Pads to 0 the int values
Parameters:
Name Type Description n
Number the number to pad - Source:
- Resources/Resource.js, line 1295
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:
- Resources/Resource.js, line 907
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:
- Resources/Resource.js, line 1331
-
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:
- Resources/Resource.js, line 494
-
removeFilter(key)
-
Finds and removes a filter from the stack
Parameters:
Name Type Description key
String the filter to be removed - Source:
- Resources/Resource.js, line 681
-
removeUnicodeEscNotation(input) → {String}
-
removes the u0000 escape notation from string
Parameters:
Name Type Description input
String The string to clean. - Source:
- Resources/Resource.js, line 1189
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:
- Resources/Resource.js, line 407
-
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:
- Resources/Resource.js, line 460
-
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:
- Resources/Resource.js, line 359
-
savePreset()
-
Runs before Post request to create a registry
- Source:
- Resources/Resource.js, line 540
-
saveSet()
-
Runs after Post request to create a registry
- Source:
- Resources/Resource.js, line 528
-
sort_unique(arr) → {Array}
-
Sorts array and removes duplicated values
Parameters:
Name Type Description arr
Array The unsorted array - Source:
- Resources/Resource.js, line 1207
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:
- Resources/Resource.js, line 149
-
stringtoXML(text) → {XMLDOM}
-
Correctly transforms a string to an xml document
Parameters:
Name Type Description text
String The xml string to transform - Source:
- Resources/Resource.js, line 1223
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:
- Resources/Resource.js, line 791
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:
- Resources/Resource.js, line 829
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:
- Resources/Resource.js, line 1304
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:
- Resources/Resource.js, line 449
-
updatePreset()
-
Runs before Post request to update a registry
- Source:
- Resources/Resource.js, line 552
-
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:
- Resources/Resource.js, line 86
-
xmlToJson(xml) → {Object}
-
Transforms an xml string to a JSON object
Parameters:
Name Type Description xml
String The xml string to transform - Source:
- Resources/Resource.js, line 1253
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:
- Resources/Resource.js, line 26
-
onSuccess(rData)
-
Resource success callback
Parameters:
Name Type Argument Description rData
object <optional>
the raw sata of the request - Source:
- Resources/Resource.js, line 21