Assets for the publications modulAssets for the publications modulee

pull/1/head
Jens Pelzetter 2019-08-19 20:26:55 +02:00
parent e204933a6f
commit ba30f3d60e
8 changed files with 839 additions and 1 deletions

2
.gitignore vendored
View File

@ -1,2 +1,4 @@
/sci-types-project/target/ /sci-types-project/target/
/scientificcms/target/ /scientificcms/target/
/sci-publications/nbproject/
/sci-publications/target/

View File

@ -43,6 +43,7 @@
<modules> <modules>
<module>sci-types-project</module> <module>sci-types-project</module>
<module>scientificcms</module> <module>scientificcms</module>
<module>sci-publications</module>
</modules> </modules>
<reporting> <reporting>

View File

@ -0,0 +1,311 @@
<?xml version="1.0" encoding="UTF-8"?>
<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/xsd/maven-4.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-publications</artifactId>
<version>7.0.0-SNAPSHOT</version>
<name>ScientificCMS Publications</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>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-envers</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
</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-publications</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<optimize>true</optimize>
<debug>true</debug>
<encoding>${project.build.sourceEncoding}</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.18.1</version>
<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>
</configuration>
<executions>
<execution>
<goals>
<goal>gen-ddl</goal>
</goals>
<phase>process-classes</phase>
</execution>
</executions>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</build>
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.10.3</version>
<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>
<doclet>org.jboss.apiviz.APIviz</doclet>
<docletArtifact>
<groupId>org.jboss.apiviz</groupId>
<artifactId>apiviz</artifactId>
<version>1.3.2.GA</version>
</docletArtifact>
<useStandardDocletOptions>true</useStandardDocletOptions>
<additionalparam>
-sourceclasspath ${project.build.outputDirectory}
</additionalparam>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jxr-plugin</artifactId>
<version>2.5</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-report-plugin</artifactId>
<version>2.18.1</version>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.7.5.201505241946</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
<version>3.0.1</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pmd-plugin</artifactId>
<version>3.7</version>
<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>
<version>2.1</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>2.8</version>
<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,16 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package org.scientificcms;
/**
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
public class SciPublicationsConstants {
public static final String DB_SCHEMA = "SCI_PUBLICATIONS";
}

View File

@ -0,0 +1,175 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package org.scientificcms.publications.assets;
import org.hibernate.envers.Audited;
import org.libreccm.l10n.LocalizedString;
import org.librecms.contentsection.Asset;
import java.util.Objects;
import javax.persistence.AssociationOverride;
import javax.persistence.Embedded;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.Table;
import static org.scientificcms.SciPublicationsConstants.*;
/**
* Asset for storing informations about a journal.
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
@Entity
@Table(name = "JOURNALS", schema = DB_SCHEMA)
@Audited
public class Journal extends Asset {
private static final long serialVersionUID = 1L;
/**
* Year in which the journal was published first.
*/
private Integer firstYear;
/**
* Year in which the journal was published last
*/
private Integer lastYear;
/**
* The ISSN of the journal.
*/
private String issn;
/**
* A short description of the journal.
*/
@Embedded
@AssociationOverride(
name = "values",
joinTable = @JoinTable(name = "JOURNAL_DESCRIPTIONS",
schema = DB_SCHEMA,
joinColumns = {
@JoinColumn(name = "OBJECT_ID")
})
)
private LocalizedString description;
/**
* The usual symbol/abbrevation used to refer to the journal.
*/
private String symbol;
public Integer getFirstYear() {
return firstYear;
}
public void setFirstYear(final Integer firstYear) {
this.firstYear = firstYear;
}
public Integer getLastYear() {
return lastYear;
}
public void setLastYear(final Integer lastYear) {
this.lastYear = lastYear;
}
public String getIssn() {
return issn;
}
public void setIssn(final String issn) {
this.issn = issn;
}
public LocalizedString getDescription() {
return description;
}
public void setDescription(final LocalizedString description) {
this.description = description;
}
public String getSymbol() {
return symbol;
}
public void setSymbol(final String symbol) {
this.symbol = symbol;
}
@Override
public int hashCode() {
int hash = super.hashCode();
hash = 73 * hash + Objects.hashCode(firstYear);
hash = 73 * hash + Objects.hashCode(lastYear);
hash = 73 * hash + Objects.hashCode(issn);
hash = 73 * hash + Objects.hashCode(description);
hash = 73 * hash + Objects.hashCode(symbol);
return hash;
}
@Override
public boolean equals(final Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!super.equals(obj)) {
return false;
}
if (!(obj instanceof Journal)) {
return false;
}
final Journal other = (Journal) obj;
if (!other.canEqual(this)) {
return false;
}
if (!Objects.equals(firstYear, other.getFirstYear())) {
return false;
}
if (!Objects.equals(lastYear, other.getLastYear())) {
return false;
}
if (!Objects.equals(issn, other.getIssn())) {
return false;
}
if (!Objects.equals(symbol, other.getSymbol())) {
return false;
}
return Objects.equals(description, other.getDescription());
}
@Override
public boolean canEqual(final Object obj) {
return obj instanceof Journal;
}
@Override
public String toString(final String data) {
return super.toString(String.format(
", firstYear = %s, "
+ "lastYear = %s, "
+ "issn = \"%s\", "
+ "symbol = \"%s\", "
+ "description = %s%s",
Objects.toString(firstYear),
Objects.toString(lastYear),
issn,
symbol,
description,
data));
}
}

