Erste kompilierfähige Version. Wird wohl noch nicht viel tun, aber sie kompiliert - und das ist doch auch schon mal was.
git-svn-id: https://svn.libreccm.org/ccm/trunk@350 8810af33-2d31-482b-a856-94f89814c4dfmaster
parent
1fd85e0a1a
commit
db3fc80861
|
|
@ -7,7 +7,7 @@ object type Survey extends ContentPage {
|
||||||
to bebop_form_sections.form_section_id;
|
to bebop_form_sections.form_section_id;
|
||||||
// Date[0..1] startDate = ct_surveys.start_date DATE;
|
// Date[0..1] startDate = ct_surveys.start_date DATE;
|
||||||
// Date[0..1] endDate = ct_surveys.end_date DATE;
|
// Date[0..1] endDate = ct_surveys.end_date DATE;
|
||||||
Boolean[0..1] responsesPublic = ct_surveys.responses_public CHAR(1);
|
Boolean[0..1] responsesPublic = ct_surveys.responses_public BOOLEAN;
|
||||||
reference key ( ct_surveys.survey_id );
|
reference key ( ct_surveys.survey_id );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,6 @@ import com.arsdigita.domain.DataObjectNotFoundException;
|
||||||
|
|
||||||
import com.arsdigita.formbuilder.PersistentForm;
|
import com.arsdigita.formbuilder.PersistentForm;
|
||||||
|
|
||||||
|
|
||||||
import com.arsdigita.util.Assert;
|
import com.arsdigita.util.Assert;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -31,7 +30,6 @@ public class Survey extends ContentPage {
|
||||||
// public static final String END_DATE = "endDate";
|
// public static final String END_DATE = "endDate";
|
||||||
/** PDL property name for responsesPublic */
|
/** PDL property name for responsesPublic */
|
||||||
public static final String RESPONSES_PUBLIC = "responsesPublic";
|
public static final String RESPONSES_PUBLIC = "responsesPublic";
|
||||||
|
|
||||||
/** Data object type for this domain object */
|
/** Data object type for this domain object */
|
||||||
public static final String BASE_DATA_OBJECT_TYPE = "com.arsdigita.simplesurvey.Survey";
|
public static final String BASE_DATA_OBJECT_TYPE = "com.arsdigita.simplesurvey.Survey";
|
||||||
|
|
||||||
|
|
@ -55,7 +53,7 @@ public class Survey extends ContentPage {
|
||||||
this(new OID(BASE_DATA_OBJECT_TYPE, id));
|
this(new OID(BASE_DATA_OBJECT_TYPE, id));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor. The contained <code>DataObject</code> is retrieved
|
* Constructor. The contained <code>DataObject</code> is retrieved
|
||||||
* from the persistent storage mechanism with an <code>OID</code>
|
* from the persistent storage mechanism with an <code>OID</code>
|
||||||
* specified by <i>id</i>.
|
* specified by <i>id</i>.
|
||||||
|
|
@ -111,24 +109,23 @@ public class Survey extends ContentPage {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
public void setStartDate(Date startDate) {
|
public void setStartDate(Date startDate) {
|
||||||
set(START_DATE, startDate);
|
set(START_DATE, startDate);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Date getStartDate() {
|
public Date getStartDate() {
|
||||||
return (Date)get(START_DATE);
|
return (Date)get(START_DATE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setEndDate(Date endDate) {
|
public void setEndDate(Date endDate) {
|
||||||
set(END_DATE, endDate);
|
set(END_DATE, endDate);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Date getEndDate() {
|
public Date getEndDate() {
|
||||||
return (Date)get(END_DATE);
|
return (Date)get(END_DATE);
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
public boolean getResponsesPublic() {
|
||||||
public boolean responsesArePublic() {
|
return ((Boolean) get(RESPONSES_PUBLIC));
|
||||||
return ((Boolean) get(RESPONSES_PUBLIC)).booleanValue();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setResponsesPublic(Boolean responsesPublic) {
|
public void setResponsesPublic(Boolean responsesPublic) {
|
||||||
|
|
@ -136,7 +133,6 @@ public class Survey extends ContentPage {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Class methods *********************************************************/
|
/* Class methods *********************************************************/
|
||||||
|
|
||||||
public static Survey retrieve(BigDecimal id)
|
public static Survey retrieve(BigDecimal id)
|
||||||
throws DataObjectNotFoundException {
|
throws DataObjectNotFoundException {
|
||||||
|
|
||||||
|
|
@ -150,25 +146,25 @@ public class Survey extends ContentPage {
|
||||||
|
|
||||||
return survey;
|
return survey;
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
public SurveyResponseCollection getResponses() {
|
public SurveyResponseCollection getResponses() {
|
||||||
return SurveyResponse.retrieveBySurvey(this);
|
return SurveyResponse.retrieveBySurvey(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public SurveyResponseCollection getUserResponses(User user) {
|
public SurveyResponseCollection getUserResponses(User user) {
|
||||||
return SurveyResponse.retrieveBySurvey(this, user);
|
return SurveyResponse.retrieveBySurvey(this, user);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasUserResponded(User user) {
|
public boolean hasUserResponded(User user) {
|
||||||
SurveyResponseCollection responses = getUserResponses(user);
|
SurveyResponseCollection responses = getUserResponses(user);
|
||||||
|
|
||||||
if (responses.next()) {
|
if (responses.next()) {
|
||||||
responses.close();
|
responses.close();
|
||||||
return true;
|
return true;
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
*/
|
return false;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
public DataQuery getLabelDataQuery() {
|
public DataQuery getLabelDataQuery() {
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,12 @@
|
||||||
package com.arsdigita.cms.contenttypes;
|
package com.arsdigita.cms.contenttypes;
|
||||||
|
|
||||||
import com.arsdigita.cms.ContentItem;
|
import com.arsdigita.cms.ContentItem;
|
||||||
import com.arsdigita.cms.ContentType;
|
|
||||||
import com.arsdigita.db.Sequences;
|
import com.arsdigita.db.Sequences;
|
||||||
import com.arsdigita.domain.DataObjectNotFoundException;
|
import com.arsdigita.domain.DataObjectNotFoundException;
|
||||||
import com.arsdigita.formbuilder.PersistentLabel;
|
import com.arsdigita.formbuilder.PersistentLabel;
|
||||||
import com.arsdigita.formbuilder.PersistentWidget;
|
import com.arsdigita.formbuilder.PersistentWidget;
|
||||||
import com.arsdigita.persistence.DataObject;
|
import com.arsdigita.persistence.DataObject;
|
||||||
import com.arsdigita.persistence.OID;
|
import com.arsdigita.persistence.OID;
|
||||||
import com.arsdigita.util.Assert;
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -22,8 +20,6 @@ import java.math.BigDecimal;
|
||||||
*/
|
*/
|
||||||
public class SurveyAnswer extends ContentItem {
|
public class SurveyAnswer extends ContentItem {
|
||||||
|
|
||||||
/** PDL property name for id */
|
|
||||||
public static final String ID = "id";
|
|
||||||
/** PDL property name for label */
|
/** PDL property name for label */
|
||||||
public static final String LABEL = "label";
|
public static final String LABEL = "label";
|
||||||
/** PDL property name for widget */
|
/** PDL property name for widget */
|
||||||
|
|
@ -90,11 +86,8 @@ public class SurveyAnswer extends ContentItem {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* accessors *****************************************************/
|
/* accessors *****************************************************/
|
||||||
public BigDecimal getID() {
|
|
||||||
return (BigDecimal) get(ID);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Class methods ********/
|
/* Class methods ********/
|
||||||
public static SurveyAnswer create(PersistentLabel label,
|
public static SurveyAnswer create(PersistentLabel label,
|
||||||
PersistentWidget widget,
|
PersistentWidget widget,
|
||||||
String value) {
|
String value) {
|
||||||
|
|
@ -115,5 +108,4 @@ public class SurveyAnswer extends ContentItem {
|
||||||
set(WIDGET, widget);
|
set(WIDGET, widget);
|
||||||
set(VALUE, value);
|
set(VALUE, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,6 @@ import com.arsdigita.formbuilder.PersistentWidget;
|
||||||
import com.arsdigita.kernel.User;
|
import com.arsdigita.kernel.User;
|
||||||
import com.arsdigita.persistence.DataObject;
|
import com.arsdigita.persistence.DataObject;
|
||||||
import com.arsdigita.persistence.OID;
|
import com.arsdigita.persistence.OID;
|
||||||
import com.arsdigita.simplesurvey.Survey;
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,8 +16,7 @@
|
||||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
package com.arsdigita.simplesurvey.ui;
|
package com.arsdigita.cms.contenttypes.ui;
|
||||||
|
|
||||||
|
|
||||||
import com.arsdigita.bebop.event.FormProcessListener;
|
import com.arsdigita.bebop.event.FormProcessListener;
|
||||||
import com.arsdigita.bebop.event.FormSectionEvent;
|
import com.arsdigita.bebop.event.FormSectionEvent;
|
||||||
|
|
@ -35,13 +34,11 @@ import java.util.Map;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import com.arsdigita.bebop.FormData;
|
import com.arsdigita.bebop.FormData;
|
||||||
import com.arsdigita.bebop.PageState;
|
import com.arsdigita.bebop.PageState;
|
||||||
import com.arsdigita.bebop.RequestLocal;
|
|
||||||
|
|
||||||
import com.arsdigita.simplesurvey.Survey;
|
|
||||||
import com.arsdigita.simplesurvey.Response;
|
|
||||||
import com.arsdigita.bebop.RequestLocal;
|
import com.arsdigita.bebop.RequestLocal;
|
||||||
import com.arsdigita.simplesurvey.ui.Question;
|
|
||||||
import com.arsdigita.bebop.parameters.ParameterData;
|
import com.arsdigita.bebop.parameters.ParameterData;
|
||||||
|
import com.arsdigita.cms.contenttypes.Survey;
|
||||||
|
import com.arsdigita.cms.contenttypes.SurveyResponse;
|
||||||
import com.arsdigita.persistence.DataAssociationCursor;
|
import com.arsdigita.persistence.DataAssociationCursor;
|
||||||
import com.arsdigita.persistence.DataOperation;
|
import com.arsdigita.persistence.DataOperation;
|
||||||
import com.arsdigita.persistence.SessionManager;
|
import com.arsdigita.persistence.SessionManager;
|
||||||
|
|
@ -58,135 +55,136 @@ import org.apache.log4j.Logger;
|
||||||
/**
|
/**
|
||||||
* The process lister that processes a survey response entered by a user.
|
* The process lister that processes a survey response entered by a user.
|
||||||
*
|
*
|
||||||
* @author <a href="mailto:pmarklun@arsdigita.com">Peter Marklund</a>
|
|
||||||
* @version $Id: SurveyProcessListener.java 759 2005-09-02 15:25:32Z sskracic $
|
|
||||||
*/
|
*/
|
||||||
public class SurveyProcessListener
|
public class SurveyProcessListener
|
||||||
implements FormProcessListener {
|
implements FormProcessListener {
|
||||||
|
|
||||||
public static final String SURVEY_ID_NAME = "__ss_survey_id__";
|
public static final String SURVEY_ID_NAME = "__ss_survey_id__";
|
||||||
public static final String RESPONSE_ID = "__ss_response_id__";
|
public static final String RESPONSE_ID = "__ss_response_id__";
|
||||||
|
|
||||||
public static final BigDecimal THE_PUBLIC_USER = new BigDecimal(-200);
|
public static final BigDecimal THE_PUBLIC_USER = new BigDecimal(-200);
|
||||||
private static final String KNOWLEDGE_TEST = "knowledge_test";
|
private static final String KNOWLEDGE_TEST = "knowledge_test";
|
||||||
protected RequestLocal m_persistentForm = new RequestLocal();
|
protected RequestLocal m_persistentForm = new RequestLocal();
|
||||||
private RequestLocal m_nameQuestionMap = new RequestLocal();
|
private RequestLocal m_nameQuestionMap = new RequestLocal();
|
||||||
private RequestLocal m_response;
|
private RequestLocal m_response;
|
||||||
|
private static org.apache.log4j.Logger s_log =
|
||||||
private static org.apache.log4j.Logger s_log =
|
Logger.getLogger(SurveyProcessListener.class.getName());
|
||||||
Logger.getLogger(SurveyProcessListener.class.getName());
|
|
||||||
|
|
||||||
public SurveyProcessListener(RequestLocal response) {
|
public SurveyProcessListener(RequestLocal response) {
|
||||||
m_response = response;
|
m_response = response;
|
||||||
}
|
}
|
||||||
|
|
||||||
public SurveyProcessListener() {
|
public SurveyProcessListener() {
|
||||||
m_response = null;
|
m_response = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void process(FormSectionEvent event) {
|
public void process(FormSectionEvent event) {
|
||||||
|
|
||||||
FormData formData = event.getFormData();
|
FormData formData = event.getFormData();
|
||||||
PageState ps = event.getPageState();
|
PageState ps = event.getPageState();
|
||||||
|
|
||||||
BigDecimal surveyID = (BigDecimal)formData.get(SURVEY_ID_NAME);
|
BigDecimal surveyID = (BigDecimal) formData.get(SURVEY_ID_NAME);
|
||||||
BigDecimal responseID = (BigDecimal)formData.get(RESPONSE_ID);
|
BigDecimal responseID = (BigDecimal) formData.get(RESPONSE_ID);
|
||||||
m_response.set(ps, responseID);
|
m_response.set(ps, responseID);
|
||||||
|
|
||||||
Survey survey = (Survey) FormBuilderUtil.instantiateObjectOneArg(Survey.class.getName(), surveyID);
|
Survey survey = (Survey) FormBuilderUtil.instantiateObjectOneArg(Survey.class.getName(), surveyID);
|
||||||
Response response = null;
|
SurveyResponse response = null;
|
||||||
try {
|
try {
|
||||||
response = (Response) DomainObjectFactory.newInstance( new OID(Response.class.getName(), responseID));
|
response = (SurveyResponse) DomainObjectFactory.newInstance(new OID(SurveyResponse.class.getName(), responseID));
|
||||||
} catch (DataObjectNotFoundException ex) {
|
} catch (DataObjectNotFoundException ex) {
|
||||||
// s_log.warn("Can't create this object" + responseID);
|
// s_log.warn("Can't create this object" + responseID);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Let's not save the data twice in the case of a double-click
|
//Let's not save the data twice in the case of a double-click
|
||||||
if ( response.questionsAnswered() ) {
|
if (response.questionsAnswered()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_persistentForm.set(ps, survey.getForm());
|
m_persistentForm.set(ps, survey.getForm());
|
||||||
|
|
||||||
// Get the responding user
|
// Get the responding user
|
||||||
User user = KernelHelper.getCurrentUser(ps.getRequest());
|
User user = KernelHelper.getCurrentUser(ps.getRequest());
|
||||||
|
|
||||||
// Use the generic user "The Public" if the user is not registered
|
// Use the generic user "The Public" if the user is not registered
|
||||||
if ( user == null) {
|
if (user == null) {
|
||||||
try {
|
try {
|
||||||
user = User.retrieve(THE_PUBLIC_USER);
|
user = User.retrieve(THE_PUBLIC_USER);
|
||||||
} catch ( DataObjectNotFoundException e ) {
|
} catch (DataObjectNotFoundException e) {
|
||||||
s_log.error("Public User does not exist.");
|
s_log.error("Public User does not exist.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Iterate over the widget parameters and insert the answers to the survey response
|
// Iterate over the widget parameters and insert the answers to the survey response
|
||||||
Iterator parameterIter = formData.getParameters().iterator();
|
Iterator parameterIter = formData.getParameters().iterator();
|
||||||
while (parameterIter.hasNext()) {
|
while (parameterIter.hasNext()) {
|
||||||
s_log.warn("Found some formData");
|
s_log.warn("Found some formData");
|
||||||
ParameterData parameterData = (ParameterData)parameterIter.next();
|
ParameterData parameterData = (ParameterData) parameterIter.next();
|
||||||
|
|
||||||
String parameterName = (String)parameterData.getName();
|
String parameterName = (String) parameterData.getName();
|
||||||
|
|
||||||
Object parameterValue = parameterData.getValue();
|
Object parameterValue = parameterData.getValue();
|
||||||
if (parameterValue instanceof java.lang.String[]) {
|
if (parameterValue instanceof java.lang.String[]) {
|
||||||
// This is a multi-answer question - iterate over the
|
// This is a multi-answer question - iterate over the
|
||||||
// answer values and add them one by one
|
// answer values and add them one by one
|
||||||
String[] valueArray = (String[])parameterValue;
|
String[] valueArray = (String[]) parameterValue;
|
||||||
for (int i = 0; i < valueArray.length; ++i) {
|
for (int i = 0; i < valueArray.length; ++i) {
|
||||||
addAnswer(response, ps, valueArray[i], parameterName);
|
// addAnswer(response, ps, valueArray[i], parameterName);
|
||||||
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Single answer question
|
// Single answer question
|
||||||
|
|
||||||
addAnswer(response, ps, parameterValue, parameterName);
|
// addAnswer(response, ps, parameterValue, parameterName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Save the survey response to the database
|
// Save the survey response to the database
|
||||||
response.save();
|
response.save();
|
||||||
saveScore(survey, response);
|
// saveScore(survey, response);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void saveScore(Survey survey, Response response) {
|
/*
|
||||||
|
private void saveScore(Survey survey, SurveyResponse response) {
|
||||||
|
|
||||||
String query;
|
String query;
|
||||||
if ( survey.getQuizType().equals(KNOWLEDGE_TEST) ) {
|
if (survey.getQuizType().equals(KNOWLEDGE_TEST)) {
|
||||||
query = "com.arsdigita.simplesurvey.saveScore";
|
query = "com.arsdigita.simplesurvey.saveScore";
|
||||||
} else {
|
} else {
|
||||||
query = "com.arsdigita.simplesurvey.saveAssessmentScore";
|
query = "com.arsdigita.simplesurvey.saveAssessmentScore";
|
||||||
}
|
}
|
||||||
DataOperation dao = SessionManager.getSession().retrieveDataOperation(query);
|
DataOperation dao = SessionManager.getSession().retrieveDataOperation(query);
|
||||||
dao.setParameter("responseID", response.getID());
|
dao.setParameter("responseID", response.getID());
|
||||||
dao.execute();
|
dao.execute();
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
/*
|
||||||
|
private void addAnswer(SurveyResponse surveyResponse,
|
||||||
|
PageState ps,
|
||||||
|
Object parameterValue,
|
||||||
|
String parameterName) {
|
||||||
|
|
||||||
private void addAnswer(Response surveyResponse,
|
s_log.debug("formData name " + parameterName + " value " + parameterValue);
|
||||||
PageState ps,
|
|
||||||
Object parameterValue,
|
|
||||||
String parameterName) {
|
|
||||||
|
|
||||||
s_log.debug("formData name " + parameterName + " value " + parameterValue);
|
Question question = getQuestion(ps, parameterName);
|
||||||
|
|
||||||
Question question = getQuestion(ps, parameterName);
|
|
||||||
|
|
||||||
if (question != null ) {
|
if (question != null) {
|
||||||
|
|
||||||
PersistentLabel persistentLabel = question.getLabel();
|
PersistentLabel persistentLabel = question.getLabel();
|
||||||
PersistentWidget persistentWidget = question.getWidget();
|
PersistentWidget persistentWidget = question.getWidget();
|
||||||
|
|
||||||
surveyResponse.addAnswer(persistentLabel, persistentWidget, getStringValue(parameterValue));
|
surveyResponse.addAnswer(persistentLabel, persistentWidget, getStringValue(parameterValue));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
/*
|
||||||
private String getStringValue(Object parameterValue) {
|
private String getStringValue(Object parameterValue) {
|
||||||
|
|
||||||
return parameterValue == null ? "" : parameterValue.toString();
|
return parameterValue == null ? "" : parameterValue.toString();
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
/*
|
||||||
protected Question getQuestion(PageState ps, String parameterName) {
|
protected Question getQuestion(PageState ps, String parameterName) {
|
||||||
|
|
||||||
if (m_nameQuestionMap.get(ps) == null) {
|
if (m_nameQuestionMap.get(ps) == null) {
|
||||||
|
|
||||||
// Populate the parameter name label id map
|
// Populate the parameter name label id map
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
|
|
||||||
|
|
@ -194,7 +192,7 @@ public class SurveyProcessListener
|
||||||
|
|
||||||
s_log.debug("initializing the parameter name persistent label map");
|
s_log.debug("initializing the parameter name persistent label map");
|
||||||
|
|
||||||
PersistentForm persistentForm = (PersistentForm)m_persistentForm.get(ps);
|
PersistentForm persistentForm = (PersistentForm) m_persistentForm.get(ps);
|
||||||
DataAssociationCursor componentCursor = persistentForm.getComponents();
|
DataAssociationCursor componentCursor = persistentForm.getComponents();
|
||||||
PersistentLabel lastPersistentLabel = null;
|
PersistentLabel lastPersistentLabel = null;
|
||||||
while (componentCursor.next()) {
|
while (componentCursor.next()) {
|
||||||
|
|
@ -205,20 +203,20 @@ public class SurveyProcessListener
|
||||||
|
|
||||||
// If this is a PersistentLabel save its id
|
// If this is a PersistentLabel save its id
|
||||||
if (factory instanceof com.arsdigita.formbuilder.PersistentLabel) {
|
if (factory instanceof com.arsdigita.formbuilder.PersistentLabel) {
|
||||||
|
|
||||||
lastPersistentLabel = (PersistentLabel)factory;
|
lastPersistentLabel = (PersistentLabel) factory;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add the previous label id if this is a PersistentWidget
|
// Add the previous label id if this is a PersistentWidget
|
||||||
if (factory instanceof com.arsdigita.formbuilder.PersistentWidget) {
|
if (factory instanceof com.arsdigita.formbuilder.PersistentWidget) {
|
||||||
|
|
||||||
s_log.debug("adding to map " + ((PersistentWidget)factory).getParameterName() +
|
s_log.debug("adding to map " + ((PersistentWidget) factory).getParameterName() +
|
||||||
" mapped to " + lastPersistentLabel);
|
" mapped to " + lastPersistentLabel);
|
||||||
|
|
||||||
Question question = new Question(lastPersistentLabel,
|
Question question = new Question(lastPersistentLabel,
|
||||||
(PersistentWidget)factory);
|
(PersistentWidget) factory);
|
||||||
|
|
||||||
nameQuestionMap.put(((PersistentWidget)factory).getParameterName(), question);
|
nameQuestionMap.put(((PersistentWidget) factory).getParameterName(), question);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -228,10 +226,12 @@ public class SurveyProcessListener
|
||||||
|
|
||||||
s_log.debug("fetching label for parameter name " + parameterName);
|
s_log.debug("fetching label for parameter name " + parameterName);
|
||||||
|
|
||||||
Question question = (Question)((Map)m_nameQuestionMap.get(ps)).get(parameterName);
|
Question question = (Question) ((Map) m_nameQuestionMap.get(ps)).get(parameterName);
|
||||||
|
|
||||||
s_log.debug("returning " + question);
|
s_log.debug("returning " + question);
|
||||||
|
|
||||||
return question;
|
return question;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,178 +18,124 @@
|
||||||
*/
|
*/
|
||||||
package com.arsdigita.cms.contenttypes.ui;
|
package com.arsdigita.cms.contenttypes.ui;
|
||||||
|
|
||||||
|
import com.arsdigita.cms.contenttypes.util.SurveyGlobalizationUtil;
|
||||||
import com.arsdigita.cms.contenttypes.util.SurveyGlobalizationUtil ;
|
|
||||||
|
|
||||||
import com.arsdigita.bebop.event.FormSectionEvent;
|
import com.arsdigita.bebop.event.FormSectionEvent;
|
||||||
import com.arsdigita.bebop.event.FormProcessListener;
|
import com.arsdigita.bebop.event.FormProcessListener;
|
||||||
import com.arsdigita.bebop.event.FormInitListener;
|
import com.arsdigita.bebop.event.FormInitListener;
|
||||||
|
|
||||||
import com.arsdigita.bebop.parameters.NotWhiteSpaceValidationListener;
|
|
||||||
import com.arsdigita.bebop.Form;
|
|
||||||
import com.arsdigita.bebop.FormProcessException;
|
import com.arsdigita.bebop.FormProcessException;
|
||||||
import com.arsdigita.bebop.PageState;
|
|
||||||
import com.arsdigita.bebop.Label;
|
import com.arsdigita.bebop.Label;
|
||||||
import com.arsdigita.bebop.BlockStylable;
|
import com.arsdigita.bebop.FormData;
|
||||||
import com.arsdigita.bebop.form.TextField;
|
import com.arsdigita.bebop.event.FormSubmissionListener;
|
||||||
import com.arsdigita.bebop.form.TextArea;
|
import com.arsdigita.bebop.form.TextArea;
|
||||||
import com.arsdigita.bebop.form.Date;
|
|
||||||
import com.arsdigita.bebop.form.Submit;
|
|
||||||
import com.arsdigita.bebop.form.RadioGroup;
|
import com.arsdigita.bebop.form.RadioGroup;
|
||||||
import com.arsdigita.bebop.form.Option;
|
import com.arsdigita.bebop.form.Option;
|
||||||
|
|
||||||
import com.arsdigita.formbuilder.PersistentForm;
|
|
||||||
|
|
||||||
|
import com.arsdigita.bebop.parameters.ParameterModel;
|
||||||
|
import com.arsdigita.bebop.parameters.StringInRangeValidationListener;
|
||||||
|
import com.arsdigita.bebop.parameters.StringParameter;
|
||||||
|
import com.arsdigita.cms.ItemSelectionModel;
|
||||||
import com.arsdigita.cms.contenttypes.Survey;
|
import com.arsdigita.cms.contenttypes.Survey;
|
||||||
|
|
||||||
import java.util.Calendar;
|
import com.arsdigita.cms.ui.authoring.BasicPageForm;
|
||||||
import java.util.GregorianCalendar;
|
|
||||||
import java.lang.Boolean;
|
|
||||||
|
|
||||||
public class SurveyPropertiesForm extends Form {
|
public class SurveyPropertiesForm extends BasicPageForm implements FormProcessListener, FormInitListener, FormSubmissionListener {
|
||||||
|
|
||||||
private SurveySelectionModel m_survey;
|
|
||||||
private Class m_type;
|
|
||||||
|
|
||||||
|
private SurveyPropertiesStep m_step;
|
||||||
|
public static final String DESCRIPTION = Survey.DESCRIPTION;
|
||||||
|
// public static final String START_DATE = Survey.START_DATE;
|
||||||
|
// public static final String END_DATE = Survey.END_DATE;
|
||||||
|
public static final String RESPONSES_PUBLIC = Survey.RESPONSES_PUBLIC;
|
||||||
|
/**
|
||||||
|
* ID of the form
|
||||||
|
*/
|
||||||
|
public static final String ID = "Survey_edit";
|
||||||
|
|
||||||
private TextField m_surveyName;
|
/**
|
||||||
private TextArea m_description;
|
* Constrctor taking an ItemSelectionModel
|
||||||
private Date m_startDate;
|
*
|
||||||
private Date m_endDate;
|
* @param itemModel
|
||||||
private RadioGroup m_responsesPublic;
|
*/
|
||||||
private RadioGroup m_quizType;
|
public SurveyPropertiesForm(ItemSelectionModel itemModel) {
|
||||||
|
this(itemModel, null);
|
||||||
public PropertiesForm(SurveySelectionModel survey,
|
|
||||||
Class type) {
|
|
||||||
|
|
||||||
super("properties" + type.getName());
|
|
||||||
|
|
||||||
m_survey = survey;
|
|
||||||
m_type = type;
|
|
||||||
|
|
||||||
m_surveyName = new TextField("surveyName");
|
|
||||||
m_surveyName.addValidationListener(new NotWhiteSpaceValidationListener());
|
|
||||||
m_description = new TextArea("description");
|
|
||||||
|
|
||||||
|
|
||||||
m_startDate = new Date("startDate");
|
|
||||||
m_endDate = new Date("endDate");
|
|
||||||
|
|
||||||
add(new Label(GlobalizationUtil.globalize("simplesurvey.ui.admin.name")));
|
|
||||||
add(m_surveyName);
|
|
||||||
|
|
||||||
add(new Label(GlobalizationUtil.globalize("simplesurvey.ui.admin.description")));
|
|
||||||
m_description.setRows(20);
|
|
||||||
m_description.setCols(60);
|
|
||||||
add(m_description);
|
|
||||||
|
|
||||||
add(new Label(GlobalizationUtil.globalize("simplesurvey.ui.admin.start_date")));
|
|
||||||
add(m_startDate);
|
|
||||||
|
|
||||||
add(new Label(GlobalizationUtil.globalize("simplesurvey.ui.admin.end_date")));
|
|
||||||
add(m_endDate);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
add(new Label(GlobalizationUtil.globalize("simplesurvey.ui.admin.should_quiz_responses_be_public")));
|
|
||||||
m_responsesPublic = new RadioGroup("responsesPublic");
|
|
||||||
Option o1 = new Option("true", new Label(GlobalizationUtil.globalize("simplesurvey.ui.admin.Yes")));
|
|
||||||
Option o2 = new Option("false", new Label(GlobalizationUtil.globalize("simplesurvey.ui.admin.No")));
|
|
||||||
m_responsesPublic.addOption(o1);
|
|
||||||
m_responsesPublic.addOption(o2);
|
|
||||||
add(m_responsesPublic);
|
|
||||||
|
|
||||||
// There can be 2 kinds of quizzes: the knowledge test kind of quiz and the personality assessment kind
|
|
||||||
add(new Label(GlobalizationUtil.globalize("simplesurvey.ui.admin.what_type_of_quiz_is_this")));
|
|
||||||
m_quizType = new RadioGroup("quizType");
|
|
||||||
Option o3 = new Option("knowledge_test", new Label(GlobalizationUtil.globalize("simplesurvey.ui.admin.knowledge_test_quiz")));
|
|
||||||
Option o4 = new Option("personal_assessment", new Label(GlobalizationUtil.globalize("simplesurvey.ui.admin.personal_assessment_quiz")));
|
|
||||||
m_quizType.addOption(o3);
|
|
||||||
m_quizType.addOption(o4);
|
|
||||||
add(m_quizType);
|
|
||||||
|
|
||||||
add(new Submit("submit"), BlockStylable.CENTER);
|
|
||||||
addInitListener(new SurveyInitListener());
|
|
||||||
addProcessListener(new PropertiesFormProcessListener());
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private class SurveyInitListener implements FormInitListener {
|
|
||||||
public void init(FormSectionEvent e)
|
|
||||||
throws FormProcessException {
|
|
||||||
PageState state = e.getPageState();
|
|
||||||
|
|
||||||
if (m_survey.isSelected(state)) {
|
|
||||||
Survey survey = m_survey.getSelectedSurvey(state);
|
|
||||||
PersistentForm form = survey.getForm();
|
|
||||||
|
|
||||||
m_surveyName.setValue(state, form.getAdminName());
|
|
||||||
m_description.setValue(state, form.getDescription());
|
|
||||||
m_startDate.setValue(state, survey.getStartDate());
|
|
||||||
m_endDate.setValue(state, survey.getEndDate());
|
|
||||||
m_quizType.setValue(state, survey.getQuizType());
|
|
||||||
if ( survey.responsesArePublic() ) {
|
|
||||||
m_responsesPublic.setValue(state, "true");
|
|
||||||
} else {
|
|
||||||
m_responsesPublic.setValue(state,"false");
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
m_surveyName.setValue(state, "");
|
|
||||||
m_description.setValue(state, "");
|
|
||||||
|
|
||||||
Calendar startCalendar = new GregorianCalendar();
|
|
||||||
startCalendar.add(Calendar.DATE, 0);
|
|
||||||
java.util.Date startDate = startCalendar.getTime();
|
|
||||||
Calendar endCalendar = new GregorianCalendar();
|
|
||||||
endCalendar.add(Calendar.DATE, 15);
|
|
||||||
java.util.Date endDate = endCalendar.getTime();
|
|
||||||
|
|
||||||
m_startDate.setValue(state, startDate);
|
|
||||||
m_endDate.setValue(state, endDate);
|
|
||||||
m_responsesPublic.setValue(state, "true");
|
|
||||||
m_quizType.setValue(state, "knowledge_test");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private class PropertiesFormProcessListener implements FormProcessListener {
|
/**
|
||||||
public void process(FormSectionEvent e)
|
* Constrctor taking an ItemSelectionModel and an instance of BaseContactPropertiesStep.
|
||||||
throws FormProcessException {
|
*
|
||||||
PageState state = e.getPageState();
|
* @param itemModel
|
||||||
|
* @param step
|
||||||
Survey survey;
|
*/
|
||||||
PersistentForm form;
|
public SurveyPropertiesForm(ItemSelectionModel itemModel, SurveyPropertiesStep step) {
|
||||||
|
super(ID, itemModel);
|
||||||
if (m_survey.isSelected(state)) {
|
m_step = step;
|
||||||
survey = m_survey.getSelectedSurvey(state);
|
addSubmissionListener(this);
|
||||||
form = survey.getForm();
|
}
|
||||||
} else {
|
|
||||||
survey = m_type.equals(Survey.class) ? new Survey() : new Poll();
|
|
||||||
survey.setPackageInstance(SimpleSurveyUtil.getPackageInstance(state));
|
|
||||||
form = new PersistentForm();
|
|
||||||
survey.setForm(form);
|
|
||||||
}
|
|
||||||
|
|
||||||
form.setAdminName((String)m_surveyName.getValue(state));
|
|
||||||
form.setHTMLName(getHTMLName((String)m_surveyName.getValue(state)));
|
|
||||||
form.setDescription((String)m_description.getValue(state));
|
|
||||||
form.save();
|
|
||||||
|
|
||||||
survey.setStartDate((java.util.Date)m_startDate.getValue(state));
|
|
||||||
survey.setEndDate((java.util.Date)m_endDate.getValue(state));
|
|
||||||
survey.setResponsesPublic(new Boolean((String) m_responsesPublic.getValue(state)));
|
|
||||||
survey.setQuizType((String) m_quizType.getValue(state));
|
|
||||||
survey.save();
|
|
||||||
}
|
|
||||||
|
|
||||||
private String getHTMLName(String surveyName) {
|
@Override
|
||||||
|
public void addWidgets() {
|
||||||
String htmlName = surveyName.trim().toLowerCase();
|
super.addWidgets();
|
||||||
|
|
||||||
htmlName = htmlName.replace(' ', '_');
|
|
||||||
|
|
||||||
return htmlName;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
add(new Label((String) SurveyGlobalizationUtil.globalize("cms.contenttypes.survey.ui.admin.description").localize()));
|
||||||
|
ParameterModel descriptionParam = new StringParameter(DESCRIPTION);
|
||||||
|
descriptionParam.addParameterListener(new StringInRangeValidationListener(0, 4000));
|
||||||
|
TextArea description = new TextArea(descriptionParam);
|
||||||
|
description.setRows(20);
|
||||||
|
description.setCols(60);
|
||||||
|
add(description);
|
||||||
|
|
||||||
|
// add(new Label(SurveyGlobalizationUtil.globalize("simplesurvey.ui.admin.start_date")));
|
||||||
|
// add(m_startDate);
|
||||||
|
//
|
||||||
|
// add(new Label(SurveyGlobalizationUtil.globalize("simplesurvey.ui.admin.end_date")));
|
||||||
|
// add(m_endDate);
|
||||||
|
|
||||||
|
add(new Label((String) SurveyGlobalizationUtil.globalize("cms.contenttypes.survey.ui.admin.should_quiz_responses_be_public").localize()));
|
||||||
|
RadioGroup responsesPublic = new RadioGroup("responsesPublic");
|
||||||
|
Option rp1 = new Option("true", new Label((String) SurveyGlobalizationUtil.globalize("cms.contenttypes.survey.ui.Yes").localize()));
|
||||||
|
Option rp2 = new Option("false", new Label((String) SurveyGlobalizationUtil.globalize("cms.contenttypes.survey.ui.No").localize()));
|
||||||
|
responsesPublic.addOption(rp1);
|
||||||
|
responsesPublic.addOption(rp2);
|
||||||
|
add(responsesPublic);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void init(FormSectionEvent e) throws FormProcessException {
|
||||||
|
FormData data = e.getFormData();
|
||||||
|
Survey survey = (Survey) super.initBasicWidgets(e);
|
||||||
|
|
||||||
|
data.put(DESCRIPTION, survey.getDescription());
|
||||||
|
// data.put(START_DATE, survey.getStartDate());
|
||||||
|
// data.put(END_DATE, survey.getEndDate());
|
||||||
|
data.put(RESPONSES_PUBLIC, survey.getResponsesPublic());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void process(FormSectionEvent e) throws FormProcessException {
|
||||||
|
FormData data = e.getFormData();
|
||||||
|
|
||||||
|
Survey survey = (Survey) super.processBasicWidgets(e);
|
||||||
|
|
||||||
|
if ((survey != null) && (getSaveCancelSection().getSaveButton().isSelected(e.getPageState()))) {
|
||||||
|
survey.setDescription((String) data.get(DESCRIPTION));
|
||||||
|
// survey.setStartDate((String)data.get(START_DATE));
|
||||||
|
// survey.setEndDate((String)data.get(END_DATE));
|
||||||
|
survey.setResponsesPublic((Boolean) data.get(RESPONSES_PUBLIC));
|
||||||
|
|
||||||
|
survey.save();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_step != null) {
|
||||||
|
m_step.maybeForwardToNextStep(e.getPageState());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void submitted(FormSectionEvent e) throws FormProcessException {
|
||||||
|
if ((m_step != null) && (getSaveCancelSection().getCancelButton().isSelected(e.getPageState()))) {
|
||||||
|
m_step.cancelStreamlinedCreation(e.getPageState());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,6 @@ import com.arsdigita.cms.util.GlobalizationUtil;
|
||||||
import com.arsdigita.bebop.Component;
|
import com.arsdigita.bebop.Component;
|
||||||
import com.arsdigita.bebop.Label;
|
import com.arsdigita.bebop.Label;
|
||||||
import com.arsdigita.bebop.SegmentedPanel;
|
import com.arsdigita.bebop.SegmentedPanel;
|
||||||
import com.arsdigita.cms.contenttypes.Survey;
|
|
||||||
import com.arsdigita.cms.contenttypes.util.SurveyGlobalizationUtil;
|
import com.arsdigita.cms.contenttypes.util.SurveyGlobalizationUtil;
|
||||||
|
|
||||||
import java.text.DateFormat;
|
import java.text.DateFormat;
|
||||||
|
|
@ -26,7 +25,6 @@ import org.apache.log4j.Logger;
|
||||||
public class SurveyPropertiesStep extends SimpleEditStep {
|
public class SurveyPropertiesStep extends SimpleEditStep {
|
||||||
|
|
||||||
private static final Logger logger = Logger.getLogger(SurveyPropertiesStep.class);
|
private static final Logger logger = Logger.getLogger(SurveyPropertiesStep.class);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Name of the this edit sheet (Don't know if this this really needed.
|
* Name of the this edit sheet (Don't know if this this really needed.
|
||||||
* It has the same value in almost all PropertiesStep classes)
|
* It has the same value in almost all PropertiesStep classes)
|
||||||
|
|
@ -44,70 +42,58 @@ public class SurveyPropertiesStep extends SimpleEditStep {
|
||||||
|
|
||||||
/* Use a Segmented Panel for the multiple parts of data */
|
/* Use a Segmented Panel for the multiple parts of data */
|
||||||
SegmentedPanel segmentedPanel = new SegmentedPanel();
|
SegmentedPanel segmentedPanel = new SegmentedPanel();
|
||||||
|
|
||||||
setDefaultEditKey(EDIT_BASIC_SHEET_NAME);
|
setDefaultEditKey(EDIT_BASIC_SHEET_NAME);
|
||||||
|
|
||||||
/* The different parts of information are displayed in seperated segments each containing a SimpleEditStep */
|
/* The different parts of information are displayed in seperated segments each containing a SimpleEditStep */
|
||||||
/* Well, not so simple anymore... */
|
/* Well, not so simple anymore... */
|
||||||
|
|
||||||
/* A new SimpleEditStep */
|
/* A new SimpleEditStep */
|
||||||
SimpleEditStep basicProperties = new SimpleEditStep(itemModel, parent, EDIT_BASIC_SHEET_NAME);
|
SimpleEditStep basicProperties = new SimpleEditStep(itemModel, parent, EDIT_BASIC_SHEET_NAME);
|
||||||
|
|
||||||
/* Create the edit component for this SimpleEditStep and the corresponding link */
|
/* Create the edit component for this SimpleEditStep and the corresponding link */
|
||||||
BasicPageForm editBasicSheet = new SurveyPropertyForm(itemModel, this);
|
BasicPageForm editBasicSheet = new SurveyPropertiesForm(itemModel, this);
|
||||||
basicProperties.add(EDIT_BASIC_SHEET_NAME, (String)SurveyGlobalizationUtil.globalize("cms.contenttypes.ui.survey.edit_basic_properties").localize(), new WorkflowLockedComponentAccess(editBasicSheet, itemModel), editBasicSheet.getSaveCancelSection().getCancelButton());
|
basicProperties.add(EDIT_BASIC_SHEET_NAME, (String) SurveyGlobalizationUtil.globalize("cms.contenttypes.ui.survey.edit_basic_properties").localize(), new WorkflowLockedComponentAccess(editBasicSheet, itemModel), editBasicSheet.getSaveCancelSection().getCancelButton());
|
||||||
|
|
||||||
/* Set the displayComponent for this step */
|
/* Set the displayComponent for this step */
|
||||||
basicProperties.setDisplayComponent(getSurveyPropertySheet(itemModel));
|
basicProperties.setDisplayComponent(getSurveyPropertiesSheet(itemModel));
|
||||||
|
|
||||||
/* Add the SimpleEditStep to the segmented panel */
|
/* Add the SimpleEditStep to the segmented panel */
|
||||||
segmentedPanel.addSegment(new Label((String)SurveyGlobalizationUtil.globalize("cms.contenttypes.ui.survey.basic_properties").localize()), basicProperties);
|
segmentedPanel.addSegment(new Label((String) SurveyGlobalizationUtil.globalize("cms.contenttypes.ui.survey.basic_properties").localize()), basicProperties);
|
||||||
|
|
||||||
// If not disabled via registry, add the ui for attaching a person
|
// Add the ui for attaching a FormSection
|
||||||
if(!Survey.getConfig().getHidePerson()) {
|
// SurveyPersonPropertiesStep personProperties = new SurveyPersonPropertiesStep(itemModel, parent);
|
||||||
SurveyPersonPropertiesStep personProperties = new SurveyPersonPropertiesStep(itemModel, parent);
|
// segmentedPanel.addSegment(new Label((String) SurveyGlobalizationUtil.globalize("cms.contenttypes.ui.survey.person").localize()), personProperties);
|
||||||
segmentedPanel.addSegment(new Label((String)SurveyGlobalizationUtil.globalize("cms.contenttypes.ui.survey.person").localize()), personProperties);
|
|
||||||
}
|
|
||||||
|
|
||||||
// If not disabled via registry, add the ui for attaching a baseAddress
|
|
||||||
if(!Survey.getConfig().getHideAddress()) {
|
|
||||||
SurveyAddressPropertiesStep addressProperties = new SurveyAddressPropertiesStep(itemModel, parent);
|
|
||||||
segmentedPanel.addSegment(new Label((String)SurveyGlobalizationUtil.globalize("cms.contenttypes.ui.survey.address").localize()), addressProperties);
|
|
||||||
}
|
|
||||||
|
|
||||||
SurveyEntriesPropertiesStep surveyEntries = new SurveyEntriesPropertiesStep(itemModel, parent);
|
|
||||||
segmentedPanel.addSegment(new Label((String)SurveyGlobalizationUtil.globalize("cms.contenttypes.ui.survey.contactEntry").localize()), surveyEntries);
|
|
||||||
|
|
||||||
/* Sets the composed segmentedPanel as display component */
|
/* Sets the composed segmentedPanel as display component */
|
||||||
setDisplayComponent(segmentedPanel);
|
setDisplayComponent(segmentedPanel);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates and returns the sheet for editing the basic properties
|
* Creates and returns the sheet for editing the basic properties
|
||||||
* of an organization. (@see SurveyPropertyForm).
|
* of a survey. (@see SurveyPropertiesForm).
|
||||||
*
|
*
|
||||||
* @param itemModel
|
* @param itemModel
|
||||||
* @return The sheet for editing the properties of the organization.
|
* @return The sheet for editing the properties of the organization.
|
||||||
*/
|
*/
|
||||||
public static Component getSurveyPropertySheet(ItemSelectionModel itemModel) {
|
public static Component getSurveyPropertiesSheet(ItemSelectionModel itemModel) {
|
||||||
|
|
||||||
|
|
||||||
/* The DisplayComponent for the Basic Properties */
|
/* The DisplayComponent for the Basic Properties */
|
||||||
DomainObjectPropertySheet sheet = new DomainObjectPropertySheet(itemModel);
|
DomainObjectPropertySheet sheet = new DomainObjectPropertySheet(itemModel);
|
||||||
|
|
||||||
sheet.add(GlobalizationUtil.globalize("cms.contenttypes.ui.name"),"name");
|
sheet.add(GlobalizationUtil.globalize("cms.contenttypes.ui.name"), "name");
|
||||||
sheet.add(GlobalizationUtil.globalize("cms.contenttypes.ui.title"),"title");
|
sheet.add(GlobalizationUtil.globalize("cms.contenttypes.ui.title"), "title");
|
||||||
|
|
||||||
if(!ContentSection.getConfig().getHideLaunchDate()) {
|
if (!ContentSection.getConfig().getHideLaunchDate()) {
|
||||||
sheet.add(GlobalizationUtil.globalize("cms.ui.authoring.page_launch_date"), ContentPage.LAUNCH_DATE, new DomainObjectPropertySheet.AttributeFormatter() {
|
sheet.add(GlobalizationUtil.globalize("cms.ui.authoring.page_launch_date"), ContentPage.LAUNCH_DATE, new DomainObjectPropertySheet.AttributeFormatter() {
|
||||||
|
|
||||||
public String format(DomainObject obj, String attribute, PageState state) {
|
public String format(DomainObject obj, String attribute, PageState state) {
|
||||||
ContentPage page = (ContentPage)obj;
|
ContentPage page = (ContentPage) obj;
|
||||||
if(page.getLaunchDate() != null) {
|
if (page.getLaunchDate() != null) {
|
||||||
return DateFormat.getDateInstance(DateFormat.LONG).format(page.getLaunchDate());
|
return DateFormat.getDateInstance(DateFormat.LONG).format(page.getLaunchDate());
|
||||||
}
|
} else {
|
||||||
else {
|
return (String) GlobalizationUtil.globalize("cms.ui.unknown").localize();
|
||||||
return (String)GlobalizationUtil.globalize("cms.ui.unknown").localize();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
@ -115,5 +101,4 @@ public class SurveyPropertiesStep extends SimpleEditStep {
|
||||||
|
|
||||||
return sheet;
|
return sheet;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -16,14 +16,14 @@
|
||||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
package com.arsdigita.simplesurvey.ui;
|
package com.arsdigita.cms.contenttypes.ui;
|
||||||
|
|
||||||
|
|
||||||
import com.arsdigita.bebop.PageState;
|
import com.arsdigita.bebop.PageState;
|
||||||
|
|
||||||
import com.arsdigita.bebop.parameters.BigDecimalParameter;
|
import com.arsdigita.bebop.parameters.BigDecimalParameter;
|
||||||
|
|
||||||
import com.arsdigita.simplesurvey.Survey;
|
import com.arsdigita.cms.contenttypes.Survey;
|
||||||
|
|
||||||
import com.arsdigita.toolbox.ui.ACSObjectSelectionModel;
|
import com.arsdigita.toolbox.ui.ACSObjectSelectionModel;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue