From 2c2773949e0e59d9b2c8293fe6852f1010c95977 Mon Sep 17 00:00:00 2001 From: Jens Pelzetter Date: Tue, 27 Sep 2022 20:22:58 +0200 Subject: [PATCH 01/16] Basic structure for sci department content type --- pom.xml | 1 + sci-types-department/pom.xml | 350 ++++++++++++++++++ .../scidepartment/SciDepartment.java | 121 ++++++ .../scidepartment/SciDepartmentConstants.java | 18 + .../SciDepartmentIdResolver.java | 57 +++ .../scidepartment/SciDepartmentModule.java | 46 +++ .../ui/SciDepartmentCreateStep.java | 45 +++ .../ui/SciDepartmentDescriptionStep.java | 26 ++ .../SciDepartmentExtendedPropertiesStep.java | 26 ++ .../ui/SciDepartmentPropertiesStep.java | 26 ++ .../ui/SciDepartmentStepsConstants.java | 16 + .../contenttypes/SciDepartment.properties | 3 + .../contenttypes/SciDepartment_de.properties | 3 + .../sciproject/SciProjectRepository.java | 1 - 14 files changed, 738 insertions(+), 1 deletion(-) create mode 100644 sci-types-department/pom.xml create mode 100644 sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/SciDepartment.java create mode 100644 sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/SciDepartmentConstants.java create mode 100644 sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/SciDepartmentIdResolver.java create mode 100644 sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/SciDepartmentModule.java create mode 100644 sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/ui/SciDepartmentCreateStep.java create mode 100644 sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/ui/SciDepartmentDescriptionStep.java create mode 100644 sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/ui/SciDepartmentExtendedPropertiesStep.java create mode 100644 sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/ui/SciDepartmentPropertiesStep.java create mode 100644 sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/ui/SciDepartmentStepsConstants.java create mode 100644 sci-types-department/src/main/resources/org/scientificcms/contenttypes/SciDepartment.properties create mode 100644 sci-types-department/src/main/resources/org/scientificcms/contenttypes/SciDepartment_de.properties diff --git a/pom.xml b/pom.xml index c08ddc3..c1a68d7 100644 --- a/pom.xml +++ b/pom.xml @@ -61,6 +61,7 @@ + sci-types-department sci-types-project scientificcms sci-publications diff --git a/sci-types-department/pom.xml b/sci-types-department/pom.xml new file mode 100644 index 0000000..18241a6 --- /dev/null +++ b/sci-types-department/pom.xml @@ -0,0 +1,350 @@ + + + 4.0.0 + + + UTF-8 + ${maven.build.timestamp} + yyyy-MM-dd'T'HH:mm:ss'Z'Z + + + + org.scientificcms + scientificcms-parent + 7.0.0-SNAPSHOT + + + org.scientificcms + sci-types-department + 7.0.0-SNAPSHOT + + ScientificCMS SciDepartment Content Type + + + + + javax + javaee-api + jar + provided + + + + org.libreccm + ccm-core + ${project.parent.version} + provided + + + + org.librecms + ccm-cms + ${project.parent.version} + provided + + + + org.hibernate + hibernate-core + provided + + + + org.hibernate + hibernate-envers + provided + + + + org.hibernate.validator + hibernate-validator + provided + + + + org.apache.logging.log4j + log4j-api + provided + + + + junit + junit + test + + + + org.hamcrest + hamcrest-core + test + + + org.hamcrest + hamcrest-library + test + + + + org.libreccm + ccm-testutils + ${project.parent.version} + test + + + + nl.jqno.equalsverifier + equalsverifier + test + + + + org.jboss.arquillian.junit + arquillian-junit-container + test + + + org.jboss.arquillian.extension + arquillian-persistence-dbunit + test + + + org.jboss.shrinkwrap.resolver + shrinkwrap-resolver-impl-maven + test + + + + com.h2database + h2 + test + + + + + + sci-types-department + + + + src/main/resources + true + + + ./target/generated-resources + + + + + + src/test/resources + + + ${project.build.directory}/generated-resources + + + + + + org.apache.maven.plugins + maven-compiler-plugin + + 11 + 11 + true + true + ${project.build.sourceEncoding} + + + + + com.github.eirslett + frontend-maven-plugin + + ../node + + + + Install node.js and NPM + + install-node-and-npm + + + v16.14.2 + + + + npm install + + npm + + + --userconfig ../libreccm.npmrc install + + + + build + + npm + + + run build + + + + + + + org.apache.maven.plugins + maven-surefire-plugin + + org.libreccm.tests.categories.UnitTest + + + + + org.jacoco + jacoco-maven-plugin + + + default-prepare-agent + + prepare-agent + + + + default-report + prepare-package + + report + + + + + + + de.jpdigital + hibernate53-ddl-maven-plugin + + + h2 + oracle12c + postgresql9 + + + org.libreccm + org.librecms + org.scientificcms + + true + ${basedir}/src/main/resources/META-INF/persistence-ddl.xml + + + + + gen-ddl + + process-classes + + + + + + + + + + + org.apache.maven.plugins + maven-javadoc-plugin + + true + true + + http://docs.oracle.com/javase/7/docs/api/ + http://docs.oracle.com/javaee/7/api/ + http://docs.jboss.org/hibernate/orm/4.3/javadocs/ + + private + true + UTF-8 + UTF-8 + UTF-8 + true + true + true + true + false + + + + + org.apache.maven.plugins + maven-jxr-plugin + + + org.apache.maven.plugins + maven-surefire-report-plugin + + + org.jacoco + jacoco-maven-plugin + + + org.codehaus.mojo + findbugs-maven-plugin + + + + org.apache.maven.plugins + maven-pmd-plugin + + true + utf-8 + 1.8 + + + + + org.codehaus.mojo + javancss-maven-plugin + + + org.apache.maven.plugins + maven-project-info-reports-plugin + + + + dependencies + licenses + + + + + false + + + + + + diff --git a/sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/SciDepartment.java b/sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/SciDepartment.java new file mode 100644 index 0000000..a4914b3 --- /dev/null +++ b/sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/SciDepartment.java @@ -0,0 +1,121 @@ +package org.scientificcms.contenttypes.scidepartment; + +import com.fasterxml.jackson.annotation.JsonIdentityInfo; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.ObjectIdGenerators; +import org.hibernate.envers.Audited; +import org.libreccm.l10n.LocalizedString; +import org.librecms.contentsection.ContentItem; +import org.librecms.contenttypes.ContentTypeDescription; +import org.librecms.ui.contentsections.documents.MvcAuthoringKit; +import org.scientificcms.contenttypes.scidepartment.ui.SciDepartmentCreateStep; +import org.scientificcms.contenttypes.scidepartment.ui.SciDepartmentDescriptionStep; +import org.scientificcms.contenttypes.scidepartment.ui.SciDepartmentExtendedPropertiesStep; +import org.scientificcms.contenttypes.scidepartment.ui.SciDepartmentPropertiesStep; + +import java.io.Serializable; +import java.util.List; +import java.util.Map; + +import javax.persistence.AssociationOverride; +import javax.persistence.CascadeType; +import javax.persistence.Embedded; +import javax.persistence.Entity; +import javax.persistence.JoinColumn; +import javax.persistence.JoinTable; +import javax.persistence.OneToMany; +import javax.persistence.OrderBy; +import javax.persistence.Table; + +import static org.scientificcms.contenttypes.scidepartment.SciDepartmentConstants.DB_SCHEMA; + +/** + * + * @author Jens Pelzetter + */ +@Entity +@Audited +@Table(name = "DEPARTMENTS", schema = DB_SCHEMA) +@ContentTypeDescription( + labelBundle = "org.scientificcms.contenttypes.SciDepartment", + descriptionBundle = "org.scientificcms.contenttypes.SciDepartment" +) +@MvcAuthoringKit( + createStep = SciDepartmentCreateStep.class, + authoringSteps = { + SciDepartmentPropertiesStep.class, + SciDepartmentExtendedPropertiesStep.class, + SciDepartmentDescriptionStep.class + } +) +@JsonIdentityInfo( + generator = ObjectIdGenerators.PropertyGenerator.class, + resolver = SciDepartmentIdResolver.class, + property = "uuid" +) +public class SciDepartment extends ContentItem implements Serializable { + + private static final long serialVersionUID = 1L; + + @Embedded + @AssociationOverride( + name = "values", + joinTable = @JoinTable( + name = "DEPARTMENT_SHORT_DESCS", + schema = DB_SCHEMA, + joinColumns = { + @JoinColumn(name = "OBJECT_ID") + } + ) + ) + private LocalizedString shortDescription; + + @Embedded + @AssociationOverride( + name = "values", + joinTable = @JoinTable( + name = "DEPARTMENT_DESCS", + schema = DB_SCHEMA, + joinColumns = { + @JoinColumn(name = "OBJECT_ID") + } + ) + ) + private LocalizedString departmentDescription; + + @Embedded + @AssociationOverride( + name = "values", + joinTable = @JoinTable( + name = "DEPARTMENT_ADDENDUM", + schema = DB_SCHEMA, + joinColumns = { + @JoinColumn(name = "OBJECT_ID") + } + ) + ) + private LocalizedString addendum; + + + @OneToMany(cascade = CascadeType.ALL, mappedBy = "department") + @OrderBy("order ASC") + @JsonIgnore + private Map additionalTexts; + + @OneToMany(cascade = CascadeType.ALL, mappedBy = "department") + @OrderBy("order ASC") + @JsonIgnore + private List contacts; + + @OneToMany(cascade = CascadeType.ALL, mappedBy = "project") + @OrderBy("member ASC") + @JsonIgnore + private List members; + + @OneToMany(cascade = CascadeType.ALL, mappedBy = "project") + @OrderBy("member ASC") + @JsonIgnore + private List projects; + + +} diff --git a/sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/SciDepartmentConstants.java b/sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/SciDepartmentConstants.java new file mode 100644 index 0000000..86678b9 --- /dev/null +++ b/sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/SciDepartmentConstants.java @@ -0,0 +1,18 @@ +package org.scientificcms.contenttypes.scidepartment; + +/** + * + * @author Jens Pelzetter + */ +public final class SciDepartmentConstants { + + public static final String DB_SCHEMA = "SCI_TYPES_DEPARTMENT"; + + public static final String SCI_PROJECT_BUNDLE + = "org.scientificcms.contenttypes.SciDepartmentResources"; + + private SciDepartmentConstants() { + // Nothing + } + +} diff --git a/sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/SciDepartmentIdResolver.java b/sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/SciDepartmentIdResolver.java new file mode 100644 index 0000000..74eb517 --- /dev/null +++ b/sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/SciDepartmentIdResolver.java @@ -0,0 +1,57 @@ +package org.scientificcms.contenttypes.scidepartment; + +import com.fasterxml.jackson.annotation.ObjectIdGenerator; +import com.fasterxml.jackson.annotation.ObjectIdResolver; +import org.libreccm.cdi.utils.CdiUtil; +import org.librecms.contentsection.ContentItemRepository; + +import java.io.Serializable; + +import javax.enterprise.context.RequestScoped; + +/** + * + * @author Jens Pelzetter + */ +@RequestScoped +public class SciDepartmentIdResolver implements Serializable, ObjectIdResolver { + + private static final long serialVersionUID = 1L; + + @Override + public void bindItem( + final ObjectIdGenerator.IdKey idKey, + final Object object + ) { + // According to the Jackson JavaDoc, this method can be used to keep + // track of objects directly in a resolver implementation. We don't need + // this here therefore this method is empty. + } + + @Override + public Object resolveId(final ObjectIdGenerator.IdKey id) { + return CdiUtil + .createCdiUtil() + .findBean(ContentItemRepository.class) + .findByUuid(id.key.toString(), SciDepartment.class) + .orElseThrow( + () -> new IllegalArgumentException( + String.format( + "No SciDepartment with UUID %s found in the datbase.", + id.key.toString() + ) + ) + ); + } + + @Override + public ObjectIdResolver newForDeserialization(final Object context) { + return new SciDepartmentIdResolver(); + } + + @Override + public boolean canUseFor(final ObjectIdResolver resolverType) { + return resolverType instanceof SciDepartmentIdResolver; + } + +} diff --git a/sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/SciDepartmentModule.java b/sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/SciDepartmentModule.java new file mode 100644 index 0000000..2ba9218 --- /dev/null +++ b/sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/SciDepartmentModule.java @@ -0,0 +1,46 @@ +package org.scientificcms.contenttypes.scidepartment; + +import org.libreccm.modules.CcmModule; +import org.libreccm.modules.InitEvent; +import org.libreccm.modules.InstallEvent; +import org.libreccm.modules.RequiredModule; +import org.libreccm.modules.ShutdownEvent; +import org.libreccm.modules.UnInstallEvent; +import org.librecms.contenttypes.ContentTypes; + +/** + * + * @author Jens Pelzetter + */ +@org.libreccm.modules.Module( + requiredModules = { + @RequiredModule(module = org.libreccm.core.CcmCore.class), + @RequiredModule(module = org.librecms.Cms.class) + } +) +@ContentTypes({ + SciDepartment.class +}) +public class SciDepartmentModule implements CcmModule { + + @Override + public void install(final InstallEvent event) { + //ToDo Create initial data for the module if neccessary + } + + @Override + public void init(final InitEvent event) { + //ToDo Add initialisation logic necessary for your module + } + + @Override + public void shutdown(final ShutdownEvent event) { + //ToDo Add shutdown logic if necessary + } + + @Override + public void uninstall(final UnInstallEvent event) { + //ToDo Remove module data + } + +} diff --git a/sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/ui/SciDepartmentCreateStep.java b/sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/ui/SciDepartmentCreateStep.java new file mode 100644 index 0000000..1978b4e --- /dev/null +++ b/sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/ui/SciDepartmentCreateStep.java @@ -0,0 +1,45 @@ +package org.scientificcms.contenttypes.scidepartment.ui; + +import org.librecms.ui.contentsections.documents.AbstractMvcDocumentCreateStep; +import org.scientificcms.contenttypes.scidepartment.SciDepartment; + +import java.util.Map; + +import javax.enterprise.context.RequestScoped; +import javax.inject.Named; + +/** + * + * @author Jens Pelzetter + */ +@RequestScoped +@Named("SciDepartmentCreateStep") +public class SciDepartmentCreateStep + extends AbstractMvcDocumentCreateStep{ + + @Override + public String showCreateStep() { + throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody + } + + @Override + public String createItem(Map maps) { + throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody + } + + @Override + public String getDocumentType() { + throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody + } + + @Override + public String getDescription() { + throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody + } + + @Override + public String getBundle() { + throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody + } + +} diff --git a/sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/ui/SciDepartmentDescriptionStep.java b/sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/ui/SciDepartmentDescriptionStep.java new file mode 100644 index 0000000..0342ed8 --- /dev/null +++ b/sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/ui/SciDepartmentDescriptionStep.java @@ -0,0 +1,26 @@ +package org.scientificcms.contenttypes.scidepartment.ui; + +import org.librecms.ui.contentsections.documents.MvcAuthoringStepDef; +import org.librecms.ui.contentsections.documents.MvcAuthoringSteps; +import org.scientificcms.contenttypes.scidepartment.SciDepartment; + +import javax.enterprise.context.RequestScoped; +import javax.mvc.Controller; +import javax.ws.rs.Path; + +/** + * + * @author Jens Pelzetter + */ +@RequestScoped +@Path(MvcAuthoringSteps.PATH_PREFIX + "scidepartment-description") +@Controller +@MvcAuthoringStepDef( + bundle = SciDepartmentStepsConstants.BUNDLE, + descriptionKey = "authoringsteps.description.description", + labelKey = "authoringsteps.description.label", + supportedDocumentType = SciDepartment.class +) +public class SciDepartmentDescriptionStep { + +} diff --git a/sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/ui/SciDepartmentExtendedPropertiesStep.java b/sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/ui/SciDepartmentExtendedPropertiesStep.java new file mode 100644 index 0000000..2de024b --- /dev/null +++ b/sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/ui/SciDepartmentExtendedPropertiesStep.java @@ -0,0 +1,26 @@ +package org.scientificcms.contenttypes.scidepartment.ui; + +import org.librecms.ui.contentsections.documents.MvcAuthoringStepDef; +import org.librecms.ui.contentsections.documents.MvcAuthoringSteps; +import org.scientificcms.contenttypes.scidepartment.SciDepartment; + +import javax.enterprise.context.RequestScoped; +import javax.mvc.Controller; +import javax.ws.rs.Path; + +/** + * + * @author Jens Pelzetter + */ +@RequestScoped +@Path(MvcAuthoringSteps.PATH_PREFIX + "scidepartment-extendedproperties") +@Controller +@MvcAuthoringStepDef( + bundle = SciDepartmentStepsConstants.BUNDLE, + descriptionKey = "authoringsteps.extendedproperties.description", + labelKey = "authoringsteps.extendedproperties.label", + supportedDocumentType = SciDepartment.class +) +public class SciDepartmentExtendedPropertiesStep { + +} diff --git a/sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/ui/SciDepartmentPropertiesStep.java b/sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/ui/SciDepartmentPropertiesStep.java new file mode 100644 index 0000000..9092fb3 --- /dev/null +++ b/sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/ui/SciDepartmentPropertiesStep.java @@ -0,0 +1,26 @@ +package org.scientificcms.contenttypes.scidepartment.ui; + +import org.librecms.ui.contentsections.documents.MvcAuthoringStepDef; +import org.librecms.ui.contentsections.documents.MvcAuthoringSteps; +import org.scientificcms.contenttypes.scidepartment.SciDepartment; + +import javax.enterprise.context.RequestScoped; +import javax.mvc.Controller; +import javax.ws.rs.Path; + +/** + * + * @author Jens Pelzetter + */ +@RequestScoped +@Path(MvcAuthoringSteps.PATH_PREFIX + "scidepartment-basicproperties") +@Controller +@MvcAuthoringStepDef( + bundle = SciDepartmentStepsConstants.BUNDLE, + descriptionKey = "authoringsteps.basicproperties.description", + labelKey = "authoringsteps.basicproperties.label", + supportedDocumentType = SciDepartment.class +) +public class SciDepartmentPropertiesStep { + +} diff --git a/sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/ui/SciDepartmentStepsConstants.java b/sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/ui/SciDepartmentStepsConstants.java new file mode 100644 index 0000000..9a0b90d --- /dev/null +++ b/sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/ui/SciDepartmentStepsConstants.java @@ -0,0 +1,16 @@ +package org.scientificcms.contenttypes.scidepartment.ui; + +/** + * + * @author Jens Pelzetter + */ +public final class SciDepartmentStepsConstants { + + private SciDepartmentStepsConstants() { + // Nothing + } + + public static final String BUNDLE + = "org.scientificcms.contenttypes.scidepartment.ui.SciDepartmentBundle"; + +} diff --git a/sci-types-department/src/main/resources/org/scientificcms/contenttypes/SciDepartment.properties b/sci-types-department/src/main/resources/org/scientificcms/contenttypes/SciDepartment.properties new file mode 100644 index 0000000..85689ad --- /dev/null +++ b/sci-types-department/src/main/resources/org/scientificcms/contenttypes/SciDepartment.properties @@ -0,0 +1,3 @@ + +label=Department +description=Describes a department. diff --git a/sci-types-department/src/main/resources/org/scientificcms/contenttypes/SciDepartment_de.properties b/sci-types-department/src/main/resources/org/scientificcms/contenttypes/SciDepartment_de.properties new file mode 100644 index 0000000..15c3876 --- /dev/null +++ b/sci-types-department/src/main/resources/org/scientificcms/contenttypes/SciDepartment_de.properties @@ -0,0 +1,3 @@ + +label=Abteillung +description=Beschreibung einer Abteilung oder eines Lehrstuhls. diff --git a/sci-types-project/src/main/java/org/scientificcms/contenttypes/sciproject/SciProjectRepository.java b/sci-types-project/src/main/java/org/scientificcms/contenttypes/sciproject/SciProjectRepository.java index 030a9b1..8420cfb 100644 --- a/sci-types-project/src/main/java/org/scientificcms/contenttypes/sciproject/SciProjectRepository.java +++ b/sci-types-project/src/main/java/org/scientificcms/contenttypes/sciproject/SciProjectRepository.java @@ -11,7 +11,6 @@ import org.librecms.contentsection.ContentItemRepository; import java.io.Serializable; import java.time.LocalDate; import java.util.List; -import java.util.Optional; import javax.enterprise.context.RequestScoped; import javax.inject.Inject; -- 2.52.0 From 5b91703cc979ff0b3583a2f33d6b0f7fc1aa2408 Mon Sep 17 00:00:00 2001 From: Jens Pelzetter Date: Wed, 28 Sep 2022 20:11:48 +0200 Subject: [PATCH 02/16] Entities for sci-types-department --- sci-types-department/pom.xml | 7 + .../contenttypes/scidepartment/Contact.java | 194 ++++++++++++++++ .../scidepartment/ContactRepository.java | 42 ++++ .../scidepartment/DepartmentProject.java | 157 +++++++++++++ .../DepartmentProjectRepository.java | 42 ++++ .../scidepartment/DepartmentText.java | 185 ++++++++++++++++ .../DepartmentTextRepository.java | 40 ++++ .../scidepartment/Membership.java | 207 ++++++++++++++++++ .../scidepartment/MembershipRepository.java | 40 ++++ .../scidepartment/MembershipStatus.java | 13 ++ .../scidepartment/SciDepartment.java | 201 ++++++++++++++++- .../contenttypes/sciproject/Contact.java | 2 +- .../contenttypes/sciproject/Membership.java | 2 +- .../contenttypes/sciproject/SciProject.java | 1 - 14 files changed, 1124 insertions(+), 9 deletions(-) create mode 100644 sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/Contact.java create mode 100644 sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/ContactRepository.java create mode 100644 sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/DepartmentProject.java create mode 100644 sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/DepartmentProjectRepository.java create mode 100644 sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/DepartmentText.java create mode 100644 sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/DepartmentTextRepository.java create mode 100644 sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/Membership.java create mode 100644 sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/MembershipRepository.java create mode 100644 sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/MembershipStatus.java diff --git a/sci-types-department/pom.xml b/sci-types-department/pom.xml index 18241a6..71c8b51 100644 --- a/sci-types-department/pom.xml +++ b/sci-types-department/pom.xml @@ -45,6 +45,13 @@ ${project.parent.version} provided + + + org.scientificcms + sci-types-project + ${project.parent.version} + provided + org.hibernate diff --git a/sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/Contact.java b/sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/Contact.java new file mode 100644 index 0000000..6720fbd --- /dev/null +++ b/sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/Contact.java @@ -0,0 +1,194 @@ +package org.scientificcms.contenttypes.scidepartment; + +import com.fasterxml.jackson.annotation.JsonIdentityInfo; +import com.fasterxml.jackson.annotation.JsonIdentityReference; +import com.fasterxml.jackson.annotation.ObjectIdGenerators; +import org.hibernate.envers.Audited; +import org.libreccm.core.CcmObjects; +import org.librecms.assets.ContactableEntity; + +import java.io.Serializable; +import java.util.Objects; +import java.util.Optional; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; +import javax.persistence.Table; + +import static org.scientificcms.contenttypes.scidepartment.SciDepartmentConstants.DB_SCHEMA; + +/** + * + * @author Jens Pelzetter + */ +@Entity(name = "DepartmentContact") +@Audited +@Table(name = "DEPARTMENT_CONTACTS", schema = DB_SCHEMA) +@JsonIdentityInfo( + generator = ObjectIdGenerators.PropertyGenerator.class, + property = "uuid" +) +public class Contact implements Serializable { + + private static final long serialVersionUID = 1L; + + @Id + @Column(name = "CONTACT_ID") + @GeneratedValue(strategy = GenerationType.AUTO) + private long contactId; + + @Column(name = "CONTACT_TYPE", length = 255, nullable = true) + private String contactType; + + @Column(name = "CONTACT_ORDER") + private long order; + + @ManyToOne + @JoinColumn(name = "DEPARTMENT_ID") + @JsonIdentityReference(alwaysAsId = true) + private SciDepartment department; + + @ManyToOne + @JoinColumn(name = "CONTACTABLE_ID") + @JsonIdentityReference(alwaysAsId = true) + private ContactableEntity contactable; + + public long getContactId() { + return contactId; + } + + protected void setContactId(final long contactId) { + this.contactId = contactId; + } + + public String getContactType() { + return contactType; + } + + public void setContactType(final String contactType) { + this.contactType = contactType; + } + + public long getOrder() { + return order; + } + + public void setOrder(final long order) { + this.order = order; + } + + public SciDepartment getDepartment() { + return department; + } + + protected void setDepartment(final SciDepartment department) { + this.department = department; + } + + public ContactableEntity getContactable() { + return contactable; + } + + protected void setContactable(final ContactableEntity contactable) { + this.contactable = contactable; + } + + @Override + public int hashCode() { + int hash = 7; + hash = 41 * hash + (int) (contactId ^ (contactId >>> 32)); + hash = 41 * hash + Objects.hashCode(contactType); + hash = 41 * hash + (int) (order ^ (order >>> 32)); + hash = 41 * hash + CcmObjects.hashCodeUsingUuid(department); + hash = 41 * hash + CcmObjects.hashCodeUsingUuid(contactable); + return hash; + } + + @Override + public boolean equals(final Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (!(obj instanceof Contact)) { + return false; + } + final Contact other = (Contact) obj; + if (!other.canEqual(this)) { + return false; + } + if (contactId != other.getContactId()) { + return false; + } + if (!Objects.equals(contactType, other.getContactType())) { + return false; + } + if (!CcmObjects.equalsUsingUuid(department, other.getDepartment())) { + return false; + } + if (!CcmObjects.equalsUsingUuid(contactable, other.getContactable())) { + return false; + } + return order == other.getOrder(); + } + + public boolean canEqual(final Object obj) { + + return obj instanceof Contact; + } + + @Override + public final String toString() { + return toString(""); + } + + public String toString(final String data) { + return String.format( + "%s{ " + + "contactId = %d, " + + "contactType = \"%s\", " + + "order = %d, " + + "project = { %s } " + + "contactableUuid = %s%s" + + " }", + super.toString(), + contactId, + contactType, + order, + Optional + .ofNullable(department) + .map( + dep -> String.format( + "objectId = %d," + + "uuid = \"%s\", " + + "name = \"%s\"", + dep.getObjectId(), + dep.getUuid(), + dep.getDisplayName() + ) + ) + .orElse(""), + Optional + .ofNullable(contactable) + .map( + entity -> String.format( + "objectId = %d," + + "uuid = \"%s\", " + + "name = \"%s\"", + entity.getObjectId(), + entity.getUuid(), + entity.getDisplayName() + ) + ) + .orElse(""), + data + ); + } +} diff --git a/sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/ContactRepository.java b/sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/ContactRepository.java new file mode 100644 index 0000000..7baf47d --- /dev/null +++ b/sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/ContactRepository.java @@ -0,0 +1,42 @@ +package org.scientificcms.contenttypes.scidepartment; + +import org.libreccm.auditing.AbstractAuditedEntityRepository; + +import javax.enterprise.context.RequestScoped; + +/** + * + * @author Jens Pelzetter + */ +@RequestScoped +public class ContactRepository + extends AbstractAuditedEntityRepository { + + private static final long serialVersionUID = 1L; + + @Override + public Long getEntityId(final Contact contact) { + return contact.getContactId(); + } + + @Override + public Class getEntityClass() { + return Contact.class; + } + + @Override + public String getIdAttributeName() { + return "contactId"; + } + + @Override + public Long getIdOfEntity(final Contact contact) { + return contact.getContactId(); + } + + @Override + public boolean isNew(final Contact contact) { + return contact.getContactId() == 0; + } + +} diff --git a/sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/DepartmentProject.java b/sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/DepartmentProject.java new file mode 100644 index 0000000..814a2eb --- /dev/null +++ b/sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/DepartmentProject.java @@ -0,0 +1,157 @@ +package org.scientificcms.contenttypes.scidepartment; + +import com.fasterxml.jackson.annotation.JsonIdentityReference; +import org.hibernate.envers.Audited; +import org.libreccm.core.CcmObjects; +import org.scientificcms.contenttypes.sciproject.SciProject; + +import java.io.Serializable; +import java.util.Objects; +import java.util.Optional; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; +import javax.persistence.Table; + +import static org.scientificcms.contenttypes.scidepartment.SciDepartmentConstants.DB_SCHEMA; + +/** + * + * @author Jens Pelzetter + */ +@Entity +@Audited +@Table(name = "DEPARTMENT_PROJECTS", schema = DB_SCHEMA) +public class DepartmentProject implements Serializable { + + private static final long serialVersionUID = 1L; + + @Id + @Column(name = "DEPARTMENT_PROJECT_ID") + @GeneratedValue(strategy = GenerationType.AUTO) + private long departmentProjectId; + + @ManyToOne + @JoinColumn(name = "DEPARTMENT_ID") + @JsonIdentityReference(alwaysAsId = true) + private SciDepartment department; + + @ManyToOne + @JoinColumn(name = "PROJECT_ID") + @JsonIdentityReference(alwaysAsId = true) + private SciProject project; + + public long getDepartmentProjectId() { + return departmentProjectId; + } + + protected void setDepartmentProjectId(final long departmentProjectId) { + this.departmentProjectId = departmentProjectId; + } + + public SciDepartment getDepartment() { + return department; + } + + protected void setDepartment(final SciDepartment department) { + this.department = department; + } + + public SciProject getProject() { + return project; + } + + protected void setProject(final SciProject project) { + this.project = project; + } + + @Override + public int hashCode() { + int hash = 7; + hash + = 59 * hash + (int) (departmentProjectId ^ (departmentProjectId + >>> 32)); + hash = 59 * hash + CcmObjects.hashCodeUsingUuid(department); + hash = 59 * hash + CcmObjects.hashCodeUsingUuid(project); + return hash; + } + + @Override + public boolean equals(final Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (!(obj instanceof DepartmentProject)) { + return false; + } + final DepartmentProject other = (DepartmentProject) obj; + if (!other.canEqual(this)) { + return false; + } + + if (departmentProjectId != other.getDepartmentProjectId()) { + return false; + } + if (!CcmObjects.equalsUsingUuid(department, other.getDepartment())) { + return false; + } + return CcmObjects.equalsUsingUuid(project, other.getProject()); + } + + public boolean canEqual(final Object obj) { + return obj instanceof DepartmentProject; + } + + @Override + public String toString() { + return toString(""); + } + + public String toString(final String data) { + return String.format( + "%s{ " + + "departmentProjectId = %d, " + + "department = { %s }, " + + "project = { %s}%s" + + " }", + super.toString(), + departmentProjectId, + Optional + .ofNullable(department) + .map( + dep -> String.format( + "objectId = %d," + + "uuid = \"%s\", " + + "name = \"%s\"", + dep.getObjectId(), + dep.getUuid(), + dep.getDisplayName() + ) + ) + .orElse(""), + Optional + .ofNullable(project) + .map( + proj -> String.format( + "objectId = %d," + + "uuid = \"%s\", " + + "name = \"%s\"", + project.getObjectId(), + project.getUuid(), + project.getDisplayName() + ) + ) + .orElse(""), + data + ); + } + +} diff --git a/sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/DepartmentProjectRepository.java b/sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/DepartmentProjectRepository.java new file mode 100644 index 0000000..b3266c8 --- /dev/null +++ b/sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/DepartmentProjectRepository.java @@ -0,0 +1,42 @@ +package org.scientificcms.contenttypes.scidepartment; + +import org.libreccm.auditing.AbstractAuditedEntityRepository; + +import javax.enterprise.context.RequestScoped; + +/** + * + * @author Jens Pelzetter + */ +@RequestScoped +public class DepartmentProjectRepository + extends AbstractAuditedEntityRepository { + + private static final long serialVersionUID = 1L; + + @Override + public Long getEntityId(final DepartmentProject project) { + return project.getDepartmentProjectId(); + } + + @Override + public Class getEntityClass() { + return DepartmentProject.class; + } + + @Override + public String getIdAttributeName() { + return "departmentProjectId"; + } + + @Override + public Long getIdOfEntity(final DepartmentProject project) { + return project.getDepartmentProjectId(); + } + + @Override + public boolean isNew(final DepartmentProject project) { + return project.getDepartmentProjectId() == 0; + } + +} diff --git a/sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/DepartmentText.java b/sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/DepartmentText.java new file mode 100644 index 0000000..dc1f781 --- /dev/null +++ b/sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/DepartmentText.java @@ -0,0 +1,185 @@ +package org.scientificcms.contenttypes.scidepartment; + +import com.fasterxml.jackson.annotation.JsonIdentityReference; +import org.hibernate.envers.Audited; +import org.libreccm.core.CcmObjects; +import org.libreccm.l10n.LocalizedString; + +import java.io.Serializable; +import java.util.Objects; +import java.util.Optional; + +import javax.persistence.AssociationOverride; +import javax.persistence.Column; +import javax.persistence.Embedded; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.JoinTable; +import javax.persistence.ManyToOne; +import javax.persistence.Table; + +import static org.scientificcms.contenttypes.scidepartment.SciDepartmentConstants.DB_SCHEMA; + +/** + * + * @author Jens Pelzetter + */ +@Entity +@Audited +@Table(name = "DEPARTMENT_TEXTS", schema = DB_SCHEMA) +public class DepartmentText implements Serializable { + + private static final long serialVersionUID = 1L; + + @Id + @Column(name = "TEXT_ID") + @GeneratedValue(strategy = GenerationType.AUTO) + private long textId; + + @Column(name = "key", length = 255, nullable = false) + private String key; + + @Column(name = "CONTACT_ORDER") + private long order; + + @ManyToOne + @JoinColumn(name = "DEPARTMENT_ID") + @JsonIdentityReference(alwaysAsId = true) + private SciDepartment department; + + @Embedded + @AssociationOverride( + name = "values", + joinTable = @JoinTable( + name = "DEPARTMENT_TEXT_VALUES", + schema = DB_SCHEMA, + joinColumns = { + @JoinColumn(name = "OBJECT_ID") + } + ) + ) + private LocalizedString text; + + public long getTextId() { + return textId; + } + + protected void setTextId(final long textId) { + this.textId = textId; + } + + public String getKey() { + return key; + } + + public void setKey(final String key) { + this.key = key; + } + + public long getOrder() { + return order; + } + + public void setOrder(final long order) { + this.order = order; + } + + public SciDepartment getDepartment() { + return department; + } + + public void setDepartment(final SciDepartment department) { + this.department = department; + } + + public LocalizedString getText() { + return text; + } + + public void setText(final LocalizedString text) { + this.text = text; + } + + @Override + public int hashCode() { + int hash = 7; + hash = 67 * hash + (int) (textId ^ (textId >>> 32)); + hash = 67 * hash + Objects.hashCode(key); + hash = 67 * hash + (int) (order ^ (order >>> 32)); + hash = 67 * hash + CcmObjects.hashCodeUsingUuid(department); + hash = 67 * hash + Objects.hashCode(text); + return hash; + } + + @Override + public boolean equals(final Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (!(obj instanceof DepartmentText)) { + return false; + } + final DepartmentText other = (DepartmentText) obj; + if (!other.canEqual(this)) { + return false; + } + + if (textId != other.getTextId()) { + return false; + } + if (order != other.getOrder()) { + return false; + } + if (!Objects.equals(key, other.getKey())) { + return false; + } + if (!Objects.equals(department, other.getDepartment())) { + return false; + } + return Objects.equals(text, other.getText()); + } + + public boolean canEqual(final Object obj) { + return obj instanceof DepartmentText; + } + + @Override + public String toString() { + return toString(""); + } + + public String toString(final String data) { + return String.format( + "textId = %d, " + + "key = %s, " + + "order = %d, " + + "department = { %s }, " + + "text = { %s }%s", + textId, + key, + order, + Optional + .ofNullable(department) + .map( + dep -> String.format( + "objectId = %d," + + "uuid = \"%s\", " + + "name = \"%s\"", + dep.getObjectId(), + dep.getUuid(), + dep.getDisplayName() + ) + ) + .orElse(""), + Objects.toString(text), + data + ); + } + +} diff --git a/sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/DepartmentTextRepository.java b/sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/DepartmentTextRepository.java new file mode 100644 index 0000000..a0dc64b --- /dev/null +++ b/sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/DepartmentTextRepository.java @@ -0,0 +1,40 @@ +package org.scientificcms.contenttypes.scidepartment; + +import org.libreccm.auditing.AbstractAuditedEntityRepository; + +import javax.enterprise.context.RequestScoped; + +/** + * + * @author Jens Pelzetter + */ +@RequestScoped +public class DepartmentTextRepository + extends AbstractAuditedEntityRepository { + + @Override + public Long getEntityId(final DepartmentText text) { + return text.getTextId(); + } + + @Override + public Class getEntityClass() { + return DepartmentText.class; + } + + @Override + public String getIdAttributeName() { + return "textId"; + } + + @Override + public Long getIdOfEntity(final DepartmentText text) { + return text.getTextId(); + } + + @Override + public boolean isNew(final DepartmentText text) { + return text.getTextId() == 0; + } + +} diff --git a/sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/Membership.java b/sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/Membership.java new file mode 100644 index 0000000..2418459 --- /dev/null +++ b/sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/Membership.java @@ -0,0 +1,207 @@ +package org.scientificcms.contenttypes.scidepartment; + +import com.fasterxml.jackson.annotation.JsonIdentityInfo; +import com.fasterxml.jackson.annotation.JsonIdentityReference; +import com.fasterxml.jackson.annotation.ObjectIdGenerators; +import org.hibernate.envers.Audited; +import org.libreccm.core.CcmObjects; +import org.librecms.assets.Person; + +import java.io.Serializable; +import java.util.Objects; +import java.util.Optional; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.EnumType; +import javax.persistence.Enumerated; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; +import javax.persistence.Table; + +import static org.scientificcms.contenttypes.scidepartment.SciDepartmentConstants.DB_SCHEMA; + +/** + * + * @author Jens Pelzetter + */ +@Entity(name = "DepartmentMembership") +@Audited +@Table(name = "DEPARTMENT_MEMBERSHIPS", schema = DB_SCHEMA) +@JsonIdentityInfo( + generator = ObjectIdGenerators.PropertyGenerator.class, + property = "uuid" +) +public class Membership implements Serializable { + + private static final long serialVersionUID = 1L; + + @Id + @Column(name = "MEMBERSHIP_ID") + @GeneratedValue(strategy = GenerationType.AUTO) + private long membershipId; + + @Column(name = "MEMBER_ROLE", length = 255, nullable = true) + private String role; + + @Column(name = "STATUS") + @Enumerated(EnumType.STRING) + private MembershipStatus status; + + @ManyToOne + @JoinColumn(name = "DEPARTMENT_ID") + @JsonIdentityReference(alwaysAsId = true) + private SciDepartment department; + + @ManyToOne + @JoinColumn(name = "MEMBER_ID") + @JsonIdentityReference(alwaysAsId = true) + private Person member; + + public long getMembershipId() { + return membershipId; + } + + protected void setMembershipId(final long membershipId) { + this.membershipId = membershipId; + } + + public String getRole() { + return role; + } + + public void setRole(final String role) { + this.role = role; + } + + public MembershipStatus getStatus() { + return status; + } + + public void setStatus(final MembershipStatus status) { + this.status = status; + } + + public SciDepartment getDepartment() { + return department; + } + + protected void setProject(final SciDepartment department) { + this.department = department; + } + + public Person getMember() { + return member; + } + + protected void setMember(final Person member) { + this.member = member; + } + + @Override + public int hashCode() { + int hash = 7; + hash = 37 * hash + + (int) (membershipId ^ (membershipId >>> 32)); + hash = 37 * hash + Objects.hashCode(role); + hash = 37 * hash + Objects.hashCode(status); + hash = 37 * hash + CcmObjects.hashCodeUsingUuid(department); + hash = 37 * hash + CcmObjects.hashCodeUsingUuid(member); + return hash; + } + + @Override + public boolean equals(final Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (!(obj instanceof Membership)) { + return false; + } + final Membership other = (Membership) obj; + if (!other.canEqual(this)) { + return false; + } + + if (membershipId != other.getMembershipId()) { + return false; + } + if (!Objects.equals(role, other.getRole())) { + return false; + } + + if (!CcmObjects.equalsUsingUuid(department, other.getDepartment())) { + return false; + } + if (!CcmObjects.equalsUsingUuid(member, other.getMember())) { + return false; + } + return status == other.getStatus(); + } + + public boolean canEqual(final Object obj) { + return obj instanceof Membership; + } + + @Override + public final String toString() { + return toString(""); + } + + public String toString(final String data) { + return String.format( + "%s{ " + + "membershipId = %d, " + + "role = \"%s\", " + + "status = \"%s\"," + + "project = { %s }, " + + "member = { %s }%s" + + " }", + super.toString(), + membershipId, + role, + Objects.toString(status), + Optional + .ofNullable(department) + .map( + dep -> String.format( + "objectId = %d," + + "uuid = \"%s\", " + + "name = \"%s\"", + dep.getObjectId(), + dep.getUuid(), + dep.getDisplayName() + ) + ) + .orElse(""), + Optional + .ofNullable(member) + .map( + person -> String.format( + "objectId = %d, " + + "uuid = \"%s\", " + + "name = \"%s\", " + + "surname = \"%s\", " + + "givenName = \"%s\", " + + "prefix = \"%s\", " + + "suffix = \"%s\"", + person.getObjectId(), + person.getUuid(), + person.getDisplayName(), + person.getPersonName().getSurname(), + person.getPersonName().getGivenName(), + person.getPersonName().getPrefix(), + person.getPersonName().getSuffix()) + ) + .orElse(""), + data + ); + } + +} diff --git a/sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/MembershipRepository.java b/sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/MembershipRepository.java new file mode 100644 index 0000000..6ba1116 --- /dev/null +++ b/sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/MembershipRepository.java @@ -0,0 +1,40 @@ +package org.scientificcms.contenttypes.scidepartment; + +import org.libreccm.auditing.AbstractAuditedEntityRepository; + +import javax.enterprise.context.RequestScoped; + +/** + * + * @author Jens Pelzetter + */ +@RequestScoped +public class MembershipRepository + extends AbstractAuditedEntityRepository { + + @Override + public Long getEntityId(final Membership membership) { + return membership.getMembershipId(); + } + + @Override + public Class getEntityClass() { + return Membership.class; + } + + @Override + public String getIdAttributeName() { + return "membershipId"; + } + + @Override + public Long getIdOfEntity(final Membership membership) { + return membership.getMembershipId(); + } + + @Override + public boolean isNew(final Membership membership) { + return membership.getMembershipId() == 0; + } + +} diff --git a/sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/MembershipStatus.java b/sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/MembershipStatus.java new file mode 100644 index 0000000..f353de2 --- /dev/null +++ b/sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/MembershipStatus.java @@ -0,0 +1,13 @@ +package org.scientificcms.contenttypes.scidepartment; + +/** + * + * @author Jens Pelzetter + */ +public enum MembershipStatus { + + ACTIVE, + ASSOCIATED, + FORMER, + +} diff --git a/sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/SciDepartment.java b/sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/SciDepartment.java index a4914b3..0f01fce 100644 --- a/sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/SciDepartment.java +++ b/sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/SciDepartment.java @@ -14,8 +14,12 @@ import org.scientificcms.contenttypes.scidepartment.ui.SciDepartmentExtendedProp import org.scientificcms.contenttypes.scidepartment.ui.SciDepartmentPropertiesStep; import java.io.Serializable; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Objects; import javax.persistence.AssociationOverride; import javax.persistence.CascadeType; @@ -95,8 +99,7 @@ public class SciDepartment extends ContentItem implements Serializable { ) ) private LocalizedString addendum; - - + @OneToMany(cascade = CascadeType.ALL, mappedBy = "department") @OrderBy("order ASC") @JsonIgnore @@ -111,11 +114,197 @@ public class SciDepartment extends ContentItem implements Serializable { @OrderBy("member ASC") @JsonIgnore private List members; - + @OneToMany(cascade = CascadeType.ALL, mappedBy = "project") - @OrderBy("member ASC") + @OrderBy("project ASC") @JsonIgnore private List projects; - - + + public SciDepartment() { + super(); + + shortDescription = new LocalizedString(); + departmentDescription = new LocalizedString(); + addendum = new LocalizedString(); + additionalTexts = new HashMap<>(); + contacts = new ArrayList<>(); + members = new ArrayList<>(); + projects = new ArrayList<>(); + } + + public LocalizedString getShortDescription() { + return shortDescription; + } + + public void setShortDescription(final LocalizedString shortDescription) { + this.shortDescription = shortDescription; + } + + public LocalizedString getDepartmentDescription() { + return departmentDescription; + } + + public void setDepartmentDescription( + final LocalizedString departmentDescription + ) { + this.departmentDescription = departmentDescription; + } + + public LocalizedString getAddendum() { + return addendum; + } + + public void setAddendum(final LocalizedString addendum) { + this.addendum = addendum; + } + + public Map getAdditionalTexts() { + return Collections.unmodifiableMap(additionalTexts); + } + + protected void putAdditionalText( + final String key, final DepartmentText text + ) { + additionalTexts.put(key, text); + } + + protected void removeAdditionalText(final String key) { + additionalTexts.remove(key); + } + + protected void setAdditionalTexts( + final Map additionalTexts + ) { + this.additionalTexts = new HashMap<>(additionalTexts); + } + + public List getContacts() { + return Collections.unmodifiableList(contacts); + } + + protected void addContact(final Contact contact) { + contacts.add(contact); + } + + protected void removeContact(final Contact contact) { + contacts.remove(contact); + } + + protected void setContacts(final List contacts) { + this.contacts = new ArrayList<>(contacts); + } + + public List getMembers() { + return Collections.unmodifiableList(members); + } + + protected void addMember(final Membership member) { + members.add(member); + } + + protected void removeMember(final Membership member) { + members.remove(member); + } + + protected void setMembers(final List members) { + this.members = new ArrayList<>(members); + } + + public List getProjects() { + return Collections.unmodifiableList(projects); + } + + protected void addProject(final DepartmentProject project) { + projects.add(project); + } + + protected void removeProject(final DepartmentProject project) { + projects.remove(project); + } + + protected void setProjects(final List projects) { + this.projects = new ArrayList<>(projects); + } + + @Override + public int hashCode() { + int hash = 3; + hash = 83 * hash + Objects.hashCode(shortDescription); + hash = 83 * hash + Objects.hashCode(departmentDescription); + hash = 83 * hash + Objects.hashCode(addendum); + hash = 83 * hash + Objects.hashCode(additionalTexts); + hash = 83 * hash + Objects.hashCode(contacts); + hash = 83 * hash + Objects.hashCode(members); + hash = 83 * hash + Objects.hashCode(projects); + return hash; + } + + @Override + public boolean equals(final Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (!(obj instanceof SciDepartment)) { + return false; + } + final SciDepartment other = (SciDepartment) obj; + if (!other.canEqual(this)) { + return false; + } + + if (!Objects.equals(shortDescription, other.getShortDescription())) { + return false; + } + if (!Objects.equals( + departmentDescription, + other.getDepartmentDescription() + )) { + return false; + } + if (!Objects.equals(addendum, other.getAddendum())) { + return false; + } + if (!Objects.equals(additionalTexts, other.getAdditionalTexts())) { + return false; + } + if (!Objects.equals(contacts, other.getContacts())) { + return false; + } + if (!Objects.equals(members, other.getMembers())) { + return false; + } + return Objects.equals(projects, other.getProjects()); + } + + @Override + public boolean canEqual(final Object obj) { + return obj instanceof SciDepartment; + } + + @Override + public String toString(final String data) { + return super.toString( + String.format( + "shortDescription = %s, " + + "departmentDescription = %s, " + + "addendum = %s, " + + "additionalTexts = %s, " + + "contacts = %s, " + + "members = %s, " + + "projects = %s%s", + Objects.toString(shortDescription), + Objects.toString(departmentDescription), + Objects.toString(addendum), + Objects.toString(additionalTexts), + Objects.toString(contacts), + Objects.toString(members), + Objects.toString(projects), + data + ) + ); + } + } diff --git a/sci-types-project/src/main/java/org/scientificcms/contenttypes/sciproject/Contact.java b/sci-types-project/src/main/java/org/scientificcms/contenttypes/sciproject/Contact.java index 1186f54..ee1e076 100644 --- a/sci-types-project/src/main/java/org/scientificcms/contenttypes/sciproject/Contact.java +++ b/sci-types-project/src/main/java/org/scientificcms/contenttypes/sciproject/Contact.java @@ -30,7 +30,7 @@ import static org.scientificcms.contenttypes.sciproject.SciProjectConstants.*; * * @author Jens Pelzetter */ -@Entity +@Entity(name = "ProjectContact") @Audited @Table(name = "PROJECT_CONTACTS", schema = DB_SCHEMA) @JsonIdentityInfo( diff --git a/sci-types-project/src/main/java/org/scientificcms/contenttypes/sciproject/Membership.java b/sci-types-project/src/main/java/org/scientificcms/contenttypes/sciproject/Membership.java index d0ab075..e22b97f 100644 --- a/sci-types-project/src/main/java/org/scientificcms/contenttypes/sciproject/Membership.java +++ b/sci-types-project/src/main/java/org/scientificcms/contenttypes/sciproject/Membership.java @@ -32,7 +32,7 @@ import static org.scientificcms.contenttypes.sciproject.SciProjectConstants.*; * * @author Jens Pelzetter */ -@Entity +@Entity(name = "PROJECT_MEMBERSHIP") @Audited @Table(name = "PROJECT_MEMBERSHIPS", schema = DB_SCHEMA) @JsonIdentityInfo( 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 7fc269a..f49b907 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 @@ -7,7 +7,6 @@ package org.scientificcms.contenttypes.sciproject; import com.fasterxml.jackson.annotation.JsonIdentityInfo; import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.ObjectIdGenerator; import com.fasterxml.jackson.annotation.ObjectIdGenerators; import javax.persistence.Entity; -- 2.52.0 From 82ef06c897b379c70c96873b4223f3918b768294 Mon Sep 17 00:00:00 2001 From: Jens Pelzetter Date: Thu, 29 Sep 2022 20:05:34 +0200 Subject: [PATCH 03/16] DB migrations and other utility classes for sci-types-department --- .gitignore | 1 + sci-types-department/package-lock.json | 6 + sci-types-department/pom.xml | 6 +- .../scidepartment/Membership.java | 2 +- .../scidepartment/SciDepartment.java | 4 +- .../scidepartment/SciDepartmentConfig.java | 52 ++++ .../SciDepartmentImExporter.java | 22 ++ .../scidepartment/SciDepartmentManager.java | 293 ++++++++++++++++++ .../h2/V7_0_0_0__create_tables.sql | 275 ++++++++++++++++ .../pgsql/V7_0_0_0__create_tables.sql | 275 ++++++++++++++++ ...idepartment.SciDepartmentModule.properties | 4 + .../DefaultContactTypes.properties | 1 + .../DefaultContactTypes_de.properties | 1 + .../sciproject/SciProjectMananger.java | 1 - 14 files changed, 936 insertions(+), 7 deletions(-) create mode 100644 sci-types-department/package-lock.json create mode 100644 sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/SciDepartmentConfig.java create mode 100644 sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/SciDepartmentImExporter.java create mode 100644 sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/SciDepartmentManager.java create mode 100644 sci-types-department/src/main/resources/db/migrations/org/scientificcms/sci_types_department/h2/V7_0_0_0__create_tables.sql create mode 100644 sci-types-department/src/main/resources/db/migrations/org/scientificcms/sci_types_department/pgsql/V7_0_0_0__create_tables.sql create mode 100644 sci-types-department/src/main/resources/module-info/org.scientificcms.contenttypes.scidepartment.SciDepartmentModule.properties create mode 100644 sci-types-department/src/main/resources/org/scientificcms/contenttypes/scidepartment/DefaultContactTypes.properties create mode 100644 sci-types-department/src/main/resources/org/scientificcms/contenttypes/scidepartment/DefaultContactTypes_de.properties diff --git a/.gitignore b/.gitignore index d420165..1d5b369 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ .settings node node_modules +/sci-types-department/target/ /sci-types-project/target/ /scientificcms/target/ /sci-publications/nbproject/ diff --git a/sci-types-department/package-lock.json b/sci-types-department/package-lock.json new file mode 100644 index 0000000..204c265 --- /dev/null +++ b/sci-types-department/package-lock.json @@ -0,0 +1,6 @@ +{ + "name": "sci-types-department", + "lockfileVersion": 2, + "requires": true, + "packages": {} +} diff --git a/sci-types-department/pom.xml b/sci-types-department/pom.xml index 71c8b51..f2671d6 100644 --- a/sci-types-department/pom.xml +++ b/sci-types-department/pom.xml @@ -166,7 +166,7 @@ - + org.apache.maven.plugins diff --git a/sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/Membership.java b/sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/Membership.java index 2418459..758fc9b 100644 --- a/sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/Membership.java +++ b/sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/Membership.java @@ -89,7 +89,7 @@ public class Membership implements Serializable { return department; } - protected void setProject(final SciDepartment department) { + protected void setDepartment(final SciDepartment department) { this.department = department; } diff --git a/sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/SciDepartment.java b/sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/SciDepartment.java index 0f01fce..742c941 100644 --- a/sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/SciDepartment.java +++ b/sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/SciDepartment.java @@ -110,12 +110,12 @@ public class SciDepartment extends ContentItem implements Serializable { @JsonIgnore private List contacts; - @OneToMany(cascade = CascadeType.ALL, mappedBy = "project") + @OneToMany(cascade = CascadeType.ALL, mappedBy = "department") @OrderBy("member ASC") @JsonIgnore private List members; - @OneToMany(cascade = CascadeType.ALL, mappedBy = "project") + @OneToMany(cascade = CascadeType.ALL, mappedBy = "department") @OrderBy("project ASC") @JsonIgnore private List projects; diff --git a/sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/SciDepartmentConfig.java b/sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/SciDepartmentConfig.java new file mode 100644 index 0000000..37b2955 --- /dev/null +++ b/sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/SciDepartmentConfig.java @@ -0,0 +1,52 @@ +package org.scientificcms.contenttypes.scidepartment; + +import org.libreccm.cdi.utils.CdiUtil; +import org.libreccm.configuration.Configuration; +import org.libreccm.configuration.ConfigurationManager; +import org.libreccm.configuration.Setting; + +/** + * + * @author Jens Pelzetter + */ +@Configuration +public class SciDepartmentConfig { + + @Setting + private String contactTypesBundleName + = "org.scientificcms.contenttypes.scidepartment.DefaultContactTypes"; + + @Setting + private String memberRolesBundleName + = "org.scientificcms.contenttypes.scidepartment.MemberRoles"; + + public static SciDepartmentConfig getConfig() { + final ConfigurationManager confManager = CdiUtil + .createCdiUtil() + .findBean(ConfigurationManager.class); + return confManager.findConfiguration(SciDepartmentConfig.class); + } + + public SciDepartmentConfig() { + super(); + } + + public String getContactTypesBundleName() { + return contactTypesBundleName; + } + + public void setContactTypesBundleName(final String contactTypesBundleName) { + this.contactTypesBundleName = contactTypesBundleName; + } + + public String getMemberRolesBundleName() { + return memberRolesBundleName; + } + + public void setMemberRolesBundleName(final String memberRolesBundleName) { + this.memberRolesBundleName = memberRolesBundleName; + } + + + +} diff --git a/sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/SciDepartmentImExporter.java b/sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/SciDepartmentImExporter.java new file mode 100644 index 0000000..ceb6502 --- /dev/null +++ b/sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/SciDepartmentImExporter.java @@ -0,0 +1,22 @@ +package org.scientificcms.contenttypes.scidepartment; + +import org.libreccm.imexport.Processes; +import org.librecms.contentsection.AbstractContentItemImExporter; + +import javax.enterprise.context.RequestScoped; + +/** + * + * @author Jens Pelzetter + */ +@RequestScoped +@Processes(SciDepartment.class) +public class SciDepartmentImExporter + extends AbstractContentItemImExporter{ + + @Override + public Class getEntityClass() { + return SciDepartment.class; + } + +} diff --git a/sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/SciDepartmentManager.java b/sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/SciDepartmentManager.java new file mode 100644 index 0000000..d5c7617 --- /dev/null +++ b/sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/SciDepartmentManager.java @@ -0,0 +1,293 @@ +package org.scientificcms.contenttypes.scidepartment; + +import org.libreccm.l10n.LocalizedString; +import org.librecms.assets.ContactableEntity; +import org.librecms.assets.Person; +import org.librecms.contentsection.ContentItemRepository; +import org.scientificcms.contenttypes.sciproject.SciProject; + +import java.io.Serializable; +import java.util.Objects; +import java.util.Optional; + +import javax.enterprise.context.RequestScoped; +import javax.inject.Inject; +import javax.transaction.Transactional; + +/** + * + * @author Jens Pelzetter + */ +@RequestScoped +public class SciDepartmentManager implements Serializable { + + private static final long serialVersionUID = 1L; + + @Inject + private ContactRepository contactRepo; + + @Inject + private ContentItemRepository itemRepo; + + @Inject + private DepartmentProjectRepository departmentProjectRepo; + + @Inject + private DepartmentTextRepository departmentTextRepo; + + @Inject + private MembershipRepository membershipRepo; + + @Transactional(Transactional.TxType.REQUIRED) + public void addText( + final LocalizedString text, + final SciDepartment toDepartment, + final String withKey + ) { + Objects.requireNonNull( + toDepartment, + "Can't add a text to department null" + ); + Objects.requireNonNull(text, "Can't add null as text."); + Objects.requireNonNull( + withKey, + "Can't add a text to a department with key null." + ); + if (withKey.isBlank()) { + throw new IllegalArgumentException( + "Can't add a text to a department using a blank key." + ); + } + + final DepartmentText departmentText = new DepartmentText(); + departmentText.setDepartment(toDepartment); + departmentText.setKey(withKey); + departmentText.setOrder(toDepartment.getAdditionalTexts().size()); + departmentText.setText(text); + + toDepartment.putAdditionalText(withKey, departmentText); + departmentTextRepo.save(departmentText); + itemRepo.save(toDepartment); + } + + @Transactional(Transactional.TxType.REQUIRED) + public void removeText( + final SciDepartment fromDepartment, + final String withKey + ) { + Objects.requireNonNull( + fromDepartment, + "Can't remove a text from department null." + ); + + if (fromDepartment.getAdditionalTexts().containsKey(withKey)) { + final DepartmentText removed = fromDepartment + .getAdditionalTexts() + .get(withKey); + fromDepartment.removeAdditionalText(withKey); + itemRepo.save(fromDepartment); + departmentTextRepo.delete(removed); + } + } + + @Transactional(Transactional.TxType.REQUIRED) + public void addContact( + final ContactableEntity contactable, + final SciDepartment toDepartment, + final String withType + ) { + Objects.requireNonNull( + contactable, + "Can't add null as Contact to a SciDepartment." + ); + Objects.requireNonNull( + toDepartment, + "Can't add a Contact to a department null." + ); + + final Contact contact = new Contact(); + contact.setContactable(contactable); + contact.setDepartment(toDepartment); + contact.setContactType(withType); + contact.setOrder(toDepartment.getContacts().size()); + + toDepartment.addContact(contact); + contactRepo.save(contact); + itemRepo.save(toDepartment); + } + + @Transactional(Transactional.TxType.REQUIRED) + public void removeContact( + final ContactableEntity contactable, + final SciDepartment fromDepartment + ) { + Objects.requireNonNull( + contactable, + "Can't remove null as Contact from a SciDepartment." + ); + Objects.requireNonNull( + fromDepartment, + "Can't remove a Contact from department null." + ); + + final Optional result = fromDepartment + .getContacts() + .stream() + .filter( + contact -> filterContact(contact, contactable, fromDepartment) + ) + .findFirst(); + + if (result.isPresent()) { + final Contact removed = result.get(); + fromDepartment.removeContact(removed); + itemRepo.save(fromDepartment); + contactRepo.delete(removed); + } + } + + @Transactional(Transactional.TxType.REQUIRED) + public void addMember( + final Person person, + final SciDepartment toDepartment, + final String withRole, + final MembershipStatus withStatus + ) { + Objects.requireNonNull( + person, + "Can't add null as a member null to a SciDepartment." + ); + Objects.requireNonNull( + toDepartment, + "Can't a member to a SciDepartment null." + ); + + final Membership membership = new Membership(); + membership.setDepartment(toDepartment); + membership.setMember(person); + membership.setRole(withRole); + membership.setStatus(withStatus); + + toDepartment.addMember(membership); + membershipRepo.save(membership); + itemRepo.save(toDepartment); + } + + @Transactional(Transactional.TxType.REQUIRED) + public void removeMember( + final Person person, + final SciDepartment fromDepartment + ) { + Objects.requireNonNull( + person, + "Can't remove null as a member from a SciDepartment." + ); + Objects.requireNonNull( + fromDepartment, + "Can't remove a member from a SciDepartment null." + ); + + final Optional result = fromDepartment + .getMembers() + .stream() + .filter( + membership -> filterMembership( + membership, + person, + fromDepartment + ) + ) + .findFirst(); + + if (result.isPresent()) { + final Membership removed = result.get(); + fromDepartment.removeMember(removed); + itemRepo.save(fromDepartment); + membershipRepo.delete(removed); + } + } + + @Transactional(Transactional.TxType.REQUIRED) + public void addProject( + final SciProject project, + final SciDepartment toDepartment + ) { + Objects.requireNonNull( + project, + "Can't add null as a project null to a SciDepartment." + ); + Objects.requireNonNull( + toDepartment, + "Can't a project to a SciDepartment null." + ); + + final DepartmentProject departmentProject =new DepartmentProject(); + departmentProject.setDepartment(toDepartment); + departmentProject.setProject(project); + + toDepartment.addProject(departmentProject); + departmentProjectRepo.save(departmentProject); + itemRepo.save(project); + } + + @Transactional(Transactional.TxType.REQUIRED) + public void removeProject( + final SciProject project, + final SciDepartment fromDepartment + ) { + Objects.requireNonNull( + project, + "Can't remove null as a project from a SciDepartment." + ); + Objects.requireNonNull( + fromDepartment, + "Can't remove a project from a SciDepartment null." + ); + + final Optional result = fromDepartment + .getProjects() + .stream() + .filter( + departmentProject -> filterDepartmentProject( + departmentProject, project, fromDepartment + ) + ) + .findFirst(); + + if (result.isPresent()) { + final DepartmentProject removed = result.get(); + fromDepartment.removeProject(removed); + itemRepo.save(fromDepartment); + departmentProjectRepo.delete(removed); + } + } + + private boolean filterContact( + final Contact contact, + final ContactableEntity byContactable, + final SciDepartment byDepartment + ) { + return contact.getContactable().equals(byContactable) + && contact.getDepartment().equals(byDepartment); + } + + private boolean filterMembership( + final Membership membership, + final Person byPerson, + final SciDepartment byDepartment + ) { + return membership.getMember().equals(byPerson) + && membership.getDepartment().equals(byDepartment); + } + + private boolean filterDepartmentProject( + final DepartmentProject departmentProject, + final SciProject byProject, + final SciDepartment byDepartment + + ) { + return departmentProject.getProject().equals(byProject) + && departmentProject.getDepartment().equals(byDepartment); + } + +} diff --git a/sci-types-department/src/main/resources/db/migrations/org/scientificcms/sci_types_department/h2/V7_0_0_0__create_tables.sql b/sci-types-department/src/main/resources/db/migrations/org/scientificcms/sci_types_department/h2/V7_0_0_0__create_tables.sql new file mode 100644 index 0000000..45a682b --- /dev/null +++ b/sci-types-department/src/main/resources/db/migrations/org/scientificcms/sci_types_department/h2/V7_0_0_0__create_tables.sql @@ -0,0 +1,275 @@ + create table SCI_TYPES_PROJECT.PROJECT_CONTACTS ( + CONTACT_ID bigint not null, + CONTACT_TYPE varchar(255), + CONTACT_ORDER bigint, + CONTACTABLE_ID bigint, + PROJECT_ID bigint, + primary key (CONTACT_ID) + ); + + create table SCI_TYPES_PROJECT.PROJECT_CONTACTS_AUD ( + CONTACT_ID bigint not null, + REV integer not null, + REVTYPE tinyint, + REVEND integer, + CONTACT_TYPE varchar(255), + CONTACT_ORDER bigint, + CONTACTABLE_ID bigint, + PROJECT_ID bigint, + primary key (CONTACT_ID, REV) + ); + + create table SCI_TYPES_PROJECT.PROJECT_DESCS ( + OBJECT_ID bigint not null, + LOCALIZED_VALUE varchar(2147483647), + LOCALE varchar(255) not null, + primary key (OBJECT_ID, LOCALE) + ); + + create table SCI_TYPES_PROJECT.PROJECT_DESCS_AUD ( + REV integer not null, + OBJECT_ID bigint not null, + LOCALIZED_VALUE varchar(2147483647) not null, + LOCALE varchar(255) not null, + REVTYPE tinyint, + REVEND integer, + primary key (REV, OBJECT_ID, LOCALIZED_VALUE, LOCALE) + ); + + create table SCI_TYPES_PROJECT.PROJECT_FUNDING ( + OBJECT_ID bigint not null, + LOCALIZED_VALUE varchar(2147483647), + LOCALE varchar(255) not null, + primary key (OBJECT_ID, LOCALE) + ); + + create table SCI_TYPES_PROJECT.PROJECT_FUNDING_AUD ( + REV integer not null, + OBJECT_ID bigint not null, + LOCALIZED_VALUE varchar(2147483647) not null, + LOCALE varchar(255) not null, + REVTYPE tinyint, + REVEND integer, + primary key (REV, OBJECT_ID, LOCALIZED_VALUE, LOCALE) + ); + + create table SCI_TYPES_PROJECT.PROJECT_FUNDING_VOLUME ( + OBJECT_ID bigint not null, + LOCALIZED_VALUE varchar(2147483647), + LOCALE varchar(255) not null, + primary key (OBJECT_ID, LOCALE) + ); + + create table SCI_TYPES_PROJECT.PROJECT_FUNDING_VOLUME_AUD ( + REV integer not null, + OBJECT_ID bigint not null, + LOCALIZED_VALUE varchar(2147483647) not null, + LOCALE varchar(255) not null, + REVTYPE tinyint, + REVEND integer, + primary key (REV, OBJECT_ID, LOCALIZED_VALUE, LOCALE) + ); + + create table SCI_TYPES_PROJECT.PROJECT_MEMBERSHIPS ( + MEMBERSHIP_ID bigint not null, + MEMBER_ROLE varchar(255), + STATUS varchar(255), + MEMBER_ID bigint, + PROJECT_ID bigint, + primary key (MEMBERSHIP_ID) + ); + + create table SCI_TYPES_PROJECT.PROJECT_MEMBERSHIPS_AUD ( + MEMBERSHIP_ID bigint not null, + REV integer not null, + REVTYPE tinyint, + REVEND integer, + MEMBER_ROLE varchar(255), + STATUS varchar(255), + MEMBER_ID bigint, + PROJECT_ID bigint, + primary key (MEMBERSHIP_ID, REV) + ); + + create table SCI_TYPES_PROJECT.PROJECT_SHORT_DESCS ( + OBJECT_ID bigint not null, + LOCALIZED_VALUE varchar(2147483647), + LOCALE varchar(255) not null, + primary key (OBJECT_ID, LOCALE) + ); + + create table SCI_TYPES_PROJECT.PROJECT_SHORT_DESCS_AUD ( + REV integer not null, + OBJECT_ID bigint not null, + LOCALIZED_VALUE varchar(2147483647) not null, + LOCALE varchar(255) not null, + REVTYPE tinyint, + REVEND integer, + primary key (REV, OBJECT_ID, LOCALIZED_VALUE, LOCALE) + ); + + create table SCI_TYPES_PROJECT.PROJECTS ( + PROJECT_BEGIN date, + PROJECT_END date, + OBJECT_ID bigint not null, + primary key (OBJECT_ID) + ); + + create table SCI_TYPES_PROJECT.PROJECTS_AUD ( + OBJECT_ID bigint not null, + REV integer not null, + PROJECT_BEGIN date, + PROJECT_END date, + primary key (OBJECT_ID, REV) + ); + + create table SCI_TYPES_PROJECT.SPONSORING ( + SPONSORING_ID bigint not null, + FUNDING_CODE varchar(512), + SPONSOR_ORDER bigint, + PROJECT_ID bigint, + SPONSOR_ID bigint, + primary key (SPONSORING_ID) + ); + + create table SCI_TYPES_PROJECT.SPONSORING_AUD ( + SPONSORING_ID bigint not null, + REV integer not null, + REVTYPE tinyint, + REVEND integer, + FUNDING_CODE varchar(512), + SPONSOR_ORDER bigint, + PROJECT_ID bigint, + SPONSOR_ID bigint, + primary key (SPONSORING_ID, REV) + ); + + alter table SCI_TYPES_PROJECT.PROJECT_CONTACTS + add constraint FKgnma88ye77fb0vdmpuepyb2y7 + foreign key (CONTACTABLE_ID) + references CCM_CMS.CONTACTABLE_ENTITIES; + + alter table SCI_TYPES_PROJECT.PROJECT_CONTACTS + add constraint FK21fku49mpakv86hra725t3sok + foreign key (PROJECT_ID) + references SCI_TYPES_PROJECT.PROJECTS; + + alter table SCI_TYPES_PROJECT.PROJECT_CONTACTS_AUD + add constraint FK15m4nnwrt964isduiuk8bbeg8 + foreign key (REV) + references CCM_CORE.CCM_REVISIONS; + + alter table SCI_TYPES_PROJECT.PROJECT_CONTACTS_AUD + add constraint FKciyhqi7w2dby8e3b4arklmfqp + foreign key (REVEND) + references CCM_CORE.CCM_REVISIONS; + + alter table SCI_TYPES_PROJECT.PROJECT_DESCS + add constraint FKfh5goal8j4gsjhf65gxm11gxu + foreign key (OBJECT_ID) + references SCI_TYPES_PROJECT.PROJECTS; + + alter table SCI_TYPES_PROJECT.PROJECT_DESCS_AUD + add constraint FKfq5fyp71qmrc9y0h6px8vae7l + foreign key (REV) + references CCM_CORE.CCM_REVISIONS; + + alter table SCI_TYPES_PROJECT.PROJECT_DESCS_AUD + add constraint FK6615a6cc9tcmovk51a9vqff7x + foreign key (REVEND) + references CCM_CORE.CCM_REVISIONS; + + alter table SCI_TYPES_PROJECT.PROJECT_FUNDING + add constraint FKqmq8depjmuly0lixjljwnwut5 + foreign key (OBJECT_ID) + references SCI_TYPES_PROJECT.PROJECTS; + + alter table SCI_TYPES_PROJECT.PROJECT_FUNDING_AUD + add constraint FK664s3oomoj23e9hvbh97hg5dw + foreign key (REV) + references CCM_CORE.CCM_REVISIONS; + + alter table SCI_TYPES_PROJECT.PROJECT_FUNDING_AUD + add constraint FKgtsw7ruamw5m1p15p5y261a23 + foreign key (REVEND) + references CCM_CORE.CCM_REVISIONS; + + alter table SCI_TYPES_PROJECT.PROJECT_FUNDING_VOLUME + add constraint FKf6lg5n24snpplnvctdknh4mrv + foreign key (OBJECT_ID) + references SCI_TYPES_PROJECT.PROJECTS; + + alter table SCI_TYPES_PROJECT.PROJECT_FUNDING_VOLUME_AUD + add constraint FKgnnop98oxffgs7bp9bspajhw9 + foreign key (REV) + references CCM_CORE.CCM_REVISIONS; + + alter table SCI_TYPES_PROJECT.PROJECT_FUNDING_VOLUME_AUD + add constraint FKk599wppcylm8yo704ht3w7ibj + foreign key (REVEND) + references CCM_CORE.CCM_REVISIONS; + + alter table SCI_TYPES_PROJECT.PROJECT_MEMBERSHIPS + add constraint FKdbcet4i6wg7jinmaa0wchqujp + foreign key (MEMBER_ID) + references CCM_CMS.PERSONS; + + alter table SCI_TYPES_PROJECT.PROJECT_MEMBERSHIPS + add constraint FK54cqbnqwnv7e13p7k842nmjvt + foreign key (PROJECT_ID) + references SCI_TYPES_PROJECT.PROJECTS; + + alter table SCI_TYPES_PROJECT.PROJECT_MEMBERSHIPS_AUD + add constraint FKjdf8o2a5cuusgee0v43n562y4 + foreign key (REV) + references CCM_CORE.CCM_REVISIONS; + + alter table SCI_TYPES_PROJECT.PROJECT_MEMBERSHIPS_AUD + add constraint FK7yfj65ojma1coq2eeywpu0fcp + foreign key (REVEND) + references CCM_CORE.CCM_REVISIONS; + + alter table SCI_TYPES_PROJECT.PROJECT_SHORT_DESCS + add constraint FKqbbb85ebs497yad3gx07kdt1e + foreign key (OBJECT_ID) + references SCI_TYPES_PROJECT.PROJECTS; + + alter table SCI_TYPES_PROJECT.PROJECT_SHORT_DESCS_AUD + add constraint FK4ijysk1fk31o5kljgpc2p7yq6 + foreign key (REV) + references CCM_CORE.CCM_REVISIONS; + + alter table SCI_TYPES_PROJECT.PROJECT_SHORT_DESCS_AUD + add constraint FKkmidmqbpihxhfu1349lcw0rb0 + foreign key (REVEND) + references CCM_CORE.CCM_REVISIONS; + + alter table SCI_TYPES_PROJECT.PROJECTS + add constraint FKqlmls86i354oxprglxg5j9xxy + foreign key (OBJECT_ID) + references CCM_CMS.CONTENT_ITEMS; + + alter table SCI_TYPES_PROJECT.PROJECTS_AUD + add constraint FKss0w64wsb71r39npak6tg963b + foreign key (OBJECT_ID, REV) + references CCM_CMS.CONTENT_ITEMS_AUD; + + alter table SCI_TYPES_PROJECT.SPONSORING + add constraint FKe8posjrbtsvd7t8q3k8l7ybmy + foreign key (PROJECT_ID) + references SCI_TYPES_PROJECT.PROJECTS; + + alter table SCI_TYPES_PROJECT.SPONSORING + add constraint FKt63gl8j92rua5risu9cnhd3py + foreign key (SPONSOR_ID) + references CCM_CMS.ORGANIZATIONS; + + alter table SCI_TYPES_PROJECT.SPONSORING_AUD + add constraint FK7ci9e1fuqi8vbjcp9x70747se + foreign key (REV) + references CCM_CORE.CCM_REVISIONS; + + alter table SCI_TYPES_PROJECT.SPONSORING_AUD + add constraint FKfa0ems4hsww6wgoapss1bx38f + foreign key (REVEND) + references CCM_CORE.CCM_REVISIONS; diff --git a/sci-types-department/src/main/resources/db/migrations/org/scientificcms/sci_types_department/pgsql/V7_0_0_0__create_tables.sql b/sci-types-department/src/main/resources/db/migrations/org/scientificcms/sci_types_department/pgsql/V7_0_0_0__create_tables.sql new file mode 100644 index 0000000..8f5c82e --- /dev/null +++ b/sci-types-department/src/main/resources/db/migrations/org/scientificcms/sci_types_department/pgsql/V7_0_0_0__create_tables.sql @@ -0,0 +1,275 @@ + create table SCI_TYPES_PROJECT.PROJECT_CONTACTS ( + CONTACT_ID int8 not null, + CONTACT_TYPE varchar(255), + CONTACT_ORDER int8, + CONTACTABLE_ID int8, + PROJECT_ID int8, + primary key (CONTACT_ID) + ); + + create table SCI_TYPES_PROJECT.PROJECT_CONTACTS_AUD ( + CONTACT_ID int8 not null, + REV int4 not null, + REVTYPE int2, + REVEND int4, + CONTACT_TYPE varchar(255), + CONTACT_ORDER int8, + CONTACTABLE_ID int8, + PROJECT_ID int8, + primary key (CONTACT_ID, REV) + ); + + create table SCI_TYPES_PROJECT.PROJECT_DESCS ( + OBJECT_ID int8 not null, + LOCALIZED_VALUE text, + LOCALE varchar(255) not null, + primary key (OBJECT_ID, LOCALE) + ); + + create table SCI_TYPES_PROJECT.PROJECT_DESCS_AUD ( + REV int4 not null, + OBJECT_ID int8 not null, + LOCALIZED_VALUE text not null, + LOCALE varchar(255) not null, + REVTYPE int2, + REVEND int4, + primary key (REV, OBJECT_ID, LOCALIZED_VALUE, LOCALE) + ); + + create table SCI_TYPES_PROJECT.PROJECT_FUNDING ( + OBJECT_ID int8 not null, + LOCALIZED_VALUE text, + LOCALE varchar(255) not null, + primary key (OBJECT_ID, LOCALE) + ); + + create table SCI_TYPES_PROJECT.PROJECT_FUNDING_AUD ( + REV int4 not null, + OBJECT_ID int8 not null, + LOCALIZED_VALUE text not null, + LOCALE varchar(255) not null, + REVTYPE int2, + REVEND int4, + primary key (REV, OBJECT_ID, LOCALIZED_VALUE, LOCALE) + ); + + create table SCI_TYPES_PROJECT.PROJECT_FUNDING_VOLUME ( + OBJECT_ID int8 not null, + LOCALIZED_VALUE text, + LOCALE varchar(255) not null, + primary key (OBJECT_ID, LOCALE) + ); + + create table SCI_TYPES_PROJECT.PROJECT_FUNDING_VOLUME_AUD ( + REV int4 not null, + OBJECT_ID int8 not null, + LOCALIZED_VALUE text not null, + LOCALE varchar(255) not null, + REVTYPE int2, + REVEND int4, + primary key (REV, OBJECT_ID, LOCALIZED_VALUE, LOCALE) + ); + + create table SCI_TYPES_PROJECT.PROJECT_MEMBERSHIPS ( + MEMBERSHIP_ID int8 not null, + MEMBER_ROLE varchar(255), + STATUS varchar(255), + MEMBER_ID int8, + PROJECT_ID int8, + primary key (MEMBERSHIP_ID) + ); + + create table SCI_TYPES_PROJECT.PROJECT_MEMBERSHIPS_AUD ( + MEMBERSHIP_ID int8 not null, + REV int4 not null, + REVTYPE int2, + REVEND int4, + MEMBER_ROLE varchar(255), + STATUS varchar(255), + MEMBER_ID int8, + PROJECT_ID int8, + primary key (MEMBERSHIP_ID, REV) + ); + + create table SCI_TYPES_PROJECT.PROJECT_SHORT_DESCS ( + OBJECT_ID int8 not null, + LOCALIZED_VALUE text, + LOCALE varchar(255) not null, + primary key (OBJECT_ID, LOCALE) + ); + + create table SCI_TYPES_PROJECT.PROJECT_SHORT_DESCS_AUD ( + REV int4 not null, + OBJECT_ID int8 not null, + LOCALIZED_VALUE text not null, + LOCALE varchar(255) not null, + REVTYPE int2, + REVEND int4, + primary key (REV, OBJECT_ID, LOCALIZED_VALUE, LOCALE) + ); + + create table SCI_TYPES_PROJECT.PROJECTS ( + PROJECT_BEGIN date, + PROJECT_END date, + OBJECT_ID int8 not null, + primary key (OBJECT_ID) + ); + + create table SCI_TYPES_PROJECT.PROJECTS_AUD ( + OBJECT_ID int8 not null, + REV int4 not null, + PROJECT_BEGIN date, + PROJECT_END date, + primary key (OBJECT_ID, REV) + ); + + create table SCI_TYPES_PROJECT.SPONSORING ( + SPONSORING_ID int8 not null, + FUNDING_CODE varchar(512), + SPONSOR_ORDER int8, + PROJECT_ID int8, + SPONSOR_ID int8, + primary key (SPONSORING_ID) + ); + + create table SCI_TYPES_PROJECT.SPONSORING_AUD ( + SPONSORING_ID int8 not null, + REV int4 not null, + REVTYPE int2, + REVEND int4, + FUNDING_CODE varchar(512), + SPONSOR_ORDER int8, + PROJECT_ID int8, + SPONSOR_ID int8, + primary key (SPONSORING_ID, REV) + ); + + alter table SCI_TYPES_PROJECT.PROJECT_CONTACTS + add constraint FKgnma88ye77fb0vdmpuepyb2y7 + foreign key (CONTACTABLE_ID) + references CCM_CMS.CONTACTABLE_ENTITIES; + + alter table SCI_TYPES_PROJECT.PROJECT_CONTACTS + add constraint FK21fku49mpakv86hra725t3sok + foreign key (PROJECT_ID) + references SCI_TYPES_PROJECT.PROJECTS; + + alter table SCI_TYPES_PROJECT.PROJECT_CONTACTS_AUD + add constraint FK15m4nnwrt964isduiuk8bbeg8 + foreign key (REV) + references CCM_CORE.CCM_REVISIONS; + + alter table SCI_TYPES_PROJECT.PROJECT_CONTACTS_AUD + add constraint FKciyhqi7w2dby8e3b4arklmfqp + foreign key (REVEND) + references CCM_CORE.CCM_REVISIONS; + + alter table SCI_TYPES_PROJECT.PROJECT_DESCS + add constraint FKfh5goal8j4gsjhf65gxm11gxu + foreign key (OBJECT_ID) + references SCI_TYPES_PROJECT.PROJECTS; + + alter table SCI_TYPES_PROJECT.PROJECT_DESCS_AUD + add constraint FKfq5fyp71qmrc9y0h6px8vae7l + foreign key (REV) + references CCM_CORE.CCM_REVISIONS; + + alter table SCI_TYPES_PROJECT.PROJECT_DESCS_AUD + add constraint FK6615a6cc9tcmovk51a9vqff7x + foreign key (REVEND) + references CCM_CORE.CCM_REVISIONS; + + alter table SCI_TYPES_PROJECT.PROJECT_FUNDING + add constraint FKqmq8depjmuly0lixjljwnwut5 + foreign key (OBJECT_ID) + references SCI_TYPES_PROJECT.PROJECTS; + + alter table SCI_TYPES_PROJECT.PROJECT_FUNDING_AUD + add constraint FK664s3oomoj23e9hvbh97hg5dw + foreign key (REV) + references CCM_CORE.CCM_REVISIONS; + + alter table SCI_TYPES_PROJECT.PROJECT_FUNDING_AUD + add constraint FKgtsw7ruamw5m1p15p5y261a23 + foreign key (REVEND) + references CCM_CORE.CCM_REVISIONS; + + alter table SCI_TYPES_PROJECT.PROJECT_FUNDING_VOLUME + add constraint FKf6lg5n24snpplnvctdknh4mrv + foreign key (OBJECT_ID) + references SCI_TYPES_PROJECT.PROJECTS; + + alter table SCI_TYPES_PROJECT.PROJECT_FUNDING_VOLUME_AUD + add constraint FKgnnop98oxffgs7bp9bspajhw9 + foreign key (REV) + references CCM_CORE.CCM_REVISIONS; + + alter table SCI_TYPES_PROJECT.PROJECT_FUNDING_VOLUME_AUD + add constraint FKk599wppcylm8yo704ht3w7ibj + foreign key (REVEND) + references CCM_CORE.CCM_REVISIONS; + + alter table SCI_TYPES_PROJECT.PROJECT_MEMBERSHIPS + add constraint FKdbcet4i6wg7jinmaa0wchqujp + foreign key (MEMBER_ID) + references CCM_CMS.PERSONS; + + alter table SCI_TYPES_PROJECT.PROJECT_MEMBERSHIPS + add constraint FK54cqbnqwnv7e13p7k842nmjvt + foreign key (PROJECT_ID) + references SCI_TYPES_PROJECT.PROJECTS; + + alter table SCI_TYPES_PROJECT.PROJECT_MEMBERSHIPS_AUD + add constraint FKjdf8o2a5cuusgee0v43n562y4 + foreign key (REV) + references CCM_CORE.CCM_REVISIONS; + + alter table SCI_TYPES_PROJECT.PROJECT_MEMBERSHIPS_AUD + add constraint FK7yfj65ojma1coq2eeywpu0fcp + foreign key (REVEND) + references CCM_CORE.CCM_REVISIONS; + + alter table SCI_TYPES_PROJECT.PROJECT_SHORT_DESCS + add constraint FKqbbb85ebs497yad3gx07kdt1e + foreign key (OBJECT_ID) + references SCI_TYPES_PROJECT.PROJECTS; + + alter table SCI_TYPES_PROJECT.PROJECT_SHORT_DESCS_AUD + add constraint FK4ijysk1fk31o5kljgpc2p7yq6 + foreign key (REV) + references CCM_CORE.CCM_REVISIONS; + + alter table SCI_TYPES_PROJECT.PROJECT_SHORT_DESCS_AUD + add constraint FKkmidmqbpihxhfu1349lcw0rb0 + foreign key (REVEND) + references CCM_CORE.CCM_REVISIONS; + + alter table SCI_TYPES_PROJECT.PROJECTS + add constraint FKqlmls86i354oxprglxg5j9xxy + foreign key (OBJECT_ID) + references CCM_CMS.CONTENT_ITEMS; + + alter table SCI_TYPES_PROJECT.PROJECTS_AUD + add constraint FKss0w64wsb71r39npak6tg963b + foreign key (OBJECT_ID, REV) + references CCM_CMS.CONTENT_ITEMS_AUD; + + alter table SCI_TYPES_PROJECT.SPONSORING + add constraint FKe8posjrbtsvd7t8q3k8l7ybmy + foreign key (PROJECT_ID) + references SCI_TYPES_PROJECT.PROJECTS; + + alter table SCI_TYPES_PROJECT.SPONSORING + add constraint FKt63gl8j92rua5risu9cnhd3py + foreign key (SPONSOR_ID) + references CCM_CMS.ORGANIZATIONS; + + alter table SCI_TYPES_PROJECT.SPONSORING_AUD + add constraint FK7ci9e1fuqi8vbjcp9x70747se + foreign key (REV) + references CCM_CORE.CCM_REVISIONS; + + alter table SCI_TYPES_PROJECT.SPONSORING_AUD + add constraint FKfa0ems4hsww6wgoapss1bx38f + foreign key (REVEND) + references CCM_CORE.CCM_REVISIONS; diff --git a/sci-types-department/src/main/resources/module-info/org.scientificcms.contenttypes.scidepartment.SciDepartmentModule.properties b/sci-types-department/src/main/resources/module-info/org.scientificcms.contenttypes.scidepartment.SciDepartmentModule.properties new file mode 100644 index 0000000..b9f3b36 --- /dev/null +++ b/sci-types-department/src/main/resources/module-info/org.scientificcms.contenttypes.scidepartment.SciDepartmentModule.properties @@ -0,0 +1,4 @@ +groupId=${project.groupId} +artifactId=${project.artifactId} +version=${project.version} +build.date=${timestamp} diff --git a/sci-types-department/src/main/resources/org/scientificcms/contenttypes/scidepartment/DefaultContactTypes.properties b/sci-types-department/src/main/resources/org/scientificcms/contenttypes/scidepartment/DefaultContactTypes.properties new file mode 100644 index 0000000..e72b04d --- /dev/null +++ b/sci-types-department/src/main/resources/org/scientificcms/contenttypes/scidepartment/DefaultContactTypes.properties @@ -0,0 +1 @@ +sciproject.contact=Contact diff --git a/sci-types-department/src/main/resources/org/scientificcms/contenttypes/scidepartment/DefaultContactTypes_de.properties b/sci-types-department/src/main/resources/org/scientificcms/contenttypes/scidepartment/DefaultContactTypes_de.properties new file mode 100644 index 0000000..aaf69df --- /dev/null +++ b/sci-types-department/src/main/resources/org/scientificcms/contenttypes/scidepartment/DefaultContactTypes_de.properties @@ -0,0 +1 @@ +sciproject.contact=Kontakt diff --git a/sci-types-project/src/main/java/org/scientificcms/contenttypes/sciproject/SciProjectMananger.java b/sci-types-project/src/main/java/org/scientificcms/contenttypes/sciproject/SciProjectMananger.java index a005391..e84ce57 100644 --- a/sci-types-project/src/main/java/org/scientificcms/contenttypes/sciproject/SciProjectMananger.java +++ b/sci-types-project/src/main/java/org/scientificcms/contenttypes/sciproject/SciProjectMananger.java @@ -9,7 +9,6 @@ import org.librecms.assets.ContactableEntity; import org.librecms.assets.Organization; import org.librecms.assets.Person; import org.librecms.contentsection.ContentItemRepository; -import org.librecms.ui.contentsections.ContentSectionsUi; import java.io.Serializable; import java.util.Objects; -- 2.52.0 From 862123fc8dae97d6bee28c993165fa084d82380a Mon Sep 17 00:00:00 2001 From: Jens Pelzetter Date: Sat, 1 Oct 2022 11:16:46 +0200 Subject: [PATCH 04/16] Some more config parameters for SciDepartment --- .../scidepartment/SciDepartmentConfig.java | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/SciDepartmentConfig.java b/sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/SciDepartmentConfig.java index 37b2955..283419e 100644 --- a/sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/SciDepartmentConfig.java +++ b/sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/SciDepartmentConfig.java @@ -20,13 +20,17 @@ public class SciDepartmentConfig { private String memberRolesBundleName = "org.scientificcms.contenttypes.scidepartment.MemberRoles"; + @Setting + private String textKeysBundleName + = "org.scientificcms.contenttypes.scidepartment.TextKeysBundle"; + public static SciDepartmentConfig getConfig() { final ConfigurationManager confManager = CdiUtil .createCdiUtil() .findBean(ConfigurationManager.class); return confManager.findConfiguration(SciDepartmentConfig.class); } - + public SciDepartmentConfig() { super(); } @@ -46,7 +50,14 @@ public class SciDepartmentConfig { public void setMemberRolesBundleName(final String memberRolesBundleName) { this.memberRolesBundleName = memberRolesBundleName; } - - + + public String getTextKeysBundleName() { + return textKeysBundleName; + } + + public void setTextKeysBundleName(final String textKeysBundleName) { + this.textKeysBundleName = textKeysBundleName; + } + } -- 2.52.0 From 1c7bef4f982e714e2c11187634d6187303148883 Mon Sep 17 00:00:00 2001 From: Jens Pelzetter Date: Sat, 1 Oct 2022 17:56:28 +0200 Subject: [PATCH 05/16] Java part of UI for sci-types-department --- .../scidepartment/SciDepartment.java | 2 - .../ui/SciDepartmentAuthoringSteps.java | 35 + .../ui/SciDepartmentContact.java | 67 + .../ui/SciDepartmentContactModel.java | 67 + .../ui/SciDepartmentCreateStep.java | 138 +- .../ui/SciDepartmentDescriptionContacts.java | 101 ++ ...SciDepartmentDescriptionContactsModel.java | 57 + .../SciDepartmentDescriptionMembersModel.java | 60 + .../ui/SciDepartmentDescriptionModel.java | 114 ++ .../ui/SciDepartmentDescriptionStep.java | 1177 ++++++++++++++++- ...SciDepartmentDescriptionStepResources.java | 123 ++ .../SciDepartmentDescriptionStepService.java | 130 ++ .../SciDepartmentExtendedPropertiesStep.java | 26 - .../ui/SciDepartmentMembershipModel.java | 143 ++ .../ui/SciDepartmentMessageBundle.java | 21 + .../ui/SciDepartmentPropertiesStep.java | 468 ++++++- .../ui/SciDepartmentPropertiesStepModel.java | 76 ++ .../ui/SciDepartmentTextModel.java | 84 ++ .../ui/SciDepartmentTextsModel.java | 53 + .../ui/SciDepartmentBundle.properties | 7 + .../ui/SciDepartmentBundle_de.properties | 7 + .../ui/SciProjectDescriptionStepService.java | 2 +- scicms-bundle-devel-wildfly/.gitignore | 1 + .../runtime.properties | 7 - 24 files changed, 2909 insertions(+), 57 deletions(-) create mode 100644 sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/ui/SciDepartmentAuthoringSteps.java create mode 100644 sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/ui/SciDepartmentContact.java create mode 100644 sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/ui/SciDepartmentContactModel.java create mode 100644 sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/ui/SciDepartmentDescriptionContacts.java create mode 100644 sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/ui/SciDepartmentDescriptionContactsModel.java create mode 100644 sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/ui/SciDepartmentDescriptionMembersModel.java create mode 100644 sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/ui/SciDepartmentDescriptionModel.java create mode 100644 sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/ui/SciDepartmentDescriptionStepResources.java create mode 100644 sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/ui/SciDepartmentDescriptionStepService.java delete mode 100644 sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/ui/SciDepartmentExtendedPropertiesStep.java create mode 100644 sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/ui/SciDepartmentMembershipModel.java create mode 100644 sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/ui/SciDepartmentMessageBundle.java create mode 100644 sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/ui/SciDepartmentPropertiesStepModel.java create mode 100644 sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/ui/SciDepartmentTextModel.java create mode 100644 sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/ui/SciDepartmentTextsModel.java create mode 100644 sci-types-department/src/main/resources/org/scientificcms/contenttypes/scidepartment/ui/SciDepartmentBundle.properties create mode 100644 sci-types-department/src/main/resources/org/scientificcms/contenttypes/scidepartment/ui/SciDepartmentBundle_de.properties create mode 100644 scicms-bundle-devel-wildfly/.gitignore delete mode 100644 scicms-bundle-devel-wildfly/runtime.properties diff --git a/sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/SciDepartment.java b/sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/SciDepartment.java index 742c941..089c4a3 100644 --- a/sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/SciDepartment.java +++ b/sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/SciDepartment.java @@ -10,7 +10,6 @@ import org.librecms.contenttypes.ContentTypeDescription; import org.librecms.ui.contentsections.documents.MvcAuthoringKit; import org.scientificcms.contenttypes.scidepartment.ui.SciDepartmentCreateStep; import org.scientificcms.contenttypes.scidepartment.ui.SciDepartmentDescriptionStep; -import org.scientificcms.contenttypes.scidepartment.ui.SciDepartmentExtendedPropertiesStep; import org.scientificcms.contenttypes.scidepartment.ui.SciDepartmentPropertiesStep; import java.io.Serializable; @@ -48,7 +47,6 @@ import static org.scientificcms.contenttypes.scidepartment.SciDepartmentConstant createStep = SciDepartmentCreateStep.class, authoringSteps = { SciDepartmentPropertiesStep.class, - SciDepartmentExtendedPropertiesStep.class, SciDepartmentDescriptionStep.class } ) diff --git a/sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/ui/SciDepartmentAuthoringSteps.java b/sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/ui/SciDepartmentAuthoringSteps.java new file mode 100644 index 0000000..3579b11 --- /dev/null +++ b/sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/ui/SciDepartmentAuthoringSteps.java @@ -0,0 +1,35 @@ +package org.scientificcms.contenttypes.scidepartment.ui; + +import org.librecms.ui.contentsections.documents.MvcAuthoringSteps; + +import java.util.Set; + +import javax.enterprise.context.ApplicationScoped; + +/** + * + * @author Jens Pelzetter + */ +@ApplicationScoped +public class SciDepartmentAuthoringSteps implements MvcAuthoringSteps { + + @Override + public Set> getClasses() { + return Set.of( + SciDepartmentPropertiesStep.class, + SciDepartmentDescriptionStep.class + ); + } + + @Override + public Set> getResourceClasses() { + return Set.of( + SciDepartmentDescriptionContacts.class, + SciDepartmentDescriptionStepResources.class, + SciDepartmentDescriptionStepService.class + ); + } + + + +} diff --git a/sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/ui/SciDepartmentContact.java b/sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/ui/SciDepartmentContact.java new file mode 100644 index 0000000..efc22e8 --- /dev/null +++ b/sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/ui/SciDepartmentContact.java @@ -0,0 +1,67 @@ +package org.scientificcms.contenttypes.scidepartment.ui; + +/** + * DTO providing the information about a {@link Contact} of a + * {@link SciDepartment} in a form that is easy to use from a MVC template. + * + * @author Jens Pelzetter + */ +public class SciDepartmentContact { + + /** + * The ID of the {@link Contact} represented by this object. + */ + private long contactId; + + /** + * The type of the contact. + * + * @see Contact#contactType + */ + private String contactType; + + /** + * Order of contact. + */ + private long order; + + /** + * The title of the {@link ContactableEntity} + * + * @see Contact#contactable + */ + private String contactable; + + public long getContactId() { + return contactId; + } + + public void setContactId(final long contactId) { + this.contactId = contactId; + } + + public String getContactType() { + return contactType; + } + + public void setContactType(final String contactType) { + this.contactType = contactType; + } + + public long getOrder() { + return order; + } + + public void setOrder(final long order) { + this.order = order; + } + + public String getContactable() { + return contactable; + } + + public void setContactable(final String contactable) { + this.contactable = contactable; + } + +} diff --git a/sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/ui/SciDepartmentContactModel.java b/sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/ui/SciDepartmentContactModel.java new file mode 100644 index 0000000..92c9d51 --- /dev/null +++ b/sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/ui/SciDepartmentContactModel.java @@ -0,0 +1,67 @@ +package org.scientificcms.contenttypes.scidepartment.ui; + +/** + * DTO providing the information about a {@link Contact} of a + * {@link SciDepartment} in a form that is easy usable from a MVC template. + * + * @author Jens Pelzetter + */ +public class SciDepartmentContactModel { + + /** + * The ID of the {@link Contact} represented by this object. + */ + private long contactId; + + /** + * The type of the contact. + * + * @see Contact#contactType + */ + private String contactType; + + /** + * Order of contact. + */ + private long order; + + /** + * The title of the {@link ContactableEntity} + * + * @see Contact#contactable + */ + private String contactable; + + public long getContactId() { + return contactId; + } + + public void setContactId(final long contactId) { + this.contactId = contactId; + } + + public String getContactType() { + return contactType; + } + + public void setContactType(final String contactType) { + this.contactType = contactType; + } + + public long getOrder() { + return order; + } + + public void setOrder(final long order) { + this.order = order; + } + + public String getContactable() { + return contactable; + } + + public void setContactable(final String contactable) { + this.contactable = contactable; + } + +} diff --git a/sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/ui/SciDepartmentCreateStep.java b/sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/ui/SciDepartmentCreateStep.java index 1978b4e..afd7ba2 100644 --- a/sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/ui/SciDepartmentCreateStep.java +++ b/sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/ui/SciDepartmentCreateStep.java @@ -1,25 +1,142 @@ package org.scientificcms.contenttypes.scidepartment.ui; +import org.libreccm.l10n.GlobalizationHelper; +import org.librecms.contentsection.ContentItemManager; +import org.librecms.contentsection.ContentItemRepository; import org.librecms.ui.contentsections.documents.AbstractMvcDocumentCreateStep; import org.scientificcms.contenttypes.scidepartment.SciDepartment; +import org.scientificcms.contenttypes.sciproject.SciProject; import java.util.Map; import javax.enterprise.context.RequestScoped; +import javax.inject.Inject; import javax.inject.Named; +import javax.transaction.Transactional; /** + * Create step for a {@link SciDepartment}. * * @author Jens Pelzetter */ @RequestScoped @Named("SciDepartmentCreateStep") -public class SciDepartmentCreateStep - extends AbstractMvcDocumentCreateStep{ +public class SciDepartmentCreateStep + extends AbstractMvcDocumentCreateStep { + + private static final String FORM_PARAM_NAME = "name"; + + private static final String FORM_PARAM_TITLE = "title"; + + private static final String FORM_PARAM_SHORT_DESCRIPTION = "shortdesc"; + + private static final String FORM_PARAM_INITIAL_LOCALE = "locale"; + + private static final String FORM_PARAM_SELECTED_WORKFLOW = "workflow"; + + /** + * Provides functions for working with content items. + */ + @Inject + private ContentItemManager itemManager; + + /** + * Used to save the event. + */ + @Inject + private ContentItemRepository itemRepo; + + /** + * Provides functions for working with {@link LocalizedString}s. + */ + @Inject + private GlobalizationHelper globalizationHelper; + + /** + * Nmae of the department. + */ + private String name; + + /** + * Title of the department. + */ + private String title; + + /** + * The short description of the department. + */ + private String shortDescription; + + /** + * The initial locale of the department. + */ + private String initialLocale; + + /** + * The workflow to use for the new department. + */ + private String selectedWorkflow; + + @Override + public String getDocumentType() { + return SciDepartment.class.getName(); + } + + @Override + public String getDescription() { + return globalizationHelper + .getLocalizedTextsUtil(getBundle()) + .getText("createstep.description"); + } + + @Override + public String getBundle() { + return SciDepartmentStepsConstants.BUNDLE; + } + + public String getName() { + return name; + } + + public String getTitle() { + return title; + } + + public String getShortDescription() { + return shortDescription; + } + + public String getInitialLocale() { + return initialLocale; + } + + @Transactional(Transactional.TxType.REQUIRED) + public String getSelectedWorkflow() { + if (selectedWorkflow == null || selectedWorkflow.isEmpty()) { + return getContentSection() + .getContentTypes() + .stream() + .filter( + type -> type.getContentItemClass().equals( + SciProject.class.getName() + ) + ) + .findAny() + .map(type -> type.getDefaultWorkflow()) + .map( + workflow -> globalizationHelper.getValueFromLocalizedString( + workflow.getName() + ) + ) + .orElse(""); + } else { + return selectedWorkflow; + } + } @Override public String showCreateStep() { - throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody + return "org/scientificcms/contenttypes/scidepartment/ui/create-scidepartment.xhtml"; } @Override @@ -27,19 +144,4 @@ public class SciDepartmentCreateStep throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody } - @Override - public String getDocumentType() { - throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody - } - - @Override - public String getDescription() { - throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody - } - - @Override - public String getBundle() { - throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody - } - } diff --git a/sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/ui/SciDepartmentDescriptionContacts.java b/sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/ui/SciDepartmentDescriptionContacts.java new file mode 100644 index 0000000..2b1cc35 --- /dev/null +++ b/sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/ui/SciDepartmentDescriptionContacts.java @@ -0,0 +1,101 @@ +package org.scientificcms.contenttypes.scidepartment.ui; + +import org.librecms.contentsection.ContentItem; +import org.librecms.contentsection.ContentItemRepository; +import org.librecms.contentsection.ContentSection; +import org.librecms.ui.contentsections.ContentSectionsUi; +import org.librecms.ui.contentsections.documents.MvcAuthoringSteps; +import org.scientificcms.contenttypes.scidepartment.Contact; +import org.scientificcms.contenttypes.scidepartment.ContactRepository; +import org.scientificcms.contenttypes.scidepartment.SciDepartment; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.enterprise.context.RequestScoped; +import javax.inject.Inject; +import javax.transaction.Transactional; +import javax.ws.rs.Consumes; +import javax.ws.rs.NotFoundException; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; + +/** + * + * @author Jens Pelzetter + */ +@RequestScoped +@Path(MvcAuthoringSteps.PATH_PREFIX + "scidepartment-description-contacts") +public class SciDepartmentDescriptionContacts { + + @Inject + private ContactRepository contactRepo; + + @Inject + private ContentItemRepository itemRepo; + + @Inject + private ContentSectionsUi sectionsUi; + + @POST + @Path("/save-order") + @Consumes(MediaType.APPLICATION_JSON) + @Transactional(Transactional.TxType.REQUIRED) + public Response saveOrder( + @PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM) + final String sectionIdentifier, + @PathParam(MvcAuthoringSteps.DOCUMENT_PATH_PATH_PARAM) + final String documentPath, + final List order + ) { + final ContentSection contentSection = sectionsUi + .findContentSection(sectionIdentifier) + .orElseThrow( + () -> new NotFoundException( + String.format( + "No content identifed by %s found.", + sectionIdentifier + ) + ) + ); + + final ContentItem document = itemRepo + .findByPath(contentSection, documentPath) + .orElseThrow( + () -> new NotFoundException( + String.format( + "No document for path %s in section %s.", + documentPath, + contentSection.getLabel() + ) + ) + ); + + if (!(document instanceof SciDepartment)) { + throw new NotFoundException( + String.format( + "No SciDepartment for path %s in section %s.", + documentPath, + contentSection.getLabel() + ) + ); + } + + final Map orderMap = new HashMap<>(); + for (int i = 0; i < order.size(); i++) { + orderMap.put(Long.parseLong(order.get(i)), (long) i); + } + + final SciDepartment department = (SciDepartment)document; + for (final Contact contact : department.getContacts()) { + contact.setOrder(orderMap.get(contact.getContactId())); + contactRepo.save(contact); + } + + return Response.ok().build(); + } +} diff --git a/sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/ui/SciDepartmentDescriptionContactsModel.java b/sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/ui/SciDepartmentDescriptionContactsModel.java new file mode 100644 index 0000000..c48c68c --- /dev/null +++ b/sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/ui/SciDepartmentDescriptionContactsModel.java @@ -0,0 +1,57 @@ +package org.scientificcms.contenttypes.scidepartment.ui; + +import org.librecms.assets.Organization; +import org.librecms.assets.Person; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import javax.enterprise.context.RequestScoped; +import javax.inject.Named; + +/** + * + * @author Jens Pelzetter + */ +@RequestScoped +@Named("SciDepartmentDescriptionContacts") +public class SciDepartmentDescriptionContactsModel { + + private boolean canEdit; + + private List contacts; + + private String baseUrl; + + public boolean getCanEdit() { + return canEdit; + } + + protected void setCanEdit(final boolean canEdit) { + this.canEdit = canEdit; + } + + public List getContacts() { + return Collections.unmodifiableList(contacts); + } + + protected void setContacts(final List contacts) { + this.contacts = new ArrayList<>(contacts); + } + + public String getContactableTypes() { + return String.join( + ",", Person.class.getName(), Organization.class.getName() + ); + } + + public String getBaseUrl() { + return baseUrl; + } + + protected void setBaseUrl(final String baseUrl) { + this.baseUrl = baseUrl; + } + +} diff --git a/sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/ui/SciDepartmentDescriptionMembersModel.java b/sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/ui/SciDepartmentDescriptionMembersModel.java new file mode 100644 index 0000000..517219a --- /dev/null +++ b/sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/ui/SciDepartmentDescriptionMembersModel.java @@ -0,0 +1,60 @@ +package org.scientificcms.contenttypes.scidepartment.ui; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + +import javax.enterprise.context.RequestScoped; +import javax.inject.Named; + +/** + * + * @author Jens Pelzetter + */ +@RequestScoped +@Named("SciDepartmentDescriptionMembers") +public class SciDepartmentDescriptionMembersModel { + + private boolean canEdit; + + private List members; + + private Map statusValues; + + private String baseUrl; + + public boolean getCanEdit() { + return canEdit; + } + + protected void setCanEdit(final boolean canEdit) { + this.canEdit = canEdit; + } + + public List getMembers() { + return Collections.unmodifiableList(members); + } + + protected void setMembers(final List member) { + this.members = new ArrayList<>(members); + } + + public Map getStatusValues() { + return Collections.unmodifiableMap(statusValues); + } + + protected void setStatusValues(final Map statusValues) { + this.statusValues = new LinkedHashMap<>(statusValues); + } + + public String getBaseUrl() { + return baseUrl; + } + + protected void setBaseUrl(final String baseUrl) { + this.baseUrl = baseUrl; + } + +} diff --git a/sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/ui/SciDepartmentDescriptionModel.java b/sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/ui/SciDepartmentDescriptionModel.java new file mode 100644 index 0000000..240206b --- /dev/null +++ b/sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/ui/SciDepartmentDescriptionModel.java @@ -0,0 +1,114 @@ +/* + * Copyright (C) 2022 LibreCCM Foundation. + * + * 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., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ +package org.scientificcms.contenttypes.scidepartment.ui; + +import org.librecms.ui.contentsections.documents.CmsEditorLocaleVariantRow; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; + +import javax.enterprise.context.RequestScoped; +import javax.inject.Named; + +/** + * + * @author Jens Pelzetter + */ +@RequestScoped +@Named("SciDepartmentDescriptionModel") +public class SciDepartmentDescriptionModel { + + private boolean canEdit; + + private Map descriptionValues; + + private List variants; + + private List unusedLocales; + + private String selectedLocale; + + public Map getDescriptionValues() { + return Optional + .ofNullable(descriptionValues) + .map(Collections::unmodifiableMap) + .orElse(Collections.emptyMap()); + } + + protected void setDescriptionValues( + final Map descriptionValues + ) { + this.descriptionValues = Optional + .ofNullable(descriptionValues) + .map(values -> new HashMap<>(values)) + .map(values -> (Map) values) + .orElse(Collections.emptyMap()); + } + + public List getVariants() { + return Optional + .ofNullable(variants) + .map(Collections::unmodifiableList) + .orElse(Collections.emptyList()); + } + + protected void setVariants(final List variants) { + this.variants = Optional + .ofNullable(variants) + .map(list -> new ArrayList<>(list)) + .map(list -> (List) list) + .orElse(Collections.emptyList()); + } + + public List getUnusedLocales() { + return Optional + .ofNullable(unusedLocales) + .map(Collections::unmodifiableList) + .orElse(Collections.emptyList()); + } + + protected void setUnusedLocales(final List unusedLocales) { + this.unusedLocales = Optional + .ofNullable(unusedLocales) + .map(list -> new ArrayList<>(list)) + .map(list -> (List) list) + .orElse(Collections.emptyList()); + } + + public String getSelectedLocale() { + return selectedLocale; + } + + protected void setSelectedLocale(final String selectedLocale) { + this.selectedLocale = selectedLocale; + } + + public boolean getCanEdit() { + return canEdit; + } + + protected void setCanEdit(final boolean canEdit) { + this.canEdit = canEdit; + } + +} diff --git a/sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/ui/SciDepartmentDescriptionStep.java b/sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/ui/SciDepartmentDescriptionStep.java index 0342ed8..569627e 100644 --- a/sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/ui/SciDepartmentDescriptionStep.java +++ b/sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/ui/SciDepartmentDescriptionStep.java @@ -1,12 +1,73 @@ +/* + * Copyright (C) 2022 LibreCCM Foundation. + * + * 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., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ package org.scientificcms.contenttypes.scidepartment.ui; +import org.libreccm.api.Identifier; +import org.libreccm.api.IdentifierParser; +import org.libreccm.l10n.GlobalizationHelper; +import org.libreccm.l10n.LocalizedString; +import org.libreccm.security.AuthorizationRequired; +import org.libreccm.ui.BaseUrl; +import org.librecms.assets.ContactableEntity; +import org.librecms.assets.Person; +import org.librecms.contentsection.Asset; +import org.librecms.contentsection.AssetRepository; +import org.librecms.contentsection.ContentItemRepository; +import org.librecms.ui.contentsections.ContentSectionNotFoundException; +import org.librecms.ui.contentsections.ItemPermissionChecker; +import org.librecms.ui.contentsections.documents.AbstractMvcAuthoringStep; +import org.librecms.ui.contentsections.documents.CmsEditorUtil; +import org.librecms.ui.contentsections.documents.DocumentNotFoundException; +import org.librecms.ui.contentsections.documents.DocumentUi; import org.librecms.ui.contentsections.documents.MvcAuthoringStepDef; import org.librecms.ui.contentsections.documents.MvcAuthoringSteps; +import org.scientificcms.contenttypes.scidepartment.Contact; +import org.scientificcms.contenttypes.scidepartment.ContactRepository; +import org.scientificcms.contenttypes.scidepartment.DepartmentText; +import org.scientificcms.contenttypes.scidepartment.DepartmentTextRepository; +import org.scientificcms.contenttypes.scidepartment.Membership; +import org.scientificcms.contenttypes.scidepartment.MembershipRepository; +import org.scientificcms.contenttypes.scidepartment.MembershipStatus; import org.scientificcms.contenttypes.scidepartment.SciDepartment; +import org.scientificcms.contenttypes.scidepartment.SciDepartmentManager; + +import java.util.Arrays; +import java.util.LinkedHashMap; +import java.util.Locale; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import java.util.Set; +import java.util.stream.Collectors; import javax.enterprise.context.RequestScoped; +import javax.inject.Inject; import javax.mvc.Controller; +import javax.mvc.Models; +import javax.servlet.http.HttpServletRequest; +import javax.transaction.Transactional; +import javax.ws.rs.FormParam; +import javax.ws.rs.GET; +import javax.ws.rs.POST; import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.core.Context; /** * @@ -21,6 +82,1118 @@ import javax.ws.rs.Path; labelKey = "authoringsteps.description.label", supportedDocumentType = SciDepartment.class ) -public class SciDepartmentDescriptionStep { - +public class SciDepartmentDescriptionStep extends AbstractMvcAuthoringStep { + + @Inject + private AssetRepository assetRepo; + + @Inject + private BaseUrl baseUrl; + + @Inject + private ContentItemRepository itemRepo; + + @Inject + private ContactRepository contactRepo; + + @Inject + private DepartmentTextRepository departmentTextRepo; + + @Inject + private DocumentUi documentUi; + + @Inject + private GlobalizationHelper globalizationHelper; + + @Inject + private IdentifierParser identifierParser; + + @Context + private HttpServletRequest request; + + @Inject + private ItemPermissionChecker itemPermissionChecker; + + @Inject + private MembershipRepository membershipRepo; + + @Inject + private Models models; + + @Inject + private SciDepartmentManager departmentManager; + + @Inject + private SciDepartmentDescriptionModel descriptionModel; + + @Inject + private SciDepartmentDescriptionContactsModel contactsModel; + + @Inject + private SciDepartmentDescriptionMembersModel membersModel; + + @Inject + private SciDepartmentMessageBundle messageBundle; + + @Inject + private SciDepartmentTextsModel textsModel; + + @Override + public Class getStepClass() { + return SciDepartmentDescriptionStep.class; + } + + @GET + @Path("/") + @Transactional(Transactional.TxType.REQUIRED) + @AuthorizationRequired + public String showStep( + @PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM) + final String sectionIdentifier, + @PathParam(MvcAuthoringSteps.DOCUMENT_PATH_PATH_PARAM_NAME) + final String documentPath + ) { + try { + init(); + } catch (ContentSectionNotFoundException ex) { + return ex.showErrorMessage(); + } catch (DocumentNotFoundException ex) { + return ex.showErrorMessage(); + } + + if (itemPermissionChecker.canEditItem(getDepartment())) { + return "org/scientificcms/contenttypes/scidepartment/ui/scidepartment-description.xhtml"; + } else { + return documentUi.showAccessDenied( + getContentSection(), + getDepartment(), + messageBundle.getMessage("scidepartment.edit.denied") + ); + } + } + + @GET + @Path("/description/view/{locale}") + @Transactional(Transactional.TxType.REQUIRED) + @AuthorizationRequired + public String viewDescription( + @PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM) + final String sectionIdentifier, + @PathParam(MvcAuthoringSteps.DOCUMENT_PATH_PATH_PARAM_NAME) + final String documentPath, + @PathParam("locale") final String localeParam + ) { + try { + init(); + } catch (ContentSectionNotFoundException ex) { + return ex.showErrorMessage(); + } catch (DocumentNotFoundException ex) { + return ex.showErrorMessage(); + } + + if (itemPermissionChecker.canEditItem(getDepartment())) { + descriptionModel.setSelectedLocale( + new Locale(localeParam).toString() + ); + + return "org/scientificcms/contenttypes/scidepartment/ui/description/view.xhtml"; + } else { + return documentUi.showAccessDenied( + getContentSection(), + getDepartment(), + messageBundle.getMessage("scidepartment.edit.denied") + ); + } + } + + @POST + @Path("/description/add") + @Transactional(Transactional.TxType.REQUIRED) + @AuthorizationRequired + public String addDescriptionValue( + @PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM) + final String sectionIdentifier, + @PathParam(MvcAuthoringSteps.DOCUMENT_PATH_PATH_PARAM_NAME) + final String documentPath, + @FormParam("locale") final String localeParam + ) { + try { + init(); + } catch (ContentSectionNotFoundException ex) { + return ex.showErrorMessage(); + } catch (DocumentNotFoundException ex) { + return ex.showErrorMessage(); + } + + if (itemPermissionChecker.canEditItem(getDepartment())) { + final String value; + if (getDepartment().getDepartmentDescription().getAvailableLocales() + .isEmpty()) { + value = ""; + } else { + value = globalizationHelper.getValueFromLocalizedString( + getDepartment().getDepartmentDescription() + ); + } + final Locale locale = new Locale(localeParam); + getDepartment().getDepartmentDescription().putValue(locale, value); + itemRepo.save(getDepartment()); + + return buildRedirectPathForStep(); + } else { + return documentUi.showAccessDenied( + getContentSection(), + getDepartment(), + messageBundle.getMessage("scidepartment.edit.denied") + ); + } + } + + @GET + @Path("/description/edit/{locale}") + @Transactional(Transactional.TxType.REQUIRED) + @AuthorizationRequired + public String editDescriptionValue( + @PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM) + final String sectionIdentifier, + @PathParam(MvcAuthoringSteps.DOCUMENT_PATH_PATH_PARAM_NAME) + final String documentPath, + @PathParam("locale") final String localeParam + ) { + try { + init(); + } catch (ContentSectionNotFoundException ex) { + return ex.showErrorMessage(); + } catch (DocumentNotFoundException ex) { + return ex.showErrorMessage(); + } + + if (itemPermissionChecker.canEditItem(getDepartment())) { + descriptionModel.setSelectedLocale( + new Locale(localeParam).toString() + ); + + return "org/scientificcms/contenttypes/scidepartment/ui/description/edit.xhtml"; + } else { + return documentUi.showAccessDenied( + getContentSection(), + getDepartment(), + messageBundle.getMessage("scidepartment.edit.denied") + ); + } + } + + @POST + @Path("/description/edit/{locale}") + @Transactional(Transactional.TxType.REQUIRED) + @AuthorizationRequired + public String editDescriptionValue( + @PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM) + final String sectionIdentifier, + @PathParam(MvcAuthoringSteps.DOCUMENT_PATH_PATH_PARAM_NAME) + final String documentPath, + @PathParam("locale") final String localeParam, + @FormParam("value") final String value + ) { + try { + init(); + } catch (ContentSectionNotFoundException ex) { + return ex.showErrorMessage(); + } catch (DocumentNotFoundException ex) { + return ex.showErrorMessage(); + } + + if (itemPermissionChecker.canEditItem(getDepartment())) { + final Locale locale = new Locale(localeParam); + getDepartment().getDepartmentDescription().putValue(locale, value); + itemRepo.save(getDepartment()); + + return buildRedirectPathForStep(); + } else { + return documentUi.showAccessDenied( + getContentSection(), + getDepartment(), + messageBundle.getMessage("scidepartment.edit.denied") + ); + } + } + + @POST + @Path("/description/remove/{locale}") + @Transactional(Transactional.TxType.REQUIRED) + @AuthorizationRequired + public String removeDescriptionValue( + @PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM) + final String sectionIdentifier, + @PathParam(MvcAuthoringSteps.DOCUMENT_PATH_PATH_PARAM_NAME) + final String documentPath, + @PathParam("locale") final String localeParam + ) { + try { + init(); + } catch (ContentSectionNotFoundException ex) { + return ex.showErrorMessage(); + } catch (DocumentNotFoundException ex) { + return ex.showErrorMessage(); + } + + if (itemPermissionChecker.canEditItem(getDepartment())) { + final Locale locale = new Locale(localeParam); + getDepartment().getDepartmentDescription().removeValue(locale); + itemRepo.save(getDepartment()); + + return buildRedirectPathForStep(); + } else { + return documentUi.showAccessDenied( + getContentSection(), + getDepartment(), + messageBundle.getMessage("scidepartment.edit.denied") + ); + } + } + + @GET + @Path("/texts/view/{textKey}") + @Transactional(Transactional.TxType.REQUIRED) + @AuthorizationRequired + public String viewDepartmentText( + @PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM) + final String sectionIdentifier, + @PathParam(MvcAuthoringSteps.DOCUMENT_PATH_PATH_PARAM_NAME) + final String documentPath, + @PathParam("textKey") + final String textKey + ) { + try { + init(); + } catch (ContentSectionNotFoundException ex) { + return ex.showErrorMessage(); + } catch (DocumentNotFoundException ex) { + return ex.showErrorMessage(); + } + + if (itemPermissionChecker.canEditItem(getDepartment())) { + textsModel.setSelectedText(textKey); + + return "org/scientificcms/contenttypes/scidepartment/ui/texts/view-values.xhtml"; + } else { + return documentUi.showAccessDenied( + getContentSection(), + getDepartment(), + messageBundle.getMessage("scidepartment.edit.denied") + ); + } + } + + @GET + @Path("/texts/view/{textKey}/{locale}") + @Transactional(Transactional.TxType.REQUIRED) + @AuthorizationRequired + public String viewDepartmentText( + @PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM) + final String sectionIdentifier, + @PathParam(MvcAuthoringSteps.DOCUMENT_PATH_PATH_PARAM_NAME) + final String documentPath, + @PathParam("textKey") final String textKey, + @PathParam("locale") final String localeParam + ) { + try { + init(); + } catch (ContentSectionNotFoundException ex) { + return ex.showErrorMessage(); + } catch (DocumentNotFoundException ex) { + return ex.showErrorMessage(); + } + + if (itemPermissionChecker.canEditItem(getDepartment())) { + textsModel.setSelectedText(textKey); + textsModel.setSelectedLocale(new Locale(localeParam).toString()); + + return "org/scientificcms/contenttypes/scidepartment/ui/texts/view-text.xhtml"; + } else { + return documentUi.showAccessDenied( + getContentSection(), + getDepartment(), + messageBundle.getMessage("scidepartment.edit.denied") + ); + } + } + + @POST + @Path("/texts/add") + @Transactional(Transactional.TxType.REQUIRED) + @AuthorizationRequired + public String addText( + @PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM) + final String sectionIdentifier, + @PathParam(MvcAuthoringSteps.DOCUMENT_PATH_PATH_PARAM_NAME) + final String documentPath, + @FormParam("textKey") final String textKey, + @FormParam("locale") final String localeParam, + @FormParam("textValue") final String textValue + ) { + try { + init(); + } catch (ContentSectionNotFoundException ex) { + return ex.showErrorMessage(); + } catch (DocumentNotFoundException ex) { + return ex.showErrorMessage(); + } + + if (itemPermissionChecker.canEditItem(getDepartment())) { + final Locale locale = new Locale(localeParam); + final LocalizedString text = new LocalizedString(); + text.putValue(locale, textValue); + + departmentManager.addText(text, getDepartment(), textKey); + itemRepo.save(getDepartment()); + + return buildRedirectPathForStep(); + } else { + return documentUi.showAccessDenied( + getContentSection(), + getDepartment(), + messageBundle.getMessage("scidepartment.edit.denied") + ); + } + } + + @POST + @Path("/texts/add/{textKey}") + @Transactional(Transactional.TxType.REQUIRED) + @AuthorizationRequired + public String addTextValue( + @PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM) + final String sectionIdentifier, + @PathParam(MvcAuthoringSteps.DOCUMENT_PATH_PATH_PARAM_NAME) + final String documentPath, + @PathParam("textKey") final String textKey, + @FormParam("locale") final String localeParam + ) { + try { + init(); + } catch (ContentSectionNotFoundException ex) { + return ex.showErrorMessage(); + } catch (DocumentNotFoundException ex) { + return ex.showErrorMessage(); + } + + if (itemPermissionChecker.canEditItem(getDepartment())) { + if (!getDepartment().getAdditionalTexts().containsKey(textKey)) { + models.put("dpartmentTextNotFound", textKey); + return showStep(sectionIdentifier, documentPath); + } + + final DepartmentText departmentText = getDepartment() + .getAdditionalTexts() + .get(textKey); + + final String value; + if (departmentText.getText().getAvailableLocales().isEmpty()) { + value = ""; + } else { + value = globalizationHelper.getValueFromLocalizedString( + departmentText.getText() + ); + } + final Locale locale = new Locale(localeParam); + departmentText.getText().putValue(locale, value); + departmentTextRepo.save(departmentText); + + return buildRedirectPathForStep(); + } else { + return documentUi.showAccessDenied( + getContentSection(), + getDepartment(), + messageBundle.getMessage("scidepartment.edit.denied") + ); + } + } + + @GET + @Path("/texts/edit/{textKey}/{locale}") + @Transactional(Transactional.TxType.REQUIRED) + @AuthorizationRequired + public String editTextValue( + @PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM) + final String sectionIdentifier, + @PathParam(MvcAuthoringSteps.DOCUMENT_PATH_PATH_PARAM_NAME) + final String documentPath, + @PathParam("textKey") final String textKey, + @PathParam("locale") final String localeParam + ) { + try { + init(); + } catch (ContentSectionNotFoundException ex) { + return ex.showErrorMessage(); + } catch (DocumentNotFoundException ex) { + return ex.showErrorMessage(); + } + + if (itemPermissionChecker.canEditItem(getDepartment())) { + if (!getDepartment().getAdditionalTexts().containsKey(textKey)) { + models.put("dpartmentTextNotFound", textKey); + return showStep(sectionIdentifier, documentPath); + } + + textsModel.setSelectedText(textKey); + textsModel.setSelectedLocale( + new Locale(localeParam).toString() + ); + + return "org/scientificcms/contenttypes/scidepartment/ui/texts/edit-text.xhtml"; + } else { + return documentUi.showAccessDenied( + getContentSection(), + getDepartment(), + messageBundle.getMessage("scidepartment.edit.denied") + ); + } + } + + @POST + @Path("/texts/edit/{textKey}/{locale}") + @Transactional(Transactional.TxType.REQUIRED) + @AuthorizationRequired + public String editTextValue( + @PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM) + final String sectionIdentifier, + @PathParam(MvcAuthoringSteps.DOCUMENT_PATH_PATH_PARAM_NAME) + final String documentPath, + @PathParam("textKey") final String textKey, + @PathParam("locale") final String localeParam, + @FormParam("value") final String value + ) { + try { + init(); + } catch (ContentSectionNotFoundException ex) { + return ex.showErrorMessage(); + } catch (DocumentNotFoundException ex) { + return ex.showErrorMessage(); + } + + if (itemPermissionChecker.canEditItem(getDepartment())) { + if (!getDepartment().getAdditionalTexts().containsKey(textKey)) { + models.put("dpartmentTextNotFound", textKey); + return showStep(sectionIdentifier, documentPath); + } + + final DepartmentText departmentText = getDepartment() + .getAdditionalTexts() + .get(textKey); + + final Locale locale = new Locale(localeParam); + departmentText.getText().putValue(locale, value); + departmentTextRepo.save(departmentText); + + return buildRedirectPathForStep(); + } else { + return documentUi.showAccessDenied( + getContentSection(), + getDepartment(), + messageBundle.getMessage("scidepartment.edit.denied") + ); + } + } + + @POST + @Path("/texts/remove/{textKey}/{locale}") + @Transactional(Transactional.TxType.REQUIRED) + @AuthorizationRequired + public String removeTextValue( + @PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM) + final String sectionIdentifier, + @PathParam(MvcAuthoringSteps.DOCUMENT_PATH_PATH_PARAM_NAME) + final String documentPath, + @PathParam("textKey") final String textKey, + @PathParam("locale") final String localeParam + ) { + try { + init(); + } catch (ContentSectionNotFoundException ex) { + return ex.showErrorMessage(); + } catch (DocumentNotFoundException ex) { + return ex.showErrorMessage(); + } + + if (itemPermissionChecker.canEditItem(getDepartment())) { + if (!getDepartment().getAdditionalTexts().containsKey(textKey)) { + models.put("dpartmentTextNotFound", textKey); + return showStep(sectionIdentifier, documentPath); + } + + final DepartmentText departmentText = getDepartment() + .getAdditionalTexts() + .get(textKey); + + final Locale locale = new Locale(localeParam); + departmentText.getText().removeValue(locale); + departmentTextRepo.save(departmentText); + + return buildRedirectPathForStep(); + } else { + return documentUi.showAccessDenied( + getContentSection(), + getDepartment(), + messageBundle.getMessage("scidepartment.edit.denied") + ); + } + } + + @POST + @Path("/texts/remove/{textKey}") + @Transactional(Transactional.TxType.REQUIRED) + @AuthorizationRequired + public String removeTextValue( + @PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM) + final String sectionIdentifier, + @PathParam(MvcAuthoringSteps.DOCUMENT_PATH_PATH_PARAM_NAME) + final String documentPath, + @PathParam("textKey") final String textKey + ) { + try { + init(); + } catch (ContentSectionNotFoundException ex) { + return ex.showErrorMessage(); + } catch (DocumentNotFoundException ex) { + return ex.showErrorMessage(); + } + + if (itemPermissionChecker.canEditItem(getDepartment())) { + if (!getDepartment().getAdditionalTexts().containsKey(textKey)) { + models.put("dpartmentTextNotFound", textKey); + return showStep(sectionIdentifier, documentPath); + } + + departmentManager.removeText(getDepartment(), textKey); + + return buildRedirectPathForStep(); + } else { + return documentUi.showAccessDenied( + getContentSection(), + getDepartment(), + messageBundle.getMessage("scidepartment.edit.denied") + ); + } + } + + @POST + @Path("/contacts/add") + @Transactional(Transactional.TxType.REQUIRED) + @AuthorizationRequired + public String addContact( + @PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM) + final String sectionIdentifier, + @PathParam(MvcAuthoringSteps.DOCUMENT_PATH_PATH_PARAM_NAME) + final String documentPath, + @FormParam("contactableUuid") + final String contactableUuid, + @FormParam("type") + final String type + ) { + try { + init(); + } catch (ContentSectionNotFoundException ex) { + return ex.showErrorMessage(); + } catch (DocumentNotFoundException ex) { + return ex.showErrorMessage(); + } + + if (itemPermissionChecker.canEditItem(getDepartment())) { + final Optional result; + final Identifier identifier = identifierParser.parseIdentifier( + contactableUuid + ); + switch (identifier.getType()) { + case ID: + result = assetRepo.findById( + Long.parseLong(identifier.getIdentifier()) + ); + break; + case UUID: + result = assetRepo.findByUuid( + identifier.getIdentifier() + ); + break; + default: + models.put("contactableNotFound", contactableUuid); + return showStep(sectionIdentifier, documentPath); + } + + if (!result.isPresent() + || !(result.get() instanceof ContactableEntity)) { + models.put("contactableNotFound", contactableUuid); + return showStep(sectionIdentifier, documentPath); + } + + final ContactableEntity contactable = (ContactableEntity) result + .get(); + departmentManager.addContact(contactable, getDepartment(), type); + + return buildRedirectPathForStep(); + } else { + return documentUi.showAccessDenied( + getContentSection(), + getDepartment(), + messageBundle.getMessage("scidepartment.edit.denied") + ); + } + } + + @POST + @Path("/contacts/edit/{contactId}") + @Transactional(Transactional.TxType.REQUIRED) + @AuthorizationRequired + public String editContact( + @PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM) + final String sectionIdentifier, + @PathParam(MvcAuthoringSteps.DOCUMENT_PATH_PATH_PARAM_NAME) + final String documentPath, + @PathParam("contactId") + final String contactId, + @FormParam("type") + final String type + ) { + try { + init(); + } catch (ContentSectionNotFoundException ex) { + return ex.showErrorMessage(); + } catch (DocumentNotFoundException ex) { + return ex.showErrorMessage(); + } + + if (itemPermissionChecker.canEditItem(getDepartment())) { + final Optional result = getDepartment() + .getContacts() + .stream() + .filter( + contact -> Long + .toString(contact.getContactId()) + .equals(contactId) + ) + .findFirst(); + + if (!result.isPresent()) { + models.put("contactNotFound", contactId); + return showStep(sectionIdentifier, documentPath); + } + + final Contact contact = result.get(); + contact.setContactType(type); + contactRepo.save(contact); + + return buildRedirectPathForStep(); + } else { + return documentUi.showAccessDenied( + getContentSection(), + getDepartment(), + messageBundle.getMessage("scidepartment.edit.denied") + ); + } + } + + @POST + @Path("/contacts/{contactId}/remove") + @Transactional(Transactional.TxType.REQUIRED) + @AuthorizationRequired + public String removeContact( + @PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM) + final String sectionIdentifier, + @PathParam(MvcAuthoringSteps.DOCUMENT_PATH_PATH_PARAM_NAME) + final String documentPath, + @PathParam("contactId") + final String contactId + ) { + try { + init(); + } catch (ContentSectionNotFoundException ex) { + return ex.showErrorMessage(); + } catch (DocumentNotFoundException ex) { + return ex.showErrorMessage(); + } + + if (itemPermissionChecker.canEditItem(getDepartment())) { + final Optional result = getDepartment() + .getContacts() + .stream() + .filter( + contact -> Long + .toString(contact.getContactId()) + .equals(contactId) + ) + .findFirst(); + + if (result.isPresent()) { + departmentManager.removeContact( + result.get().getContactable(), + getDepartment() + ); + } + + return buildRedirectPathForStep(); + } else { + return documentUi.showAccessDenied( + getContentSection(), + getDepartment(), + messageBundle.getMessage("scidepartment.edit.denied") + ); + } + } + + @POST + @Path("/members/add") + @Transactional(Transactional.TxType.REQUIRED) + @AuthorizationRequired + public String addMembership( + @PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM) + final String sectionIdentifier, + @PathParam(MvcAuthoringSteps.DOCUMENT_PATH_PATH_PARAM_NAME) + final String documentPath, + @FormParam("personUuid") + final String personUuid, + @FormParam("role") + final String role, + @FormParam("status") + final String statusParam + ) { + try { + init(); + } catch (ContentSectionNotFoundException ex) { + return ex.showErrorMessage(); + } catch (DocumentNotFoundException ex) { + return ex.showErrorMessage(); + } + + if (itemPermissionChecker.canEditItem(getDepartment())) { + final Optional result; + final Identifier personIdentifier = identifierParser + .parseIdentifier(personUuid); + switch (personIdentifier.getType()) { + case ID: + result = assetRepo.findById( + Long.parseLong(personIdentifier.getIdentifier()), + Person.class + ); + break; + case UUID: + result = assetRepo + .findByUuidAndType( + personIdentifier.getIdentifier(), + Person.class + ); + break; + default: + models.put("personNotFound", personUuid); + return showStep(sectionIdentifier, documentPath); + + } + + if (!result.isPresent()) { + models.put("personNotFound", personUuid); + return showStep(sectionIdentifier, documentPath); + } + + final Person person = result.get(); + final MembershipStatus status; + try { + status = MembershipStatus.valueOf(statusParam); + } catch (IllegalArgumentException ex) { + models.put("illegalStatusValue", statusParam); + return showStep(sectionIdentifier, documentPath); + } + + departmentManager.addMember(person, getDepartment(), role, status); + + return buildRedirectPathForStep(); + } else { + return documentUi.showAccessDenied( + getContentSection(), + getDepartment(), + messageBundle.getMessage("scidepartment.edit.denied") + ); + } + } + + @POST + @Path("/members/edit/{membershipId}") + @Transactional(Transactional.TxType.REQUIRED) + @AuthorizationRequired + public String editMembership( + @PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM) + final String sectionIdentifier, + @PathParam(MvcAuthoringSteps.DOCUMENT_PATH_PATH_PARAM_NAME) + final String documentPath, + @PathParam("membershipId") + final String membershipId, + @FormParam("role") + final String role, + @FormParam("status") + final String statusParam + ) { + try { + init(); + } catch (ContentSectionNotFoundException ex) { + return ex.showErrorMessage(); + } catch (DocumentNotFoundException ex) { + return ex.showErrorMessage(); + } + + if (itemPermissionChecker.canEditItem(getDepartment())) { + final Optional result = getDepartment() + .getMembers() + .stream() + .filter( + member -> Long + .toString(member.getMembershipId()) + .equals(membershipId) + ) + .findFirst(); + + if (!result.isPresent()) { + models.put("membershipNotFound", membershipId); + return showStep(sectionIdentifier, documentPath); + } + + final Membership membership = result.get(); + membership.setRole(role); + membership.setStatus(MembershipStatus.valueOf(statusParam)); + membershipRepo.save(membership); + + return buildRedirectPathForStep(); + } else { + return documentUi.showAccessDenied( + getContentSection(), + getDepartment(), + messageBundle.getMessage("scidepartment.edit.denied") + ); + } + } + + @POST + @Path("/members/remove/{membershipId}") + @Transactional(Transactional.TxType.REQUIRED) + @AuthorizationRequired + public String removeMembership( + @PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM) + final String sectionIdentifier, + @PathParam(MvcAuthoringSteps.DOCUMENT_PATH_PATH_PARAM_NAME) + final String documentPath, + @PathParam("membershipId") + final String membershipId + ) { + try { + init(); + } catch (ContentSectionNotFoundException ex) { + return ex.showErrorMessage(); + } catch (DocumentNotFoundException ex) { + return ex.showErrorMessage(); + } + + if (itemPermissionChecker.canEditItem(getDepartment())) { + final Optional result = getDepartment() + .getMembers() + .stream() + .filter( + member -> Long + .toString(member.getMembershipId()) + .equals(membershipId) + ) + .findFirst(); + + if (result.isPresent()) { + departmentManager.removeMember( + result.get().getMember(), + getDepartment() + ); + } + + return buildRedirectPathForStep(); + } else { + return documentUi.showAccessDenied( + getContentSection(), + getDepartment(), + messageBundle.getMessage("scidepartment.edit.denied") + ); + } + } + + @Override + public void init() throws ContentSectionNotFoundException, + DocumentNotFoundException { + super.init(); + + final boolean canEdit = itemPermissionChecker.canEditItem( + getDepartment() + ); + if (canEdit) { + descriptionModel.setCanEdit(canEdit); + descriptionModel.setDescriptionValues( + getDepartment() + .getDepartmentDescription() + .getValues() + .entrySet() + .stream() + .collect( + Collectors.toMap( + entry -> entry.getKey().toString(), + Map.Entry::getValue + ) + ) + ); + descriptionModel.setVariants( + getDepartment() + .getDepartmentDescription() + .getValues() + .entrySet() + .stream() + .map(CmsEditorUtil::buildVariantRow) + .collect(Collectors.toList()) + ); + final Set descriptionLocales = getDepartment() + .getDepartmentDescription() + .getAvailableLocales(); + descriptionModel.setUnusedLocales( + globalizationHelper + .getAvailableLocales() + .stream() + .filter(locale -> !descriptionLocales.contains(locale)) + .map(Locale::toString) + .collect(Collectors.toList()) + ); + + textsModel.setCanEdit(canEdit); + textsModel.setTexts( + getDepartment() + .getAdditionalTexts() + .entrySet() + .stream() + .collect( + Collectors.toMap( + entry -> entry.getKey(), + entry -> buildTextModel(entry.getValue()) + ) + ) + ); + + contactsModel.setCanEdit(canEdit); + contactsModel.setContacts( + getDepartment() + .getContacts() + .stream() + .map(this::buildContactModel) + .collect(Collectors.toList()) + ); + contactsModel.setBaseUrl(baseUrl.getBaseUrl(request)); + + membersModel.setCanEdit(canEdit); + membersModel.setMembers( + getDepartment() + .getMembers() + .stream() + .map(this::buildMembershipModel) + .collect(Collectors.toList()) + ); + membersModel.setStatusValues( + Arrays + .stream(MembershipStatus.values()) + .collect( + Collectors.toMap( + status -> status.toString(), + status -> messageBundle.getMessage( + String.format( + "members.status.%s", + status.toString().toLowerCase() + ) + ), + (value1, value2) -> value1, + LinkedHashMap::new + ) + ) + ); + membersModel.setBaseUrl(baseUrl.getBaseUrl(request)); + } + } + + private SciDepartment getDepartment() { + return (SciDepartment) getDocument(); + } + + private SciDepartmentContactModel buildContactModel(final Contact contact) { + final SciDepartmentContactModel model = new SciDepartmentContactModel(); + model.setContactId(contact.getContactId()); + model.setContactType(contact.getContactType()); + model.setContactable( + contact.getContactable().getTitle().getValue( + globalizationHelper.getNegotiatedLocale() + ) + ); + model.setOrder(contact.getOrder()); + + return model; + } + + private SciDepartmentMembershipModel buildMembershipModel( + final Membership membership + ) { + final SciDepartmentMembershipModel model + = new SciDepartmentMembershipModel(); + model.setGivenName( + membership.getMember().getPersonName().getGivenName() + ); + model.setMembershipId(membership.getMembershipId()); + model.setPrefix( + membership.getMember().getPersonName().getPrefix() + ); + model.setRole(membership.getRole()); + model.setStatus(Objects.toString(membership.getStatus())); + model.setSuffix( + membership.getMember().getPersonName().getSuffix() + ); + model.setSurname( + membership.getMember().getPersonName().getSurname() + ); + + return model; + } + + private SciDepartmentTextModel buildTextModel(final DepartmentText text) { + final SciDepartmentTextModel model = new SciDepartmentTextModel(); + model.setTextValues( + text + .getText() + .getValues() + .entrySet() + .stream() + .collect( + Collectors.toMap( + entry -> entry.getKey().toString(), + entry -> entry.getValue() + ) + ) + ); + model.setUnusedLocales( + globalizationHelper + .getAvailableLocales() + .stream() + .filter( + locale -> !text.getText().getAvailableLocales().contains( + locale + ) + ) + .map(Locale::toString) + .collect(Collectors.toList()) + ); + model.setVariants( + text + .getText() + .getValues() + .entrySet() + .stream() + .map(CmsEditorUtil::buildVariantRow) + .collect(Collectors.toList()) + ); + + return model; + } + } diff --git a/sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/ui/SciDepartmentDescriptionStepResources.java b/sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/ui/SciDepartmentDescriptionStepResources.java new file mode 100644 index 0000000..383b41d --- /dev/null +++ b/sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/ui/SciDepartmentDescriptionStepResources.java @@ -0,0 +1,123 @@ +package org.scientificcms.contenttypes.scidepartment.ui; + +import org.jsoup.Jsoup; +import org.jsoup.nodes.Document; +import org.librecms.contentsection.ContentItem; +import org.librecms.contentsection.ContentItemRepository; +import org.librecms.contentsection.ContentSection; +import org.librecms.ui.contentsections.ContentSectionsUi; +import org.librecms.ui.contentsections.ItemPermissionChecker; +import org.librecms.ui.contentsections.documents.MvcAuthoringSteps; +import org.scientificcms.contenttypes.scidepartment.SciDepartment; + +import java.util.Locale; +import java.util.StringTokenizer; + +import javax.enterprise.context.RequestScoped; +import javax.inject.Inject; +import javax.transaction.Transactional; +import javax.ws.rs.ForbiddenException; +import javax.ws.rs.GET; +import javax.ws.rs.NotFoundException; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; + +/** + * + * @author Jens Pelzetter + */ +@RequestScoped +@Path(MvcAuthoringSteps.PATH_PREFIX + "scidepartment-description-resources") +public class SciDepartmentDescriptionStepResources { + + @Inject + private ContentItemRepository itemRepo; + + @Inject + private ContentSectionsUi sectionsUi; + + @Inject + private ItemPermissionChecker itemPermissionChecker; + + @GET + @Path("/department-description/wordcount/{locale}") + @Produces(MediaType.TEXT_HTML) + @Transactional(Transactional.TxType.REQUIRED) + public String getDepartmentDescriptionWordCount( + @PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM) + final String sectionIdentifier, + @PathParam(MvcAuthoringSteps.DOCUMENT_PATH_PATH_PARAM_NAME) + final String documentPathParam, + @PathParam("locale") final String localeParam + ) { + final ContentSection contentSection = sectionsUi + .findContentSection(sectionIdentifier) + .orElseThrow( + () -> new NotFoundException() + ); + + final ContentItem document = itemRepo + .findByPath(contentSection, documentPathParam) + .orElseThrow( + () -> new NotFoundException() + ); + + if (!(document instanceof SciDepartment)) { + throw new NotFoundException(); + } + + final SciDepartment department = (SciDepartment) document; + if (itemPermissionChecker.canEditItem(department)) { + final String text = department + .getDepartmentDescription() + .getValue(new Locale(localeParam)); + final Document jsoupDoc = Jsoup.parseBodyFragment(text); + final long result = new StringTokenizer( + jsoupDoc.body().text() + ).countTokens(); + return Long.toString(result); + } else { + throw new ForbiddenException(); + } + } + + @GET + @Path("/department-description/{locale}") + @Produces(MediaType.TEXT_HTML) + @Transactional(Transactional.TxType.REQUIRED) + public String viewDepartmentDescriptionValue( + @PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM) + final String sectionIdentifier, + @PathParam(MvcAuthoringSteps.DOCUMENT_PATH_PATH_PARAM_NAME) + final String documentPathParam, + @PathParam("locale") final String localeParam + ) { + final ContentSection contentSection = sectionsUi + .findContentSection(sectionIdentifier) + .orElseThrow( + () -> new NotFoundException() + ); + + final ContentItem document = itemRepo + .findByPath(contentSection, documentPathParam) + .orElseThrow( + () -> new NotFoundException() + ); + + if (!(document instanceof SciDepartment)) { + throw new NotFoundException(); + } + + final SciDepartment department = (SciDepartment) document; + if (itemPermissionChecker.canEditItem(department)) { + return department.getDepartmentDescription().getValue( + new Locale(localeParam) + ); + } else { + throw new ForbiddenException(); + } + } + +} diff --git a/sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/ui/SciDepartmentDescriptionStepService.java b/sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/ui/SciDepartmentDescriptionStepService.java new file mode 100644 index 0000000..f914d36 --- /dev/null +++ b/sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/ui/SciDepartmentDescriptionStepService.java @@ -0,0 +1,130 @@ +package org.scientificcms.contenttypes.scidepartment.ui; + +import org.librecms.contentsection.ContentItem; +import org.librecms.contentsection.ContentItemRepository; +import org.librecms.contentsection.ContentSection; +import org.librecms.ui.contentsections.ContentSectionsUi; +import org.librecms.ui.contentsections.documents.MvcAuthoringSteps; +import org.scientificcms.contenttypes.scidepartment.Contact; +import org.scientificcms.contenttypes.scidepartment.ContactRepository; +import org.scientificcms.contenttypes.scidepartment.SciDepartment; + +import java.util.List; + +import javax.enterprise.context.RequestScoped; +import javax.inject.Inject; +import javax.transaction.Transactional; +import javax.ws.rs.BadRequestException; +import javax.ws.rs.Consumes; +import javax.ws.rs.NotFoundException; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; + +/** + * + * @author Jens Pelzetter + */ +@RequestScoped +@Path(MvcAuthoringSteps.PATH_PREFIX + "scidepartment-description-service") +public class SciDepartmentDescriptionStepService { + + @Inject + private ContactRepository contactRepo; + + @Inject + private ContentItemRepository itemRepo; + + @Inject + private ContentSectionsUi sectionsUi; + + @POST + @Path("/contacts/save-order") + @Consumes(MediaType.APPLICATION_JSON) + @Transactional(Transactional.TxType.REQUIRED) + public Response saveContactsOrder( + @PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM) + final String sectionIdentifier, + @PathParam(MvcAuthoringSteps.DOCUMENT_PATH_PATH_PARAM_NAME) + final String documentPath, + final List contactsOrder + ) { + final ContentSection contentSection = sectionsUi + .findContentSection(sectionIdentifier) + .orElseThrow( + () -> new NotFoundException( + String.format( + "No content identifed by %s found.", + sectionIdentifier + ) + ) + ); + + final ContentItem document = itemRepo + .findByPath(contentSection, documentPath) + .orElseThrow( + () -> new NotFoundException( + String.format( + "No document for path %s in section %s.", + documentPath, + contentSection.getLabel() + ) + ) + ); + + if (!(document instanceof SciDepartment)) { + throw new BadRequestException( + String.format( + "Document %s is not a %s.", + documentPath, + SciDepartment.class.getSimpleName() + ) + ); + } + + final SciDepartment department = (SciDepartment) document; + + final List contacts = department.getContacts(); + + if (contactsOrder.size() != contacts.size()) { + throw new BadRequestException( + String.format( + "Number of contacts of the SciDepartment %s does " + + "not match the number of values in the order " + + "list. Number of contactas: %d, number of values in " + + "the contacts order list: %d", + documentPath, + contacts.size(), + contactsOrder.size() + ) + ); + } + + for (int i = 0; i < contactsOrder.size(); i++) { + final String contactIdParam = contactsOrder.get(i); + final long contactId = Long.parseLong(contactIdParam); + final Contact contact = contacts + .stream() + .filter(con -> con.getContactId() == contactId) + .findAny() + .orElseThrow( + () -> new BadRequestException( + String.format( + "contactsOrder has an entry for contact with " + + "ID %d, but there is not contact with that " + + "ID.", + contactId + ) + ) + ); + + contact.setOrder(i); + contactRepo.save(contact); + } + + return Response.ok().build(); + } + +} diff --git a/sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/ui/SciDepartmentExtendedPropertiesStep.java b/sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/ui/SciDepartmentExtendedPropertiesStep.java deleted file mode 100644 index 2de024b..0000000 --- a/sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/ui/SciDepartmentExtendedPropertiesStep.java +++ /dev/null @@ -1,26 +0,0 @@ -package org.scientificcms.contenttypes.scidepartment.ui; - -import org.librecms.ui.contentsections.documents.MvcAuthoringStepDef; -import org.librecms.ui.contentsections.documents.MvcAuthoringSteps; -import org.scientificcms.contenttypes.scidepartment.SciDepartment; - -import javax.enterprise.context.RequestScoped; -import javax.mvc.Controller; -import javax.ws.rs.Path; - -/** - * - * @author Jens Pelzetter - */ -@RequestScoped -@Path(MvcAuthoringSteps.PATH_PREFIX + "scidepartment-extendedproperties") -@Controller -@MvcAuthoringStepDef( - bundle = SciDepartmentStepsConstants.BUNDLE, - descriptionKey = "authoringsteps.extendedproperties.description", - labelKey = "authoringsteps.extendedproperties.label", - supportedDocumentType = SciDepartment.class -) -public class SciDepartmentExtendedPropertiesStep { - -} diff --git a/sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/ui/SciDepartmentMembershipModel.java b/sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/ui/SciDepartmentMembershipModel.java new file mode 100644 index 0000000..db39d13 --- /dev/null +++ b/sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/ui/SciDepartmentMembershipModel.java @@ -0,0 +1,143 @@ +package org.scientificcms.contenttypes.scidepartment.ui; + +import org.scientificcms.contenttypes.scidepartment.Membership; +import org.scientificcms.contenttypes.scidepartment.SciDepartment; + +/** + * DTO providing the information about a {@link Membership} of a + * {@link SciDepartment} in an form that easy usable from a MVC template. + * + * @author Jens Pelzetter + */ +public class SciDepartmentMembershipModel { + + /** + * The ID of the {@link Membership}. + */ + private long membershipId; + + /** + * The role of the member. + * + * @see Membership#role + */ + private String role; + + /** + * The status of the membership. + * + * @see Membership#status + */ + private String status; + + /** + * The given name of the member. + * + * @see PersonName#givenName + */ + private String givenName; + + /** + * The surname of the member. + * + * @see PersonName#surname + */ + private String surname; + + /** + * An optional prefix for the name of the member. + * + * @see PersonName#prefix + */ + private String prefix; + + /** + * An optional suffix for the name of the member. + * + * @see PersonName#suffix + */ + private String suffix; + + public long getMembershipId() { + return membershipId; + } + + public void setMembershipId(final long membershipId) { + this.membershipId = membershipId; + } + + public String getRole() { + return role; + } + + public void setRole(final String role) { + this.role = role; + } + + public String getStatus() { + return status; + } + + public void setStatus(final String status) { + this.status = status; + } + + public String getName() { + final StringBuilder builder = new StringBuilder(); + if (prefix != null && !prefix.isBlank()) { + builder.append(prefix); + builder.append(" "); + } + if (surname != null && !surname.isBlank()) { + builder.append(surname); + } + if (surname != null + && !surname.isBlank() + && givenName != null + && !givenName.isBlank()) { + builder.append(", "); + } + if (givenName != null && !givenName.isBlank()) { + builder.append(givenName); + } + if (suffix != null && !suffix.isBlank()) { + builder.append(" "); + builder.append(suffix); + } + + return builder.toString(); + } + + public String getGivenName() { + return givenName; + } + + public void setGivenName(final String givenName) { + this.givenName = givenName; + } + + public String getSurname() { + return surname; + } + + public void setSurname(final String surname) { + this.surname = surname; + } + + public String getPrefix() { + return prefix; + } + + public void setPrefix(final String prefix) { + this.prefix = prefix; + } + + public String getSuffix() { + return suffix; + } + + public void setSuffix(final String suffix) { + this.suffix = suffix; + } + +} diff --git a/sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/ui/SciDepartmentMessageBundle.java b/sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/ui/SciDepartmentMessageBundle.java new file mode 100644 index 0000000..8f0e840 --- /dev/null +++ b/sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/ui/SciDepartmentMessageBundle.java @@ -0,0 +1,21 @@ +package org.scientificcms.contenttypes.scidepartment.ui; + +import org.libreccm.ui.AbstractMessagesBean; + +import javax.enterprise.context.RequestScoped; +import javax.inject.Named; + +/** + * + * @author Jens Pelzetter + */ +@RequestScoped +@Named("SciDepartmentMessageBundle") +public class SciDepartmentMessageBundle extends AbstractMessagesBean { + + @Override + protected String getMessageBundle() { + return SciDepartmentStepsConstants.BUNDLE; + } + +} diff --git a/sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/ui/SciDepartmentPropertiesStep.java b/sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/ui/SciDepartmentPropertiesStep.java index 9092fb3..e894add 100644 --- a/sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/ui/SciDepartmentPropertiesStep.java +++ b/sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/ui/SciDepartmentPropertiesStep.java @@ -1,12 +1,33 @@ package org.scientificcms.contenttypes.scidepartment.ui; +import org.libreccm.l10n.GlobalizationHelper; +import org.libreccm.l10n.LocalizedString; +import org.libreccm.security.AuthorizationRequired; +import org.librecms.contentsection.ContentItemRepository; +import org.librecms.ui.contentsections.ContentSectionNotFoundException; +import org.librecms.ui.contentsections.ItemPermissionChecker; +import org.librecms.ui.contentsections.documents.AbstractMvcAuthoringStep; +import org.librecms.ui.contentsections.documents.DocumentNotFoundException; +import org.librecms.ui.contentsections.documents.DocumentUi; import org.librecms.ui.contentsections.documents.MvcAuthoringStepDef; import org.librecms.ui.contentsections.documents.MvcAuthoringSteps; import org.scientificcms.contenttypes.scidepartment.SciDepartment; +import java.util.Locale; +import java.util.Set; +import java.util.stream.Collectors; + import javax.enterprise.context.RequestScoped; +import javax.inject.Inject; import javax.mvc.Controller; +import javax.mvc.Models; +import javax.transaction.Transactional; +import javax.ws.rs.DefaultValue; +import javax.ws.rs.FormParam; +import javax.ws.rs.GET; +import javax.ws.rs.POST; import javax.ws.rs.Path; +import javax.ws.rs.PathParam; /** * @@ -21,6 +42,451 @@ import javax.ws.rs.Path; labelKey = "authoringsteps.basicproperties.label", supportedDocumentType = SciDepartment.class ) -public class SciDepartmentPropertiesStep { +public class SciDepartmentPropertiesStep extends AbstractMvcAuthoringStep { + + @Inject + private SciDepartmentMessageBundle messageBundle; + + /** + * Used for retrieving and saving the departments. + */ + @Inject + private ContentItemRepository itemRepo; + + @Inject + private DocumentUi documentUi; + + /** + * Provides functions for working with {@link LocalizedString}s. + */ + @Inject + private GlobalizationHelper globalizationHelper; + + @Inject + private ItemPermissionChecker itemPermissionChecker; + + @Inject + private SciDepartmentPropertiesStepModel propertiesStepModel; + + @Inject + private Models models; + + @Override + public Class getStepClass() { + return SciDepartmentPropertiesStep.class; + } + + @Override + @Transactional(Transactional.TxType.REQUIRED) + protected void init() throws ContentSectionNotFoundException, + DocumentNotFoundException { + super.init(); + + propertiesStepModel.setName(getDocument().getDisplayName()); + + final Set titleLocales = getDocument() + .getTitle() + .getAvailableLocales(); + + propertiesStepModel.setTitleValues( + getDocument() + .getTitle() + .getValues() + .entrySet() + .stream() + .collect( + Collectors.toMap( + entry -> entry.getKey().toString(), + entry -> entry.getValue() + ) + ) + ); + + propertiesStepModel.setUnusedTitleLocales( + globalizationHelper + .getAvailableLocales() + .stream() + .filter(locale -> !titleLocales.contains(locale)) + .map(Locale::toString) + .collect(Collectors.toList()) + ); + + final SciDepartment department = (SciDepartment) getDocument(); + + propertiesStepModel.setShortDescriptionValues( + department + .getShortDescription() + .getValues() + .entrySet() + .stream() + .collect( + Collectors.toMap( + entry -> entry.getKey().toString(), + entry -> entry.getValue() + ) + ) + ); + final Set shortDescriptionLocales = department + .getShortDescription() + .getAvailableLocales(); + + propertiesStepModel.setUnusedShortDescriptionLocales( + globalizationHelper + .getAvailableLocales() + .stream() + .filter(locale -> !shortDescriptionLocales.contains(locale)) + .map(Locale::toString) + .collect(Collectors.toList()) + ); + } + + @GET + @Path("/") + @Transactional(Transactional.TxType.REQUIRED) + @AuthorizationRequired + public String showStep( + @PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM) + final String sectionIdentifier, + @PathParam(MvcAuthoringSteps.DOCUMENT_PATH_PATH_PARAM_NAME) + final String documentPath + ) { + try { + init(); + } catch (ContentSectionNotFoundException ex) { + return ex.showErrorMessage(); + } catch (DocumentNotFoundException ex) { + return ex.showErrorMessage(); + } + if (itemPermissionChecker.canEditItem(getDocument())) { + return "org/scientificcms/contenttypes/scidepartment/ui/scidepartment-basic-properties.xhtml"; + } else { + return documentUi.showAccessDenied( + getContentSection(), + getDocument(), + messageBundle.getMessage("scidepartment.edit.denied") + ); + } + } + + /** + * Updates the name of the current department. + * + * @param sectionIdentifier + * @param documentPath + * @param name + * + * @return A redirect to this authoring step. + */ + @POST + @Path("/name") + @AuthorizationRequired + @Transactional(Transactional.TxType.REQUIRED) + public String updateName( + @PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM) + final String sectionIdentifier, + @PathParam(MvcAuthoringSteps.DOCUMENT_PATH_PATH_PARAM_NAME) + final String documentPath, + @FormParam("name") @DefaultValue("") final String name + ) { + try { + init(); + } catch (ContentSectionNotFoundException ex) { + return ex.showErrorMessage(); + } catch (DocumentNotFoundException ex) { + return ex.showErrorMessage(); + } + + if (itemPermissionChecker.canEditItem(getDocument())) { + if (name.isBlank()) { + models.put("nameMissing", true); + + return showStep(sectionIdentifier, documentPath); + } + + getDocument().setDisplayName(name); + itemRepo.save(getDocument()); + + updateDocumentPath(); + + return buildRedirectPathForStep(); + } else { + return documentUi.showAccessDenied( + getContentSection(), + getDocument(), + getLabel() + ); + } + } + + /** + * Updates a localized title of the department. + * + * @param sectionIdentifier + * @param documentPath + * @param localeParam The locale to update. + * @param value The updated title value. + * + * @return A redirect to this authoring step. + */ + @POST + @Path("/title/@add") + @AuthorizationRequired + @Transactional(Transactional.TxType.REQUIRED) + public String addTitle( + @PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM) + final String sectionIdentifier, + @PathParam(MvcAuthoringSteps.DOCUMENT_PATH_PATH_PARAM_NAME) + final String documentPath, + @FormParam("locale") final String localeParam, + @FormParam("value") final String value + ) { + try { + init(); + } catch (ContentSectionNotFoundException ex) { + return ex.showErrorMessage(); + } catch (DocumentNotFoundException ex) { + return ex.showErrorMessage(); + } + + if (itemPermissionChecker.canEditItem(getDocument())) { + final Locale locale = new Locale(localeParam); + getDocument().getTitle().putValue(locale, value); + itemRepo.save(getDocument()); + + return buildRedirectPathForStep(); + } else { + return documentUi.showAccessDenied( + getContentSection(), + getDocument(), + getLabel() + ); + } + } + + /** + * Updates a localized title of the department. + * + * @param sectionIdentifier + * @param documentPath + * @param localeParam The locale to update. + * @param value The updated title value. + * + * @return A redirect to this authoring step. + */ + @POST + @Path("/title/@edit/{locale}") + @AuthorizationRequired + @Transactional(Transactional.TxType.REQUIRED) + public String editTitle( + @PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM) + final String sectionIdentifier, + @PathParam(MvcAuthoringSteps.DOCUMENT_PATH_PATH_PARAM_NAME) + final String documentPath, + @PathParam("locale") final String localeParam, + @FormParam("value") final String value + ) { + try { + init(); + } catch (ContentSectionNotFoundException ex) { + return ex.showErrorMessage(); + } catch (DocumentNotFoundException ex) { + return ex.showErrorMessage(); + } + + if (itemPermissionChecker.canEditItem(getDocument())) { + final Locale locale = new Locale(localeParam); + getDocument().getTitle().putValue(locale, value); + itemRepo.save(getDocument()); + + return buildRedirectPathForStep(); + } else { + return documentUi.showAccessDenied( + getContentSection(), + getDocument(), + getLabel() + ); + } + } + + /** + * Removes a localized title of the department. + * + * @param sectionIdentifier + * @param documentPath + * @param localeParam The locale to remove. + * + * @return A redirect to this authoring step. + */ + @POST + @Path("/title/@remove/{locale}") + @AuthorizationRequired + @Transactional(Transactional.TxType.REQUIRED) + public String removeTitle( + @PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM) + final String sectionIdentifier, + @PathParam(MvcAuthoringSteps.DOCUMENT_PATH_PATH_PARAM_NAME) + final String documentPath, + @PathParam("locale") final String localeParam + ) { + try { + init(); + } catch (ContentSectionNotFoundException ex) { + return ex.showErrorMessage(); + } catch (DocumentNotFoundException ex) { + return ex.showErrorMessage(); + } + + if (itemPermissionChecker.canEditItem(getDocument())) { + final Locale locale = new Locale(localeParam); + getDocument().getTitle().removeValue(locale); + itemRepo.save(getDocument()); + + return buildRedirectPathForStep(); + } else { + return documentUi.showAccessDenied( + getContentSection(), + getDocument(), + getLabel() + ); + } + } + + /** + * Adds a localized short description to the department. + * + * @param sectionIdentifier + * @param documentPath + * @param localeParam The locale of the description. + * @param value The description value. + * + * @return A redirect to this authoring step. + */ + @POST + @Path("/short-description/@add") + @Transactional(Transactional.TxType.REQUIRED) + @AuthorizationRequired + public String addShortDescription( + @PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM) + final String sectionIdentifier, + @PathParam(MvcAuthoringSteps.DOCUMENT_PATH_PATH_PARAM_NAME) + final String documentPath, + @FormParam("locale") final String localeParam, + @FormParam("value") final String value + ) { + try { + init(); + } catch (ContentSectionNotFoundException ex) { + return ex.showErrorMessage(); + } catch (DocumentNotFoundException ex) { + return ex.showErrorMessage(); + } + + if (itemPermissionChecker.canEditItem(getDocument())) { + final Locale locale = new Locale(localeParam); + final SciDepartment department = (SciDepartment) getDocument(); + department.getShortDescription().putValue(locale, value); + + itemRepo.save(department); + + return buildRedirectPathForStep(); + } else { + return documentUi.showAccessDenied( + getContentSection(), + getDocument(), + getLabel() + ); + } + } + + /** + * Updates a localized short description to the department. + * + * @param sectionIdentifier + * @param documentPath + * @param localeParam The locale to update. + * @param value The description value. + * + * @return A redirect to this authoring step. + */ + @POST + @Path("/short-description/@edit/{locale}") + @Transactional(Transactional.TxType.REQUIRED) + @AuthorizationRequired + public String editShortDescription( + @PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM) + final String sectionIdentifier, + @PathParam(MvcAuthoringSteps.DOCUMENT_PATH_PATH_PARAM_NAME) + final String documentPath, + @PathParam("locale") final String localeParam, + @FormParam("value") final String value + ) { + try { + init(); + } catch (ContentSectionNotFoundException ex) { + return ex.showErrorMessage(); + } catch (DocumentNotFoundException ex) { + return ex.showErrorMessage(); + } + + if (itemPermissionChecker.canEditItem(getDocument())) { + final Locale locale = new Locale(localeParam); + final SciDepartment department = (SciDepartment) getDocument(); + department.getShortDescription().putValue(locale, value); + + itemRepo.save(department); + + return buildRedirectPathForStep(); + } else { + return documentUi.showAccessDenied( + getContentSection(), + getDocument(), + getLabel() + ); + } + } + + /** + * Removes a localized short description from the department. + * + * @param sectionIdentifier + * @param documentPath + * @param localeParam The locale to remove. + * + * @return A redirect to this authoring step. + */ + @POST + @Path("/short-description/@remove/{locale}") + @Transactional(Transactional.TxType.REQUIRED) + @AuthorizationRequired + public String removeShortDescription( + @PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM) + final String sectionIdentifier, + @PathParam(MvcAuthoringSteps.DOCUMENT_PATH_PATH_PARAM_NAME) + final String documentPath, + @PathParam("locale") final String localeParam + ) { + try { + init(); + } catch (ContentSectionNotFoundException ex) { + return ex.showErrorMessage(); + } catch (DocumentNotFoundException ex) { + return ex.showErrorMessage(); + } + + if (itemPermissionChecker.canEditItem(getDocument())) { + final Locale locale = new Locale(localeParam); + final SciDepartment department = (SciDepartment) getDocument(); + department.getShortDescription().removeValue(locale); + itemRepo.save(department); + + return buildRedirectPathForStep(); + } else { + return documentUi.showAccessDenied( + getContentSection(), + getDocument(), + getLabel() + ); + } + } } diff --git a/sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/ui/SciDepartmentPropertiesStepModel.java b/sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/ui/SciDepartmentPropertiesStepModel.java new file mode 100644 index 0000000..ebc788f --- /dev/null +++ b/sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/ui/SciDepartmentPropertiesStepModel.java @@ -0,0 +1,76 @@ +package org.scientificcms.contenttypes.scidepartment.ui; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.enterprise.context.RequestScoped; +import javax.inject.Named; + +/** + * + * @author Jens Pelzetter + */ +@RequestScoped +@Named("SciDepartmentPropertiesStep") +public class SciDepartmentPropertiesStepModel { + + private String name; + + private Map titleValues; + + private List unusedTitleLocales; + + private Map shortDescriptionValues; + + private List unusedShortDescriptionLocales; + + public String getName() { + return name; + } + + public void setName(final String name) { + this.name = name; + } + + public Map getTitleValues() { + return Collections.unmodifiableMap(titleValues); + } + + public void setTitleValues(final Map titleValues) { + this.titleValues = new HashMap<>(titleValues); + } + + public List getUnusedTitleLocales() { + return Collections.unmodifiableList(unusedTitleLocales); + } + + public void setUnusedTitleLocales(final List unusedTitleLocales) { + this.unusedTitleLocales = new ArrayList<>(unusedTitleLocales); + } + + public Map getShortDescriptionValues() { + return Collections.unmodifiableMap(shortDescriptionValues); + } + + public void setShortDescriptionValues( + final Map shortDescriptionValues + ) { + this.shortDescriptionValues = new HashMap<>(shortDescriptionValues); + } + + public List getUnusedShortDescriptionLocales() { + return Collections.unmodifiableList(unusedShortDescriptionLocales); + } + + public void setUnusedShortDescriptionLocales( + final List unusedShortDescriptionLocales + ) { + this.unusedShortDescriptionLocales = new ArrayList<>( + unusedShortDescriptionLocales + ); + } + +} diff --git a/sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/ui/SciDepartmentTextModel.java b/sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/ui/SciDepartmentTextModel.java new file mode 100644 index 0000000..b250d98 --- /dev/null +++ b/sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/ui/SciDepartmentTextModel.java @@ -0,0 +1,84 @@ +package org.scientificcms.contenttypes.scidepartment.ui; + +import org.librecms.ui.contentsections.documents.CmsEditorLocaleVariantRow; +import org.scientificcms.contenttypes.scidepartment.DepartmentText; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; + +/** + * DTO providing the data of a {@link DepartmentText} in a form that is easy + * usable from the view. + * + * @author Jens Pelzetter + */ +public class SciDepartmentTextModel { + + private Map textValues; + + private List variants; + + private List unusedLocales; + + private long order; + + public Map getTextValues() { + return Optional + .ofNullable(textValues) + .map(Collections::unmodifiableMap) + .orElse(Collections.emptyMap()); + } + + protected void setTextValues( + final Map textValues + ) { + this.textValues = Optional + .ofNullable(textValues) + .map(values -> new HashMap<>(values)) + .map(values -> (Map) values) + .orElse(Collections.emptyMap()); + } + + public List getVariants() { + return Optional + .ofNullable(variants) + .map(Collections::unmodifiableList) + .orElse(Collections.emptyList()); + } + + protected void setVariants(final List variants) { + this.variants = Optional + .ofNullable(variants) + .map(list -> new ArrayList<>(list)) + .map(list -> (List) list) + .orElse(Collections.emptyList()); + } + + public List getUnusedLocales() { + return Optional + .ofNullable(unusedLocales) + .map(Collections::unmodifiableList) + .orElse(Collections.emptyList()); + } + + protected void setUnusedLocales(final List unusedLocales) { + this.unusedLocales = Optional + .ofNullable(unusedLocales) + .map(list -> new ArrayList<>(list)) + .map(list -> (List) list) + .orElse(Collections.emptyList()); + } + + public long getOrder() { + return order; + } + + public void setOrder(final long order) { + this.order = order; + } + +} diff --git a/sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/ui/SciDepartmentTextsModel.java b/sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/ui/SciDepartmentTextsModel.java new file mode 100644 index 0000000..e7f7b9d --- /dev/null +++ b/sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/ui/SciDepartmentTextsModel.java @@ -0,0 +1,53 @@ +package org.scientificcms.contenttypes.scidepartment.ui; + +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; + +/** + * + * @author Jens Pelzetter + */ +public class SciDepartmentTextsModel { + + private boolean canEdit; + + private Map texts; + + private String selectedText; + + private String selectedLocale; + + public boolean getCanEdit() { + return canEdit; + } + + protected void setCanEdit(final boolean canEdit) { + this.canEdit = canEdit; + } + + public Map getTexts() { + return Collections.unmodifiableMap(texts); + } + + protected void setTexts(final Map texts) { + this.texts = new HashMap<>(texts); + } + + public String getSelectedText() { + return selectedText; + } + + public void setSelectedText(final String selectedText) { + this.selectedText = selectedText; + } + + public String getSelectedLocale() { + return selectedLocale; + } + + protected void setSelectedLocale(final String selectedLocale) { + this.selectedLocale = selectedLocale; + } + +} diff --git a/sci-types-department/src/main/resources/org/scientificcms/contenttypes/scidepartment/ui/SciDepartmentBundle.properties b/sci-types-department/src/main/resources/org/scientificcms/contenttypes/scidepartment/ui/SciDepartmentBundle.properties new file mode 100644 index 0000000..5e37325 --- /dev/null +++ b/sci-types-department/src/main/resources/org/scientificcms/contenttypes/scidepartment/ui/SciDepartmentBundle.properties @@ -0,0 +1,7 @@ + +createstep.description=Creates a new SciDepartment. +authoringsteps.description.description=Description of the department. +authoringsteps.description.label=Description +scidepartment.edit.denied=Access denied. +authoringsteps.basicproperties.description=Basicproperties of the department. +authoringsteps.basicproperties.label=Basic Properties diff --git a/sci-types-department/src/main/resources/org/scientificcms/contenttypes/scidepartment/ui/SciDepartmentBundle_de.properties b/sci-types-department/src/main/resources/org/scientificcms/contenttypes/scidepartment/ui/SciDepartmentBundle_de.properties new file mode 100644 index 0000000..c7805e8 --- /dev/null +++ b/sci-types-department/src/main/resources/org/scientificcms/contenttypes/scidepartment/ui/SciDepartmentBundle_de.properties @@ -0,0 +1,7 @@ + +createstep.description=Erstellt eine neue Abteilung. +authoringsteps.description.description=Beschreibung der Abteilung. +authoringsteps.description.label=Beschreibung +scidepartment.edit.denied=Zugriff verweigert. +authoringsteps.basicproperties.description=Basiseigenschaften der Abteilung. +authoringsteps.basicproperties.label=Basiseigenschaften diff --git a/sci-types-project/src/main/java/org/scientificcms/contenttypes/sciproject/ui/SciProjectDescriptionStepService.java b/sci-types-project/src/main/java/org/scientificcms/contenttypes/sciproject/ui/SciProjectDescriptionStepService.java index ae66eac..35f9e92 100644 --- a/sci-types-project/src/main/java/org/scientificcms/contenttypes/sciproject/ui/SciProjectDescriptionStepService.java +++ b/sci-types-project/src/main/java/org/scientificcms/contenttypes/sciproject/ui/SciProjectDescriptionStepService.java @@ -76,7 +76,7 @@ public class SciProjectDescriptionStepService { ) ); - if ((document instanceof SciProject)) { + if (!(document instanceof SciProject)) { throw new BadRequestException( String.format( "Document %s is not a %s.", diff --git a/scicms-bundle-devel-wildfly/.gitignore b/scicms-bundle-devel-wildfly/.gitignore new file mode 100644 index 0000000..bae7835 --- /dev/null +++ b/scicms-bundle-devel-wildfly/.gitignore @@ -0,0 +1 @@ +runtime.properties diff --git a/scicms-bundle-devel-wildfly/runtime.properties b/scicms-bundle-devel-wildfly/runtime.properties deleted file mode 100644 index a702584..0000000 --- a/scicms-bundle-devel-wildfly/runtime.properties +++ /dev/null @@ -1,7 +0,0 @@ -libreccm.debug.suspend=n - -libreccm.database.host=localhost -libreccm.database.port=5432 -libreccm.database.name=scicms-devel -libreccm.database.user=ccm -libreccm.database.password=ccm47web -- 2.52.0 From 258d6c614f71a6f44666a3910fd63f5a0a5cee97 Mon Sep 17 00:00:00 2001 From: Jens Pelzetter Date: Mon, 3 Oct 2022 08:35:23 +0200 Subject: [PATCH 06/16] Added missing META-INF files for SciDepartment --- .../resources/META-INF/persistence-ddl.xml | 42 +++++++++++++++++++ .../services/org.libreccm.modules.CcmModule | 1 + 2 files changed, 43 insertions(+) create mode 100644 sci-types-department/src/main/resources/META-INF/persistence-ddl.xml create mode 100644 sci-types-department/src/main/resources/META-INF/services/org.libreccm.modules.CcmModule diff --git a/sci-types-department/src/main/resources/META-INF/persistence-ddl.xml b/sci-types-department/src/main/resources/META-INF/persistence-ddl.xml new file mode 100644 index 0000000..d28eae8 --- /dev/null +++ b/sci-types-department/src/main/resources/META-INF/persistence-ddl.xml @@ -0,0 +1,42 @@ + + + + + + + + + org.hibernate.jpa.HibernatePersistenceProvider + + java:/comp/env/jdbc/scientificcms/db + + + + + + + + + + + + + + + diff --git a/sci-types-department/src/main/resources/META-INF/services/org.libreccm.modules.CcmModule b/sci-types-department/src/main/resources/META-INF/services/org.libreccm.modules.CcmModule new file mode 100644 index 0000000..1fefd10 --- /dev/null +++ b/sci-types-department/src/main/resources/META-INF/services/org.libreccm.modules.CcmModule @@ -0,0 +1 @@ +org.scientificcms.contenttypes.scidepartment.SciDepartmentModule -- 2.52.0 From 0f86a8f540c864772ee403fcbcec2366644920d8 Mon Sep 17 00:00:00 2001 From: Jens Pelzetter Date: Mon, 3 Oct 2022 08:35:38 +0200 Subject: [PATCH 07/16] Simplified controller for editing department texts. --- .../ui/SciDepartmentDescriptionStep.java | 66 +++++++++---------- 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/ui/SciDepartmentDescriptionStep.java b/sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/ui/SciDepartmentDescriptionStep.java index 569627e..d5ae79d 100644 --- a/sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/ui/SciDepartmentDescriptionStep.java +++ b/sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/ui/SciDepartmentDescriptionStep.java @@ -352,38 +352,38 @@ public class SciDepartmentDescriptionStep extends AbstractMvcAuthoringStep { } } - @GET - @Path("/texts/view/{textKey}") - @Transactional(Transactional.TxType.REQUIRED) - @AuthorizationRequired - public String viewDepartmentText( - @PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM) - final String sectionIdentifier, - @PathParam(MvcAuthoringSteps.DOCUMENT_PATH_PATH_PARAM_NAME) - final String documentPath, - @PathParam("textKey") - final String textKey - ) { - try { - init(); - } catch (ContentSectionNotFoundException ex) { - return ex.showErrorMessage(); - } catch (DocumentNotFoundException ex) { - return ex.showErrorMessage(); - } - - if (itemPermissionChecker.canEditItem(getDepartment())) { - textsModel.setSelectedText(textKey); - - return "org/scientificcms/contenttypes/scidepartment/ui/texts/view-values.xhtml"; - } else { - return documentUi.showAccessDenied( - getContentSection(), - getDepartment(), - messageBundle.getMessage("scidepartment.edit.denied") - ); - } - } +// @GET +// @Path("/texts/view/{textKey}") +// @Transactional(Transactional.TxType.REQUIRED) +// @AuthorizationRequired +// public String viewDepartmentText( +// @PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM) +// final String sectionIdentifier, +// @PathParam(MvcAuthoringSteps.DOCUMENT_PATH_PATH_PARAM_NAME) +// final String documentPath, +// @PathParam("textKey") +// final String textKey +// ) { +// try { +// init(); +// } catch (ContentSectionNotFoundException ex) { +// return ex.showErrorMessage(); +// } catch (DocumentNotFoundException ex) { +// return ex.showErrorMessage(); +// } +// +// if (itemPermissionChecker.canEditItem(getDepartment())) { +// textsModel.setSelectedText(textKey); +// +// return "org/scientificcms/contenttypes/scidepartment/ui/texts/view-values.xhtml"; +// } else { +// return documentUi.showAccessDenied( +// getContentSection(), +// getDepartment(), +// messageBundle.getMessage("scidepartment.edit.denied") +// ); +// } +// } @GET @Path("/texts/view/{textKey}/{locale}") @@ -409,7 +409,7 @@ public class SciDepartmentDescriptionStep extends AbstractMvcAuthoringStep { textsModel.setSelectedText(textKey); textsModel.setSelectedLocale(new Locale(localeParam).toString()); - return "org/scientificcms/contenttypes/scidepartment/ui/texts/view-text.xhtml"; + return "org/scientificcms/contenttypes/scidepartment/ui/texts/view.xhtml"; } else { return documentUi.showAccessDenied( getContentSection(), -- 2.52.0 From 087f3c4dcdf33a855693fa80d44f02e0d63dce5c Mon Sep 17 00:00:00 2001 From: Jens Pelzetter Date: Mon, 3 Oct 2022 09:03:13 +0200 Subject: [PATCH 08/16] View for create step of SciDepartment --- .gitignore | 1 + .../scidepartment/SciDepartmentConfig.java | 2 +- .../scidepartment/ui/SciDepartmentRoles.java | 29 +++++++ .../scidepartment/ui/SciDepartmentTexts.java | 29 +++++++ .../ui/create-scidepartment.xhtml | 86 +++++++++++++++++++ .../scidepartment/DefaultTextKeys.properties | 3 + .../DefaultTextKeys_de.properties | 3 + .../ui/SciDepartmentBundle.properties | 13 +++ .../ui/SciDepartmentBundle_de.properties | 13 +++ 9 files changed, 178 insertions(+), 1 deletion(-) create mode 100644 sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/ui/SciDepartmentRoles.java create mode 100644 sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/ui/SciDepartmentTexts.java create mode 100644 sci-types-department/src/main/resources/WEB-INF/views/org/scientificcms/contenttypes/scidepartment/ui/create-scidepartment.xhtml create mode 100644 sci-types-department/src/main/resources/org/scientificcms/contenttypes/scidepartment/DefaultTextKeys.properties create mode 100644 sci-types-department/src/main/resources/org/scientificcms/contenttypes/scidepartment/DefaultTextKeys_de.properties diff --git a/.gitignore b/.gitignore index 1d5b369..13e0f07 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,4 @@ node_modules /sci-publications/target/ /scicms-bundle-devel-wildfly/target/ /sci-types-project/nbproject/ +/sci-types-department/nbproject/ diff --git a/sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/SciDepartmentConfig.java b/sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/SciDepartmentConfig.java index 283419e..811df1b 100644 --- a/sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/SciDepartmentConfig.java +++ b/sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/SciDepartmentConfig.java @@ -22,7 +22,7 @@ public class SciDepartmentConfig { @Setting private String textKeysBundleName - = "org.scientificcms.contenttypes.scidepartment.TextKeysBundle"; + = "org.scientificcms.contenttypes.scidepartment.DefaultTextKeys"; public static SciDepartmentConfig getConfig() { final ConfigurationManager confManager = CdiUtil diff --git a/sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/ui/SciDepartmentRoles.java b/sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/ui/SciDepartmentRoles.java new file mode 100644 index 0000000..32e5229 --- /dev/null +++ b/sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/ui/SciDepartmentRoles.java @@ -0,0 +1,29 @@ +package org.scientificcms.contenttypes.scidepartment.ui; + +import org.libreccm.configuration.ConfigurationManager; +import org.libreccm.ui.AbstractMessagesBean; +import org.scientificcms.contenttypes.scidepartment.SciDepartmentConfig; + +import javax.enterprise.context.RequestScoped; +import javax.inject.Inject; +import javax.inject.Named; + +/** + * + * @author Jens Pelzetter + */ +@RequestScoped +@Named("SciDepartmentRoles") +public class SciDepartmentRoles extends AbstractMessagesBean { + + @Inject + private ConfigurationManager confManager; + + @Override + protected String getMessageBundle() { + return confManager + .findConfiguration(SciDepartmentConfig.class) + .getMemberRolesBundleName(); + } + +} diff --git a/sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/ui/SciDepartmentTexts.java b/sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/ui/SciDepartmentTexts.java new file mode 100644 index 0000000..96d1d70 --- /dev/null +++ b/sci-types-department/src/main/java/org/scientificcms/contenttypes/scidepartment/ui/SciDepartmentTexts.java @@ -0,0 +1,29 @@ +package org.scientificcms.contenttypes.scidepartment.ui; + +import org.libreccm.configuration.ConfigurationManager; +import org.libreccm.ui.AbstractMessagesBean; +import org.scientificcms.contenttypes.scidepartment.SciDepartmentConfig; + +import javax.enterprise.context.RequestScoped; +import javax.inject.Inject; +import javax.inject.Named; + +/** + * + * @author Jens Pelzetter + */ +@RequestScoped +@Named("SciDepartmentTexts") +public class SciDepartmentTexts extends AbstractMessagesBean { + + @Inject + private ConfigurationManager confManager; + + @Override + protected String getMessageBundle() { + return confManager + .findConfiguration(SciDepartmentConfig.class) + .getTextKeysBundleName(); + } + +} diff --git a/sci-types-department/src/main/resources/WEB-INF/views/org/scientificcms/contenttypes/scidepartment/ui/create-scidepartment.xhtml b/sci-types-department/src/main/resources/WEB-INF/views/org/scientificcms/contenttypes/scidepartment/ui/create-scidepartment.xhtml new file mode 100644 index 0000000..c669db6 --- /dev/null +++ b/sci-types-department/src/main/resources/WEB-INF/views/org/scientificcms/contenttypes/scidepartment/ui/create-scidepartment.xhtml @@ -0,0 +1,86 @@ +]> + + + + +
+

