/*
* Copyright 2015 Anyware Services
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* The survey page DAO.
*/
Ext.define('Ametys.cms.survey.PageDAO', {
singleton: true,
constructor: function(config)
{
/**
* @callable
* @member Ametys.cms.survey.PageDAO
* @method createPage
* Creates a survey page.
* This calls the method 'createPage' of the server DAO 'PageDAO'.
* @param {Object[]} parameters The parameters to transmit to the server method
* @param {Object} parameters.values The values
* @param {String} parameters.values.surveyId The id of the parent survey
* @param {String} parameters.values.label The label
* @param {String} parameters.values.title The title
* @param {String} parameters.values.description The description
* @param {Function} callback The function to call when the java process is over. Use options.scope for the scope.
* @param {Object} callback.returnedValue The value return from the server. Null on error (please note that when an error occured, the callback may not be called depending on the value of errorMessage).
* @param {Object} callback.arguments Other arguments specified in option.arguments
* @param {Object} [options] Advanced options for the call.
* @param {Boolean/String/Object} [options.errorMessage] Display an error message. See Ametys.data.ServerComm#callMethod errorMessage.
* @param {Boolean/String/Object} [options.waitMessage] Display a waiting message. See Ametys.data.ServerComm#callMethod waitMessage.
* @param {Number} [options.scope] This parameter is the scope used to call the callback. Moreover is the given class is a mixin of Ametys.data.ServerCaller, its methods Ametys.data.ServerCaller#beforeServerCall and Ametys.data.ServerCaller#afterServerCall will be used so see their documentation to look for additional options (such a refreshing on Ametys.ribbon.element.ui.ButtonController#beforeServerCall).
* @param {Number} [options.priority] The message priority. See Ametys.data.ServerComm#callMethod for more information on the priority. PRIORITY_SYNCHRONOUS cannot be used here.
* @param {String} [options.cancelCode] Cancel similar unachieved read operations. See Ametys.data.ServerComm#callMethod cancelCode.
* @param {Object} [options.arguments] Additional arguments set in the callback.arguments parameter.
* @param {Boolean} [options.ignoreCallbackOnError] If the server throws an exception, should the callback beeing called with a null parameter. See Ametys.data.ServerComm#callMethod ignoreOnError.
*/
this.addCallables(
{
role: "org.ametys.plugins.survey.dao.PageDAO",
methodName: "createPage",
callback: {
handler: this._createPageCb
},
errorMessage: {
msg: "{{i18n PLUGINS_SURVEY_ADD_PAGE_ERROR}}",
category: Ext.getClassName(this)
}
}
);
/**
* @callable
* @member Ametys.cms.survey.PageDAO
* @method editPage
* Edits a survey page.
* This calls the method 'editPage' of the server DAO 'PageDAO'.
* @param {Object[]} parameters The parameters to transmit to the server method
* @param {Object} parameters.values The values
* @param {String} parameters.values.id The id of the page to edit
* @param {String} parameters.values.label The label
* @param {String} parameters.values.title The title
* @param {String} parameters.description The description
* @param {Function} callback The function to call when the java process is over. Use options.scope for the scope.
* @param {Object} callback.returnedValue The value return from the server. Null on error (please note that when an error occured, the callback may not be called depending on the value of errorMessage).
* @param {Object} callback.arguments Other arguments specified in option.arguments
* @param {Object} [options] Advanced options for the call.
* @param {Boolean/String/Object} [options.errorMessage] Display an error message. See Ametys.data.ServerComm#callMethod errorMessage.
* @param {Boolean/String/Object} [options.waitMessage] Display a waiting message. See Ametys.data.ServerComm#callMethod waitMessage.
* @param {Number} [options.scope] This parameter is the scope used to call the callback. Moreover is the given class is a mixin of Ametys.data.ServerCaller, its methods Ametys.data.ServerCaller#beforeServerCall and Ametys.data.ServerCaller#afterServerCall will be used so see their documentation to look for additional options (such a refreshing on Ametys.ribbon.element.ui.ButtonController#beforeServerCall).
* @param {Number} [options.priority] The message priority. See Ametys.data.ServerComm#callMethod for more information on the priority. PRIORITY_SYNCHRONOUS cannot be used here.
* @param {String} [options.cancelCode] Cancel similar unachieved read operations. See Ametys.data.ServerComm#callMethod cancelCode.
* @param {Object} [options.arguments] Additional arguments set in the callback.arguments parameter.
* @param {Boolean} [options.ignoreCallbackOnError] If the server throws an exception, should the callback beeing called with a null parameter. See Ametys.data.ServerComm#callMethod ignoreOnError.
*/
this.addCallables(
{
role: "org.ametys.plugins.survey.dao.PageDAO",
methodName: "editPage",
callback: {
handler: this._editPageCb
},
errorMessage: {
msg: "{{i18n PLUGINS_SURVEY_EDIT_PAGE_ERROR}}",
category: Ext.getClassName(this)
}
}
);
/**
* @callable
* @member Ametys.cms.survey.PageDAO
* @method copyPage
* Copies and pastes a survey page.
* This calls the method 'copyPage' of the server DAO 'PageDAO'.
* @param {Object[]} parameters The parameters to transmit to the server method
* @param {String} parameters.surveyId The id of the survey, target of the copy
* @param {String} parameters.pageId The id of the page to copy
* @param {Function} callback The function to call when the java process is over. Use options.scope for the scope.
* @param {Object} callback.returnedValue The value return from the server. Null on error (please note that when an error occured, the callback may not be called depending on the value of errorMessage).
* @param {Object} callback.arguments Other arguments specified in option.arguments
* @param {Object} [options] Advanced options for the call.
* @param {Boolean/String/Object} [options.errorMessage] Display an error message. See Ametys.data.ServerComm#callMethod errorMessage.
* @param {Boolean/String/Object} [options.waitMessage] Display a waiting message. See Ametys.data.ServerComm#callMethod waitMessage.
* @param {Number} [options.scope] This parameter is the scope used to call the callback. Moreover is the given class is a mixin of Ametys.data.ServerCaller, its methods Ametys.data.ServerCaller#beforeServerCall and Ametys.data.ServerCaller#afterServerCall will be used so see their documentation to look for additional options (such a refreshing on Ametys.ribbon.element.ui.ButtonController#beforeServerCall).
* @param {Number} [options.priority] The message priority. See Ametys.data.ServerComm#callMethod for more information on the priority. PRIORITY_SYNCHRONOUS cannot be used here.
* @param {String} [options.cancelCode] Cancel similar unachieved read operations. See Ametys.data.ServerComm#callMethod cancelCode.
* @param {Object} [options.arguments] Additional arguments set in the callback.arguments parameter.
* @param {Boolean} [options.ignoreCallbackOnError] If the server throws an exception, should the callback beeing called with a null parameter. See Ametys.data.ServerComm#callMethod ignoreOnError.
*/
this.addCallables(
{
role: "org.ametys.plugins.survey.dao.PageDAO",
methodName: "copyPage",
callback: {
handler: this._copyPageCb
},
errorMessage: {
msg: "{{i18n PLUGINS_SURVEY_COPY_PAGE_ERROR}}",
category: Ext.getClassName(this)
}
}
);
/**
* @callable
* @member Ametys.cms.survey.PageDAO
* @method deletePage
* Deletes a survey page.
* This calls the method 'deletePage' of the server DAO 'PageDAO'.
* @param {Object[]} parameters The parameters to transmit to the server method
* @param {String} parameters.id The id of the page to delete
* @param {Function} callback The function to call when the java process is over. Use options.scope for the scope.
* @param {Object} callback.returnedValue The value return from the server. Null on error (please note that when an error occured, the callback may not be called depending on the value of errorMessage).
* @param {Object} callback.arguments Other arguments specified in option.arguments
* @param {Object} [options] Advanced options for the call.
* @param {Boolean/String/Object} [options.errorMessage] Display an error message. See Ametys.data.ServerComm#callMethod errorMessage.
* @param {Boolean/String/Object} [options.waitMessage] Display a waiting message. See Ametys.data.ServerComm#callMethod waitMessage.
* @param {Number} [options.scope] This parameter is the scope used to call the callback. Moreover is the given class is a mixin of Ametys.data.ServerCaller, its methods Ametys.data.ServerCaller#beforeServerCall and Ametys.data.ServerCaller#afterServerCall will be used so see their documentation to look for additional options (such a refreshing on Ametys.ribbon.element.ui.ButtonController#beforeServerCall).
* @param {Number} [options.priority] The message priority. See Ametys.data.ServerComm#callMethod for more information on the priority. PRIORITY_SYNCHRONOUS cannot be used here.
* @param {String} [options.cancelCode] Cancel similar unachieved read operations. See Ametys.data.ServerComm#callMethod cancelCode.
* @param {Object} [options.arguments] Additional arguments set in the callback.arguments parameter.
* @param {Boolean} [options.ignoreCallbackOnError] If the server throws an exception, should the callback beeing called with a null parameter. See Ametys.data.ServerComm#callMethod ignoreOnError.
*/
this.addCallables(
{
role: "org.ametys.plugins.survey.dao.PageDAO",
methodName: "deletePage",
callback: {
handler: this._deletePageCb
},
errorMessage: {
msg: "{{i18n PLUGINS_SURVEY_DELETE_PAGE_ERROR}}",
category: Ext.getClassName(this)
}
}
);
/**
* @callable
* @member Ametys.cms.survey.PageDAO
* @method getPage
* Gets properties of a survey page
* This calls the method 'getPage' of the server DAO 'PageDAO'.
* @param {Object[]} parameters The parameters to transmit to the server method
* @param {String} parameters.id The id of the page to retrieve
* @param {Function} callback The function to call when the java process is over. Use options.scope for the scope.
* @param {Object} callback.returnedValue The value return from the server. Null on error (please note that when an error occured, the callback may not be called depending on the value of errorMessage).
* @param {Object} callback.arguments Other arguments specified in option.arguments
* @param {Object} [options] Advanced options for the call.
* @param {Boolean/String/Object} [options.errorMessage] Display an error message. See Ametys.data.ServerComm#callMethod errorMessage.
* @param {Boolean/String/Object} [options.waitMessage] Display a waiting message. See Ametys.data.ServerComm#callMethod waitMessage.
* @param {Number} [options.scope] This parameter is the scope used to call the callback. Moreover is the given class is a mixin of Ametys.data.ServerCaller, its methods Ametys.data.ServerCaller#beforeServerCall and Ametys.data.ServerCaller#afterServerCall will be used so see their documentation to look for additional options (such a refreshing on Ametys.ribbon.element.ui.ButtonController#beforeServerCall).
* @param {Number} [options.priority] The message priority. See Ametys.data.ServerComm#callMethod for more information on the priority. PRIORITY_SYNCHRONOUS cannot be used here.
* @param {String} [options.cancelCode] Cancel similar unachieved read operations. See Ametys.data.ServerComm#callMethod cancelCode.
* @param {Object} [options.arguments] Additional arguments set in the callback.arguments parameter.
* @param {Boolean} [options.ignoreCallbackOnError] If the server throws an exception, should the callback beeing called with a null parameter. See Ametys.data.ServerComm#callMethod ignoreOnError.
*/
this.addCallables(
{
role: "org.ametys.plugins.survey.dao.PageDAO",
methodName: "getPage",
callback: {
handler: Ext.emptyFn
},
errorMessage: {
msg: "{{i18n PLUGINS_SURVEY_TOOL_ERROR}}",
category: Ext.getClassName(this)
}
}
);
/**
* @callable
* @member Ametys.cms.survey.PageDAO
* @method isLastPage
* Determines if a page is the last of survey's pages.
* This calls the method 'isLastPage' of the server DAO 'PageDAO'.
* @param {Object[]} parameters The parameters to transmit to the server method
* @param {String} parameters.id The id of the page to test
* @param {Function} callback The function to call when the java process is over. Use options.scope for the scope.
* @param {Object} callback.returnedValue The value return from the server. Null on error (please note that when an error occured, the callback may not be called depending on the value of errorMessage).
* @param {Object} callback.arguments Other arguments specified in option.arguments
* @param {Object} [options] Advanced options for the call.
* @param {Boolean/String/Object} [options.errorMessage] Display an error message. See Ametys.data.ServerComm#callMethod errorMessage.
* @param {Boolean/String/Object} [options.waitMessage] Display a waiting message. See Ametys.data.ServerComm#callMethod waitMessage.
* @param {Number} [options.scope] This parameter is the scope used to call the callback. Moreover is the given class is a mixin of Ametys.data.ServerCaller, its methods Ametys.data.ServerCaller#beforeServerCall and Ametys.data.ServerCaller#afterServerCall will be used so see their documentation to look for additional options (such a refreshing on Ametys.ribbon.element.ui.ButtonController#beforeServerCall).
* @param {Number} [options.priority] The message priority. See Ametys.data.ServerComm#callMethod for more information on the priority. PRIORITY_SYNCHRONOUS cannot be used here.
* @param {String} [options.cancelCode] Cancel similar unachieved read operations. See Ametys.data.ServerComm#callMethod cancelCode.
* @param {Object} [options.arguments] Additional arguments set in the callback.arguments parameter.
* @param {Boolean} [options.ignoreCallbackOnError] If the server throws an exception, should the callback beeing called with a null parameter. See Ametys.data.ServerComm#callMethod ignoreOnError.
*/
this.addCallables(
{
role: "org.ametys.plugins.survey.dao.PageDAO",
methodName: "isLastPage",
callback: {
handler: Ext.emptyFn
},
errorMessage: {
msg: "{{i18n PLUGINS_SURVEY_TOOL_ERROR}}",
category: Ext.getClassName(this)
}
}
);
/**
* @callable
* @member Ametys.cms.survey.PageDAO
* @method addRule
* Adds a a new rule to a page.
* This calls the method 'addRule' of the server DAO 'PageDAO'.
* @param {Object[]} parameters The parameters to transmit to the server method
* @param {String} parameters.id The id of the page
* @param {String} parameters.rule The rule type
* @param {String} parameters.page The page to jump or skip
* @param {Function} callback The function to call when the java process is over. Use options.scope for the scope.
* @param {Object} callback.returnedValue The value return from the server. Null on error (please note that when an error occured, the callback may not be called depending on the value of errorMessage).
* @param {Object} callback.arguments Other arguments specified in option.arguments
* @param {Object} [options] Advanced options for the call.
* @param {Boolean/String/Object} [options.errorMessage] Display an error message. See Ametys.data.ServerComm#callMethod errorMessage.
* @param {Boolean/String/Object} [options.waitMessage] Display a waiting message. See Ametys.data.ServerComm#callMethod waitMessage.
* @param {Number} [options.scope] This parameter is the scope used to call the callback. Moreover is the given class is a mixin of Ametys.data.ServerCaller, its methods Ametys.data.ServerCaller#beforeServerCall and Ametys.data.ServerCaller#afterServerCall will be used so see their documentation to look for additional options (such a refreshing on Ametys.ribbon.element.ui.ButtonController#beforeServerCall).
* @param {Number} [options.priority] The message priority. See Ametys.data.ServerComm#callMethod for more information on the priority. PRIORITY_SYNCHRONOUS cannot be used here.
* @param {String} [options.cancelCode] Cancel similar unachieved read operations. See Ametys.data.ServerComm#callMethod cancelCode.
* @param {Object} [options.arguments] Additional arguments set in the callback.arguments parameter.
* @param {Boolean} [options.ignoreCallbackOnError] If the server throws an exception, should the callback beeing called with a null parameter. See Ametys.data.ServerComm#callMethod ignoreOnError.
*/
this.addCallables(
{
role: "org.ametys.plugins.survey.dao.PageDAO",
methodName: "addRule",
callback: {
handler: Ext.emptyFn
},
errorMessage: {
msg: "{{i18n PLUGINS_SURVEY_ADD_RULE_ERROR}}",
category: Ext.getClassName(this)
}
}
);
/**
* @callable
* @member Ametys.cms.survey.PageDAO
* @method deleteRule
* Deletes a rule to a page
* This calls the method 'deleteRule' of the server DAO 'PageDAO'.
* @param {Object[]} parameters The parameters to transmit to the server method
* @param {String} parameters.id The id of the page
* @param {Function} callback The function to call when the java process is over. Use options.scope for the scope.
* @param {Object} callback.returnedValue The value return from the server. Null on error (please note that when an error occured, the callback may not be called depending on the value of errorMessage).
* @param {Object} callback.arguments Other arguments specified in option.arguments
* @param {Object} [options] Advanced options for the call.
* @param {Boolean/String/Object} [options.errorMessage] Display an error message. See Ametys.data.ServerComm#callMethod errorMessage.
* @param {Boolean/String/Object} [options.waitMessage] Display a waiting message. See Ametys.data.ServerComm#callMethod waitMessage.
* @param {Number} [options.scope] This parameter is the scope used to call the callback. Moreover is the given class is a mixin of Ametys.data.ServerCaller, its methods Ametys.data.ServerCaller#beforeServerCall and Ametys.data.ServerCaller#afterServerCall will be used so see their documentation to look for additional options (such a refreshing on Ametys.ribbon.element.ui.ButtonController#beforeServerCall).
* @param {Number} [options.priority] The message priority. See Ametys.data.ServerComm#callMethod for more information on the priority. PRIORITY_SYNCHRONOUS cannot be used here.
* @param {String} [options.cancelCode] Cancel similar unachieved read operations. See Ametys.data.ServerComm#callMethod cancelCode.
* @param {Object} [options.arguments] Additional arguments set in the callback.arguments parameter.
* @param {Boolean} [options.ignoreCallbackOnError] If the server throws an exception, should the callback beeing called with a null parameter. See Ametys.data.ServerComm#callMethod ignoreOnError.
*/
this.addCallables(
{
role: "org.ametys.plugins.survey.dao.PageDAO",
methodName: "deleteRule",
callback: {
handler: Ext.emptyFn
},
errorMessage: {
msg: "{{i18n PLUGINS_SURVEY_DELETE_RULE_ERROR}}",
category: Ext.getClassName(this)
}
}
);
/**
* @callable
* @member Ametys.cms.survey.PageDAO
* @method getRule
* Gets the rule for a survey page.
* This calls the method 'getRule' of the server DAO 'PageDAO'.
* @param {Object[]} parameters The parameters to transmit to the server method
* @param {String} parameters.id The id of the page
* @param {Function} callback The function to call when the java process is over. Use options.scope for the scope.
* @param {Object} callback.returnedValue The value return from the server. Null on error (please note that when an error occured, the callback may not be called depending on the value of errorMessage).
* @param {Object} callback.arguments Other arguments specified in option.arguments
* @param {Object} [options] Advanced options for the call.
* @param {Boolean/String/Object} [options.errorMessage] Display an error message. See Ametys.data.ServerComm#callMethod errorMessage.
* @param {Boolean/String/Object} [options.waitMessage] Display a waiting message. See Ametys.data.ServerComm#callMethod waitMessage.
* @param {Number} [options.scope] This parameter is the scope used to call the callback. Moreover is the given class is a mixin of Ametys.data.ServerCaller, its methods Ametys.data.ServerCaller#beforeServerCall and Ametys.data.ServerCaller#afterServerCall will be used so see their documentation to look for additional options (such a refreshing on Ametys.ribbon.element.ui.ButtonController#beforeServerCall).
* @param {Number} [options.priority] The message priority. See Ametys.data.ServerComm#callMethod for more information on the priority. PRIORITY_SYNCHRONOUS cannot be used here.
* @param {String} [options.cancelCode] Cancel similar unachieved read operations. See Ametys.data.ServerComm#callMethod cancelCode.
* @param {Object} [options.arguments] Additional arguments set in the callback.arguments parameter.
* @param {Boolean} [options.ignoreCallbackOnError] If the server throws an exception, should the callback beeing called with a null parameter. See Ametys.data.ServerComm#callMethod ignoreOnError.
*/
this.addCallables(
{
role: "org.ametys.plugins.survey.dao.PageDAO",
methodName: "getRule",
callback: {
handler: Ext.emptyFn
},
errorMessage: {
msg: "{{i18n PLUGINS_SURVEY_BRANCHES_ERROR}}",
category: Ext.getClassName(this)
}
}
);
/**
* @callable
* @member Ametys.cms.survey.PageDAO
* @method getBranches
* Gets the branches for a survey page.
* This calls the method 'getBranches' of the server DAO 'PageDAO'.
* @param {Object[]} parameters The parameters to transmit to the server method
* @param {String} parameters.id The id of the page
* @param {Function} callback The function to call when the java process is over. Use options.scope for the scope.
* @param {Object} callback.returnedValue The value return from the server. Null on error (please note that when an error occured, the callback may not be called depending on the value of errorMessage).
* @param {Object} callback.arguments Other arguments specified in option.arguments
* @param {Object} [options] Advanced options for the call.
* @param {Boolean/String/Object} [options.errorMessage] Display an error message. See Ametys.data.ServerComm#callMethod errorMessage.
* @param {Boolean/String/Object} [options.waitMessage] Display a waiting message. See Ametys.data.ServerComm#callMethod waitMessage.
* @param {Number} [options.scope] This parameter is the scope used to call the callback. Moreover is the given class is a mixin of Ametys.data.ServerCaller, its methods Ametys.data.ServerCaller#beforeServerCall and Ametys.data.ServerCaller#afterServerCall will be used so see their documentation to look for additional options (such a refreshing on Ametys.ribbon.element.ui.ButtonController#beforeServerCall).
* @param {Number} [options.priority] The message priority. See Ametys.data.ServerComm#callMethod for more information on the priority. PRIORITY_SYNCHRONOUS cannot be used here.
* @param {String} [options.cancelCode] Cancel similar unachieved read operations. See Ametys.data.ServerComm#callMethod cancelCode.
* @param {Object} [options.arguments] Additional arguments set in the callback.arguments parameter.
* @param {Boolean} [options.ignoreCallbackOnError] If the server throws an exception, should the callback beeing called with a null parameter. See Ametys.data.ServerComm#callMethod ignoreOnError.
*/
this.addCallables(
{
role: "org.ametys.plugins.survey.dao.PageDAO",
methodName: "getBranches",
callback: {
handler: Ext.emptyFn
},
errorMessage: {
msg: "{{i18n PLUGINS_SURVEY_BRANCHES_ERROR}}",
category: Ext.getClassName(this)
}
}
);
},
/**
* Callback function called after {@link #createPage} has been processed.
* @param {Object} response The text response provided by the {@link Ametys.data.ServerComm}
* @param {Object} args The callback arguments
* @param {Array} params The parameters
* @private
*/
_createPageCb: function(response, args, params)
{
Ext.create("Ametys.message.Message", {
type: Ametys.message.Message.CREATED,
targets: {
id: Ametys.message.MessageTarget.SURVEY_PAGE,
parameters: {
id: response.id,
surveyId: params[0].surveyId
}
}
});
},
/**
* Callback function called after {@link #editPage} has been processed.
* @param {Object} response The text response provided by the {@link Ametys.data.ServerComm}
* @private
*/
_editPageCb: function(response)
{
Ext.create("Ametys.message.Message", {
type: Ametys.message.Message.MODIFIED,
targets: {
id: Ametys.message.MessageTarget.SURVEY_PAGE,
parameters: {
id: response.id,
surveyId: response.surveyId
}
}
});
},
/**
* Callback function called after {@link #copyPage} has been processed.
* @param {Object} response The text response provided by the {@link Ametys.data.ServerComm}
* @param {Object} args The callback arguments
* @param {Array} params The parameters
* @private
*/
_copyPageCb: function(response, args, params)
{
Ext.create("Ametys.message.Message", {
type: Ametys.message.Message.CREATED,
targets: {
id: Ametys.message.MessageTarget.SURVEY_PAGE,
parameters: {
id: response.id,
surveyId: params[0]
}
}
});
},
/**
* Callback function called after {@link #deletePage} has been processed.
* @param {Object} response The text response provided by the {@link Ametys.data.ServerComm}
* @private
*/
_deletePageCb: function(response)
{
Ext.create("Ametys.message.Message", {
type: Ametys.message.Message.DELETED,
targets: {
id: Ametys.message.MessageTarget.SURVEY_PAGE,
parameters: {
id: response.id,
surveyId: response.surveyId
}
}
});
}
});