From 55e3fda08299493c5b286435d6d417b790bf6881 Mon Sep 17 00:00:00 2001 From: Jens Pelzetter Date: Sun, 18 Aug 2019 09:32:35 +0200 Subject: [PATCH] All forms for SciProject migrated --- sci-types-project/pom.xml | 2 +- .../contenttypes/ui/SciProjectController.java | 93 ++++++---- .../ui/SciProjectDescriptionStep.java | 4 +- .../ui/SciProjectFundingEditForm.java | 159 ++++++++++++++++++ .../ui/SciProjectFundingStep.java | 83 +++++++++ .../ui/SciProjectFundingUploadForm.java | 67 ++++++++ .../ui/SciProjectUiConstants.java | 4 + .../contenttypes/sciproject/SciProject.java | 1 - .../sciproject/SciProjectConfig.java | 37 +++- .../sciproject/EqualsAndHashCodeTest.java | 41 +++-- 10 files changed, 439 insertions(+), 52 deletions(-) create mode 100644 sci-types-project/src/main/java/com/arsdigita/cms/contenttypes/ui/SciProjectFundingEditForm.java create mode 100644 sci-types-project/src/main/java/com/arsdigita/cms/contenttypes/ui/SciProjectFundingStep.java create mode 100644 sci-types-project/src/main/java/com/arsdigita/cms/contenttypes/ui/SciProjectFundingUploadForm.java diff --git a/sci-types-project/pom.xml b/sci-types-project/pom.xml index b37c514..74fca5a 100644 --- a/sci-types-project/pom.xml +++ b/sci-types-project/pom.xml @@ -20,7 +20,7 @@ org.scientificcms sci-types-project - sci-types-project + ScientificCMS SciProject Content Type diff --git a/sci-types-project/src/main/java/com/arsdigita/cms/contenttypes/ui/SciProjectController.java b/sci-types-project/src/main/java/com/arsdigita/cms/contenttypes/ui/SciProjectController.java index 2acc6e0..78d9a8d 100644 --- a/sci-types-project/src/main/java/com/arsdigita/cms/contenttypes/ui/SciProjectController.java +++ b/sci-types-project/src/main/java/com/arsdigita/cms/contenttypes/ui/SciProjectController.java @@ -44,11 +44,11 @@ class SciProjectController { public static final String CONTACT_TYPE = "contactType"; public static final String CONTACT_ID = "contactId"; - + public static final String SPONSOR_ID = "sponsorId"; - + public static final String SPONSOR_NAME = "name"; - + public static final String SPONSOR_FUNDING_CODE = "fundingCode"; @Inject @@ -204,7 +204,7 @@ class SciProjectController { } @Transactional(Transactional.TxType.REQUIRED) - public void swapWithPreviousContact(final long projectId, + public void swapWithPreviousContact(final long projectId, final long contactId) { final SciProject project = projectRepository @@ -240,7 +240,7 @@ class SciProjectController { } @Transactional(Transactional.TxType.REQUIRED) - public void swapWithNextContact(final long projectId, + public void swapWithNextContact(final long projectId, final long contactId) { final SciProject project = projectRepository @@ -318,12 +318,12 @@ class SciProjectController { projectRepository.save(project); } - - @Transactional(Transactional.TxType.REQUIRED) - public Optional findSponsoring(final long projectId, + + @Transactional(Transactional.TxType.REQUIRED) + public Optional findSponsoring(final long projectId, final Object key) { - - final SciProject project = projectRepository + + final SciProject project = projectRepository .findById(projectId, SciProject.class) .orElseThrow( () -> new IllegalArgumentException( @@ -332,18 +332,18 @@ class SciProjectController { ); final long sponsoringId = (long) key; - + return project .getSponsoring() .stream() .filter(sponsoring -> sponsoring.getSponsoringId() == sponsoringId) .findAny(); } - + @Transactional(Transactional.TxType.REQUIRED) public List> getSponsors(final long forProjectId) { - - final SciProject project = projectRepository + + final SciProject project = projectRepository .findById(forProjectId, SciProject.class) .orElseThrow( () -> new IllegalArgumentException( @@ -357,16 +357,16 @@ class SciProjectController { .map(this::buildSponsorEntry) .collect(Collectors.toList()); } - + private Map buildSponsorEntry(final Sponsoring sponsoring) { - + Objects.requireNonNull(sponsoring); - + final Map result = new HashMap<>(); result.put(SPONSOR_ID, sponsoring.getSponsoringId()); result.put(SPONSOR_NAME, sponsoring.getSponsor().getName()); result.put(SPONSOR_FUNDING_CODE, sponsoring.getFundingCode()); - + return result; } @@ -462,7 +462,7 @@ class SciProjectController { projectRepository.save(project); } } - + @Transactional(Transactional.TxType.REQUIRED) public void swapWithPrevSponsoring(final long projectId, final long sponsoringId) { @@ -473,27 +473,27 @@ class SciProjectController { String.format("No SciProject with ID %d found.", projectId)) ); - + final List sponsoringList = project.getSponsoring(); Sponsoring sponsoring = null; int index = -1; for (int i = 0; i < sponsoringList.size(); i++) { - + if (sponsoringList.get(i).getSponsoringId() == sponsoringId) { sponsoring = sponsoringList.get(i); index = i; break; } } - + if (index > 0 && sponsoring != null) { final long order = sponsoring.getOrder(); final Sponsoring prevSponsoring = sponsoringList.get(index - 1); final long prevOrder = prevSponsoring.getOrder(); - + sponsoring.setOrder(prevOrder); prevSponsoring.setOrder(order); - + projectRepository.save(project); } } @@ -508,31 +508,62 @@ class SciProjectController { String.format("No SciProject with ID %d found.", projectId)) ); - - final List sponsoringList = project.getSponsoring(); + + final List sponsoringList = project.getSponsoring(); Sponsoring sponsoring = null; int index = -1; for (int i = 0; i < sponsoringList.size(); i++) { - + if (sponsoringList.get(i).getSponsoringId() == sponsoringId) { sponsoring = sponsoringList.get(i); index = i; break; } } - + if (index > 0 && sponsoring != null) { final long order = sponsoring.getOrder(); final Sponsoring nextSponsoring = sponsoringList.get(index + 1); final long nextOrder = nextSponsoring.getOrder(); - + sponsoring.setOrder(nextOrder); nextSponsoring.setOrder(order); - + projectRepository.save(project); } } - + + @Transactional(Transactional.TxType.REQUIRED) + public void updateFundingData(final long projectId, + final Locale locale, + final Map data) { + + final SciProject project = projectRepository + .findById(projectId, SciProject.class) + .orElseThrow( + () -> new IllegalArgumentException( + String.format("No SciProject with ID %d found.", + projectId)) + ); + + final SciProjectConfig config = confManager + .findConfiguration(SciProjectConfig.class); + + if (config.isEnableFunding()) { + final String funding = (String) data + .get(SciProjectUiConstants.FUNDING); + project.getFunding().addValue(locale, funding); + } + + if (config.isEnableFundingVolume()) { + final String volume = (String) data + .get(SciProjectUiConstants.FUNDING_VOLUME); + project.getFundingVolume().addValue(locale, volume); + } + + projectRepository.save(project); + } + @Transactional(Transactional.TxType.REQUIRED) public void save(final long projectId, final Locale selectedLocale, diff --git a/sci-types-project/src/main/java/com/arsdigita/cms/contenttypes/ui/SciProjectDescriptionStep.java b/sci-types-project/src/main/java/com/arsdigita/cms/contenttypes/ui/SciProjectDescriptionStep.java index b00b86a..8a9d431 100644 --- a/sci-types-project/src/main/java/com/arsdigita/cms/contenttypes/ui/SciProjectDescriptionStep.java +++ b/sci-types-project/src/main/java/com/arsdigita/cms/contenttypes/ui/SciProjectDescriptionStep.java @@ -64,7 +64,9 @@ public class SciProjectDescriptionStep extends SimpleEditStep { } if (config.isEnableFunding()) { - addStep(new SciProjectFundingStep(itemModel, parent), + addStep(new SciProjectFundingStep(itemModel, + parent, + selectedLanguageParam), "sciproject.ui.steps.funding.title"); } } diff --git a/sci-types-project/src/main/java/com/arsdigita/cms/contenttypes/ui/SciProjectFundingEditForm.java b/sci-types-project/src/main/java/com/arsdigita/cms/contenttypes/ui/SciProjectFundingEditForm.java new file mode 100644 index 0000000..d9f38fd --- /dev/null +++ b/sci-types-project/src/main/java/com/arsdigita/cms/contenttypes/ui/SciProjectFundingEditForm.java @@ -0,0 +1,159 @@ +/* ; + * Copyright (c) 2013 Jens Pelzetter + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ +package com.arsdigita.cms.contenttypes.ui; + +import com.arsdigita.bebop.FormData; +import com.arsdigita.bebop.FormProcessException; +import com.arsdigita.bebop.PageState; +import com.arsdigita.bebop.event.FormInitListener; +import com.arsdigita.bebop.event.FormProcessListener; +import com.arsdigita.bebop.event.FormSectionEvent; +import com.arsdigita.bebop.form.TextArea; +import com.arsdigita.bebop.form.TextField; +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.ui.CMSDHTMLEditor; +import com.arsdigita.cms.ui.authoring.BasicItemForm; +import com.arsdigita.cms.ui.authoring.SelectedLanguageUtil; +import com.arsdigita.globalization.GlobalizedMessage; + +import org.libreccm.cdi.utils.CdiUtil; +import org.scientificcms.contenttypes.sciproject.SciProject; +import org.scientificcms.contenttypes.sciproject.SciProjectConfig; +import org.scientificcms.contenttypes.sciproject.SciProjectConstants; + +import java.util.HashMap; +import java.util.Locale; +import java.util.Map; + +/** + * + * @author Jens Pelzetter + */ +public class SciProjectFundingEditForm + extends BasicItemForm + implements FormProcessListener, FormInitListener { + + private final static SciProjectConfig CONFIG = SciProjectConfig.getConfig(); + + private final StringParameter selectedLanguageParam; + + public SciProjectFundingEditForm( + final ItemSelectionModel itemModel, + final StringParameter selectedLanguageParam) { + + super("SciProjectFundingForm", itemModel, selectedLanguageParam); + this.selectedLanguageParam = selectedLanguageParam; + } + + @Override + public void addWidgets() { + + if (CONFIG.isEnableFunding()) { + final ParameterModel fundingParam = new StringParameter( + SciProjectUiConstants.FUNDING); + final TextArea funding; + if (CONFIG.isEnableFundingDhtml()) { + funding = new CMSDHTMLEditor(fundingParam); + } else { + funding = new TextArea(fundingParam); + } + funding.setLabel(new GlobalizedMessage( + "sciproject.ui.funding", + SciProjectConstants.SCI_PROJECT_BUNDLE)); + funding.setCols(75); + funding.setRows(8); + add(funding); + } + + if (CONFIG.isEnableFundingVolume()) { + final ParameterModel fundingVolumeParam = new StringParameter( + SciProjectUiConstants.FUNDING_VOLUME); + final TextField fundingVolume = new TextField(fundingVolumeParam); + fundingVolume.addValidationListener( + new StringInRangeValidationListener( + 0, + CONFIG.getFundingVolumeLength())); + fundingVolume.setLabel(new GlobalizedMessage( + "sciproject.ui.funding.volume", + SciProjectConstants.SCI_PROJECT_BUNDLE)); + add(fundingVolume); + } + } + + @Override + public void init(final FormSectionEvent event) throws FormProcessException { + final PageState state = event.getPageState(); + final FormData data = event.getFormData(); + final Locale locale = SelectedLanguageUtil + .selectedLocale(state, selectedLanguageParam); + final SciProject project = (SciProject) getItemSelectionModel() + .getSelectedObject(state); + + if (CONFIG.isEnableFunding()) { + data.put(SciProjectUiConstants.FUNDING, + project.getFunding().getValue(locale)); + } + + if (CONFIG.isEnableFundingVolume()) { + data.put(SciProjectUiConstants.FUNDING_VOLUME, + project.getFundingVolume().getValue(locale)); + } + + setVisible(state, true); + + } + + @Override + public void process(final FormSectionEvent event) throws + FormProcessException { + final PageState state = event.getPageState(); + final FormData formData = event.getFormData(); + final Locale locale = SelectedLanguageUtil + .selectedLocale(state, selectedLanguageParam); + final SciProject project = (SciProject) getItemSelectionModel() + .getSelectedObject(state); + + if ((project != null) + && getSaveCancelSection().getSaveButton().isSelected(state)) { + + final Map data = new HashMap<>(); + + if (CONFIG.isEnableFunding()) { + data.put(SciProjectUiConstants.FUNDING, + formData.get(SciProjectUiConstants.FUNDING)); + } + if (CONFIG.isEnableFundingVolume()) { + data.put(SciProjectUiConstants.FUNDING_VOLUME, + formData.get(SciProjectUiConstants.FUNDING_VOLUME)); + } + + final SciProjectController controller = CdiUtil + .createCdiUtil() + .findBean(SciProjectController.class); + controller.updateFundingData(project.getObjectId(), locale, data); + } + + init(event); + } + +} diff --git a/sci-types-project/src/main/java/com/arsdigita/cms/contenttypes/ui/SciProjectFundingStep.java b/sci-types-project/src/main/java/com/arsdigita/cms/contenttypes/ui/SciProjectFundingStep.java new file mode 100644 index 0000000..d9b8466 --- /dev/null +++ b/sci-types-project/src/main/java/com/arsdigita/cms/contenttypes/ui/SciProjectFundingStep.java @@ -0,0 +1,83 @@ +package com.arsdigita.cms.contenttypes.ui; + +import com.arsdigita.bebop.Component; +import com.arsdigita.bebop.parameters.StringParameter; +import com.arsdigita.cms.ItemSelectionModel; + +import com.arsdigita.cms.ui.authoring.AuthoringKitWizard; +import com.arsdigita.cms.ui.authoring.BasicItemForm; +import com.arsdigita.cms.ui.authoring.SimpleEditStep; +import com.arsdigita.cms.ui.workflow.WorkflowLockedComponentAccess; +import com.arsdigita.globalization.GlobalizedMessage; +import com.arsdigita.toolbox.ui.DomainObjectPropertySheet; + +import org.scientificcms.contenttypes.sciproject.SciProjectConfig; +import org.scientificcms.contenttypes.sciproject.SciProjectConstants; + +/** + * + * @author Jens Pelzetter + * @version $Id: SciProjectFundingStep.java 2334 2013-10-03 07:51:31Z jensp $ + */ +public class SciProjectFundingStep extends SimpleEditStep { + + private static final String EDIT_PROJECT_FUNDING_SHEET_NAME + = "editProjectFunding"; + + private static final String UPLOAD_PROJECT_FUNDING_SHEET_NAME + = "uploadProjectFunding"; + + public SciProjectFundingStep(final ItemSelectionModel itemModel, + final AuthoringKitWizard parent, + final StringParameter selectedLanguageParam) { + this(itemModel, parent, selectedLanguageParam, null); + } + + public SciProjectFundingStep(final ItemSelectionModel itemModel, + final AuthoringKitWizard parent, + final StringParameter selectedLanguageParam, + final String prefix) { + super(itemModel, parent, selectedLanguageParam, prefix); + + final BasicItemForm editFundingForm = new SciProjectFundingEditForm( + itemModel, selectedLanguageParam); + add(EDIT_PROJECT_FUNDING_SHEET_NAME, + new GlobalizedMessage("sciproject.ui.funding.edit", + SciProjectConstants.SCI_PROJECT_BUNDLE), + new WorkflowLockedComponentAccess(editFundingForm, itemModel), + editFundingForm.getSaveCancelSection().getCancelButton()); + + final SciProjectFundingUploadForm uploadFundingForm + = new SciProjectFundingUploadForm( + itemModel, selectedLanguageParam); + add(UPLOAD_PROJECT_FUNDING_SHEET_NAME, + new GlobalizedMessage("sciproject.ui.funding.upload", + SciProjectConstants.SCI_PROJECT_BUNDLE), + new WorkflowLockedComponentAccess(uploadFundingForm, itemModel), + uploadFundingForm.getSaveCancelSection().getCancelButton()); + + setDisplayComponent(getSciProjectEditFundingSheet(itemModel)); + } + + public static Component getSciProjectEditFundingSheet( + final ItemSelectionModel itemModel) { + final DomainObjectPropertySheet sheet = new DomainObjectPropertySheet( + itemModel); + + if (SciProjectConfig.getConfig().isEnableFunding()) { + sheet.add( + new GlobalizedMessage("sciproject.ui.funding", + SciProjectConstants.SCI_PROJECT_BUNDLE), + SciProjectUiConstants.FUNDING); + } + if (SciProjectConfig.getConfig().isEnableFundingVolume()) { + sheet.add( + new GlobalizedMessage("sciproject.ui.funding.volume", + SciProjectConstants.SCI_PROJECT_BUNDLE), + SciProjectUiConstants.FUNDING_VOLUME); + } + + return sheet; + } + +} diff --git a/sci-types-project/src/main/java/com/arsdigita/cms/contenttypes/ui/SciProjectFundingUploadForm.java b/sci-types-project/src/main/java/com/arsdigita/cms/contenttypes/ui/SciProjectFundingUploadForm.java new file mode 100644 index 0000000..c1815b5 --- /dev/null +++ b/sci-types-project/src/main/java/com/arsdigita/cms/contenttypes/ui/SciProjectFundingUploadForm.java @@ -0,0 +1,67 @@ +package com.arsdigita.cms.contenttypes.ui; + +import com.arsdigita.bebop.PageState; +import com.arsdigita.bebop.parameters.StringParameter; +import com.arsdigita.cms.ItemSelectionModel; +import com.arsdigita.cms.ui.authoring.SelectedLanguageUtil; +import com.arsdigita.cms.ui.contenttypes.AbstractTextUploadForm; +import com.arsdigita.globalization.GlobalizedMessage; + +import org.libreccm.cdi.utils.CdiUtil; +import org.scientificcms.contenttypes.sciproject.SciProject; +import org.scientificcms.contenttypes.sciproject.SciProjectConstants; + +import java.util.HashMap; +import java.util.Locale; +import java.util.Map; + +/** + * + * @author Jens Pelzetter + * @version $Id: SciProjectFundingUploadForm.java 2334 2013-10-03 07:51:31Z + * jensp $ + */ +public class SciProjectFundingUploadForm extends AbstractTextUploadForm { + + private final StringParameter selectedLanguageParam; + + public SciProjectFundingUploadForm( + final ItemSelectionModel itemModel, + final StringParameter selectedLanguageParam) { + + super(itemModel); + this.selectedLanguageParam = selectedLanguageParam; + } + + @Override + public GlobalizedMessage getLabelText() { + return new GlobalizedMessage("sciproject.ui.funding.upload", + SciProjectConstants.SCI_PROJECT_BUNDLE); + } + + @Override + public GlobalizedMessage getMimeTypeLabel() { + return new GlobalizedMessage("sciproject.ui.funding.upload.mimetype", + SciProjectConstants.SCI_PROJECT_BUNDLE); + } + + @Override + public void setText(final ItemSelectionModel itemModel, + final PageState state, + final String text) { + + final SciProject project = (SciProject) itemModel.getSelectedObject( + state); + final Locale locale = SelectedLanguageUtil + .selectedLocale(state, + selectedLanguageParam); + + final Map data = new HashMap<>(); + data.put(SciProjectUiConstants.FUNDING, text); + CdiUtil + .createCdiUtil() + .findBean(SciProjectController.class) + .updateFundingData(project.getObjectId(), locale, data); + } + +} diff --git a/sci-types-project/src/main/java/com/arsdigita/cms/contenttypes/ui/SciProjectUiConstants.java b/sci-types-project/src/main/java/com/arsdigita/cms/contenttypes/ui/SciProjectUiConstants.java index 9019083..53fad95 100644 --- a/sci-types-project/src/main/java/com/arsdigita/cms/contenttypes/ui/SciProjectUiConstants.java +++ b/sci-types-project/src/main/java/com/arsdigita/cms/contenttypes/ui/SciProjectUiConstants.java @@ -21,6 +21,10 @@ public final class SciProjectUiConstants { public static final String EDIT_DESC_TEXT_SHEET_NAME = "editProjectDescText"; + public static final String FUNDING = "funding"; + + public static final String FUNDING_VOLUME = "fundingVolume"; + public static final String FUNDING_CODE = "fundingCode"; public static final String END = "end"; diff --git a/sci-types-project/src/main/java/org/scientificcms/contenttypes/sciproject/SciProject.java b/sci-types-project/src/main/java/org/scientificcms/contenttypes/sciproject/SciProject.java index 85aa675..438748f 100644 --- a/sci-types-project/src/main/java/org/scientificcms/contenttypes/sciproject/SciProject.java +++ b/sci-types-project/src/main/java/org/scientificcms/contenttypes/sciproject/SciProject.java @@ -12,7 +12,6 @@ import javax.persistence.Entity; import org.hibernate.envers.Audited; import org.libreccm.l10n.LocalizedString; -import org.librecms.assets.Organization; import org.librecms.contentsection.ContentItem; import org.librecms.contenttypes.AuthoringKit; import org.librecms.contenttypes.AuthoringStep; diff --git a/sci-types-project/src/main/java/org/scientificcms/contenttypes/sciproject/SciProjectConfig.java b/sci-types-project/src/main/java/org/scientificcms/contenttypes/sciproject/SciProjectConfig.java index 32df65a..26b1084 100644 --- a/sci-types-project/src/main/java/org/scientificcms/contenttypes/sciproject/SciProjectConfig.java +++ b/sci-types-project/src/main/java/org/scientificcms/contenttypes/sciproject/SciProjectConfig.java @@ -20,13 +20,22 @@ public class SciProjectConfig { @Setting private String contactTypesBundleName = "org.scientificcms.contenttypes.sciproject.DefaultContactTypes"; - + @Setting private boolean enableSponsor = true; - + @Setting private boolean enableFunding = true; + @Setting + private boolean enableFundingDhtml = true; + + @Setting + private boolean enableFundingVolume = true; + + @Setting + private int fundingVolumeLength = 128; + public static SciProjectConfig getConfig() { final ConfigurationManager confManager = CdiUtil.createCdiUtil() .findBean(ConfigurationManager.class); @@ -60,6 +69,30 @@ public class SciProjectConfig { public void setEnableFunding(final boolean enableFunding) { this.enableFunding = enableFunding; } + + public boolean isEnableFundingDhtml() { + return enableFundingDhtml; + } + + public void setEnableFundingDhtml(boolean enableFundingDhtml) { + this.enableFundingDhtml = enableFundingDhtml; + } + + public boolean isEnableFundingVolume() { + return enableFundingVolume; + } + + public void setEnableFundingVolume(final boolean enableFundingVolume) { + this.enableFundingVolume = enableFundingVolume; + } + + public int getFundingVolumeLength() { + return fundingVolumeLength; + } + + public void setFundingVolumeLength(final int fundingVolumeLength) { + this.fundingVolumeLength = fundingVolumeLength; + } diff --git a/sci-types-project/src/test/java/org/scientificcms/contenttypes/sciproject/EqualsAndHashCodeTest.java b/sci-types-project/src/test/java/org/scientificcms/contenttypes/sciproject/EqualsAndHashCodeTest.java index 2d52506..b31ac94 100644 --- a/sci-types-project/src/test/java/org/scientificcms/contenttypes/sciproject/EqualsAndHashCodeTest.java +++ b/sci-types-project/src/test/java/org/scientificcms/contenttypes/sciproject/EqualsAndHashCodeTest.java @@ -5,25 +5,24 @@ */ package org.scientificcms.contenttypes.sciproject; +import nl.jqno.equalsverifier.Warning; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; import org.libreccm.categorization.Category; import org.libreccm.core.CcmObject; import org.libreccm.l10n.LocalizedString; -import org.libreccm.security.Group; -import org.libreccm.security.Role; import org.libreccm.security.SecurityEntitiesPrefabProvider; -import org.libreccm.security.User; import org.libreccm.tests.categories.UnitTest; import org.libreccm.testutils.EqualsVerifier; import org.libreccm.workflow.Workflow; import org.librecms.assets.ContactableEntity; +import org.librecms.assets.Organization; import org.librecms.assets.Person; import org.librecms.assets.PostalAddress; -import org.librecms.contentsection.AttachmentList; import org.librecms.contentsection.ContentItem; import org.librecms.contentsection.ContentSection; import org.librecms.contentsection.ContentType; +import org.librecms.contentsection.ItemAttachment; import org.librecms.lifecycle.Lifecycle; import java.util.Arrays; @@ -151,18 +150,6 @@ public class EqualsAndHashCodeTest extends EqualsVerifier { verifier.withPrefabValues(ContentItem.class, item1, item2); - final AttachmentList attachmentList1 = new AttachmentList(); - attachmentList1.setListId(701); - attachmentList1.setName("list1"); - - final AttachmentList attachmentList2 = new AttachmentList(); - attachmentList2.setListId(702); - attachmentList2.setName("list2"); - - verifier.withPrefabValues(AttachmentList.class, - attachmentList1, - attachmentList2); - final Lifecycle lifecycle1 = new Lifecycle(); lifecycle1.setLifecycleId(801); lifecycle1.setStarted(true); @@ -206,6 +193,28 @@ public class EqualsAndHashCodeTest extends EqualsVerifier { category2.setName("category2"); verifier.withPrefabValues(Category.class, category1, category2); + + final Organization organization1 = new Organization(); + organization1.setName("orga1"); + + final Organization organization2 = new Organization(); + organization1.setName("orga2"); + + verifier.withPrefabValues(Organization.class, + organization1, + organization2); + + final ItemAttachment itemAttachment1 = new ItemAttachment<>(); + itemAttachment1.setUuid("927ac9de-029d-4233-9015-1135eb861c34"); + + final ItemAttachment itemAttachment2 = new ItemAttachment<>(); + itemAttachment2.setUuid("d1bd98a1-75c2-4e61-8f9f-2e2eadd30812"); + + verifier.withPrefabValues(ItemAttachment.class, + itemAttachment1, + itemAttachment2); + + verifier.suppress(Warning.REFERENCE_EQUALITY); } }