#{SciDepartmentMessageBundle['createstep.title']}

+ + + + + +
+ + + + + + + + + + + + #{SciDepartmentMessageBundle['createform.cancel']} + + + + +
+
+ +
+ diff --git a/sci-types-department/src/main/resources/org/scientificcms/contenttypes/scidepartment/DefaultTextKeys.properties b/sci-types-department/src/main/resources/org/scientificcms/contenttypes/scidepartment/DefaultTextKeys.properties new file mode 100644 index 0000000..c43c21b --- /dev/null +++ b/sci-types-department/src/main/resources/org/scientificcms/contenttypes/scidepartment/DefaultTextKeys.properties @@ -0,0 +1,3 @@ + +scidepartment.research=Research +scidepartment.concept=Concept diff --git a/sci-types-department/src/main/resources/org/scientificcms/contenttypes/scidepartment/DefaultTextKeys_de.properties b/sci-types-department/src/main/resources/org/scientificcms/contenttypes/scidepartment/DefaultTextKeys_de.properties new file mode 100644 index 0000000..f608bfa --- /dev/null +++ b/sci-types-department/src/main/resources/org/scientificcms/contenttypes/scidepartment/DefaultTextKeys_de.properties @@ -0,0 +1,3 @@ + +scidepartment.research=Forschung +scidepartment.concept=Leitkonzept diff --git a/sci-types-department/src/main/resources/org/scientificcms/contenttypes/scidepartment/ui/SciDepartmentBundle.properties b/sci-types-department/src/main/resources/org/scientificcms/contenttypes/scidepartment/ui/SciDepartmentBundle.properties index 5e37325..ec666a2 100644 --- a/sci-types-department/src/main/resources/org/scientificcms/contenttypes/scidepartment/ui/SciDepartmentBundle.properties +++ b/sci-types-department/src/main/resources/org/scientificcms/contenttypes/scidepartment/ui/SciDepartmentBundle.properties @@ -5,3 +5,16 @@ authoringsteps.description.label=Description scidepartment.edit.denied=Access denied. authoringsteps.basicproperties.description=Basicproperties of the department. authoringsteps.basicproperties.label=Basic Properties +createstep.title=Create a new department description +createstep.name.help=The name of the new department description. Also used as URL fragment. +createstep.name.label=Name +createform.initial_locale.help=The initial locale of the department description. +createform.initial_locale.label=Summary +createform.title.help=The title of the department. +createform.title.label=Title +createform.summary.help=A summary of the description of the department. +createform.summary.label=Summary +createform.workflow.help=The workflow to use for the department description. +createform.workflow.label=Workflow +createform.cancel=Cancel +createform.submit=Create department diff --git a/sci-types-department/src/main/resources/org/scientificcms/contenttypes/scidepartment/ui/SciDepartmentBundle_de.properties b/sci-types-department/src/main/resources/org/scientificcms/contenttypes/scidepartment/ui/SciDepartmentBundle_de.properties index c7805e8..542fd79 100644 --- a/sci-types-department/src/main/resources/org/scientificcms/contenttypes/scidepartment/ui/SciDepartmentBundle_de.properties +++ b/sci-types-department/src/main/resources/org/scientificcms/contenttypes/scidepartment/ui/SciDepartmentBundle_de.properties @@ -5,3 +5,16 @@ authoringsteps.description.label=Beschreibung scidepartment.edit.denied=Zugriff verweigert. authoringsteps.basicproperties.description=Basiseigenschaften der Abteilung. authoringsteps.basicproperties.label=Basiseigenschaften +createstep.title=Neue Abteilungsbeschriebung anlegen +createstep.name.help=Der Name des neuen Abteilungsbeschreibung. Wird auch als URL-Fragment genutzt. +createstep.name.label=Name +createform.initial_locale.help=Die initiale Sprache der Abteilungsbeschreibung. +createform.initial_locale.label=Zusammenfassung +createform.title.help=Der Titel des Abteilung. +createform.title.label=Titel +createform.summary.help=Eine Zusammenfassung der Beschreibung der Abteilung +createform.summary.label=Zusammenfassung +createform.workflow.help=Der Arbeitsablauf, der f\u00fcr die Abteilungsbeschreibung genutzt werden soll. +createform.workflow.label=Arbeitsablauf +createform.cancel=Abbrechen +createform.submit=Abteilung anlegen -- 2.52.0 From 78d6dbb85d51f67b89f54f3cb28dc3593d846c32 Mon Sep 17 00:00:00 2001 From: Jens Pelzetter Date: Mon, 3 Oct 2022 09:24:54 +0200 Subject: [PATCH 09/16] Fixed a typo in the translations for the views of SciProject. --- .../contenttypes/sciproject/ui/SciProjectBundle_de.properties | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sci-types-project/src/main/resources/org/scientificcms/contenttypes/sciproject/ui/SciProjectBundle_de.properties b/sci-types-project/src/main/resources/org/scientificcms/contenttypes/sciproject/ui/SciProjectBundle_de.properties index 9827564..7800796 100644 --- a/sci-types-project/src/main/resources/org/scientificcms/contenttypes/sciproject/ui/SciProjectBundle_de.properties +++ b/sci-types-project/src/main/resources/org/scientificcms/contenttypes/sciproject/ui/SciProjectBundle_de.properties @@ -8,7 +8,7 @@ basicproperties.name.header=Name basicproperties.name.edit=Name bearbeiten basicproperties.name.edit.title=Name bearbeiten basicproperties.name.edit.close=Abbrechen -basicproperties.name.help=Der Name des Projektes. Wird auch als URL fragment verwendet. +basicproperties.name.help=Der Name des Projektes. Wird auch als URL Fragment verwendet. basicproperties.name.label=Name basicproperties.name.edit.submit=Speichern basicproperties.title.add=Lokalisierten Titel hinzuf\u00fcgen @@ -29,7 +29,7 @@ basicproperties.title.remove=Entfernen basicproperties.title.remove.cancel=Abbrechen basicproperties.title.remove.submit=Entfernen basicproperties.title.remove.text=Sind Sie sicher dass Sie diesen lokalisierten Titel entfernen wollen? -basicproperties.title.remove.header=Entfernen eines lokalisierten Titels entfernen +basicproperties.title.remove.header=Entfernen eines lokalisierten Titels best\u00e4tigen basicproperties.title.header=Titel basicproperties.begin.header=Beginn des Projektes basicproperties.begin.edit=Bearbeiten -- 2.52.0 From 6a795bb049b3350db5f03516113a85c8b8dfa830 Mon Sep 17 00:00:00 2001 From: Jens Pelzetter Date: Mon, 3 Oct 2022 09:25:13 +0200 Subject: [PATCH 10/16] View for editing the basic properties of a SciDepartment --- .../ui/scidepartment-basic-properties.xhtml | 148 ++++++++++++++++++ .../ui/SciDepartmentBundle.properties | 47 ++++++ .../ui/SciDepartmentBundle_de.properties | 47 ++++++ 3 files changed, 242 insertions(+) create mode 100644 sci-types-department/src/main/resources/WEB-INF/views/org/scientificcms/contenttypes/scidepartment/ui/scidepartment-basic-properties.xhtml diff --git a/sci-types-department/src/main/resources/WEB-INF/views/org/scientificcms/contenttypes/scidepartment/ui/scidepartment-basic-properties.xhtml b/sci-types-department/src/main/resources/WEB-INF/views/org/scientificcms/contenttypes/scidepartment/ui/scidepartment-basic-properties.xhtml new file mode 100644 index 0000000..b9d54d7 --- /dev/null +++ b/sci-types-department/src/main/resources/WEB-INF/views/org/scientificcms/contenttypes/scidepartment/ui/scidepartment-basic-properties.xhtml @@ -0,0 +1,148 @@ +]> + + + + + + +

