Namespace Papercube.adaptor
| Extends: | SC.Server |
| Defined in: | clients/papercube/adaptor.js |
| Version: | 1.0 |
| Author: | Peter Bergstrom |
| Copyright: | 2008-2009 Peter Bergström. |
Overview
Papercube.adaptor
The adaptor object controls the interaction between Papercube and the server back end.
Desired Actions:
PAPERS searchPapers // summary info only getPaperDetails // returns {Array} paper details with authors getAllDataForPaper // reutnrs {Array} full paper details.
AUTHORS: searchAuthors // summary info only getAuthorDetails // returns {Array} author details
This list of actions will probably be modified, expanded, and reduced as the project develops.
Property Summary
-
+ (Function) _getAuthorDetailsCallBack [R/W]Call back function for getAuthorDetails. -
+ (Function) _getPaperDetailsCallback [R/W]Call back function for getPaperDetails. -
+ (String) base [R/W]The base API path is specified here and it will be automatically added to requests. -
+ (Array) prefix [R/W]This is the application prefix. -
+ (Integer) requestIndex [R/W]This allows the tracking of which query result should be loaded from the SC Store. -
+ (Object) requests [R/W]List of requests.
Method Summary
-
+ (String) _handleMult(object)Converts an array of guids to a comma separated string of guids, if it is not an array, it is just return as is. -
+ (Boolean) evaluateStatus(json)Evaluate status of the response. -
+ (void) getAllDataForPaper(guid, callBack)Get the ALL details of a given paper. -
+ (void) getAuthorDetails(guid, callBack)Get the details of a given author. -
+ (void) getAuthorDetailsSuccess(response)When the getAuthorDetails action is successful, you want to display the results in the search list. -
+ (void) getPaperDetails(guid, callBack)Get the details of a given paper. -
+ (void) getPaperDetailsSuccess(response)When the getPaperDetails action is successful, you want to display the results in the search list. -
+ (void) handleError(response, transport)Generic error handler. -
+ (void) handleFailure(response, transport)Generic failure handler. -
+ (void) importRecords(clientData)Import records into the SC Store. -
+ (void) request(requestHash, url, params)Create the request and call the server. -
+ (Boolean) requestError(requestHash, transport)Generic error, then pass it along to the generic error handler for the request. -
+ (Boolean) requestFailure(requestHash, transport)Generic failure, then pass it along to the generic failure handler for the request. -
+ (Boolean) requestSuccess(requestHash, transport)Generic success, parse the JSON and insert it into the SC Store, then pass it along to the custom success handler for the request. -
+ (Boolean) searchAuthors(searchKey, searchValue, sc, start, limit)Searches against a key and value in the database for authors. -
+ (void) searchAuthorsSuccess(response)When the searchAuthors action is successful, you want to display the results in the search list. -
+ (Boolean) searchPapers(searchKey, searchValue, sc, start, limit)Searches against a key and value in the database for papers. -
+ (void) searchPapersSuccess(response)When the searchPapers action is successful, you want to display the results in the search list.
Property Details
_getAuthorDetailsCallBack [R/W]
Call back function for getAuthorDetails.
+ Function _getAuthorDetailsCallBack
_getPaperDetailsCallback [R/W]
Call back function for getPaperDetails.
+ Function _getPaperDetailsCallback
base [R/W]
The base API path is specified here and it will be automatically added to requests.
+ String base
Default Value: '/api/request.php'
prefix [R/W]
This is the application prefix.
+ Array prefix
Default Value: ['Papercube']
Discussion
It is used when loading data into the SC Store.
requestIndex [R/W]
This allows the tracking of which query result should be loaded from the SC Store.
+ Integer requestIndex
Default Value: 0
Discussion
Many requests could be in flight and you may want to match the latest request easily.
Method Detail
_handleMult()
Converts an array of guids to a comma separated string of guids, if it is not an array, it is just return as is.
+ (String) _handleMult (object)
Parameters
(Object|String)object The potential array of guids.
Returns
(String) The guids string.
evaluateStatus()
Evaluate status of the response.
+ (Boolean) evaluateStatus (json)
Parameters
json {Object} The request response JSON object.
Returns
(Boolean) Returns YES if NO error or returns NO if there is an error.
getAllDataForPaper()
Get the ALL details of a given paper.
+ (void) getAllDataForPaper (guid, callBack)
Parameters
guid {string} The guid parameter could also be an array of guids if desired.
callBack {Function} The callBack function is called when the request is successful.
getAuthorDetails()
Get the details of a given author.
+ (void) getAuthorDetails (guid, callBack)
Parameters
guid {string} The guid parameter could also be an array of guids if desired.
callBack {Function} The callBack function is called when the request is successful.
getAuthorDetailsSuccess()
When the getAuthorDetails action is successful, you want to display the results in the search list.
+ (void) getAuthorDetailsSuccess (response)
Parameters
response {Object} The response object from the AJAX request.
getPaperDetails()
Get the details of a given paper.
+ (void) getPaperDetails (guid, callBack)
Parameters
guid {string} The guid parameter could also be an array of guids if desired.
callBack {Function} The callBack function is called when the request is successful.
getPaperDetailsSuccess()
When the getPaperDetails action is successful, you want to display the results in the search list.
+ (void) getPaperDetailsSuccess (response)
Parameters
response {Object} The response object from the AJAX request.
handleError()
Generic error handler.
+ (void) handleError (response, transport)
Parameters
response {Object} The request response.
transport {Object} The AJAX request object.
handleFailure()
Generic failure handler.
+ (void) handleFailure (response, transport)
Parameters
response {Object} The request response.
transport {Object} The AJAX request object.
importRecords()
Import records into the SC Store.
+ (void) importRecords (clientData)
Parameters
clientData {Object} Data that can be imported to the store.
request()
Create the request and call the server.
+ (void) request (requestHash, url, params)
Parameters
requestHash {Object} The request parameters.
url {string} The url for the request.
params {Object} The parameters for the request.
requestError()
Generic error, then pass it along to the generic error handler for the request.
+ (Boolean) requestError (requestHash, transport)
Parameters
requestHash {Object} The request parameters.
transport {Object} The AJAX request object.
Returns
(Boolean) Returns NO if there is an error.
requestFailure()
Generic failure, then pass it along to the generic failure handler for the request.
+ (Boolean) requestFailure (requestHash, transport)
Parameters
requestHash {Object} The request parameters.
transport {Object} The AJAX request object.
Returns
(Boolean) Returns NO if there is an error.
requestSuccess()
Generic success, parse the JSON and insert it into the SC Store, then pass it along to the custom success handler for the request.
+ (Boolean) requestSuccess (requestHash, transport)
Parameters
requestHash {Object} The request parameters.
transport {Object} The AJAX request object.
Returns
(Boolean) Returns NO if there is an error.
searchAuthors()
Searches against a key and value in the database for authors.
+ (Boolean) searchAuthors (searchKey, searchValue, sc, start, limit)
Parameters
searchKey {string} The field key that is searched against.
searchValue {string} The field value that is search against.
sc {Integer} The searchCount parameter. Used for determining what is shown in search list.
start {Integer} The start index.
limit {Integer} The limit.
Returns
(Boolean) Returns NO if there is an error.
searchAuthorsSuccess()
When the searchAuthors action is successful, you want to display the results in the search list.
+ (void) searchAuthorsSuccess (response)
Parameters
response {Object} The response object from the AJAX request.
searchPapers()
Searches against a key and value in the database for papers.
+ (Boolean) searchPapers (searchKey, searchValue, sc, start, limit)
Parameters
searchKey {string} The field key that is searched against.
searchValue {string} The field value that is search against.
sc {Integer} The searchCount parameter, it is used for determining what is shown in search list.
start {Integer} The start index.
limit {Integer} The limit.
Returns
(Boolean) Returns NO if there is an error.
searchPapersSuccess()
When the searchPapers action is successful, you want to display the results in the search list.
+ (void) searchPapersSuccess (response)
Parameters
response {Object} The response object from the AJAX request.