package pt.estgp.estgweb.web.form.questionarios;
import org.apache.log4j.Logger;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionMapping;
import org.json.JSONArray;
import org.json.JSONException;
import pt.estgp.estgweb.domain.QuestionarioReportFile;
import pt.estgp.estgweb.domain.QuestionarioReportFileGroup;
import pt.estgp.estgweb.domain.QuestionarioReportFileGroupImpl;
import pt.estgp.estgweb.domain.QuestionarioReportFileImpl;
import pt.estgp.estgweb.domain.utils.InputDrivenInput;
import pt.estgp.estgweb.web.form.ApplicationForm;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
/**
* @author Jorge Machado
* @date 25/Jun/2008
* @see pt.estgp.estgweb.web.form.courses
*/
public class QuestionarioReportGroupForm
extends ApplicationForm
{
private static final 1.5.0/docs/api/java/util/logging/Logger.html">Logger logger =
1.5.0/docs/api/java/util/logging/Logger.html">Logger.
getLogger(QuestionarioReportGroupForm.
class);
//For new instance creation
private 1.5.0/docs/api/java/lang/String.html">String title
;
private 1.5.0/docs/api/java/lang/String.html">String reportFileGroupClass
;
private 1.5.0/docs/api/java/lang/String.html">String dispatch
;
private 1.5.0/docs/api/java/lang/String.html">String parametersArrayObtainedFromWidget
;
private 1.5.0/docs/api/java/lang/String.html">String processSigesCode
;
//For administration
QuestionarioReportFileGroup questionarioReportFileGroup =
new QuestionarioReportFileGroupImpl
() {
@
1.5.0/docs/api/java/lang/Override.html">Override
public List
<InputDrivenInput
> getInputs
() {
throw new 1.5.0/docs/api/java/lang/RuntimeException.html">RuntimeException("Only for input form use, thisreportGroup is only for data exchange purposes");
}
@
1.5.0/docs/api/java/lang/Override.html">Override
public 1.5.0/docs/api/java/lang/String.html">String getInputsJson
() throws JSONException
{
throw new 1.5.0/docs/api/java/lang/RuntimeException.html">RuntimeException("Only for input form use, thisreportGroup is only for data exchange purposes");
}
@
1.5.0/docs/api/java/lang/Override.html">Override
public JSONArray getInputsJsonArray
() throws JSONException
{
throw new 1.5.0/docs/api/java/lang/RuntimeException.html">RuntimeException("Only for input form use, thisreportGroup is only for data exchange purposes");
}
};
QuestionarioReportFile questionarioReportFile =
new QuestionarioReportFileImpl
();
public QuestionarioReportGroupForm
()
{
}
public QuestionarioReportFile getQuestionarioReportFile
() {
return questionarioReportFile
;
}
public void setQuestionarioReportFile
(QuestionarioReportFile questionarioReportFile
) {
this.
questionarioReportFile = questionarioReportFile
;
}
public 1.5.0/docs/api/java/lang/String.html">String getParametersArrayObtainedFromWidget
() {
return parametersArrayObtainedFromWidget
;
}
public void setParametersArrayObtainedFromWidget
(1.5.0/docs/api/java/lang/String.html">String parametersArrayObtainedFromWidget
) {
this.
parametersArrayObtainedFromWidget = parametersArrayObtainedFromWidget
;
}
public QuestionarioReportFileGroup getQuestionarioReportFileGroup
() {
return questionarioReportFileGroup
;
}
public void setQuestionarioReportFileGroup
(QuestionarioReportFileGroup questionarioReportFileGroup
) {
this.
questionarioReportFileGroup = questionarioReportFileGroup
;
}
public 1.5.0/docs/api/java/lang/String.html">String getTitle
() {
return title
;
}
public void setTitle
(1.5.0/docs/api/java/lang/String.html">String title
) {
this.
title = title
;
}
public 1.5.0/docs/api/java/lang/String.html">String getReportFileGroupClass
() {
return reportFileGroupClass
;
}
public void setReportFileGroupClass
(1.5.0/docs/api/java/lang/String.html">String reportFileGroupClass
) {
this.
reportFileGroupClass = reportFileGroupClass
;
}
public 1.5.0/docs/api/java/lang/String.html">String getOp
() {
return dispatch
;
}
public void setOp
(1.5.0/docs/api/java/lang/String.html">String dispatch
) {
this.
dispatch = dispatch
;
}
public 1.5.0/docs/api/java/lang/String.html">String getProcessSigesCode
() {
return processSigesCode
;
}
public void setProcessSigesCode
(1.5.0/docs/api/java/lang/String.html">String processSigesCode
) {
this.
processSigesCode = processSigesCode
;
}
@
1.5.0/docs/api/java/lang/Override.html">Override
public ActionErrors validate
(ActionMapping mapping, HttpServletRequest request
) {
ActionErrors errors =
new ActionErrors
();
return errors
;
}
public ActionErrors validateForGenerate
(ActionMapping mapping, HttpServletRequest request
) {
ActionErrors errors =
new ActionErrors
();
if(getQuestionarioReportFileGroup
().
getTitle() ==
null || getQuestionarioReportFileGroup
().
getTitle().
trim().
length() ==
0)
{
addMessageAsString
(errors,
"É necessário definir um titulo para o processador de relatórios");
}
if(getQuestionarioReportFileGroup
().
getReportProcessorClass() ==
null || getQuestionarioReportFileGroup
().
getReportProcessorClass().
trim().
length() ==
0)
{
addMessageAsString
(errors,
"É necessário definir um processador de relatórios");
}
try {
if(parametersArrayObtainedFromWidget ==
null ||
new JSONArray
(parametersArrayObtainedFromWidget
).
length() ==
0)
addMessageAsString
(errors,
"É necessário definir os parâmetros antes de mandar processar os relatórios");
} catch (JSONException e
) {
logger.
error(e,e
);
addMessageAsString
(errors,
"É necessário definir os parâmetros antes de mandar processar os relatórios");
}
return errors
;
}
}