#{SciDepartmentMessageBundle.getMessage('basicproperties.header', [SciDepartmentPropertiesStep.name])}

+ +

#{SciDepartmentMessageBundle['basicproperties.name.header']}

+
+
#{SciDepartmentPropertiesStep.name}
+ + + +
+ + + + + + + + + +
+ +
+ diff --git a/sci-types-department/src/main/resources/org/scientificcms/contenttypes/scidepartment/ui/SciDepartmentBundle.properties b/sci-types-department/src/main/resources/org/scientificcms/contenttypes/scidepartment/ui/SciDepartmentBundle.properties index ec666a2..2aa4ed2 100644 --- a/sci-types-department/src/main/resources/org/scientificcms/contenttypes/scidepartment/ui/SciDepartmentBundle.properties +++ b/sci-types-department/src/main/resources/org/scientificcms/contenttypes/scidepartment/ui/SciDepartmentBundle.properties @@ -18,3 +18,50 @@ createform.workflow.help=The workflow to use for the department description. createform.workflow.label=Workflow createform.cancel=Cancel createform.submit=Create department +basicproperties.header=Edit basic properties of department {0} +basicproperties.name.header=Name +basicproperties.name.edit=Edit name +basicproperties.name.edit.title=Edit name +basicproperties.name.edit.close=Cancel +basicproperties.name.help=The name of the department. Also used as URL fragment. +basicproperties.name.label=Name +basicproperties.title.add=Add a localized title +basicproperties.title.add.cancel=Cancel +basicproperties.title.add.locale.help=The locale of the localized title. +basicproperties.title.add.locale.label=Locale +basicproperties.title.add.submit=Add +basicproperties.title.add.header=Add localized title +basicproperties.title.add.value.help=The localized title. +basicproperties.title.add.value.label=Title +basicproperties.title.edit=Edit +basicproperties.title.edit.cancel=Cancel +basicproperties.title.edit.submit=Save +basicproperties.title.edit.header=Edit localized title +basicproperties.title.edit.value.help=The localized title. +basicproperties.title.edit.value.label=Title +basicproperties.title.remove=Remove +basicproperties.title.remove.cancel=Cancel +basicproperties.title.remove.submit=Remove +basicproperties.title.remove.text=Are you sure to remove this localized title? +basicproperties.title.remove.header=Confirm removal of localized title +basicproperties.title.header=Title +basicproperties.shortdescription.add=Add +basicproperties.shortdescription.add.cancel=Cancel +basicproperties.shortdescription.add.locale.help=The locale of the localized short description. +basicproperties.shortdescription.add.locale.label=Locale +basicproperties.shortdescription.add.submit=Add +basicproperties.shortdescription.add.header=Add a localized short description +basicproperties.shortdescription.add.value.help=The localized short description. +basicproperties.shortdescription.add.value.label=Short description +basicproperties.shortdescription.edit=Edit +basicproperties.shortdescription.edit.cancel=Cancel +basicproperties.shortdescription.edit.submit=Save +basicproperties.shortdescription.edit.header=Edit localized short description +basicproperties.shortdescription.edit.value.help=The localized short description. +basicproperties.shortdescription.edit.value.label=Short description +basicproperties.shortdescription.remove=Remove +basicproperties.shortdescription.remove.cancel=Cancel +basicproperties.shortdescription.remove.submit=Remove +basicproperties.shortdescription.remove.text=Are you sure to remove this localized short description? +basicproperties.shortdescription.remove.header=Confirm removal of localized short description +basicproperties.shortdescription.header=Short description diff --git a/sci-types-department/src/main/resources/org/scientificcms/contenttypes/scidepartment/ui/SciDepartmentBundle_de.properties b/sci-types-department/src/main/resources/org/scientificcms/contenttypes/scidepartment/ui/SciDepartmentBundle_de.properties index 542fd79..ed35947 100644 --- a/sci-types-department/src/main/resources/org/scientificcms/contenttypes/scidepartment/ui/SciDepartmentBundle_de.properties +++ b/sci-types-department/src/main/resources/org/scientificcms/contenttypes/scidepartment/ui/SciDepartmentBundle_de.properties @@ -18,3 +18,50 @@ createform.workflow.help=Der Arbeitsablauf, der f\u00fcr die Abteilungsbeschreib createform.workflow.label=Arbeitsablauf createform.cancel=Abbrechen createform.submit=Abteilung anlegen +basicproperties.header=Basiseigenschaften der Abteilung {0} bearbeiten +basicproperties.name.header=Name +basicproperties.name.edit=Name bearbeiten +basicproperties.name.edit.title=Name bearbeiten +basicproperties.name.edit.close=Abbrechen +basicproperties.name.help=Der Name der Abteilung. Wird auch als URL Fragment verwendet. +basicproperties.name.label=Name +basicproperties.title.add=Lokalisierten Titel hinzuf\u00fcgen +basicproperties.title.add.cancel=Abbrechen +basicproperties.title.add.locale.help=Die Sprache des lokalisierten Titels. +basicproperties.title.add.locale.label=Sprache +basicproperties.title.add.submit=Hinzuf\u00fcgen +basicproperties.title.add.header=Lokalisierten Titel hinzuf\u00fcgen +basicproperties.title.add.value.help=Der lokalisierte Titel. +basicproperties.title.add.value.label=Titel +basicproperties.title.edit=Bearbeiten +basicproperties.title.edit.cancel=Abbrechen +basicproperties.title.edit.submit=Speichern +basicproperties.title.edit.header=Lokalisierten Titel bearbeiten +basicproperties.title.edit.value.help=Der lokalisierte Titel +basicproperties.title.edit.value.label=Titel +basicproperties.title.remove=Entfernen +basicproperties.title.remove.cancel=Abbrechen +basicproperties.title.remove.submit=Entfernen +basicproperties.title.remove.text=Sind Sie sicher dass Sie diesen lokalisierten Titel entfernen wollen? +basicproperties.title.remove.header=Entfernen eines lokalisierten Titels best\u00e4tigen +basicproperties.title.header=Titel +basicproperties.shortdescription.add=Hinzuf\u00fcgen +basicproperties.shortdescription.add.cancel=Abbrechen +basicproperties.shortdescription.add.locale.help=Die Sprache der lokaliserten Kurzbeschreibung. +basicproperties.shortdescription.add.locale.label=Sprache +basicproperties.shortdescription.add.submit=Hinzuf\u00fcgen +basicproperties.shortdescription.add.header=Eine lokaliserte Kurzbeschreibung hinzuf\u00fcgen +basicproperties.shortdescription.add.value.help=Die lokalisierte Kurzbeschreibung. +basicproperties.shortdescription.add.value.label=Kurzbeschreibung +basicproperties.shortdescription.edit=Bearbeiten +basicproperties.shortdescription.edit.cancel=Abbrechen +basicproperties.shortdescription.edit.submit=Speichern +basicproperties.shortdescription.edit.header=Lokalisierte Kurzbeschreibung bearbeiten +basicproperties.shortdescription.edit.value.help=Die lokalisierte Kurzbeschreibung. +basicproperties.shortdescription.edit.value.label=Kurzbeschreibung +basicproperties.shortdescription.remove=Entfernen +basicproperties.shortdescription.remove.cancel=Abbrechen +basicproperties.shortdescription.remove.submit=Entfernen +basicproperties.shortdescription.remove.text=Sind Sie sicher, dass Sie diese lokaliserte Kurzbeschreibung entfernen wollen? +basicproperties.shortdescription.remove.header=Entfernen einer lokalisierten Kurzbeschreibung best\u00e4tigen +basicproperties.shortdescription.header=Kurzbeschreibung -- 2.52.0 From c094c8aa58e447ad039bfe46bdd8aa229b9ea3f8 Mon Sep 17 00:00:00 2001 From: Jens Pelzetter Date: Mon, 3 Oct 2022 13:37:24 +0200 Subject: [PATCH 11/16] Fixed some bugs --- .../sciproject/ui/SciProjectContactTypes.java | 29 +++++++++++++++ .../sciproject/ui/SciProjectRoles.java | 29 +++++++++++++++ .../sciproject/ui/description/view.xhtml | 1 + .../ui/sciproject-description.xhtml | 36 ++++++++++--------- .../sciproject/DefaultMemberRoles.properties | 5 +++ .../DefaultMemberRoles_de.properties | 5 +++ 6 files changed, 89 insertions(+), 16 deletions(-) create mode 100644 sci-types-project/src/main/java/org/scientificcms/contenttypes/sciproject/ui/SciProjectContactTypes.java create mode 100644 sci-types-project/src/main/java/org/scientificcms/contenttypes/sciproject/ui/SciProjectRoles.java create mode 100644 sci-types-project/src/main/resources/org/scientificcms/contenttypes/sciproject/DefaultMemberRoles.properties create mode 100644 sci-types-project/src/main/resources/org/scientificcms/contenttypes/sciproject/DefaultMemberRoles_de.properties diff --git a/sci-types-project/src/main/java/org/scientificcms/contenttypes/sciproject/ui/SciProjectContactTypes.java b/sci-types-project/src/main/java/org/scientificcms/contenttypes/sciproject/ui/SciProjectContactTypes.java new file mode 100644 index 0000000..fad252e --- /dev/null +++ b/sci-types-project/src/main/java/org/scientificcms/contenttypes/sciproject/ui/SciProjectContactTypes.java @@ -0,0 +1,29 @@ +package org.scientificcms.contenttypes.sciproject.ui; + +import org.libreccm.configuration.ConfigurationManager; +import org.libreccm.ui.AbstractMessagesBean; +import org.scientificcms.contenttypes.sciproject.SciProjectConfig; + +import javax.enterprise.context.RequestScoped; +import javax.inject.Inject; +import javax.inject.Named; + +/** + * + * @author Jens Pelzetter + */ +@RequestScoped +@Named("SciProjectContactTypes") +public class SciProjectContactTypes extends AbstractMessagesBean { + + @Inject + private ConfigurationManager confManager; + + @Override + protected String getMessageBundle() { + return confManager + .findConfiguration(SciProjectConfig.class) + .getContactTypesBundleName(); + } + +} diff --git a/sci-types-project/src/main/java/org/scientificcms/contenttypes/sciproject/ui/SciProjectRoles.java b/sci-types-project/src/main/java/org/scientificcms/contenttypes/sciproject/ui/SciProjectRoles.java new file mode 100644 index 0000000..d99a155 --- /dev/null +++ b/sci-types-project/src/main/java/org/scientificcms/contenttypes/sciproject/ui/SciProjectRoles.java @@ -0,0 +1,29 @@ +package org.scientificcms.contenttypes.sciproject.ui; + +import org.libreccm.configuration.ConfigurationManager; +import org.libreccm.ui.AbstractMessagesBean; +import org.scientificcms.contenttypes.sciproject.SciProjectConfig; + +import javax.enterprise.context.RequestScoped; +import javax.inject.Inject; +import javax.inject.Named; + +/** + * + * @author Jens Pelzetter + */ +@RequestScoped +@Named("SciProjectRoles") +public class SciProjectRoles extends AbstractMessagesBean { + + @Inject + private ConfigurationManager confManager; + + @Override + protected String getMessageBundle() { + return confManager + .findConfiguration(SciProjectConfig.class) + .getMemberRolesBundleName(); + } + +} diff --git a/sci-types-project/src/main/resources/WEB-INF/views/org/scientificcms/contenttypes/sciproject/ui/description/view.xhtml b/sci-types-project/src/main/resources/WEB-INF/views/org/scientificcms/contenttypes/sciproject/ui/description/view.xhtml index 346d2ca..15e6423 100644 --- a/sci-types-project/src/main/resources/WEB-INF/views/org/scientificcms/contenttypes/sciproject/ui/description/view.xhtml +++ b/sci-types-project/src/main/resources/WEB-INF/views/org/scientificcms/contenttypes/sciproject/ui/description/view.xhtml @@ -31,6 +31,7 @@ + diff --git a/sci-types-project/src/main/resources/WEB-INF/views/org/scientificcms/contenttypes/sciproject/ui/sciproject-description.xhtml b/sci-types-project/src/main/resources/WEB-INF/views/org/scientificcms/contenttypes/sciproject/ui/sciproject-description.xhtml index ce62f3e..58b3b71 100644 --- a/sci-types-project/src/main/resources/WEB-INF/views/org/scientificcms/contenttypes/sciproject/ui/sciproject-description.xhtml +++ b/sci-types-project/src/main/resources/WEB-INF/views/org/scientificcms/contenttypes/sciproject/ui/sciproject-description.xhtml @@ -18,13 +18,13 @@ #{SciProjectMessageBundle.getMessage('description_step.errors.contactable_not_found', [contactableNotFound])} - + - +