From 3aaa683233be46d83d245b06433afd2f4b011a13 Mon Sep 17 00:00:00 2001 From: jensp Date: Thu, 18 Apr 2013 13:30:07 +0000 Subject: [PATCH] =?UTF-8?q?F=C3=BCr=20den=20Typ=20SciPublications/Proceedi?= =?UTF-8?q?ngs=20kann=20nun=20konfiguriert=20werden=20ob=20die=20Felder=20?= =?UTF-8?q?*=20Place=20of=20Conference=20*=20Begin=20of=20Conference=20*?= =?UTF-8?q?=20End=20of=20Conference?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Pflichtfelder sind. In der Default-Einstellung sind die Felder Pflichtfelder. git-svn-id: https://svn.libreccm.org/ccm/trunk@2138 8810af33-2d31-482b-a856-94f89814c4df --- .../src/ccm-sci-publications.config | 1 + .../cms/contenttypes/Proceedings.java | 82 ++++++++++--------- .../cms/contenttypes/ProceedingsConfig.java | 56 +++++++++++++ .../ProceedingsConfig_parameter.properties | 14 ++++ .../cms/contenttypes/PublicationsConfig.java | 2 +- .../ui/ProceedingsPropertyForm.java | 63 ++++++++------ 6 files changed, 152 insertions(+), 66 deletions(-) create mode 100644 ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ProceedingsConfig.java create mode 100644 ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ProceedingsConfig_parameter.properties diff --git a/ccm-sci-publications/src/ccm-sci-publications.config b/ccm-sci-publications/src/ccm-sci-publications.config index 65fbdd7f4..efca9399a 100644 --- a/ccm-sci-publications/src/ccm-sci-publications.config +++ b/ccm-sci-publications/src/ccm-sci-publications.config @@ -1,5 +1,6 @@ + diff --git a/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/Proceedings.java b/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/Proceedings.java index af30f9b06..b21235c31 100644 --- a/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/Proceedings.java +++ b/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/Proceedings.java @@ -32,9 +32,8 @@ import java.util.Date; import java.util.List; /** - * Content type of proceedings. Provides attributes for storing the data - * of the conference (name, date, place, organizer) and for linking the papers - * (objects of the content type {@link InProceedings} to a proceedings object. + * Content type of proceedings. Provides attributes for storing the data of the conference (name, date, place, + * organizer) and for linking the papers (objects of the content type {@link InProceedings} to a proceedings object. * * * @author Jens Pelzetter @@ -50,6 +49,7 @@ public class Proceedings extends PublicationWithPublisher { public static final String PAPER_ORDER = "paperOrder"; public static final String BASE_DATA_OBJECT_TYPE = "com.arsdigita.cms.contenttypes.Proceedings"; + private static final ProceedingsConfig PROCEEDINGS_CONFIG = new ProceedingsConfig(); public Proceedings() { super(BASE_DATA_OBJECT_TYPE); @@ -70,7 +70,11 @@ public class Proceedings extends PublicationWithPublisher { public Proceedings(String type) { super(type); } - + + public static ProceedingsConfig getProceedingsConfig() { + return PROCEEDINGS_CONFIG; + } + public ProceedingsBundle getProceedingsBundle() { return (ProceedingsBundle) getContentBundle(); } @@ -78,34 +82,34 @@ public class Proceedings extends PublicationWithPublisher { public GenericOrganizationalUnit getOrganizerOfConference() { /*DataCollection collection; - collection = (DataCollection) get(ORGANIZER_OF_CONFERENCE); + collection = (DataCollection) get(ORGANIZER_OF_CONFERENCE); - if (0 == collection.size()) { - return null; - } else { - DataObject dobj; + if (0 == collection.size()) { + return null; + } else { + DataObject dobj; - collection.next(); - dobj = collection.getDataObject(); - collection.close(); + collection.next(); + dobj = collection.getDataObject(); + collection.close(); + + return (GenericOrganizationalUnit) DomainObjectFactory.newInstance( + dobj); + }*/ - return (GenericOrganizationalUnit) DomainObjectFactory.newInstance( - dobj); - }*/ - final GenericOrganizationalUnitBundle bundle = getProceedingsBundle().getOrganizerOfConference(); - + if (bundle == null) { return null; } else { return (GenericOrganizationalUnit) bundle.getPrimaryInstance(); } } - + public GenericOrganizationalUnit getOrganizerOfConference( final String language) { - final GenericOrganizationalUnitBundle bundle = getProceedingsBundle().getOrganizerOfConference(); - + final GenericOrganizationalUnitBundle bundle = getProceedingsBundle().getOrganizerOfConference(); + if (bundle == null) { return null; } else { @@ -116,18 +120,18 @@ public class Proceedings extends PublicationWithPublisher { public void setOrganizerOfConference(GenericOrganizationalUnit organizer) { /*GenericOrganizationalUnit oldOrga; - oldOrga = getOrganizerOfConference(); - if (oldOrga != null) { - remove(ORGANIZER_OF_CONFERENCE, oldOrga); - } + oldOrga = getOrganizerOfConference(); + if (oldOrga != null) { + remove(ORGANIZER_OF_CONFERENCE, oldOrga); + } + + if (null != organizer) { + Assert.exists(organizer, GenericOrganizationalUnit.class); + DataObject link = add(ORGANIZER_OF_CONFERENCE, organizer); + link.set("organizerOrder", 1); + link.save(); + } */ - if (null != organizer) { - Assert.exists(organizer, GenericOrganizationalUnit.class); - DataObject link = add(ORGANIZER_OF_CONFERENCE, organizer); - link.set("organizerOrder", 1); - link.save(); - } */ - getProceedingsBundle().setOrganizerOfConference(organizer); } @@ -165,38 +169,38 @@ public class Proceedings extends PublicationWithPublisher { public InProceedingsCollection getPapers() { //return new InProceedingsCollection((DataCollection) get(PAPERS)); - + return getProceedingsBundle().getPapers(); } public void addPaper(InProceedings paper) { /*Assert.exists(paper, InProceedings.class); - DataObject link = add(PAPERS, paper); + DataObject link = add(PAPERS, paper); + + link.set(PAPER_ORDER, Integer.valueOf((int) getPapers().size()));*/ - link.set(PAPER_ORDER, Integer.valueOf((int) getPapers().size()));*/ - getProceedingsBundle().addPaper(paper); } public void removePaper(InProceedings paper) { /*Assert.exists(paper, InProceedings.class); - remove(PAPERS, paper);*/ - + remove(PAPERS, paper);*/ + getProceedingsBundle().removePaper(paper); } public boolean hasPapers() { return !this.getPapers().isEmpty(); } - + @Override public List getExtraXMLGenerators() { final List generators = super.getExtraXMLGenerators(); generators.add(new ProceedingsExtraXmlGenerator()); return generators; } - + @Override public List getExtraListXMLGenerators() { final List generators = super.getExtraListXMLGenerators(); diff --git a/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ProceedingsConfig.java b/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ProceedingsConfig.java new file mode 100644 index 000000000..568a4c919 --- /dev/null +++ b/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ProceedingsConfig.java @@ -0,0 +1,56 @@ +package com.arsdigita.cms.contenttypes; + +import com.arsdigita.runtime.AbstractConfig; +import com.arsdigita.util.parameter.BooleanParameter; +import com.arsdigita.util.parameter.Parameter; + +/** + * Special configuration file for the {@link Proceedings} type. The parameters in this configuration + * can be used to decide if some fields of the {@link Proceedings} type are mandatory. + * + * @author Jens Pelzetter + * @version $Id$ + */ +public class ProceedingsConfig extends AbstractConfig { + + private final Parameter beginOfConferenceMandatory; + private final Parameter endOfConferenceMandatory; + private final Parameter placeOfConferenceMandatory; + + public ProceedingsConfig() { + super(); + + beginOfConferenceMandatory = new BooleanParameter( + "com.arsdigita.cms.contenttypes.publications.proceedings.beginOfConferenceIsMandatory", + Parameter.REQUIRED, + Boolean.TRUE); + + endOfConferenceMandatory = new BooleanParameter( + "com.arsdigita.cms.contenttypes.publications.proceedings.endOfConferenceIsMandatory", + Parameter.REQUIRED, + Boolean.TRUE); + + placeOfConferenceMandatory = new BooleanParameter( + "com.arsdigita.cms.contenttypes.publications.proceedings.placeOfConferenceIsMandatory", + Parameter.REQUIRED, + Boolean.TRUE); + + register(beginOfConferenceMandatory); + register(endOfConferenceMandatory); + register(placeOfConferenceMandatory); + + loadInfo(); + } + + public Boolean isBeginOfConferenceMandatory() { + return (Boolean) get(beginOfConferenceMandatory); + } + + public Boolean isEndOfConferenceMandatory() { + return (Boolean) get(endOfConferenceMandatory); + } + + public Boolean isPlaceOfConferenceMandatory() { + return (Boolean) get(placeOfConferenceMandatory); + } +} diff --git a/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ProceedingsConfig_parameter.properties b/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ProceedingsConfig_parameter.properties new file mode 100644 index 000000000..78821e473 --- /dev/null +++ b/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ProceedingsConfig_parameter.properties @@ -0,0 +1,14 @@ +com.arsdigita.cms.contenttypes.publications.proceedings.beginOfConferenceIsMandatory.title = Is Begin of Conference mandatory? +com.arsdigita.cms.contenttypes.publications.proceedings.beginOfConferenceIsMandatory.purpose = Decides wether the field 'Begin of Conference' is mandatory in the Proceedings type. +com.arsdigita.cms.contenttypes.publications.proceedings.beginOfConferenceIsMandatory.example = true +com.arsdigita.cms.contenttypes.publications.proceedings.beginOfConferenceIsMandatory.format = [Boolean] + +com.arsdigita.cms.contenttypes.publications.proceedings.endOfConferenceIsMandatory.title = Is End of Conference mandatory? +com.arsdigita.cms.contenttypes.publications.proceedings.endOfConferenceIsMandatory.purpose = Decides wether the field 'End of Conference' is mandatory in the Proceedings type. +com.arsdigita.cms.contenttypes.publications.proceedings.endOfConferenceIsMandatory.example = true +com.arsdigita.cms.contenttypes.publications.proceedings.endOfConferenceIsMandatory.format = [Boolean] + +com.arsdigita.cms.contenttypes.publications.proceedings.placeOfConferenceIsMandatory.title = Is Place of Conference mandatory? +com.arsdigita.cms.contenttypes.publications.proceedings.placeOfConferenceIsMandatory.purpose = Decides wether the field 'Place of Conference' is mandatory in the Proceedings type. +com.arsdigita.cms.contenttypes.publications.proceedings.placeOfConferenceIsMandatory.example = true +com.arsdigita.cms.contenttypes.publications.proceedings.placeOfConferenceIsMandatory.format = [Boolean] diff --git a/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/PublicationsConfig.java b/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/PublicationsConfig.java index a43d395f2..4cfbf9dbd 100644 --- a/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/PublicationsConfig.java +++ b/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/PublicationsConfig.java @@ -32,7 +32,7 @@ public class PublicationsConfig extends AbstractConfig { private final Parameter orgaType; private final Parameter orgaBundleType; private final Parameter enableFirstPublishedProperty; - private final Parameter enableLanguageProperty; + private final Parameter enableLanguageProperty; public PublicationsConfig() { attachOrgaUnitsStep = diff --git a/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ui/ProceedingsPropertyForm.java b/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ui/ProceedingsPropertyForm.java index c3ba1e53a..0354c0739 100644 --- a/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ui/ProceedingsPropertyForm.java +++ b/ccm-sci-publications/src/com/arsdigita/cms/contenttypes/ui/ProceedingsPropertyForm.java @@ -35,12 +35,15 @@ import com.arsdigita.bebop.parameters.ParameterModel; import com.arsdigita.bebop.parameters.StringParameter; import com.arsdigita.cms.ItemSelectionModel; import com.arsdigita.cms.contenttypes.Proceedings; +import com.arsdigita.cms.contenttypes.ProceedingsConfig; +import com.arsdigita.cms.contenttypes.Publication; import java.util.Calendar; import java.util.GregorianCalendar; /** * * @author Jens Pelzetter + * @version $Id$ */ public class ProceedingsPropertyForm extends PublicationWithPublisherPropertyForm @@ -48,17 +51,17 @@ public class ProceedingsPropertyForm FormInitListener, FormSubmissionListener { - private ProceedingsPropertiesStep m_step; + //private ProceedingsPropertiesStep m_step; public static final String ID = "proceedingsEdit"; - public ProceedingsPropertyForm(ItemSelectionModel itemModel) { + public ProceedingsPropertyForm(final ItemSelectionModel itemModel) { this(itemModel, null); } - public ProceedingsPropertyForm(ItemSelectionModel itemModel, - ProceedingsPropertiesStep step) { + public ProceedingsPropertyForm(final ItemSelectionModel itemModel, + final ProceedingsPropertiesStep step) { super(itemModel, step); - m_step = step; + //m_step = step; addSubmissionListener(this); } @@ -66,53 +69,61 @@ public class ProceedingsPropertyForm protected void addWidgets() { super.addWidgets(); + final ProceedingsConfig proceedingsConfig = Proceedings.getProceedingsConfig(); + add(new Label(PublicationGlobalizationUtil.globalize( "publications.ui.proceedings.name_of_conference"))); - ParameterModel nameOfConfParam = new StringParameter( + final ParameterModel nameOfConfParam = new StringParameter( Proceedings.NAME_OF_CONFERENCE); - TextField nameOfConf = new TextField(nameOfConfParam); + final TextField nameOfConf = new TextField(nameOfConfParam); nameOfConf.addValidationListener(new NotNullValidationListener()); nameOfConf.addValidationListener(new NotEmptyValidationListener()); add(nameOfConf); add(new Label(PublicationGlobalizationUtil.globalize( "publications.ui.proceedings.place_of_conference"))); - ParameterModel placeOfConfParam = new StringParameter( + final ParameterModel placeOfConfParam = new StringParameter( Proceedings.PLACE_OF_CONFERENCE); - TextField placeOfConf = new TextField(placeOfConfParam); - placeOfConf.addValidationListener(new NotNullValidationListener()); - placeOfConf.addValidationListener(new NotEmptyValidationListener()); + final TextField placeOfConf = new TextField(placeOfConfParam); + if (proceedingsConfig.isPlaceOfConferenceMandatory()) { + placeOfConf.addValidationListener(new NotNullValidationListener()); + placeOfConf.addValidationListener(new NotEmptyValidationListener()); + } add(placeOfConf); - Calendar today = new GregorianCalendar(); + final Calendar today = new GregorianCalendar(); add(new Label(PublicationGlobalizationUtil.globalize( "publications.ui.proceedings.date_from_of_conference"))); - ParameterModel dateFromParam = new DateParameter( + final ParameterModel dateFromParam = new DateParameter( Proceedings.DATE_FROM_OF_CONFERENCE); - Date dateFrom = new Date(dateFromParam); + final Date dateFrom = new Date(dateFromParam); dateFrom.setYearRange(1900, today.get(Calendar.YEAR) + 3); - dateFrom.addValidationListener(new NotNullValidationListener()); - dateFrom.addValidationListener(new NotEmptyValidationListener()); + if (proceedingsConfig.isBeginOfConferenceMandatory()) { + dateFrom.addValidationListener(new NotNullValidationListener()); + dateFrom.addValidationListener(new NotEmptyValidationListener()); + } add(dateFrom); add(new Label(PublicationGlobalizationUtil.globalize( "publications.ui.proceedings.date_to_of_conference"))); - ParameterModel dateToParam = new DateParameter( + final ParameterModel dateToParam = new DateParameter( Proceedings.DATE_TO_OF_CONFERENCE); - Date dateTo = new Date(dateToParam); + final Date dateTo = new Date(dateToParam); dateTo.setYearRange(1900, today.get(Calendar.YEAR) + 3); - dateTo.addValidationListener(new NotNullValidationListener()); - dateTo.addValidationListener(new NotEmptyValidationListener()); + if (proceedingsConfig.isEndOfConferenceMandatory()) { + dateTo.addValidationListener(new NotNullValidationListener()); + dateTo.addValidationListener(new NotEmptyValidationListener()); + } add(dateTo); } @Override - public void init(FormSectionEvent fse) throws FormProcessException { + public void init(final FormSectionEvent fse) throws FormProcessException { super.init(fse); - FormData data = fse.getFormData(); - Proceedings proceedings = (Proceedings) super.initBasicWidgets(fse); + final FormData data = fse.getFormData(); + final Proceedings proceedings = (Proceedings) super.initBasicWidgets(fse); data.put(Proceedings.NAME_OF_CONFERENCE, proceedings.getNameOfConference()); @@ -125,11 +136,11 @@ public class ProceedingsPropertyForm } @Override - public void process(FormSectionEvent fse) throws FormProcessException { + public void process(final FormSectionEvent fse) throws FormProcessException { super.process(fse); - FormData data = fse.getFormData(); - Proceedings proceedings = (Proceedings) super.processBasicWidgets(fse); + final FormData data = fse.getFormData(); + final Proceedings proceedings = (Proceedings) super.processBasicWidgets(fse); if ((proceedings != null) && getSaveCancelSection().getSaveButton().