View File

@ -0,0 +1,109 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package org.scientificcms.publications.assets;
import org.hibernate.envers.Audited;
import org.librecms.contentsection.Asset;
import java.util.Objects;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import static org.scientificcms.SciPublicationsConstants.*;
/**
* An asset for storing the informations about a publisher required to create
* correct bibliographic references.
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
@Entity
@Table(name = "PUBLISHERS", schema = DB_SCHEMA)
@Audited
public class Publisher extends Asset {
private static final long serialVersionUID = 1L;
/**
* Name of the publisher. The title of the asset is only for internal use,
* this property should be used for name of the publisher which is displayed
* on public pages.
*/
@Column(name = "NAME", length = 2048, nullable = false)
private String name;
/**
* The place of the publisher.
*/
@Column(name = "PLACE", length = 2048)
private String place;
public String getName() {
return name;
}
public void setName(final String name) {
this.name = name;
}
public String getPlace() {
return place;
}
public void setPlace(final String place) {
this.place = place;
}
@Override
public int hashCode() {
int hash = super.hashCode();
hash = 29 * hash + Objects.hashCode(name);
hash = 29 * hash + Objects.hashCode(place);
return hash;
}
@Override
public boolean equals(final Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!super.equals(obj)) {
return false;
}
if (!(obj instanceof Publisher)) {
return false;
}
final Publisher other = (Publisher) obj;
if (!other.canEqual(this)) {
return false;
}
if (!Objects.equals(name, other.getName())) {
return false;
}
return Objects.equals(place, other.getPlace());
}
@Override
public boolean canEqual(final Object obj) {
return obj instanceof Publisher;
}
@Override
public String toString(final String data) {
return super.toString(String.format(
", name = \"%s\", "
+ "place = \"%s\"%s",
name,
place,
data));
}
}

View File

