Basic structure for sci department content type

pull/1/head
Jens Pelzetter 2022-09-27 20:22:58 +02:00
parent e7ba0e4822
commit 2c2773949e
14 changed files with 738 additions and 1 deletions

View File

@ -61,6 +61,7 @@
</repositories>
<modules>
<module>sci-types-department</module>
<module>sci-types-project</module>
<module>scientificcms</module>
<module>sci-publications</module>

View File

@ -0,0 +1,350 @@
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<timestamp>${maven.build.timestamp}</timestamp>
<maven.build.timestamp.format>yyyy-MM-dd'T'HH:mm:ss'Z'Z</maven.build.timestamp.format>
</properties>
<parent>
<groupId>org.scientificcms</groupId>
<artifactId>scientificcms-parent</artifactId>
<version>7.0.0-SNAPSHOT</version>
</parent>
<groupId>org.scientificcms</groupId>
<artifactId>sci-types-department</artifactId>
<version>7.0.0-SNAPSHOT</version>
<name>ScientificCMS SciDepartment Content Type</name>
<dependencies>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<type>jar</type>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.libreccm</groupId>
<artifactId>ccm-core</artifactId>
<version>${project.parent.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.librecms</groupId>
<artifactId>ccm-cms</artifactId>
<version>${project.parent.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-envers</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.hibernate.validator</groupId>
<artifactId>hibernate-validator</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-library</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.libreccm</groupId>
<artifactId>ccm-testutils</artifactId>
<version>${project.parent.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>nl.jqno.equalsverifier</groupId>
<artifactId>equalsverifier</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.arquillian.junit</groupId>
<artifactId>arquillian-junit-container</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.arquillian.extension</groupId>
<artifactId>arquillian-persistence-dbunit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.shrinkwrap.resolver</groupId>
<artifactId>shrinkwrap-resolver-impl-maven</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<finalName>sci-types-department</finalName>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
<resource>
<directory>./target/generated-resources</directory>
</resource>
</resources>
<testResources>
<testResource>
<directory>src/test/resources</directory>
</testResource>
<testResource>
<directory>${project.build.directory}/generated-resources</directory>
</testResource>
</testResources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>11</source>
<target>11</target>
<optimize>true</optimize>
<debug>true</debug>
<encoding>${project.build.sourceEncoding}</encoding>
</configuration>
</plugin>
<plugin>
<groupId>com.github.eirslett</groupId>
<artifactId>frontend-maven-plugin</artifactId>
<configuration>
<installDirectory>../node</installDirectory>
</configuration>
<executions>
<execution>
<id>Install node.js and NPM</id>
<goals>
<goal>install-node-and-npm</goal>
</goals>
<configuration>
<nodeVersion>v16.14.2</nodeVersion>
</configuration>
</execution>
<execution>
<id>npm install</id>
<goals>
<goal>npm</goal>
</goals>
<configuration>
<arguments> --userconfig ../libreccm.npmrc install</arguments>
</configuration>
</execution>
<execution>
<id>build</id>
<goals>
<goal>npm</goal>
</goals>
<configuration>
<arguments>run build</arguments>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<groups>org.libreccm.tests.categories.UnitTest</groups>
</configuration>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<executions>
<execution>
<id>default-prepare-agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>default-report</id>
<phase>prepare-package</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>de.jpdigital</groupId>
<artifactId>hibernate53-ddl-maven-plugin</artifactId>
<configuration>
<dialects>
<param>h2</param>
<param>oracle12c</param>
<param>postgresql9</param>
</dialects>
<packages>
<param>org.libreccm</param>
<param>org.librecms</param>
<param>org.scientificcms</param>
</packages>
<useEnvers>true</useEnvers>
<persistenceXml>${basedir}/src/main/resources/META-INF/persistence-ddl.xml</persistenceXml>
</configuration>
<executions>
<execution>
<goals>
<goal>gen-ddl</goal>
</goals>
<phase>process-classes</phase>
</execution>
</executions>
</plugin>
</plugins>
</build>
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<configuration>
<detectLinks>true</detectLinks>
<detectJavaApiLinks>true</detectJavaApiLinks>
<links>
<link>http://docs.oracle.com/javase/7/docs/api/</link>
<link>http://docs.oracle.com/javaee/7/api/</link>
<link>http://docs.jboss.org/hibernate/orm/4.3/javadocs/</link>
</links>
<show>private</show>
<docfilessubdirs>true</docfilessubdirs>
<charset>UTF-8</charset>
<encoding>UTF-8</encoding>
<docencoding>UTF-8</docencoding>
<breakiterator>true</breakiterator>
<version>true</version>
<author>true</author>
<keywords>true</keywords>
<failOnError>false</failOnError>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jxr-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-report-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pmd-plugin</artifactId>
<configuration>
<linkXref>true</linkXref>
<sourceEncoding>utf-8</sourceEncoding>
<targetJdk>1.8</targetJdk>
<!-- <rulesets>
<ruleset>/rulesets/java/basic.xml</ruleset>
<ruleset>/rulesets/java/braces.xml</ruleset>
<ruleset>/rulesets/java/clone.xml</ruleset>
<ruleset>/rulesets/java/codesize.xml</ruleset>
<ruleset>/rulesets/java/design.xml</ruleset>
<ruleset>/rulesets/java/empty.xml</ruleset>
<ruleset>/rulesets/java/finalizers.xml</ruleset>
<ruleset>/rulesets/java/imports.xml</ruleset>
<ruleset>/rulesets/java/junit.xml</ruleset>
<ruleset>/rulesets/java/naming.xml</ruleset>
<ruleset>/rulesets/java/optimizations.xml</ruleset>
<ruleset>/rulesets/java/strictexception.xml</ruleset>
<ruleset>/rulesets/java/strings.xml</ruleset>
<ruleset>/rulesets/java/sunsecure.xml</ruleset>
<ruleset>/rulesets/java/typeresolution.xml</ruleset>
<ruleset>/rulesets/java/unnecessary.xml</ruleset>
<ruleset>/rulesets/java/unusedcode.xml</ruleset>
</rulesets>-->
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>javancss-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId>
<reportSets>
<reportSet>
<reports>
<report>dependencies</report>
<report>licenses</report>
</reports>
</reportSet>
</reportSets>
<configuration>
<dependencyLocationsEnabled>false</dependencyLocationsEnabled>
</configuration>
</plugin>
</plugins>
</reporting>
</project>

View File

@ -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 <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
@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<String, DepartmentText> additionalTexts;
@OneToMany(cascade = CascadeType.ALL, mappedBy = "department")
@OrderBy("order ASC")
@JsonIgnore
private List<Contact> contacts;
@OneToMany(cascade = CascadeType.ALL, mappedBy = "project")
@OrderBy("member ASC")
@JsonIgnore
private List<Membership> members;
@OneToMany(cascade = CascadeType.ALL, mappedBy = "project")
@OrderBy("member ASC")
@JsonIgnore
private List<DepartmentProject> projects;
}

View File

@ -0,0 +1,18 @@
package org.scientificcms.contenttypes.scidepartment;
/**
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
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
}
}

View File

@ -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 <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
@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;
}
}

View File

@ -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 <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
@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
}
}

View File

@ -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 <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
@RequestScoped
@Named("SciDepartmentCreateStep")
public class SciDepartmentCreateStep
extends AbstractMvcDocumentCreateStep<SciDepartment>{
@Override
public String showCreateStep() {
throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody
}
@Override
public String createItem(Map<String, String[]> 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
}
}

View File

@ -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 <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
@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 {
}

View File

@ -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 <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
@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 {
}

View File

@ -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 <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
@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 {
}

View File

@ -0,0 +1,16 @@
package org.scientificcms.contenttypes.scidepartment.ui;
/**
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
public final class SciDepartmentStepsConstants {
private SciDepartmentStepsConstants() {
// Nothing
}
public static final String BUNDLE
= "org.scientificcms.contenttypes.scidepartment.ui.SciDepartmentBundle";
}

View File

@ -0,0 +1,3 @@
label=Department
description=Describes a department.

View File

@ -0,0 +1,3 @@
label=Abteillung
description=Beschreibung einer Abteilung oder eines Lehrstuhls.

View File

@ -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;