@ -0,0 +1,53 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package org.libreccm.security;
import nl.jqno.equalsverifier.EqualsVerifier;
/**
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
public final class SecurityEntitiesPrefabProvider {
private SecurityEntitiesPrefabProvider() {
// Nothing
}
public static void addPrefabEntities(final EqualsVerifier<?> verifier) {
final Role role1 = new Role();
role1.setRoleId(2001);
role1.setName("role1");
final Role role2 = new Role();
role2.setRoleId(2002);
role2.setName("role2");
verifier.withPrefabValues(Role.class, role1, role2);
final Group group1 = new Group();
group1.setPartyId(3001);
group1.setName("group1");
final Group group2 = new Group();
group2.setPartyId(3002);
group2.setName("group2");
verifier.withPrefabValues(Group.class, group1, group2);
final User user1 = new User();
user1.setPartyId(4001);
user1.setName("user1");
final User user2 = new User();
user2.setPartyId(4002);
user2.setName("user2");
verifier.withPrefabValues(User.class, user1, user2);
}
}

View File

@ -0,0 +1,171 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package org.scientificcms.publications.assets;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.libreccm.categorization.Category;
import org.libreccm.core.CcmObject;
import org.libreccm.l10n.LocalizedString;
import org.libreccm.security.SecurityEntitiesPrefabProvider;
import org.libreccm.tests.categories.UnitTest;
import org.libreccm.testutils.EqualsVerifier;
import org.libreccm.workflow.Workflow;
import org.librecms.assets.Organization;
import org.librecms.contentsection.ContentItem;
import org.librecms.contentsection.ContentSection;
import org.librecms.contentsection.ContentType;
import org.librecms.contentsection.ItemAttachment;
import org.librecms.lifecycle.Lifecycle;
import java.util.Arrays;
import java.util.Collection;
import java.util.Locale;
/**
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
@RunWith(Parameterized.class)
@org.junit.experimental.categories.Category(UnitTest.class)
public class EqualsAndHashCodeTest extends EqualsVerifier {
@Parameterized.Parameters(name = "{0}")
public static Collection<Class<?>> data() {
return Arrays.asList(new Class<?>[]{
Journal.class,
Publisher.class
});
}
public EqualsAndHashCodeTest(final Class<?> clazz) {
super(clazz);
}
@Override
protected void addPrefabValues(
final nl.jqno.equalsverifier.EqualsVerifier<?> verifier) {
final Journal journal1 = new Journal();
journal1.setFirstYear(1953);
journal1.setSymbol("foo");
final Journal journal2 = new Journal();
journal2.setSymbol("bar");
verifier.withPrefabValues(Journal.class, journal1, journal2);
final Publisher publisher1 = new Publisher();
publisher1.setName("Muster Verlag");
publisher1.setPlace("Musterburg");
final Publisher publisher2 = new Publisher();
publisher2.setName("Example Press");
publisher2.setPlace("Riverton");
verifier.withPrefabValues(Publisher.class, publisher1, publisher2);
final ContentSection contentSection1 = new ContentSection();
contentSection1.setObjectId(401);
contentSection1.setDisplayName("section1");
final ContentSection contentSection2 = new ContentSection();
contentSection2.setObjectId(402);
contentSection2.setDisplayName("section2");
verifier.withPrefabValues(ContentSection.class,
contentSection1,
contentSection2);
final ContentType contentType1 = new ContentType();
contentType1.setObjectId(501);
contentType1.setDisplayName("type-1");
final ContentType contentType2 = new ContentType();
contentType2.setObjectId(502);
contentType2.setDisplayName("type-2");
verifier.withPrefabValues(ContentType.class,
contentType1,
contentType2);
final ContentItem item1 = new ContentItem();
item1.setObjectId(601);
item1.setDisplayName("item1");
final ContentItem item2 = new ContentItem();
item2.setObjectId(602);
item2.setDisplayName("item2");
verifier.withPrefabValues(ContentItem.class, item1, item2);
final Lifecycle lifecycle1 = new Lifecycle();
lifecycle1.setLifecycleId(801);
lifecycle1.setStarted(true);
final Lifecycle lifecycle2 = new Lifecycle();
lifecycle2.setLifecycleId(802);
lifecycle2.setStarted(false);
verifier.withPrefabValues(Lifecycle.class, lifecycle1, lifecycle2);
final Workflow workflow1 = new Workflow();
final LocalizedString workflow1Name = new LocalizedString();
workflow1Name.addValue(Locale.ROOT, "workflow1");
workflow1.setName(workflow1Name);
final Workflow workflow2 = new Workflow();
final LocalizedString workflow2Name = new LocalizedString();
workflow2Name.addValue(Locale.ROOT, "workflow2");
workflow2.setName(workflow2Name);
verifier.withPrefabValues(Workflow.class, workflow1, workflow2);
final CcmObject ccmObj1 = new CcmObject();
ccmObj1.setObjectId(1001);
ccmObj1.setDisplayName("obj1");
final CcmObject ccmObj2 = new CcmObject();
ccmObj2.setObjectId(1002);
ccmObj2.setDisplayName("obj2");
verifier.withPrefabValues(CcmObject.class, ccmObj1, ccmObj2);
SecurityEntitiesPrefabProvider.addPrefabEntities(verifier);
final Category category1 = new Category();
category1.setObjectId(5001);
category1.setName("category1");
final Category category2 = new Category();
category2.setCategoryOrder(5002);
category2.setName("category2");
verifier.withPrefabValues(Category.class, category1, category2);
final Organization organization1 = new Organization();
organization1.setName("orga1");
final Organization organization2 = new Organization();
organization1.setName("orga2");
verifier.withPrefabValues(Organization.class,
organization1,
organization2);
final ItemAttachment<?> itemAttachment1 = new ItemAttachment<>();
itemAttachment1.setUuid("927ac9de-029d-4233-9015-1135eb861c34");
final ItemAttachment<?> itemAttachment2 = new ItemAttachment<>();
itemAttachment2.setUuid("d1bd98a1-75c2-4e61-8f9f-2e2eadd30812");
verifier.withPrefabValues(ItemAttachment.class,
itemAttachment1,
itemAttachment2);
}
}