Adaptions because of changes in ccm-core and ccm-cms
parent
0da54d551a
commit
7404564cdc
86
pom.xml
86
pom.xml
|
|
@ -118,15 +118,15 @@
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-assembly-plugin</artifactId>
|
<artifactId>maven-assembly-plugin</artifactId>
|
||||||
<version>3.1.1</version>
|
<version>3.3.0</version>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
<version>3.8.0</version>
|
<version>3.8.1</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<source>1.8</source>
|
<source>11</source>
|
||||||
<target>1.8</target>
|
<target>11</target>
|
||||||
<optimize>true</optimize>
|
<optimize>true</optimize>
|
||||||
<debug>true</debug>
|
<debug>true</debug>
|
||||||
<encoding>${project.build.sourceEncoding}</encoding>
|
<encoding>${project.build.sourceEncoding}</encoding>
|
||||||
|
|
@ -135,31 +135,31 @@
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-ear-plugin</artifactId>
|
<artifactId>maven-ear-plugin</artifactId>
|
||||||
<version>3.0.1</version>
|
<version>3.0.2</version>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-enforcer-plugin</artifactId>
|
<artifactId>maven-enforcer-plugin</artifactId>
|
||||||
<version>3.0.0-M2</version>
|
<version>3.0.0-M3</version>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-jar-plugin</artifactId>
|
<artifactId>maven-jar-plugin</artifactId>
|
||||||
<version>3.1.1</version>
|
<version>3.2.0</version>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-javadoc-plugin</artifactId>
|
<artifactId>maven-javadoc-plugin</artifactId>
|
||||||
<version>3.1.0</version>
|
<version>3.2.0</version>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-pmd-plugin</artifactId>
|
<artifactId>maven-pmd-plugin</artifactId>
|
||||||
<version>3.11.0</version>
|
<version>3.13.0</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<linkXref>true</linkXref>
|
<linkXref>true</linkXref>
|
||||||
<sourceEncoding>utf-8</sourceEncoding>
|
<sourceEncoding>utf-8</sourceEncoding>
|
||||||
<targetJdk>1.8</targetJdk>
|
<targetJdk>11</targetJdk>
|
||||||
<!-- <rulesets>
|
<!-- <rulesets>
|
||||||
<ruleset>/rulesets/basic.xml</ruleset>
|
<ruleset>/rulesets/basic.xml</ruleset>
|
||||||
<ruleset>/rulesets/braces.xml</ruleset>
|
<ruleset>/rulesets/braces.xml</ruleset>
|
||||||
|
|
@ -191,27 +191,32 @@
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-project-info-reports-plugin</artifactId>
|
<artifactId>maven-project-info-reports-plugin</artifactId>
|
||||||
<version>3.0.0</version>
|
<version>3.1.0</version>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-release-plugin</artifactId>
|
<artifactId>maven-release-plugin</artifactId>
|
||||||
<version>2.5.3</version>
|
<version>3.0.0-M1</version>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-failsafe-plugin</artifactId>
|
||||||
|
<version>3.0.0-M5</version>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-surefire-plugin</artifactId>
|
<artifactId>maven-surefire-plugin</artifactId>
|
||||||
<version>3.0.0-M3</version>
|
<version>3.0.0-M4</version>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-site-plugin</artifactId>
|
<artifactId>maven-site-plugin</artifactId>
|
||||||
<version>3.7.1</version>
|
<version>3.9.0</version>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-war-plugin</artifactId>
|
<artifactId>maven-war-plugin</artifactId>
|
||||||
<version>3.2.2</version>
|
<version>3.3.0</version>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
|
|
@ -220,17 +225,17 @@
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.codehaus.mojo</groupId>
|
<groupId>org.codehaus.mojo</groupId>
|
||||||
<artifactId>exec-maven-plugin</artifactId>
|
<artifactId>exec-maven-plugin</artifactId>
|
||||||
<version>1.6.0</version>
|
<version>3.3.0</version>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>com.github.eirslett</groupId>
|
<groupId>com.github.eirslett</groupId>
|
||||||
<artifactId>frontend-maven-plugin</artifactId>
|
<artifactId>frontend-maven-plugin</artifactId>
|
||||||
<version>1.7.6</version>
|
<version>1.10.0</version>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>com.github.spotbugs</groupId>
|
<groupId>com.github.spotbugs</groupId>
|
||||||
<artifactId>spotbugs-maven-plugin</artifactId>
|
<artifactId>spotbugs-maven-plugin</artifactId>
|
||||||
<version>3.1.11</version>
|
<version>4.0.0</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<findbugsXmlOutput>true</findbugsXmlOutput>
|
<findbugsXmlOutput>true</findbugsXmlOutput>
|
||||||
<xmlOutput>true</xmlOutput>
|
<xmlOutput>true</xmlOutput>
|
||||||
|
|
@ -249,47 +254,42 @@
|
||||||
<artifactId>hibernate53-ddl-maven-plugin</artifactId>
|
<artifactId>hibernate53-ddl-maven-plugin</artifactId>
|
||||||
<version>2.3.0</version>
|
<version>2.3.0</version>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
|
||||||
<groupId>io.thorntail</groupId>
|
|
||||||
<artifactId>thorntail-maven-plugin</artifactId>
|
|
||||||
<version>2.4.0.Final</version>
|
|
||||||
</plugin>
|
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.codehaus.mojo</groupId>
|
<groupId>org.codehaus.mojo</groupId>
|
||||||
<artifactId>build-helper-maven-plugin</artifactId>
|
<artifactId>build-helper-maven-plugin</artifactId>
|
||||||
<version>3.0.0</version>
|
<version>3.1.0</version>
|
||||||
</plugin>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.codehaus.mojo</groupId>
|
|
||||||
<artifactId>findbugs-maven-plugin</artifactId>
|
|
||||||
<version>3.0.5</version>
|
|
||||||
<configuration>
|
|
||||||
<findbugsXmlOutput>true</findbugsXmlOutput>
|
|
||||||
<xmlOutput>true</xmlOutput>
|
|
||||||
</configuration>
|
|
||||||
<executions>
|
|
||||||
<execution>
|
|
||||||
<phase>package</phase>
|
|
||||||
<goals>
|
|
||||||
<goal>findbugs</goal>
|
|
||||||
</goals>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.codehaus.mojo</groupId>
|
<groupId>org.codehaus.mojo</groupId>
|
||||||
<artifactId>versions-maven-plugin</artifactId>
|
<artifactId>versions-maven-plugin</artifactId>
|
||||||
<version>2.7</version>
|
<version>2.7</version>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.codehaus.mojo</groupId>
|
||||||
|
<artifactId>taglist-maven-plugin</artifactId>
|
||||||
|
<version>2.4</version>
|
||||||
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.jacoco</groupId>
|
<groupId>org.jacoco</groupId>
|
||||||
<artifactId>jacoco-maven-plugin</artifactId>
|
<artifactId>jacoco-maven-plugin</artifactId>
|
||||||
<version>0.8.3</version>
|
<version>0.8.5</version>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.wildfly.plugins</groupId>
|
<groupId>org.wildfly.plugins</groupId>
|
||||||
<artifactId>wildfly-maven-plugin</artifactId>
|
<artifactId>wildfly-maven-plugin</artifactId>
|
||||||
<version>2.0.1.Final</version>
|
<version>2.1.0.Beta1</version>
|
||||||
|
<configuration>
|
||||||
|
<skip>true</skip>
|
||||||
|
<version>24.0.1.Final</version>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.wildfly.plugins</groupId>
|
||||||
|
<artifactId>wildfly-jar-maven-plugin</artifactId>
|
||||||
|
<version>3.0.2.Final</version>
|
||||||
|
<configuration>
|
||||||
|
<skip>true</skip>
|
||||||
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</pluginManagement>
|
</pluginManagement>
|
||||||
|
|
|
||||||
|
|
@ -58,11 +58,17 @@
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.hibernate</groupId>
|
<groupId>org.hibernate.validator</groupId>
|
||||||
<artifactId>hibernate-validator</artifactId>
|
<artifactId>hibernate-validator</artifactId>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.logging.log4j</groupId>
|
||||||
|
<artifactId>log4j-api</artifactId>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>junit</groupId>
|
<groupId>junit</groupId>
|
||||||
<artifactId>junit</artifactId>
|
<artifactId>junit</artifactId>
|
||||||
|
|
@ -125,10 +131,9 @@
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
<version>3.3</version>
|
|
||||||
<configuration>
|
<configuration>
|
||||||
<source>1.8</source>
|
<source>11</source>
|
||||||
<target>1.8</target>
|
<target>11</target>
|
||||||
<optimize>true</optimize>
|
<optimize>true</optimize>
|
||||||
<debug>true</debug>
|
<debug>true</debug>
|
||||||
<encoding>${project.build.sourceEncoding}</encoding>
|
<encoding>${project.build.sourceEncoding}</encoding>
|
||||||
|
|
@ -138,7 +143,6 @@
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-surefire-plugin</artifactId>
|
<artifactId>maven-surefire-plugin</artifactId>
|
||||||
<version>2.18.1</version>
|
|
||||||
<configuration>
|
<configuration>
|
||||||
<groups>org.libreccm.tests.categories.UnitTest</groups>
|
<groups>org.libreccm.tests.categories.UnitTest</groups>
|
||||||
</configuration>
|
</configuration>
|
||||||
|
|
@ -205,7 +209,6 @@
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-javadoc-plugin</artifactId>
|
<artifactId>maven-javadoc-plugin</artifactId>
|
||||||
<version>2.10.3</version>
|
|
||||||
<configuration>
|
<configuration>
|
||||||
<detectLinks>true</detectLinks>
|
<detectLinks>true</detectLinks>
|
||||||
<detectJavaApiLinks>true</detectJavaApiLinks>
|
<detectJavaApiLinks>true</detectJavaApiLinks>
|
||||||
|
|
@ -224,49 +227,34 @@
|
||||||
<author>true</author>
|
<author>true</author>
|
||||||
<keywords>true</keywords>
|
<keywords>true</keywords>
|
||||||
<failOnError>false</failOnError>
|
<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>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-jxr-plugin</artifactId>
|
<artifactId>maven-jxr-plugin</artifactId>
|
||||||
<version>2.5</version>
|
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-surefire-report-plugin</artifactId>
|
<artifactId>maven-surefire-report-plugin</artifactId>
|
||||||
<version>2.18.1</version>
|
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.jacoco</groupId>
|
<groupId>org.jacoco</groupId>
|
||||||
<artifactId>jacoco-maven-plugin</artifactId>
|
<artifactId>jacoco-maven-plugin</artifactId>
|
||||||
<version>0.7.5.201505241946</version>
|
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.codehaus.mojo</groupId>
|
<groupId>org.codehaus.mojo</groupId>
|
||||||
<artifactId>findbugs-maven-plugin</artifactId>
|
<artifactId>findbugs-maven-plugin</artifactId>
|
||||||
<version>3.0.1</version>
|
|
||||||
</plugin>
|
</plugin>
|
||||||
|
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-pmd-plugin</artifactId>
|
<artifactId>maven-pmd-plugin</artifactId>
|
||||||
<version>3.7</version>
|
|
||||||
<configuration>
|
<configuration>
|
||||||
<linkXref>true</linkXref>
|
<linkXref>true</linkXref>
|
||||||
<sourceEncoding>utf-8</sourceEncoding>
|
<sourceEncoding>utf-8</sourceEncoding>
|
||||||
<targetJdk>1.8</targetJdk>
|
<targetJdk>1.8</targetJdk>
|
||||||
<rulesets>
|
<!-- <rulesets>
|
||||||
<ruleset>/rulesets/java/basic.xml</ruleset>
|
<ruleset>/rulesets/java/basic.xml</ruleset>
|
||||||
<ruleset>/rulesets/java/braces.xml</ruleset>
|
<ruleset>/rulesets/java/braces.xml</ruleset>
|
||||||
<ruleset>/rulesets/java/clone.xml</ruleset>
|
<ruleset>/rulesets/java/clone.xml</ruleset>
|
||||||
|
|
@ -284,18 +272,16 @@
|
||||||
<ruleset>/rulesets/java/typeresolution.xml</ruleset>
|
<ruleset>/rulesets/java/typeresolution.xml</ruleset>
|
||||||
<ruleset>/rulesets/java/unnecessary.xml</ruleset>
|
<ruleset>/rulesets/java/unnecessary.xml</ruleset>
|
||||||
<ruleset>/rulesets/java/unusedcode.xml</ruleset>
|
<ruleset>/rulesets/java/unusedcode.xml</ruleset>
|
||||||
</rulesets>
|
</rulesets>-->
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.codehaus.mojo</groupId>
|
<groupId>org.codehaus.mojo</groupId>
|
||||||
<artifactId>javancss-maven-plugin</artifactId>
|
<artifactId>javancss-maven-plugin</artifactId>
|
||||||
<version>2.1</version>
|
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-project-info-reports-plugin</artifactId>
|
<artifactId>maven-project-info-reports-plugin</artifactId>
|
||||||
<version>2.8</version>
|
|
||||||
<reportSets>
|
<reportSets>
|
||||||
<reportSet>
|
<reportSet>
|
||||||
<reports>
|
<reports>
|
||||||
|
|
|
||||||
|
|
@ -1,61 +0,0 @@
|
||||||
/*
|
|
||||||
* 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 com.arsdigita.cms.contenttypes.ui;
|
|
||||||
|
|
||||||
import com.arsdigita.bebop.FormData;
|
|
||||||
import com.arsdigita.bebop.PageState;
|
|
||||||
import com.arsdigita.bebop.parameters.StringParameter;
|
|
||||||
import com.arsdigita.cms.ItemSelectionModel;
|
|
||||||
import com.arsdigita.cms.ui.authoring.CreationSelector;
|
|
||||||
import com.arsdigita.cms.ui.authoring.PageCreateForm;
|
|
||||||
|
|
||||||
import org.librecms.contentsection.ContentItemInitializer;
|
|
||||||
import org.scientificcms.publications.Publication;
|
|
||||||
import org.scientificcms.publications.contenttypes.PublicationItem;
|
|
||||||
|
|
||||||
import java.util.Locale;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
|
||||||
* @param <P>
|
|
||||||
* @param <T>
|
|
||||||
*/
|
|
||||||
public abstract class AbstractPublicationCreateForm<P extends Publication, T extends PublicationItem<P>>
|
|
||||||
extends PageCreateForm {
|
|
||||||
|
|
||||||
public AbstractPublicationCreateForm(
|
|
||||||
final ItemSelectionModel itemModel,
|
|
||||||
final CreationSelector creationSelector,
|
|
||||||
final StringParameter selectedLanguageParam
|
|
||||||
) {
|
|
||||||
super(itemModel, creationSelector, selectedLanguageParam);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
protected ContentItemInitializer<?> getItemInitializer(
|
|
||||||
final FormData data, final PageState state) {
|
|
||||||
|
|
||||||
return item -> ((T) item).setPublication(
|
|
||||||
createPublication(data)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected P createPublication(final FormData data) {
|
|
||||||
|
|
||||||
final Locale locale = new Locale((String) data.get(LANGUAGE));
|
|
||||||
final String title = (String) data.get(TITLE);
|
|
||||||
|
|
||||||
final P publication = createPublication();
|
|
||||||
publication.getTitle().addValue(locale, title);
|
|
||||||
|
|
||||||
return publication;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected abstract P createPublication();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,102 +0,0 @@
|
||||||
/*
|
|
||||||
* 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 com.arsdigita.cms.contenttypes.ui;
|
|
||||||
|
|
||||||
import com.arsdigita.bebop.FormData;
|
|
||||||
import com.arsdigita.bebop.FormProcessException;
|
|
||||||
import com.arsdigita.bebop.PageState;
|
|
||||||
import com.arsdigita.bebop.event.FormInitListener;
|
|
||||||
import com.arsdigita.bebop.event.FormProcessListener;
|
|
||||||
import com.arsdigita.bebop.event.FormSectionEvent;
|
|
||||||
import com.arsdigita.bebop.parameters.StringParameter;
|
|
||||||
import com.arsdigita.cms.ItemSelectionModel;
|
|
||||||
import com.arsdigita.cms.ui.authoring.BasicItemForm;
|
|
||||||
import com.arsdigita.globalization.GlobalizedMessage;
|
|
||||||
|
|
||||||
import org.libreccm.cdi.utils.CdiUtil;
|
|
||||||
import org.scientificcms.publications.ArticleInCollectedVolume;
|
|
||||||
import org.scientificcms.publications.CollectedVolume;
|
|
||||||
import org.scientificcms.publications.SciPublicationsConstants;
|
|
||||||
import org.scientificcms.publications.contenttypes.ArticleInCollectedVolumeItem;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Form for adding an association between an ArticleInCollectedVolume and a
|
|
||||||
* CollectedVolume.
|
|
||||||
*
|
|
||||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
|
||||||
*/
|
|
||||||
public class ArticleInCollectedVolumeCollectedVolumeForm
|
|
||||||
extends BasicItemForm
|
|
||||||
implements FormProcessListener, FormInitListener {
|
|
||||||
|
|
||||||
private final static String COLLECTED_VOLUME_SEARCH
|
|
||||||
= "collectedVolumeSearch";
|
|
||||||
|
|
||||||
private PublicationSearchWidget collectedVolumeSearch;
|
|
||||||
|
|
||||||
public ArticleInCollectedVolumeCollectedVolumeForm(
|
|
||||||
final ItemSelectionModel itemSelectionModel,
|
|
||||||
final StringParameter selectedLanguageParam) {
|
|
||||||
|
|
||||||
super(
|
|
||||||
"ArticleInCollectedVolumeCollectedVolumeForm",
|
|
||||||
itemSelectionModel,
|
|
||||||
selectedLanguageParam
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void addWidgets() {
|
|
||||||
|
|
||||||
collectedVolumeSearch = new PublicationSearchWidget(
|
|
||||||
COLLECTED_VOLUME_SEARCH, CollectedVolume.class
|
|
||||||
);
|
|
||||||
|
|
||||||
collectedVolumeSearch.setLabel(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.articleInCollectedVolume.selectCollectedVolume",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
)
|
|
||||||
);
|
|
||||||
add(collectedVolumeSearch);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void init(final FormSectionEvent event) throws FormProcessException {
|
|
||||||
final PageState state = event.getPageState();
|
|
||||||
|
|
||||||
setVisible(state, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void process(final FormSectionEvent event)
|
|
||||||
throws FormProcessException {
|
|
||||||
|
|
||||||
final FormData data = event.getFormData();
|
|
||||||
final PageState state = event.getPageState();
|
|
||||||
|
|
||||||
final ArticleInCollectedVolumeItem articleItem
|
|
||||||
= (ArticleInCollectedVolumeItem) getItemSelectionModel()
|
|
||||||
.getSelectedObject(state);
|
|
||||||
final ArticleInCollectedVolume article = articleItem.getPublication();
|
|
||||||
|
|
||||||
if (this.getSaveCancelSection().getSaveButton().isSelected(state)) {
|
|
||||||
final CollectedVolume collectedVolume = (CollectedVolume) data.get(
|
|
||||||
COLLECTED_VOLUME_SEARCH
|
|
||||||
);
|
|
||||||
|
|
||||||
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
|
|
||||||
final ArticleInCollectedVolumeController controller = cdiUtil
|
|
||||||
.findBean(ArticleInCollectedVolumeController.class);
|
|
||||||
controller.setCollectedVolume(
|
|
||||||
article.getPublicationId(), collectedVolume.getPublicationId()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
init(event);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,305 +0,0 @@
|
||||||
/*
|
|
||||||
* 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 com.arsdigita.cms.contenttypes.ui;
|
|
||||||
|
|
||||||
import com.arsdigita.bebop.Component;
|
|
||||||
import com.arsdigita.bebop.ControlLink;
|
|
||||||
import com.arsdigita.bebop.FormProcessException;
|
|
||||||
import com.arsdigita.bebop.Label;
|
|
||||||
import com.arsdigita.bebop.PageState;
|
|
||||||
import com.arsdigita.bebop.Table;
|
|
||||||
import com.arsdigita.bebop.Text;
|
|
||||||
import com.arsdigita.bebop.event.TableActionEvent;
|
|
||||||
import com.arsdigita.bebop.event.TableActionListener;
|
|
||||||
import com.arsdigita.bebop.parameters.StringParameter;
|
|
||||||
import com.arsdigita.bebop.table.TableCellRenderer;
|
|
||||||
import com.arsdigita.bebop.table.TableColumn;
|
|
||||||
import com.arsdigita.bebop.table.TableColumnModel;
|
|
||||||
import com.arsdigita.bebop.table.TableModel;
|
|
||||||
import com.arsdigita.bebop.table.TableModelBuilder;
|
|
||||||
import com.arsdigita.cms.ItemSelectionModel;
|
|
||||||
import com.arsdigita.cms.ui.authoring.SelectedLanguageUtil;
|
|
||||||
import com.arsdigita.globalization.GlobalizedMessage;
|
|
||||||
import com.arsdigita.util.LockableImpl;
|
|
||||||
|
|
||||||
import org.libreccm.cdi.utils.CdiUtil;
|
|
||||||
import org.libreccm.security.PermissionChecker;
|
|
||||||
import org.librecms.contentsection.privileges.ItemPrivileges;
|
|
||||||
import org.scientificcms.publications.CollectedVolume;
|
|
||||||
import org.scientificcms.publications.SciPublicationsConstants;
|
|
||||||
import org.scientificcms.publications.contenttypes.ArticleInCollectedVolumeItem;
|
|
||||||
|
|
||||||
import java.util.Locale;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sheet which displays the collected volume to which an article in a collected
|
|
||||||
* volume is associated to.
|
|
||||||
*
|
|
||||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
|
||||||
*/
|
|
||||||
public class ArticleInCollectedVolumeCollectedVolumeSheet
|
|
||||||
extends Table
|
|
||||||
implements TableActionListener {
|
|
||||||
|
|
||||||
private final String TABLE_COL_EDIT = "table_col_edit";
|
|
||||||
|
|
||||||
private final String TABLE_COL_DEL = "table_col_del";
|
|
||||||
|
|
||||||
private ItemSelectionModel itemModel;
|
|
||||||
|
|
||||||
public ArticleInCollectedVolumeCollectedVolumeSheet(
|
|
||||||
final ItemSelectionModel itemModel,
|
|
||||||
final StringParameter selectedLangParam
|
|
||||||
) {
|
|
||||||
super();
|
|
||||||
this.itemModel = itemModel;
|
|
||||||
|
|
||||||
setEmptyView(
|
|
||||||
new Label(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.articleInCollectedVolume.collectedVolume.none",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
final TableColumnModel colModel = getColumnModel();
|
|
||||||
colModel.add(
|
|
||||||
new TableColumn(
|
|
||||||
0,
|
|
||||||
new Label(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.articleInCollectedVolume.collectedVolume",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
)
|
|
||||||
),
|
|
||||||
TABLE_COL_EDIT
|
|
||||||
)
|
|
||||||
);
|
|
||||||
colModel.add(
|
|
||||||
new TableColumn(
|
|
||||||
1,
|
|
||||||
new Label(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.articleInCollectedVolume.collectedVolume.remove",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
)
|
|
||||||
),
|
|
||||||
TABLE_COL_DEL
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
setModelBuilder(
|
|
||||||
new ArticleInCollectedVolumeCollectedVolumeSheetModelBuilder(
|
|
||||||
itemModel, selectedLangParam
|
|
||||||
)
|
|
||||||
);
|
|
||||||
colModel.get(0).setCellRenderer(new EditCellRenderer());
|
|
||||||
colModel.get(1).setCellRenderer(new DeleteCellRenderer());
|
|
||||||
|
|
||||||
addTableActionListener(this);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void cellSelected(final TableActionEvent event)
|
|
||||||
throws FormProcessException {
|
|
||||||
|
|
||||||
final PageState state = event.getPageState();
|
|
||||||
|
|
||||||
final ArticleInCollectedVolumeItem articleItem
|
|
||||||
= (ArticleInCollectedVolumeItem) itemModel
|
|
||||||
.getSelectedObject(state);
|
|
||||||
|
|
||||||
final TableColumn column = getColumnModel().get(event.getColumn());
|
|
||||||
|
|
||||||
if (column.getHeaderKey().toString().equals(TABLE_COL_EDIT)) {
|
|
||||||
// Nothing
|
|
||||||
} else if (column.getHeaderKey().toString().equals(TABLE_COL_DEL)) {
|
|
||||||
final ArticleInCollectedVolumeController controller = CdiUtil
|
|
||||||
.createCdiUtil()
|
|
||||||
.findBean(ArticleInCollectedVolumeController.class);
|
|
||||||
controller.unsetCollectedVolume(
|
|
||||||
articleItem.getPublication().getPublicationId()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void headSelected(TableActionEvent event) {
|
|
||||||
// Nothing
|
|
||||||
}
|
|
||||||
|
|
||||||
private class ArticleInCollectedVolumeCollectedVolumeSheetModelBuilder
|
|
||||||
extends LockableImpl
|
|
||||||
implements TableModelBuilder {
|
|
||||||
|
|
||||||
private final ItemSelectionModel itemModel;
|
|
||||||
private final StringParameter selectedLangParam;
|
|
||||||
|
|
||||||
public ArticleInCollectedVolumeCollectedVolumeSheetModelBuilder(
|
|
||||||
final ItemSelectionModel itemModel,
|
|
||||||
final StringParameter selectedLangParam
|
|
||||||
) {
|
|
||||||
this.itemModel = itemModel;
|
|
||||||
this.selectedLangParam = selectedLangParam;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public TableModel makeModel(final Table table, final PageState state) {
|
|
||||||
table.getRowSelectionModel().clearSelection(state);
|
|
||||||
final ArticleInCollectedVolumeItem article
|
|
||||||
= (ArticleInCollectedVolumeItem) itemModel
|
|
||||||
.getSelectedObject(state);
|
|
||||||
return new ArticleInCollectedVolumeCollectedVolumeSheetModel(
|
|
||||||
table, state, article, selectedLangParam
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private class ArticleInCollectedVolumeCollectedVolumeSheetModel
|
|
||||||
implements TableModel {
|
|
||||||
|
|
||||||
private final Table table;
|
|
||||||
|
|
||||||
private final String collectedVolumeTitle;
|
|
||||||
|
|
||||||
private final Long collectedVolumeId;
|
|
||||||
|
|
||||||
private boolean done;
|
|
||||||
|
|
||||||
public ArticleInCollectedVolumeCollectedVolumeSheetModel(
|
|
||||||
final Table table,
|
|
||||||
final PageState state,
|
|
||||||
final ArticleInCollectedVolumeItem articleItem,
|
|
||||||
final StringParameter selectedLangParam
|
|
||||||
) {
|
|
||||||
this.table = table;
|
|
||||||
final CollectedVolume collectedVolume = articleItem
|
|
||||||
.getPublication()
|
|
||||||
.getCollectedVolume();
|
|
||||||
if (collectedVolume == null) {
|
|
||||||
done = false;
|
|
||||||
collectedVolumeTitle = null;
|
|
||||||
collectedVolumeId = null;
|
|
||||||
} else {
|
|
||||||
done = true;
|
|
||||||
final Locale selectedLang = SelectedLanguageUtil.selectedLocale(
|
|
||||||
state, selectedLangParam
|
|
||||||
);
|
|
||||||
collectedVolumeTitle = collectedVolume.getTitle().getValue(
|
|
||||||
selectedLang
|
|
||||||
);
|
|
||||||
collectedVolumeId = collectedVolume.getPublicationId();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getColumnCount() {
|
|
||||||
return table.getColumnModel().size();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean nextRow() {
|
|
||||||
boolean ret;
|
|
||||||
|
|
||||||
if (done) {
|
|
||||||
ret = true;
|
|
||||||
done = false;
|
|
||||||
} else {
|
|
||||||
ret = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object getElementAt(final int columnIndex) {
|
|
||||||
switch (columnIndex) {
|
|
||||||
case 0:
|
|
||||||
return collectedVolumeTitle;
|
|
||||||
case 1:
|
|
||||||
return new Label(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.articleInCollectedVolume.collectedVolume.remove",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
)
|
|
||||||
);
|
|
||||||
default:
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object getKeyAt(int columnIndex) {
|
|
||||||
return collectedVolumeId;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private class EditCellRenderer
|
|
||||||
extends LockableImpl
|
|
||||||
implements TableCellRenderer {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Component getComponent(
|
|
||||||
final Table table,
|
|
||||||
final PageState state,
|
|
||||||
final Object value,
|
|
||||||
final boolean isSelected,
|
|
||||||
final Object key,
|
|
||||||
final int row,
|
|
||||||
final int column
|
|
||||||
) {
|
|
||||||
return new Text((String) value);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private class DeleteCellRenderer
|
|
||||||
extends LockableImpl
|
|
||||||
implements TableCellRenderer {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Component getComponent(
|
|
||||||
final Table table,
|
|
||||||
final PageState state,
|
|
||||||
final Object value,
|
|
||||||
final boolean isSelected,
|
|
||||||
final Object key,
|
|
||||||
final int row,
|
|
||||||
final int column
|
|
||||||
) {
|
|
||||||
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
|
|
||||||
final PermissionChecker permissionChecker = cdiUtil
|
|
||||||
.findBean(PermissionChecker.class);
|
|
||||||
final ArticleInCollectedVolumeItem articleItem
|
|
||||||
= (ArticleInCollectedVolumeItem) itemModel
|
|
||||||
.getSelectedObject(state);
|
|
||||||
final boolean canEdit = permissionChecker.isPermitted(
|
|
||||||
ItemPrivileges.EDIT, articleItem
|
|
||||||
);
|
|
||||||
|
|
||||||
if (canEdit) {
|
|
||||||
final ControlLink link = new ControlLink((Component) value);
|
|
||||||
link.setConfirmation(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.articleInCollectedVolume.collectedVolume."
|
|
||||||
+ "confirm_remove",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
)
|
|
||||||
);
|
|
||||||
return link;
|
|
||||||
} else {
|
|
||||||
return new Text("");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,75 +0,0 @@
|
||||||
/*
|
|
||||||
* 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 com.arsdigita.cms.contenttypes.ui;
|
|
||||||
|
|
||||||
import com.arsdigita.bebop.parameters.StringParameter;
|
|
||||||
import com.arsdigita.cms.ItemSelectionModel;
|
|
||||||
import com.arsdigita.cms.ui.authoring.AuthoringKitWizard;
|
|
||||||
import com.arsdigita.cms.ui.authoring.BasicItemForm;
|
|
||||||
import com.arsdigita.cms.ui.authoring.SimpleEditStep;
|
|
||||||
import com.arsdigita.cms.ui.workflow.WorkflowLockedComponentAccess;
|
|
||||||
import com.arsdigita.globalization.GlobalizedMessage;
|
|
||||||
|
|
||||||
import org.scientificcms.publications.SciPublicationsConstants;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* /**
|
|
||||||
* Step for adding a association between a ArticleInCollectedVolume and a
|
|
||||||
* CollectedVolume.
|
|
||||||
*
|
|
||||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
|
||||||
*/
|
|
||||||
public class ArticleInCollectedVolumeCollectedVolumeStep
|
|
||||||
extends SimpleEditStep {
|
|
||||||
|
|
||||||
private final static String ADD_COLLECTED_VOLUME_STEP = "addCollectedVolume";
|
|
||||||
|
|
||||||
public ArticleInCollectedVolumeCollectedVolumeStep(
|
|
||||||
final ItemSelectionModel itemModel,
|
|
||||||
final AuthoringKitWizard parent,
|
|
||||||
final StringParameter selectedLanguageParam
|
|
||||||
) {
|
|
||||||
this(itemModel, parent, selectedLanguageParam, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ArticleInCollectedVolumeCollectedVolumeStep(
|
|
||||||
final ItemSelectionModel itemSelectionModel,
|
|
||||||
final AuthoringKitWizard authoringKitWizard,
|
|
||||||
final StringParameter selectedLanguageParam,
|
|
||||||
final String parameterSuffix
|
|
||||||
) {
|
|
||||||
super(
|
|
||||||
itemSelectionModel,
|
|
||||||
authoringKitWizard,
|
|
||||||
selectedLanguageParam,
|
|
||||||
parameterSuffix
|
|
||||||
);
|
|
||||||
|
|
||||||
final BasicItemForm addCollectedVolumeForm
|
|
||||||
= new ArticleInCollectedVolumeCollectedVolumeForm(
|
|
||||||
itemSelectionModel,
|
|
||||||
selectedLanguageParam
|
|
||||||
);
|
|
||||||
|
|
||||||
add(
|
|
||||||
ADD_COLLECTED_VOLUME_STEP,
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.collectedVolume.addCollectedVolume",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
),
|
|
||||||
new WorkflowLockedComponentAccess(
|
|
||||||
addCollectedVolumeForm, itemSelectionModel
|
|
||||||
),
|
|
||||||
addCollectedVolumeForm.getSaveCancelSection().getCancelButton()
|
|
||||||
);
|
|
||||||
|
|
||||||
final ArticleInCollectedVolumeCollectedVolumeSheet sheet
|
|
||||||
= new ArticleInCollectedVolumeCollectedVolumeSheet(
|
|
||||||
itemSelectionModel, selectedLanguageParam);
|
|
||||||
setDisplayComponent(sheet);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,139 +0,0 @@
|
||||||
/*
|
|
||||||
* 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 com.arsdigita.cms.contenttypes.ui;
|
|
||||||
|
|
||||||
import org.scientificcms.publications.ArticleInCollectedVolume;
|
|
||||||
import org.scientificcms.publications.ArticleInCollectedVolumeManager;
|
|
||||||
import org.scientificcms.publications.CollectedVolume;
|
|
||||||
import org.scientificcms.publications.PublicationRepository;
|
|
||||||
|
|
||||||
import java.util.Locale;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import javax.enterprise.context.RequestScoped;
|
|
||||||
import javax.inject.Inject;
|
|
||||||
import javax.transaction.Transactional;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
|
||||||
*/
|
|
||||||
@RequestScoped
|
|
||||||
public class ArticleInCollectedVolumeController {
|
|
||||||
|
|
||||||
public static final String START_PAGE = "startPage";
|
|
||||||
|
|
||||||
public static final String END_PAGE = "endPage";
|
|
||||||
|
|
||||||
public static final String CHAPTER = "chapter";
|
|
||||||
|
|
||||||
public static final String PEER_REVIEWED = "peerReviewed";
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
private ArticleInCollectedVolumeManager articleManager;
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
private PublicationRepository publicationRepository;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Save a changed {@link ArticleInCollectedVolume}.
|
|
||||||
*
|
|
||||||
* @param articleId The ID of the article.
|
|
||||||
* @param selectedLocale The locale selected in the UI.
|
|
||||||
* @param data The data to set on the article.
|
|
||||||
*/
|
|
||||||
@Transactional(Transactional.TxType.REQUIRED)
|
|
||||||
public void saveArticle(
|
|
||||||
final long articleId,
|
|
||||||
final Locale selectedLocale,
|
|
||||||
final Map<String, Object> data
|
|
||||||
) {
|
|
||||||
final ArticleInCollectedVolume article = publicationRepository
|
|
||||||
.findByIdAndType(articleId, ArticleInCollectedVolume.class)
|
|
||||||
.orElseThrow(
|
|
||||||
() -> new IllegalArgumentException(
|
|
||||||
String.format(
|
|
||||||
"No ArticleInCollectedVolume with ID %d found.",
|
|
||||||
articleId
|
|
||||||
)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
if (data.get(START_PAGE) != null) {
|
|
||||||
final Integer startPage = (Integer) data.get(START_PAGE);
|
|
||||||
article.setStartPage(startPage);
|
|
||||||
}
|
|
||||||
if (data.get(END_PAGE) != null) {
|
|
||||||
final Integer endPage = (Integer) data.get(END_PAGE);
|
|
||||||
article.setEndPage(endPage);
|
|
||||||
}
|
|
||||||
if (data.get(CHAPTER) != null) {
|
|
||||||
final String chapter = (String) data.get(CHAPTER);
|
|
||||||
article.setChapter(chapter);
|
|
||||||
}
|
|
||||||
if (data.get(PEER_REVIEWED) != null) {
|
|
||||||
final Boolean peerReviewed = (Boolean) data.get(PEER_REVIEWED);
|
|
||||||
article.setPeerReviewed(peerReviewed);
|
|
||||||
}
|
|
||||||
|
|
||||||
publicationRepository.save(article);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the value of the {@link ArticleInCollectedVolume#collectedVolume}
|
|
||||||
* property to a {@link CollectedVolume}.
|
|
||||||
*
|
|
||||||
* @param articleId The ID of the article to use.
|
|
||||||
* @param collectedVolumeId The ID of the collected volume to use.
|
|
||||||
*/
|
|
||||||
@Transactional(Transactional.TxType.REQUIRED)
|
|
||||||
public void setCollectedVolume(
|
|
||||||
final long articleId, final long collectedVolumeId
|
|
||||||
) {
|
|
||||||
final ArticleInCollectedVolume article = publicationRepository
|
|
||||||
.findByIdAndType(articleId, ArticleInCollectedVolume.class)
|
|
||||||
.orElseThrow(
|
|
||||||
() -> new IllegalArgumentException(
|
|
||||||
String.format(
|
|
||||||
"No ArticleInCollectedVolume with ID %d found",
|
|
||||||
articleId
|
|
||||||
)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
final CollectedVolume collectedVolume = publicationRepository
|
|
||||||
.findByIdAndType(collectedVolumeId, CollectedVolume.class)
|
|
||||||
.orElseThrow(
|
|
||||||
() -> new IllegalArgumentException(
|
|
||||||
String.format(
|
|
||||||
"No CollectedVolume with ID %d found.",
|
|
||||||
collectedVolumeId
|
|
||||||
)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
articleManager.setCollectedVolume(article, collectedVolume);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Transactional(Transactional.TxType.REQUIRED)
|
|
||||||
public void unsetCollectedVolume(
|
|
||||||
final long articleId
|
|
||||||
) {
|
|
||||||
final ArticleInCollectedVolume article = publicationRepository
|
|
||||||
.findByIdAndType(articleId, ArticleInCollectedVolume.class)
|
|
||||||
.orElseThrow(
|
|
||||||
() -> new IllegalArgumentException(
|
|
||||||
String.format(
|
|
||||||
"No ArticleInCollectedVolume with ID %d found",
|
|
||||||
articleId
|
|
||||||
)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
articleManager.unsetCollectedVolume(article);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,35 +0,0 @@
|
||||||
/*
|
|
||||||
* 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 com.arsdigita.cms.contenttypes.ui;
|
|
||||||
|
|
||||||
import com.arsdigita.bebop.parameters.StringParameter;
|
|
||||||
import com.arsdigita.cms.ItemSelectionModel;
|
|
||||||
import com.arsdigita.cms.ui.authoring.CreationSelector;
|
|
||||||
|
|
||||||
import org.scientificcms.publications.ArticleInCollectedVolume;
|
|
||||||
import org.scientificcms.publications.contenttypes.ArticleInCollectedVolumeItem;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
|
||||||
*/
|
|
||||||
public class ArticleInCollectedVolumeCreateForm
|
|
||||||
extends AbstractPublicationCreateForm<ArticleInCollectedVolume, ArticleInCollectedVolumeItem> {
|
|
||||||
|
|
||||||
public ArticleInCollectedVolumeCreateForm(
|
|
||||||
final ItemSelectionModel itemModel,
|
|
||||||
final CreationSelector creationSelector,
|
|
||||||
final StringParameter selectedLanguageParam
|
|
||||||
) {
|
|
||||||
super(itemModel, creationSelector, selectedLanguageParam);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected ArticleInCollectedVolume createPublication() {
|
|
||||||
return new ArticleInCollectedVolume();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,169 +0,0 @@
|
||||||
package com.arsdigita.cms.contenttypes.ui;
|
|
||||||
|
|
||||||
import com.arsdigita.bebop.Component;
|
|
||||||
import com.arsdigita.bebop.Label;
|
|
||||||
import com.arsdigita.bebop.PageState;
|
|
||||||
import com.arsdigita.bebop.parameters.StringParameter;
|
|
||||||
import com.arsdigita.cms.ItemSelectionModel;
|
|
||||||
import com.arsdigita.cms.ui.authoring.AuthoringKitWizard;
|
|
||||||
import com.arsdigita.cms.ui.authoring.BasicPageForm;
|
|
||||||
import com.arsdigita.cms.ui.authoring.SimpleEditStep;
|
|
||||||
import com.arsdigita.cms.ui.workflow.WorkflowLockedComponentAccess;
|
|
||||||
import com.arsdigita.domain.DomainService;
|
|
||||||
import com.arsdigita.globalization.GlobalizedMessage;
|
|
||||||
import com.arsdigita.toolbox.ui.DomainObjectPropertySheet;
|
|
||||||
|
|
||||||
import org.scientificcms.publications.SciPublicationsConstants;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
|
||||||
*/
|
|
||||||
public class ArticleInCollectedVolumePropertiesStep
|
|
||||||
extends PublicationPropertiesStep {
|
|
||||||
|
|
||||||
private final StringParameter selectedLangParameter;
|
|
||||||
|
|
||||||
public ArticleInCollectedVolumePropertiesStep(
|
|
||||||
final ItemSelectionModel itemModel,
|
|
||||||
final AuthoringKitWizard parent,
|
|
||||||
final StringParameter selectedLangParameter
|
|
||||||
) {
|
|
||||||
super(itemModel, parent, selectedLangParameter);
|
|
||||||
this.selectedLangParameter = selectedLangParameter;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Component getArticleInCollectedVolumePropertySheet(
|
|
||||||
final ItemSelectionModel itemModel,
|
|
||||||
final StringParameter selectedLanguageParam
|
|
||||||
) {
|
|
||||||
|
|
||||||
final DomainObjectPropertySheet sheet
|
|
||||||
= (DomainObjectPropertySheet) PublicationPropertiesStep
|
|
||||||
.getPublicationPropertySheet(itemModel, selectedLanguageParam);
|
|
||||||
|
|
||||||
sheet.add(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.article_in_collected_volume.pages_from",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
),
|
|
||||||
ArticleInCollectedVolumeController.START_PAGE
|
|
||||||
);
|
|
||||||
|
|
||||||
sheet.add(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.article_in_collected_volume.pages_to",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
),
|
|
||||||
ArticleInCollectedVolumeController.END_PAGE
|
|
||||||
);
|
|
||||||
|
|
||||||
sheet.add(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.article_in_collected_volume.chapter",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
),
|
|
||||||
ArticleInCollectedVolumeController.CHAPTER
|
|
||||||
);
|
|
||||||
|
|
||||||
sheet.add(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.articleInCollectedVolume.reviewed",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
),
|
|
||||||
ArticleInCollectedVolumeController.PEER_REVIEWED,
|
|
||||||
new ReviewedFormatter()
|
|
||||||
);
|
|
||||||
|
|
||||||
return sheet;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void addBasicProperties(
|
|
||||||
final ItemSelectionModel itemModel, final AuthoringKitWizard parent
|
|
||||||
) {
|
|
||||||
final SimpleEditStep basicProperties = new SimpleEditStep(
|
|
||||||
itemModel, parent, selectedLangParameter, EDIT_SHEET_NAME
|
|
||||||
);
|
|
||||||
|
|
||||||
final BasicPageForm editBasicSheet
|
|
||||||
= new ArticleInCollectedVolumePropertyForm(
|
|
||||||
itemModel, this, selectedLangParameter
|
|
||||||
);
|
|
||||||
|
|
||||||
basicProperties.add(
|
|
||||||
EDIT_SHEET_NAME,
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.article_in_collected_volume.edit_basic_sheet",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
),
|
|
||||||
new WorkflowLockedComponentAccess(editBasicSheet, itemModel),
|
|
||||||
editBasicSheet.getSaveCancelSection().getCancelButton()
|
|
||||||
);
|
|
||||||
|
|
||||||
basicProperties.setDisplayComponent(
|
|
||||||
getArticleInCollectedVolumePropertySheet(
|
|
||||||
itemModel, selectedLangParameter
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
getSegmentedPanel().addSegment(
|
|
||||||
new Label(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.publication.basic_properties",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
)
|
|
||||||
),
|
|
||||||
basicProperties
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void addSteps(
|
|
||||||
final ItemSelectionModel itemModel, final AuthoringKitWizard parent
|
|
||||||
) {
|
|
||||||
super.addSteps(itemModel, parent);
|
|
||||||
|
|
||||||
addStep(
|
|
||||||
new ArticleInCollectedVolumeCollectedVolumeStep(
|
|
||||||
itemModel, parent, selectedLangParameter
|
|
||||||
),
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.articleInCollectedVolume.collectedVolume",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class ReviewedFormatter
|
|
||||||
extends DomainService
|
|
||||||
implements DomainObjectPropertySheet.AttributeFormatter {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String format(
|
|
||||||
final Object obj, final String attribute, final PageState state
|
|
||||||
) {
|
|
||||||
final GlobalizedMessage msg;
|
|
||||||
if ((get(obj, attribute) instanceof Boolean)
|
|
||||||
&& ((Boolean) get(obj, attribute) == true)) {
|
|
||||||
msg = new GlobalizedMessage(
|
|
||||||
"publications.ui.articleInCollectedVolume.reviewed.yes",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
msg = new GlobalizedMessage(
|
|
||||||
"publications.ui.articleInCollectedVolume.reviewed.no",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return (String) msg.localize();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected boolean isSeriesStepEnabled() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,221 +0,0 @@
|
||||||
/*
|
|
||||||
* 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 com.arsdigita.cms.contenttypes.ui;
|
|
||||||
|
|
||||||
import com.arsdigita.bebop.FormData;
|
|
||||||
import com.arsdigita.bebop.FormProcessException;
|
|
||||||
import com.arsdigita.bebop.Label;
|
|
||||||
import com.arsdigita.bebop.PageState;
|
|
||||||
import com.arsdigita.bebop.event.FormInitListener;
|
|
||||||
import com.arsdigita.bebop.event.FormProcessListener;
|
|
||||||
import com.arsdigita.bebop.event.FormSectionEvent;
|
|
||||||
import com.arsdigita.bebop.event.FormSubmissionListener;
|
|
||||||
import com.arsdigita.bebop.form.CheckboxGroup;
|
|
||||||
import com.arsdigita.bebop.form.Option;
|
|
||||||
import com.arsdigita.bebop.form.TextField;
|
|
||||||
import com.arsdigita.bebop.parameters.IntegerParameter;
|
|
||||||
import com.arsdigita.bebop.parameters.ParameterModel;
|
|
||||||
import com.arsdigita.bebop.parameters.StringParameter;
|
|
||||||
import com.arsdigita.cms.ItemSelectionModel;
|
|
||||||
import com.arsdigita.cms.ui.authoring.SelectedLanguageUtil;
|
|
||||||
import com.arsdigita.globalization.GlobalizedMessage;
|
|
||||||
|
|
||||||
import org.libreccm.cdi.utils.CdiUtil;
|
|
||||||
import org.scientificcms.publications.ArticleInCollectedVolume;
|
|
||||||
import org.scientificcms.publications.SciPublicationsConstants;
|
|
||||||
import org.scientificcms.publications.contenttypes.ArticleInCollectedVolumeItem;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Locale;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
|
||||||
*/
|
|
||||||
public class ArticleInCollectedVolumePropertyForm
|
|
||||||
extends PublicationPropertyForm
|
|
||||||
implements FormProcessListener, FormInitListener, FormSubmissionListener {
|
|
||||||
|
|
||||||
public static final String ID = "ArticleInCollectedVolumeEdit";
|
|
||||||
|
|
||||||
private static final String REVIEWED = "reviewed";
|
|
||||||
|
|
||||||
private final ArticleInCollectedVolumePropertiesStep propertiesStep;
|
|
||||||
|
|
||||||
private final StringParameter selectedLangParam;
|
|
||||||
|
|
||||||
private CheckboxGroup reviewed;
|
|
||||||
|
|
||||||
public ArticleInCollectedVolumePropertyForm(
|
|
||||||
final ItemSelectionModel itemModel,
|
|
||||||
final StringParameter selectedLangParam
|
|
||||||
) {
|
|
||||||
this(itemModel, null, selectedLangParam);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ArticleInCollectedVolumePropertyForm(
|
|
||||||
final ItemSelectionModel itemModel,
|
|
||||||
final ArticleInCollectedVolumePropertiesStep step,
|
|
||||||
final StringParameter selectedLangParam
|
|
||||||
) {
|
|
||||||
super(itemModel, step, selectedLangParam);
|
|
||||||
propertiesStep = step;
|
|
||||||
this.selectedLangParam = selectedLangParam;
|
|
||||||
addSubmissionListener(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void addWidgets() {
|
|
||||||
|
|
||||||
super.addWidgets();
|
|
||||||
|
|
||||||
final ParameterModel startPageParam = new IntegerParameter(
|
|
||||||
ArticleInCollectedVolumeController.START_PAGE);
|
|
||||||
final TextField startPage = new TextField(startPageParam);
|
|
||||||
startPage.setLabel(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.article_in_collected_volume.pages_from",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
)
|
|
||||||
);
|
|
||||||
add(startPage);
|
|
||||||
|
|
||||||
ParameterModel endPageParam = new IntegerParameter(
|
|
||||||
ArticleInCollectedVolumeController.END_PAGE
|
|
||||||
);
|
|
||||||
final TextField endPage = new TextField(endPageParam);
|
|
||||||
endPage.setLabel(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.article_in_collected_volume.pages_to",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
)
|
|
||||||
);
|
|
||||||
add(endPage);
|
|
||||||
|
|
||||||
ParameterModel chapterParam = new StringParameter(
|
|
||||||
ArticleInCollectedVolumeController.CHAPTER
|
|
||||||
);
|
|
||||||
final TextField chapter = new TextField(chapterParam);
|
|
||||||
chapter.setLabel(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.article_in_collected_volume.chapter",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
)
|
|
||||||
);
|
|
||||||
add(chapter);
|
|
||||||
|
|
||||||
reviewed = new CheckboxGroup("reviewedGroup");
|
|
||||||
reviewed.addOption(
|
|
||||||
new Option(
|
|
||||||
REVIEWED,
|
|
||||||
new Label(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.articleInCollectedVolume.reviewed",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
reviewed.setLabel(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.articleInCollectedVolume.reviewed",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
)
|
|
||||||
);
|
|
||||||
add(reviewed);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void init(final FormSectionEvent event) throws FormProcessException {
|
|
||||||
|
|
||||||
super.init(event);
|
|
||||||
|
|
||||||
final FormData data = event.getFormData();
|
|
||||||
final ArticleInCollectedVolumeItem articleItem
|
|
||||||
= (ArticleInCollectedVolumeItem) initBasicWidgets(
|
|
||||||
event);
|
|
||||||
|
|
||||||
final ArticleInCollectedVolume article = articleItem.getPublication();
|
|
||||||
|
|
||||||
data.put(
|
|
||||||
ArticleInCollectedVolumeController.START_PAGE,
|
|
||||||
article.getStartPage()
|
|
||||||
);
|
|
||||||
data.put(
|
|
||||||
ArticleInCollectedVolumeController.END_PAGE,
|
|
||||||
article.getEndPage()
|
|
||||||
);
|
|
||||||
data.put(
|
|
||||||
ArticleInCollectedVolumeController.CHAPTER, article.getChapter()
|
|
||||||
);
|
|
||||||
|
|
||||||
if ((article.getPeerReviewed() != null)
|
|
||||||
&& (article.getPeerReviewed())) {
|
|
||||||
reviewed.setValue(event.getPageState(), new String[]{REVIEWED});
|
|
||||||
} else {
|
|
||||||
reviewed.setValue(event.getPageState(), null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void process(final FormSectionEvent event)
|
|
||||||
throws FormProcessException {
|
|
||||||
|
|
||||||
super.process(event);
|
|
||||||
|
|
||||||
final FormData formData = event.getFormData();
|
|
||||||
final PageState state = event.getPageState();
|
|
||||||
final ArticleInCollectedVolumeItem articleItem
|
|
||||||
= (ArticleInCollectedVolumeItem) processBasicWidgets(
|
|
||||||
event);
|
|
||||||
|
|
||||||
if (articleItem != null
|
|
||||||
&& getSaveCancelSection().getSaveButton().isSelected(state)) {
|
|
||||||
|
|
||||||
final Map<String, Object> data = new HashMap<>();
|
|
||||||
|
|
||||||
data.put(
|
|
||||||
ArticleInCollectedVolumeController.START_PAGE,
|
|
||||||
formData.get(ArticleInCollectedVolumeController.START_PAGE)
|
|
||||||
);
|
|
||||||
data.put(
|
|
||||||
ArticleInCollectedVolumeController.END_PAGE,
|
|
||||||
formData.get(ArticleInCollectedVolumeController.END_PAGE)
|
|
||||||
);
|
|
||||||
data.put(
|
|
||||||
ArticleInCollectedVolumeController.CHAPTER,
|
|
||||||
formData.get(ArticleInCollectedVolumeController.CHAPTER)
|
|
||||||
);
|
|
||||||
|
|
||||||
if (reviewed.getValue(event.getPageState()) == null) {
|
|
||||||
data.put(
|
|
||||||
ArticleInCollectedVolumeController.PEER_REVIEWED,
|
|
||||||
Boolean.FALSE
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
data.put(
|
|
||||||
ArticleInCollectedVolumeController.PEER_REVIEWED,
|
|
||||||
Boolean.TRUE
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
final Locale selectedLocale = SelectedLanguageUtil.selectedLocale(
|
|
||||||
state, selectedLangParam
|
|
||||||
);
|
|
||||||
|
|
||||||
final ArticleInCollectedVolumeController controller = CdiUtil
|
|
||||||
.createCdiUtil()
|
|
||||||
.findBean(ArticleInCollectedVolumeController.class);
|
|
||||||
controller.saveArticle(
|
|
||||||
articleItem.getPublication().getPublicationId(),
|
|
||||||
selectedLocale,
|
|
||||||
data
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,156 +0,0 @@
|
||||||
/*
|
|
||||||
* 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 com.arsdigita.cms.contenttypes.ui;
|
|
||||||
|
|
||||||
import org.scientificcms.publications.ArticleInJournal;
|
|
||||||
import org.scientificcms.publications.ArticleInJournalManager;
|
|
||||||
import org.scientificcms.publications.Journal;
|
|
||||||
import org.scientificcms.publications.JournalRepository;
|
|
||||||
import org.scientificcms.publications.PublicationRepository;
|
|
||||||
|
|
||||||
import java.time.LocalDate;
|
|
||||||
import java.util.Locale;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import javax.enterprise.context.RequestScoped;
|
|
||||||
import javax.inject.Inject;
|
|
||||||
import javax.transaction.Transactional;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
|
||||||
*/
|
|
||||||
@RequestScoped
|
|
||||||
public class ArticleInJournalController {
|
|
||||||
|
|
||||||
public static final String VOLUME = "volume";
|
|
||||||
|
|
||||||
public static final String ISSUE = "issue";
|
|
||||||
|
|
||||||
public static final String START_PAGE = "startPage";
|
|
||||||
|
|
||||||
public static final String END_PAGE = "endPage";
|
|
||||||
|
|
||||||
public static final String PUBLICATION_DATE = "publicationDate";
|
|
||||||
|
|
||||||
public static final String PEER_REVIEWED = "reviewed";
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
private ArticleInJournalManager articleManager;
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
private JournalRepository journalRepository;
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
private PublicationRepository publicationRepository;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Save a changed {@link ArticleInJournal}.
|
|
||||||
*
|
|
||||||
* @param articleId The ID of the article.
|
|
||||||
* @param selectedLocale The locale selected in the UI.
|
|
||||||
* @param data The data to set on the article.
|
|
||||||
*/
|
|
||||||
@Transactional(Transactional.TxType.REQUIRED)
|
|
||||||
public void saveArticle(
|
|
||||||
final long articleId,
|
|
||||||
final Locale selectedLocale,
|
|
||||||
final Map<String, Object> data
|
|
||||||
) {
|
|
||||||
final ArticleInJournal article = publicationRepository
|
|
||||||
.findByIdAndType(articleId, ArticleInJournal.class)
|
|
||||||
.orElseThrow(
|
|
||||||
() -> new IllegalArgumentException(
|
|
||||||
String.format(
|
|
||||||
"No ArticleInJournal with ID %d found.",
|
|
||||||
articleId
|
|
||||||
)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
if (data.get(VOLUME) != null) {
|
|
||||||
final Integer volume = (Integer) data.get(VOLUME);
|
|
||||||
article.setVolume(volume);
|
|
||||||
}
|
|
||||||
if (data.get(ISSUE) != null) {
|
|
||||||
final String issue = (String) data.get(ISSUE);
|
|
||||||
article.setIssue(issue);
|
|
||||||
}
|
|
||||||
if (data.get(START_PAGE) != null) {
|
|
||||||
final Integer startPage = (Integer) data.get(START_PAGE);
|
|
||||||
article.setStartPage(startPage);
|
|
||||||
}
|
|
||||||
if (data.get(END_PAGE) != null) {
|
|
||||||
final Integer endPage = (Integer) data.get(END_PAGE);
|
|
||||||
article.setStartPage(endPage);
|
|
||||||
}
|
|
||||||
if (data.get(PUBLICATION_DATE) != null) {
|
|
||||||
final LocalDate publicationDate = (LocalDate) data.get(
|
|
||||||
PUBLICATION_DATE
|
|
||||||
);
|
|
||||||
article.setPublicationDate(publicationDate);
|
|
||||||
}
|
|
||||||
if (data.get(PEER_REVIEWED) != null) {
|
|
||||||
final Boolean peerReviewed = (Boolean) data.get(PEER_REVIEWED);
|
|
||||||
article.setPeerReviewed(peerReviewed);
|
|
||||||
}
|
|
||||||
|
|
||||||
publicationRepository.save(article);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the value of the {@link ArticleInJournal#journal} property to a
|
|
||||||
* {@link Journal}.
|
|
||||||
*
|
|
||||||
* @param articleId The ID of the article to use.
|
|
||||||
* @param journalId The ID of the journal to use.
|
|
||||||
*/
|
|
||||||
@Transactional(Transactional.TxType.REQUIRED)
|
|
||||||
public void setJournal(
|
|
||||||
final long articleId, final long journalId
|
|
||||||
) {
|
|
||||||
final ArticleInJournal article = publicationRepository
|
|
||||||
.findByIdAndType(articleId, ArticleInJournal.class)
|
|
||||||
.orElseThrow(
|
|
||||||
() -> new IllegalArgumentException(
|
|
||||||
String.format(
|
|
||||||
"No ArticleInJournal with ID %d found.",
|
|
||||||
articleId
|
|
||||||
)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
final Journal journal = journalRepository
|
|
||||||
.findById(journalId)
|
|
||||||
.orElseThrow(
|
|
||||||
() -> new IllegalArgumentException(
|
|
||||||
String.format(
|
|
||||||
"No Journal with ID %d found",
|
|
||||||
journalId
|
|
||||||
)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
articleManager.setJournal(article, journal);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Transactional(Transactional.TxType.REQUIRED)
|
|
||||||
public void unsetJournal(
|
|
||||||
final long articleId) {
|
|
||||||
final ArticleInJournal article = publicationRepository
|
|
||||||
.findByIdAndType(articleId, ArticleInJournal.class)
|
|
||||||
.orElseThrow(
|
|
||||||
() -> new IllegalArgumentException(
|
|
||||||
String.format(
|
|
||||||
"No ArticleInJournal with ID %d found.",
|
|
||||||
articleId
|
|
||||||
)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
articleManager.unsetJournal(article);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,35 +0,0 @@
|
||||||
/*
|
|
||||||
* 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 com.arsdigita.cms.contenttypes.ui;
|
|
||||||
|
|
||||||
import com.arsdigita.bebop.parameters.StringParameter;
|
|
||||||
import com.arsdigita.cms.ItemSelectionModel;
|
|
||||||
import com.arsdigita.cms.ui.authoring.CreationSelector;
|
|
||||||
|
|
||||||
import org.scientificcms.publications.ArticleInJournal;
|
|
||||||
import org.scientificcms.publications.contenttypes.ArticleInJournalItem;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
|
||||||
*/
|
|
||||||
public class ArticleInJournalCreateForm
|
|
||||||
extends AbstractPublicationCreateForm<ArticleInJournal, ArticleInJournalItem> {
|
|
||||||
|
|
||||||
public ArticleInJournalCreateForm(
|
|
||||||
final ItemSelectionModel itemModel,
|
|
||||||
final CreationSelector creationSelector,
|
|
||||||
final StringParameter selectedLanguageParam
|
|
||||||
) {
|
|
||||||
super(itemModel, creationSelector, selectedLanguageParam);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected ArticleInJournal createPublication() {
|
|
||||||
return new ArticleInJournal();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,93 +0,0 @@
|
||||||
/*
|
|
||||||
* 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 com.arsdigita.cms.contenttypes.ui;
|
|
||||||
|
|
||||||
import com.arsdigita.bebop.FormData;
|
|
||||||
import com.arsdigita.bebop.FormProcessException;
|
|
||||||
import com.arsdigita.bebop.PageState;
|
|
||||||
import com.arsdigita.bebop.event.FormInitListener;
|
|
||||||
import com.arsdigita.bebop.event.FormProcessListener;
|
|
||||||
import com.arsdigita.bebop.event.FormSectionEvent;
|
|
||||||
import com.arsdigita.bebop.parameters.StringParameter;
|
|
||||||
import com.arsdigita.cms.ItemSelectionModel;
|
|
||||||
import com.arsdigita.cms.ui.authoring.BasicItemForm;
|
|
||||||
import com.arsdigita.globalization.GlobalizedMessage;
|
|
||||||
|
|
||||||
import org.libreccm.cdi.utils.CdiUtil;
|
|
||||||
import org.scientificcms.publications.ArticleInJournal;
|
|
||||||
import org.scientificcms.publications.Journal;
|
|
||||||
import org.scientificcms.publications.SciPublicationsConstants;
|
|
||||||
import org.scientificcms.publications.contenttypes.ArticleInJournalItem;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
|
||||||
*/
|
|
||||||
public class ArticleInJournalJournalForm
|
|
||||||
extends BasicItemForm
|
|
||||||
implements FormProcessListener, FormInitListener {
|
|
||||||
|
|
||||||
private JournalSearchWidget journalSearch;
|
|
||||||
private final String JOURNAL_SEARCH = "journal";
|
|
||||||
//private final static PublicationsConfig config = new PublicationsConfig();
|
|
||||||
|
|
||||||
public ArticleInJournalJournalForm(
|
|
||||||
final ItemSelectionModel itemSelectionModel,
|
|
||||||
final StringParameter selectedLanguageParam
|
|
||||||
) {
|
|
||||||
|
|
||||||
super(
|
|
||||||
"ArticleInJournalJournal",
|
|
||||||
itemSelectionModel,
|
|
||||||
selectedLanguageParam
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void addWidgets() {
|
|
||||||
|
|
||||||
journalSearch = new JournalSearchWidget(JOURNAL_SEARCH);
|
|
||||||
journalSearch.setLabel(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.articleInJournal.selectJournal",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
)
|
|
||||||
);
|
|
||||||
add(journalSearch);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void init(final FormSectionEvent event) throws FormProcessException {
|
|
||||||
final PageState state = event.getPageState();
|
|
||||||
|
|
||||||
setVisible(state, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void process(final FormSectionEvent event)
|
|
||||||
throws FormProcessException {
|
|
||||||
final FormData data = event.getFormData();
|
|
||||||
final PageState state = event.getPageState();
|
|
||||||
|
|
||||||
final ArticleInJournalItem articleItem = (ArticleInJournalItem) getItemSelectionModel().
|
|
||||||
getSelectedObject(state);
|
|
||||||
final ArticleInJournal article = articleItem.getPublication();
|
|
||||||
|
|
||||||
if (this.getSaveCancelSection().getSaveButton().isSelected(state)) {
|
|
||||||
final Journal journal = (Journal) data.get(JOURNAL_SEARCH);
|
|
||||||
|
|
||||||
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
|
|
||||||
final ArticleInJournalController controller = cdiUtil
|
|
||||||
.findBean(ArticleInJournalController.class);
|
|
||||||
controller.setJournal(
|
|
||||||
article.getPublicationId(), journal.getJournalId()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
init(event);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,284 +0,0 @@
|
||||||
/*
|
|
||||||
* 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 com.arsdigita.cms.contenttypes.ui;
|
|
||||||
|
|
||||||
import com.arsdigita.bebop.Component;
|
|
||||||
import com.arsdigita.bebop.ControlLink;
|
|
||||||
import com.arsdigita.bebop.Label;
|
|
||||||
import com.arsdigita.bebop.PageState;
|
|
||||||
import com.arsdigita.bebop.Table;
|
|
||||||
import com.arsdigita.bebop.Text;
|
|
||||||
import com.arsdigita.bebop.event.TableActionEvent;
|
|
||||||
import com.arsdigita.bebop.event.TableActionListener;
|
|
||||||
import com.arsdigita.bebop.parameters.StringParameter;
|
|
||||||
import com.arsdigita.bebop.table.TableCellRenderer;
|
|
||||||
import com.arsdigita.bebop.table.TableColumn;
|
|
||||||
import com.arsdigita.bebop.table.TableColumnModel;
|
|
||||||
import com.arsdigita.bebop.table.TableModel;
|
|
||||||
import com.arsdigita.bebop.table.TableModelBuilder;
|
|
||||||
import com.arsdigita.cms.ItemSelectionModel;
|
|
||||||
import com.arsdigita.globalization.GlobalizedMessage;
|
|
||||||
import com.arsdigita.util.LockableImpl;
|
|
||||||
|
|
||||||
import org.libreccm.cdi.utils.CdiUtil;
|
|
||||||
import org.libreccm.security.PermissionChecker;
|
|
||||||
import org.librecms.contentsection.privileges.ItemPrivileges;
|
|
||||||
import org.scientificcms.publications.Journal;
|
|
||||||
import org.scientificcms.publications.SciPublicationsConstants;
|
|
||||||
import org.scientificcms.publications.contenttypes.ArticleInJournalItem;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
|
||||||
*/
|
|
||||||
public class ArticleInJournalJournalSheet
|
|
||||||
extends Table
|
|
||||||
implements TableActionListener {
|
|
||||||
|
|
||||||
private final String TABLE_COL_EDIT = "table_col_edit";
|
|
||||||
|
|
||||||
private final String TABLE_COL_DEL = "table_col_del";
|
|
||||||
|
|
||||||
private ItemSelectionModel itemSelectionModel;
|
|
||||||
|
|
||||||
public ArticleInJournalJournalSheet(
|
|
||||||
final ItemSelectionModel itemSelectionModel,
|
|
||||||
final StringParameter selectedLangParam
|
|
||||||
) {
|
|
||||||
super();
|
|
||||||
this.itemSelectionModel = itemSelectionModel;
|
|
||||||
|
|
||||||
setEmptyView(
|
|
||||||
new Label(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.articleInJournal.journal.none",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
final TableColumnModel columnModel = getColumnModel();
|
|
||||||
columnModel.add(
|
|
||||||
new TableColumn(
|
|
||||||
0,
|
|
||||||
new Label(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.articleInJournal.journal",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
)
|
|
||||||
),
|
|
||||||
TABLE_COL_EDIT
|
|
||||||
)
|
|
||||||
);
|
|
||||||
columnModel.add(
|
|
||||||
new TableColumn(
|
|
||||||
1,
|
|
||||||
new Label(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.articleInJournal.journal.remove",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
)
|
|
||||||
),
|
|
||||||
TABLE_COL_DEL
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
setModelBuilder(
|
|
||||||
new ArticleInJournalJournalSheetModelBuilder(
|
|
||||||
itemSelectionModel, selectedLangParam
|
|
||||||
)
|
|
||||||
);
|
|
||||||
columnModel.get(0).setCellRenderer(new EditCellRenderer());
|
|
||||||
columnModel.get(1).setCellRenderer(new DeleteCellRenderer());
|
|
||||||
|
|
||||||
addTableActionListener(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void cellSelected(final TableActionEvent event) {
|
|
||||||
final PageState state = event.getPageState();
|
|
||||||
|
|
||||||
final ArticleInJournalItem article
|
|
||||||
= (ArticleInJournalItem) itemSelectionModel
|
|
||||||
.getSelectedObject(state);
|
|
||||||
|
|
||||||
final TableColumn column = getColumnModel().get(event.getColumn());
|
|
||||||
|
|
||||||
if (column.getHeaderKey().toString().equals(TABLE_COL_EDIT)) {
|
|
||||||
// Nothing
|
|
||||||
} else if (column.getHeaderKey().toString().equals(TABLE_COL_DEL)) {
|
|
||||||
final ArticleInJournalController controller = CdiUtil
|
|
||||||
.createCdiUtil()
|
|
||||||
.findBean(ArticleInJournalController.class);
|
|
||||||
controller.unsetJournal(article.getPublication().getPublicationId());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void headSelected(TableActionEvent event) {
|
|
||||||
//Nothing to do
|
|
||||||
}
|
|
||||||
|
|
||||||
private class ArticleInJournalJournalSheetModelBuilder
|
|
||||||
extends LockableImpl
|
|
||||||
implements TableModelBuilder {
|
|
||||||
|
|
||||||
private final ItemSelectionModel itemModel;
|
|
||||||
private final StringParameter selectedLangParam;
|
|
||||||
|
|
||||||
public ArticleInJournalJournalSheetModelBuilder(
|
|
||||||
final ItemSelectionModel itemModel,
|
|
||||||
final StringParameter selectedLangParam
|
|
||||||
) {
|
|
||||||
this.itemModel = itemModel;
|
|
||||||
this.selectedLangParam = selectedLangParam;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public TableModel makeModel(final Table table, final PageState state) {
|
|
||||||
table.getRowSelectionModel().clearSelection(state);
|
|
||||||
final ArticleInJournalItem article
|
|
||||||
= (ArticleInJournalItem) itemModel.
|
|
||||||
getSelectedObject(state);
|
|
||||||
return new ArticleInJournalJournalSheetModel(
|
|
||||||
table, state, article, selectedLangParam);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private class ArticleInJournalJournalSheetModel implements TableModel {
|
|
||||||
|
|
||||||
private final Table table;
|
|
||||||
|
|
||||||
private final String journalTitle;
|
|
||||||
|
|
||||||
private final Long journalId;
|
|
||||||
|
|
||||||
private boolean done;
|
|
||||||
|
|
||||||
public ArticleInJournalJournalSheetModel(
|
|
||||||
final Table table,
|
|
||||||
final PageState state,
|
|
||||||
final ArticleInJournalItem articleItem,
|
|
||||||
final StringParameter selectedLangParam
|
|
||||||
) {
|
|
||||||
this.table = table;
|
|
||||||
final Journal journal = articleItem
|
|
||||||
.getPublication()
|
|
||||||
.getJournal();
|
|
||||||
if (journal == null) {
|
|
||||||
done = false;
|
|
||||||
journalTitle = null;
|
|
||||||
journalId = null;
|
|
||||||
} else {
|
|
||||||
done = true;
|
|
||||||
journalTitle = journal.getTitle();
|
|
||||||
journalId = journal.getJournalId();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getColumnCount() {
|
|
||||||
return table.getColumnModel().size();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean nextRow() {
|
|
||||||
boolean ret;
|
|
||||||
|
|
||||||
if (done) {
|
|
||||||
ret = true;
|
|
||||||
done = false;
|
|
||||||
} else {
|
|
||||||
ret = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object getElementAt(final int columnIndex) {
|
|
||||||
switch (columnIndex) {
|
|
||||||
case 0:
|
|
||||||
return journalTitle;
|
|
||||||
case 1:
|
|
||||||
return new Label(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.articleInCollectedVolume.collectedVolume.remove",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
)
|
|
||||||
);
|
|
||||||
default:
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object getKeyAt(final int columnIndex) {
|
|
||||||
return journalId;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private class EditCellRenderer
|
|
||||||
extends LockableImpl
|
|
||||||
implements TableCellRenderer {
|
|
||||||
|
|
||||||
public Component getComponent(
|
|
||||||
final Table table,
|
|
||||||
final PageState state,
|
|
||||||
final Object value,
|
|
||||||
final boolean isSelected,
|
|
||||||
final Object key,
|
|
||||||
final int row,
|
|
||||||
final int column
|
|
||||||
) {
|
|
||||||
return new Text((String) value);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private class DeleteCellRenderer
|
|
||||||
extends LockableImpl
|
|
||||||
implements TableCellRenderer {
|
|
||||||
|
|
||||||
public Component getComponent(
|
|
||||||
final Table table,
|
|
||||||
final PageState state,
|
|
||||||
final Object value,
|
|
||||||
final boolean isSelected,
|
|
||||||
final Object key,
|
|
||||||
final int row,
|
|
||||||
final int column
|
|
||||||
) {
|
|
||||||
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
|
|
||||||
final PermissionChecker permissionChecker = cdiUtil
|
|
||||||
.findBean(PermissionChecker.class);
|
|
||||||
final ArticleInJournalItem articleItem
|
|
||||||
= (ArticleInJournalItem) itemSelectionModel
|
|
||||||
.getSelectedItem(state);
|
|
||||||
final boolean canEdit = permissionChecker.isPermitted(
|
|
||||||
ItemPrivileges.EDIT, articleItem
|
|
||||||
);
|
|
||||||
|
|
||||||
if (canEdit) {
|
|
||||||
final ControlLink link = new ControlLink((Component) value);
|
|
||||||
link.setConfirmation(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publication.ui.articleInJournal.journal.confirm_remove",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
)
|
|
||||||
);
|
|
||||||
return link;
|
|
||||||
} else {
|
|
||||||
return new Text("");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,68 +0,0 @@
|
||||||
package com.arsdigita.cms.contenttypes.ui;
|
|
||||||
|
|
||||||
import com.arsdigita.bebop.parameters.StringParameter;
|
|
||||||
import com.arsdigita.cms.ItemSelectionModel;
|
|
||||||
import com.arsdigita.cms.ui.authoring.AuthoringKitWizard;
|
|
||||||
import com.arsdigita.cms.ui.authoring.BasicItemForm;
|
|
||||||
import com.arsdigita.cms.ui.authoring.SimpleEditStep;
|
|
||||||
import com.arsdigita.cms.ui.workflow.WorkflowLockedComponentAccess;
|
|
||||||
import com.arsdigita.globalization.GlobalizedMessage;
|
|
||||||
|
|
||||||
import org.scientificcms.publications.SciPublicationsConstants;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
|
||||||
*/
|
|
||||||
public class ArticleInJournalJournalStep extends SimpleEditStep {
|
|
||||||
|
|
||||||
private String ADD_JOURNAL_STEP = "addJournal";
|
|
||||||
|
|
||||||
public ArticleInJournalJournalStep(
|
|
||||||
final ItemSelectionModel itemModel,
|
|
||||||
final AuthoringKitWizard parent,
|
|
||||||
final StringParameter selectedLanguageParam
|
|
||||||
) {
|
|
||||||
this(itemModel, parent, selectedLanguageParam, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ArticleInJournalJournalStep(
|
|
||||||
final ItemSelectionModel itemSelectionModel,
|
|
||||||
final AuthoringKitWizard authoringKitWizard,
|
|
||||||
final StringParameter selectedLanguageParam,
|
|
||||||
final String parameterSuffix
|
|
||||||
) {
|
|
||||||
super(
|
|
||||||
itemSelectionModel,
|
|
||||||
authoringKitWizard,
|
|
||||||
selectedLanguageParam,
|
|
||||||
parameterSuffix
|
|
||||||
);
|
|
||||||
|
|
||||||
final BasicItemForm addJournalForm = new ArticleInJournalJournalForm(
|
|
||||||
itemSelectionModel, selectedLanguageParam
|
|
||||||
);
|
|
||||||
add(
|
|
||||||
ADD_JOURNAL_STEP,
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.articleInJournal.addJournal",
|
|
||||||
SciPublicationsConstants.BUNDLE),
|
|
||||||
new WorkflowLockedComponentAccess(
|
|
||||||
addJournalForm, itemSelectionModel
|
|
||||||
),
|
|
||||||
addJournalForm.getSaveCancelSection().getCancelButton());
|
|
||||||
|
|
||||||
final ArticleInJournalJournalSheet sheet
|
|
||||||
= new ArticleInJournalJournalSheet(
|
|
||||||
itemSelectionModel,
|
|
||||||
selectedLanguageParam
|
|
||||||
);
|
|
||||||
setDisplayComponent(sheet);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,202 +0,0 @@
|
||||||
/*
|
|
||||||
* 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 com.arsdigita.cms.contenttypes.ui;
|
|
||||||
|
|
||||||
import com.arsdigita.bebop.Component;
|
|
||||||
import com.arsdigita.bebop.Label;
|
|
||||||
import com.arsdigita.bebop.PageState;
|
|
||||||
import com.arsdigita.bebop.parameters.StringParameter;
|
|
||||||
import com.arsdigita.cms.ItemSelectionModel;
|
|
||||||
import com.arsdigita.cms.ui.authoring.AuthoringKitWizard;
|
|
||||||
import com.arsdigita.cms.ui.authoring.BasicPageForm;
|
|
||||||
import com.arsdigita.cms.ui.authoring.SimpleEditStep;
|
|
||||||
import com.arsdigita.cms.ui.workflow.WorkflowLockedComponentAccess;
|
|
||||||
import com.arsdigita.globalization.GlobalizedMessage;
|
|
||||||
import com.arsdigita.toolbox.ui.DomainObjectPropertySheet;
|
|
||||||
|
|
||||||
import org.librecms.CmsConstants;
|
|
||||||
import org.scientificcms.publications.ArticleInJournal;
|
|
||||||
import org.scientificcms.publications.SciPublicationsConstants;
|
|
||||||
|
|
||||||
import java.text.DateFormat;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
|
||||||
*/
|
|
||||||
public class ArticleInJournalPropertiesStep extends PublicationPropertiesStep {
|
|
||||||
|
|
||||||
private final StringParameter selectedLanguageParam;
|
|
||||||
|
|
||||||
public ArticleInJournalPropertiesStep(
|
|
||||||
final ItemSelectionModel itemModel,
|
|
||||||
final AuthoringKitWizard parent,
|
|
||||||
final StringParameter selectedLanguageParam
|
|
||||||
) {
|
|
||||||
super(itemModel, parent, selectedLanguageParam);
|
|
||||||
|
|
||||||
this.selectedLanguageParam = selectedLanguageParam;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Component getArticleInJournalPropertySheet(
|
|
||||||
final ItemSelectionModel itemModel,
|
|
||||||
final StringParameter selectedLanguageParameter
|
|
||||||
) {
|
|
||||||
final DomainObjectPropertySheet sheet
|
|
||||||
= (DomainObjectPropertySheet) PublicationPropertiesStep
|
|
||||||
.getPublicationPropertySheet(
|
|
||||||
itemModel,
|
|
||||||
selectedLanguageParameter
|
|
||||||
);
|
|
||||||
|
|
||||||
sheet.add(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.articleinjournal.volume",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
),
|
|
||||||
ArticleInJournalController.VOLUME
|
|
||||||
);
|
|
||||||
|
|
||||||
sheet.add(new GlobalizedMessage(
|
|
||||||
"publications.ui.articleinjournal.issue",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
),
|
|
||||||
ArticleInJournalController.ISSUE);
|
|
||||||
|
|
||||||
sheet.add(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.articleinjournal.pages_from",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
),
|
|
||||||
ArticleInJournalController.START_PAGE
|
|
||||||
);
|
|
||||||
|
|
||||||
sheet.add(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.articleinjournal.pages_to",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
),
|
|
||||||
ArticleInJournalController.END_PAGE
|
|
||||||
);
|
|
||||||
|
|
||||||
sheet.add(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.articleinjournal.publication_date",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
),
|
|
||||||
ArticleInJournalController.PUBLICATION_DATE,
|
|
||||||
ArticleInJournalPropertiesStep::formatPublicationDate
|
|
||||||
);
|
|
||||||
|
|
||||||
sheet.add(new GlobalizedMessage(
|
|
||||||
"publications.ui.articleinjournal.reviewed"
|
|
||||||
),
|
|
||||||
ArticleInJournalController.PEER_REVIEWED,
|
|
||||||
ArticleInJournalPropertiesStep::formatReviewed
|
|
||||||
);
|
|
||||||
|
|
||||||
return sheet;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void addBasicProperties(final ItemSelectionModel itemModel,
|
|
||||||
final AuthoringKitWizard parent
|
|
||||||
) {
|
|
||||||
final SimpleEditStep basicProperties = new SimpleEditStep(
|
|
||||||
itemModel,
|
|
||||||
parent,
|
|
||||||
selectedLanguageParam,
|
|
||||||
EDIT_SHEET_NAME
|
|
||||||
);
|
|
||||||
|
|
||||||
final BasicPageForm editBasicSheet = new ArticleInJournalPropertyForm(
|
|
||||||
itemModel, this, selectedLanguageParam
|
|
||||||
);
|
|
||||||
|
|
||||||
basicProperties.add(
|
|
||||||
EDIT_SHEET_NAME,
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.articleinjournal.edit_basic_sheet",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
),
|
|
||||||
new WorkflowLockedComponentAccess(editBasicSheet,
|
|
||||||
itemModel
|
|
||||||
),
|
|
||||||
editBasicSheet.getSaveCancelSection().getCancelButton()
|
|
||||||
);
|
|
||||||
|
|
||||||
basicProperties.setDisplayComponent(
|
|
||||||
getArticleInJournalPropertySheet(
|
|
||||||
itemModel,
|
|
||||||
selectedLanguageParam
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
getSegmentedPanel().addSegment(
|
|
||||||
new Label(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.publication.basic_properties",
|
|
||||||
SciPublicationsConstants.BUNDLE)
|
|
||||||
),
|
|
||||||
basicProperties
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void addSteps(
|
|
||||||
final ItemSelectionModel itemModel,
|
|
||||||
final AuthoringKitWizard parent
|
|
||||||
) {
|
|
||||||
super.addSteps(itemModel, parent);
|
|
||||||
|
|
||||||
addStep(
|
|
||||||
new ArticleInJournalJournalStep(
|
|
||||||
itemModel, parent, selectedLanguageParam
|
|
||||||
),
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publication.ui.articleInJournal.journal",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private static String formatPublicationDate(
|
|
||||||
final Object obj, final String attribute, final PageState state
|
|
||||||
) {
|
|
||||||
final ArticleInJournal article = (ArticleInJournal) obj;
|
|
||||||
|
|
||||||
if (article.getPublicationDate() != null) {
|
|
||||||
return DateFormat.getDateInstance(DateFormat.LONG)
|
|
||||||
.format(
|
|
||||||
article.getPublicationDate());
|
|
||||||
} else {
|
|
||||||
return (String) new GlobalizedMessage(
|
|
||||||
"cms.ui.unknown",
|
|
||||||
CmsConstants.CMS_BUNDLE
|
|
||||||
).localize();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static String formatReviewed(
|
|
||||||
final Object obj, final String attribute, final PageState state
|
|
||||||
) {
|
|
||||||
final ArticleInJournal article = (ArticleInJournal) obj;
|
|
||||||
|
|
||||||
if (article.getPeerReviewed()) {
|
|
||||||
return (String) new GlobalizedMessage(
|
|
||||||
"publications.ui.articleinjournal.reviewed.yes",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
).localize();
|
|
||||||
} else {
|
|
||||||
return (String) new GlobalizedMessage(
|
|
||||||
"publications.ui.articleinjournal.reviewed.no",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
).localize();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,273 +0,0 @@
|
||||||
/*
|
|
||||||
* 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 com.arsdigita.cms.contenttypes.ui;
|
|
||||||
|
|
||||||
import com.arsdigita.bebop.FormData;
|
|
||||||
import com.arsdigita.bebop.FormProcessException;
|
|
||||||
import com.arsdigita.bebop.Label;
|
|
||||||
import com.arsdigita.bebop.PageState;
|
|
||||||
import com.arsdigita.bebop.event.FormInitListener;
|
|
||||||
import com.arsdigita.bebop.event.FormProcessListener;
|
|
||||||
import com.arsdigita.bebop.event.FormSectionEvent;
|
|
||||||
import com.arsdigita.bebop.event.FormSubmissionListener;
|
|
||||||
import com.arsdigita.bebop.form.CheckboxGroup;
|
|
||||||
import com.arsdigita.bebop.form.Option;
|
|
||||||
import com.arsdigita.bebop.form.TextField;
|
|
||||||
import com.arsdigita.bebop.parameters.DateParameter;
|
|
||||||
import com.arsdigita.bebop.parameters.IntegerParameter;
|
|
||||||
import com.arsdigita.bebop.parameters.ParameterModel;
|
|
||||||
import com.arsdigita.bebop.parameters.StringParameter;
|
|
||||||
import com.arsdigita.cms.ItemSelectionModel;
|
|
||||||
import com.arsdigita.cms.ui.authoring.SelectedLanguageUtil;
|
|
||||||
import com.arsdigita.globalization.GlobalizedMessage;
|
|
||||||
|
|
||||||
import org.libreccm.cdi.utils.CdiUtil;
|
|
||||||
import org.scientificcms.publications.ArticleInJournal;
|
|
||||||
import org.scientificcms.publications.SciPublicationsConstants;
|
|
||||||
import org.scientificcms.publications.contenttypes.ArticleInJournalItem;
|
|
||||||
|
|
||||||
import java.util.Calendar;
|
|
||||||
import java.util.GregorianCalendar;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Locale;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
|
||||||
*/
|
|
||||||
public class ArticleInJournalPropertyForm
|
|
||||||
extends PublicationPropertyForm
|
|
||||||
implements FormInitListener,
|
|
||||||
FormProcessListener,
|
|
||||||
FormSubmissionListener {
|
|
||||||
|
|
||||||
public static final String ID = "ArticleInJournalEdit";
|
|
||||||
|
|
||||||
private static final String REVIEWED = "reviewed";
|
|
||||||
|
|
||||||
private final ArticleInJournalPropertiesStep propertiesStep;
|
|
||||||
|
|
||||||
private final StringParameter selectedLanguageParam;
|
|
||||||
|
|
||||||
private CheckboxGroup reviewed;
|
|
||||||
|
|
||||||
public ArticleInJournalPropertyForm(
|
|
||||||
final ItemSelectionModel itemModel,
|
|
||||||
final StringParameter selectedLanguageParam
|
|
||||||
) {
|
|
||||||
this(itemModel, null, selectedLanguageParam);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ArticleInJournalPropertyForm(
|
|
||||||
final ItemSelectionModel itemModel,
|
|
||||||
final ArticleInJournalPropertiesStep propertiesStep,
|
|
||||||
final StringParameter selectedLanguageParam
|
|
||||||
) {
|
|
||||||
|
|
||||||
super(itemModel, propertiesStep, selectedLanguageParam);
|
|
||||||
this.propertiesStep = propertiesStep;
|
|
||||||
this.selectedLanguageParam = selectedLanguageParam;
|
|
||||||
addSubmissionListener(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void addWidgets() {
|
|
||||||
|
|
||||||
super.addWidgets();
|
|
||||||
|
|
||||||
final ParameterModel volumeParam = new IntegerParameter(
|
|
||||||
ArticleInJournalController.VOLUME
|
|
||||||
);
|
|
||||||
final TextField volume = new TextField(volumeParam);
|
|
||||||
volume.setLabel(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.articleinjournal.volume",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
)
|
|
||||||
);
|
|
||||||
add(volume);
|
|
||||||
|
|
||||||
final ParameterModel issueParam = new StringParameter(
|
|
||||||
ArticleInJournalController.ISSUE
|
|
||||||
);
|
|
||||||
final TextField issue = new TextField(issueParam);
|
|
||||||
issue.setLabel(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.articleinjournal.issue",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
)
|
|
||||||
);
|
|
||||||
add(issue);
|
|
||||||
|
|
||||||
final ParameterModel pagesFromParam = new IntegerParameter(
|
|
||||||
ArticleInJournalController.START_PAGE
|
|
||||||
);
|
|
||||||
final TextField startPage = new TextField(pagesFromParam);
|
|
||||||
startPage.setLabel(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.articleinjournal.pages_from",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
)
|
|
||||||
);
|
|
||||||
add(startPage);
|
|
||||||
|
|
||||||
final ParameterModel pagesToParam = new IntegerParameter(
|
|
||||||
ArticleInJournalController.END_PAGE
|
|
||||||
);
|
|
||||||
final TextField endPage = new TextField(pagesToParam);
|
|
||||||
endPage.setLabel(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.articleinjournal.pages_to",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
)
|
|
||||||
);
|
|
||||||
add(endPage);
|
|
||||||
|
|
||||||
final Calendar today = new GregorianCalendar();
|
|
||||||
final ParameterModel pubDateParam = new DateParameter(
|
|
||||||
ArticleInJournalController.PUBLICATION_DATE
|
|
||||||
);
|
|
||||||
final com.arsdigita.bebop.form.Date pubDate
|
|
||||||
= new com.arsdigita.bebop.form.Date(
|
|
||||||
pubDateParam
|
|
||||||
);
|
|
||||||
pubDate.setYearAsc(false);
|
|
||||||
pubDate.setYearRange(1900, today.get(Calendar.YEAR) + 2);
|
|
||||||
pubDate.setLabel(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.articleinjournal.publicationDate",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
)
|
|
||||||
);
|
|
||||||
add(pubDate);
|
|
||||||
|
|
||||||
reviewed = new CheckboxGroup("reviewedGroup");
|
|
||||||
reviewed.addOption(new Option(
|
|
||||||
REVIEWED,
|
|
||||||
new Label(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.articleinjournal.reviewed",
|
|
||||||
SciPublicationsConstants.BUNDLE)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
reviewed.setLabel(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.articleinjournal.reviewed"
|
|
||||||
)
|
|
||||||
);
|
|
||||||
add(reviewed);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected final CheckboxGroup getReviewed() {
|
|
||||||
return reviewed;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void init(final FormSectionEvent event) throws FormProcessException {
|
|
||||||
super.init(event);
|
|
||||||
|
|
||||||
final FormData data = event.getFormData();
|
|
||||||
final ArticleInJournalItem articleItem
|
|
||||||
= (ArticleInJournalItem) initBasicWidgets(
|
|
||||||
event);
|
|
||||||
final ArticleInJournal article = articleItem.getPublication();
|
|
||||||
|
|
||||||
data.put(ArticleInJournalController.VOLUME, article.getVolume());
|
|
||||||
data.put(ArticleInJournalController.ISSUE, article.getIssue());
|
|
||||||
data.put(ArticleInJournalController.START_PAGE, article.getStartPage());
|
|
||||||
data.put(ArticleInJournalController.END_PAGE, article.getEndPage());
|
|
||||||
data.put(ArticleInJournalController.PUBLICATION_DATE,
|
|
||||||
article.getPublicationDate());
|
|
||||||
|
|
||||||
if ((article.getPeerReviewed() != null)
|
|
||||||
&& (article.getPeerReviewed())) {
|
|
||||||
reviewed.setValue(event.getPageState(), new String[]{REVIEWED});
|
|
||||||
} else {
|
|
||||||
reviewed.setValue(event.getPageState(), null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void process(final FormSectionEvent event)
|
|
||||||
throws FormProcessException {
|
|
||||||
|
|
||||||
super.process(event);
|
|
||||||
|
|
||||||
final FormData formData = event.getFormData();
|
|
||||||
final PageState state = event.getPageState();
|
|
||||||
final ArticleInJournalItem articleItem
|
|
||||||
= (ArticleInJournalItem) processBasicWidgets(
|
|
||||||
event
|
|
||||||
);
|
|
||||||
|
|
||||||
if ((articleItem != null)
|
|
||||||
&& getSaveCancelSection().getSaveButton().isSelected(event
|
|
||||||
.getPageState()
|
|
||||||
)) {
|
|
||||||
|
|
||||||
final Map<String, Object> data = new HashMap<>();
|
|
||||||
|
|
||||||
data.put(
|
|
||||||
ArticleInJournalController.VOLUME,
|
|
||||||
formData.get(ArticleInJournalController.VOLUME
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
data.put(
|
|
||||||
ArticleInJournalController.ISSUE,
|
|
||||||
formData.get(ArticleInJournalController.ISSUE
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
data.put(
|
|
||||||
ArticleInJournalController.START_PAGE,
|
|
||||||
formData.get(ArticleInJournalController.START_PAGE
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
data.put(
|
|
||||||
ArticleInJournalController.END_PAGE,
|
|
||||||
formData.get(ArticleInJournalController.END_PAGE
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
data.put(
|
|
||||||
ArticleInJournalController.PUBLICATION_DATE,
|
|
||||||
formData.get(ArticleInJournalController.PUBLICATION_DATE
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
if (reviewed.getValue(event.getPageState()) == null) {
|
|
||||||
data.put(
|
|
||||||
ArticleInCollectedVolumeController.PEER_REVIEWED,
|
|
||||||
Boolean.FALSE
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
data.put(
|
|
||||||
ArticleInCollectedVolumeController.PEER_REVIEWED,
|
|
||||||
Boolean.TRUE
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
final Locale selectedLocale = SelectedLanguageUtil.selectedLocale(
|
|
||||||
state, selectedLanguageParam
|
|
||||||
);
|
|
||||||
|
|
||||||
final ArticleInJournalController controller = CdiUtil
|
|
||||||
.createCdiUtil()
|
|
||||||
.findBean(ArticleInJournalController.class);
|
|
||||||
controller.saveArticle(
|
|
||||||
articleItem.getPublication().getPublicationId(),
|
|
||||||
selectedLocale,
|
|
||||||
data
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,102 +0,0 @@
|
||||||
/*
|
|
||||||
* 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 com.arsdigita.cms.contenttypes.ui;
|
|
||||||
|
|
||||||
import com.arsdigita.bebop.FormData;
|
|
||||||
import com.arsdigita.bebop.FormProcessException;
|
|
||||||
import com.arsdigita.bebop.PageState;
|
|
||||||
import com.arsdigita.bebop.event.FormInitListener;
|
|
||||||
import com.arsdigita.bebop.event.FormProcessListener;
|
|
||||||
import com.arsdigita.bebop.event.FormSectionEvent;
|
|
||||||
import com.arsdigita.bebop.parameters.StringParameter;
|
|
||||||
import com.arsdigita.cms.ItemSelectionModel;
|
|
||||||
import com.arsdigita.cms.ui.authoring.BasicItemForm;
|
|
||||||
import com.arsdigita.globalization.GlobalizedMessage;
|
|
||||||
|
|
||||||
import org.apache.logging.log4j.LogManager;
|
|
||||||
import org.apache.logging.log4j.Logger;
|
|
||||||
import org.libreccm.cdi.utils.CdiUtil;
|
|
||||||
import org.scientificcms.publications.ArticleInCollectedVolume;
|
|
||||||
import org.scientificcms.publications.SciPublicationsConstants;
|
|
||||||
import org.scientificcms.publications.contenttypes.CollectedVolumeItem;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
|
||||||
*/
|
|
||||||
public class CollectedVolumeArticlesAddForm
|
|
||||||
extends BasicItemForm
|
|
||||||
implements FormProcessListener,
|
|
||||||
FormInitListener {
|
|
||||||
|
|
||||||
private static final Logger LOGGER = LogManager.getLogger(
|
|
||||||
CollectedVolumeArticlesAddForm.class
|
|
||||||
);
|
|
||||||
|
|
||||||
private final String ARTICLE_SEARCH = "articles";
|
|
||||||
|
|
||||||
private final ItemSelectionModel itemModel;
|
|
||||||
|
|
||||||
private PublicationSearchWidget articleSearch;
|
|
||||||
|
|
||||||
public CollectedVolumeArticlesAddForm(
|
|
||||||
final ItemSelectionModel itemModel,
|
|
||||||
final StringParameter selectedLangParam
|
|
||||||
) {
|
|
||||||
super("ArticlesAddForm", itemModel, selectedLangParam);
|
|
||||||
this.itemModel = itemModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void addWidgets() {
|
|
||||||
|
|
||||||
articleSearch = new PublicationSearchWidget(
|
|
||||||
ARTICLE_SEARCH, ArticleInCollectedVolume.class
|
|
||||||
);
|
|
||||||
articleSearch.setLabel(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.collected_volume.articles.select_article",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
)
|
|
||||||
);
|
|
||||||
add(articleSearch);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void init(final FormSectionEvent event) throws FormProcessException {
|
|
||||||
final PageState state = event.getPageState();
|
|
||||||
|
|
||||||
setVisible(state, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void process(final FormSectionEvent event)
|
|
||||||
throws FormProcessException {
|
|
||||||
final FormData formData = event.getFormData();
|
|
||||||
final PageState state = event.getPageState();
|
|
||||||
final CollectedVolumeItem collectedVolumeItem
|
|
||||||
= (CollectedVolumeItem) getItemSelectionModel()
|
|
||||||
.getSelectedItem(state);
|
|
||||||
|
|
||||||
if (this.getSaveCancelSection().getSaveButton().isSelected(state)) {
|
|
||||||
final ArticleInCollectedVolume article
|
|
||||||
= (ArticleInCollectedVolume) formData
|
|
||||||
.get(ARTICLE_SEARCH);
|
|
||||||
|
|
||||||
final CollectedVolumeController controller = CdiUtil
|
|
||||||
.createCdiUtil()
|
|
||||||
.findBean(CollectedVolumeController.class);
|
|
||||||
|
|
||||||
controller.addArticle(
|
|
||||||
collectedVolumeItem.getPublication().getPublicationId(),
|
|
||||||
article.getPublicationId()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
init(event);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,62 +0,0 @@
|
||||||
/*
|
|
||||||
* 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 com.arsdigita.cms.contenttypes.ui;
|
|
||||||
|
|
||||||
import com.arsdigita.bebop.parameters.StringParameter;
|
|
||||||
import com.arsdigita.cms.ItemSelectionModel;
|
|
||||||
import com.arsdigita.cms.ui.authoring.AuthoringKitWizard;
|
|
||||||
import com.arsdigita.cms.ui.authoring.BasicItemForm;
|
|
||||||
import com.arsdigita.cms.ui.authoring.SimpleEditStep;
|
|
||||||
import com.arsdigita.cms.ui.workflow.WorkflowLockedComponentAccess;
|
|
||||||
import com.arsdigita.globalization.GlobalizedMessage;
|
|
||||||
|
|
||||||
import org.scientificcms.publications.SciPublicationsConstants;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
|
||||||
*/
|
|
||||||
public class CollectedVolumeArticlesStep extends SimpleEditStep {
|
|
||||||
|
|
||||||
private static final String ADD_ARTICLE_SHEET_NAME = "addArticle";
|
|
||||||
|
|
||||||
public CollectedVolumeArticlesStep(
|
|
||||||
final ItemSelectionModel itemModel,
|
|
||||||
final AuthoringKitWizard parent,
|
|
||||||
final StringParameter selectedLangParam
|
|
||||||
) {
|
|
||||||
this(itemModel, parent, selectedLangParam, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public CollectedVolumeArticlesStep(
|
|
||||||
final ItemSelectionModel itemModel,
|
|
||||||
final AuthoringKitWizard parent,
|
|
||||||
final StringParameter selectedLangParam,
|
|
||||||
final String prefix
|
|
||||||
) {
|
|
||||||
super(itemModel, parent, selectedLangParam, prefix);
|
|
||||||
|
|
||||||
final BasicItemForm addArticleSheet = new CollectedVolumeArticlesAddForm(
|
|
||||||
itemModel, selectedLangParam
|
|
||||||
);
|
|
||||||
add(
|
|
||||||
ADD_ARTICLE_SHEET_NAME,
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.collected_volume.add_article",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
),
|
|
||||||
new WorkflowLockedComponentAccess(addArticleSheet, itemModel),
|
|
||||||
addArticleSheet.getSaveCancelSection().getCancelButton());
|
|
||||||
|
|
||||||
final CollectedVolumeArticlesTable articlesTable
|
|
||||||
= new CollectedVolumeArticlesTable(
|
|
||||||
itemModel,
|
|
||||||
selectedLangParam
|
|
||||||
);
|
|
||||||
setDisplayComponent(articlesTable);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,328 +0,0 @@
|
||||||
/*
|
|
||||||
* 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 com.arsdigita.cms.contenttypes.ui;
|
|
||||||
|
|
||||||
import com.arsdigita.bebop.Component;
|
|
||||||
import com.arsdigita.bebop.ControlLink;
|
|
||||||
import com.arsdigita.bebop.Label;
|
|
||||||
import com.arsdigita.bebop.PageState;
|
|
||||||
import com.arsdigita.bebop.Table;
|
|
||||||
import com.arsdigita.bebop.Text;
|
|
||||||
import com.arsdigita.bebop.event.TableActionEvent;
|
|
||||||
import com.arsdigita.bebop.event.TableActionListener;
|
|
||||||
import com.arsdigita.bebop.parameters.StringParameter;
|
|
||||||
import com.arsdigita.bebop.table.TableCellRenderer;
|
|
||||||
import com.arsdigita.bebop.table.TableColumn;
|
|
||||||
import com.arsdigita.bebop.table.TableColumnModel;
|
|
||||||
import com.arsdigita.bebop.table.TableModel;
|
|
||||||
import com.arsdigita.bebop.table.TableModelBuilder;
|
|
||||||
import com.arsdigita.cms.ItemSelectionModel;
|
|
||||||
import com.arsdigita.globalization.GlobalizedMessage;
|
|
||||||
import com.arsdigita.util.LockableImpl;
|
|
||||||
|
|
||||||
import org.apache.logging.log4j.LogManager;
|
|
||||||
import org.apache.logging.log4j.Logger;
|
|
||||||
import org.libreccm.cdi.utils.CdiUtil;
|
|
||||||
import org.libreccm.security.PermissionChecker;
|
|
||||||
import org.librecms.contentsection.privileges.ItemPrivileges;
|
|
||||||
import org.scientificcms.publications.ArticleInCollectedVolume;
|
|
||||||
import org.scientificcms.publications.CollectedVolume;
|
|
||||||
import org.scientificcms.publications.SciPublicationsConstants;
|
|
||||||
import org.scientificcms.publications.contenttypes.CollectedVolumeItem;
|
|
||||||
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
|
||||||
*/
|
|
||||||
public class CollectedVolumeArticlesTable
|
|
||||||
extends Table
|
|
||||||
implements TableActionListener {
|
|
||||||
|
|
||||||
private static final Logger LOGGER = LogManager.getLogger(
|
|
||||||
CollectedVolumeArticlesTable.class
|
|
||||||
);
|
|
||||||
|
|
||||||
private final String TABLE_COL_EDIT = "table_col_edit";
|
|
||||||
|
|
||||||
private final String TABLE_COL_DEL = "table_col_del";
|
|
||||||
|
|
||||||
private final ItemSelectionModel itemModel;
|
|
||||||
|
|
||||||
public CollectedVolumeArticlesTable(
|
|
||||||
final ItemSelectionModel itemModel,
|
|
||||||
final StringParameter selectedLangParam
|
|
||||||
) {
|
|
||||||
super();
|
|
||||||
this.itemModel = itemModel;
|
|
||||||
|
|
||||||
setEmptyView(
|
|
||||||
new Label(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.collected_volume.no_articles",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
TableColumnModel colModel = getColumnModel();
|
|
||||||
colModel.add(new TableColumn(
|
|
||||||
0,
|
|
||||||
new Label(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.collected_volume.article",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
)),
|
|
||||||
TABLE_COL_EDIT));
|
|
||||||
colModel.add(new TableColumn(
|
|
||||||
1,
|
|
||||||
new Label(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.collected_volume.article.remove",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
)
|
|
||||||
),
|
|
||||||
TABLE_COL_DEL));
|
|
||||||
|
|
||||||
setModelBuilder(
|
|
||||||
new CollectedVolumeArticlesTableModelBuilder(itemModel));
|
|
||||||
|
|
||||||
colModel.get(0).setCellRenderer(new EditCellRenderer());
|
|
||||||
colModel.get(1).setCellRenderer(new DeleteCellRenderer());
|
|
||||||
|
|
||||||
addTableActionListener(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void cellSelected(final TableActionEvent event) {
|
|
||||||
final PageState state = event.getPageState();
|
|
||||||
|
|
||||||
final CollectedVolumeController controller = CdiUtil
|
|
||||||
.createCdiUtil()
|
|
||||||
.findBean(CollectedVolumeController.class);
|
|
||||||
|
|
||||||
final ArticleInCollectedVolume article = controller
|
|
||||||
.findArticle((Long) event.getRowKey());
|
|
||||||
|
|
||||||
final CollectedVolumeItem collectedVolumeItem
|
|
||||||
= (CollectedVolumeItem) itemModel
|
|
||||||
.getSelectedObject(state);
|
|
||||||
final CollectedVolume collectedVolume = collectedVolumeItem
|
|
||||||
.getPublication();
|
|
||||||
|
|
||||||
final TableColumn column = getColumnModel().get(event.getColumn());
|
|
||||||
|
|
||||||
if (column.getHeaderKey().toString().equals(TABLE_COL_EDIT)) {
|
|
||||||
// Nothing
|
|
||||||
} else if (column.getHeaderKey().toString().equals(TABLE_COL_DEL)) {
|
|
||||||
controller.removeArticle(
|
|
||||||
collectedVolume.getPublicationId(),
|
|
||||||
article.getPublicationId()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
// else if (column.getHeaderKey().toString().equals(TABLE_COL_UP)) {
|
|
||||||
// controller.swapWithPreviousArticle(
|
|
||||||
// collectedVolume.getPublicationId(),
|
|
||||||
// article.getPublicationId()
|
|
||||||
// );
|
|
||||||
// } else if (column.getHeaderKey().toString().equals(TABLE_COL_DOWN)) {
|
|
||||||
// controller.swapWithNextArticle(
|
|
||||||
// collectedVolume.getPublicationId(),
|
|
||||||
// article.getPublicationId()
|
|
||||||
// );
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void headSelected(TableActionEvent event) {
|
|
||||||
//Nothing to do.
|
|
||||||
}
|
|
||||||
|
|
||||||
private class CollectedVolumeArticlesTableModelBuilder
|
|
||||||
extends LockableImpl
|
|
||||||
implements TableModelBuilder {
|
|
||||||
|
|
||||||
private final ItemSelectionModel itemModel;
|
|
||||||
|
|
||||||
public CollectedVolumeArticlesTableModelBuilder(
|
|
||||||
final ItemSelectionModel itemModel
|
|
||||||
) {
|
|
||||||
this.itemModel = itemModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public TableModel makeModel(final Table table, final PageState state) {
|
|
||||||
table.getRowSelectionModel().clearSelection(state);
|
|
||||||
final CollectedVolumeItem collectedVolumeItem
|
|
||||||
= (CollectedVolumeItem) itemModel
|
|
||||||
.getSelectedItem(state);
|
|
||||||
return new CollectedVolumeArticlesTableModel(
|
|
||||||
table, state, collectedVolumeItem.getPublication()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private class CollectedVolumeArticlesTableModel implements TableModel {
|
|
||||||
|
|
||||||
private final Table table;
|
|
||||||
|
|
||||||
private final Iterator<ArticleInCollectedVolume> articles;
|
|
||||||
|
|
||||||
private ArticleInCollectedVolume article;
|
|
||||||
|
|
||||||
private CollectedVolumeArticlesTableModel(
|
|
||||||
final Table table,
|
|
||||||
final PageState state,
|
|
||||||
final CollectedVolume collectedVolume
|
|
||||||
) {
|
|
||||||
this.table = table;
|
|
||||||
articles = collectedVolume.getArticles().iterator();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getColumnCount() {
|
|
||||||
return table.getColumnModel().size();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean nextRow() {
|
|
||||||
if (articles != null && articles.hasNext()) {
|
|
||||||
article = articles.next();
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object getElementAt(final int columnIndex) {
|
|
||||||
switch (columnIndex) {
|
|
||||||
case 0:
|
|
||||||
return article.getTitle();
|
|
||||||
case 1:
|
|
||||||
return new Label(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.collected_volume.article.remove",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
)
|
|
||||||
);
|
|
||||||
default:
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object getKeyAt(final int columnIndex) {
|
|
||||||
return article.getPublicationId();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private class EditCellRenderer
|
|
||||||
extends LockableImpl
|
|
||||||
implements TableCellRenderer {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Component getComponent(
|
|
||||||
final Table table,
|
|
||||||
final PageState state,
|
|
||||||
final Object value,
|
|
||||||
final boolean isSelected,
|
|
||||||
final Object key,
|
|
||||||
final int row,
|
|
||||||
final int col
|
|
||||||
) {
|
|
||||||
// SecurityManager securityManager = Utilities
|
|
||||||
// .getSecurityManager(state);
|
|
||||||
// CollectedVolume collectedVolume = (CollectedVolume) m_itemModel.
|
|
||||||
// getSelectedObject(state);
|
|
||||||
//
|
|
||||||
// boolean canEdit = securityManager.canAccess(
|
|
||||||
// state.getRequest(),
|
|
||||||
// SecurityManager.EDIT_ITEM,
|
|
||||||
// collectedVolume);
|
|
||||||
//
|
|
||||||
// if (canEdit) {
|
|
||||||
// ArticleInCollectedVolume article;
|
|
||||||
// try {
|
|
||||||
// article = new ArticleInCollectedVolume((BigDecimal) key);
|
|
||||||
// } catch (ObjectNotFoundException ex) {
|
|
||||||
// s_log.warn(String.format("No object with key '%s' found.",
|
|
||||||
// key),
|
|
||||||
// ex);
|
|
||||||
// return new Label(value.toString());
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// ContentSection section = article.getContentSection();//CMS.getContext().getContentSection();
|
|
||||||
// ItemResolver resolver = section.getItemResolver();
|
|
||||||
// Link link = new Link(value.toString(),
|
|
||||||
// resolver.generateItemURL(state,
|
|
||||||
// article,
|
|
||||||
// section,
|
|
||||||
// article
|
|
||||||
// .getVersion()));
|
|
||||||
//
|
|
||||||
// return link;
|
|
||||||
// } else {
|
|
||||||
// ArticleInCollectedVolume article;
|
|
||||||
// try {
|
|
||||||
// article = new ArticleInCollectedVolume((BigDecimal) key);
|
|
||||||
// } catch (ObjectNotFoundException ex) {
|
|
||||||
// s_log.warn(String.format("No object with key '%s' found.",
|
|
||||||
// key),
|
|
||||||
// ex);
|
|
||||||
// return new Label(value.toString());
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// Label label = new Label(value.toString());
|
|
||||||
// return label;
|
|
||||||
// }
|
|
||||||
return new Text((String) value);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private class DeleteCellRenderer
|
|
||||||
extends LockableImpl
|
|
||||||
implements TableCellRenderer {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Component getComponent(
|
|
||||||
final Table table,
|
|
||||||
final PageState state,
|
|
||||||
final Object value,
|
|
||||||
final boolean isSelected,
|
|
||||||
final Object key,
|
|
||||||
final int row,
|
|
||||||
final int col
|
|
||||||
) {
|
|
||||||
final PermissionChecker permissionChecker = CdiUtil
|
|
||||||
.createCdiUtil()
|
|
||||||
.findBean(PermissionChecker.class);
|
|
||||||
|
|
||||||
final CollectedVolumeItem collectedVolumeItem
|
|
||||||
= (CollectedVolumeItem) itemModel
|
|
||||||
.getSelectedObject(state);
|
|
||||||
|
|
||||||
boolean canEdit = permissionChecker
|
|
||||||
.isPermitted(ItemPrivileges.DELETE, collectedVolumeItem);
|
|
||||||
|
|
||||||
if (canEdit) {
|
|
||||||
ControlLink link = new ControlLink((Label) value);
|
|
||||||
link.setConfirmation(new GlobalizedMessage(
|
|
||||||
"publications.ui.collected_volume.articles.confirm_remove"));
|
|
||||||
return link;
|
|
||||||
} else {
|
|
||||||
return new Text("");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,133 +0,0 @@
|
||||||
/*
|
|
||||||
* 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 com.arsdigita.cms.contenttypes.ui;
|
|
||||||
|
|
||||||
import org.scientificcms.publications.ArticleInCollectedVolume;
|
|
||||||
import org.scientificcms.publications.CollectedVolume;
|
|
||||||
import org.scientificcms.publications.CollectedVolumeManager;
|
|
||||||
import org.scientificcms.publications.PublicationRepository;
|
|
||||||
|
|
||||||
import java.util.Locale;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import javax.enterprise.context.RequestScoped;
|
|
||||||
import javax.inject.Inject;
|
|
||||||
import javax.transaction.Transactional;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
|
||||||
*/
|
|
||||||
@RequestScoped
|
|
||||||
public class CollectedVolumeController {
|
|
||||||
|
|
||||||
public static final String PEER_REVIEWED = "peerReviewed";
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
private CollectedVolumeManager collectedVolumeManager;
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
private PublicationRepository publicationRepository;
|
|
||||||
|
|
||||||
@Transactional(Transactional.TxType.REQUIRED)
|
|
||||||
public void save(
|
|
||||||
final long collectedVolumeId,
|
|
||||||
final Locale selectedLocale,
|
|
||||||
final Map<String, Object> data
|
|
||||||
) {
|
|
||||||
final CollectedVolume collectedVolume = publicationRepository
|
|
||||||
.findByIdAndType(collectedVolumeId, CollectedVolume.class)
|
|
||||||
.orElseThrow(
|
|
||||||
() -> new IllegalArgumentException(
|
|
||||||
String.format(
|
|
||||||
"No CollectedVolume with ID %d found.",
|
|
||||||
collectedVolumeId
|
|
||||||
)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
if (data.get(PEER_REVIEWED) != null) {
|
|
||||||
final Boolean reviewed = (Boolean) data.get(PEER_REVIEWED);
|
|
||||||
collectedVolume.setPeerReviewed(reviewed);
|
|
||||||
}
|
|
||||||
|
|
||||||
publicationRepository.save(collectedVolume);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ArticleInCollectedVolume findArticle(final long articleId) {
|
|
||||||
return publicationRepository
|
|
||||||
.findByIdAndType(articleId, ArticleInCollectedVolume.class)
|
|
||||||
.orElseThrow(
|
|
||||||
() -> new IllegalArgumentException(
|
|
||||||
String.format(
|
|
||||||
"No ArticleInCollectedVolume with ID %d found.",
|
|
||||||
articleId
|
|
||||||
)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addArticle(
|
|
||||||
final long collectedVolumeId, final long articleId
|
|
||||||
) {
|
|
||||||
final CollectedVolume collectedVolume = publicationRepository
|
|
||||||
.findByIdAndType(collectedVolumeId, CollectedVolume.class)
|
|
||||||
.orElseThrow(
|
|
||||||
() -> new IllegalArgumentException(
|
|
||||||
String.format(
|
|
||||||
"No CollectedVolume with ID %d found",
|
|
||||||
collectedVolumeId
|
|
||||||
)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
final ArticleInCollectedVolume article = publicationRepository
|
|
||||||
.findByIdAndType(articleId, ArticleInCollectedVolume.class)
|
|
||||||
.orElseThrow(
|
|
||||||
() -> new IllegalArgumentException(
|
|
||||||
String.format(
|
|
||||||
"No ArticleInCollectedVolume with ID %d found.",
|
|
||||||
articleId
|
|
||||||
)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
collectedVolumeManager.addArticleToCollectedVolume(
|
|
||||||
article, collectedVolume
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void removeArticle(
|
|
||||||
final long collectedVolumeId, final long articleId
|
|
||||||
) {
|
|
||||||
final CollectedVolume collectedVolume = publicationRepository
|
|
||||||
.findByIdAndType(collectedVolumeId, CollectedVolume.class)
|
|
||||||
.orElseThrow(
|
|
||||||
() -> new IllegalArgumentException(
|
|
||||||
String.format(
|
|
||||||
"No CollectedVolume with ID %d found",
|
|
||||||
collectedVolumeId
|
|
||||||
)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
final ArticleInCollectedVolume article = publicationRepository
|
|
||||||
.findByIdAndType(articleId, ArticleInCollectedVolume.class)
|
|
||||||
.orElseThrow(
|
|
||||||
() -> new IllegalArgumentException(
|
|
||||||
String.format(
|
|
||||||
"No ArticleInCollectedVolume with ID %d found.",
|
|
||||||
articleId
|
|
||||||
)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
collectedVolumeManager.removeArticleFromCollectedVolume(
|
|
||||||
article, collectedVolume
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,37 +0,0 @@
|
||||||
/*
|
|
||||||
* 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 com.arsdigita.cms.contenttypes.ui;
|
|
||||||
|
|
||||||
import com.arsdigita.bebop.parameters.StringParameter;
|
|
||||||
import com.arsdigita.cms.ItemSelectionModel;
|
|
||||||
import com.arsdigita.cms.ui.authoring.CreationSelector;
|
|
||||||
|
|
||||||
import org.scientificcms.publications.CollectedVolume;
|
|
||||||
import org.scientificcms.publications.Publication;
|
|
||||||
import org.scientificcms.publications.contenttypes.CollectedVolumeItem;
|
|
||||||
import org.scientificcms.publications.contenttypes.PublicationItem;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
|
||||||
*/
|
|
||||||
public class CollectedVolumeCreateForm
|
|
||||||
extends AbstractPublicationCreateForm<CollectedVolume, CollectedVolumeItem> {
|
|
||||||
|
|
||||||
public CollectedVolumeCreateForm(
|
|
||||||
final ItemSelectionModel itemModel,
|
|
||||||
final CreationSelector creationSelector,
|
|
||||||
final StringParameter selectedLanguageParam
|
|
||||||
) {
|
|
||||||
super(itemModel, creationSelector, selectedLanguageParam);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected CollectedVolume createPublication() {
|
|
||||||
return new CollectedVolume();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,144 +0,0 @@
|
||||||
/*
|
|
||||||
* 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 com.arsdigita.cms.contenttypes.ui;
|
|
||||||
|
|
||||||
import com.arsdigita.bebop.Component;
|
|
||||||
import com.arsdigita.bebop.Label;
|
|
||||||
import com.arsdigita.bebop.PageState;
|
|
||||||
import com.arsdigita.bebop.parameters.StringParameter;
|
|
||||||
import com.arsdigita.cms.ItemSelectionModel;
|
|
||||||
import com.arsdigita.cms.ui.authoring.AuthoringKitWizard;
|
|
||||||
import com.arsdigita.cms.ui.authoring.BasicPageForm;
|
|
||||||
import com.arsdigita.cms.ui.authoring.SimpleEditStep;
|
|
||||||
import com.arsdigita.cms.ui.workflow.WorkflowLockedComponentAccess;
|
|
||||||
import com.arsdigita.domain.DomainService;
|
|
||||||
import com.arsdigita.globalization.GlobalizedMessage;
|
|
||||||
import com.arsdigita.toolbox.ui.DomainObjectPropertySheet;
|
|
||||||
|
|
||||||
import org.scientificcms.publications.SciPublicationsConstants;
|
|
||||||
|
|
||||||
import static com.arsdigita.cms.contenttypes.ui.PublicationPropertiesStep.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
|
||||||
*/
|
|
||||||
public class CollectedVolumePropertiesStep
|
|
||||||
extends PublicationWithPublisherPropertiesStep {
|
|
||||||
|
|
||||||
private final StringParameter selectedLangParam;
|
|
||||||
|
|
||||||
public CollectedVolumePropertiesStep(
|
|
||||||
final ItemSelectionModel itemModel,
|
|
||||||
final AuthoringKitWizard parent,
|
|
||||||
final StringParameter selectedLangParam
|
|
||||||
) {
|
|
||||||
super(itemModel, parent, selectedLangParam);
|
|
||||||
this.selectedLangParam = selectedLangParam;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Component getCollectedVolumePropertySheet(
|
|
||||||
final ItemSelectionModel itemModel,
|
|
||||||
final StringParameter selectedLangParam
|
|
||||||
) {
|
|
||||||
final DomainObjectPropertySheet sheet
|
|
||||||
= (DomainObjectPropertySheet) PublicationWithPublisherPropertiesStep
|
|
||||||
.getPublicationWithPublisherPropertySheet(
|
|
||||||
itemModel, selectedLangParam
|
|
||||||
);
|
|
||||||
|
|
||||||
sheet.add(new GlobalizedMessage(
|
|
||||||
"publications.ui.collectedVolume.reviewed",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
),
|
|
||||||
CollectedVolumeController.PEER_REVIEWED,
|
|
||||||
new ReviewedFormatter());
|
|
||||||
|
|
||||||
return sheet;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void addBasicProperties(
|
|
||||||
ItemSelectionModel itemModel,
|
|
||||||
AuthoringKitWizard parent) {
|
|
||||||
SimpleEditStep basicProperties = new SimpleEditStep(
|
|
||||||
itemModel, parent, selectedLangParam, EDIT_SHEET_NAME);
|
|
||||||
|
|
||||||
final BasicPageForm editBasicSheet
|
|
||||||
= new CollectedVolumePropertyForm(
|
|
||||||
itemModel,
|
|
||||||
this,
|
|
||||||
selectedLangParam
|
|
||||||
);
|
|
||||||
|
|
||||||
basicProperties.add(
|
|
||||||
EDIT_SHEET_NAME,
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.collected_volume.edit_basic_sheet",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
),
|
|
||||||
new WorkflowLockedComponentAccess(editBasicSheet, itemModel),
|
|
||||||
editBasicSheet.getSaveCancelSection().getCancelButton());
|
|
||||||
|
|
||||||
basicProperties.setDisplayComponent(
|
|
||||||
getCollectedVolumePropertySheet(itemModel, selectedLangParam));
|
|
||||||
|
|
||||||
getSegmentedPanel().addSegment(
|
|
||||||
new Label(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.publication.basic_properties",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
)
|
|
||||||
),
|
|
||||||
basicProperties);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void addSteps(
|
|
||||||
final ItemSelectionModel itemModel, final AuthoringKitWizard parent
|
|
||||||
) {
|
|
||||||
super.addSteps(itemModel, parent);
|
|
||||||
|
|
||||||
addStep(
|
|
||||||
new CollectedVolumeArticlesStep(
|
|
||||||
itemModel, parent, selectedLangParam
|
|
||||||
),
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.collected_volume_articles",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class ReviewedFormatter
|
|
||||||
extends DomainService
|
|
||||||
implements DomainObjectPropertySheet.AttributeFormatter {
|
|
||||||
|
|
||||||
public ReviewedFormatter() {
|
|
||||||
super();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String format(
|
|
||||||
final Object obj, final String attribute, final PageState state
|
|
||||||
) {
|
|
||||||
if ((get(obj, attribute) != null)
|
|
||||||
&& (get(obj, attribute) instanceof Boolean)
|
|
||||||
&& ((Boolean) get(obj, attribute) == true)) {
|
|
||||||
return (String) new GlobalizedMessage(
|
|
||||||
"publications.ui.collectedVolume.reviewed.yes",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
).localize();
|
|
||||||
} else {
|
|
||||||
return (String) new GlobalizedMessage(
|
|
||||||
"publications.ui.collectedVolume.reviewed.no",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
).localize();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,155 +0,0 @@
|
||||||
/*
|
|
||||||
* 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 com.arsdigita.cms.contenttypes.ui;
|
|
||||||
|
|
||||||
import com.arsdigita.bebop.FormData;
|
|
||||||
import com.arsdigita.bebop.FormProcessException;
|
|
||||||
import com.arsdigita.bebop.Label;
|
|
||||||
import com.arsdigita.bebop.PageState;
|
|
||||||
import com.arsdigita.bebop.event.FormInitListener;
|
|
||||||
import com.arsdigita.bebop.event.FormProcessListener;
|
|
||||||
import com.arsdigita.bebop.event.FormSectionEvent;
|
|
||||||
import com.arsdigita.bebop.event.FormSubmissionListener;
|
|
||||||
import com.arsdigita.bebop.form.CheckboxGroup;
|
|
||||||
import com.arsdigita.bebop.form.Option;
|
|
||||||
import com.arsdigita.bebop.parameters.StringParameter;
|
|
||||||
import com.arsdigita.cms.ItemSelectionModel;
|
|
||||||
import com.arsdigita.cms.ui.authoring.SelectedLanguageUtil;
|
|
||||||
import com.arsdigita.globalization.GlobalizedMessage;
|
|
||||||
|
|
||||||
import org.apache.logging.log4j.LogManager;
|
|
||||||
import org.apache.logging.log4j.Logger;
|
|
||||||
import org.libreccm.cdi.utils.CdiUtil;
|
|
||||||
import org.scientificcms.publications.CollectedVolume;
|
|
||||||
import org.scientificcms.publications.SciPublicationsConstants;
|
|
||||||
import org.scientificcms.publications.contenttypes.CollectedVolumeItem;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Locale;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
|
||||||
*/
|
|
||||||
public class CollectedVolumePropertyForm
|
|
||||||
extends PublicationWithPublisherPropertyForm
|
|
||||||
implements FormProcessListener,
|
|
||||||
FormInitListener,
|
|
||||||
FormSubmissionListener {
|
|
||||||
|
|
||||||
private static final Logger LOGGER = LogManager.getLogger(
|
|
||||||
CollectedVolumePropertyForm.class
|
|
||||||
);
|
|
||||||
|
|
||||||
private static final String ID = "CollectedVolumeEdit";
|
|
||||||
|
|
||||||
private final StringParameter selectedLangParam;
|
|
||||||
|
|
||||||
private final CollectedVolumePropertiesStep step;
|
|
||||||
|
|
||||||
private CheckboxGroup reviewed;
|
|
||||||
|
|
||||||
public CollectedVolumePropertyForm(
|
|
||||||
final ItemSelectionModel itemModel,
|
|
||||||
final StringParameter selectedLangParam
|
|
||||||
) {
|
|
||||||
this(itemModel, null, selectedLangParam);
|
|
||||||
}
|
|
||||||
|
|
||||||
public CollectedVolumePropertyForm(
|
|
||||||
final ItemSelectionModel itemModel,
|
|
||||||
CollectedVolumePropertiesStep step,
|
|
||||||
final StringParameter selectedLangParam
|
|
||||||
) {
|
|
||||||
super(itemModel, step, selectedLangParam);
|
|
||||||
this.step = step;
|
|
||||||
this.selectedLangParam = selectedLangParam;
|
|
||||||
addSubmissionListener(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void addWidgets() {
|
|
||||||
|
|
||||||
super.addWidgets();
|
|
||||||
|
|
||||||
reviewed = new CheckboxGroup("reviewedGroup");
|
|
||||||
reviewed.addOption(
|
|
||||||
new Option(
|
|
||||||
CollectedVolumeController.PEER_REVIEWED,
|
|
||||||
new Label(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.collectedVolume.reviewed",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
reviewed.setLabel(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.collectedVolume.reviewed",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
)
|
|
||||||
);
|
|
||||||
add(reviewed);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void init(final FormSectionEvent event) throws FormProcessException {
|
|
||||||
super.init(event);
|
|
||||||
|
|
||||||
final FormData data = event.getFormData();
|
|
||||||
final CollectedVolumeItem collectedVolumeItem
|
|
||||||
= (CollectedVolumeItem) super
|
|
||||||
.initBasicWidgets(event);
|
|
||||||
|
|
||||||
final CollectedVolume collectedVolume = collectedVolumeItem
|
|
||||||
.getPublication();
|
|
||||||
|
|
||||||
if ((collectedVolume.getPeerReviewed() != null)
|
|
||||||
&& (collectedVolume.getPeerReviewed())) {
|
|
||||||
reviewed.setValue(
|
|
||||||
event.getPageState(),
|
|
||||||
new String[]{CollectedVolumeController.PEER_REVIEWED}
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
reviewed.setValue(event.getPageState(), null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void process(final FormSectionEvent event) throws
|
|
||||||
FormProcessException {
|
|
||||||
super.process(event);
|
|
||||||
|
|
||||||
final PageState state = event.getPageState();
|
|
||||||
final CollectedVolumeItem collectedVolumeItem
|
|
||||||
= (CollectedVolumeItem) super
|
|
||||||
.processBasicWidgets(event);
|
|
||||||
|
|
||||||
if ((collectedVolumeItem != null)
|
|
||||||
&& getSaveCancelSection().getSaveButton().isSelected(state)) {
|
|
||||||
|
|
||||||
final CollectedVolumeController controller = CdiUtil
|
|
||||||
.createCdiUtil()
|
|
||||||
.findBean(CollectedVolumeController.class);
|
|
||||||
final Map<String, Object> data = new HashMap<>();
|
|
||||||
if (reviewed.getValue(state.getPageState()) == null) {
|
|
||||||
data.put(CollectedVolumeController.PEER_REVIEWED, false);
|
|
||||||
} else {
|
|
||||||
data.put(CollectedVolumeController.PEER_REVIEWED, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
controller.save(
|
|
||||||
collectedVolumeItem.getPublication().getPublicationId(),
|
|
||||||
SelectedLanguageUtil.selectedLocale(
|
|
||||||
state, selectedLangParam
|
|
||||||
),
|
|
||||||
data);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,133 +0,0 @@
|
||||||
/*
|
|
||||||
* 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 com.arsdigita.cms.contenttypes.ui;
|
|
||||||
|
|
||||||
import org.librecms.assets.Organization;
|
|
||||||
import org.librecms.contentsection.AssetRepository;
|
|
||||||
import org.scientificcms.publications.Expertise;
|
|
||||||
import org.scientificcms.publications.PublicationRepository;
|
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import javax.enterprise.context.RequestScoped;
|
|
||||||
import javax.inject.Inject;
|
|
||||||
import javax.transaction.Transactional;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
|
||||||
*/
|
|
||||||
@RequestScoped
|
|
||||||
public class ExpertiseController {
|
|
||||||
|
|
||||||
public static final String PLACE = "place";
|
|
||||||
public static final String NUMBER_OF_PAGES = "numberOfPages";
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
private AssetRepository assetRepository;
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
private PublicationRepository publicationRepository;
|
|
||||||
|
|
||||||
@Transactional(Transactional.TxType.REQUIRED)
|
|
||||||
public void save(final long expertiseId, final Map<String, Object> data) {
|
|
||||||
final Expertise expertise = publicationRepository
|
|
||||||
.findByIdAndType(expertiseId, Expertise.class)
|
|
||||||
.orElseThrow(
|
|
||||||
() -> new IllegalArgumentException(
|
|
||||||
String.format("No Expertise with ID %d found.", expertiseId)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
if (data.containsKey(PLACE)) {
|
|
||||||
expertise.setPlace((String) data.get(PLACE));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (data.containsKey(NUMBER_OF_PAGES)) {
|
|
||||||
expertise.setNumberOfPages((Integer) data.get(NUMBER_OF_PAGES));
|
|
||||||
}
|
|
||||||
|
|
||||||
publicationRepository.save(expertise);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Transactional
|
|
||||||
public void setOrderer(final long expertiseId, final long ordererId) {
|
|
||||||
final Expertise expertise = publicationRepository
|
|
||||||
.findByIdAndType(expertiseId, Expertise.class)
|
|
||||||
.orElseThrow(
|
|
||||||
() -> new IllegalArgumentException(
|
|
||||||
String.format("No Expertise with ID %d found.", expertiseId)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
final Organization orderer = assetRepository
|
|
||||||
.findById(ordererId, Organization.class)
|
|
||||||
.orElseThrow(
|
|
||||||
() -> new IllegalArgumentException(
|
|
||||||
String.format(
|
|
||||||
"No Organization with ID %d found.", ordererId
|
|
||||||
)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
expertise.setOrderer(orderer);
|
|
||||||
publicationRepository.save(expertise);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Transactional
|
|
||||||
public void unsetOrderer(final long expertiseId) {
|
|
||||||
final Expertise expertise = publicationRepository
|
|
||||||
.findByIdAndType(expertiseId, Expertise.class)
|
|
||||||
.orElseThrow(
|
|
||||||
() -> new IllegalArgumentException(
|
|
||||||
String.format("No Expertise with ID %d found.", expertiseId)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
expertise.setOrderer(null);
|
|
||||||
publicationRepository.save(expertise);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Transactional
|
|
||||||
public void setOrganization(
|
|
||||||
final long expertiseId, final long organizationId
|
|
||||||
) {
|
|
||||||
final Expertise expertise = publicationRepository
|
|
||||||
.findByIdAndType(expertiseId, Expertise.class)
|
|
||||||
.orElseThrow(
|
|
||||||
() -> new IllegalArgumentException(
|
|
||||||
String.format("No Expertise with ID %d found.", expertiseId)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
final Organization organization = assetRepository
|
|
||||||
.findById(organizationId, Organization.class)
|
|
||||||
.orElseThrow(
|
|
||||||
() -> new IllegalArgumentException(
|
|
||||||
String.format(
|
|
||||||
"No Organization with ID %d found.", organizationId
|
|
||||||
)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
expertise.setOrganization(organization);
|
|
||||||
publicationRepository.save(expertise);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Transactional
|
|
||||||
public void unsetOrganization(final long expertiseId) {
|
|
||||||
final Expertise expertise = publicationRepository
|
|
||||||
.findByIdAndType(expertiseId, Expertise.class)
|
|
||||||
.orElseThrow(
|
|
||||||
() -> new IllegalArgumentException(
|
|
||||||
String.format("No Expertise with ID %d found.", expertiseId)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
expertise.setOrganization(null);
|
|
||||||
publicationRepository.save(expertise);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,33 +0,0 @@
|
||||||
/*
|
|
||||||
* 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 com.arsdigita.cms.contenttypes.ui;
|
|
||||||
|
|
||||||
import com.arsdigita.bebop.parameters.StringParameter;
|
|
||||||
import com.arsdigita.cms.ItemSelectionModel;
|
|
||||||
import com.arsdigita.cms.ui.authoring.CreationSelector;
|
|
||||||
|
|
||||||
import org.scientificcms.publications.Expertise;
|
|
||||||
import org.scientificcms.publications.contenttypes.ExpertiseItem;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
|
||||||
*/
|
|
||||||
public class ExpertiseCreateForm
|
|
||||||
extends AbstractPublicationCreateForm<Expertise, ExpertiseItem>{
|
|
||||||
|
|
||||||
public ExpertiseCreateForm(final ItemSelectionModel itemModel,
|
|
||||||
final CreationSelector creationSelector,
|
|
||||||
final StringParameter selectedLanguageParam) {
|
|
||||||
super(itemModel, creationSelector, selectedLanguageParam);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected Expertise createPublication() {
|
|
||||||
return new Expertise();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,91 +0,0 @@
|
||||||
/*
|
|
||||||
* 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 com.arsdigita.cms.contenttypes.ui;
|
|
||||||
|
|
||||||
import com.arsdigita.bebop.FormData;
|
|
||||||
import com.arsdigita.bebop.FormProcessException;
|
|
||||||
import com.arsdigita.bebop.PageState;
|
|
||||||
import com.arsdigita.bebop.event.FormInitListener;
|
|
||||||
import com.arsdigita.bebop.event.FormProcessListener;
|
|
||||||
import com.arsdigita.bebop.event.FormSectionEvent;
|
|
||||||
import com.arsdigita.bebop.parameters.StringParameter;
|
|
||||||
import com.arsdigita.cms.ItemSelectionModel;
|
|
||||||
import com.arsdigita.cms.ui.assets.AssetSearchWidget;
|
|
||||||
import com.arsdigita.cms.ui.authoring.BasicItemForm;
|
|
||||||
import com.arsdigita.globalization.GlobalizedMessage;
|
|
||||||
|
|
||||||
import org.hibernate.resource.beans.container.internal.CdiBasedBeanContainer;
|
|
||||||
import org.libreccm.cdi.utils.CdiUtil;
|
|
||||||
import org.librecms.assets.Organization;
|
|
||||||
import org.scientificcms.publications.SciPublicationsConstants;
|
|
||||||
import org.scientificcms.publications.contenttypes.ExpertiseItem;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
|
||||||
*/
|
|
||||||
public class ExpertiseOrdererForm
|
|
||||||
extends BasicItemForm
|
|
||||||
implements FormProcessListener, FormInitListener {
|
|
||||||
|
|
||||||
private static final String ORGA_SEARCH = "expertiseOrderer";
|
|
||||||
|
|
||||||
private AssetSearchWidget orgaSearch;
|
|
||||||
|
|
||||||
private final ItemSelectionModel itemModel;
|
|
||||||
|
|
||||||
public ExpertiseOrdererForm(
|
|
||||||
final ItemSelectionModel itemModel,
|
|
||||||
final StringParameter selectedLangParam
|
|
||||||
) {
|
|
||||||
super("ExpertiseOrdererForm", itemModel, selectedLangParam);
|
|
||||||
this.itemModel = itemModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void addWidgets() {
|
|
||||||
orgaSearch = new AssetSearchWidget(
|
|
||||||
ORGA_SEARCH, Organization.class
|
|
||||||
);
|
|
||||||
orgaSearch.setLabel(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.expertise.orderer",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
)
|
|
||||||
);
|
|
||||||
add(orgaSearch);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void init(final FormSectionEvent event) throws FormProcessException {
|
|
||||||
final PageState state = event.getPageState();
|
|
||||||
|
|
||||||
setVisible(state, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void process(final FormSectionEvent event)
|
|
||||||
throws FormProcessException {
|
|
||||||
final PageState state = event.getPageState();
|
|
||||||
final ExpertiseItem expertise = (ExpertiseItem) itemModel.
|
|
||||||
getSelectedItem(state);
|
|
||||||
|
|
||||||
if (getSaveCancelSection().getSaveButton().isSelected(state)) {
|
|
||||||
final Organization orderer = (Organization) orgaSearch
|
|
||||||
.getValue(state);
|
|
||||||
final ExpertiseController controller = CdiUtil
|
|
||||||
.createCdiUtil()
|
|
||||||
.findBean(ExpertiseController.class);
|
|
||||||
controller.setOrderer(
|
|
||||||
expertise.getPublication().getPublicationId(),
|
|
||||||
orderer.getObjectId()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
init(event);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,266 +0,0 @@
|
||||||
/*
|
|
||||||
* 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 com.arsdigita.cms.contenttypes.ui;
|
|
||||||
|
|
||||||
import com.arsdigita.bebop.Component;
|
|
||||||
import com.arsdigita.bebop.ControlLink;
|
|
||||||
import com.arsdigita.bebop.Label;
|
|
||||||
import com.arsdigita.bebop.PageState;
|
|
||||||
import com.arsdigita.bebop.Table;
|
|
||||||
import com.arsdigita.bebop.Text;
|
|
||||||
import com.arsdigita.bebop.event.TableActionEvent;
|
|
||||||
import com.arsdigita.bebop.event.TableActionListener;
|
|
||||||
import com.arsdigita.bebop.table.TableCellRenderer;
|
|
||||||
import com.arsdigita.bebop.table.TableColumn;
|
|
||||||
import com.arsdigita.bebop.table.TableColumnModel;
|
|
||||||
import com.arsdigita.bebop.table.TableModel;
|
|
||||||
import com.arsdigita.bebop.table.TableModelBuilder;
|
|
||||||
import com.arsdigita.cms.ItemSelectionModel;
|
|
||||||
import com.arsdigita.globalization.GlobalizedMessage;
|
|
||||||
import com.arsdigita.util.LockableImpl;
|
|
||||||
|
|
||||||
import org.libreccm.cdi.utils.CdiUtil;
|
|
||||||
import org.libreccm.security.PermissionChecker;
|
|
||||||
import org.librecms.assets.Organization;
|
|
||||||
import org.librecms.contentsection.privileges.ItemPrivileges;
|
|
||||||
import org.scientificcms.publications.Expertise;
|
|
||||||
import org.scientificcms.publications.SciPublicationsConstants;
|
|
||||||
import org.scientificcms.publications.contenttypes.ExpertiseItem;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
|
||||||
*/
|
|
||||||
public class ExpertiseOrdererSheet
|
|
||||||
extends Table
|
|
||||||
implements TableActionListener {
|
|
||||||
|
|
||||||
private static final String TABLE_COL_EDIT = "table_col_edit";
|
|
||||||
|
|
||||||
private static final String TABLE_COL_DEL = "table_col_del";
|
|
||||||
|
|
||||||
private final ItemSelectionModel itemModel;
|
|
||||||
|
|
||||||
public ExpertiseOrdererSheet(final ItemSelectionModel itemModel) {
|
|
||||||
super();
|
|
||||||
|
|
||||||
this.itemModel = itemModel;
|
|
||||||
|
|
||||||
setEmptyView(
|
|
||||||
new Label(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.expertise.orderer.none",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
final TableColumnModel columnModel = getColumnModel();
|
|
||||||
columnModel.add(
|
|
||||||
new TableColumn(
|
|
||||||
0,
|
|
||||||
new Label(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.expertise.orderer",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
)
|
|
||||||
),
|
|
||||||
TABLE_COL_EDIT
|
|
||||||
)
|
|
||||||
);
|
|
||||||
columnModel.add(
|
|
||||||
new TableColumn(
|
|
||||||
1,
|
|
||||||
new Label(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.expertise.orderer.remove",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
)
|
|
||||||
),
|
|
||||||
TABLE_COL_DEL
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
setModelBuilder(new ExpertiseOrganizationSheetModelBuilder(itemModel));
|
|
||||||
columnModel.get(0).setCellRenderer(new EditCellRenderer());
|
|
||||||
columnModel.get(1).setCellRenderer(new DeleteCellRenderer());
|
|
||||||
|
|
||||||
addTableActionListener(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void cellSelected(final TableActionEvent event) {
|
|
||||||
final PageState state = event.getPageState();
|
|
||||||
|
|
||||||
final ExpertiseItem expertiseItem = (ExpertiseItem) itemModel
|
|
||||||
.getSelectedItem(state);
|
|
||||||
|
|
||||||
final TableColumn column = getColumnModel().get(event.getColumn());
|
|
||||||
|
|
||||||
if (column.getHeaderKey().toString().equals(TABLE_COL_EDIT)) {
|
|
||||||
// Nothing
|
|
||||||
} else if (column.getHeaderKey().toString().equals(TABLE_COL_DEL)) {
|
|
||||||
final ExpertiseController controller = CdiUtil
|
|
||||||
.createCdiUtil()
|
|
||||||
.findBean(ExpertiseController.class);
|
|
||||||
controller.unsetOrderer(
|
|
||||||
expertiseItem.getPublication().getPublicationId()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void headSelected(final TableActionEvent event) {
|
|
||||||
//Nothing to do
|
|
||||||
}
|
|
||||||
|
|
||||||
private class ExpertiseOrganizationSheetModelBuilder
|
|
||||||
extends LockableImpl
|
|
||||||
implements TableModelBuilder {
|
|
||||||
|
|
||||||
private final ItemSelectionModel itemModel;
|
|
||||||
|
|
||||||
public ExpertiseOrganizationSheetModelBuilder(
|
|
||||||
final ItemSelectionModel itemModel
|
|
||||||
) {
|
|
||||||
this.itemModel = itemModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public final TableModel makeModel(
|
|
||||||
final Table table, final PageState state
|
|
||||||
) {
|
|
||||||
table.getRowSelectionModel().clearSelection(state);
|
|
||||||
final ExpertiseItem expertiseItem = (ExpertiseItem) itemModel
|
|
||||||
.getSelectedItem(state);
|
|
||||||
return new ExpertiseOrganizationSheetModel(
|
|
||||||
table, state, expertiseItem.getPublication()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private class ExpertiseOrganizationSheetModel implements TableModel {
|
|
||||||
|
|
||||||
private final Table table;
|
|
||||||
private final Organization orderer;
|
|
||||||
private boolean done;
|
|
||||||
|
|
||||||
public ExpertiseOrganizationSheetModel(
|
|
||||||
final Table table,
|
|
||||||
final PageState state,
|
|
||||||
final Expertise expertise
|
|
||||||
) {
|
|
||||||
this.table = table;
|
|
||||||
orderer = expertise.getOrderer();
|
|
||||||
done = orderer != null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getColumnCount() {
|
|
||||||
return table.getColumnModel().size();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean nextRow() {
|
|
||||||
boolean ret;
|
|
||||||
|
|
||||||
if (done) {
|
|
||||||
ret = true;
|
|
||||||
done = false;
|
|
||||||
} else {
|
|
||||||
ret = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object getElementAt(final int columnIndex) {
|
|
||||||
switch (columnIndex) {
|
|
||||||
case 0:
|
|
||||||
return orderer.getTitle();
|
|
||||||
case 1:
|
|
||||||
return new Label(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.expertise.orderer.remove",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
)
|
|
||||||
);
|
|
||||||
default:
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object getKeyAt(final int columnIndex) {
|
|
||||||
return orderer.getObjectId();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private class EditCellRenderer
|
|
||||||
extends LockableImpl
|
|
||||||
implements TableCellRenderer {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public final Component getComponent(
|
|
||||||
final Table table,
|
|
||||||
final PageState state,
|
|
||||||
final Object value,
|
|
||||||
final boolean isSelected,
|
|
||||||
final Object key,
|
|
||||||
final int row,
|
|
||||||
final int column
|
|
||||||
) {
|
|
||||||
return new Text((String) value);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private class DeleteCellRenderer
|
|
||||||
extends LockableImpl
|
|
||||||
implements TableCellRenderer {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Component getComponent(
|
|
||||||
final Table table,
|
|
||||||
final PageState state,
|
|
||||||
final Object value,
|
|
||||||
final boolean isSelected,
|
|
||||||
final Object key,
|
|
||||||
final int row,
|
|
||||||
final int col
|
|
||||||
) {
|
|
||||||
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
|
|
||||||
|
|
||||||
final PermissionChecker permissionChecker = cdiUtil
|
|
||||||
.findBean(PermissionChecker.class);
|
|
||||||
|
|
||||||
final ExpertiseItem expertiseItem = (ExpertiseItem) itemModel
|
|
||||||
.getSelectedItem(state);
|
|
||||||
|
|
||||||
final boolean canEdit = permissionChecker.isPermitted(
|
|
||||||
ItemPrivileges.DELETE, expertiseItem
|
|
||||||
);
|
|
||||||
|
|
||||||
if (canEdit) {
|
|
||||||
final ControlLink link = new ControlLink((Component) value);
|
|
||||||
link.setConfirmation(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publication.ui.expertise.orderer.remove.confirm",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
)
|
|
||||||
);
|
|
||||||
return link;
|
|
||||||
} else {
|
|
||||||
return new Text("");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,63 +0,0 @@
|
||||||
/*
|
|
||||||
* 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 com.arsdigita.cms.contenttypes.ui;
|
|
||||||
|
|
||||||
import com.arsdigita.bebop.parameters.StringParameter;
|
|
||||||
import com.arsdigita.cms.ItemSelectionModel;
|
|
||||||
import com.arsdigita.cms.ui.authoring.AuthoringKitWizard;
|
|
||||||
import com.arsdigita.cms.ui.authoring.BasicItemForm;
|
|
||||||
import com.arsdigita.cms.ui.authoring.SimpleEditStep;
|
|
||||||
import com.arsdigita.cms.ui.workflow.WorkflowLockedComponentAccess;
|
|
||||||
import com.arsdigita.globalization.GlobalizedMessage;
|
|
||||||
|
|
||||||
import org.scientificcms.publications.SciPublicationsConstants;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
|
||||||
*/
|
|
||||||
public class ExpertiseOrdererStep extends SimpleEditStep {
|
|
||||||
|
|
||||||
private static final String SET_EXPERTISE_ORDERER_STEP
|
|
||||||
= "setExpertiseOrdererStep";
|
|
||||||
|
|
||||||
public ExpertiseOrdererStep(
|
|
||||||
final ItemSelectionModel itemModel,
|
|
||||||
final AuthoringKitWizard parent,
|
|
||||||
final StringParameter selectedLangParam
|
|
||||||
) {
|
|
||||||
this(itemModel, parent, selectedLangParam, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ExpertiseOrdererStep(
|
|
||||||
final ItemSelectionModel itemModel,
|
|
||||||
final AuthoringKitWizard parent,
|
|
||||||
final StringParameter selectedLangParam,
|
|
||||||
final String prefix
|
|
||||||
) {
|
|
||||||
super(itemModel, parent, selectedLangParam, prefix);
|
|
||||||
|
|
||||||
final BasicItemForm setOrdererForm = new ExpertiseOrdererForm(
|
|
||||||
itemModel,
|
|
||||||
selectedLangParam
|
|
||||||
);
|
|
||||||
add(
|
|
||||||
SET_EXPERTISE_ORDERER_STEP,
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.expertise.setOrderer",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
),
|
|
||||||
new WorkflowLockedComponentAccess(setOrdererForm, itemModel),
|
|
||||||
setOrdererForm.getSaveCancelSection().getCancelButton()
|
|
||||||
);
|
|
||||||
|
|
||||||
final ExpertiseOrdererSheet sheet = new ExpertiseOrdererSheet(
|
|
||||||
itemModel
|
|
||||||
);
|
|
||||||
setDisplayComponent(sheet);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,89 +0,0 @@
|
||||||
/*
|
|
||||||
* 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 com.arsdigita.cms.contenttypes.ui;
|
|
||||||
|
|
||||||
import com.arsdigita.bebop.FormProcessException;
|
|
||||||
import com.arsdigita.bebop.PageState;
|
|
||||||
import com.arsdigita.bebop.event.FormInitListener;
|
|
||||||
import com.arsdigita.bebop.event.FormProcessListener;
|
|
||||||
import com.arsdigita.bebop.event.FormSectionEvent;
|
|
||||||
import com.arsdigita.bebop.parameters.StringParameter;
|
|
||||||
import com.arsdigita.cms.ItemSelectionModel;
|
|
||||||
import com.arsdigita.cms.ui.assets.AssetSearchWidget;
|
|
||||||
import com.arsdigita.cms.ui.authoring.BasicItemForm;
|
|
||||||
import com.arsdigita.globalization.GlobalizedMessage;
|
|
||||||
|
|
||||||
import org.libreccm.cdi.utils.CdiUtil;
|
|
||||||
import org.librecms.assets.Organization;
|
|
||||||
import org.scientificcms.publications.SciPublicationsConstants;
|
|
||||||
import org.scientificcms.publications.contenttypes.ExpertiseItem;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
|
||||||
*/
|
|
||||||
public class ExpertiseOrganizationForm
|
|
||||||
extends BasicItemForm
|
|
||||||
implements FormProcessListener, FormInitListener {
|
|
||||||
|
|
||||||
private static final String ORGA_SEARCH = "expertiseOrganization";
|
|
||||||
|
|
||||||
private AssetSearchWidget orgaSearch;
|
|
||||||
|
|
||||||
private final ItemSelectionModel itemModel;
|
|
||||||
|
|
||||||
public ExpertiseOrganizationForm(
|
|
||||||
final ItemSelectionModel itemModel,
|
|
||||||
final StringParameter selectedLangParam
|
|
||||||
) {
|
|
||||||
super("ExpertiseOrganizationForm", itemModel, selectedLangParam);
|
|
||||||
this.itemModel = itemModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void addWidgets() {
|
|
||||||
orgaSearch = new AssetSearchWidget(
|
|
||||||
ORGA_SEARCH, Organization.class
|
|
||||||
);
|
|
||||||
orgaSearch.setLabel(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.expertise.orderer",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
)
|
|
||||||
);
|
|
||||||
add(orgaSearch);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void init(final FormSectionEvent event) throws FormProcessException {
|
|
||||||
final PageState state = event.getPageState();
|
|
||||||
|
|
||||||
setVisible(state, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void process(final FormSectionEvent event)
|
|
||||||
throws FormProcessException {
|
|
||||||
final PageState state = event.getPageState();
|
|
||||||
final ExpertiseItem expertise = (ExpertiseItem) itemModel.
|
|
||||||
getSelectedItem(state);
|
|
||||||
|
|
||||||
if (getSaveCancelSection().getSaveButton().isSelected(state)) {
|
|
||||||
final Organization organization = (Organization) orgaSearch
|
|
||||||
.getValue(state);
|
|
||||||
final ExpertiseController controller = CdiUtil
|
|
||||||
.createCdiUtil()
|
|
||||||
.findBean(ExpertiseController.class);
|
|
||||||
controller.setOrganization(
|
|
||||||
expertise.getPublication().getPublicationId(),
|
|
||||||
organization.getObjectId()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
init(event);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,268 +0,0 @@
|
||||||
/*
|
|
||||||
* 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 com.arsdigita.cms.contenttypes.ui;
|
|
||||||
|
|
||||||
import com.arsdigita.bebop.Component;
|
|
||||||
import com.arsdigita.bebop.ControlLink;
|
|
||||||
import com.arsdigita.bebop.Label;
|
|
||||||
import com.arsdigita.bebop.PageState;
|
|
||||||
import com.arsdigita.bebop.Table;
|
|
||||||
import com.arsdigita.bebop.Text;
|
|
||||||
import com.arsdigita.bebop.event.TableActionEvent;
|
|
||||||
import com.arsdigita.bebop.event.TableActionListener;
|
|
||||||
import com.arsdigita.bebop.table.TableCellRenderer;
|
|
||||||
import com.arsdigita.bebop.table.TableColumn;
|
|
||||||
import com.arsdigita.bebop.table.TableColumnModel;
|
|
||||||
import com.arsdigita.bebop.table.TableModel;
|
|
||||||
import com.arsdigita.bebop.table.TableModelBuilder;
|
|
||||||
import com.arsdigita.cms.ItemSelectionModel;
|
|
||||||
import com.arsdigita.globalization.GlobalizedMessage;
|
|
||||||
import com.arsdigita.util.LockableImpl;
|
|
||||||
|
|
||||||
import org.libreccm.cdi.utils.CdiUtil;
|
|
||||||
import org.libreccm.security.PermissionChecker;
|
|
||||||
import org.librecms.assets.Organization;
|
|
||||||
import org.librecms.contentsection.privileges.ItemPrivileges;
|
|
||||||
import org.scientificcms.publications.Expertise;
|
|
||||||
import org.scientificcms.publications.SciPublicationsConstants;
|
|
||||||
import org.scientificcms.publications.contenttypes.ExpertiseItem;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
|
||||||
*/
|
|
||||||
public class ExpertiseOrganizationSheet
|
|
||||||
extends Table
|
|
||||||
implements TableActionListener {
|
|
||||||
|
|
||||||
private static final String TABLE_COL_EDIT = "table_col_edit";
|
|
||||||
|
|
||||||
private static final String TABLE_COL_DEL = "table_col_del";
|
|
||||||
|
|
||||||
private final ItemSelectionModel itemModel;
|
|
||||||
|
|
||||||
public ExpertiseOrganizationSheet(final ItemSelectionModel itemModel) {
|
|
||||||
super();
|
|
||||||
|
|
||||||
this.itemModel = itemModel;
|
|
||||||
|
|
||||||
setEmptyView(
|
|
||||||
new Label(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.expertise.organization.none",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
final TableColumnModel columnModel = getColumnModel();
|
|
||||||
columnModel.add(
|
|
||||||
new TableColumn(
|
|
||||||
0,
|
|
||||||
new Label(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.expertise.organization",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
)
|
|
||||||
),
|
|
||||||
TABLE_COL_EDIT
|
|
||||||
)
|
|
||||||
);
|
|
||||||
columnModel.add(
|
|
||||||
new TableColumn(
|
|
||||||
1,
|
|
||||||
new Label(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.expertise.organization.remove",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
)
|
|
||||||
),
|
|
||||||
TABLE_COL_DEL
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
setModelBuilder(new ExpertiseOrganizationSheetModelBuilder(itemModel));
|
|
||||||
columnModel.get(0).setCellRenderer(new EditCellRenderer());
|
|
||||||
columnModel.get(1).setCellRenderer(new DeleteCellRenderer());
|
|
||||||
|
|
||||||
addTableActionListener(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void cellSelected(final TableActionEvent event) {
|
|
||||||
final PageState state = event.getPageState();
|
|
||||||
|
|
||||||
final ExpertiseItem expertiseItem = (ExpertiseItem) itemModel
|
|
||||||
.getSelectedItem(state);
|
|
||||||
|
|
||||||
final TableColumn column = getColumnModel().get(event.getColumn());
|
|
||||||
|
|
||||||
if (column.getHeaderKey().toString().equals(TABLE_COL_EDIT)) {
|
|
||||||
// Nothing
|
|
||||||
} else if (column.getHeaderKey().toString().equals(TABLE_COL_DEL)) {
|
|
||||||
final ExpertiseController controller = CdiUtil
|
|
||||||
.createCdiUtil()
|
|
||||||
.findBean(ExpertiseController.class);
|
|
||||||
controller.unsetOrganization(
|
|
||||||
expertiseItem.getPublication().getPublicationId()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void headSelected(final TableActionEvent event) {
|
|
||||||
//Nothing to do
|
|
||||||
}
|
|
||||||
|
|
||||||
private class ExpertiseOrganizationSheetModelBuilder
|
|
||||||
extends LockableImpl
|
|
||||||
implements TableModelBuilder {
|
|
||||||
|
|
||||||
private final ItemSelectionModel itemModel;
|
|
||||||
|
|
||||||
public ExpertiseOrganizationSheetModelBuilder(
|
|
||||||
final ItemSelectionModel itemModel
|
|
||||||
) {
|
|
||||||
this.itemModel = itemModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public final TableModel makeModel(
|
|
||||||
final Table table, final PageState state
|
|
||||||
) {
|
|
||||||
table.getRowSelectionModel().clearSelection(state);
|
|
||||||
final ExpertiseItem expertiseItem = (ExpertiseItem) itemModel
|
|
||||||
.getSelectedItem(state);
|
|
||||||
return new ExpertiseOrganizationSheetModel(
|
|
||||||
table, state, expertiseItem.getPublication()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private class ExpertiseOrganizationSheetModel implements TableModel {
|
|
||||||
|
|
||||||
private final Table table;
|
|
||||||
|
|
||||||
private final Organization organization;
|
|
||||||
|
|
||||||
private boolean done;
|
|
||||||
|
|
||||||
public ExpertiseOrganizationSheetModel(
|
|
||||||
final Table table,
|
|
||||||
final PageState state,
|
|
||||||
final Expertise expertise
|
|
||||||
) {
|
|
||||||
this.table = table;
|
|
||||||
organization = expertise.getOrganization();
|
|
||||||
done = organization != null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getColumnCount() {
|
|
||||||
return table.getColumnModel().size();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean nextRow() {
|
|
||||||
boolean ret;
|
|
||||||
|
|
||||||
if (done) {
|
|
||||||
ret = true;
|
|
||||||
done = false;
|
|
||||||
} else {
|
|
||||||
ret = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object getElementAt(final int columnIndex) {
|
|
||||||
switch (columnIndex) {
|
|
||||||
case 0:
|
|
||||||
return organization.getTitle();
|
|
||||||
case 1:
|
|
||||||
return new Label(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.expertise.organization.remove",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
)
|
|
||||||
);
|
|
||||||
default:
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object getKeyAt(final int columnIndex) {
|
|
||||||
return organization.getObjectId();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private class EditCellRenderer
|
|
||||||
extends LockableImpl
|
|
||||||
implements TableCellRenderer {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public final Component getComponent(
|
|
||||||
final Table table,
|
|
||||||
final PageState state,
|
|
||||||
final Object value,
|
|
||||||
final boolean isSelected,
|
|
||||||
final Object key,
|
|
||||||
final int row,
|
|
||||||
final int column
|
|
||||||
) {
|
|
||||||
return new Text((String) value);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private class DeleteCellRenderer
|
|
||||||
extends LockableImpl
|
|
||||||
implements TableCellRenderer {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Component getComponent(
|
|
||||||
final Table table,
|
|
||||||
final PageState state,
|
|
||||||
final Object value,
|
|
||||||
final boolean isSelected,
|
|
||||||
final Object key,
|
|
||||||
final int row,
|
|
||||||
final int col
|
|
||||||
) {
|
|
||||||
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
|
|
||||||
|
|
||||||
final PermissionChecker permissionChecker = cdiUtil
|
|
||||||
.findBean(PermissionChecker.class);
|
|
||||||
|
|
||||||
final ExpertiseItem expertiseItem = (ExpertiseItem) itemModel
|
|
||||||
.getSelectedItem(state);
|
|
||||||
|
|
||||||
final boolean canEdit = permissionChecker.isPermitted(
|
|
||||||
ItemPrivileges.DELETE, expertiseItem
|
|
||||||
);
|
|
||||||
|
|
||||||
if (canEdit) {
|
|
||||||
final ControlLink link = new ControlLink((Component) value);
|
|
||||||
link.setConfirmation(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publication.ui.expertise.organization.remove.confirm",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
)
|
|
||||||
);
|
|
||||||
return link;
|
|
||||||
} else {
|
|
||||||
return new Text("");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,63 +0,0 @@
|
||||||
/*
|
|
||||||
* 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 com.arsdigita.cms.contenttypes.ui;
|
|
||||||
|
|
||||||
import com.arsdigita.bebop.parameters.StringParameter;
|
|
||||||
import com.arsdigita.cms.ItemSelectionModel;
|
|
||||||
import com.arsdigita.cms.ui.authoring.AuthoringKitWizard;
|
|
||||||
import com.arsdigita.cms.ui.authoring.BasicItemForm;
|
|
||||||
import com.arsdigita.cms.ui.authoring.SimpleEditStep;
|
|
||||||
import com.arsdigita.cms.ui.workflow.WorkflowLockedComponentAccess;
|
|
||||||
import com.arsdigita.globalization.GlobalizedMessage;
|
|
||||||
|
|
||||||
import org.scientificcms.publications.SciPublicationsConstants;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
|
||||||
*/
|
|
||||||
public class ExpertiseOrganizationStep extends SimpleEditStep {
|
|
||||||
|
|
||||||
private static final String SET_EXPERTISE_ORGANIZATION_STEP
|
|
||||||
= "setExpertiseOrganizationStep";
|
|
||||||
|
|
||||||
public ExpertiseOrganizationStep(
|
|
||||||
final ItemSelectionModel itemModel,
|
|
||||||
final AuthoringKitWizard parent,
|
|
||||||
final StringParameter selectedLangParam
|
|
||||||
) {
|
|
||||||
this(itemModel, parent, selectedLangParam, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ExpertiseOrganizationStep(
|
|
||||||
final ItemSelectionModel itemModel,
|
|
||||||
final AuthoringKitWizard parent,
|
|
||||||
final StringParameter selectedLangParam,
|
|
||||||
final String prefix
|
|
||||||
) {
|
|
||||||
super(itemModel, parent, selectedLangParam, prefix);
|
|
||||||
|
|
||||||
final BasicItemForm setOrgaForm = new ExpertiseOrganizationForm(
|
|
||||||
itemModel, selectedLangParam
|
|
||||||
);
|
|
||||||
add(
|
|
||||||
SET_EXPERTISE_ORGANIZATION_STEP,
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.expertise.setOrganization",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
),
|
|
||||||
new WorkflowLockedComponentAccess(
|
|
||||||
setOrgaForm, itemModel),
|
|
||||||
setOrgaForm.getSaveCancelSection().getCancelButton()
|
|
||||||
);
|
|
||||||
|
|
||||||
final ExpertiseOrganizationSheet sheet = new ExpertiseOrganizationSheet(
|
|
||||||
itemModel
|
|
||||||
);
|
|
||||||
setDisplayComponent(sheet);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,131 +0,0 @@
|
||||||
/*
|
|
||||||
* 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 com.arsdigita.cms.contenttypes.ui;
|
|
||||||
|
|
||||||
import com.arsdigita.bebop.Component;
|
|
||||||
import com.arsdigita.bebop.Label;
|
|
||||||
import com.arsdigita.bebop.parameters.StringParameter;
|
|
||||||
import com.arsdigita.cms.ItemSelectionModel;
|
|
||||||
import com.arsdigita.cms.ui.authoring.AuthoringKitWizard;
|
|
||||||
import com.arsdigita.cms.ui.authoring.BasicPageForm;
|
|
||||||
import com.arsdigita.cms.ui.authoring.SimpleEditStep;
|
|
||||||
import com.arsdigita.cms.ui.workflow.WorkflowLockedComponentAccess;
|
|
||||||
import com.arsdigita.globalization.GlobalizedMessage;
|
|
||||||
import com.arsdigita.toolbox.ui.DomainObjectPropertySheet;
|
|
||||||
|
|
||||||
import org.scientificcms.publications.SciPublicationsConstants;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
|
||||||
*/
|
|
||||||
public class ExpertisePropertiesStep extends PublicationPropertiesStep {
|
|
||||||
|
|
||||||
private final StringParameter selectedLangParam;
|
|
||||||
|
|
||||||
public ExpertisePropertiesStep(
|
|
||||||
final ItemSelectionModel itemModel,
|
|
||||||
final AuthoringKitWizard parent,
|
|
||||||
final StringParameter selectedLangParam
|
|
||||||
) {
|
|
||||||
super(itemModel, parent, selectedLangParam);
|
|
||||||
this.selectedLangParam = selectedLangParam;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Component getExpertisePropertySheet(
|
|
||||||
final ItemSelectionModel itemModel,
|
|
||||||
final StringParameter selectedLangParam
|
|
||||||
) {
|
|
||||||
final DomainObjectPropertySheet sheet
|
|
||||||
= (DomainObjectPropertySheet) getPublicationPropertySheet(
|
|
||||||
itemModel, selectedLangParam);
|
|
||||||
|
|
||||||
sheet.add(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.expertise.place",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
),
|
|
||||||
ExpertiseController.PLACE
|
|
||||||
);
|
|
||||||
|
|
||||||
sheet.add(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.expertise.number_of_pages",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
),
|
|
||||||
ExpertiseController.NUMBER_OF_PAGES
|
|
||||||
);
|
|
||||||
|
|
||||||
return sheet;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void addBasicProperties(
|
|
||||||
final ItemSelectionModel itemModel,
|
|
||||||
final AuthoringKitWizard parent
|
|
||||||
) {
|
|
||||||
final SimpleEditStep basicProperties = new SimpleEditStep(
|
|
||||||
itemModel,
|
|
||||||
parent,
|
|
||||||
selectedLangParam,
|
|
||||||
EDIT_SHEET_NAME
|
|
||||||
);
|
|
||||||
|
|
||||||
final BasicPageForm editBasicSheet
|
|
||||||
= new ExpertisePropertyForm(
|
|
||||||
itemModel, this, selectedLangParam
|
|
||||||
);
|
|
||||||
|
|
||||||
basicProperties.add(
|
|
||||||
EDIT_SHEET_NAME,
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.expertise.edit_basic_sheet",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
),
|
|
||||||
new WorkflowLockedComponentAccess(
|
|
||||||
editBasicSheet,
|
|
||||||
itemModel
|
|
||||||
),
|
|
||||||
editBasicSheet.getSaveCancelSection().getCancelButton()
|
|
||||||
);
|
|
||||||
|
|
||||||
basicProperties.setDisplayComponent(
|
|
||||||
getExpertisePropertySheet(itemModel, selectedLangParam)
|
|
||||||
);
|
|
||||||
|
|
||||||
getSegmentedPanel().addSegment(
|
|
||||||
new Label(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.publication.basic_properties"
|
|
||||||
)
|
|
||||||
),
|
|
||||||
basicProperties
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void addSteps(
|
|
||||||
final ItemSelectionModel itemModel, final AuthoringKitWizard parent
|
|
||||||
) {
|
|
||||||
super.addSteps(itemModel, parent);
|
|
||||||
|
|
||||||
addStep(
|
|
||||||
new ExpertiseOrganizationStep(itemModel, parent, selectedLangParam),
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.expertise.setOrganization",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
)
|
|
||||||
);
|
|
||||||
addStep(
|
|
||||||
new ExpertiseOrdererStep(itemModel, parent, selectedLangParam),
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.expertise.setOrderer",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,141 +0,0 @@
|
||||||
/*
|
|
||||||
* 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 com.arsdigita.cms.contenttypes.ui;
|
|
||||||
|
|
||||||
import com.arsdigita.bebop.FormData;
|
|
||||||
import com.arsdigita.bebop.FormProcessException;
|
|
||||||
import com.arsdigita.bebop.PageState;
|
|
||||||
import com.arsdigita.bebop.event.FormInitListener;
|
|
||||||
import com.arsdigita.bebop.event.FormProcessListener;
|
|
||||||
import com.arsdigita.bebop.event.FormSectionEvent;
|
|
||||||
import com.arsdigita.bebop.event.FormSubmissionListener;
|
|
||||||
import com.arsdigita.bebop.form.TextField;
|
|
||||||
import com.arsdigita.bebop.parameters.IntegerParameter;
|
|
||||||
import com.arsdigita.bebop.parameters.ParameterModel;
|
|
||||||
import com.arsdigita.bebop.parameters.StringParameter;
|
|
||||||
import com.arsdigita.cms.ItemSelectionModel;
|
|
||||||
import com.arsdigita.globalization.GlobalizedMessage;
|
|
||||||
|
|
||||||
import org.libreccm.cdi.utils.CdiUtil;
|
|
||||||
import org.scientificcms.publications.Expertise;
|
|
||||||
import org.scientificcms.publications.SciPublicationsConstants;
|
|
||||||
import org.scientificcms.publications.contenttypes.ExpertiseItem;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
|
||||||
*/
|
|
||||||
public class ExpertisePropertyForm
|
|
||||||
extends PublicationPropertyForm
|
|
||||||
implements FormInitListener, FormProcessListener, FormSubmissionListener {
|
|
||||||
|
|
||||||
public static final String ID = "ExpertiseEdit";
|
|
||||||
|
|
||||||
private final ExpertisePropertiesStep step;
|
|
||||||
|
|
||||||
public ExpertisePropertyForm(
|
|
||||||
final ItemSelectionModel itemModel,
|
|
||||||
final StringParameter selectedLangParam
|
|
||||||
) {
|
|
||||||
this(itemModel, null, selectedLangParam);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ExpertisePropertyForm(
|
|
||||||
final ItemSelectionModel itemModel,
|
|
||||||
final ExpertisePropertiesStep step,
|
|
||||||
final StringParameter selectedLangParam
|
|
||||||
) {
|
|
||||||
super(itemModel, step, selectedLangParam);
|
|
||||||
this.step = step;
|
|
||||||
addSubmissionListener(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void addWidgets() {
|
|
||||||
|
|
||||||
super.addWidgets();
|
|
||||||
|
|
||||||
final ParameterModel placeParam = new StringParameter(
|
|
||||||
ExpertiseController.PLACE
|
|
||||||
);
|
|
||||||
final TextField place = new TextField(placeParam);
|
|
||||||
place.setLabel(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.expertise.place",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
)
|
|
||||||
);
|
|
||||||
add(place);
|
|
||||||
|
|
||||||
final ParameterModel numberOfPagesParam = new IntegerParameter(
|
|
||||||
ExpertiseController.NUMBER_OF_PAGES
|
|
||||||
);
|
|
||||||
final TextField numberOfPages = new TextField(numberOfPagesParam);
|
|
||||||
numberOfPages.setLabel(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.expertise.number_of_pages",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
)
|
|
||||||
);
|
|
||||||
add(numberOfPages);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void init(final FormSectionEvent event) throws FormProcessException {
|
|
||||||
super.init(event);
|
|
||||||
|
|
||||||
final FormData data = event.getFormData();
|
|
||||||
final ExpertiseItem expertiseItem = (ExpertiseItem) initBasicWidgets(
|
|
||||||
event);
|
|
||||||
|
|
||||||
final Expertise expertise = expertiseItem.getPublication();
|
|
||||||
|
|
||||||
data.put(ExpertiseController.PLACE, expertise.getPlace());
|
|
||||||
data.put(
|
|
||||||
ExpertiseController.NUMBER_OF_PAGES,
|
|
||||||
expertise.getNumberOfPages()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void process(final FormSectionEvent event)
|
|
||||||
throws FormProcessException {
|
|
||||||
super.process(event);
|
|
||||||
|
|
||||||
final FormData formData = event.getFormData();
|
|
||||||
final PageState state = event.getPageState();
|
|
||||||
final ExpertiseItem expertiseItem = (ExpertiseItem) processBasicWidgets(
|
|
||||||
event
|
|
||||||
);
|
|
||||||
|
|
||||||
if ((expertiseItem != null)
|
|
||||||
&& getSaveCancelSection().getSaveButton().isSelected(state)) {
|
|
||||||
|
|
||||||
final Map<String, Object> data = new HashMap<>();
|
|
||||||
data.put(
|
|
||||||
ExpertiseController.PLACE,
|
|
||||||
formData.get(ExpertiseController.PLACE)
|
|
||||||
);
|
|
||||||
data.put(
|
|
||||||
ExpertiseController.NUMBER_OF_PAGES,
|
|
||||||
formData.get(ExpertiseController.NUMBER_OF_PAGES)
|
|
||||||
);
|
|
||||||
|
|
||||||
final ExpertiseController controller = CdiUtil
|
|
||||||
.createCdiUtil()
|
|
||||||
.findBean(ExpertiseController.class);
|
|
||||||
|
|
||||||
controller.save(
|
|
||||||
expertiseItem.getPublication().getPublicationId(),
|
|
||||||
data
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,57 +0,0 @@
|
||||||
/*
|
|
||||||
* 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 com.arsdigita.cms.contenttypes.ui;
|
|
||||||
|
|
||||||
import org.scientificcms.publications.GreyLiterature;
|
|
||||||
import org.scientificcms.publications.PublicationRepository;
|
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import javax.enterprise.context.RequestScoped;
|
|
||||||
import javax.inject.Inject;
|
|
||||||
import javax.transaction.Transactional;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
|
||||||
*/
|
|
||||||
@RequestScoped
|
|
||||||
public class GreyLiteratureController {
|
|
||||||
|
|
||||||
public static final String START_PAGE = "startPage";
|
|
||||||
public static final String END_PAGE = "endPage";
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
private PublicationRepository publicationRepository;
|
|
||||||
|
|
||||||
@Transactional(Transactional.TxType.REQUIRED)
|
|
||||||
public void saveGreyLiterature(
|
|
||||||
final long greyLiteratureId, final Map<String, Object> data
|
|
||||||
) {
|
|
||||||
final GreyLiterature publication = publicationRepository
|
|
||||||
.findByIdAndType(greyLiteratureId, GreyLiterature.class
|
|
||||||
)
|
|
||||||
.orElseThrow(
|
|
||||||
() -> new IllegalArgumentException(
|
|
||||||
String.format(
|
|
||||||
"No GreyLiterature publication with ID %d found",
|
|
||||||
greyLiteratureId
|
|
||||||
)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
if (data.containsKey(START_PAGE)) {
|
|
||||||
publication.setStartPage((Integer) data.get(START_PAGE));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (data.containsKey(END_PAGE)) {
|
|
||||||
publication.setEndPage((Integer) data.get(END_PAGE));
|
|
||||||
}
|
|
||||||
|
|
||||||
publicationRepository.save(publication);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,35 +0,0 @@
|
||||||
/*
|
|
||||||
* 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 com.arsdigita.cms.contenttypes.ui;
|
|
||||||
|
|
||||||
import com.arsdigita.bebop.parameters.StringParameter;
|
|
||||||
import com.arsdigita.cms.ItemSelectionModel;
|
|
||||||
import com.arsdigita.cms.ui.authoring.CreationSelector;
|
|
||||||
|
|
||||||
import org.scientificcms.publications.GreyLiterature;
|
|
||||||
import org.scientificcms.publications.contenttypes.GreyLiteratureItem;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
|
||||||
*/
|
|
||||||
public class GreyLiteratureCreateForm
|
|
||||||
extends AbstractPublicationCreateForm<GreyLiterature, GreyLiteratureItem> {
|
|
||||||
|
|
||||||
public GreyLiteratureCreateForm(
|
|
||||||
final ItemSelectionModel itemModel,
|
|
||||||
final CreationSelector creationSelector,
|
|
||||||
final StringParameter selectedLanguageParam
|
|
||||||
) {
|
|
||||||
super(itemModel, creationSelector, selectedLanguageParam);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected GreyLiterature createPublication() {
|
|
||||||
return new GreyLiterature();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,111 +0,0 @@
|
||||||
/*
|
|
||||||
* 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 com.arsdigita.cms.contenttypes.ui;
|
|
||||||
|
|
||||||
import com.arsdigita.bebop.Component;
|
|
||||||
import com.arsdigita.bebop.Label;
|
|
||||||
import com.arsdigita.bebop.parameters.StringParameter;
|
|
||||||
import com.arsdigita.cms.ItemSelectionModel;
|
|
||||||
import com.arsdigita.cms.ui.authoring.AuthoringKitWizard;
|
|
||||||
import com.arsdigita.cms.ui.authoring.BasicPageForm;
|
|
||||||
import com.arsdigita.cms.ui.authoring.SimpleEditStep;
|
|
||||||
import com.arsdigita.cms.ui.workflow.WorkflowLockedComponentAccess;
|
|
||||||
import com.arsdigita.globalization.GlobalizedMessage;
|
|
||||||
import com.arsdigita.toolbox.ui.DomainObjectPropertySheet;
|
|
||||||
|
|
||||||
import org.scientificcms.publications.SciPublicationsConstants;
|
|
||||||
|
|
||||||
import static com.arsdigita.cms.contenttypes.ui.PublicationPropertiesStep.*;
|
|
||||||
import static com.arsdigita.cms.contenttypes.ui.UnPublishedPropertiesStep.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
|
||||||
*/
|
|
||||||
public class GreyLiteraturePropertiesStep extends UnPublishedPropertiesStep {
|
|
||||||
|
|
||||||
private final StringParameter selectedLangParam;
|
|
||||||
|
|
||||||
public GreyLiteraturePropertiesStep(
|
|
||||||
final ItemSelectionModel itemModel,
|
|
||||||
final AuthoringKitWizard parent,
|
|
||||||
final StringParameter selectedLangParam
|
|
||||||
) {
|
|
||||||
super(itemModel, parent, selectedLangParam);
|
|
||||||
this.selectedLangParam = selectedLangParam;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Component getGreyLiteraturePropertySheet(
|
|
||||||
final ItemSelectionModel itemModel,
|
|
||||||
final StringParameter selectedLangParam
|
|
||||||
) {
|
|
||||||
final DomainObjectPropertySheet sheet
|
|
||||||
= (DomainObjectPropertySheet) getUnPublishedPropertySheet(
|
|
||||||
itemModel, selectedLangParam
|
|
||||||
);
|
|
||||||
|
|
||||||
sheet.add(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.greyliterature.pages_from",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
),
|
|
||||||
GreyLiteratureController.START_PAGE
|
|
||||||
);
|
|
||||||
|
|
||||||
sheet.add(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.greyliterature.pages_to",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
),
|
|
||||||
GreyLiteratureController.END_PAGE);
|
|
||||||
|
|
||||||
return sheet;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void addBasicProperties(
|
|
||||||
final ItemSelectionModel itemModel,
|
|
||||||
final AuthoringKitWizard parent
|
|
||||||
) {
|
|
||||||
final SimpleEditStep basicProperties = new SimpleEditStep(
|
|
||||||
itemModel,
|
|
||||||
parent,
|
|
||||||
selectedLangParam,
|
|
||||||
EDIT_SHEET_NAME
|
|
||||||
);
|
|
||||||
|
|
||||||
final BasicPageForm editBasicSheet = new GreyLiteraturePropertyForm(
|
|
||||||
itemModel,
|
|
||||||
this,
|
|
||||||
selectedLangParam
|
|
||||||
);
|
|
||||||
|
|
||||||
basicProperties.add(
|
|
||||||
EDIT_SHEET_NAME,
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.greyliterature.edit_basic_sheet",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
),
|
|
||||||
new WorkflowLockedComponentAccess(
|
|
||||||
editBasicSheet,
|
|
||||||
itemModel
|
|
||||||
),
|
|
||||||
editBasicSheet.getSaveCancelSection().getCancelButton());
|
|
||||||
|
|
||||||
basicProperties.setDisplayComponent(
|
|
||||||
getGreyLiteraturePropertySheet(itemModel, selectedLangParam));
|
|
||||||
|
|
||||||
getSegmentedPanel().addSegment(
|
|
||||||
new Label(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.publication.basic_properties",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
)
|
|
||||||
),
|
|
||||||
basicProperties);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,140 +0,0 @@
|
||||||
/*
|
|
||||||
* 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 com.arsdigita.cms.contenttypes.ui;
|
|
||||||
|
|
||||||
import com.arsdigita.bebop.FormData;
|
|
||||||
import com.arsdigita.bebop.FormProcessException;
|
|
||||||
import com.arsdigita.bebop.PageState;
|
|
||||||
import com.arsdigita.bebop.event.FormInitListener;
|
|
||||||
import com.arsdigita.bebop.event.FormProcessListener;
|
|
||||||
import com.arsdigita.bebop.event.FormSectionEvent;
|
|
||||||
import com.arsdigita.bebop.event.FormSubmissionListener;
|
|
||||||
import com.arsdigita.bebop.form.TextField;
|
|
||||||
import com.arsdigita.bebop.parameters.IntegerParameter;
|
|
||||||
import com.arsdigita.bebop.parameters.ParameterModel;
|
|
||||||
import com.arsdigita.bebop.parameters.StringParameter;
|
|
||||||
import com.arsdigita.cms.ItemSelectionModel;
|
|
||||||
import com.arsdigita.globalization.GlobalizedMessage;
|
|
||||||
|
|
||||||
import org.libreccm.cdi.utils.CdiUtil;
|
|
||||||
import org.scientificcms.publications.GreyLiterature;
|
|
||||||
import org.scientificcms.publications.SciPublicationsConstants;
|
|
||||||
import org.scientificcms.publications.contenttypes.GreyLiteratureItem;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
|
||||||
*/
|
|
||||||
public class GreyLiteraturePropertyForm extends UnPublishedPropertyForm
|
|
||||||
implements FormInitListener,
|
|
||||||
FormProcessListener, FormSubmissionListener {
|
|
||||||
|
|
||||||
public static final String ID = "GreyLiteratureEdit";
|
|
||||||
|
|
||||||
private GreyLiteraturePropertiesStep step;
|
|
||||||
|
|
||||||
public GreyLiteraturePropertyForm(
|
|
||||||
final ItemSelectionModel itemModel,
|
|
||||||
final StringParameter selectedLangParam
|
|
||||||
) {
|
|
||||||
this(itemModel, null, selectedLangParam);
|
|
||||||
}
|
|
||||||
|
|
||||||
public GreyLiteraturePropertyForm(
|
|
||||||
final ItemSelectionModel itemModel,
|
|
||||||
final GreyLiteraturePropertiesStep step,
|
|
||||||
final StringParameter selectedLangParam
|
|
||||||
) {
|
|
||||||
super(itemModel, step, selectedLangParam);
|
|
||||||
this.step = step;
|
|
||||||
addSubmissionListener(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void addWidgets() {
|
|
||||||
|
|
||||||
super.addWidgets();
|
|
||||||
|
|
||||||
final ParameterModel fromParam = new IntegerParameter(
|
|
||||||
GreyLiteratureController.START_PAGE
|
|
||||||
);
|
|
||||||
final TextField pagesFrom = new TextField(fromParam);
|
|
||||||
pagesFrom.setLabel(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.greyliterature.pages_from",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
)
|
|
||||||
);
|
|
||||||
add(pagesFrom);
|
|
||||||
|
|
||||||
final ParameterModel toParam = new IntegerParameter(
|
|
||||||
GreyLiteratureController.END_PAGE);
|
|
||||||
final TextField pagesTo = new TextField(toParam);
|
|
||||||
pagesTo.setLabel(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.greyliterature.pages_to",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
)
|
|
||||||
);
|
|
||||||
add(pagesTo);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void init(final FormSectionEvent event) throws FormProcessException {
|
|
||||||
super.init(event);
|
|
||||||
|
|
||||||
final FormData data = event.getFormData();
|
|
||||||
final GreyLiteratureItem greyItem
|
|
||||||
= (GreyLiteratureItem) initBasicWidgets(
|
|
||||||
event);
|
|
||||||
final GreyLiterature grey = greyItem.getPublication();
|
|
||||||
|
|
||||||
data.put(
|
|
||||||
GreyLiteratureController.START_PAGE, grey.getStartPage()
|
|
||||||
);
|
|
||||||
data.put(
|
|
||||||
GreyLiteratureController.END_PAGE, grey.getEndPage()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void process(final FormSectionEvent event)
|
|
||||||
throws FormProcessException {
|
|
||||||
super.process(event);
|
|
||||||
|
|
||||||
final FormData formData = event.getFormData();
|
|
||||||
final PageState state = event.getPageState();
|
|
||||||
final GreyLiteratureItem greyItem
|
|
||||||
= (GreyLiteratureItem) processBasicWidgets(
|
|
||||||
event);
|
|
||||||
|
|
||||||
if ((greyItem != null)
|
|
||||||
&& getSaveCancelSection().getSaveButton().isSelected(state)) {
|
|
||||||
|
|
||||||
final Map<String, Object> data = new HashMap<>();
|
|
||||||
data.put(
|
|
||||||
GreyLiteratureController.START_PAGE,
|
|
||||||
formData.get(GreyLiteratureController.START_PAGE)
|
|
||||||
);
|
|
||||||
data.put(
|
|
||||||
GreyLiteratureController.END_PAGE,
|
|
||||||
formData.get(GreyLiteratureController.END_PAGE)
|
|
||||||
);
|
|
||||||
|
|
||||||
final GreyLiteratureController controller = CdiUtil
|
|
||||||
.createCdiUtil()
|
|
||||||
.findBean(GreyLiteratureController.class);
|
|
||||||
controller.saveGreyLiterature(
|
|
||||||
greyItem.getPublication().getPublicationId(),
|
|
||||||
data
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,117 +0,0 @@
|
||||||
/*
|
|
||||||
* 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 com.arsdigita.cms.contenttypes.ui;
|
|
||||||
|
|
||||||
import org.scientificcms.publications.InProceedings;
|
|
||||||
import org.scientificcms.publications.Proceedings;
|
|
||||||
import org.scientificcms.publications.ProceedingsManager;
|
|
||||||
import org.scientificcms.publications.PublicationRepository;
|
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import javax.enterprise.context.RequestScoped;
|
|
||||||
import javax.inject.Inject;
|
|
||||||
import javax.transaction.Transactional;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
|
||||||
*/
|
|
||||||
@RequestScoped
|
|
||||||
public class InProceedingsController {
|
|
||||||
|
|
||||||
public static final String START_PAGE = "startPage";
|
|
||||||
public static final String END_PAGE = "endPage";
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
private ProceedingsManager proceedingsManager;
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
private PublicationRepository publicationRepository;
|
|
||||||
|
|
||||||
@Transactional(Transactional.TxType.REQUIRED)
|
|
||||||
public void saveInProceedings(
|
|
||||||
final long inProceedingsId,
|
|
||||||
final Map<String, Object> data
|
|
||||||
) {
|
|
||||||
final InProceedings inProceedings = publicationRepository
|
|
||||||
.findByIdAndType(inProceedingsId, InProceedings.class)
|
|
||||||
.orElseThrow(
|
|
||||||
() -> new IllegalArgumentException(
|
|
||||||
String.format(
|
|
||||||
"No InProceedings publication with ID %d found.",
|
|
||||||
inProceedingsId
|
|
||||||
)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
if (data.containsKey(START_PAGE)) {
|
|
||||||
inProceedings.setStartPage((Integer) data.get(START_PAGE));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (data.containsKey(END_PAGE)) {
|
|
||||||
inProceedings.setEndPage((Integer) data.get(END_PAGE));
|
|
||||||
}
|
|
||||||
|
|
||||||
publicationRepository.save(inProceedings);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setProceedings(
|
|
||||||
final long inProceedingsId, final long proceedingsId
|
|
||||||
) {
|
|
||||||
final InProceedings inProceedings = publicationRepository
|
|
||||||
.findByIdAndType(inProceedingsId, InProceedings.class)
|
|
||||||
.orElseThrow(
|
|
||||||
() -> new IllegalArgumentException(
|
|
||||||
String.format(
|
|
||||||
"No InProceedings publication with ID %d found.",
|
|
||||||
inProceedingsId
|
|
||||||
)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
final Proceedings proccedings = publicationRepository
|
|
||||||
.findByIdAndType(proceedingsId, Proceedings.class)
|
|
||||||
.orElseThrow(
|
|
||||||
() -> new IllegalArgumentException(
|
|
||||||
String.format(
|
|
||||||
"No Proceedings with ID %d found", proceedingsId
|
|
||||||
)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
proceedingsManager.addPaperToCollectedVolume(inProceedings, proccedings);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void unsetProcceedings(
|
|
||||||
final long inProceedingsId, final long proceedingsId
|
|
||||||
) {
|
|
||||||
final InProceedings inProceedings = publicationRepository
|
|
||||||
.findByIdAndType(inProceedingsId, InProceedings.class)
|
|
||||||
.orElseThrow(
|
|
||||||
() -> new IllegalArgumentException(
|
|
||||||
String.format(
|
|
||||||
"No InProceedings publication with ID %d found.",
|
|
||||||
inProceedingsId
|
|
||||||
)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
final Proceedings proccedings = publicationRepository
|
|
||||||
.findByIdAndType(proceedingsId, Proceedings.class)
|
|
||||||
.orElseThrow(
|
|
||||||
() -> new IllegalArgumentException(
|
|
||||||
String.format(
|
|
||||||
"No Proceedings with ID %d found", proceedingsId
|
|
||||||
)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
proceedingsManager.removeArticleFromCollectedVolume(
|
|
||||||
inProceedings, proccedings);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,33 +0,0 @@
|
||||||
/*
|
|
||||||
* 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 com.arsdigita.cms.contenttypes.ui;
|
|
||||||
|
|
||||||
import com.arsdigita.bebop.parameters.StringParameter;
|
|
||||||
import com.arsdigita.cms.ItemSelectionModel;
|
|
||||||
import com.arsdigita.cms.ui.authoring.CreationSelector;
|
|
||||||
|
|
||||||
import org.scientificcms.publications.InProceedings;
|
|
||||||
import org.scientificcms.publications.contenttypes.InProceedingsItem;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
|
||||||
*/
|
|
||||||
public class InProceedingsCreateForm
|
|
||||||
extends AbstractPublicationCreateForm<InProceedings, InProceedingsItem> {
|
|
||||||
|
|
||||||
public InProceedingsCreateForm(final ItemSelectionModel itemModel,
|
|
||||||
final CreationSelector creationSelector,
|
|
||||||
final StringParameter selectedLanguageParam) {
|
|
||||||
super(itemModel, creationSelector, selectedLanguageParam);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected InProceedings createPublication() {
|
|
||||||
return new InProceedings();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,91 +0,0 @@
|
||||||
/*
|
|
||||||
* 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 com.arsdigita.cms.contenttypes.ui;
|
|
||||||
|
|
||||||
import com.arsdigita.bebop.FormData;
|
|
||||||
import com.arsdigita.bebop.FormProcessException;
|
|
||||||
import com.arsdigita.bebop.PageState;
|
|
||||||
import com.arsdigita.bebop.event.FormInitListener;
|
|
||||||
import com.arsdigita.bebop.event.FormProcessListener;
|
|
||||||
import com.arsdigita.bebop.event.FormSectionEvent;
|
|
||||||
import com.arsdigita.bebop.parameters.StringParameter;
|
|
||||||
import com.arsdigita.cms.ItemSelectionModel;
|
|
||||||
import com.arsdigita.cms.ui.authoring.BasicItemForm;
|
|
||||||
import com.arsdigita.globalization.GlobalizedMessage;
|
|
||||||
|
|
||||||
import org.libreccm.cdi.utils.CdiUtil;
|
|
||||||
import org.scientificcms.publications.Proceedings;
|
|
||||||
import org.scientificcms.publications.SciPublicationsConstants;
|
|
||||||
import org.scientificcms.publications.contenttypes.InProceedingsItem;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
|
||||||
*/
|
|
||||||
public class InProceedingsProceedingsForm
|
|
||||||
extends BasicItemForm
|
|
||||||
implements FormProcessListener, FormInitListener {
|
|
||||||
|
|
||||||
private static final String PROCEEDINGS_SEARCH = "proceedings";
|
|
||||||
|
|
||||||
private PublicationSearchWidget proceedingsSearch;
|
|
||||||
|
|
||||||
public InProceedingsProceedingsForm(
|
|
||||||
final ItemSelectionModel itemModel,
|
|
||||||
final StringParameter selectedLangParam
|
|
||||||
) {
|
|
||||||
super("InProceedingsProceedings", itemModel, selectedLangParam);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void addWidgets() {
|
|
||||||
proceedingsSearch = new PublicationSearchWidget(
|
|
||||||
PROCEEDINGS_SEARCH, Proceedings.class
|
|
||||||
);
|
|
||||||
proceedingsSearch.setLabel(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.inProceedings.selectProceedings",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
)
|
|
||||||
);
|
|
||||||
add(proceedingsSearch);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void init(final FormSectionEvent event) throws FormProcessException {
|
|
||||||
final PageState state = event.getPageState();
|
|
||||||
|
|
||||||
setVisible(state, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void process(final FormSectionEvent event)
|
|
||||||
throws FormProcessException {
|
|
||||||
final FormData data = event.getFormData();
|
|
||||||
final PageState state = event.getPageState();
|
|
||||||
|
|
||||||
final InProceedingsItem inProceedingsItem
|
|
||||||
= (InProceedingsItem) getItemSelectionModel()
|
|
||||||
.getSelectedItem(state);
|
|
||||||
|
|
||||||
if (this.getSaveCancelSection().getSaveButton().isSelected(state)) {
|
|
||||||
final Proceedings proceedings = (Proceedings) data
|
|
||||||
.get(PROCEEDINGS_SEARCH);
|
|
||||||
|
|
||||||
final InProceedingsController controller = CdiUtil
|
|
||||||
.createCdiUtil()
|
|
||||||
.findBean(InProceedingsController.class);
|
|
||||||
|
|
||||||
controller.setProceedings(
|
|
||||||
inProceedingsItem.getPublication().getPublicationId(),
|
|
||||||
proceedings.getPublicationId()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
init(event);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,274 +0,0 @@
|
||||||
/*
|
|
||||||
* 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 com.arsdigita.cms.contenttypes.ui;
|
|
||||||
|
|
||||||
import com.arsdigita.bebop.Component;
|
|
||||||
import com.arsdigita.bebop.ControlLink;
|
|
||||||
import com.arsdigita.bebop.Label;
|
|
||||||
import com.arsdigita.bebop.Link;
|
|
||||||
import com.arsdigita.bebop.PageState;
|
|
||||||
import com.arsdigita.bebop.Table;
|
|
||||||
import com.arsdigita.bebop.Text;
|
|
||||||
import com.arsdigita.bebop.event.TableActionEvent;
|
|
||||||
import com.arsdigita.bebop.event.TableActionListener;
|
|
||||||
import com.arsdigita.bebop.table.TableCellRenderer;
|
|
||||||
import com.arsdigita.bebop.table.TableColumn;
|
|
||||||
import com.arsdigita.bebop.table.TableColumnModel;
|
|
||||||
import com.arsdigita.bebop.table.TableModel;
|
|
||||||
import com.arsdigita.bebop.table.TableModelBuilder;
|
|
||||||
import com.arsdigita.cms.ItemSelectionModel;
|
|
||||||
import com.arsdigita.cms.dispatcher.Utilities;
|
|
||||||
import com.arsdigita.globalization.GlobalizedMessage;
|
|
||||||
import com.arsdigita.util.LockableImpl;
|
|
||||||
|
|
||||||
import org.hibernate.secure.spi.PermissionCheckEntityInformation;
|
|
||||||
import org.libreccm.cdi.utils.CdiUtil;
|
|
||||||
import org.libreccm.security.PermissionChecker;
|
|
||||||
import org.librecms.contentsection.privileges.ItemPrivileges;
|
|
||||||
import org.scientificcms.publications.InProceedings;
|
|
||||||
import org.scientificcms.publications.Proceedings;
|
|
||||||
import org.scientificcms.publications.SciPublicationsConstants;
|
|
||||||
import org.scientificcms.publications.contenttypes.InProceedingsItem;
|
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
|
||||||
*/
|
|
||||||
public class InProceedingsProceedingsSheet
|
|
||||||
extends Table
|
|
||||||
implements TableActionListener {
|
|
||||||
|
|
||||||
private static final String TABLE_COL_EDIT = "table_col_edit";
|
|
||||||
|
|
||||||
private static final String TABLE_COL_DEL = "table_col_del";
|
|
||||||
|
|
||||||
private final ItemSelectionModel itemModel;
|
|
||||||
|
|
||||||
public InProceedingsProceedingsSheet(final ItemSelectionModel itemModel) {
|
|
||||||
super();
|
|
||||||
this.itemModel = itemModel;
|
|
||||||
|
|
||||||
setEmptyView(
|
|
||||||
new Label(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.inProceedings.proceedings.none",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
final TableColumnModel columnModel = getColumnModel();
|
|
||||||
columnModel.add(
|
|
||||||
new TableColumn(
|
|
||||||
0,
|
|
||||||
new Label(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.inProceedings.proceedings",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
)
|
|
||||||
),
|
|
||||||
TABLE_COL_EDIT
|
|
||||||
)
|
|
||||||
);
|
|
||||||
columnModel.add(
|
|
||||||
new TableColumn(
|
|
||||||
1,
|
|
||||||
new Label(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.inProceedings.proceedings.remove",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
)
|
|
||||||
),
|
|
||||||
TABLE_COL_DEL
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
setModelBuilder(new InProceedingsProceedingsSheetModelBuilder(
|
|
||||||
itemModel));
|
|
||||||
columnModel.get(0).setCellRenderer(new EditCellRenderer());
|
|
||||||
columnModel.get(1).setCellRenderer(new DeleteCellRenderer());
|
|
||||||
|
|
||||||
addTableActionListener(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void cellSelected(final TableActionEvent event) {
|
|
||||||
PageState state = event.getPageState();
|
|
||||||
|
|
||||||
final InProceedingsItem inProceedingsItem
|
|
||||||
= (InProceedingsItem) itemModel.
|
|
||||||
getSelectedItem(state);
|
|
||||||
final InProceedings inProceedings = inProceedingsItem.getPublication();
|
|
||||||
|
|
||||||
final TableColumn column = getColumnModel().get(event.getColumn());
|
|
||||||
|
|
||||||
if (column.getHeaderKey().toString().equals(TABLE_COL_EDIT)) {
|
|
||||||
// Nothing
|
|
||||||
} else if (column.getHeaderKey().toString().equals(TABLE_COL_DEL)) {
|
|
||||||
final InProceedingsController controller = CdiUtil
|
|
||||||
.createCdiUtil()
|
|
||||||
.findBean(InProceedingsController.class);
|
|
||||||
controller.unsetProcceedings(
|
|
||||||
inProceedings.getPublicationId(),
|
|
||||||
inProceedings.getProceedings().getPublicationId()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void headSelected(final TableActionEvent event) {
|
|
||||||
//Nothing to do
|
|
||||||
}
|
|
||||||
|
|
||||||
private class InProceedingsProceedingsSheetModelBuilder
|
|
||||||
extends LockableImpl
|
|
||||||
implements TableModelBuilder {
|
|
||||||
|
|
||||||
private ItemSelectionModel itemModel;
|
|
||||||
|
|
||||||
public InProceedingsProceedingsSheetModelBuilder(
|
|
||||||
ItemSelectionModel itemModel) {
|
|
||||||
this.itemModel = itemModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public TableModel makeModel(final Table table, final PageState state) {
|
|
||||||
table.getRowSelectionModel().clearSelection(state);
|
|
||||||
final InProceedingsItem inProceedingsItem
|
|
||||||
= (InProceedingsItem) itemModel.
|
|
||||||
getSelectedItem(state);
|
|
||||||
return new InProceedingsProceedingsSheetModel(
|
|
||||||
table,
|
|
||||||
state,
|
|
||||||
inProceedingsItem.getPublication()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private class InProceedingsProceedingsSheetModel implements TableModel {
|
|
||||||
|
|
||||||
private final Table table;
|
|
||||||
private final Proceedings proceedings;
|
|
||||||
private boolean done;
|
|
||||||
|
|
||||||
public InProceedingsProceedingsSheetModel(
|
|
||||||
final Table table,
|
|
||||||
final PageState state,
|
|
||||||
final InProceedings inProceedings
|
|
||||||
) {
|
|
||||||
this.table = table;
|
|
||||||
this.proceedings = inProceedings.getProceedings();
|
|
||||||
if (proceedings == null) {
|
|
||||||
done = false;
|
|
||||||
} else {
|
|
||||||
done = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getColumnCount() {
|
|
||||||
return table.getColumnModel().size();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean nextRow() {
|
|
||||||
boolean ret;
|
|
||||||
|
|
||||||
if (done) {
|
|
||||||
ret = true;
|
|
||||||
done = false;
|
|
||||||
} else {
|
|
||||||
ret = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object getElementAt(final int columnIndex) {
|
|
||||||
switch (columnIndex) {
|
|
||||||
case 0:
|
|
||||||
return proceedings.getTitle();
|
|
||||||
case 1:
|
|
||||||
return new Label(new GlobalizedMessage(
|
|
||||||
"publications.ui.inProceedings.proceedings.remove"));
|
|
||||||
default:
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object getKeyAt(final int columnIndex) {
|
|
||||||
return proceedings.getPublicationId();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private class EditCellRenderer
|
|
||||||
extends LockableImpl
|
|
||||||
implements TableCellRenderer {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Component getComponent(
|
|
||||||
final Table table,
|
|
||||||
final PageState state,
|
|
||||||
final Object value,
|
|
||||||
final boolean isSelected,
|
|
||||||
final Object key,
|
|
||||||
final int row,
|
|
||||||
final int column
|
|
||||||
) {
|
|
||||||
return new Text((String) value);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private class DeleteCellRenderer
|
|
||||||
extends LockableImpl
|
|
||||||
implements TableCellRenderer {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Component getComponent(
|
|
||||||
final Table table,
|
|
||||||
final PageState state,
|
|
||||||
final Object value,
|
|
||||||
final boolean isSelected,
|
|
||||||
final Object key,
|
|
||||||
final int row,
|
|
||||||
final int column
|
|
||||||
) {
|
|
||||||
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
|
|
||||||
final PermissionChecker permissionChecker = cdiUtil.findBean(
|
|
||||||
PermissionChecker.class
|
|
||||||
);
|
|
||||||
|
|
||||||
final InProceedingsItem inProceedingsItem
|
|
||||||
= (InProceedingsItem) itemModel.
|
|
||||||
getSelectedItem(state);
|
|
||||||
|
|
||||||
final boolean canEdit = permissionChecker
|
|
||||||
.isPermitted(ItemPrivileges.EDIT, inProceedingsItem);
|
|
||||||
|
|
||||||
if (canEdit) {
|
|
||||||
ControlLink link = new ControlLink((Component) value);
|
|
||||||
link.setConfirmation(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.inProceedings.proceedings.confirm_remove",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
)
|
|
||||||
);
|
|
||||||
return link;
|
|
||||||
} else {
|
|
||||||
return new Text("");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,64 +0,0 @@
|
||||||
/*
|
|
||||||
* 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 com.arsdigita.cms.contenttypes.ui;
|
|
||||||
|
|
||||||
import com.arsdigita.bebop.parameters.StringParameter;
|
|
||||||
import com.arsdigita.cms.ItemSelectionModel;
|
|
||||||
import com.arsdigita.cms.ui.authoring.AuthoringKitWizard;
|
|
||||||
import com.arsdigita.cms.ui.authoring.BasicItemForm;
|
|
||||||
import com.arsdigita.cms.ui.authoring.SimpleEditStep;
|
|
||||||
import com.arsdigita.cms.ui.workflow.WorkflowLockedComponentAccess;
|
|
||||||
import com.arsdigita.globalization.GlobalizedMessage;
|
|
||||||
|
|
||||||
import org.scientificcms.publications.SciPublicationsConstants;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
|
||||||
*/
|
|
||||||
public class InProceedingsProceedingsStep extends SimpleEditStep {
|
|
||||||
|
|
||||||
private static final String ADD_PROCEEDINGS_STEP = "addProceedings";
|
|
||||||
|
|
||||||
public InProceedingsProceedingsStep(
|
|
||||||
final ItemSelectionModel itemModel,
|
|
||||||
final AuthoringKitWizard parent,
|
|
||||||
final StringParameter selectedLangParam
|
|
||||||
) {
|
|
||||||
this(itemModel, parent, selectedLangParam, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public InProceedingsProceedingsStep(
|
|
||||||
final ItemSelectionModel itemModel,
|
|
||||||
final AuthoringKitWizard parent,
|
|
||||||
final StringParameter selectedLangParam,
|
|
||||||
final String prefix) {
|
|
||||||
super(itemModel, parent, selectedLangParam, prefix);
|
|
||||||
|
|
||||||
final BasicItemForm addProceedingsForm
|
|
||||||
= new InProceedingsProceedingsForm(
|
|
||||||
itemModel, selectedLangParam
|
|
||||||
);
|
|
||||||
add(
|
|
||||||
ADD_PROCEEDINGS_STEP,
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.inProceedings.addProceedings",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
),
|
|
||||||
new WorkflowLockedComponentAccess(
|
|
||||||
addProceedingsForm,
|
|
||||||
itemModel
|
|
||||||
),
|
|
||||||
addProceedingsForm.getSaveCancelSection().getCancelButton());
|
|
||||||
|
|
||||||
final InProceedingsProceedingsSheet sheet
|
|
||||||
= new InProceedingsProceedingsSheet(
|
|
||||||
itemModel
|
|
||||||
);
|
|
||||||
setDisplayComponent(sheet);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,129 +0,0 @@
|
||||||
/*
|
|
||||||
* 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 com.arsdigita.cms.contenttypes.ui;
|
|
||||||
|
|
||||||
import com.arsdigita.bebop.Component;
|
|
||||||
import com.arsdigita.bebop.Label;
|
|
||||||
import com.arsdigita.bebop.parameters.StringParameter;
|
|
||||||
import com.arsdigita.cms.ItemSelectionModel;
|
|
||||||
import com.arsdigita.cms.ui.authoring.AuthoringKitWizard;
|
|
||||||
import com.arsdigita.cms.ui.authoring.BasicPageForm;
|
|
||||||
import com.arsdigita.cms.ui.authoring.SimpleEditStep;
|
|
||||||
import com.arsdigita.cms.ui.workflow.WorkflowLockedComponentAccess;
|
|
||||||
import com.arsdigita.globalization.GlobalizedMessage;
|
|
||||||
import com.arsdigita.toolbox.ui.DomainObjectPropertySheet;
|
|
||||||
|
|
||||||
import org.scientificcms.publications.SciPublicationsConstants;
|
|
||||||
|
|
||||||
import static com.arsdigita.cms.contenttypes.ui.PublicationPropertiesStep.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
|
||||||
*/
|
|
||||||
public class InProceedingsPropertiesStep
|
|
||||||
extends PublicationPropertiesStep {
|
|
||||||
|
|
||||||
private final ItemSelectionModel itemModel;
|
|
||||||
private final StringParameter selectedLangParam;
|
|
||||||
|
|
||||||
public InProceedingsPropertiesStep(
|
|
||||||
final ItemSelectionModel itemModel,
|
|
||||||
final AuthoringKitWizard parent,
|
|
||||||
final StringParameter selectedLangParam
|
|
||||||
) {
|
|
||||||
super(itemModel, parent, selectedLangParam);
|
|
||||||
this.selectedLangParam = selectedLangParam;
|
|
||||||
this.itemModel = itemModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Component getInProceedingsPropertySheet(
|
|
||||||
final ItemSelectionModel itemModel,
|
|
||||||
final StringParameter selectedLangParam
|
|
||||||
) {
|
|
||||||
final DomainObjectPropertySheet sheet
|
|
||||||
= (DomainObjectPropertySheet) PublicationWithPublisherPropertiesStep
|
|
||||||
.getPublicationPropertySheet(
|
|
||||||
itemModel, selectedLangParam
|
|
||||||
);
|
|
||||||
|
|
||||||
sheet.add(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.inproceedings.pages_from",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
),
|
|
||||||
InProceedingsController.START_PAGE
|
|
||||||
);
|
|
||||||
|
|
||||||
sheet.add(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.inproceedings.pages_to",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
),
|
|
||||||
InProceedingsController.END_PAGE);
|
|
||||||
|
|
||||||
return sheet;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void addBasicProperties(
|
|
||||||
final ItemSelectionModel itemModel,
|
|
||||||
final AuthoringKitWizard parent
|
|
||||||
) {
|
|
||||||
final SimpleEditStep basicProperties = new SimpleEditStep(
|
|
||||||
itemModel,
|
|
||||||
parent,
|
|
||||||
selectedLangParam,
|
|
||||||
EDIT_SHEET_NAME
|
|
||||||
);
|
|
||||||
|
|
||||||
final BasicPageForm editBasicSheet = new InProceedingsPropertyForm(
|
|
||||||
itemModel, this, selectedLangParam
|
|
||||||
);
|
|
||||||
|
|
||||||
basicProperties.add(
|
|
||||||
EDIT_SHEET_NAME,
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.inproceedings.edit_basic_sheet",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
),
|
|
||||||
new WorkflowLockedComponentAccess(
|
|
||||||
editBasicSheet, itemModel
|
|
||||||
),
|
|
||||||
editBasicSheet.getSaveCancelSection().getCancelButton());
|
|
||||||
|
|
||||||
basicProperties.setDisplayComponent(
|
|
||||||
getInProceedingsPropertySheet(itemModel, selectedLangParam)
|
|
||||||
);
|
|
||||||
|
|
||||||
getSegmentedPanel().addSegment(
|
|
||||||
new Label(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.publications.basic_properties",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
)
|
|
||||||
),
|
|
||||||
basicProperties);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void addSteps(
|
|
||||||
final ItemSelectionModel itemModel, final AuthoringKitWizard parent
|
|
||||||
) {
|
|
||||||
super.addSteps(itemModel, parent);
|
|
||||||
|
|
||||||
addStep(
|
|
||||||
new InProceedingsProceedingsStep(
|
|
||||||
itemModel, parent, selectedLangParam
|
|
||||||
),
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.inProceedings.proceedings",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,137 +0,0 @@
|
||||||
/*
|
|
||||||
* 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 com.arsdigita.cms.contenttypes.ui;
|
|
||||||
|
|
||||||
import com.arsdigita.bebop.FormData;
|
|
||||||
import com.arsdigita.bebop.FormProcessException;
|
|
||||||
import com.arsdigita.bebop.PageState;
|
|
||||||
import com.arsdigita.bebop.event.FormInitListener;
|
|
||||||
import com.arsdigita.bebop.event.FormProcessListener;
|
|
||||||
import com.arsdigita.bebop.event.FormSectionEvent;
|
|
||||||
import com.arsdigita.bebop.event.FormSubmissionListener;
|
|
||||||
import com.arsdigita.bebop.form.TextField;
|
|
||||||
import com.arsdigita.bebop.parameters.IntegerParameter;
|
|
||||||
import com.arsdigita.bebop.parameters.ParameterModel;
|
|
||||||
import com.arsdigita.bebop.parameters.StringParameter;
|
|
||||||
import com.arsdigita.cms.ItemSelectionModel;
|
|
||||||
import com.arsdigita.globalization.GlobalizedMessage;
|
|
||||||
|
|
||||||
import org.libreccm.cdi.utils.CdiUtil;
|
|
||||||
import org.scientificcms.publications.InProceedings;
|
|
||||||
import org.scientificcms.publications.SciPublicationsConstants;
|
|
||||||
import org.scientificcms.publications.contenttypes.InProceedingsItem;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
|
||||||
*/
|
|
||||||
public class InProceedingsPropertyForm extends PublicationPropertyForm
|
|
||||||
implements FormProcessListener, FormInitListener, FormSubmissionListener {
|
|
||||||
|
|
||||||
public static final String ID = "InProceedingsEdit";
|
|
||||||
|
|
||||||
private InProceedingsPropertiesStep step;
|
|
||||||
|
|
||||||
public InProceedingsPropertyForm(
|
|
||||||
final ItemSelectionModel itemModel,
|
|
||||||
final StringParameter selectedLangParam
|
|
||||||
) {
|
|
||||||
this(itemModel, null, selectedLangParam);
|
|
||||||
}
|
|
||||||
|
|
||||||
public InProceedingsPropertyForm(
|
|
||||||
final ItemSelectionModel itemModel,
|
|
||||||
final InProceedingsPropertiesStep step,
|
|
||||||
final StringParameter selectedLangParam
|
|
||||||
) {
|
|
||||||
super(itemModel, step, selectedLangParam);
|
|
||||||
this.step = step;
|
|
||||||
addSubmissionListener(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void addWidgets() {
|
|
||||||
|
|
||||||
super.addWidgets();
|
|
||||||
|
|
||||||
final ParameterModel pagesFromParam = new IntegerParameter(
|
|
||||||
InProceedingsController.START_PAGE);
|
|
||||||
final TextField pagesFrom = new TextField(pagesFromParam);
|
|
||||||
pagesFrom.setLabel(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.inproceedings.pages_from",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
)
|
|
||||||
);
|
|
||||||
add(pagesFrom);
|
|
||||||
|
|
||||||
ParameterModel pagesToParam = new IntegerParameter(
|
|
||||||
InProceedingsController.END_PAGE
|
|
||||||
);
|
|
||||||
final TextField pagesTo = new TextField(pagesToParam);
|
|
||||||
pagesTo.setLabel(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.inproceedings.pages_to",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
)
|
|
||||||
);
|
|
||||||
add(pagesTo);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void init(final FormSectionEvent event) throws FormProcessException {
|
|
||||||
super.init(event);
|
|
||||||
|
|
||||||
final FormData data = event.getFormData();
|
|
||||||
final InProceedingsItem inProceedingsItem = (InProceedingsItem) super
|
|
||||||
.initBasicWidgets(event);
|
|
||||||
final InProceedings inProceedings = inProceedingsItem.getPublication();
|
|
||||||
|
|
||||||
data.put(
|
|
||||||
InProceedingsController.START_PAGE, inProceedings.getStartPage()
|
|
||||||
);
|
|
||||||
data.put(
|
|
||||||
InProceedingsController.END_PAGE, inProceedings.getEndPage()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void process(final FormSectionEvent event)
|
|
||||||
throws FormProcessException {
|
|
||||||
super.process(event);
|
|
||||||
|
|
||||||
final FormData formData = event.getFormData();
|
|
||||||
final PageState state = event.getPageState();
|
|
||||||
final InProceedingsItem inProceedingsItem = (InProceedingsItem) super
|
|
||||||
.processBasicWidgets(event);
|
|
||||||
|
|
||||||
if ((inProceedingsItem != null)
|
|
||||||
&& getSaveCancelSection().getSaveButton().isSelected(state)) {
|
|
||||||
|
|
||||||
final Map<String, Object> data = new HashMap<>();
|
|
||||||
data.put(
|
|
||||||
InProceedingsController.START_PAGE,
|
|
||||||
formData.get(InProceedingsController.START_PAGE)
|
|
||||||
);
|
|
||||||
data.put(
|
|
||||||
InProceedingsController.END_PAGE,
|
|
||||||
formData.get(InProceedingsController.END_PAGE)
|
|
||||||
);
|
|
||||||
|
|
||||||
final InProceedingsController controller = CdiUtil
|
|
||||||
.createCdiUtil()
|
|
||||||
.findBean(InProceedingsController.class);
|
|
||||||
|
|
||||||
controller.saveInProceedings(
|
|
||||||
inProceedingsItem.getPublication().getPublicationId(), data
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,153 +0,0 @@
|
||||||
/*
|
|
||||||
* 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 com.arsdigita.cms.contenttypes.ui;
|
|
||||||
|
|
||||||
import org.librecms.assets.Organization;
|
|
||||||
import org.librecms.contentsection.AssetRepository;
|
|
||||||
import org.scientificcms.publications.InternetArticle;
|
|
||||||
import org.scientificcms.publications.PublicationRepository;
|
|
||||||
|
|
||||||
import java.time.LocalDate;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import javax.enterprise.context.RequestScoped;
|
|
||||||
import javax.inject.Inject;
|
|
||||||
import javax.transaction.Transactional;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
|
||||||
*/
|
|
||||||
@RequestScoped
|
|
||||||
public class InternetArticleController {
|
|
||||||
|
|
||||||
public static final String PLACE = "place";
|
|
||||||
|
|
||||||
public static final String NUMBER = "number";
|
|
||||||
|
|
||||||
public static final String NUMBER_OF_PAGES = "numberOfPages";
|
|
||||||
|
|
||||||
public static final String EDITION = "edition";
|
|
||||||
|
|
||||||
public static final String ISSN = "issn";
|
|
||||||
|
|
||||||
public static final String LAST_ACCESSED = "lastAccessed";
|
|
||||||
|
|
||||||
public static final String URL = "url";
|
|
||||||
|
|
||||||
public static final String URN = "urn";
|
|
||||||
|
|
||||||
public static final String DOI = "doi";
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
private AssetRepository assetRepository;
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
private PublicationRepository publicationRepository;
|
|
||||||
|
|
||||||
@Transactional(Transactional.TxType.REQUIRED)
|
|
||||||
public void saveInternetArticle(
|
|
||||||
final long internetArticleId, final Map<String, Object> data
|
|
||||||
) {
|
|
||||||
final InternetArticle internetArticle = publicationRepository
|
|
||||||
.findByIdAndType(internetArticleId, InternetArticle.class)
|
|
||||||
.orElseThrow(
|
|
||||||
() -> new IllegalArgumentException(
|
|
||||||
String.format(
|
|
||||||
"No InternetArticle with ID %d found.",
|
|
||||||
internetArticleId
|
|
||||||
)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
if (data.containsKey(PLACE)) {
|
|
||||||
internetArticle.setPlace((String) data.get(PLACE));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (data.containsKey(NUMBER)) {
|
|
||||||
internetArticle.setNumber((String) data.get(NUMBER));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (data.containsKey(NUMBER_OF_PAGES)) {
|
|
||||||
internetArticle.setNumberOfPages(
|
|
||||||
(Integer) data.get(NUMBER_OF_PAGES)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (data.containsKey(EDITION)) {
|
|
||||||
internetArticle.setEdition((String) data.get(EDITION));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (data.containsKey(ISSN)) {
|
|
||||||
internetArticle.setIssn((String) data.get(ISSN));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (data.containsKey(LAST_ACCESSED)) {
|
|
||||||
internetArticle.setLastAccessed((LocalDate) data.get(LAST_ACCESSED));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (data.containsKey(URL)) {
|
|
||||||
internetArticle.setUrl((String) data.get(URL));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (data.containsKey(URN)) {
|
|
||||||
internetArticle.setUrn((String) data.get(URN));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (data.containsKey(DOI)) {
|
|
||||||
internetArticle.setDoi((String) data.get(DOI));
|
|
||||||
}
|
|
||||||
|
|
||||||
publicationRepository.save(internetArticle);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Transactional(Transactional.TxType.REQUIRED)
|
|
||||||
public void setOrganization(
|
|
||||||
final long internetArticleId,
|
|
||||||
final long organizationId
|
|
||||||
) {
|
|
||||||
final InternetArticle internetArticle = publicationRepository
|
|
||||||
.findByIdAndType(internetArticleId, InternetArticle.class)
|
|
||||||
.orElseThrow(
|
|
||||||
() -> new IllegalArgumentException(
|
|
||||||
String.format(
|
|
||||||
"No InternetArticle with ID %d found.",
|
|
||||||
internetArticleId
|
|
||||||
)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
final Organization organization = assetRepository
|
|
||||||
.findById(organizationId, Organization.class)
|
|
||||||
.orElseThrow(
|
|
||||||
() -> new IllegalArgumentException(
|
|
||||||
String.format(
|
|
||||||
"No Organization with ID %d found.", organizationId
|
|
||||||
)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
internetArticle.setOrganization(organization);
|
|
||||||
publicationRepository.save(internetArticle);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Transactional(Transactional.TxType.REQUIRED)
|
|
||||||
public void unsetOrganization(final long internetArticleId) {
|
|
||||||
final InternetArticle internetArticle = publicationRepository
|
|
||||||
.findByIdAndType(internetArticleId, InternetArticle.class)
|
|
||||||
.orElseThrow(
|
|
||||||
() -> new IllegalArgumentException(
|
|
||||||
String.format(
|
|
||||||
"No InternetArticle with ID %d found.",
|
|
||||||
internetArticleId
|
|
||||||
)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
internetArticle.setOrganization(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,35 +0,0 @@
|
||||||
/*
|
|
||||||
* 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 com.arsdigita.cms.contenttypes.ui;
|
|
||||||
|
|
||||||
import com.arsdigita.bebop.parameters.StringParameter;
|
|
||||||
import com.arsdigita.cms.ItemSelectionModel;
|
|
||||||
import com.arsdigita.cms.ui.authoring.CreationSelector;
|
|
||||||
|
|
||||||
import org.scientificcms.publications.InternetArticle;
|
|
||||||
import org.scientificcms.publications.contenttypes.InternetArticleItem;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
|
||||||
*/
|
|
||||||
public class InternetArticleCreateForm
|
|
||||||
extends AbstractPublicationCreateForm<InternetArticle, InternetArticleItem> {
|
|
||||||
|
|
||||||
public InternetArticleCreateForm(
|
|
||||||
final ItemSelectionModel itemModel,
|
|
||||||
final CreationSelector creationSelector,
|
|
||||||
final StringParameter selectedLanguageParam
|
|
||||||
) {
|
|
||||||
super(itemModel, creationSelector, selectedLanguageParam);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected InternetArticle createPublication() {
|
|
||||||
return new InternetArticle();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,89 +0,0 @@
|
||||||
/*
|
|
||||||
* 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 com.arsdigita.cms.contenttypes.ui;
|
|
||||||
|
|
||||||
import com.arsdigita.bebop.FormData;
|
|
||||||
import com.arsdigita.bebop.FormProcessException;
|
|
||||||
import com.arsdigita.bebop.PageState;
|
|
||||||
import com.arsdigita.bebop.event.FormInitListener;
|
|
||||||
import com.arsdigita.bebop.event.FormProcessListener;
|
|
||||||
import com.arsdigita.bebop.event.FormSectionEvent;
|
|
||||||
import com.arsdigita.bebop.parameters.StringParameter;
|
|
||||||
import com.arsdigita.cms.ItemSelectionModel;
|
|
||||||
import com.arsdigita.cms.ui.assets.AssetSearchWidget;
|
|
||||||
import com.arsdigita.cms.ui.authoring.BasicItemForm;
|
|
||||||
import com.arsdigita.globalization.GlobalizedMessage;
|
|
||||||
|
|
||||||
import org.libreccm.cdi.utils.CdiUtil;
|
|
||||||
import org.librecms.assets.Organization;
|
|
||||||
import org.scientificcms.publications.SciPublicationsConstants;
|
|
||||||
import org.scientificcms.publications.contenttypes.InternetArticleItem;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
|
||||||
*/
|
|
||||||
public class InternetArticleOrganizationForm
|
|
||||||
extends BasicItemForm
|
|
||||||
implements FormProcessListener, FormInitListener {
|
|
||||||
|
|
||||||
private static final String ORGA_SEARCH = "internetArticleOrga";
|
|
||||||
|
|
||||||
private AssetSearchWidget orgaSearch;
|
|
||||||
|
|
||||||
public InternetArticleOrganizationForm(
|
|
||||||
final ItemSelectionModel itemModel,
|
|
||||||
final StringParameter selectedLangParam
|
|
||||||
) {
|
|
||||||
super("InternetArticleOrganizationForm", itemModel, selectedLangParam);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void addWidgets() {
|
|
||||||
orgaSearch = new AssetSearchWidget(ORGA_SEARCH, Organization.class);
|
|
||||||
orgaSearch.setLabel(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.internetarticle.select_organization",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
)
|
|
||||||
);
|
|
||||||
add(orgaSearch);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void init(final FormSectionEvent event) throws FormProcessException {
|
|
||||||
final PageState state = event.getPageState();
|
|
||||||
setVisible(state, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void process(final FormSectionEvent event)
|
|
||||||
throws FormProcessException {
|
|
||||||
final FormData formData = event.getFormData();
|
|
||||||
final PageState state = event.getPageState();
|
|
||||||
|
|
||||||
final InternetArticleItem articleItem
|
|
||||||
= (InternetArticleItem) getItemSelectionModel()
|
|
||||||
.getSelectedItem(state);
|
|
||||||
|
|
||||||
if (getSaveCancelSection().getSaveButton().isSelected(state)) {
|
|
||||||
final Organization orga
|
|
||||||
= (Organization) formData
|
|
||||||
.get(ORGA_SEARCH);
|
|
||||||
final InternetArticleController controller = CdiUtil
|
|
||||||
.createCdiUtil()
|
|
||||||
.findBean(InternetArticleController.class);
|
|
||||||
|
|
||||||
controller.setOrganization(
|
|
||||||
articleItem.getPublication().getPublicationId(),
|
|
||||||
orga.getObjectId()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
init(event);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,267 +0,0 @@
|
||||||
/*
|
|
||||||
* 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 com.arsdigita.cms.contenttypes.ui;
|
|
||||||
|
|
||||||
import com.arsdigita.bebop.Component;
|
|
||||||
import com.arsdigita.bebop.ControlLink;
|
|
||||||
import com.arsdigita.bebop.Label;
|
|
||||||
import com.arsdigita.bebop.PageState;
|
|
||||||
import com.arsdigita.bebop.Table;
|
|
||||||
import com.arsdigita.bebop.Text;
|
|
||||||
import com.arsdigita.bebop.event.TableActionEvent;
|
|
||||||
import com.arsdigita.bebop.event.TableActionListener;
|
|
||||||
import com.arsdigita.bebop.table.TableCellRenderer;
|
|
||||||
import com.arsdigita.bebop.table.TableColumn;
|
|
||||||
import com.arsdigita.bebop.table.TableColumnModel;
|
|
||||||
import com.arsdigita.bebop.table.TableModel;
|
|
||||||
import com.arsdigita.bebop.table.TableModelBuilder;
|
|
||||||
import com.arsdigita.cms.ItemSelectionModel;
|
|
||||||
import com.arsdigita.cms.dispatcher.Utilities;
|
|
||||||
import com.arsdigita.globalization.GlobalizedMessage;
|
|
||||||
import com.arsdigita.util.LockableImpl;
|
|
||||||
|
|
||||||
import org.libreccm.cdi.utils.CdiUtil;
|
|
||||||
import org.libreccm.security.PermissionChecker;
|
|
||||||
import org.librecms.assets.Organization;
|
|
||||||
import org.librecms.contentsection.privileges.ItemPrivileges;
|
|
||||||
import org.scientificcms.publications.InternetArticle;
|
|
||||||
import org.scientificcms.publications.SciPublicationsConstants;
|
|
||||||
import org.scientificcms.publications.contenttypes.InternetArticleItem;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
|
||||||
*/
|
|
||||||
public class InternetArticleOrganizationSheet
|
|
||||||
extends Table
|
|
||||||
implements TableActionListener {
|
|
||||||
|
|
||||||
private static final String TABLE_COL_EDIT = "table_col_edit";
|
|
||||||
|
|
||||||
private static final String TABLE_COL_DEL = "table_col_del";
|
|
||||||
|
|
||||||
private final ItemSelectionModel itemModel;
|
|
||||||
|
|
||||||
public InternetArticleOrganizationSheet(final ItemSelectionModel itemModel) {
|
|
||||||
super();
|
|
||||||
this.itemModel = itemModel;
|
|
||||||
|
|
||||||
setEmptyView(
|
|
||||||
new Label(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.internetarticle.organization.none",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
final TableColumnModel columnModel = getColumnModel();
|
|
||||||
columnModel.add(
|
|
||||||
new TableColumn(
|
|
||||||
0,
|
|
||||||
new Label(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.internetarticle.organization",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
)
|
|
||||||
),
|
|
||||||
TABLE_COL_EDIT
|
|
||||||
)
|
|
||||||
);
|
|
||||||
columnModel.add(
|
|
||||||
new TableColumn(
|
|
||||||
1,
|
|
||||||
new Label(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.internetarticle.organization.remove",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
)
|
|
||||||
),
|
|
||||||
TABLE_COL_DEL));
|
|
||||||
|
|
||||||
setModelBuilder(
|
|
||||||
new InternetArticleOrganizationSheetModelBuilder(itemModel)
|
|
||||||
);
|
|
||||||
columnModel.get(0).setCellRenderer(new EditCellRenderer());
|
|
||||||
columnModel.get(1).setCellRenderer(new DeleteCellRenderer());
|
|
||||||
|
|
||||||
addTableActionListener(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void cellSelected(final TableActionEvent event) {
|
|
||||||
final PageState state = event.getPageState();
|
|
||||||
|
|
||||||
final InternetArticleItem articleItem = (InternetArticleItem) itemModel
|
|
||||||
.getSelectedObject(state);
|
|
||||||
|
|
||||||
final TableColumn column = getColumnModel().get(event.getColumn());
|
|
||||||
|
|
||||||
if (column.getHeaderKey().toString().equals(TABLE_COL_EDIT)) {
|
|
||||||
// Nothing
|
|
||||||
} else if (column.getHeaderKey().toString().equals(TABLE_COL_DEL)) {
|
|
||||||
final InternetArticleController controller = CdiUtil
|
|
||||||
.createCdiUtil()
|
|
||||||
.findBean(InternetArticleController.class);
|
|
||||||
controller.unsetOrganization(
|
|
||||||
articleItem.getPublication().getPublicationId()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void headSelected(final TableActionEvent event) {
|
|
||||||
//Nothing to do
|
|
||||||
}
|
|
||||||
|
|
||||||
private class InternetArticleOrganizationSheetModelBuilder
|
|
||||||
extends LockableImpl
|
|
||||||
implements TableModelBuilder {
|
|
||||||
|
|
||||||
private final ItemSelectionModel itemModel;
|
|
||||||
|
|
||||||
public InternetArticleOrganizationSheetModelBuilder(
|
|
||||||
final ItemSelectionModel itemModel
|
|
||||||
) {
|
|
||||||
this.itemModel = itemModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public TableModel makeModel(final Table table, final PageState state) {
|
|
||||||
table.getRowSelectionModel().clearSelection(state);
|
|
||||||
final InternetArticleItem articleItem
|
|
||||||
= (InternetArticleItem) itemModel.
|
|
||||||
getSelectedObject(state);
|
|
||||||
return new InternetArticleOrganizationSheetModel(
|
|
||||||
table, state, articleItem.getPublication()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private class InternetArticleOrganizationSheetModel
|
|
||||||
implements TableModel {
|
|
||||||
|
|
||||||
private final Table table;
|
|
||||||
|
|
||||||
private final Organization orga;
|
|
||||||
|
|
||||||
private boolean done;
|
|
||||||
|
|
||||||
public InternetArticleOrganizationSheetModel(
|
|
||||||
final Table table,
|
|
||||||
final PageState state,
|
|
||||||
final InternetArticle article
|
|
||||||
) {
|
|
||||||
this.table = table;
|
|
||||||
orga = article.getOrganization();
|
|
||||||
done = orga != null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getColumnCount() {
|
|
||||||
return table.getColumnModel().size();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean nextRow() {
|
|
||||||
boolean ret;
|
|
||||||
|
|
||||||
if (done) {
|
|
||||||
ret = true;
|
|
||||||
done = false;
|
|
||||||
} else {
|
|
||||||
ret = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object getElementAt(final int columnIndex) {
|
|
||||||
switch (columnIndex) {
|
|
||||||
case 0:
|
|
||||||
return orga.getTitle();
|
|
||||||
case 1:
|
|
||||||
return new Label(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publication.ui.internetarticle.organization.remove",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
)
|
|
||||||
);
|
|
||||||
default:
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object getKeyAt(final int columnIndex) {
|
|
||||||
return orga.getObjectId();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private class EditCellRenderer
|
|
||||||
extends LockableImpl
|
|
||||||
implements TableCellRenderer {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Component getComponent(
|
|
||||||
final Table table,
|
|
||||||
final PageState state,
|
|
||||||
final Object value,
|
|
||||||
final boolean isSelected,
|
|
||||||
final Object key,
|
|
||||||
final int row,
|
|
||||||
final int column
|
|
||||||
) {
|
|
||||||
return new Text((String) value);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private class DeleteCellRenderer
|
|
||||||
extends LockableImpl
|
|
||||||
implements TableCellRenderer {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Component getComponent(
|
|
||||||
final Table table,
|
|
||||||
final PageState state,
|
|
||||||
final Object value,
|
|
||||||
final boolean isSelected,
|
|
||||||
final Object key,
|
|
||||||
final int row,
|
|
||||||
final int col
|
|
||||||
) {
|
|
||||||
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
|
|
||||||
final PermissionChecker permissionChecker = cdiUtil.findBean(
|
|
||||||
PermissionChecker.class
|
|
||||||
);
|
|
||||||
|
|
||||||
final InternetArticleItem articleItem
|
|
||||||
= (InternetArticleItem) itemModel
|
|
||||||
.getSelectedObject(state);
|
|
||||||
final boolean canEdit = permissionChecker
|
|
||||||
.isPermitted(ItemPrivileges.EDIT, articleItem);
|
|
||||||
|
|
||||||
if (canEdit) {
|
|
||||||
final ControlLink link = new ControlLink((Component) value);
|
|
||||||
link.setConfirmation(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.internetarticle.organization.remove.confirm",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
)
|
|
||||||
);
|
|
||||||
return link;
|
|
||||||
} else {
|
|
||||||
return new Text("");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,61 +0,0 @@
|
||||||
/*
|
|
||||||
* 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 com.arsdigita.cms.contenttypes.ui;
|
|
||||||
|
|
||||||
import com.arsdigita.bebop.parameters.StringParameter;
|
|
||||||
import com.arsdigita.cms.ItemSelectionModel;
|
|
||||||
import com.arsdigita.cms.ui.authoring.AuthoringKitWizard;
|
|
||||||
import com.arsdigita.cms.ui.authoring.BasicItemForm;
|
|
||||||
import com.arsdigita.cms.ui.authoring.SimpleEditStep;
|
|
||||||
import com.arsdigita.cms.ui.workflow.WorkflowLockedComponentAccess;
|
|
||||||
import com.arsdigita.globalization.GlobalizedMessage;
|
|
||||||
|
|
||||||
import org.scientificcms.publications.SciPublicationsConstants;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
|
||||||
*/
|
|
||||||
public class InternetArticleOrganizationStep extends SimpleEditStep {
|
|
||||||
|
|
||||||
private static final String SET_INTERNET_ARTICLE_ORGANIZATION_STEP
|
|
||||||
= "setInternetArticleOrganizationStep";
|
|
||||||
|
|
||||||
public InternetArticleOrganizationStep(
|
|
||||||
final ItemSelectionModel itemModel,
|
|
||||||
final AuthoringKitWizard parent,
|
|
||||||
final StringParameter selectedLangParam
|
|
||||||
) {
|
|
||||||
this(itemModel, parent, selectedLangParam, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public InternetArticleOrganizationStep(
|
|
||||||
final ItemSelectionModel itemModel,
|
|
||||||
final AuthoringKitWizard parent,
|
|
||||||
final StringParameter selectedLangParam,
|
|
||||||
final String prefix
|
|
||||||
) {
|
|
||||||
super(itemModel, parent, selectedLangParam, prefix);
|
|
||||||
|
|
||||||
final BasicItemForm setOrgaForm = new InternetArticleOrganizationForm(
|
|
||||||
itemModel, selectedLangParam
|
|
||||||
);
|
|
||||||
add(
|
|
||||||
SET_INTERNET_ARTICLE_ORGANIZATION_STEP,
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.internetarticle.setOrganization",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
),
|
|
||||||
new WorkflowLockedComponentAccess(setOrgaForm, itemModel),
|
|
||||||
setOrgaForm.getSaveCancelSection().getCancelButton());
|
|
||||||
|
|
||||||
final InternetArticleOrganizationSheet sheet
|
|
||||||
= new InternetArticleOrganizationSheet(
|
|
||||||
itemModel);
|
|
||||||
setDisplayComponent(sheet);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,180 +0,0 @@
|
||||||
/*
|
|
||||||
* 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 com.arsdigita.cms.contenttypes.ui;
|
|
||||||
|
|
||||||
import com.arsdigita.bebop.Component;
|
|
||||||
import com.arsdigita.bebop.Label;
|
|
||||||
import com.arsdigita.bebop.parameters.StringParameter;
|
|
||||||
import com.arsdigita.cms.ItemSelectionModel;
|
|
||||||
import com.arsdigita.cms.ui.authoring.AuthoringKitWizard;
|
|
||||||
import com.arsdigita.cms.ui.authoring.BasicPageForm;
|
|
||||||
import com.arsdigita.cms.ui.authoring.SimpleEditStep;
|
|
||||||
import com.arsdigita.cms.ui.workflow.WorkflowLockedComponentAccess;
|
|
||||||
import com.arsdigita.globalization.GlobalizedMessage;
|
|
||||||
import com.arsdigita.toolbox.ui.DomainObjectPropertySheet;
|
|
||||||
|
|
||||||
import org.scientificcms.publications.SciPublicationsConstants;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
|
||||||
*/
|
|
||||||
public class InternetArticlePropertiesStep extends PublicationPropertiesStep {
|
|
||||||
|
|
||||||
private final StringParameter selectedLangParam;
|
|
||||||
|
|
||||||
public InternetArticlePropertiesStep(
|
|
||||||
final ItemSelectionModel itemModel,
|
|
||||||
final AuthoringKitWizard parent,
|
|
||||||
final StringParameter selectedLangParam
|
|
||||||
) {
|
|
||||||
super(itemModel, parent, selectedLangParam);
|
|
||||||
this.selectedLangParam = selectedLangParam;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Component getInternetArticlePropertySheet(
|
|
||||||
final ItemSelectionModel itemModel,
|
|
||||||
final StringParameter selectedLangParam
|
|
||||||
) {
|
|
||||||
final DomainObjectPropertySheet sheet
|
|
||||||
= (DomainObjectPropertySheet) PublicationPropertiesStep
|
|
||||||
.getPublicationPropertySheet(itemModel, selectedLangParam);
|
|
||||||
|
|
||||||
sheet.add(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.internetarticle.place",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
),
|
|
||||||
InternetArticleController.PLACE
|
|
||||||
);
|
|
||||||
|
|
||||||
sheet.add(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.internetarticle.number",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
),
|
|
||||||
InternetArticleController.NUMBER
|
|
||||||
);
|
|
||||||
|
|
||||||
sheet.add(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.internetarticle.number_of_pages",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
),
|
|
||||||
InternetArticleController.NUMBER_OF_PAGES
|
|
||||||
);
|
|
||||||
|
|
||||||
sheet.add(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.internetarticle.edition",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
),
|
|
||||||
InternetArticleController.EDITION
|
|
||||||
);
|
|
||||||
|
|
||||||
sheet.add(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.internetarticle.issn",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
),
|
|
||||||
InternetArticleController.ISSN
|
|
||||||
);
|
|
||||||
|
|
||||||
sheet.add(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.internetarticle.lastAccessed",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
),
|
|
||||||
InternetArticleController.LAST_ACCESSED
|
|
||||||
);
|
|
||||||
|
|
||||||
sheet.add(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.internetarticle.url",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
),
|
|
||||||
InternetArticleController.URL
|
|
||||||
);
|
|
||||||
|
|
||||||
sheet.add(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.internetarticle.urn",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
),
|
|
||||||
InternetArticleController.URN
|
|
||||||
);
|
|
||||||
|
|
||||||
sheet.add(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.internetarticle.doi",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
),
|
|
||||||
InternetArticleController.DOI
|
|
||||||
);
|
|
||||||
|
|
||||||
return sheet;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void addBasicProperties(
|
|
||||||
final ItemSelectionModel itemModel, final AuthoringKitWizard parent
|
|
||||||
) {
|
|
||||||
final SimpleEditStep basicProperties = new SimpleEditStep(
|
|
||||||
itemModel,
|
|
||||||
parent,
|
|
||||||
selectedLangParam,
|
|
||||||
EDIT_SHEET_NAME
|
|
||||||
);
|
|
||||||
|
|
||||||
final BasicPageForm editBasicSheet
|
|
||||||
= new InternetArticlePropertyForm(
|
|
||||||
itemModel,
|
|
||||||
this,
|
|
||||||
selectedLangParam
|
|
||||||
);
|
|
||||||
|
|
||||||
basicProperties.add(
|
|
||||||
EDIT_SHEET_NAME,
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.internetarticle.edit_basic_sheet",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
),
|
|
||||||
new WorkflowLockedComponentAccess(editBasicSheet, itemModel),
|
|
||||||
editBasicSheet.getSaveCancelSection().getCancelButton()
|
|
||||||
);
|
|
||||||
|
|
||||||
basicProperties.setDisplayComponent(
|
|
||||||
getInternetArticlePropertySheet(itemModel, selectedLangParam));
|
|
||||||
|
|
||||||
getSegmentedPanel().addSegment(
|
|
||||||
new Label(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.publication.basic_properties",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
)
|
|
||||||
),
|
|
||||||
basicProperties
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void addSteps(
|
|
||||||
final ItemSelectionModel itemModel, final AuthoringKitWizard parent
|
|
||||||
) {
|
|
||||||
super.addSteps(itemModel, parent);
|
|
||||||
|
|
||||||
addStep(
|
|
||||||
new InternetArticleOrganizationStep(
|
|
||||||
itemModel, parent, selectedLangParam
|
|
||||||
),
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.internetarticle.setOrganization",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,318 +0,0 @@
|
||||||
/*
|
|
||||||
* 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 com.arsdigita.cms.contenttypes.ui;
|
|
||||||
|
|
||||||
import com.arsdigita.bebop.FormData;
|
|
||||||
import com.arsdigita.bebop.FormProcessException;
|
|
||||||
import com.arsdigita.bebop.PageState;
|
|
||||||
import com.arsdigita.bebop.event.FormInitListener;
|
|
||||||
import com.arsdigita.bebop.event.FormProcessListener;
|
|
||||||
import com.arsdigita.bebop.event.FormSectionEvent;
|
|
||||||
import com.arsdigita.bebop.event.FormSubmissionListener;
|
|
||||||
import com.arsdigita.bebop.event.ParameterEvent;
|
|
||||||
import com.arsdigita.bebop.event.ParameterListener;
|
|
||||||
import com.arsdigita.bebop.form.TextField;
|
|
||||||
import com.arsdigita.bebop.parameters.DateParameter;
|
|
||||||
import com.arsdigita.bebop.parameters.IntegerParameter;
|
|
||||||
import com.arsdigita.bebop.parameters.ParameterData;
|
|
||||||
import com.arsdigita.bebop.parameters.ParameterModel;
|
|
||||||
import com.arsdigita.bebop.parameters.StringParameter;
|
|
||||||
import com.arsdigita.cms.ItemSelectionModel;
|
|
||||||
import com.arsdigita.globalization.GlobalizedMessage;
|
|
||||||
|
|
||||||
import org.libreccm.cdi.utils.CdiUtil;
|
|
||||||
import org.scientificcms.publications.InternetArticle;
|
|
||||||
import org.scientificcms.publications.SciPublicationsConstants;
|
|
||||||
import org.scientificcms.publications.contenttypes.InternetArticleItem;
|
|
||||||
|
|
||||||
import java.time.ZoneId;
|
|
||||||
import java.util.Calendar;
|
|
||||||
import java.util.GregorianCalendar;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
|
||||||
*/
|
|
||||||
public class InternetArticlePropertyForm
|
|
||||||
extends PublicationPropertyForm
|
|
||||||
implements FormInitListener, FormProcessListener, FormSubmissionListener {
|
|
||||||
|
|
||||||
public static final String ID = "InternetArticleEdit";
|
|
||||||
|
|
||||||
private final InternetArticlePropertiesStep step;
|
|
||||||
|
|
||||||
private final StringParameter selectedLangParam;
|
|
||||||
|
|
||||||
public InternetArticlePropertyForm(
|
|
||||||
final ItemSelectionModel itemModel,
|
|
||||||
final StringParameter selectedLangParam
|
|
||||||
) {
|
|
||||||
this(itemModel, null, selectedLangParam);
|
|
||||||
}
|
|
||||||
|
|
||||||
public InternetArticlePropertyForm(
|
|
||||||
final ItemSelectionModel itemModel,
|
|
||||||
final InternetArticlePropertiesStep step,
|
|
||||||
final StringParameter selectedLangParam
|
|
||||||
) {
|
|
||||||
super(itemModel, step, selectedLangParam);
|
|
||||||
this.step = step;
|
|
||||||
this.selectedLangParam = selectedLangParam;
|
|
||||||
addSubmissionListener(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void addWidgets() {
|
|
||||||
super.addWidgets();
|
|
||||||
|
|
||||||
final ParameterModel placeParam = new StringParameter(
|
|
||||||
InternetArticleController.PLACE
|
|
||||||
);
|
|
||||||
final TextField place = new TextField(placeParam);
|
|
||||||
place.setLabel(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.internetarticle.place",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
)
|
|
||||||
);
|
|
||||||
add(place);
|
|
||||||
|
|
||||||
final ParameterModel numberParam = new StringParameter(
|
|
||||||
InternetArticleController.NUMBER
|
|
||||||
);
|
|
||||||
final TextField number = new TextField(numberParam);
|
|
||||||
number.setLabel(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.internetarticle.number",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
)
|
|
||||||
);
|
|
||||||
add(number);
|
|
||||||
|
|
||||||
final ParameterModel numberOfPagesParam = new IntegerParameter(
|
|
||||||
InternetArticleController.NUMBER_OF_PAGES
|
|
||||||
);
|
|
||||||
final TextField numberOfPages = new TextField(numberOfPagesParam);
|
|
||||||
numberOfPages.setLabel(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.internetarticle.number_of_pages",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
)
|
|
||||||
);
|
|
||||||
add(numberOfPages);
|
|
||||||
|
|
||||||
final ParameterModel editionParam = new StringParameter(
|
|
||||||
InternetArticleController.EDITION
|
|
||||||
);
|
|
||||||
final TextField edition = new TextField(editionParam);
|
|
||||||
edition.setLabel(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.internetarticle.edition",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
)
|
|
||||||
);
|
|
||||||
add(edition);
|
|
||||||
|
|
||||||
final ParameterModel issnParam = new StringParameter(
|
|
||||||
InternetArticleController.ISSN
|
|
||||||
);
|
|
||||||
final TextField issn = new TextField(issnParam);
|
|
||||||
issn.setLabel(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.internetarticle.issn",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
)
|
|
||||||
);
|
|
||||||
issn.setMaxLength(9);
|
|
||||||
issn.addValidationListener(new ParameterListener() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void validate(final ParameterEvent event)
|
|
||||||
throws FormProcessException {
|
|
||||||
final ParameterData data = event.getParameterData();
|
|
||||||
String value = (String) data.getValue();
|
|
||||||
|
|
||||||
if (value.isEmpty()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
value = value.replace("-", "");
|
|
||||||
|
|
||||||
if (value.length() != 8) {
|
|
||||||
data.invalidate();
|
|
||||||
data.addError(new GlobalizedMessage(
|
|
||||||
"publications.ui.invalid_issn"));
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
Long num = Long.parseLong(value);
|
|
||||||
} catch (NumberFormatException ex) {
|
|
||||||
data.invalidate();
|
|
||||||
data.addError(new GlobalizedMessage(
|
|
||||||
"publications.ui.invalid_issn"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
||||||
add(issn);
|
|
||||||
|
|
||||||
final Calendar today = new GregorianCalendar();
|
|
||||||
final ParameterModel pubDateParam = new DateParameter(
|
|
||||||
InternetArticleController.LAST_ACCESSED
|
|
||||||
);
|
|
||||||
final com.arsdigita.bebop.form.Date pubDate
|
|
||||||
= new com.arsdigita.bebop.form.Date(
|
|
||||||
pubDateParam
|
|
||||||
);
|
|
||||||
pubDate.setYearRange(1900, today.get(Calendar.YEAR) + 2);
|
|
||||||
pubDate.setLabel(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.internetarticle.lastAccessed",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
)
|
|
||||||
);
|
|
||||||
add(pubDate);
|
|
||||||
|
|
||||||
ParameterModel urlModel = new StringParameter(
|
|
||||||
InternetArticleController.URL
|
|
||||||
);
|
|
||||||
TextField url = new TextField(urlModel);
|
|
||||||
url.setLabel(new GlobalizedMessage(
|
|
||||||
"publications.ui.internetarticle.url"));
|
|
||||||
add(url);
|
|
||||||
|
|
||||||
final ParameterModel urnModel = new StringParameter(
|
|
||||||
InternetArticleController.URN
|
|
||||||
);
|
|
||||||
final TextField urn = new TextField(urnModel);
|
|
||||||
urn.setLabel(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.internetarticle.urn",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
)
|
|
||||||
);
|
|
||||||
add(urn);
|
|
||||||
|
|
||||||
final ParameterModel doiModel = new StringParameter(
|
|
||||||
InternetArticleController.DOI
|
|
||||||
);
|
|
||||||
final TextField doi = new TextField(doiModel);
|
|
||||||
doi.setLabel(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.internetarticle.doi",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
)
|
|
||||||
);
|
|
||||||
add(doi);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void init(final FormSectionEvent event) throws FormProcessException {
|
|
||||||
super.init(event);
|
|
||||||
|
|
||||||
final FormData data = event.getFormData();
|
|
||||||
final InternetArticleItem articleItem
|
|
||||||
= (InternetArticleItem) initBasicWidgets(
|
|
||||||
event);
|
|
||||||
final InternetArticle article = articleItem.getPublication();
|
|
||||||
|
|
||||||
data.put(InternetArticleController.PLACE, article.getPlace());
|
|
||||||
data.put(InternetArticleController.NUMBER, article.getNumber());
|
|
||||||
data.put(InternetArticleController.NUMBER_OF_PAGES, article
|
|
||||||
.getNumberOfPages());
|
|
||||||
data.put(InternetArticleController.EDITION, article.getEdition());
|
|
||||||
data.put(InternetArticleController.ISSN, article.getIssn());
|
|
||||||
data.put(
|
|
||||||
InternetArticleController.LAST_ACCESSED,
|
|
||||||
java.util.Date.from(
|
|
||||||
article.getLastAccessed().atStartOfDay().atZone(
|
|
||||||
ZoneId.systemDefault()
|
|
||||||
).toInstant()
|
|
||||||
)
|
|
||||||
);
|
|
||||||
data.put(InternetArticleController.URL, article.getUrl());
|
|
||||||
data.put(InternetArticleController.URN, article.getUrn());
|
|
||||||
data.put(InternetArticleController.DOI, article.getDoi());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void process(final FormSectionEvent event)
|
|
||||||
throws FormProcessException {
|
|
||||||
super.process(event);
|
|
||||||
|
|
||||||
final FormData formData = event.getFormData();
|
|
||||||
final PageState state = event.getPageState();
|
|
||||||
|
|
||||||
final InternetArticleItem articleItem
|
|
||||||
= (InternetArticleItem) processBasicWidgets(
|
|
||||||
event);
|
|
||||||
|
|
||||||
if ((articleItem != null)
|
|
||||||
&& getSaveCancelSection().getSaveButton().isSelected(state)) {
|
|
||||||
final Map<String, Object> data = new HashMap<>();
|
|
||||||
|
|
||||||
data.put(
|
|
||||||
InternetArticleController.PLACE,
|
|
||||||
formData.get(InternetArticleController.PLACE
|
|
||||||
)
|
|
||||||
);
|
|
||||||
data.put(
|
|
||||||
InternetArticleController.NUMBER,
|
|
||||||
formData.get(InternetArticleController.NUMBER
|
|
||||||
)
|
|
||||||
);
|
|
||||||
data.put(
|
|
||||||
InternetArticleController.NUMBER_OF_PAGES,
|
|
||||||
formData.get(InternetArticleController.NUMBER_OF_PAGES
|
|
||||||
)
|
|
||||||
);
|
|
||||||
data.put(
|
|
||||||
InternetArticleController.EDITION,
|
|
||||||
formData.get(InternetArticleController.EDITION
|
|
||||||
)
|
|
||||||
);
|
|
||||||
data.put(
|
|
||||||
InternetArticleController.ISSN,
|
|
||||||
formData.get(InternetArticleController.ISSN
|
|
||||||
)
|
|
||||||
);
|
|
||||||
final java.util.Date lastAccessed = (java.util.Date) formData.get(
|
|
||||||
InternetArticleController.LAST_ACCESSED
|
|
||||||
);
|
|
||||||
data.put(
|
|
||||||
InternetArticleController.LAST_ACCESSED,
|
|
||||||
lastAccessed.toInstant().atZone(
|
|
||||||
ZoneId.systemDefault()
|
|
||||||
).toLocalDate()
|
|
||||||
);
|
|
||||||
data.put(
|
|
||||||
InternetArticleController.URL,
|
|
||||||
formData.get(InternetArticleController.URL
|
|
||||||
)
|
|
||||||
);
|
|
||||||
data.put(
|
|
||||||
InternetArticleController.URN,
|
|
||||||
formData.get(InternetArticleController.URN
|
|
||||||
)
|
|
||||||
);
|
|
||||||
data.put(
|
|
||||||
InternetArticleController.DOI,
|
|
||||||
formData.get(InternetArticleController.DOI
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
final InternetArticleController controller = CdiUtil
|
|
||||||
.createCdiUtil()
|
|
||||||
.findBean(InternetArticleController.class);
|
|
||||||
controller.saveInternetArticle(
|
|
||||||
articleItem.getPublication().getPublicationId(), data
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,82 +0,0 @@
|
||||||
/*
|
|
||||||
* 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 com.arsdigita.cms.contenttypes.ui;
|
|
||||||
|
|
||||||
import com.arsdigita.bebop.PageState;
|
|
||||||
import com.arsdigita.bebop.form.Widget;
|
|
||||||
import com.arsdigita.bebop.parameters.LongParameter;
|
|
||||||
import com.arsdigita.cms.CMS;
|
|
||||||
import com.arsdigita.xml.Element;
|
|
||||||
|
|
||||||
import org.libreccm.cdi.utils.CdiUtil;
|
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
|
||||||
*/
|
|
||||||
public class JournalSearchWidget extends Widget {
|
|
||||||
|
|
||||||
public JournalSearchWidget(final String name) {
|
|
||||||
super(new LongParameter(name));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isCompound() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected String getType() {
|
|
||||||
return "journal-search-widget";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getElementTag() {
|
|
||||||
return "cms:journal-search-widget";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void generateWidget(
|
|
||||||
final PageState state, final Element parent
|
|
||||||
) {
|
|
||||||
final Element widget = parent.newChildElement(getElementTag(),
|
|
||||||
CMS.CMS_XML_NS);
|
|
||||||
|
|
||||||
widget.addAttribute("name", getName());
|
|
||||||
|
|
||||||
final Long value = (Long) getValue(state);
|
|
||||||
if (value != null) {
|
|
||||||
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
|
|
||||||
final JournalSearchWidgetController controller = cdiUtil
|
|
||||||
.findBean(JournalSearchWidgetController.class);
|
|
||||||
|
|
||||||
final Map<String, String> data = controller.getData(value);
|
|
||||||
|
|
||||||
final Element selected = widget
|
|
||||||
.newChildElement("cms:selected-journal", CMS.CMS_XML_NS);
|
|
||||||
selected.addAttribute(
|
|
||||||
"journalId",
|
|
||||||
data.get(JournalSearchWidgetController.JOURNAL_ID)
|
|
||||||
);
|
|
||||||
selected.addAttribute(
|
|
||||||
"title",
|
|
||||||
data.get(JournalSearchWidgetController.TITLE)
|
|
||||||
);
|
|
||||||
selected.addAttribute(
|
|
||||||
"symbol",
|
|
||||||
data.get(JournalSearchWidgetController.SYMBOL)
|
|
||||||
);
|
|
||||||
selected.addAttribute(
|
|
||||||
"issn",
|
|
||||||
data.get(JournalSearchWidgetController.ISSN));
|
|
||||||
|
|
||||||
exportAttributes(widget);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,58 +0,0 @@
|
||||||
/*
|
|
||||||
* 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 com.arsdigita.cms.contenttypes.ui;
|
|
||||||
|
|
||||||
import org.libreccm.l10n.GlobalizationHelper;
|
|
||||||
import org.scientificcms.publications.Journal;
|
|
||||||
import org.scientificcms.publications.JournalRepository;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import javax.enterprise.context.RequestScoped;
|
|
||||||
import javax.inject.Inject;
|
|
||||||
import javax.transaction.Transactional;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
|
||||||
*/
|
|
||||||
@RequestScoped
|
|
||||||
public class JournalSearchWidgetController {
|
|
||||||
|
|
||||||
protected static final String JOURNAL_ID = "journalId";
|
|
||||||
|
|
||||||
protected static final String TITLE = "title";
|
|
||||||
|
|
||||||
protected static final String SYMBOL = "symbol";
|
|
||||||
|
|
||||||
protected static final String ISSN = "issn";
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
private JournalRepository journalRepository;
|
|
||||||
|
|
||||||
@Transactional(Transactional.TxType.REQUIRED)
|
|
||||||
public Map<String, String> getData(final long journalId) {
|
|
||||||
|
|
||||||
final Journal journal = journalRepository
|
|
||||||
.findById(journalId)
|
|
||||||
.orElseThrow(
|
|
||||||
() -> new IllegalArgumentException(
|
|
||||||
String.format("No Journal with ID %d found.", journalId)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
final Map<String, String> data = new HashMap<>();
|
|
||||||
|
|
||||||
data.put(JOURNAL_ID, Long.toString(journal.getJournalId()));
|
|
||||||
data.put(TITLE, journal.getTitle());
|
|
||||||
data.put(SYMBOL, journal.getSymbol());
|
|
||||||
data.put(ISSN, journal.getIssn());
|
|
||||||
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,48 +0,0 @@
|
||||||
/*
|
|
||||||
* 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 com.arsdigita.cms.contenttypes.ui;
|
|
||||||
|
|
||||||
import org.scientificcms.publications.Monograph;
|
|
||||||
import org.scientificcms.publications.PublicationRepository;
|
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import javax.enterprise.context.RequestScoped;
|
|
||||||
import javax.inject.Inject;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
|
||||||
*/
|
|
||||||
@RequestScoped
|
|
||||||
public class MonographController {
|
|
||||||
|
|
||||||
public static final String REVIEWED = "reviewed";
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
private PublicationRepository publicationRepository;
|
|
||||||
|
|
||||||
public void saveMonograph(
|
|
||||||
final long monographId, final Map<String, Object> data
|
|
||||||
) {
|
|
||||||
final Monograph monograph = publicationRepository
|
|
||||||
.findByIdAndType(monographId, Monograph.class)
|
|
||||||
.orElseThrow(
|
|
||||||
() -> new IllegalArgumentException(
|
|
||||||
String.format(
|
|
||||||
"No Monograph with ID %d found.", monographId
|
|
||||||
)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
if (data.containsKey(REVIEWED)) {
|
|
||||||
monograph.setReviewed((Boolean) data.get(REVIEWED));
|
|
||||||
}
|
|
||||||
|
|
||||||
publicationRepository.save(monograph);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,34 +0,0 @@
|
||||||
/*
|
|
||||||
* 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 com.arsdigita.cms.contenttypes.ui;
|
|
||||||
|
|
||||||
import com.arsdigita.bebop.parameters.StringParameter;
|
|
||||||
import com.arsdigita.cms.ItemSelectionModel;
|
|
||||||
import com.arsdigita.cms.ui.authoring.CreationSelector;
|
|
||||||
|
|
||||||
import org.scientificcms.publications.Monograph;
|
|
||||||
import org.scientificcms.publications.contenttypes.MonographItem;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
|
||||||
*/
|
|
||||||
public class MonographCreateForm
|
|
||||||
extends AbstractPublicationCreateForm<Monograph, MonographItem> {
|
|
||||||
|
|
||||||
public MonographCreateForm(final ItemSelectionModel itemModel,
|
|
||||||
final CreationSelector creationSelector,
|
|
||||||
final StringParameter selectedLanguageParam) {
|
|
||||||
super(itemModel, creationSelector, selectedLanguageParam);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected Monograph createPublication() {
|
|
||||||
return new Monograph();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,128 +0,0 @@
|
||||||
/*
|
|
||||||
* 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 com.arsdigita.cms.contenttypes.ui;
|
|
||||||
|
|
||||||
import com.arsdigita.bebop.Component;
|
|
||||||
import com.arsdigita.bebop.Label;
|
|
||||||
import com.arsdigita.bebop.PageState;
|
|
||||||
import com.arsdigita.bebop.parameters.StringParameter;
|
|
||||||
import com.arsdigita.cms.ItemSelectionModel;
|
|
||||||
import com.arsdigita.cms.ui.authoring.AuthoringKitWizard;
|
|
||||||
import com.arsdigita.cms.ui.authoring.BasicPageForm;
|
|
||||||
import com.arsdigita.cms.ui.authoring.SimpleEditStep;
|
|
||||||
import com.arsdigita.cms.ui.workflow.WorkflowLockedComponentAccess;
|
|
||||||
import com.arsdigita.domain.DomainService;
|
|
||||||
import com.arsdigita.globalization.GlobalizedMessage;
|
|
||||||
import com.arsdigita.toolbox.ui.DomainObjectPropertySheet;
|
|
||||||
|
|
||||||
import org.scientificcms.publications.SciPublicationsConstants;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
|
||||||
*/
|
|
||||||
public class MonographPropertiesStep
|
|
||||||
extends PublicationWithPublisherPropertiesStep {
|
|
||||||
|
|
||||||
private final StringParameter selectedLangParam;
|
|
||||||
|
|
||||||
public MonographPropertiesStep(
|
|
||||||
final ItemSelectionModel itemModel,
|
|
||||||
final AuthoringKitWizard parent,
|
|
||||||
final StringParameter selectedLangParam
|
|
||||||
) {
|
|
||||||
super(itemModel, parent, selectedLangParam);
|
|
||||||
this.selectedLangParam = selectedLangParam;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Component getMonographPropertySheet(
|
|
||||||
final ItemSelectionModel itemModel,
|
|
||||||
final StringParameter selectedLangParam
|
|
||||||
) {
|
|
||||||
DomainObjectPropertySheet sheet
|
|
||||||
= (DomainObjectPropertySheet) PublicationWithPublisherPropertiesStep
|
|
||||||
.getPublicationWithPublisherPropertySheet(
|
|
||||||
itemModel,
|
|
||||||
selectedLangParam
|
|
||||||
);
|
|
||||||
|
|
||||||
sheet.add(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.monograph.reviewed",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
),
|
|
||||||
MonographController.REVIEWED,
|
|
||||||
new ReviewedFormatter()
|
|
||||||
);
|
|
||||||
|
|
||||||
return sheet;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void addBasicProperties(
|
|
||||||
final ItemSelectionModel itemModel, final AuthoringKitWizard parent
|
|
||||||
) {
|
|
||||||
final SimpleEditStep basicProperties = new SimpleEditStep(
|
|
||||||
itemModel, parent, selectedLangParam, EDIT_SHEET_NAME
|
|
||||||
);
|
|
||||||
|
|
||||||
final BasicPageForm editBasicSheet
|
|
||||||
= new MonographPropertyForm(
|
|
||||||
itemModel, this, selectedLangParam
|
|
||||||
);
|
|
||||||
|
|
||||||
basicProperties.add(
|
|
||||||
EDIT_SHEET_NAME,
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.monograph.edit_basic_sheet",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
),
|
|
||||||
new WorkflowLockedComponentAccess(editBasicSheet, itemModel),
|
|
||||||
editBasicSheet.getSaveCancelSection().getCancelButton()
|
|
||||||
);
|
|
||||||
|
|
||||||
basicProperties.setDisplayComponent(
|
|
||||||
getMonographPropertySheet(itemModel, selectedLangParam)
|
|
||||||
);
|
|
||||||
|
|
||||||
getSegmentedPanel().addSegment(
|
|
||||||
new Label(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.publication.basic_properties",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
)
|
|
||||||
),
|
|
||||||
basicProperties);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class ReviewedFormatter
|
|
||||||
extends DomainService
|
|
||||||
implements DomainObjectPropertySheet.AttributeFormatter {
|
|
||||||
|
|
||||||
public ReviewedFormatter() {
|
|
||||||
super();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String format(
|
|
||||||
final Object obj, final String attribute, final PageState state
|
|
||||||
) {
|
|
||||||
if ((get(obj, attribute) != null)
|
|
||||||
&& (get(obj, attribute) instanceof Boolean)
|
|
||||||
&& ((Boolean) get(obj, attribute) == true)) {
|
|
||||||
return (String) new GlobalizedMessage(
|
|
||||||
"publications.ui.monograph.reviewed.yes",
|
|
||||||
SciPublicationsConstants.BUNDLE).localize();
|
|
||||||
} else {
|
|
||||||
return (String) new GlobalizedMessage(
|
|
||||||
"publications.ui.monograph.reviewed.no",
|
|
||||||
SciPublicationsConstants.BUNDLE).localize();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,133 +0,0 @@
|
||||||
/*
|
|
||||||
* 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 com.arsdigita.cms.contenttypes.ui;
|
|
||||||
|
|
||||||
import com.arsdigita.bebop.FormData;
|
|
||||||
import com.arsdigita.bebop.FormProcessException;
|
|
||||||
import com.arsdigita.bebop.Label;
|
|
||||||
import com.arsdigita.bebop.PageState;
|
|
||||||
import com.arsdigita.bebop.event.FormInitListener;
|
|
||||||
import com.arsdigita.bebop.event.FormProcessListener;
|
|
||||||
import com.arsdigita.bebop.event.FormSectionEvent;
|
|
||||||
import com.arsdigita.bebop.event.FormSubmissionListener;
|
|
||||||
import com.arsdigita.bebop.form.CheckboxGroup;
|
|
||||||
import com.arsdigita.bebop.form.Option;
|
|
||||||
import com.arsdigita.bebop.parameters.StringParameter;
|
|
||||||
import com.arsdigita.cms.ItemSelectionModel;
|
|
||||||
import com.arsdigita.globalization.GlobalizedMessage;
|
|
||||||
|
|
||||||
import org.libreccm.cdi.utils.CdiUtil;
|
|
||||||
import org.scientificcms.publications.Monograph;
|
|
||||||
import org.scientificcms.publications.SciPublicationsConstants;
|
|
||||||
import org.scientificcms.publications.contenttypes.MonographItem;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
|
||||||
*/
|
|
||||||
public class MonographPropertyForm extends PublicationWithPublisherPropertyForm
|
|
||||||
implements FormProcessListener, FormInitListener, FormSubmissionListener {
|
|
||||||
|
|
||||||
public static final String ID = "MonographEdit";
|
|
||||||
|
|
||||||
|
|
||||||
private CheckboxGroup reviewed;
|
|
||||||
|
|
||||||
public MonographPropertyForm(
|
|
||||||
final ItemSelectionModel itemModel,
|
|
||||||
final StringParameter selectedLangParam
|
|
||||||
) {
|
|
||||||
this(itemModel, null, selectedLangParam);
|
|
||||||
}
|
|
||||||
|
|
||||||
public MonographPropertyForm(
|
|
||||||
final ItemSelectionModel itemModel,
|
|
||||||
final MonographPropertiesStep step,
|
|
||||||
final StringParameter selectedLangParam
|
|
||||||
) {
|
|
||||||
super(itemModel, step, selectedLangParam);
|
|
||||||
addSubmissionListener(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void addWidgets() {
|
|
||||||
|
|
||||||
super.addWidgets();
|
|
||||||
|
|
||||||
reviewed = new CheckboxGroup("reviewedGroup");
|
|
||||||
reviewed.addOption(
|
|
||||||
new Option(
|
|
||||||
MonographController.REVIEWED,
|
|
||||||
new Label(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.monograph.reviewed",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
reviewed.setLabel(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.monograph.reviewed",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
)
|
|
||||||
);
|
|
||||||
add(reviewed);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void init(final FormSectionEvent event) throws FormProcessException {
|
|
||||||
super.init(event);
|
|
||||||
|
|
||||||
final FormData data = event.getFormData();
|
|
||||||
final MonographItem monographItem = (MonographItem) super
|
|
||||||
.initBasicWidgets(event);
|
|
||||||
final Monograph monograph = monographItem.getPublication();
|
|
||||||
|
|
||||||
if ((monograph.getReviewed() != null) && (monograph.getReviewed())) {
|
|
||||||
reviewed.setValue(
|
|
||||||
event.getPageState(),
|
|
||||||
new String[]{MonographController.REVIEWED}
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
reviewed.setValue(event.getPageState(), null);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void process(final FormSectionEvent event)
|
|
||||||
throws FormProcessException {
|
|
||||||
super.process(event);
|
|
||||||
|
|
||||||
final PageState state = event.getPageState();
|
|
||||||
final MonographItem monographItem = (MonographItem) super
|
|
||||||
.processBasicWidgets(event);
|
|
||||||
|
|
||||||
if ((monographItem != null)
|
|
||||||
&& getSaveCancelSection().getSaveButton().isSelected(state)) {
|
|
||||||
|
|
||||||
final Map<String, Object> data = new HashMap<>();
|
|
||||||
if (reviewed.getValue(event.getPageState()) == null) {
|
|
||||||
data.put(MonographController.REVIEWED, false);
|
|
||||||
} else {
|
|
||||||
data.put(MonographController.REVIEWED, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
final MonographController controller = CdiUtil
|
|
||||||
.createCdiUtil()
|
|
||||||
.findBean(MonographController.class);
|
|
||||||
controller.saveMonograph(
|
|
||||||
monographItem.getPublication().getPublicationId(),
|
|
||||||
data
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,184 +0,0 @@
|
||||||
/*
|
|
||||||
* 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 com.arsdigita.cms.contenttypes.ui;
|
|
||||||
|
|
||||||
import org.librecms.assets.Organization;
|
|
||||||
import org.librecms.contentsection.AssetRepository;
|
|
||||||
import org.scientificcms.publications.InProceedings;
|
|
||||||
import org.scientificcms.publications.Proceedings;
|
|
||||||
import org.scientificcms.publications.ProceedingsManager;
|
|
||||||
import org.scientificcms.publications.PublicationRepository;
|
|
||||||
|
|
||||||
import java.time.LocalDate;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import javax.enterprise.context.RequestScoped;
|
|
||||||
import javax.inject.Inject;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
|
||||||
*/
|
|
||||||
@RequestScoped
|
|
||||||
public class ProceedingsController {
|
|
||||||
|
|
||||||
public static final String NAME_OF_CONFERENCE = "nameOfConference";
|
|
||||||
|
|
||||||
public static final String PLACE_OF_CONFERENCE = "placeOfConference";
|
|
||||||
|
|
||||||
public static final String START_DATE = "startDate";
|
|
||||||
|
|
||||||
public static final String END_DATE = "endDate";
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
private AssetRepository assetRepository;
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
private ProceedingsManager proceedingsManager;
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
private PublicationRepository publicationRepository;
|
|
||||||
|
|
||||||
public void saveProceedings(
|
|
||||||
final long proceedingsId, final Map<String, Object> data
|
|
||||||
) {
|
|
||||||
final Proceedings proceedings = publicationRepository
|
|
||||||
.findByIdAndType(proceedingsId, Proceedings.class)
|
|
||||||
.orElseThrow(
|
|
||||||
() -> new IllegalArgumentException(
|
|
||||||
String.format(
|
|
||||||
"No Procceedings with ID %d found.", proceedingsId
|
|
||||||
)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
if (data.containsKey(NAME_OF_CONFERENCE)) {
|
|
||||||
proceedings.setNameOfConference(
|
|
||||||
(String) data.get(NAME_OF_CONFERENCE)
|
|
||||||
);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
if (data.containsKey(PLACE_OF_CONFERENCE)) {
|
|
||||||
proceedings.setPlaceOfConference((String) data.get(
|
|
||||||
PLACE_OF_CONFERENCE)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (data.containsKey(START_DATE)) {
|
|
||||||
proceedings.setStartDate((LocalDate) data.get(START_DATE));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (data.containsKey(END_DATE)) {
|
|
||||||
proceedings.setStartDate((LocalDate) data.get(END_DATE));
|
|
||||||
}
|
|
||||||
|
|
||||||
publicationRepository.save(proceedings);
|
|
||||||
}
|
|
||||||
|
|
||||||
public InProceedings findPaper(final long paperId) {
|
|
||||||
final InProceedings paper = publicationRepository
|
|
||||||
.findByIdAndType(paperId, InProceedings.class)
|
|
||||||
.orElseThrow(
|
|
||||||
() -> new IllegalArgumentException(
|
|
||||||
String.format(
|
|
||||||
"No InProcceedings with ID %d found.", paperId
|
|
||||||
)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
return paper;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addPaper(final long proceedingsId, final long paperId) {
|
|
||||||
final Proceedings proceedings = publicationRepository
|
|
||||||
.findByIdAndType(proceedingsId, Proceedings.class)
|
|
||||||
.orElseThrow(
|
|
||||||
() -> new IllegalArgumentException(
|
|
||||||
String.format(
|
|
||||||
"No Procceedings with ID %d found.", proceedingsId
|
|
||||||
)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
final InProceedings paper = publicationRepository
|
|
||||||
.findByIdAndType(paperId, InProceedings.class)
|
|
||||||
.orElseThrow(
|
|
||||||
() -> new IllegalArgumentException(
|
|
||||||
String.format(
|
|
||||||
"No InProcceedings with ID %d found.", paperId
|
|
||||||
)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
proceedingsManager.addPaperToCollectedVolume(paper, proceedings);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void removePaper(final long proceedingsId, final long paperId) {
|
|
||||||
final Proceedings proceedings = publicationRepository
|
|
||||||
.findByIdAndType(proceedingsId, Proceedings.class)
|
|
||||||
.orElseThrow(
|
|
||||||
() -> new IllegalArgumentException(
|
|
||||||
String.format(
|
|
||||||
"No Procceedings with ID %d found.", proceedingsId
|
|
||||||
)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
final InProceedings paper = publicationRepository
|
|
||||||
.findByIdAndType(paperId, InProceedings.class)
|
|
||||||
.orElseThrow(
|
|
||||||
() -> new IllegalArgumentException(
|
|
||||||
String.format(
|
|
||||||
"No InProcceedings with ID %d found.", paperId
|
|
||||||
)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
proceedingsManager.removeArticleFromCollectedVolume(paper, proceedings);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setOrganizier(final long proceedingsId, final long organizerId) {
|
|
||||||
final Proceedings proceedings = publicationRepository
|
|
||||||
.findByIdAndType(proceedingsId, Proceedings.class)
|
|
||||||
.orElseThrow(
|
|
||||||
() -> new IllegalArgumentException(
|
|
||||||
String.format(
|
|
||||||
"No Procceedings with ID %d found.", proceedingsId
|
|
||||||
)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
final Organization organizer = assetRepository
|
|
||||||
.findById(organizerId, Organization.class)
|
|
||||||
.orElseThrow(
|
|
||||||
() -> new IllegalArgumentException(
|
|
||||||
String.format(
|
|
||||||
"No Organization with ID %d found.", organizerId
|
|
||||||
)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
proceedings.setOrganizer(organizer);
|
|
||||||
publicationRepository.save(proceedings);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void unsetOrganizier(final long proceedingsId) {
|
|
||||||
final Proceedings proceedings = publicationRepository
|
|
||||||
.findByIdAndType(proceedingsId, Proceedings.class)
|
|
||||||
.orElseThrow(
|
|
||||||
() -> new IllegalArgumentException(
|
|
||||||
String.format(
|
|
||||||
"No Procceedings with ID %d found.", proceedingsId
|
|
||||||
)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
proceedings.setOrganizer(null);
|
|
||||||
publicationRepository.save(proceedings);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,33 +0,0 @@
|
||||||
/*
|
|
||||||
* 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 com.arsdigita.cms.contenttypes.ui;
|
|
||||||
|
|
||||||
import com.arsdigita.bebop.parameters.StringParameter;
|
|
||||||
import com.arsdigita.cms.ItemSelectionModel;
|
|
||||||
import com.arsdigita.cms.ui.authoring.CreationSelector;
|
|
||||||
|
|
||||||
import org.scientificcms.publications.Proceedings;
|
|
||||||
import org.scientificcms.publications.contenttypes.ProceedingsItem;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
|
||||||
*/
|
|
||||||
public class ProceedingsCreateForm
|
|
||||||
extends AbstractPublicationCreateForm<Proceedings, ProceedingsItem>{
|
|
||||||
|
|
||||||
public ProceedingsCreateForm(final ItemSelectionModel itemModel,
|
|
||||||
final CreationSelector creationSelector,
|
|
||||||
final StringParameter selectedLanguageParam) {
|
|
||||||
super(itemModel, creationSelector, selectedLanguageParam);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected Proceedings createPublication() {
|
|
||||||
return new Proceedings();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,89 +0,0 @@
|
||||||
/*
|
|
||||||
* 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 com.arsdigita.cms.contenttypes.ui;
|
|
||||||
|
|
||||||
import com.arsdigita.bebop.FormProcessException;
|
|
||||||
import com.arsdigita.bebop.PageState;
|
|
||||||
import com.arsdigita.bebop.event.FormInitListener;
|
|
||||||
import com.arsdigita.bebop.event.FormProcessListener;
|
|
||||||
import com.arsdigita.bebop.event.FormSectionEvent;
|
|
||||||
import com.arsdigita.bebop.parameters.StringParameter;
|
|
||||||
import com.arsdigita.cms.ItemSelectionModel;
|
|
||||||
import com.arsdigita.cms.ui.assets.AssetSearchWidget;
|
|
||||||
import com.arsdigita.cms.ui.authoring.BasicItemForm;
|
|
||||||
import com.arsdigita.globalization.GlobalizedMessage;
|
|
||||||
|
|
||||||
import org.libreccm.cdi.utils.CdiUtil;
|
|
||||||
import org.librecms.assets.Organization;
|
|
||||||
import org.scientificcms.publications.SciPublicationsConstants;
|
|
||||||
import org.scientificcms.publications.contenttypes.ProceedingsItem;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
|
||||||
*/
|
|
||||||
public class ProceedingsOrganizerForm
|
|
||||||
extends BasicItemForm
|
|
||||||
implements FormProcessListener, FormInitListener {
|
|
||||||
|
|
||||||
private static final String ORGA_SEARCH = "conferenceOrganization";
|
|
||||||
|
|
||||||
private AssetSearchWidget orgaSearch;
|
|
||||||
|
|
||||||
private final ItemSelectionModel itemModel;
|
|
||||||
|
|
||||||
public ProceedingsOrganizerForm(
|
|
||||||
final ItemSelectionModel itemModel,
|
|
||||||
final StringParameter selectedLangParam
|
|
||||||
) {
|
|
||||||
super("ProceeingsOrganizerForm", itemModel, selectedLangParam);
|
|
||||||
this.itemModel = itemModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void addWidgets() {
|
|
||||||
orgaSearch = new AssetSearchWidget(
|
|
||||||
ORGA_SEARCH, Organization.class
|
|
||||||
);
|
|
||||||
orgaSearch.setLabel(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.proceedings.organizer",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
)
|
|
||||||
);
|
|
||||||
add(orgaSearch);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void init(final FormSectionEvent event) throws FormProcessException {
|
|
||||||
final PageState state = event.getPageState();
|
|
||||||
|
|
||||||
setVisible(state, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void process(final FormSectionEvent event)
|
|
||||||
throws FormProcessException {
|
|
||||||
final PageState state = event.getPageState();
|
|
||||||
final ProceedingsItem proceedingsItem = (ProceedingsItem) itemModel.
|
|
||||||
getSelectedItem(state);
|
|
||||||
|
|
||||||
if (getSaveCancelSection().getSaveButton().isSelected(state)) {
|
|
||||||
final Organization organization = (Organization) orgaSearch
|
|
||||||
.getValue(state);
|
|
||||||
final ProceedingsController controller = CdiUtil
|
|
||||||
.createCdiUtil()
|
|
||||||
.findBean(ProceedingsController.class);
|
|
||||||
controller.setOrganizier(
|
|
||||||
proceedingsItem.getPublication().getPublicationId(),
|
|
||||||
organization.getObjectId()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
init(event);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,269 +0,0 @@
|
||||||
/*
|
|
||||||
* 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 com.arsdigita.cms.contenttypes.ui;
|
|
||||||
|
|
||||||
import com.arsdigita.bebop.Component;
|
|
||||||
import com.arsdigita.bebop.ControlLink;
|
|
||||||
import com.arsdigita.bebop.Label;
|
|
||||||
import com.arsdigita.bebop.PageState;
|
|
||||||
import com.arsdigita.bebop.Table;
|
|
||||||
import com.arsdigita.bebop.Text;
|
|
||||||
import com.arsdigita.bebop.event.TableActionEvent;
|
|
||||||
import com.arsdigita.bebop.event.TableActionListener;
|
|
||||||
import com.arsdigita.bebop.table.TableCellRenderer;
|
|
||||||
import com.arsdigita.bebop.table.TableColumn;
|
|
||||||
import com.arsdigita.bebop.table.TableColumnModel;
|
|
||||||
import com.arsdigita.bebop.table.TableModel;
|
|
||||||
import com.arsdigita.bebop.table.TableModelBuilder;
|
|
||||||
import com.arsdigita.cms.ItemSelectionModel;
|
|
||||||
import com.arsdigita.globalization.GlobalizedMessage;
|
|
||||||
import com.arsdigita.util.LockableImpl;
|
|
||||||
|
|
||||||
import org.libreccm.cdi.utils.CdiUtil;
|
|
||||||
import org.libreccm.security.PermissionChecker;
|
|
||||||
import org.librecms.assets.Organization;
|
|
||||||
import org.librecms.contentsection.privileges.ItemPrivileges;
|
|
||||||
import org.scientificcms.publications.Proceedings;
|
|
||||||
import org.scientificcms.publications.SciPublicationsConstants;
|
|
||||||
import org.scientificcms.publications.contenttypes.ProceedingsItem;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
|
||||||
*/
|
|
||||||
public class ProceedingsOrganizerSheet
|
|
||||||
extends Table
|
|
||||||
implements TableActionListener {
|
|
||||||
|
|
||||||
private static final String TABLE_COL_EDIT = "table_col_edit";
|
|
||||||
|
|
||||||
private static final String TABLE_COL_DEL = "table_col_del";
|
|
||||||
|
|
||||||
private final ItemSelectionModel itemModel;
|
|
||||||
|
|
||||||
public ProceedingsOrganizerSheet(final ItemSelectionModel itemModel) {
|
|
||||||
super();
|
|
||||||
|
|
||||||
this.itemModel = itemModel;
|
|
||||||
|
|
||||||
setEmptyView(
|
|
||||||
new Label(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.proceedings.organizer.none",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
final TableColumnModel columnModel = getColumnModel();
|
|
||||||
columnModel.add(
|
|
||||||
new TableColumn(
|
|
||||||
0,
|
|
||||||
new Label(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.proceedings.organizer",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
)
|
|
||||||
),
|
|
||||||
TABLE_COL_EDIT
|
|
||||||
)
|
|
||||||
);
|
|
||||||
columnModel.add(
|
|
||||||
new TableColumn(
|
|
||||||
1,
|
|
||||||
new Label(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.proceedings.organizer.remove",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
)
|
|
||||||
),
|
|
||||||
TABLE_COL_DEL
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
setModelBuilder(new ProceedingsOrganizerSheetModelBuilder(itemModel));
|
|
||||||
columnModel.get(0).setCellRenderer(new EditCellRenderer());
|
|
||||||
columnModel.get(1).setCellRenderer(new DeleteCellRenderer());
|
|
||||||
|
|
||||||
addTableActionListener(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void cellSelected(final TableActionEvent event) {
|
|
||||||
final PageState state = event.getPageState();
|
|
||||||
|
|
||||||
final ProceedingsItem proceedingsItem = (ProceedingsItem) itemModel
|
|
||||||
.getSelectedItem(state);
|
|
||||||
|
|
||||||
final TableColumn column = getColumnModel().get(event.getColumn());
|
|
||||||
|
|
||||||
if (column.getHeaderKey().toString().equals(TABLE_COL_EDIT)) {
|
|
||||||
// Nothing
|
|
||||||
} else if (column.getHeaderKey().toString().equals(TABLE_COL_DEL)) {
|
|
||||||
final ProceedingsController controller = CdiUtil
|
|
||||||
.createCdiUtil()
|
|
||||||
.findBean(ProceedingsController.class);
|
|
||||||
controller.unsetOrganizier(
|
|
||||||
proceedingsItem.getPublication().getPublicationId()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void headSelected(final TableActionEvent event) {
|
|
||||||
//Nothing to do
|
|
||||||
}
|
|
||||||
|
|
||||||
private class ProceedingsOrganizerSheetModelBuilder
|
|
||||||
extends LockableImpl
|
|
||||||
implements TableModelBuilder {
|
|
||||||
|
|
||||||
private final ItemSelectionModel itemModel;
|
|
||||||
|
|
||||||
public ProceedingsOrganizerSheetModelBuilder(
|
|
||||||
final ItemSelectionModel itemModel
|
|
||||||
) {
|
|
||||||
this.itemModel = itemModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public final TableModel makeModel(
|
|
||||||
final Table table, final PageState state
|
|
||||||
) {
|
|
||||||
table.getRowSelectionModel().clearSelection(state);
|
|
||||||
final ProceedingsItem proceedingsItem = (ProceedingsItem) itemModel
|
|
||||||
.getSelectedItem(state);
|
|
||||||
return new ProceedingsOrganizerSheetModel(
|
|
||||||
table, state, proceedingsItem.getPublication()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private class ProceedingsOrganizerSheetModel implements TableModel {
|
|
||||||
|
|
||||||
private final Table table;
|
|
||||||
|
|
||||||
private final Organization organizer;
|
|
||||||
|
|
||||||
private boolean done;
|
|
||||||
|
|
||||||
public ProceedingsOrganizerSheetModel(
|
|
||||||
final Table table,
|
|
||||||
final PageState state,
|
|
||||||
final Proceedings proceedings
|
|
||||||
) {
|
|
||||||
this.table = table;
|
|
||||||
organizer = proceedings.getOrganizer();
|
|
||||||
done = organizer != null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getColumnCount() {
|
|
||||||
return table.getColumnModel().size();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean nextRow() {
|
|
||||||
boolean ret;
|
|
||||||
|
|
||||||
if (done) {
|
|
||||||
ret = true;
|
|
||||||
done = false;
|
|
||||||
} else {
|
|
||||||
ret = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object getElementAt(final int columnIndex) {
|
|
||||||
switch (columnIndex) {
|
|
||||||
case 0:
|
|
||||||
return organizer.getTitle();
|
|
||||||
case 1:
|
|
||||||
return new Label(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.proceedings.organizer.remove",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
)
|
|
||||||
);
|
|
||||||
default:
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object getKeyAt(final int columnIndex) {
|
|
||||||
return organizer.getObjectId();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private class EditCellRenderer
|
|
||||||
extends LockableImpl
|
|
||||||
implements TableCellRenderer {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public final Component getComponent(
|
|
||||||
final Table table,
|
|
||||||
final PageState state,
|
|
||||||
final Object value,
|
|
||||||
final boolean isSelected,
|
|
||||||
final Object key,
|
|
||||||
final int row,
|
|
||||||
final int column
|
|
||||||
) {
|
|
||||||
return new Text((String) value);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private class DeleteCellRenderer
|
|
||||||
extends LockableImpl
|
|
||||||
implements TableCellRenderer {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Component getComponent(
|
|
||||||
final Table table,
|
|
||||||
final PageState state,
|
|
||||||
final Object value,
|
|
||||||
final boolean isSelected,
|
|
||||||
final Object key,
|
|
||||||
final int row,
|
|
||||||
final int col
|
|
||||||
) {
|
|
||||||
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
|
|
||||||
|
|
||||||
final PermissionChecker permissionChecker = cdiUtil
|
|
||||||
.findBean(PermissionChecker.class);
|
|
||||||
|
|
||||||
final ProceedingsItem proceedingsItem = (ProceedingsItem) itemModel
|
|
||||||
.getSelectedItem(state);
|
|
||||||
|
|
||||||
final boolean canEdit = permissionChecker.isPermitted(
|
|
||||||
ItemPrivileges.DELETE, proceedingsItem
|
|
||||||
);
|
|
||||||
|
|
||||||
if (canEdit) {
|
|
||||||
final ControlLink link = new ControlLink((Component) value);
|
|
||||||
link.setConfirmation(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publication.ui.proceedings.organizer.remove.confirm",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
)
|
|
||||||
);
|
|
||||||
return link;
|
|
||||||
} else {
|
|
||||||
return new Text("");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,61 +0,0 @@
|
||||||
/*
|
|
||||||
* 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 com.arsdigita.cms.contenttypes.ui;
|
|
||||||
|
|
||||||
import com.arsdigita.bebop.parameters.StringParameter;
|
|
||||||
import com.arsdigita.cms.ItemSelectionModel;
|
|
||||||
import com.arsdigita.cms.ui.authoring.AuthoringKitWizard;
|
|
||||||
import com.arsdigita.cms.ui.authoring.BasicItemForm;
|
|
||||||
import com.arsdigita.cms.ui.authoring.SimpleEditStep;
|
|
||||||
import com.arsdigita.cms.ui.workflow.WorkflowLockedComponentAccess;
|
|
||||||
import com.arsdigita.globalization.GlobalizedMessage;
|
|
||||||
|
|
||||||
import org.scientificcms.publications.SciPublicationsConstants;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
|
||||||
*/
|
|
||||||
public class ProceedingsOrganizerStep extends SimpleEditStep {
|
|
||||||
|
|
||||||
private static final String SET_PROCEEDINGS_ORGANIZER_STEP
|
|
||||||
= "setProceedingsOrganizerStep";
|
|
||||||
|
|
||||||
public ProceedingsOrganizerStep(
|
|
||||||
final ItemSelectionModel itemModel,
|
|
||||||
final AuthoringKitWizard parent,
|
|
||||||
final StringParameter selectedLangParam
|
|
||||||
) {
|
|
||||||
this(itemModel, parent, selectedLangParam, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ProceedingsOrganizerStep(
|
|
||||||
final ItemSelectionModel itemModel,
|
|
||||||
final AuthoringKitWizard parent,
|
|
||||||
final StringParameter selectedLangParam,
|
|
||||||
final String prefix
|
|
||||||
) {
|
|
||||||
super(itemModel, parent, selectedLangParam, prefix);
|
|
||||||
|
|
||||||
final BasicItemForm setOrganizerForm = new ProceedingsOrganizerForm(
|
|
||||||
itemModel, selectedLangParam
|
|
||||||
);
|
|
||||||
add(
|
|
||||||
SET_PROCEEDINGS_ORGANIZER_STEP,
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.proceedings.setOrganizer",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
),
|
|
||||||
new WorkflowLockedComponentAccess(setOrganizerForm, itemModel),
|
|
||||||
setOrganizerForm.getSaveCancelSection().getCancelButton());
|
|
||||||
|
|
||||||
final ProceedingsOrganizerSheet sheet = new ProceedingsOrganizerSheet(
|
|
||||||
itemModel
|
|
||||||
);
|
|
||||||
setDisplayComponent(sheet);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,91 +0,0 @@
|
||||||
/*
|
|
||||||
* 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 com.arsdigita.cms.contenttypes.ui;
|
|
||||||
|
|
||||||
import com.arsdigita.bebop.FormData;
|
|
||||||
import com.arsdigita.bebop.FormProcessException;
|
|
||||||
import com.arsdigita.bebop.PageState;
|
|
||||||
import com.arsdigita.bebop.event.FormInitListener;
|
|
||||||
import com.arsdigita.bebop.event.FormProcessListener;
|
|
||||||
import com.arsdigita.bebop.event.FormSectionEvent;
|
|
||||||
import com.arsdigita.bebop.parameters.StringParameter;
|
|
||||||
import com.arsdigita.cms.ItemSelectionModel;
|
|
||||||
import com.arsdigita.cms.ui.authoring.BasicItemForm;
|
|
||||||
import com.arsdigita.globalization.GlobalizedMessage;
|
|
||||||
|
|
||||||
import org.libreccm.cdi.utils.CdiUtil;
|
|
||||||
import org.scientificcms.publications.InProceedings;
|
|
||||||
import org.scientificcms.publications.Proceedings;
|
|
||||||
import org.scientificcms.publications.SciPublicationsConstants;
|
|
||||||
import org.scientificcms.publications.contenttypes.ProceedingsItem;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
|
||||||
*/
|
|
||||||
public class ProceedingsPapersAddForm extends BasicItemForm
|
|
||||||
implements FormProcessListener,
|
|
||||||
FormInitListener {
|
|
||||||
|
|
||||||
private static final String PAPER_SEARCH = "papers";
|
|
||||||
|
|
||||||
private PublicationSearchWidget paperSearch;
|
|
||||||
|
|
||||||
public ProceedingsPapersAddForm(
|
|
||||||
final ItemSelectionModel itemModel,
|
|
||||||
final StringParameter selectedLangParam
|
|
||||||
) {
|
|
||||||
super("PapersAddForm", itemModel, selectedLangParam);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void addWidgets() {
|
|
||||||
paperSearch = new PublicationSearchWidget(
|
|
||||||
PAPER_SEARCH, InProceedings.class
|
|
||||||
);
|
|
||||||
paperSearch.setLabel(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.proceedings.select_paper",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
)
|
|
||||||
);
|
|
||||||
add(paperSearch);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void init(final FormSectionEvent event) throws FormProcessException {
|
|
||||||
PageState state = event.getPageState();
|
|
||||||
setVisible(state, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void process(final FormSectionEvent event)
|
|
||||||
throws FormProcessException {
|
|
||||||
final FormData formData = event.getFormData();
|
|
||||||
final PageState state = event.getPageState();
|
|
||||||
final ProceedingsItem proceedingsItem
|
|
||||||
= (ProceedingsItem) getItemSelectionModel().
|
|
||||||
getSelectedObject(state);
|
|
||||||
final Proceedings proceedings = proceedingsItem.getPublication();
|
|
||||||
|
|
||||||
if (getSaveCancelSection().getSaveButton().isSelected(state)) {
|
|
||||||
final InProceedings paper = (InProceedings) formData.get(
|
|
||||||
PAPER_SEARCH
|
|
||||||
);
|
|
||||||
|
|
||||||
final ProceedingsController controller = CdiUtil
|
|
||||||
.createCdiUtil()
|
|
||||||
.findBean(ProceedingsController.class);
|
|
||||||
controller.addPaper(
|
|
||||||
proceedings.getPublicationId(), paper.getPublicationId()
|
|
||||||
);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
init(event);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,61 +0,0 @@
|
||||||
/*
|
|
||||||
* 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 com.arsdigita.cms.contenttypes.ui;
|
|
||||||
|
|
||||||
import com.arsdigita.bebop.parameters.StringParameter;
|
|
||||||
import com.arsdigita.cms.ItemSelectionModel;
|
|
||||||
import com.arsdigita.cms.ui.authoring.AuthoringKitWizard;
|
|
||||||
import com.arsdigita.cms.ui.authoring.BasicItemForm;
|
|
||||||
import com.arsdigita.cms.ui.authoring.SimpleEditStep;
|
|
||||||
import com.arsdigita.cms.ui.workflow.WorkflowLockedComponentAccess;
|
|
||||||
import com.arsdigita.globalization.GlobalizedMessage;
|
|
||||||
|
|
||||||
import org.scientificcms.publications.SciPublicationsConstants;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
|
||||||
*/
|
|
||||||
public class ProceedingsPapersStep extends SimpleEditStep {
|
|
||||||
|
|
||||||
private static final String ADD_PAPER_SHEET_NAME = "addPaper";
|
|
||||||
|
|
||||||
public ProceedingsPapersStep(
|
|
||||||
final ItemSelectionModel itemModel,
|
|
||||||
final AuthoringKitWizard parent,
|
|
||||||
final StringParameter selectedLangParam
|
|
||||||
) {
|
|
||||||
this(itemModel, parent, selectedLangParam, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ProceedingsPapersStep(
|
|
||||||
final ItemSelectionModel itemModel,
|
|
||||||
final AuthoringKitWizard parent,
|
|
||||||
final StringParameter selectedLangParam,
|
|
||||||
final String prefix
|
|
||||||
) {
|
|
||||||
super(itemModel, parent, selectedLangParam, prefix);
|
|
||||||
|
|
||||||
BasicItemForm addPaperSheet = new ProceedingsPapersAddForm(
|
|
||||||
itemModel, selectedLangParam
|
|
||||||
);
|
|
||||||
add(
|
|
||||||
ADD_PAPER_SHEET_NAME,
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.proceedings.add_paper",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
),
|
|
||||||
new WorkflowLockedComponentAccess(addPaperSheet, itemModel),
|
|
||||||
addPaperSheet.getSaveCancelSection().getCancelButton());
|
|
||||||
|
|
||||||
final ProceedingsPapersTable papersTable = new ProceedingsPapersTable(
|
|
||||||
itemModel
|
|
||||||
);
|
|
||||||
setDisplayComponent(papersTable);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,274 +0,0 @@
|
||||||
/*
|
|
||||||
* 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 com.arsdigita.cms.contenttypes.ui;
|
|
||||||
|
|
||||||
import com.arsdigita.bebop.Component;
|
|
||||||
import com.arsdigita.bebop.ControlLink;
|
|
||||||
import com.arsdigita.bebop.Label;
|
|
||||||
import com.arsdigita.bebop.PageState;
|
|
||||||
import com.arsdigita.bebop.Table;
|
|
||||||
import com.arsdigita.bebop.Text;
|
|
||||||
import com.arsdigita.bebop.event.TableActionEvent;
|
|
||||||
import com.arsdigita.bebop.event.TableActionListener;
|
|
||||||
import com.arsdigita.bebop.table.TableCellRenderer;
|
|
||||||
import com.arsdigita.bebop.table.TableColumn;
|
|
||||||
import com.arsdigita.bebop.table.TableColumnModel;
|
|
||||||
import com.arsdigita.bebop.table.TableModel;
|
|
||||||
import com.arsdigita.bebop.table.TableModelBuilder;
|
|
||||||
import com.arsdigita.cms.ItemSelectionModel;
|
|
||||||
import com.arsdigita.cms.dispatcher.Utilities;
|
|
||||||
import com.arsdigita.globalization.GlobalizedMessage;
|
|
||||||
import com.arsdigita.util.LockableImpl;
|
|
||||||
|
|
||||||
import org.apache.logging.log4j.LogManager;
|
|
||||||
import org.apache.logging.log4j.Logger;
|
|
||||||
import org.libreccm.cdi.utils.CdiUtil;
|
|
||||||
import org.libreccm.security.PermissionChecker;
|
|
||||||
import org.librecms.contentsection.privileges.ItemPrivileges;
|
|
||||||
import org.scientificcms.publications.InProceedings;
|
|
||||||
import org.scientificcms.publications.Proceedings;
|
|
||||||
import org.scientificcms.publications.SciPublicationsConstants;
|
|
||||||
import org.scientificcms.publications.contenttypes.ProceedingsItem;
|
|
||||||
|
|
||||||
import java.util.Iterator;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
|
||||||
*/
|
|
||||||
public class ProceedingsPapersTable
|
|
||||||
extends Table
|
|
||||||
implements TableActionListener {
|
|
||||||
|
|
||||||
private final Logger LOGGER = LogManager.getLogger(
|
|
||||||
ProceedingsPapersTable.class);
|
|
||||||
|
|
||||||
private final String TABLE_COL_EDIT = "table_col_edit";
|
|
||||||
|
|
||||||
private final String TABLE_COL_DEL = "table_col_del";
|
|
||||||
|
|
||||||
private final String TABLE_COL_UP = "table_col_up";
|
|
||||||
|
|
||||||
private final String TABLE_COL_DOWN = "table_col_down";
|
|
||||||
|
|
||||||
private final ItemSelectionModel itemModel;
|
|
||||||
|
|
||||||
public ProceedingsPapersTable(final ItemSelectionModel itemModel) {
|
|
||||||
super();
|
|
||||||
this.itemModel = itemModel;
|
|
||||||
|
|
||||||
setEmptyView(
|
|
||||||
new Label(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.procreedings.no_papers",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
TableColumnModel colModel = getColumnModel();
|
|
||||||
colModel.add(
|
|
||||||
new TableColumn(
|
|
||||||
0,
|
|
||||||
new Label(new GlobalizedMessage(
|
|
||||||
"publications.ui.proceedings.paper",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
)
|
|
||||||
),
|
|
||||||
TABLE_COL_EDIT));
|
|
||||||
colModel.add(
|
|
||||||
new TableColumn(
|
|
||||||
1,
|
|
||||||
new Label(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.proceedings.paper.remove",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
)
|
|
||||||
),
|
|
||||||
TABLE_COL_DEL));
|
|
||||||
|
|
||||||
setModelBuilder(
|
|
||||||
new ProceedingsPapersTableModelBuilder(itemModel));
|
|
||||||
|
|
||||||
colModel.get(0).setCellRenderer(new EditCellRenderer());
|
|
||||||
colModel.get(1).setCellRenderer(new DeleteCellRenderer());
|
|
||||||
|
|
||||||
addTableActionListener(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void cellSelected(final TableActionEvent event) {
|
|
||||||
final PageState state = event.getPageState();
|
|
||||||
|
|
||||||
final ProceedingsController controller = CdiUtil
|
|
||||||
.createCdiUtil()
|
|
||||||
.findBean(ProceedingsController.class);
|
|
||||||
|
|
||||||
final InProceedings paper = controller
|
|
||||||
.findPaper((Long) event.getRowKey());
|
|
||||||
|
|
||||||
final ProceedingsItem proceedingsItem = (ProceedingsItem) itemModel
|
|
||||||
.getSelectedItem(state);
|
|
||||||
final Proceedings proceedings = proceedingsItem.getPublication();
|
|
||||||
|
|
||||||
TableColumn column = getColumnModel().get(event.getColumn());
|
|
||||||
|
|
||||||
if (column.getHeaderKey().toString().equals(TABLE_COL_EDIT)) {
|
|
||||||
// Nothing
|
|
||||||
} else if (column.getHeaderKey().toString().equals(TABLE_COL_DEL)) {
|
|
||||||
controller.removePaper(
|
|
||||||
proceedings.getPublicationId(),
|
|
||||||
paper.getPublicationId()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void headSelected(TableActionEvent event) {
|
|
||||||
//Noting to do
|
|
||||||
}
|
|
||||||
|
|
||||||
private class ProceedingsPapersTableModelBuilder
|
|
||||||
extends LockableImpl
|
|
||||||
implements TableModelBuilder {
|
|
||||||
|
|
||||||
private final ItemSelectionModel itemModel;
|
|
||||||
|
|
||||||
public ProceedingsPapersTableModelBuilder(
|
|
||||||
final ItemSelectionModel itemModel
|
|
||||||
) {
|
|
||||||
this.itemModel = itemModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public TableModel makeModel(final Table table, final PageState state) {
|
|
||||||
table.getRowSelectionModel().clearSelection(state);
|
|
||||||
final ProceedingsItem proceedings = (ProceedingsItem) itemModel
|
|
||||||
.getSelectedObject(state);
|
|
||||||
return new ProceedingsPapersTableModel(
|
|
||||||
table, state, proceedings.getPublication()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private class ProceedingsPapersTableModel implements TableModel {
|
|
||||||
|
|
||||||
private final Table table;
|
|
||||||
|
|
||||||
private final Iterator<InProceedings> papers;
|
|
||||||
|
|
||||||
private InProceedings paper;
|
|
||||||
|
|
||||||
private ProceedingsPapersTableModel(
|
|
||||||
final Table table,
|
|
||||||
final PageState state,
|
|
||||||
final Proceedings proceedings
|
|
||||||
) {
|
|
||||||
this.table = table;
|
|
||||||
papers = proceedings.getPapers().iterator();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getColumnCount() {
|
|
||||||
return table.getColumnModel().size();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean nextRow() {
|
|
||||||
if (papers != null && papers.hasNext()) {
|
|
||||||
paper = papers.next();
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object getElementAt(final int columnIndex) {
|
|
||||||
switch (columnIndex) {
|
|
||||||
case 0:
|
|
||||||
return paper.getTitle();
|
|
||||||
case 1:
|
|
||||||
return new Label(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.proceedings.paper.remove",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
)
|
|
||||||
);
|
|
||||||
default:
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object getKeyAt(final int columnIndex) {
|
|
||||||
return paper.getPublicationId();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private class EditCellRenderer
|
|
||||||
extends LockableImpl
|
|
||||||
implements TableCellRenderer {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Component getComponent(
|
|
||||||
final Table table,
|
|
||||||
final PageState state,
|
|
||||||
final Object value,
|
|
||||||
final boolean isSelected,
|
|
||||||
final Object key,
|
|
||||||
final int row,
|
|
||||||
final int col
|
|
||||||
) {
|
|
||||||
return new Text((String) value);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private class DeleteCellRenderer
|
|
||||||
extends LockableImpl
|
|
||||||
implements TableCellRenderer {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Component getComponent(
|
|
||||||
final Table table,
|
|
||||||
final PageState state,
|
|
||||||
final Object value,
|
|
||||||
final boolean isSelected,
|
|
||||||
final Object key,
|
|
||||||
final int row,
|
|
||||||
final int column
|
|
||||||
) {
|
|
||||||
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
|
|
||||||
final PermissionChecker permissionChecker = cdiUtil
|
|
||||||
.findBean(PermissionChecker.class);
|
|
||||||
|
|
||||||
final ProceedingsItem proceedingsItem = (ProceedingsItem) itemModel
|
|
||||||
.getSelectedItem(state);
|
|
||||||
|
|
||||||
final boolean canEdit = permissionChecker
|
|
||||||
.isPermitted(ItemPrivileges.EDIT, proceedingsItem
|
|
||||||
);
|
|
||||||
|
|
||||||
if (canEdit) {
|
|
||||||
final ControlLink link = new ControlLink((Component) value);
|
|
||||||
link.setConfirmation(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.proceedings.paper.confirm_remove",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
)
|
|
||||||
);
|
|
||||||
return link;
|
|
||||||
} else {
|
|
||||||
return new Text("");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,200 +0,0 @@
|
||||||
/*
|
|
||||||
* 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 com.arsdigita.cms.contenttypes.ui;
|
|
||||||
|
|
||||||
import com.arsdigita.bebop.Component;
|
|
||||||
import com.arsdigita.bebop.Label;
|
|
||||||
import com.arsdigita.bebop.PageState;
|
|
||||||
import com.arsdigita.bebop.parameters.StringParameter;
|
|
||||||
import com.arsdigita.cms.ItemSelectionModel;
|
|
||||||
import com.arsdigita.cms.ui.authoring.AuthoringKitWizard;
|
|
||||||
import com.arsdigita.cms.ui.authoring.BasicPageForm;
|
|
||||||
import com.arsdigita.cms.ui.authoring.SimpleEditStep;
|
|
||||||
import com.arsdigita.cms.ui.workflow.WorkflowLockedComponentAccess;
|
|
||||||
import com.arsdigita.globalization.GlobalizedMessage;
|
|
||||||
import com.arsdigita.toolbox.ui.DomainObjectPropertySheet;
|
|
||||||
|
|
||||||
import org.librecms.CmsConstants;
|
|
||||||
import org.scientificcms.publications.Proceedings;
|
|
||||||
import org.scientificcms.publications.SciPublicationsConstants;
|
|
||||||
import org.scientificcms.publications.contenttypes.ProceedingsItem;
|
|
||||||
|
|
||||||
import java.text.DateFormat;
|
|
||||||
import java.time.LocalDate;
|
|
||||||
import java.time.ZoneId;
|
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
|
||||||
*/
|
|
||||||
public class ProceedingsPropertiesStep
|
|
||||||
extends PublicationWithPublisherPropertiesStep {
|
|
||||||
|
|
||||||
private StringParameter selectedLangParam;
|
|
||||||
|
|
||||||
public ProceedingsPropertiesStep(
|
|
||||||
final ItemSelectionModel itemModel,
|
|
||||||
final AuthoringKitWizard parent,
|
|
||||||
final StringParameter selectedLangParam
|
|
||||||
) {
|
|
||||||
super(itemModel, parent, selectedLangParam);
|
|
||||||
this.selectedLangParam = selectedLangParam;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Component getProceedingsPropertySheet(
|
|
||||||
final ItemSelectionModel itemModel,
|
|
||||||
final StringParameter selectedLangParam
|
|
||||||
) {
|
|
||||||
final DomainObjectPropertySheet sheet
|
|
||||||
= (DomainObjectPropertySheet) getPublicationWithPublisherPropertySheet(
|
|
||||||
itemModel, selectedLangParam
|
|
||||||
);
|
|
||||||
|
|
||||||
sheet.add(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.proceedings.name_of_conference",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
),
|
|
||||||
ProceedingsController.NAME_OF_CONFERENCE);
|
|
||||||
|
|
||||||
sheet.add(new GlobalizedMessage(
|
|
||||||
"publications.ui.proceedings.place_of_conference",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
),
|
|
||||||
ProceedingsController.PLACE_OF_CONFERENCE);
|
|
||||||
|
|
||||||
sheet.add(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.proceedings.date_from_of_conference",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
),
|
|
||||||
ProceedingsController.START_DATE,
|
|
||||||
new DomainObjectPropertySheet.AttributeFormatter() {
|
|
||||||
|
|
||||||
public String format(
|
|
||||||
final Object item,
|
|
||||||
final String attribute,
|
|
||||||
final PageState state
|
|
||||||
) {
|
|
||||||
final ProceedingsItem proceedingsItem = (ProceedingsItem) item;
|
|
||||||
final Proceedings proceedings = proceedingsItem.getPublication();
|
|
||||||
if (proceedings.getStartDate() != null) {
|
|
||||||
final LocalDate startLocalDate = proceedings.getStartDate();
|
|
||||||
final Date startDate = Date.from(
|
|
||||||
startLocalDate
|
|
||||||
.atStartOfDay()
|
|
||||||
.atZone(ZoneId.systemDefault())
|
|
||||||
.toInstant()
|
|
||||||
);
|
|
||||||
return DateFormat.getDateInstance(DateFormat.LONG)
|
|
||||||
.format(startDate);
|
|
||||||
} else {
|
|
||||||
return (String) new GlobalizedMessage(
|
|
||||||
"cms.ui.unknown",
|
|
||||||
CmsConstants.CMS_BUNDLE
|
|
||||||
).localize();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
sheet.add(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.proceedings.date_to_of_conference",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
),
|
|
||||||
ProceedingsController.END_DATE,
|
|
||||||
new DomainObjectPropertySheet.AttributeFormatter() {
|
|
||||||
|
|
||||||
public String format(
|
|
||||||
final Object item,
|
|
||||||
final String attribute,
|
|
||||||
final PageState state
|
|
||||||
) {
|
|
||||||
final ProceedingsItem proceedingsItem = (ProceedingsItem) item;
|
|
||||||
final Proceedings proceedings = proceedingsItem.getPublication();
|
|
||||||
if (proceedings.getEndDate() != null) {
|
|
||||||
final LocalDate endLocalDate = proceedings.getEndDate();
|
|
||||||
final Date endDate = Date.from(
|
|
||||||
endLocalDate
|
|
||||||
.atStartOfDay()
|
|
||||||
.atZone(ZoneId.systemDefault())
|
|
||||||
.toInstant()
|
|
||||||
);
|
|
||||||
|
|
||||||
return DateFormat.getDateInstance(DateFormat.LONG)
|
|
||||||
.format(endDate);
|
|
||||||
} else {
|
|
||||||
return (String) new GlobalizedMessage(
|
|
||||||
"cms.ui.unknown",
|
|
||||||
CmsConstants.CMS_BUNDLE
|
|
||||||
).localize();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
return sheet;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void addBasicProperties(
|
|
||||||
final ItemSelectionModel itemModel,
|
|
||||||
final AuthoringKitWizard parent) {
|
|
||||||
final SimpleEditStep basicProperties = new SimpleEditStep(
|
|
||||||
itemModel, parent, selectedLangParam, EDIT_SHEET_NAME);
|
|
||||||
|
|
||||||
BasicPageForm editBasicSheet = new ProceedingsPropertyForm(
|
|
||||||
itemModel, this, selectedLangParam
|
|
||||||
);
|
|
||||||
|
|
||||||
basicProperties.add(
|
|
||||||
EDIT_SHEET_NAME,
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.proceedings.edit_basic_sheet",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
),
|
|
||||||
new WorkflowLockedComponentAccess(editBasicSheet, itemModel),
|
|
||||||
editBasicSheet.getSaveCancelSection().getCancelButton());
|
|
||||||
|
|
||||||
basicProperties.setDisplayComponent(
|
|
||||||
getProceedingsPropertySheet(itemModel, selectedLangParam)
|
|
||||||
);
|
|
||||||
|
|
||||||
getSegmentedPanel().addSegment(
|
|
||||||
new Label(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.proceedings.basic_properties",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
)
|
|
||||||
),
|
|
||||||
basicProperties);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void addSteps(
|
|
||||||
final ItemSelectionModel itemModel, final AuthoringKitWizard parent) {
|
|
||||||
super.addSteps(itemModel, parent);
|
|
||||||
|
|
||||||
addStep(
|
|
||||||
new ProceedingsOrganizerStep(itemModel, parent, selectedLangParam),
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.proceedings.organizer",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
addStep(
|
|
||||||
new ProceedingsPapersStep(itemModel, parent, selectedLangParam),
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.proceedings.papers",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,205 +0,0 @@
|
||||||
/*
|
|
||||||
* 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 com.arsdigita.cms.contenttypes.ui;
|
|
||||||
|
|
||||||
import com.arsdigita.bebop.FormData;
|
|
||||||
import com.arsdigita.bebop.FormProcessException;
|
|
||||||
import com.arsdigita.bebop.PageState;
|
|
||||||
import com.arsdigita.bebop.event.FormInitListener;
|
|
||||||
import com.arsdigita.bebop.event.FormProcessListener;
|
|
||||||
import com.arsdigita.bebop.event.FormSectionEvent;
|
|
||||||
import com.arsdigita.bebop.event.FormSubmissionListener;
|
|
||||||
import com.arsdigita.bebop.form.Date;
|
|
||||||
import com.arsdigita.bebop.form.TextField;
|
|
||||||
import com.arsdigita.bebop.parameters.DateParameter;
|
|
||||||
import com.arsdigita.bebop.parameters.NotEmptyValidationListener;
|
|
||||||
import com.arsdigita.bebop.parameters.NotNullValidationListener;
|
|
||||||
import com.arsdigita.bebop.parameters.ParameterModel;
|
|
||||||
import com.arsdigita.bebop.parameters.StringParameter;
|
|
||||||
import com.arsdigita.cms.ItemSelectionModel;
|
|
||||||
import com.arsdigita.globalization.GlobalizedMessage;
|
|
||||||
|
|
||||||
import org.libreccm.cdi.utils.CdiUtil;
|
|
||||||
import org.scientificcms.publications.Proceedings;
|
|
||||||
import org.scientificcms.publications.SciPublicationsConstants;
|
|
||||||
import org.scientificcms.publications.contenttypes.ProceedingsItem;
|
|
||||||
|
|
||||||
import java.time.LocalDate;
|
|
||||||
import java.time.ZoneId;
|
|
||||||
import java.util.Calendar;
|
|
||||||
import java.util.GregorianCalendar;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
|
||||||
*/
|
|
||||||
public class ProceedingsPropertyForm
|
|
||||||
extends PublicationWithPublisherPropertyForm
|
|
||||||
implements FormProcessListener, FormInitListener, FormSubmissionListener {
|
|
||||||
|
|
||||||
public static final String ID = "proceedingsEdit";
|
|
||||||
|
|
||||||
public ProceedingsPropertyForm(
|
|
||||||
final ItemSelectionModel itemModel,
|
|
||||||
final StringParameter selectedLangParam
|
|
||||||
) {
|
|
||||||
this(itemModel, null, selectedLangParam);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ProceedingsPropertyForm(
|
|
||||||
final ItemSelectionModel itemModel,
|
|
||||||
final ProceedingsPropertiesStep step,
|
|
||||||
final StringParameter selectedLangParam
|
|
||||||
) {
|
|
||||||
super(itemModel, step, selectedLangParam);
|
|
||||||
//m_step = step;
|
|
||||||
addSubmissionListener(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void addWidgets() {
|
|
||||||
|
|
||||||
super.addWidgets();
|
|
||||||
|
|
||||||
final ParameterModel nameOfConfParam = new StringParameter(
|
|
||||||
ProceedingsController.NAME_OF_CONFERENCE
|
|
||||||
);
|
|
||||||
final TextField nameOfConf = new TextField(nameOfConfParam);
|
|
||||||
nameOfConf.addValidationListener(new NotNullValidationListener());
|
|
||||||
nameOfConf.addValidationListener(new NotEmptyValidationListener());
|
|
||||||
nameOfConf.setLabel(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.proceedings.name_of_conference",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
)
|
|
||||||
);
|
|
||||||
add(nameOfConf);
|
|
||||||
|
|
||||||
final ParameterModel placeOfConfParam = new StringParameter(
|
|
||||||
ProceedingsController.PLACE_OF_CONFERENCE);
|
|
||||||
final TextField placeOfConf = new TextField(placeOfConfParam);
|
|
||||||
placeOfConf.setLabel(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.proceedings.place_of_conference",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
)
|
|
||||||
);
|
|
||||||
add(placeOfConf);
|
|
||||||
|
|
||||||
final Calendar today = new GregorianCalendar();
|
|
||||||
final ParameterModel dateFromParam = new DateParameter(
|
|
||||||
ProceedingsController.START_DATE);
|
|
||||||
final Date dateFrom = new Date(dateFromParam);
|
|
||||||
dateFrom.setYearRange(1900, today.get(Calendar.YEAR) + 3);
|
|
||||||
|
|
||||||
dateFrom.setLabel(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.proceedings.date_from_of_conference",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
)
|
|
||||||
);
|
|
||||||
add(dateFrom);
|
|
||||||
|
|
||||||
final ParameterModel dateToParam = new DateParameter(
|
|
||||||
ProceedingsController.END_DATE
|
|
||||||
);
|
|
||||||
final Date dateTo = new Date(dateToParam);
|
|
||||||
dateTo.setYearRange(1900, today.get(Calendar.YEAR) + 3);
|
|
||||||
|
|
||||||
dateTo.setLabel(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.proceedings.date_to_of_conference",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
)
|
|
||||||
);
|
|
||||||
add(dateTo);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void init(final FormSectionEvent event) throws FormProcessException {
|
|
||||||
|
|
||||||
super.init(event);
|
|
||||||
|
|
||||||
final FormData data = event.getFormData();
|
|
||||||
final ProceedingsItem proceedingsItem = (ProceedingsItem) super
|
|
||||||
.initBasicWidgets(event);
|
|
||||||
final Proceedings proceedings = proceedingsItem.getPublication();
|
|
||||||
|
|
||||||
data.put(
|
|
||||||
ProceedingsController.NAME_OF_CONFERENCE,
|
|
||||||
proceedings.getNameOfConference()
|
|
||||||
);
|
|
||||||
data.put(
|
|
||||||
ProceedingsController.PLACE_OF_CONFERENCE,
|
|
||||||
proceedings.getPlaceOfConference()
|
|
||||||
);
|
|
||||||
final LocalDate localStartDate = proceedings.getStartDate();
|
|
||||||
final java.util.Date startDate = java.util.Date.from(
|
|
||||||
localStartDate.atStartOfDay().atZone(
|
|
||||||
ZoneId.systemDefault()
|
|
||||||
).toInstant());
|
|
||||||
data.put(ProceedingsController.START_DATE, startDate);
|
|
||||||
final LocalDate localEndDate = proceedings.getEndDate();
|
|
||||||
final java.util.Date endDate = java.util.Date.from(
|
|
||||||
localEndDate.atStartOfDay().atZone(
|
|
||||||
ZoneId.systemDefault()
|
|
||||||
).toInstant());
|
|
||||||
data.put(ProceedingsController.END_DATE, endDate);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void process(final FormSectionEvent event)
|
|
||||||
throws FormProcessException {
|
|
||||||
super.process(event);
|
|
||||||
|
|
||||||
final FormData formData = event.getFormData();
|
|
||||||
final PageState state = event.getPageState();
|
|
||||||
final ProceedingsItem proceedingsItem = (ProceedingsItem) super
|
|
||||||
.processBasicWidgets(event);
|
|
||||||
|
|
||||||
if ((proceedingsItem != null)
|
|
||||||
&& getSaveCancelSection().getSaveButton().isSelected(state)) {
|
|
||||||
|
|
||||||
final Map<String, Object> data = new HashMap<>();
|
|
||||||
data.put(
|
|
||||||
ProceedingsController.NAME_OF_CONFERENCE,
|
|
||||||
formData.get(ProceedingsController.NAME_OF_CONFERENCE)
|
|
||||||
);
|
|
||||||
data.put(
|
|
||||||
ProceedingsController.PLACE_OF_CONFERENCE,
|
|
||||||
formData.get(ProceedingsController.PLACE_OF_CONFERENCE)
|
|
||||||
);
|
|
||||||
|
|
||||||
final java.util.Date startDate = (java.util.Date) formData
|
|
||||||
.get(ProceedingsController.START_DATE);
|
|
||||||
data.put(
|
|
||||||
ProceedingsController.START_DATE,
|
|
||||||
startDate.toInstant().atZone(
|
|
||||||
ZoneId.systemDefault()
|
|
||||||
).toLocalDate()
|
|
||||||
);
|
|
||||||
|
|
||||||
final java.util.Date endDate = (java.util.Date) formData
|
|
||||||
.get(ProceedingsController.END_DATE);
|
|
||||||
data.put(
|
|
||||||
ProceedingsController.END_DATE,
|
|
||||||
endDate.toInstant().atZone(
|
|
||||||
ZoneId.systemDefault()
|
|
||||||
).toLocalDate()
|
|
||||||
);
|
|
||||||
|
|
||||||
final ProceedingsController controller = CdiUtil
|
|
||||||
.createCdiUtil()
|
|
||||||
.findBean(ProceedingsController.class);
|
|
||||||
controller.saveProceedings(
|
|
||||||
proceedingsItem.getPublication().getPublicationId(), data
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,281 +0,0 @@
|
||||||
/*
|
|
||||||
* 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 com.arsdigita.cms.contenttypes.ui;
|
|
||||||
|
|
||||||
import com.arsdigita.bebop.FormData;
|
|
||||||
import com.arsdigita.bebop.FormProcessException;
|
|
||||||
import com.arsdigita.bebop.Label;
|
|
||||||
import com.arsdigita.bebop.PageState;
|
|
||||||
import com.arsdigita.bebop.Text;
|
|
||||||
import com.arsdigita.bebop.event.FormInitListener;
|
|
||||||
import com.arsdigita.bebop.event.FormProcessListener;
|
|
||||||
import com.arsdigita.bebop.event.FormSectionEvent;
|
|
||||||
import com.arsdigita.bebop.event.FormSubmissionListener;
|
|
||||||
import com.arsdigita.bebop.form.CheckboxGroup;
|
|
||||||
import com.arsdigita.bebop.form.Option;
|
|
||||||
import com.arsdigita.bebop.parameters.StringParameter;
|
|
||||||
import com.arsdigita.cms.ItemSelectionModel;
|
|
||||||
import com.arsdigita.cms.ui.assets.AssetSearchWidget;
|
|
||||||
import com.arsdigita.cms.ui.assets.ItemSearchWidget;
|
|
||||||
import com.arsdigita.cms.ui.authoring.BasicItemForm;
|
|
||||||
import com.arsdigita.cms.ui.authoring.SimpleEditStep;
|
|
||||||
import com.arsdigita.globalization.GlobalizedMessage;
|
|
||||||
|
|
||||||
import org.apache.logging.log4j.LogManager;
|
|
||||||
import org.apache.logging.log4j.Logger;
|
|
||||||
import org.libreccm.cdi.utils.CdiUtil;
|
|
||||||
import org.librecms.assets.Person;
|
|
||||||
import org.scientificcms.publications.Publication;
|
|
||||||
import org.scientificcms.publications.SciPublicationsConfig;
|
|
||||||
import org.scientificcms.publications.SciPublicationsConstants;
|
|
||||||
import org.scientificcms.publications.contenttypes.PublicationItem;
|
|
||||||
|
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
|
||||||
*/
|
|
||||||
public class PublicationAuthorAddForm
|
|
||||||
extends BasicItemForm
|
|
||||||
implements FormProcessListener, FormInitListener, FormSubmissionListener {
|
|
||||||
|
|
||||||
private static final Logger LOGGER = LogManager.getLogger(
|
|
||||||
PublicationAuthorAddForm.class
|
|
||||||
);
|
|
||||||
|
|
||||||
private final static String AUTHOR_SEARCH = "authors";
|
|
||||||
|
|
||||||
private final static SciPublicationsConfig CONFIG = SciPublicationsConfig
|
|
||||||
.getConfig();
|
|
||||||
|
|
||||||
private PublicationPropertiesStep step;
|
|
||||||
|
|
||||||
private AssetSearchWidget authorSearchWidget;
|
|
||||||
|
|
||||||
private final ItemSelectionModel itemModel;
|
|
||||||
|
|
||||||
private final SimpleEditStep editStep;
|
|
||||||
|
|
||||||
private Text selectedAuthorLabel;
|
|
||||||
|
|
||||||
private CheckboxGroup isEditor;
|
|
||||||
|
|
||||||
public PublicationAuthorAddForm(
|
|
||||||
final ItemSelectionModel itemModel,
|
|
||||||
final SimpleEditStep editStep,
|
|
||||||
final StringParameter selectedLanguageParam
|
|
||||||
) {
|
|
||||||
super("AuthorsEntryForm", itemModel, selectedLanguageParam);
|
|
||||||
this.itemModel = itemModel;
|
|
||||||
this.editStep = editStep;
|
|
||||||
addSubmissionListener(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void addWidgets() {
|
|
||||||
|
|
||||||
authorSearchWidget = new AssetSearchWidget(
|
|
||||||
AUTHOR_SEARCH, Person.class
|
|
||||||
);
|
|
||||||
authorSearchWidget.setLabel(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.authors.selectAuthor",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
)
|
|
||||||
);
|
|
||||||
add(authorSearchWidget);
|
|
||||||
|
|
||||||
selectedAuthorLabel = new Text();
|
|
||||||
add(selectedAuthorLabel);
|
|
||||||
|
|
||||||
isEditor = new CheckboxGroup("isEditorGroup");
|
|
||||||
isEditor.addOption(
|
|
||||||
new Option(
|
|
||||||
SciPublicationsController.AUTHORSHIP_IS_EDITOR,
|
|
||||||
new Label(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.authors.author.is_editor",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
add(isEditor);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void init(final FormSectionEvent event) throws FormProcessException {
|
|
||||||
|
|
||||||
final FormData formData = event.getFormData();
|
|
||||||
final PageState state = event.getPageState();
|
|
||||||
|
|
||||||
final Person author;
|
|
||||||
final Boolean editor;
|
|
||||||
|
|
||||||
author = ((PublicationAuthorsPropertyStep) editStep).getSelectedAuthor();
|
|
||||||
editor = ((PublicationAuthorsPropertyStep) editStep)
|
|
||||||
.isSelectedAuthorEditor();
|
|
||||||
|
|
||||||
if (author == null) {
|
|
||||||
LOGGER.warn("No author selected.");
|
|
||||||
|
|
||||||
authorSearchWidget.setVisible(state, true);
|
|
||||||
selectedAuthorLabel.setVisible(state, false);
|
|
||||||
} else {
|
|
||||||
LOGGER.warn(
|
|
||||||
String.format(
|
|
||||||
"Author is here: %s", Objects.toString(author)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
formData.put(AUTHOR_SEARCH, author);
|
|
||||||
if ((editor != null) && editor) {
|
|
||||||
isEditor.setValue(
|
|
||||||
state,
|
|
||||||
new String[]{
|
|
||||||
SciPublicationsController.AUTHORSHIP_IS_EDITOR
|
|
||||||
}
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
isEditor.setValue(state, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
authorSearchWidget.setVisible(state, false);
|
|
||||||
selectedAuthorLabel.setText(
|
|
||||||
String.format("%s, %s",
|
|
||||||
author.getPersonName().getSurname(),
|
|
||||||
author.getPersonName().getGivenName()
|
|
||||||
)
|
|
||||||
);
|
|
||||||
selectedAuthorLabel.setVisible(state, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
setVisible(state, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void process(final FormSectionEvent event)
|
|
||||||
throws FormProcessException {
|
|
||||||
|
|
||||||
final FormData formData = event.getFormData();
|
|
||||||
final PageState state = event.getPageState();
|
|
||||||
|
|
||||||
final PublicationItem<?> item = (PublicationItem) itemModel
|
|
||||||
.getSelectedItem(state);
|
|
||||||
final Publication publication = item.getPublication();
|
|
||||||
|
|
||||||
if (getSaveCancelSection().getSaveButton().isSelected(state)) {
|
|
||||||
|
|
||||||
final Person author = ((PublicationAuthorsPropertyStep) editStep)
|
|
||||||
.getSelectedAuthor();
|
|
||||||
|
|
||||||
final Boolean editor;
|
|
||||||
if (isEditor.getValue(state) == null) {
|
|
||||||
editor = Boolean.FALSE;
|
|
||||||
} else {
|
|
||||||
editor = Boolean.TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
final SciPublicationsController controller = CdiUtil
|
|
||||||
.createCdiUtil()
|
|
||||||
.findBean(SciPublicationsController.class);
|
|
||||||
if (author == null) {
|
|
||||||
final Person authorToAdd = (Person) formData.get(
|
|
||||||
AUTHOR_SEARCH
|
|
||||||
);
|
|
||||||
|
|
||||||
controller.addAuthor(
|
|
||||||
publication.getPublicationId(),
|
|
||||||
authorToAdd.getObjectId(),
|
|
||||||
editor
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
|
|
||||||
controller.updateAuthorship(publication.getPublicationId(),
|
|
||||||
author.getObjectId(),
|
|
||||||
editor);
|
|
||||||
|
|
||||||
((PublicationAuthorsPropertyStep) editStep)
|
|
||||||
.setSelectedAuthor(null);
|
|
||||||
((PublicationAuthorsPropertyStep) editStep)
|
|
||||||
.setSelectedAuthorEditor(null);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
init(event);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void submitted(final FormSectionEvent fse) throws
|
|
||||||
FormProcessException {
|
|
||||||
if (getSaveCancelSection().getCancelButton()
|
|
||||||
.isSelected(fse.getPageState())) {
|
|
||||||
((PublicationAuthorsPropertyStep) editStep)
|
|
||||||
.setSelectedAuthor(null);
|
|
||||||
((PublicationAuthorsPropertyStep) editStep)
|
|
||||||
.setSelectedAuthorEditor(null);
|
|
||||||
|
|
||||||
init(fse);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void validate(final FormSectionEvent event)
|
|
||||||
throws FormProcessException {
|
|
||||||
|
|
||||||
final PageState state = event.getPageState();
|
|
||||||
final FormData formData = event.getFormData();
|
|
||||||
boolean editing = false; //Are we editing the association
|
|
||||||
|
|
||||||
if ((((PublicationAuthorsPropertyStep) editStep)
|
|
||||||
.getSelectedAuthor() == null)
|
|
||||||
&& (formData.get(AUTHOR_SEARCH) == null)) {
|
|
||||||
formData.addError(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.authors.selectAuthor.no_author_selected",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
)
|
|
||||||
);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
final PublicationItem<?> item
|
|
||||||
= (PublicationItem<?>) getItemSelectionModel()
|
|
||||||
.getSelectedObject(state);
|
|
||||||
final Person author;
|
|
||||||
if (formData.get(AUTHOR_SEARCH) == null) {
|
|
||||||
author = ((PublicationAuthorsPropertyStep) editStep)
|
|
||||||
.getSelectedAuthor();
|
|
||||||
editing = true;
|
|
||||||
} else {
|
|
||||||
author = (Person) formData.get(AUTHOR_SEARCH);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!editing) {
|
|
||||||
|
|
||||||
final SciPublicationsController controller = CdiUtil
|
|
||||||
.createCdiUtil()
|
|
||||||
.findBean(SciPublicationsController.class);
|
|
||||||
|
|
||||||
final boolean hasAuthor = controller.hasAuthor(
|
|
||||||
item.getPublication().getPublicationId(),
|
|
||||||
author.getObjectId()
|
|
||||||
);
|
|
||||||
|
|
||||||
if (hasAuthor) {
|
|
||||||
formData.addError(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.authors.selectAuthor.already_added",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,81 +0,0 @@
|
||||||
/*
|
|
||||||
* 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 com.arsdigita.cms.contenttypes.ui;
|
|
||||||
|
|
||||||
import com.arsdigita.bebop.parameters.StringParameter;
|
|
||||||
import com.arsdigita.cms.ItemSelectionModel;
|
|
||||||
import com.arsdigita.cms.ui.authoring.AuthoringKitWizard;
|
|
||||||
import com.arsdigita.cms.ui.authoring.BasicItemForm;
|
|
||||||
import com.arsdigita.cms.ui.authoring.SimpleEditStep;
|
|
||||||
import com.arsdigita.cms.ui.workflow.WorkflowLockedComponentAccess;
|
|
||||||
import com.arsdigita.globalization.GlobalizedMessage;
|
|
||||||
|
|
||||||
import org.librecms.assets.Person;
|
|
||||||
import org.scientificcms.publications.SciPublicationsConstants;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
|
||||||
*/
|
|
||||||
public class PublicationAuthorsPropertyStep extends SimpleEditStep {
|
|
||||||
|
|
||||||
public static final String ADD_AUTHOR_SHEET_NAME = "addAuthor";
|
|
||||||
|
|
||||||
private Person selectedAuthor;
|
|
||||||
|
|
||||||
private Boolean selectedAuthorEditor;
|
|
||||||
|
|
||||||
public PublicationAuthorsPropertyStep(
|
|
||||||
final ItemSelectionModel itemModel,
|
|
||||||
final AuthoringKitWizard parent,
|
|
||||||
final StringParameter selectedLanguageParam
|
|
||||||
) {
|
|
||||||
this(itemModel, parent, selectedLanguageParam, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public PublicationAuthorsPropertyStep(
|
|
||||||
final ItemSelectionModel itemModel,
|
|
||||||
final AuthoringKitWizard authoringKitWizard,
|
|
||||||
final StringParameter selectedLanguageParameter,
|
|
||||||
final String prefix
|
|
||||||
) {
|
|
||||||
super(itemModel, authoringKitWizard, selectedLanguageParameter, prefix);
|
|
||||||
|
|
||||||
final BasicItemForm addAuthorSheet = new PublicationAuthorAddForm(
|
|
||||||
itemModel, this, selectedLanguageParameter
|
|
||||||
);
|
|
||||||
add(ADD_AUTHOR_SHEET_NAME,
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.authors.add_author",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
),
|
|
||||||
new WorkflowLockedComponentAccess(addAuthorSheet, itemModel),
|
|
||||||
addAuthorSheet.getSaveCancelSection().getCancelButton());
|
|
||||||
|
|
||||||
final PublicationAuthorsTable authorsTable = new PublicationAuthorsTable(
|
|
||||||
itemModel, this);
|
|
||||||
setDisplayComponent(authorsTable);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected Person getSelectedAuthor() {
|
|
||||||
return selectedAuthor;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected Boolean isSelectedAuthorEditor() {
|
|
||||||
return selectedAuthorEditor;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void setSelectedAuthor(final Person selectedAuthor) {
|
|
||||||
this.selectedAuthor = selectedAuthor;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void setSelectedAuthorEditor(final Boolean selectedAuthorEditor) {
|
|
||||||
this.selectedAuthorEditor = selectedAuthorEditor;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,489 +0,0 @@
|
||||||
/*
|
|
||||||
* 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 com.arsdigita.cms.contenttypes.ui;
|
|
||||||
|
|
||||||
import com.arsdigita.bebop.Component;
|
|
||||||
import com.arsdigita.bebop.ControlLink;
|
|
||||||
import com.arsdigita.bebop.FormProcessException;
|
|
||||||
import com.arsdigita.bebop.Label;
|
|
||||||
import com.arsdigita.bebop.PageState;
|
|
||||||
import com.arsdigita.bebop.Table;
|
|
||||||
import com.arsdigita.bebop.Text;
|
|
||||||
import com.arsdigita.bebop.event.TableActionEvent;
|
|
||||||
import com.arsdigita.bebop.event.TableActionListener;
|
|
||||||
import com.arsdigita.bebop.table.TableCellRenderer;
|
|
||||||
import com.arsdigita.bebop.table.TableColumn;
|
|
||||||
import com.arsdigita.bebop.table.TableColumnModel;
|
|
||||||
import com.arsdigita.bebop.table.TableModel;
|
|
||||||
import com.arsdigita.bebop.table.TableModelBuilder;
|
|
||||||
import com.arsdigita.cms.ItemSelectionModel;
|
|
||||||
import com.arsdigita.globalization.GlobalizedMessage;
|
|
||||||
import com.arsdigita.util.LockableImpl;
|
|
||||||
|
|
||||||
import org.apache.logging.log4j.LogManager;
|
|
||||||
import org.apache.logging.log4j.Logger;
|
|
||||||
import org.libreccm.cdi.utils.CdiUtil;
|
|
||||||
import org.libreccm.security.PermissionChecker;
|
|
||||||
import org.librecms.contentsection.privileges.ItemPrivileges;
|
|
||||||
import org.scientificcms.publications.Authorship;
|
|
||||||
import org.scientificcms.publications.SciPublicationsConstants;
|
|
||||||
import org.scientificcms.publications.contenttypes.PublicationItem;
|
|
||||||
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
|
||||||
*/
|
|
||||||
public class PublicationAuthorsTable
|
|
||||||
extends Table
|
|
||||||
implements TableActionListener {
|
|
||||||
|
|
||||||
private static final Logger LOGGER = LogManager.getLogger(
|
|
||||||
PublicationAuthorsTable.class
|
|
||||||
);
|
|
||||||
|
|
||||||
private final String TABLE_COL_EDIT = "table_col_edit";
|
|
||||||
|
|
||||||
private final String TABLE_COL_EDIT_ASSOC = "table_col_edit_assoc";
|
|
||||||
|
|
||||||
private final String TABLE_COL_DEL = "table_col_del";
|
|
||||||
|
|
||||||
private final String TABLE_COL_UP = "table_col_up";
|
|
||||||
|
|
||||||
private final String TABLE_COL_DOWN = "table_col_down";
|
|
||||||
|
|
||||||
public static final String SELECTED_PUBLICATION
|
|
||||||
= "selected_publication_author_association_publication";
|
|
||||||
|
|
||||||
public static final String SELECTED_AUTHOR
|
|
||||||
= "selected_publication_author_association_author";
|
|
||||||
|
|
||||||
private final ItemSelectionModel itemModel;
|
|
||||||
|
|
||||||
private final PublicationAuthorsPropertyStep editStep;
|
|
||||||
|
|
||||||
public PublicationAuthorsTable(
|
|
||||||
final ItemSelectionModel itemModel,
|
|
||||||
final PublicationAuthorsPropertyStep editStep
|
|
||||||
) {
|
|
||||||
super();
|
|
||||||
this.itemModel = itemModel;
|
|
||||||
this.editStep = editStep;
|
|
||||||
|
|
||||||
setEmptyView(
|
|
||||||
new Label(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.authors.none",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
final TableColumnModel colModel = getColumnModel();
|
|
||||||
colModel.add(
|
|
||||||
new TableColumn(
|
|
||||||
0,
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.authors.author.name",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
),
|
|
||||||
TABLE_COL_EDIT
|
|
||||||
)
|
|
||||||
);
|
|
||||||
colModel.add(
|
|
||||||
new TableColumn(
|
|
||||||
1,
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.authors.author.isEditor",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
colModel.add(
|
|
||||||
new TableColumn(
|
|
||||||
2,
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.authors.edit_assoc",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
),
|
|
||||||
TABLE_COL_EDIT_ASSOC
|
|
||||||
)
|
|
||||||
);
|
|
||||||
colModel.add(
|
|
||||||
new TableColumn(
|
|
||||||
3,
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.authors.author.delete",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
),
|
|
||||||
TABLE_COL_DEL
|
|
||||||
)
|
|
||||||
);
|
|
||||||
colModel.add(
|
|
||||||
new TableColumn(
|
|
||||||
4,
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.authors.author.up",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
),
|
|
||||||
TABLE_COL_UP));
|
|
||||||
colModel.add(
|
|
||||||
new TableColumn(
|
|
||||||
5,
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.authors.author.down",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
),
|
|
||||||
TABLE_COL_DOWN
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
setModelBuilder(
|
|
||||||
new PublicationAuthorsTableModelBuilder(itemModel));
|
|
||||||
|
|
||||||
colModel.get(0).setCellRenderer(new EditCellRenderer());
|
|
||||||
colModel.get(2).setCellRenderer(new EditAssocCellRenderer());
|
|
||||||
colModel.get(3).setCellRenderer(new DeleteCellRenderer());
|
|
||||||
colModel.get(4).setCellRenderer(new UpCellRenderer());
|
|
||||||
colModel.get(5).setCellRenderer(new DownCellRenderer());
|
|
||||||
|
|
||||||
LOGGER.info("Adding table action listener...");
|
|
||||||
addTableActionListener(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void cellSelected(final TableActionEvent event)
|
|
||||||
throws FormProcessException {
|
|
||||||
|
|
||||||
final PageState state = event.getPageState();
|
|
||||||
final PublicationItem<?> selected = (PublicationItem<?>) itemModel
|
|
||||||
.getSelectedItem(state);
|
|
||||||
final SciPublicationsController controller = CdiUtil
|
|
||||||
.createCdiUtil()
|
|
||||||
.findBean(SciPublicationsController.class);
|
|
||||||
final Authorship authorship = controller.findAuthorship(
|
|
||||||
selected.getPublication().getPublicationId(),
|
|
||||||
event.getRowKey()
|
|
||||||
).get();
|
|
||||||
|
|
||||||
final TableColumn column = getColumnModel().get(event.getColumn());
|
|
||||||
|
|
||||||
if (TABLE_COL_EDIT_ASSOC.equals(column.getHeaderKey())) {
|
|
||||||
editStep.setSelectedAuthor(authorship.getAuthor());
|
|
||||||
editStep.setSelectedAuthorEditor(authorship.isEditor());
|
|
||||||
|
|
||||||
editStep.showComponent(state, "AuthorsEntryForm");
|
|
||||||
} else if (TABLE_COL_DEL.equals(column.getHeaderKey())) {
|
|
||||||
controller.removeAuthor(
|
|
||||||
selected.getPublication().getPublicationId(),
|
|
||||||
authorship.getAuthorshipId()
|
|
||||||
);
|
|
||||||
} else if (TABLE_COL_UP.equals(column.getHeaderKey())) {
|
|
||||||
controller.swapWithPrevAuthorship(
|
|
||||||
selected.getPublication().getPublicationId(),
|
|
||||||
authorship.getAuthorshipId()
|
|
||||||
);
|
|
||||||
} else if (TABLE_COL_DOWN.equals(column.getHeaderKey())) {
|
|
||||||
controller.swapWithNextAuthorship(
|
|
||||||
selected.getPublication().getPublicationId(),
|
|
||||||
authorship.getAuthorshipId()
|
|
||||||
);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void headSelected(final TableActionEvent event) {
|
|
||||||
|
|
||||||
// Nothing
|
|
||||||
}
|
|
||||||
|
|
||||||
private class PublicationAuthorsTableModelBuilder
|
|
||||||
extends LockableImpl
|
|
||||||
implements TableModelBuilder {
|
|
||||||
|
|
||||||
private ItemSelectionModel itemModel;
|
|
||||||
|
|
||||||
public PublicationAuthorsTableModelBuilder(
|
|
||||||
final ItemSelectionModel itemModel
|
|
||||||
) {
|
|
||||||
this.itemModel = itemModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public TableModel makeModel(final Table table, final PageState state) {
|
|
||||||
|
|
||||||
table.getRowSelectionModel().clearSelection(state);
|
|
||||||
final PublicationItem<?> publication = (PublicationItem) itemModel
|
|
||||||
.getSelectedObject(state);
|
|
||||||
return new PublicationAuthorsTableModel(table, state, publication);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private class PublicationAuthorsTableModel implements TableModel {
|
|
||||||
|
|
||||||
private static final int MAX_DESC_LENGTH = 25;
|
|
||||||
|
|
||||||
private final Table table;
|
|
||||||
|
|
||||||
private final Iterator<Map<String, Object>> iterator;
|
|
||||||
|
|
||||||
private Map<String, Object> currentRow;
|
|
||||||
|
|
||||||
public PublicationAuthorsTableModel(
|
|
||||||
final Table table,
|
|
||||||
final PageState state,
|
|
||||||
final PublicationItem<?> publicationItem
|
|
||||||
) {
|
|
||||||
this.table = table;
|
|
||||||
|
|
||||||
final SciPublicationsController controller = CdiUtil
|
|
||||||
.createCdiUtil()
|
|
||||||
.findBean(SciPublicationsController.class);
|
|
||||||
iterator = controller.getAuthors(
|
|
||||||
publicationItem.getPublication().getPublicationId()
|
|
||||||
).iterator();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getColumnCount() {
|
|
||||||
return table.getColumnModel().size();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean nextRow() {
|
|
||||||
if (iterator.hasNext()) {
|
|
||||||
currentRow = iterator.next();
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object getElementAt(final int columnIndex) {
|
|
||||||
|
|
||||||
switch (columnIndex) {
|
|
||||||
case 0:
|
|
||||||
return currentRow.get(
|
|
||||||
SciPublicationsController.AUTHOR_NAME
|
|
||||||
);
|
|
||||||
case 1: {
|
|
||||||
final boolean isEditor = (boolean) currentRow
|
|
||||||
.get(SciPublicationsController.AUTHORSHIP_IS_EDITOR
|
|
||||||
);
|
|
||||||
if (isEditor) {
|
|
||||||
return new Label(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.authors.author.is_editor_true",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
)
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
return new Label(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.authors.author.is_not_editor",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
case 2:
|
|
||||||
return new Label(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.authors.edit_assoc",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
)
|
|
||||||
);
|
|
||||||
case 3:
|
|
||||||
return new Label(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.authors.author.remove",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
)
|
|
||||||
);
|
|
||||||
default:
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object getKeyAt(final int columnIndex) {
|
|
||||||
return currentRow.get(SciPublicationsController.AUTHORSHIP_ID);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private class EditCellRenderer
|
|
||||||
extends LockableImpl
|
|
||||||
implements TableCellRenderer {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Component getComponent(
|
|
||||||
final Table table,
|
|
||||||
final PageState state,
|
|
||||||
final Object value,
|
|
||||||
final boolean isSelected,
|
|
||||||
final Object key,
|
|
||||||
final int row,
|
|
||||||
final int col
|
|
||||||
) {
|
|
||||||
final PublicationItem<?> selected = (PublicationItem<?>) itemModel
|
|
||||||
.getSelectedItem(state);
|
|
||||||
final SciPublicationsController controller = CdiUtil
|
|
||||||
.createCdiUtil()
|
|
||||||
.findBean(SciPublicationsController.class);
|
|
||||||
final Authorship authorship = controller
|
|
||||||
.findAuthorship(selected.getPublication().getPublicationId(),
|
|
||||||
key)
|
|
||||||
.get();
|
|
||||||
|
|
||||||
return new Text(
|
|
||||||
String.format(
|
|
||||||
"%s, %s",
|
|
||||||
authorship.getAuthor().getPersonName().getSurname(),
|
|
||||||
authorship.getAuthor().getPersonName().getGivenName()
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private class EditAssocCellRenderer
|
|
||||||
extends LockableImpl
|
|
||||||
implements TableCellRenderer {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Component getComponent(
|
|
||||||
final Table table,
|
|
||||||
final PageState state,
|
|
||||||
final Object value,
|
|
||||||
final boolean isSelected,
|
|
||||||
final Object key,
|
|
||||||
final int row,
|
|
||||||
final int col
|
|
||||||
) {
|
|
||||||
final PermissionChecker permissionChecker = CdiUtil
|
|
||||||
.createCdiUtil()
|
|
||||||
.findBean(PermissionChecker.class);
|
|
||||||
|
|
||||||
final PublicationItem<?> selected = (PublicationItem<?>) itemModel
|
|
||||||
.getSelectedItem(state);
|
|
||||||
final boolean canEdit = permissionChecker
|
|
||||||
.isPermitted(ItemPrivileges.EDIT, selected);
|
|
||||||
|
|
||||||
if (canEdit) {
|
|
||||||
return new ControlLink((Component) value);
|
|
||||||
} else {
|
|
||||||
return new Text("");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private class DeleteCellRenderer
|
|
||||||
extends LockableImpl
|
|
||||||
implements TableCellRenderer {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Component getComponent(
|
|
||||||
final Table table,
|
|
||||||
final PageState state,
|
|
||||||
final Object value,
|
|
||||||
final boolean isSelected,
|
|
||||||
final Object key,
|
|
||||||
final int row,
|
|
||||||
final int col
|
|
||||||
) {
|
|
||||||
final PermissionChecker permissionChecker = CdiUtil
|
|
||||||
.createCdiUtil()
|
|
||||||
.findBean(PermissionChecker.class);
|
|
||||||
|
|
||||||
final PublicationItem<?> selected = (PublicationItem<?>) itemModel
|
|
||||||
.getSelectedItem(state);
|
|
||||||
final boolean canEdit = permissionChecker
|
|
||||||
.isPermitted(ItemPrivileges.EDIT, selected);
|
|
||||||
|
|
||||||
if (canEdit) {
|
|
||||||
final ControlLink link = new ControlLink(
|
|
||||||
(Component) value
|
|
||||||
);
|
|
||||||
link.setConfirmation(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.authors.author.confirm_remove",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
)
|
|
||||||
);
|
|
||||||
return link;
|
|
||||||
} else {
|
|
||||||
return new Text("");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private class UpCellRenderer
|
|
||||||
extends LockableImpl
|
|
||||||
implements TableCellRenderer {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Component getComponent(
|
|
||||||
final Table table,
|
|
||||||
final PageState state,
|
|
||||||
final Object value,
|
|
||||||
final boolean isSelected,
|
|
||||||
final Object key,
|
|
||||||
final int row,
|
|
||||||
final int col
|
|
||||||
) {
|
|
||||||
if (0 == row) {
|
|
||||||
return new Label();
|
|
||||||
} else {
|
|
||||||
final ControlLink link = new ControlLink("up");
|
|
||||||
return link;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private class DownCellRenderer
|
|
||||||
extends LockableImpl
|
|
||||||
implements TableCellRenderer {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Component getComponent(
|
|
||||||
final Table table,
|
|
||||||
final PageState state,
|
|
||||||
final Object value,
|
|
||||||
final boolean isSelected,
|
|
||||||
final Object key,
|
|
||||||
final int row,
|
|
||||||
final int col
|
|
||||||
) {
|
|
||||||
final PublicationItem<?> selected = (PublicationItem<?>) itemModel
|
|
||||||
.getSelectedItem(state);
|
|
||||||
final SciPublicationsController controller = CdiUtil
|
|
||||||
.createCdiUtil()
|
|
||||||
.findBean(SciPublicationsController.class);
|
|
||||||
final List<Map<String, Object>> authorships = controller
|
|
||||||
.getAuthors(selected.getPublication().getPublicationId()
|
|
||||||
);
|
|
||||||
|
|
||||||
if ((authorships.size() - 1) == row) {
|
|
||||||
return new Label();
|
|
||||||
} else {
|
|
||||||
final ControlLink link = new ControlLink("down");
|
|
||||||
return link;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,259 +0,0 @@
|
||||||
/*
|
|
||||||
* 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 com.arsdigita.cms.contenttypes.ui;
|
|
||||||
|
|
||||||
import com.arsdigita.bebop.Component;
|
|
||||||
import com.arsdigita.bebop.Label;
|
|
||||||
import com.arsdigita.bebop.PageState;
|
|
||||||
import com.arsdigita.bebop.SegmentedPanel;
|
|
||||||
import com.arsdigita.bebop.parameters.StringParameter;
|
|
||||||
import com.arsdigita.cms.ItemSelectionModel;
|
|
||||||
import com.arsdigita.cms.ui.authoring.AuthoringKitWizard;
|
|
||||||
import com.arsdigita.cms.ui.authoring.BasicPageForm;
|
|
||||||
import com.arsdigita.cms.ui.authoring.SimpleEditStep;
|
|
||||||
import com.arsdigita.cms.ui.workflow.WorkflowLockedComponentAccess;
|
|
||||||
import com.arsdigita.domain.DomainService;
|
|
||||||
import com.arsdigita.globalization.GlobalizedMessage;
|
|
||||||
import com.arsdigita.toolbox.ui.DomainObjectPropertySheet;
|
|
||||||
|
|
||||||
import org.arsdigita.cms.CMSConfig;
|
|
||||||
import org.librecms.CmsConstants;
|
|
||||||
import org.librecms.contentsection.ContentItem;
|
|
||||||
import org.scientificcms.publications.SciPublicationsConfig;
|
|
||||||
import org.scientificcms.publications.SciPublicationsConstants;
|
|
||||||
|
|
||||||
import java.text.DateFormat;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
|
||||||
*/
|
|
||||||
public class PublicationPropertiesStep extends SimpleEditStep {
|
|
||||||
|
|
||||||
public static final String EDIT_SHEET_NAME = "edit";
|
|
||||||
|
|
||||||
private final SegmentedPanel segmentedPanel;
|
|
||||||
|
|
||||||
private final StringParameter selectedLangParameter;
|
|
||||||
|
|
||||||
public PublicationPropertiesStep(
|
|
||||||
final ItemSelectionModel itemModel,
|
|
||||||
final AuthoringKitWizard parent,
|
|
||||||
final StringParameter selectedLangParameter
|
|
||||||
) {
|
|
||||||
super(itemModel, parent, selectedLangParameter);
|
|
||||||
|
|
||||||
segmentedPanel = new SegmentedPanel();
|
|
||||||
setDefaultEditKey(EDIT_SHEET_NAME);
|
|
||||||
|
|
||||||
addBasicProperties(itemModel, parent);
|
|
||||||
addSteps(itemModel, parent);
|
|
||||||
|
|
||||||
this.selectedLangParameter = selectedLangParameter;
|
|
||||||
|
|
||||||
setDisplayComponent(segmentedPanel);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Component getPublicationPropertySheet(
|
|
||||||
final ItemSelectionModel itemModel,
|
|
||||||
final StringParameter selectedLanguageParam
|
|
||||||
) {
|
|
||||||
final DomainObjectPropertySheet sheet = new DomainObjectPropertySheet(
|
|
||||||
itemModel,
|
|
||||||
false,
|
|
||||||
selectedLanguageParam
|
|
||||||
);
|
|
||||||
|
|
||||||
sheet.add(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.publication.name",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
),
|
|
||||||
SciPublicationsController.NAME
|
|
||||||
);
|
|
||||||
sheet.add(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.publication.title",
|
|
||||||
SciPublicationsConstants.BUNDLE),
|
|
||||||
SciPublicationsController.TITLE
|
|
||||||
);
|
|
||||||
sheet.add(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.publication.year_of_publication",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
),
|
|
||||||
SciPublicationsController.YEAR_OF_PUBLICATION
|
|
||||||
);
|
|
||||||
sheet.add(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.publication.short_desc",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
),
|
|
||||||
SciPublicationsController.SHORT_DESCRIPTION
|
|
||||||
);
|
|
||||||
sheet.add(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.publication.abstract",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
),
|
|
||||||
SciPublicationsController.ABSTRACT
|
|
||||||
);
|
|
||||||
//new PreFormattedTextFormatter());
|
|
||||||
sheet.add(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.publication.misc",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
),
|
|
||||||
SciPublicationsController.MISC
|
|
||||||
);
|
|
||||||
|
|
||||||
final SciPublicationsConfig config = SciPublicationsConfig.getConfig();
|
|
||||||
if (config.isFirstPublishedPropertyEnabled()) {
|
|
||||||
sheet.add(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.publication.first_published",
|
|
||||||
SciPublicationsConstants.BUNDLE),
|
|
||||||
SciPublicationsController.YEAR_FIRST_PUBLISHED
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (config.isLanguagePropertyEnabled()) {
|
|
||||||
sheet.add(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.publication.language_of_publication",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
),
|
|
||||||
SciPublicationsController.LANGUAGE_OF_PUBLICATION
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!CMSConfig.getConfig().isHideLaunchDate()) {
|
|
||||||
sheet.add(new GlobalizedMessage("cms.contenttypes.ui.launch_date",
|
|
||||||
CmsConstants.CMS_BUNDLE),
|
|
||||||
SciPublicationsController.LAUNCH_DATE,
|
|
||||||
new DomainObjectPropertySheet.AttributeFormatter() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String format(final Object item,
|
|
||||||
final String attribute,
|
|
||||||
final PageState state) {
|
|
||||||
final ContentItem page = (ContentItem) item;
|
|
||||||
if (page.getLaunchDate() != null) {
|
|
||||||
return DateFormat
|
|
||||||
.getDateInstance(DateFormat.LONG)
|
|
||||||
.format(page.getLaunchDate());
|
|
||||||
} else {
|
|
||||||
return (String) new GlobalizedMessage(
|
|
||||||
"cms.ui.unknown",
|
|
||||||
CmsConstants.CMS_BUNDLE)
|
|
||||||
.localize();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return sheet;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected SegmentedPanel getSegmentedPanel() {
|
|
||||||
return segmentedPanel;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void addBasicProperties(
|
|
||||||
final ItemSelectionModel itemModel, final AuthoringKitWizard parent
|
|
||||||
) {
|
|
||||||
final SimpleEditStep basicProperties = new SimpleEditStep(
|
|
||||||
itemModel,
|
|
||||||
parent,
|
|
||||||
selectedLangParameter,
|
|
||||||
EDIT_SHEET_NAME
|
|
||||||
);
|
|
||||||
|
|
||||||
final BasicPageForm editBasicSheet = new PublicationPropertyForm(
|
|
||||||
itemModel,
|
|
||||||
this,
|
|
||||||
selectedLangParameter
|
|
||||||
);
|
|
||||||
basicProperties.add(
|
|
||||||
EDIT_SHEET_NAME,
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.publication.edit_basic_sheet",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
),
|
|
||||||
new WorkflowLockedComponentAccess(editBasicSheet, itemModel),
|
|
||||||
editBasicSheet.getSaveCancelSection().getCancelButton());
|
|
||||||
|
|
||||||
basicProperties.setDisplayComponent(
|
|
||||||
getPublicationPropertySheet(itemModel, selectedLangParameter)
|
|
||||||
);
|
|
||||||
|
|
||||||
segmentedPanel.addSegment(
|
|
||||||
new Label(new GlobalizedMessage(
|
|
||||||
"publications.ui.publication.basic_properties",
|
|
||||||
SciPublicationsConstants.BUNDLE)
|
|
||||||
),
|
|
||||||
basicProperties);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void addSteps(ItemSelectionModel itemModel,
|
|
||||||
AuthoringKitWizard parent) {
|
|
||||||
addStep(
|
|
||||||
new PublicationAuthorsPropertyStep(
|
|
||||||
itemModel, parent, selectedLangParameter),
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.publication.authors",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
)
|
|
||||||
);
|
|
||||||
if (isSeriesStepEnabled()) {
|
|
||||||
addStep(
|
|
||||||
new PublicationSeriesPropertyStep(
|
|
||||||
itemModel, parent, selectedLangParameter),
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.publication.series",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void addStep(final SimpleEditStep step,
|
|
||||||
final GlobalizedMessage label
|
|
||||||
) {
|
|
||||||
segmentedPanel.addSegment(new Label(label), step);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected boolean isSeriesStepEnabled() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected static class PreFormattedTextFormatter
|
|
||||||
extends DomainService
|
|
||||||
implements DomainObjectPropertySheet.AttributeFormatter {
|
|
||||||
|
|
||||||
public PreFormattedTextFormatter() {
|
|
||||||
super();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String format(final Object obj,
|
|
||||||
final String attribute,
|
|
||||||
final PageState state) {
|
|
||||||
|
|
||||||
final String str = (String) get(obj, attribute);
|
|
||||||
if ((str == null) || str.trim().isEmpty()) {
|
|
||||||
return (String) new GlobalizedMessage(
|
|
||||||
"cms.ui.unknown", CmsConstants.CMS_BUNDLE
|
|
||||||
).localize();
|
|
||||||
} else {
|
|
||||||
return String.format("<pre>%s</pre>", str);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,338 +0,0 @@
|
||||||
/*
|
|
||||||
* 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 com.arsdigita.cms.contenttypes.ui;
|
|
||||||
|
|
||||||
import com.arsdigita.bebop.FormData;
|
|
||||||
import com.arsdigita.bebop.FormProcessException;
|
|
||||||
import com.arsdigita.bebop.Label;
|
|
||||||
import com.arsdigita.bebop.PageState;
|
|
||||||
import com.arsdigita.bebop.Text;
|
|
||||||
import com.arsdigita.bebop.event.FormInitListener;
|
|
||||||
import com.arsdigita.bebop.event.FormProcessListener;
|
|
||||||
import com.arsdigita.bebop.event.FormSectionEvent;
|
|
||||||
import com.arsdigita.bebop.event.FormSubmissionListener;
|
|
||||||
import com.arsdigita.bebop.event.PrintEvent;
|
|
||||||
import com.arsdigita.bebop.event.PrintListener;
|
|
||||||
import com.arsdigita.bebop.form.Option;
|
|
||||||
import com.arsdigita.bebop.form.SingleSelect;
|
|
||||||
import com.arsdigita.bebop.form.TextArea;
|
|
||||||
import com.arsdigita.bebop.form.TextField;
|
|
||||||
import com.arsdigita.bebop.parameters.IntegerParameter;
|
|
||||||
import com.arsdigita.bebop.parameters.ParameterModel;
|
|
||||||
import com.arsdigita.bebop.parameters.StringParameter;
|
|
||||||
import com.arsdigita.cms.ItemSelectionModel;
|
|
||||||
import com.arsdigita.cms.ui.CMSDHTMLEditor;
|
|
||||||
import com.arsdigita.cms.ui.authoring.BasicPageForm;
|
|
||||||
import com.arsdigita.cms.ui.authoring.SelectedLanguageUtil;
|
|
||||||
import com.arsdigita.globalization.GlobalizedMessage;
|
|
||||||
|
|
||||||
import org.apache.logging.log4j.LogManager;
|
|
||||||
import org.apache.logging.log4j.Logger;
|
|
||||||
import org.libreccm.cdi.utils.CdiUtil;
|
|
||||||
import org.libreccm.l10n.GlobalizationHelper;
|
|
||||||
import org.scientificcms.publications.SciPublicationsConfig;
|
|
||||||
import org.scientificcms.publications.SciPublicationsConstants;
|
|
||||||
|
|
||||||
import org.scientificcms.publications.contenttypes.PublicationItem;
|
|
||||||
|
|
||||||
import java.text.Collator;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Comparator;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Locale;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
|
||||||
*/
|
|
||||||
public class PublicationPropertyForm
|
|
||||||
extends BasicPageForm
|
|
||||||
implements FormProcessListener, FormInitListener, FormSubmissionListener {
|
|
||||||
|
|
||||||
private static final Logger LOGGER = LogManager.getLogger(
|
|
||||||
PublicationPropertyForm.class
|
|
||||||
);
|
|
||||||
|
|
||||||
public static final String ID = "Publication_edit";
|
|
||||||
|
|
||||||
private final static SciPublicationsConfig CONFIG = SciPublicationsConfig
|
|
||||||
.getConfig();
|
|
||||||
|
|
||||||
private PublicationPropertiesStep step;
|
|
||||||
|
|
||||||
private final StringParameter selectedLanguageParam;
|
|
||||||
|
|
||||||
public PublicationPropertyForm(final ItemSelectionModel itemModel,
|
|
||||||
final StringParameter selectedLangParam) {
|
|
||||||
|
|
||||||
this(itemModel, null, selectedLangParam);
|
|
||||||
}
|
|
||||||
|
|
||||||
public PublicationPropertyForm(final ItemSelectionModel itemModel,
|
|
||||||
final PublicationPropertiesStep step,
|
|
||||||
final StringParameter selectedLangParam) {
|
|
||||||
|
|
||||||
super(ID, itemModel, selectedLangParam);
|
|
||||||
this.step = step;
|
|
||||||
this.selectedLanguageParam = selectedLangParam;
|
|
||||||
addSubmissionListener(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void addWidgets() {
|
|
||||||
|
|
||||||
super.addWidgets();
|
|
||||||
|
|
||||||
final ParameterModel yearOfPublicationParam = new IntegerParameter(
|
|
||||||
"yearOfPublication"
|
|
||||||
);
|
|
||||||
final TextField yearOfPublication
|
|
||||||
= new TextField(yearOfPublicationParam);
|
|
||||||
yearOfPublication.setMaxLength(4);
|
|
||||||
yearOfPublication.setLabel(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.publication.year_of_publication",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
)
|
|
||||||
);
|
|
||||||
add(yearOfPublication);
|
|
||||||
|
|
||||||
final ParameterModel firstPublishedParam = new IntegerParameter(
|
|
||||||
SciPublicationsController.YEAR_FIRST_PUBLISHED);
|
|
||||||
final TextField firstPublished = new TextField(firstPublishedParam);
|
|
||||||
firstPublished.setLabel(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.publication.first_published",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
)
|
|
||||||
);
|
|
||||||
add(firstPublished);
|
|
||||||
final ParameterModel langParam = new StringParameter(
|
|
||||||
SciPublicationsController.LANGUAGE_OF_PUBLICATION
|
|
||||||
);
|
|
||||||
final SingleSelect lang = new SingleSelect(langParam);
|
|
||||||
final Locale[] locales = Locale.getAvailableLocales();
|
|
||||||
lang.addOption(new Option("", new Text("")));
|
|
||||||
Arrays.sort(locales, new Comparator<Locale>() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int compare(final Locale locale1,
|
|
||||||
final Locale locale2) {
|
|
||||||
final GlobalizationHelper globalizationHelper = CdiUtil
|
|
||||||
.createCdiUtil()
|
|
||||||
.findBean(GlobalizationHelper.class);
|
|
||||||
final Locale negLocale = globalizationHelper
|
|
||||||
.getNegotiatedLocale();
|
|
||||||
final Collator collator = Collator
|
|
||||||
.getInstance(negLocale);
|
|
||||||
|
|
||||||
return collator.compare(locale1
|
|
||||||
.getDisplayName(negLocale),
|
|
||||||
locale2
|
|
||||||
.getDisplayName(negLocale));
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
for (Locale locale : locales) {
|
|
||||||
final Locale currentLocale = locale;
|
|
||||||
|
|
||||||
final Label optionLabel = new Label(new PrintListener() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void prepare(final PrintEvent event) {
|
|
||||||
final Label target = (Label) event.getTarget();
|
|
||||||
final GlobalizationHelper globalizationHelper = CdiUtil
|
|
||||||
.createCdiUtil()
|
|
||||||
.findBean(GlobalizationHelper.class);
|
|
||||||
target.setLabel(
|
|
||||||
currentLocale.getDisplayName(
|
|
||||||
globalizationHelper.getNegotiatedLocale()
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
||||||
lang.addOption(new Option(locale.toString(), optionLabel));
|
|
||||||
}
|
|
||||||
lang.setLabel(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.publication.language",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
)
|
|
||||||
);
|
|
||||||
add(lang);
|
|
||||||
|
|
||||||
final ParameterModel abstractParam = new StringParameter(
|
|
||||||
SciPublicationsController.ABSTRACT
|
|
||||||
);
|
|
||||||
final TextArea abstractArea;
|
|
||||||
if (CONFIG.isAbstractHtmlEnabled()) {
|
|
||||||
abstractArea = new CMSDHTMLEditor(abstractParam);
|
|
||||||
} else {
|
|
||||||
abstractArea = new TextArea(abstractParam);
|
|
||||||
}
|
|
||||||
abstractArea.setCols(60);
|
|
||||||
abstractArea.setRows(18);
|
|
||||||
abstractArea.setLabel(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.publication.abstract",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
)
|
|
||||||
);
|
|
||||||
add(abstractArea);
|
|
||||||
|
|
||||||
final ParameterModel shortDescParam = new StringParameter(
|
|
||||||
SciPublicationsController.SHORT_DESCRIPTION
|
|
||||||
);
|
|
||||||
final TextArea shortDesc;
|
|
||||||
if (CONFIG.isShortDescriptionHtmlEnabled()) {
|
|
||||||
shortDesc = new CMSDHTMLEditor(shortDescParam);
|
|
||||||
} else {
|
|
||||||
shortDesc = new TextArea(shortDescParam);
|
|
||||||
}
|
|
||||||
shortDesc.setLabel(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.publication.short_description",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
)
|
|
||||||
);
|
|
||||||
shortDesc.setCols(60);
|
|
||||||
shortDesc.setRows(10);
|
|
||||||
add(shortDesc);
|
|
||||||
|
|
||||||
final ParameterModel miscParam = new StringParameter(
|
|
||||||
SciPublicationsController.MISC
|
|
||||||
);
|
|
||||||
final TextArea misc;
|
|
||||||
if (CONFIG.isMiscHtmlEnabled()) {
|
|
||||||
misc = new CMSDHTMLEditor(miscParam);
|
|
||||||
} else {
|
|
||||||
misc = new TextArea(miscParam);
|
|
||||||
}
|
|
||||||
misc.setLabel(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.publication.misc",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
)
|
|
||||||
);
|
|
||||||
misc.setCols(60);
|
|
||||||
misc.setRows(18);
|
|
||||||
add(misc);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void init(final FormSectionEvent event) throws FormProcessException {
|
|
||||||
|
|
||||||
final FormData data = event.getFormData();
|
|
||||||
final PublicationItem<?> item = (PublicationItem<?>) super
|
|
||||||
.initBasicWidgets(event);
|
|
||||||
|
|
||||||
final PageState state = event.getPageState();
|
|
||||||
|
|
||||||
final Locale selectedLanguage = SelectedLanguageUtil
|
|
||||||
.selectedLocale(state, selectedLanguageParam);
|
|
||||||
|
|
||||||
data.put(SciPublicationsController.YEAR_OF_PUBLICATION,
|
|
||||||
item.getPublication().getYearOfPublication());
|
|
||||||
data.put(SciPublicationsController.YEAR_FIRST_PUBLISHED,
|
|
||||||
item.getPublication().getYearFirstPublished());
|
|
||||||
data.put(SciPublicationsController.LANGUAGE_OF_PUBLICATION,
|
|
||||||
item.getPublication().getLanguageOfPublication());
|
|
||||||
data.put(
|
|
||||||
SciPublicationsController.ABSTRACT,
|
|
||||||
item.getPublication().getPublicationAbstract().getValue(
|
|
||||||
selectedLanguage
|
|
||||||
)
|
|
||||||
);
|
|
||||||
data.put(
|
|
||||||
SciPublicationsController.SHORT_DESCRIPTION,
|
|
||||||
item.getPublication().getShortDescription().getValue(
|
|
||||||
selectedLanguage
|
|
||||||
)
|
|
||||||
);
|
|
||||||
data.put(
|
|
||||||
SciPublicationsController.MISC,
|
|
||||||
item.getPublication().getMisc().getValue(selectedLanguage)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void process(FormSectionEvent event) throws FormProcessException {
|
|
||||||
|
|
||||||
final FormData formData = event.getFormData();
|
|
||||||
final PageState state = event.getPageState();
|
|
||||||
final PublicationItem<?> item = (PublicationItem) super
|
|
||||||
.processBasicWidgets(event);
|
|
||||||
|
|
||||||
if ((item != null)
|
|
||||||
&& getSaveCancelSection().getSaveButton().isSelected(state)) {
|
|
||||||
|
|
||||||
final Map<String, Object> data = new HashMap<>();
|
|
||||||
|
|
||||||
data.put(
|
|
||||||
SciPublicationsController.YEAR_OF_PUBLICATION,
|
|
||||||
formData.get(SciPublicationsController.YEAR_OF_PUBLICATION)
|
|
||||||
);
|
|
||||||
data.put(
|
|
||||||
SciPublicationsController.YEAR_FIRST_PUBLISHED,
|
|
||||||
formData.get(SciPublicationsController.YEAR_FIRST_PUBLISHED
|
|
||||||
)
|
|
||||||
);
|
|
||||||
data.put(
|
|
||||||
SciPublicationsController.LANGUAGE_OF_PUBLICATION,
|
|
||||||
new Locale(
|
|
||||||
(String) formData.get(
|
|
||||||
SciPublicationsController.LANGUAGE_OF_PUBLICATION
|
|
||||||
)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
data.put(
|
|
||||||
SciPublicationsController.ABSTRACT,
|
|
||||||
formData.get(SciPublicationsController.ABSTRACT)
|
|
||||||
);
|
|
||||||
data.put(
|
|
||||||
SciPublicationsController.SHORT_DESCRIPTION,
|
|
||||||
formData.get(SciPublicationsController.SHORT_DESCRIPTION)
|
|
||||||
);
|
|
||||||
data.put(
|
|
||||||
SciPublicationsController.MISC,
|
|
||||||
formData.get(SciPublicationsController.MISC)
|
|
||||||
);
|
|
||||||
|
|
||||||
final Locale selectedLocale = SelectedLanguageUtil.selectedLocale(
|
|
||||||
state, selectedLanguageParam
|
|
||||||
);
|
|
||||||
|
|
||||||
final SciPublicationsController controller = CdiUtil
|
|
||||||
.createCdiUtil()
|
|
||||||
.findBean(SciPublicationsController.class);
|
|
||||||
controller.savePublication(item.getPublication().getPublicationId(),
|
|
||||||
selectedLocale,
|
|
||||||
data);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void submitted(final FormSectionEvent event)
|
|
||||||
throws FormProcessException {
|
|
||||||
|
|
||||||
if ((step != null) && getSaveCancelSection().getCancelButton().
|
|
||||||
isSelected(event.getPageState())) {
|
|
||||||
step.cancelStreamlinedCreation(event.getPageState());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected GlobalizedMessage getTitleLabel() {
|
|
||||||
return new GlobalizedMessage(
|
|
||||||
"publications.ui.publication.title",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,109 +0,0 @@
|
||||||
/*
|
|
||||||
* 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 com.arsdigita.cms.contenttypes.ui;
|
|
||||||
|
|
||||||
import com.arsdigita.bebop.PageState;
|
|
||||||
import com.arsdigita.bebop.form.Widget;
|
|
||||||
import com.arsdigita.bebop.parameters.LongParameter;
|
|
||||||
import com.arsdigita.cms.CMS;
|
|
||||||
import com.arsdigita.xml.Element;
|
|
||||||
|
|
||||||
import org.libreccm.cdi.utils.CdiUtil;
|
|
||||||
import org.scientificcms.publications.Publication;
|
|
||||||
import org.scientificcms.publications.PublicationWithPublisher;
|
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
|
||||||
*/
|
|
||||||
public class PublicationSearchWidget extends Widget {
|
|
||||||
|
|
||||||
private Class<? extends Publication> type;
|
|
||||||
|
|
||||||
public PublicationSearchWidget(final String name) {
|
|
||||||
super(new LongParameter(name));
|
|
||||||
}
|
|
||||||
|
|
||||||
public PublicationSearchWidget(
|
|
||||||
final String name, final Class<? extends Publication> type
|
|
||||||
) {
|
|
||||||
this(name);
|
|
||||||
this.type = type;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isCompound() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected String getType() {
|
|
||||||
return "publication-search-widget";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected String getElementTag() {
|
|
||||||
return "cms:publication-search-widget";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void generateWidget(final PageState state,
|
|
||||||
final Element parent) {
|
|
||||||
final Element widget = parent.newChildElement(
|
|
||||||
getElementTag(), CMS.CMS_XML_NS
|
|
||||||
);
|
|
||||||
|
|
||||||
widget.addAttribute("name", getName());
|
|
||||||
|
|
||||||
if (type != null) {
|
|
||||||
widget.addAttribute("publication-type", type.getName());
|
|
||||||
}
|
|
||||||
|
|
||||||
final Long value = (Long) getValue(state);
|
|
||||||
if (value != null) {
|
|
||||||
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
|
|
||||||
final PublicationSearchWidgetController controller = cdiUtil
|
|
||||||
.findBean(PublicationSearchWidgetController.class);
|
|
||||||
|
|
||||||
final Map<String, String> data = controller.getData(value);
|
|
||||||
|
|
||||||
final Element selected = widget.newChildElement(
|
|
||||||
"cms:selected-publication", CMS.CMS_XML_NS
|
|
||||||
);
|
|
||||||
selected.addAttribute(
|
|
||||||
"publicationId",
|
|
||||||
data.get(PublicationSearchWidgetController.PUBLICATION_ID)
|
|
||||||
);
|
|
||||||
|
|
||||||
selected.addAttribute(
|
|
||||||
"title",
|
|
||||||
data.get(PublicationSearchWidgetController.TITLE)
|
|
||||||
);
|
|
||||||
|
|
||||||
selected.addAttribute(
|
|
||||||
"year",
|
|
||||||
data.get(PublicationSearchWidgetController.YEAR)
|
|
||||||
);
|
|
||||||
|
|
||||||
if (type != null
|
|
||||||
&& PublicationWithPublisher.class.isAssignableFrom(type)) {
|
|
||||||
selected.addAttribute(
|
|
||||||
"publisher",
|
|
||||||
data.get(PublicationSearchWidgetController.PUBLISHER)
|
|
||||||
);
|
|
||||||
selected.addAttribute(
|
|
||||||
"place",
|
|
||||||
data.get(PublicationSearchWidgetController.PLACE)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
exportAttributes(widget);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,95 +0,0 @@
|
||||||
/*
|
|
||||||
* 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 com.arsdigita.cms.contenttypes.ui;
|
|
||||||
|
|
||||||
import org.libreccm.l10n.GlobalizationHelper;
|
|
||||||
import org.librecms.assets.Person;
|
|
||||||
import org.scientificcms.publications.Authorship;
|
|
||||||
import org.scientificcms.publications.Publication;
|
|
||||||
import org.scientificcms.publications.PublicationRepository;
|
|
||||||
import org.scientificcms.publications.PublicationWithPublisher;
|
|
||||||
import org.scientificcms.publications.Publisher;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
import javax.enterprise.context.RequestScoped;
|
|
||||||
import javax.inject.Inject;
|
|
||||||
import javax.transaction.Transactional;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
|
||||||
*/
|
|
||||||
@RequestScoped
|
|
||||||
public class PublicationSearchWidgetController {
|
|
||||||
|
|
||||||
protected static final String PUBLICATION_ID = "publicationId";
|
|
||||||
|
|
||||||
protected static final String TITLE = "title";
|
|
||||||
|
|
||||||
protected static final String YEAR = "year";
|
|
||||||
|
|
||||||
protected static final String AUTHORS = "authors";
|
|
||||||
|
|
||||||
protected static final String PUBLISHER = "publisher";
|
|
||||||
|
|
||||||
protected static final String PLACE = "place";
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
private PublicationRepository publicationRepository;
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
private GlobalizationHelper globalizationHelper;
|
|
||||||
|
|
||||||
@Transactional(Transactional.TxType.REQUIRED)
|
|
||||||
public Map<String, String> getData(final long publicationId) {
|
|
||||||
|
|
||||||
final Publication publication = publicationRepository
|
|
||||||
.findById(publicationId)
|
|
||||||
.orElseThrow(
|
|
||||||
() -> new IllegalArgumentException(
|
|
||||||
String.format("No Publication with ID %d found.",
|
|
||||||
publicationId)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
final Map<String, String> data = new HashMap<>();
|
|
||||||
|
|
||||||
data.put(PUBLICATION_ID, Long.toString(publication.getPublicationId()));
|
|
||||||
data.put(
|
|
||||||
TITLE,
|
|
||||||
globalizationHelper.getValueFromLocalizedString(
|
|
||||||
publication.getTitle()
|
|
||||||
)
|
|
||||||
);
|
|
||||||
data.put(YEAR, Integer.toString(publication.getYearOfPublication()));
|
|
||||||
data.put(
|
|
||||||
AUTHORS,
|
|
||||||
publication
|
|
||||||
.getAuthorships()
|
|
||||||
.stream()
|
|
||||||
.sorted()
|
|
||||||
.map(Authorship::getAuthor)
|
|
||||||
.map(Person::getPersonName)
|
|
||||||
.map(name -> String.format("%s, %s",
|
|
||||||
name.getSurname(),
|
|
||||||
name.getGivenName()))
|
|
||||||
.collect(Collectors.joining("; "))
|
|
||||||
);
|
|
||||||
|
|
||||||
if (publication instanceof PublicationWithPublisher) {
|
|
||||||
final Publisher publisher = ((PublicationWithPublisher) publication)
|
|
||||||
.getPublisher();
|
|
||||||
data.put(PUBLISHER, publisher.getName());
|
|
||||||
data.put(PLACE, publisher.getPlace());
|
|
||||||
}
|
|
||||||
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,126 +0,0 @@
|
||||||
/*
|
|
||||||
* 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 com.arsdigita.cms.contenttypes.ui;
|
|
||||||
|
|
||||||
import com.arsdigita.bebop.FormData;
|
|
||||||
import com.arsdigita.bebop.FormProcessException;
|
|
||||||
import com.arsdigita.bebop.PageState;
|
|
||||||
import com.arsdigita.bebop.event.FormInitListener;
|
|
||||||
import com.arsdigita.bebop.event.FormProcessListener;
|
|
||||||
import com.arsdigita.bebop.event.FormSectionEvent;
|
|
||||||
import com.arsdigita.bebop.form.TextField;
|
|
||||||
import com.arsdigita.bebop.parameters.ParameterModel;
|
|
||||||
import com.arsdigita.bebop.parameters.StringParameter;
|
|
||||||
import com.arsdigita.cms.ItemSelectionModel;
|
|
||||||
import com.arsdigita.cms.ui.assets.AssetSearchWidget;
|
|
||||||
import com.arsdigita.cms.ui.authoring.BasicItemForm;
|
|
||||||
import com.arsdigita.globalization.GlobalizedMessage;
|
|
||||||
|
|
||||||
import org.apache.logging.log4j.LogManager;
|
|
||||||
import org.apache.logging.log4j.Logger;
|
|
||||||
import org.libreccm.cdi.utils.CdiUtil;
|
|
||||||
import org.scientificcms.publications.PublicationManager;
|
|
||||||
import org.scientificcms.publications.SciPublicationsConfig;
|
|
||||||
import org.scientificcms.publications.SciPublicationsConstants;
|
|
||||||
import org.scientificcms.publications.Series;
|
|
||||||
import org.scientificcms.publications.assets.SeriesAsset;
|
|
||||||
import org.scientificcms.publications.contenttypes.PublicationItem;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
|
||||||
*/
|
|
||||||
public class PublicationSeriesAddForm
|
|
||||||
extends BasicItemForm
|
|
||||||
implements FormProcessListener, FormInitListener {
|
|
||||||
|
|
||||||
private static final Logger LOGGER = LogManager.getLogger(
|
|
||||||
PublicationSeriesAddForm.class
|
|
||||||
);
|
|
||||||
|
|
||||||
private static final String SERIES_SEARCH = "series";
|
|
||||||
|
|
||||||
private final static SciPublicationsConfig CONFIG = SciPublicationsConfig
|
|
||||||
.getConfig();
|
|
||||||
|
|
||||||
private PublicationPropertiesStep step;
|
|
||||||
|
|
||||||
private AssetSearchWidget seriesSearchWidget;
|
|
||||||
|
|
||||||
private ItemSelectionModel itemModel;
|
|
||||||
|
|
||||||
private TextField volumeOfSeries;
|
|
||||||
|
|
||||||
public PublicationSeriesAddForm(final ItemSelectionModel itemModel,
|
|
||||||
final StringParameter selectedLanguageParam) {
|
|
||||||
super("SeriesEntryForm", itemModel, selectedLanguageParam);
|
|
||||||
this.itemModel = itemModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void addWidgets() {
|
|
||||||
|
|
||||||
seriesSearchWidget = new AssetSearchWidget(
|
|
||||||
SERIES_SEARCH,
|
|
||||||
SeriesAsset.class
|
|
||||||
);
|
|
||||||
seriesSearchWidget.setLabel(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.series.select_series",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
)
|
|
||||||
);
|
|
||||||
add(seriesSearchWidget);
|
|
||||||
|
|
||||||
final ParameterModel volumeOfSeriesParam = new StringParameter(
|
|
||||||
SciPublicationsController.VOLUME_IN_SERIES
|
|
||||||
);
|
|
||||||
volumeOfSeries = new TextField(volumeOfSeriesParam);
|
|
||||||
volumeOfSeries.setLabel(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.series.volume_of_series",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
)
|
|
||||||
);
|
|
||||||
add(volumeOfSeries);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void init(FormSectionEvent event) throws FormProcessException {
|
|
||||||
|
|
||||||
final PageState state = event.getPageState();
|
|
||||||
|
|
||||||
setVisible(state, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void process(final FormSectionEvent event)
|
|
||||||
throws FormProcessException {
|
|
||||||
|
|
||||||
final FormData data = event.getFormData();
|
|
||||||
final PageState state = event.getPageState();
|
|
||||||
|
|
||||||
final PublicationItem<?> item
|
|
||||||
= (PublicationItem<?>) getItemSelectionModel()
|
|
||||||
.getSelectedObject(state);
|
|
||||||
|
|
||||||
if (!(getSaveCancelSection().getCancelButton().isSelected(state))) {
|
|
||||||
|
|
||||||
Series series = (Series) data.get(SERIES_SEARCH);
|
|
||||||
|
|
||||||
final PublicationManager publicationManager = CdiUtil
|
|
||||||
.createCdiUtil().findBean(PublicationManager.class);
|
|
||||||
publicationManager.addSeries(
|
|
||||||
series,
|
|
||||||
item.getPublication(),
|
|
||||||
(String) volumeOfSeries.getValue(state)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
init(event);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,58 +0,0 @@
|
||||||
/*
|
|
||||||
* 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 com.arsdigita.cms.contenttypes.ui;
|
|
||||||
|
|
||||||
import com.arsdigita.bebop.parameters.StringParameter;
|
|
||||||
import com.arsdigita.cms.ItemSelectionModel;
|
|
||||||
import com.arsdigita.cms.ui.authoring.AuthoringKitWizard;
|
|
||||||
import com.arsdigita.cms.ui.authoring.BasicItemForm;
|
|
||||||
import com.arsdigita.cms.ui.authoring.SimpleEditStep;
|
|
||||||
import com.arsdigita.cms.ui.workflow.WorkflowLockedComponentAccess;
|
|
||||||
import com.arsdigita.globalization.GlobalizedMessage;
|
|
||||||
|
|
||||||
import org.scientificcms.publications.SciPublicationsConstants;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
|
||||||
*/
|
|
||||||
public class PublicationSeriesPropertyStep extends SimpleEditStep {
|
|
||||||
|
|
||||||
private static final String ADD_SERIES_SHEET_NAME = "addSeries";
|
|
||||||
|
|
||||||
public PublicationSeriesPropertyStep(
|
|
||||||
final ItemSelectionModel itemModel,
|
|
||||||
final AuthoringKitWizard parent,
|
|
||||||
final StringParameter selectedLanguageParameter) {
|
|
||||||
this(itemModel, parent, selectedLanguageParameter, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public PublicationSeriesPropertyStep(
|
|
||||||
final ItemSelectionModel itemModel,
|
|
||||||
final AuthoringKitWizard parent,
|
|
||||||
final StringParameter selectedLanguageParameter,
|
|
||||||
final String prefix
|
|
||||||
) {
|
|
||||||
super(itemModel, parent, selectedLanguageParameter, prefix);
|
|
||||||
|
|
||||||
final BasicItemForm addSeriesSheet = new PublicationSeriesAddForm(
|
|
||||||
itemModel, selectedLanguageParameter
|
|
||||||
);
|
|
||||||
add(ADD_SERIES_SHEET_NAME,
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.series.add_series",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
),
|
|
||||||
new WorkflowLockedComponentAccess(addSeriesSheet, itemModel),
|
|
||||||
addSeriesSheet.getSaveCancelSection().getCancelButton());
|
|
||||||
|
|
||||||
final PublicationSeriesTable seriesTable = new PublicationSeriesTable(
|
|
||||||
itemModel, this, selectedLanguageParameter
|
|
||||||
);
|
|
||||||
setDisplayComponent(seriesTable);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,357 +0,0 @@
|
||||||
/*
|
|
||||||
* 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 com.arsdigita.cms.contenttypes.ui;
|
|
||||||
|
|
||||||
import com.arsdigita.bebop.Component;
|
|
||||||
import com.arsdigita.bebop.ControlLink;
|
|
||||||
import com.arsdigita.bebop.FormProcessException;
|
|
||||||
import com.arsdigita.bebop.Label;
|
|
||||||
import com.arsdigita.bebop.PageState;
|
|
||||||
import com.arsdigita.bebop.Table;
|
|
||||||
import com.arsdigita.bebop.Text;
|
|
||||||
import com.arsdigita.bebop.event.TableActionEvent;
|
|
||||||
import com.arsdigita.bebop.event.TableActionListener;
|
|
||||||
import com.arsdigita.bebop.parameters.StringParameter;
|
|
||||||
import com.arsdigita.bebop.table.TableCellRenderer;
|
|
||||||
import com.arsdigita.bebop.table.TableColumn;
|
|
||||||
import com.arsdigita.bebop.table.TableColumnModel;
|
|
||||||
import com.arsdigita.bebop.table.TableModel;
|
|
||||||
import com.arsdigita.bebop.table.TableModelBuilder;
|
|
||||||
import com.arsdigita.cms.ItemSelectionModel;
|
|
||||||
import com.arsdigita.cms.ui.authoring.SelectedLanguageUtil;
|
|
||||||
import com.arsdigita.globalization.GlobalizedMessage;
|
|
||||||
import com.arsdigita.util.LockableImpl;
|
|
||||||
|
|
||||||
import org.apache.logging.log4j.LogManager;
|
|
||||||
import org.apache.logging.log4j.Logger;
|
|
||||||
import org.libreccm.cdi.utils.CdiUtil;
|
|
||||||
import org.libreccm.l10n.LocalizedString;
|
|
||||||
import org.libreccm.security.PermissionChecker;
|
|
||||||
import org.librecms.contentsection.privileges.ItemPrivileges;
|
|
||||||
import org.scientificcms.publications.SciPublicationsConstants;
|
|
||||||
import org.scientificcms.publications.VolumeInSeries;
|
|
||||||
import org.scientificcms.publications.contenttypes.PublicationItem;
|
|
||||||
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.Locale;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
|
||||||
*/
|
|
||||||
public class PublicationSeriesTable
|
|
||||||
extends Table
|
|
||||||
implements TableActionListener {
|
|
||||||
|
|
||||||
private static final Logger LOGGER = LogManager.getLogger(
|
|
||||||
PublicationSeriesTable.class);
|
|
||||||
|
|
||||||
private final static String TABLE_COL_EDIT = "table_col_edit";
|
|
||||||
|
|
||||||
private final static String TABLE_COL_NUMBER = "table_col_num";
|
|
||||||
|
|
||||||
private final static String TABLE_COL_DEL = "table_col_del";
|
|
||||||
|
|
||||||
private final ItemSelectionModel itemModel;
|
|
||||||
|
|
||||||
private final PublicationSeriesPropertyStep editStep;
|
|
||||||
|
|
||||||
private final StringParameter selectedLangParam;
|
|
||||||
|
|
||||||
public PublicationSeriesTable(
|
|
||||||
final ItemSelectionModel itemModel,
|
|
||||||
final PublicationSeriesPropertyStep editStep,
|
|
||||||
final StringParameter selectedLangParam
|
|
||||||
) {
|
|
||||||
|
|
||||||
super();
|
|
||||||
this.itemModel = itemModel;
|
|
||||||
this.editStep = editStep;
|
|
||||||
this.selectedLangParam = selectedLangParam;
|
|
||||||
|
|
||||||
setEmptyView(
|
|
||||||
new Label(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.series.none",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
final TableColumnModel colModel = getColumnModel();
|
|
||||||
colModel.add(
|
|
||||||
new TableColumn(
|
|
||||||
0,
|
|
||||||
new Label(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.series.title",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
)
|
|
||||||
),
|
|
||||||
TABLE_COL_EDIT
|
|
||||||
)
|
|
||||||
);
|
|
||||||
colModel.add(
|
|
||||||
new TableColumn(
|
|
||||||
1,
|
|
||||||
new Label(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.series.number",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
)
|
|
||||||
),
|
|
||||||
TABLE_COL_NUMBER
|
|
||||||
)
|
|
||||||
);
|
|
||||||
colModel.add(
|
|
||||||
new TableColumn(
|
|
||||||
2,
|
|
||||||
new Label(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.series.remove",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
)
|
|
||||||
),
|
|
||||||
TABLE_COL_DEL
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
setModelBuilder(
|
|
||||||
new PublicationSeriesTableModelBuilder(
|
|
||||||
itemModel, selectedLangParam
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
colModel.get(0).setCellRenderer(new EditCellRenderer());
|
|
||||||
colModel.get(1).setCellRenderer(new NumberCellRenderer());
|
|
||||||
colModel.get(2).setCellRenderer(new DeleteCellRenderer());
|
|
||||||
|
|
||||||
LOGGER.info("Adding table action listener...");
|
|
||||||
addTableActionListener(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void cellSelected(final TableActionEvent event)
|
|
||||||
throws FormProcessException {
|
|
||||||
|
|
||||||
final PageState state = event.getPageState();
|
|
||||||
final PublicationItem<?> selected = (PublicationItem<?>) itemModel
|
|
||||||
.getSelectedItem(state);
|
|
||||||
final SciPublicationsController controller = CdiUtil
|
|
||||||
.createCdiUtil()
|
|
||||||
.findBean(SciPublicationsController.class);
|
|
||||||
final VolumeInSeries volumeInSeries = controller.findVolumeInSeries(
|
|
||||||
selected.getPublication().getPublicationId(),
|
|
||||||
event.getRowKey()
|
|
||||||
).get();
|
|
||||||
|
|
||||||
final TableColumn column = getColumnModel().get(event.getColumn());
|
|
||||||
|
|
||||||
if (TABLE_COL_EDIT.equals(column.getHeaderKey().toString())) {
|
|
||||||
// Nothing for now
|
|
||||||
} else if (TABLE_COL_DEL.equals(column.getHeaderKey().toString())) {
|
|
||||||
controller.removeSeries(
|
|
||||||
selected.getPublication().getPublicationId(),
|
|
||||||
volumeInSeries.getVolumeId()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void headSelected(final TableActionEvent event) {
|
|
||||||
|
|
||||||
// Nothing
|
|
||||||
}
|
|
||||||
|
|
||||||
private class PublicationSeriesTableModelBuilder
|
|
||||||
extends LockableImpl
|
|
||||||
implements TableModelBuilder {
|
|
||||||
|
|
||||||
private final ItemSelectionModel itemModel;
|
|
||||||
|
|
||||||
public PublicationSeriesTableModelBuilder(
|
|
||||||
final ItemSelectionModel itemModel,
|
|
||||||
final StringParameter selectedLangParam
|
|
||||||
) {
|
|
||||||
this.itemModel = itemModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public TableModel makeModel(final Table table, final PageState state) {
|
|
||||||
|
|
||||||
table.getRowSelectionModel().clearSelection(state);
|
|
||||||
final PublicationItem<?> publication
|
|
||||||
= (PublicationItem<?>) itemModel
|
|
||||||
.getSelectedItem(state);
|
|
||||||
return new PublicationSeriesTableModel(
|
|
||||||
table, state, selectedLangParam, publication
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private class PublicationSeriesTableModel implements TableModel {
|
|
||||||
|
|
||||||
private final Table table;
|
|
||||||
|
|
||||||
private final PageState state;
|
|
||||||
|
|
||||||
private final StringParameter selectedLangParam;
|
|
||||||
|
|
||||||
private final Iterator<Map<String, Object>> iterator;
|
|
||||||
|
|
||||||
private Map<String, Object> currentRow;
|
|
||||||
|
|
||||||
public PublicationSeriesTableModel(
|
|
||||||
final Table table,
|
|
||||||
final PageState state,
|
|
||||||
final StringParameter selectedLangParam,
|
|
||||||
final PublicationItem<?> publicationItem
|
|
||||||
) {
|
|
||||||
this.table = table;
|
|
||||||
this.state = state;
|
|
||||||
this.selectedLangParam = selectedLangParam;
|
|
||||||
|
|
||||||
final SciPublicationsController controller = CdiUtil
|
|
||||||
.createCdiUtil()
|
|
||||||
.findBean(SciPublicationsController.class);
|
|
||||||
iterator = controller.getVolumesInSeries(
|
|
||||||
publicationItem.getPublication().getPublicationId()
|
|
||||||
).iterator();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getColumnCount() {
|
|
||||||
return table.getColumnModel().size();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean nextRow() {
|
|
||||||
if (iterator.hasNext()) {
|
|
||||||
currentRow = iterator.next();
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object getElementAt(final int columnIndex) {
|
|
||||||
switch (columnIndex) {
|
|
||||||
case 0: {
|
|
||||||
final LocalizedString title = (LocalizedString) currentRow
|
|
||||||
.get(SciPublicationsController.VOLUME_IN_SERIES_TITLE);
|
|
||||||
final Locale selectedLocale = SelectedLanguageUtil
|
|
||||||
.selectedLocale(state, selectedLangParam);
|
|
||||||
return title.getValue(selectedLocale);
|
|
||||||
}
|
|
||||||
case 1: {
|
|
||||||
return currentRow.get(
|
|
||||||
SciPublicationsController.VOLUME_IN_SERIES_VOLUME
|
|
||||||
);
|
|
||||||
}
|
|
||||||
case 2:
|
|
||||||
return new Label(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.series.remove",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
)
|
|
||||||
);
|
|
||||||
default:
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object getKeyAt(final int columnIndex) {
|
|
||||||
return currentRow.get(
|
|
||||||
SciPublicationsController.VOLUME_IN_SERIES_ID
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private class EditCellRenderer
|
|
||||||
extends LockableImpl
|
|
||||||
implements
|
|
||||||
TableCellRenderer {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Component getComponent(
|
|
||||||
final Table table,
|
|
||||||
final PageState state,
|
|
||||||
final Object value,
|
|
||||||
final boolean isSelected,
|
|
||||||
final Object key,
|
|
||||||
final int row,
|
|
||||||
final int column
|
|
||||||
) {
|
|
||||||
return new Text((String) value);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private class NumberCellRenderer
|
|
||||||
extends LockableImpl
|
|
||||||
implements TableCellRenderer {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Component getComponent(
|
|
||||||
final Table table,
|
|
||||||
final PageState state,
|
|
||||||
final Object value,
|
|
||||||
final boolean isSelected,
|
|
||||||
final Object key,
|
|
||||||
final int row,
|
|
||||||
final int column
|
|
||||||
) {
|
|
||||||
return new Text((String) value);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private class DeleteCellRenderer
|
|
||||||
extends LockableImpl
|
|
||||||
implements TableCellRenderer {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Component getComponent(
|
|
||||||
final Table table,
|
|
||||||
final PageState state,
|
|
||||||
final Object value,
|
|
||||||
final boolean isSelected,
|
|
||||||
final Object key, final int row,
|
|
||||||
final int column
|
|
||||||
) {
|
|
||||||
final PermissionChecker permissionChecker = CdiUtil
|
|
||||||
.createCdiUtil()
|
|
||||||
.findBean(PermissionChecker.class);
|
|
||||||
|
|
||||||
final PublicationItem<?> selected = (PublicationItem<?>) itemModel
|
|
||||||
.getSelectedItem(state);
|
|
||||||
final boolean canEdit = permissionChecker
|
|
||||||
.isPermitted(ItemPrivileges.EDIT, selected);
|
|
||||||
|
|
||||||
if (canEdit) {
|
|
||||||
final ControlLink link = new ControlLink(
|
|
||||||
(Component) value
|
|
||||||
);
|
|
||||||
link.setConfirmation(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.series.confirm_remove",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
)
|
|
||||||
);
|
|
||||||
return link;
|
|
||||||
} else {
|
|
||||||
return new Text("");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,154 +0,0 @@
|
||||||
/*
|
|
||||||
* 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 com.arsdigita.cms.contenttypes.ui;
|
|
||||||
|
|
||||||
import com.arsdigita.bebop.Component;
|
|
||||||
import com.arsdigita.bebop.Label;
|
|
||||||
import com.arsdigita.bebop.parameters.StringParameter;
|
|
||||||
import com.arsdigita.cms.ItemSelectionModel;
|
|
||||||
import com.arsdigita.cms.ui.authoring.AuthoringKitWizard;
|
|
||||||
import com.arsdigita.cms.ui.authoring.BasicPageForm;
|
|
||||||
import com.arsdigita.cms.ui.authoring.SimpleEditStep;
|
|
||||||
import com.arsdigita.cms.ui.workflow.WorkflowLockedComponentAccess;
|
|
||||||
import com.arsdigita.globalization.GlobalizedMessage;
|
|
||||||
import com.arsdigita.toolbox.ui.DomainObjectPropertySheet;
|
|
||||||
|
|
||||||
import org.scientificcms.publications.SciPublicationsConstants;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
|
||||||
*/
|
|
||||||
public class PublicationWithPublisherPropertiesStep
|
|
||||||
extends PublicationPropertiesStep {
|
|
||||||
|
|
||||||
private final StringParameter selectedLangParam;
|
|
||||||
|
|
||||||
public PublicationWithPublisherPropertiesStep(
|
|
||||||
final ItemSelectionModel itemModel,
|
|
||||||
final AuthoringKitWizard parent,
|
|
||||||
final StringParameter selectedLangParam
|
|
||||||
) {
|
|
||||||
super(itemModel, parent, selectedLangParam);
|
|
||||||
this.selectedLangParam = selectedLangParam;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Component getPublicationWithPublisherPropertySheet(
|
|
||||||
final ItemSelectionModel itemModel,
|
|
||||||
final StringParameter selectedLangParam
|
|
||||||
) {
|
|
||||||
final DomainObjectPropertySheet sheet
|
|
||||||
= (DomainObjectPropertySheet) PublicationPropertiesStep
|
|
||||||
.getPublicationPropertySheet(itemModel, selectedLangParam);
|
|
||||||
|
|
||||||
sheet.add(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.with_publisher.isbn10",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
),
|
|
||||||
SciPublicationsWithPublisherController.ISBN10
|
|
||||||
);
|
|
||||||
|
|
||||||
sheet.add(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.with_publisher.isbn13",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
),
|
|
||||||
SciPublicationsWithPublisherController.ISBN13
|
|
||||||
);
|
|
||||||
|
|
||||||
sheet.add(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.with_publisher.volume",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
),
|
|
||||||
SciPublicationsWithPublisherController.VOLUME
|
|
||||||
);
|
|
||||||
|
|
||||||
sheet.add(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.with_publisher.number_of_volumes",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
),
|
|
||||||
SciPublicationsWithPublisherController.NUMBER_OF_VOLUMES
|
|
||||||
);
|
|
||||||
|
|
||||||
sheet.add(new GlobalizedMessage(
|
|
||||||
"publications.ui.with_publisher.number_of_pages",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
),
|
|
||||||
SciPublicationsWithPublisherController.NUMBER_OF_PAGES
|
|
||||||
);
|
|
||||||
|
|
||||||
sheet.add(new GlobalizedMessage(
|
|
||||||
"publications.ui.with_publisher.edition",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
),
|
|
||||||
SciPublicationsWithPublisherController.EDITION
|
|
||||||
);
|
|
||||||
|
|
||||||
return sheet;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void addBasicProperties(
|
|
||||||
final ItemSelectionModel itemModel, final AuthoringKitWizard parent
|
|
||||||
) {
|
|
||||||
final SimpleEditStep basicProperties = new SimpleEditStep(
|
|
||||||
itemModel,
|
|
||||||
parent,
|
|
||||||
selectedLangParam,
|
|
||||||
EDIT_SHEET_NAME
|
|
||||||
);
|
|
||||||
|
|
||||||
final BasicPageForm editBasicSheet
|
|
||||||
= new PublicationWithPublisherPropertyForm(
|
|
||||||
itemModel, this, selectedLangParam);
|
|
||||||
|
|
||||||
basicProperties.add(
|
|
||||||
EDIT_SHEET_NAME,
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.publication.edit_basic_sheet",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
),
|
|
||||||
new WorkflowLockedComponentAccess(editBasicSheet, itemModel),
|
|
||||||
editBasicSheet.getSaveCancelSection().getCancelButton()
|
|
||||||
);
|
|
||||||
|
|
||||||
basicProperties.setDisplayComponent(
|
|
||||||
getPublicationWithPublisherPropertySheet(
|
|
||||||
itemModel, selectedLangParam
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
getSegmentedPanel().addSegment(
|
|
||||||
new Label(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.publication.basic_properties"
|
|
||||||
)
|
|
||||||
),
|
|
||||||
basicProperties
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void addSteps(
|
|
||||||
final ItemSelectionModel itemModel, final AuthoringKitWizard parent
|
|
||||||
) {
|
|
||||||
super.addSteps(itemModel, parent);
|
|
||||||
|
|
||||||
addStep(
|
|
||||||
new PublicationWithPublisherSetPublisherStep(
|
|
||||||
itemModel, parent, selectedLangParam
|
|
||||||
),
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.with_publisher.publisher",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,334 +0,0 @@
|
||||||
/*
|
|
||||||
* 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 com.arsdigita.cms.contenttypes.ui;
|
|
||||||
|
|
||||||
import com.arsdigita.bebop.FormData;
|
|
||||||
import com.arsdigita.bebop.FormProcessException;
|
|
||||||
import com.arsdigita.bebop.PageState;
|
|
||||||
import com.arsdigita.bebop.event.FormInitListener;
|
|
||||||
import com.arsdigita.bebop.event.FormProcessListener;
|
|
||||||
import com.arsdigita.bebop.event.FormSectionEvent;
|
|
||||||
import com.arsdigita.bebop.event.FormSubmissionListener;
|
|
||||||
import com.arsdigita.bebop.event.ParameterEvent;
|
|
||||||
import com.arsdigita.bebop.event.ParameterListener;
|
|
||||||
import com.arsdigita.bebop.form.TextField;
|
|
||||||
import com.arsdigita.bebop.parameters.IntegerParameter;
|
|
||||||
import com.arsdigita.bebop.parameters.ParameterData;
|
|
||||||
import com.arsdigita.bebop.parameters.ParameterModel;
|
|
||||||
import com.arsdigita.bebop.parameters.StringParameter;
|
|
||||||
import com.arsdigita.cms.ItemSelectionModel;
|
|
||||||
import com.arsdigita.cms.ui.authoring.SelectedLanguageUtil;
|
|
||||||
import com.arsdigita.globalization.GlobalizedMessage;
|
|
||||||
|
|
||||||
import org.apache.logging.log4j.LogManager;
|
|
||||||
import org.apache.logging.log4j.Logger;
|
|
||||||
import org.libreccm.cdi.utils.CdiUtil;
|
|
||||||
import org.scientificcms.publications.PublicationWithPublisher;
|
|
||||||
import org.scientificcms.publications.SciPublicationsConstants;
|
|
||||||
import org.scientificcms.publications.contenttypes.PublicationWithPublisherItem;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Locale;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
|
||||||
*/
|
|
||||||
public class PublicationWithPublisherPropertyForm
|
|
||||||
extends PublicationPropertyForm
|
|
||||||
implements FormProcessListener,
|
|
||||||
FormInitListener,
|
|
||||||
FormSubmissionListener {
|
|
||||||
|
|
||||||
private static final Logger LOGGER = LogManager.getLogger(
|
|
||||||
PublicationWithPublisherPropertyForm.class
|
|
||||||
);
|
|
||||||
|
|
||||||
public static final String ID = "PublicationWithPublisherEdit";
|
|
||||||
|
|
||||||
private static final String PUBLISHER_SEARCH = "publisher";
|
|
||||||
|
|
||||||
private final PublicationWithPublisherPropertiesStep step;
|
|
||||||
|
|
||||||
private final ItemSelectionModel itemModel;
|
|
||||||
|
|
||||||
private final StringParameter selectedLangParam;
|
|
||||||
|
|
||||||
private PublisherSearchWidget publisherSearch;
|
|
||||||
|
|
||||||
public PublicationWithPublisherPropertyForm(
|
|
||||||
final ItemSelectionModel itemModel,
|
|
||||||
final StringParameter selectedLangParam
|
|
||||||
) {
|
|
||||||
this(itemModel, null, selectedLangParam);
|
|
||||||
}
|
|
||||||
|
|
||||||
public PublicationWithPublisherPropertyForm(
|
|
||||||
ItemSelectionModel itemModel,
|
|
||||||
PublicationWithPublisherPropertiesStep step,
|
|
||||||
final StringParameter selectedLangParam
|
|
||||||
) {
|
|
||||||
super(itemModel, step, selectedLangParam);
|
|
||||||
this.step = step;
|
|
||||||
this.itemModel = itemModel;
|
|
||||||
this.selectedLangParam = selectedLangParam;
|
|
||||||
addSubmissionListener(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void addWidgets() {
|
|
||||||
|
|
||||||
super.addWidgets();
|
|
||||||
|
|
||||||
final ParameterModel isbn10Param = new StringParameter(
|
|
||||||
SciPublicationsWithPublisherController.ISBN10
|
|
||||||
);
|
|
||||||
final TextField isbn10 = new TextField(isbn10Param);
|
|
||||||
isbn10.setMaxLength(17);
|
|
||||||
isbn10.addValidationListener(new ParameterListener() {
|
|
||||||
|
|
||||||
public void validate(final ParameterEvent event)
|
|
||||||
throws FormProcessException {
|
|
||||||
ParameterData data = event.getParameterData();
|
|
||||||
String value = (String) data.getValue();
|
|
||||||
|
|
||||||
if (value.isEmpty()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
value = value.replace("-", "");
|
|
||||||
|
|
||||||
if (value.length() != 10) {
|
|
||||||
data.invalidate();
|
|
||||||
data.addError(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.invalid_isbn10",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
Long num = Long.parseLong(value);
|
|
||||||
} catch (NumberFormatException ex) {
|
|
||||||
data.invalidate();
|
|
||||||
data.addError(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.invalid_isbn10",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
||||||
isbn10.setLabel(new GlobalizedMessage(
|
|
||||||
"publications.ui.with_publisher.isbn10"));
|
|
||||||
add(isbn10);
|
|
||||||
|
|
||||||
final ParameterModel isbn13Param = new StringParameter(
|
|
||||||
SciPublicationsWithPublisherController.ISBN13
|
|
||||||
);
|
|
||||||
final TextField isbn13 = new TextField(isbn13Param);
|
|
||||||
isbn13.setMaxLength(17);
|
|
||||||
isbn13.addValidationListener(new ParameterListener() {
|
|
||||||
|
|
||||||
public void validate(final ParameterEvent event)
|
|
||||||
throws FormProcessException {
|
|
||||||
ParameterData data = event.getParameterData();
|
|
||||||
String value = (String) data.getValue();
|
|
||||||
|
|
||||||
if (value.isEmpty()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
value = value.replace("-", "");
|
|
||||||
|
|
||||||
if (value.length() != 13) {
|
|
||||||
data.invalidate();
|
|
||||||
data.addError(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.invalid_isbn13",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
Long num = Long.parseLong(value);
|
|
||||||
} catch (NumberFormatException ex) {
|
|
||||||
data.invalidate();
|
|
||||||
data.addError(new GlobalizedMessage(
|
|
||||||
"publications.ui.invalid_isbn13",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
||||||
isbn13.setLabel(new GlobalizedMessage(
|
|
||||||
"publications.ui.with_publisher.isbn13"));
|
|
||||||
add(isbn13);
|
|
||||||
|
|
||||||
final ParameterModel volumeParam = new IntegerParameter(
|
|
||||||
SciPublicationsWithPublisherController.VOLUME
|
|
||||||
);
|
|
||||||
final TextField volume = new TextField(volumeParam);
|
|
||||||
volume.setLabel(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.collected_volume.volume",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
)
|
|
||||||
);
|
|
||||||
add(volume);
|
|
||||||
|
|
||||||
final ParameterModel numberOfVolumesParam = new IntegerParameter(
|
|
||||||
SciPublicationsWithPublisherController.NUMBER_OF_VOLUMES
|
|
||||||
);
|
|
||||||
TextField numberOfVolumes = new TextField(numberOfVolumesParam);
|
|
||||||
numberOfVolumes.setLabel(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.collected_volume.number_of_volumes",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
)
|
|
||||||
);
|
|
||||||
add(numberOfVolumes);
|
|
||||||
|
|
||||||
final ParameterModel numberOfPagesParam = new IntegerParameter(
|
|
||||||
SciPublicationsWithPublisherController.NUMBER_OF_PAGES
|
|
||||||
);
|
|
||||||
final TextField numberOfPages = new TextField(numberOfPagesParam);
|
|
||||||
numberOfPages.setLabel(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.collected_volume.number_of_pages",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
)
|
|
||||||
);
|
|
||||||
add(numberOfPages);
|
|
||||||
|
|
||||||
ParameterModel editionModel = new StringParameter(
|
|
||||||
SciPublicationsWithPublisherController.EDITION
|
|
||||||
);
|
|
||||||
|
|
||||||
final TextField edition = new TextField(editionModel);
|
|
||||||
edition.setLabel(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.collected_volume.edition",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
)
|
|
||||||
);
|
|
||||||
add(edition);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void init(final FormSectionEvent event) throws FormProcessException {
|
|
||||||
|
|
||||||
final FormData data = event.getFormData();
|
|
||||||
super.init(event);
|
|
||||||
|
|
||||||
final PublicationWithPublisherItem<?> publicationItem
|
|
||||||
= (PublicationWithPublisherItem) super
|
|
||||||
.initBasicWidgets(event);
|
|
||||||
|
|
||||||
final PublicationWithPublisher publication = publicationItem
|
|
||||||
.getPublication();
|
|
||||||
|
|
||||||
data.put(
|
|
||||||
SciPublicationsWithPublisherController.ISBN10,
|
|
||||||
publication.getIsbn10()
|
|
||||||
);
|
|
||||||
data.put(
|
|
||||||
SciPublicationsWithPublisherController.ISBN13,
|
|
||||||
publication.getIsbn10()
|
|
||||||
);
|
|
||||||
data.put(
|
|
||||||
SciPublicationsWithPublisherController.VOLUME,
|
|
||||||
publication.getVolume()
|
|
||||||
);
|
|
||||||
data.put(
|
|
||||||
SciPublicationsWithPublisherController.NUMBER_OF_VOLUMES,
|
|
||||||
publication.getNumberOfVolumes()
|
|
||||||
);
|
|
||||||
data.put(
|
|
||||||
SciPublicationsWithPublisherController.NUMBER_OF_PAGES,
|
|
||||||
publication.getNumberOfPages()
|
|
||||||
);
|
|
||||||
data.put(
|
|
||||||
SciPublicationsWithPublisherController.EDITION,
|
|
||||||
publication.getEdition()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void process(final FormSectionEvent event)
|
|
||||||
throws FormProcessException {
|
|
||||||
|
|
||||||
final FormData formData = event.getFormData();
|
|
||||||
final PageState state = event.getPageState();
|
|
||||||
super.process(event);
|
|
||||||
|
|
||||||
final PublicationWithPublisherItem<?> item
|
|
||||||
= (PublicationWithPublisherItem) super
|
|
||||||
.processBasicWidgets(event);
|
|
||||||
|
|
||||||
if ((item != null)
|
|
||||||
&& getSaveCancelSection().getSaveButton().isSelected(state)) {
|
|
||||||
final PublicationWithPublisher publication = item
|
|
||||||
.getPublication();
|
|
||||||
|
|
||||||
final Map<String, Object> data = new HashMap<>();
|
|
||||||
|
|
||||||
data.put(
|
|
||||||
SciPublicationsWithPublisherController.ISBN10,
|
|
||||||
formData.get(SciPublicationsWithPublisherController.ISBN10)
|
|
||||||
);
|
|
||||||
|
|
||||||
data.put(
|
|
||||||
SciPublicationsWithPublisherController.ISBN13,
|
|
||||||
formData.get(SciPublicationsWithPublisherController.ISBN13)
|
|
||||||
);
|
|
||||||
|
|
||||||
data.put(
|
|
||||||
SciPublicationsWithPublisherController.VOLUME,
|
|
||||||
formData.get(SciPublicationsWithPublisherController.VOLUME)
|
|
||||||
);
|
|
||||||
|
|
||||||
data.put(
|
|
||||||
SciPublicationsWithPublisherController.NUMBER_OF_PAGES,
|
|
||||||
formData.get(
|
|
||||||
SciPublicationsWithPublisherController.NUMBER_OF_PAGES
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
data.put(
|
|
||||||
SciPublicationsWithPublisherController.NUMBER_OF_VOLUMES,
|
|
||||||
formData.get(
|
|
||||||
SciPublicationsWithPublisherController.NUMBER_OF_VOLUMES
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
data.put(
|
|
||||||
SciPublicationsWithPublisherController.EDITION,
|
|
||||||
formData.get(SciPublicationsWithPublisherController.EDITION)
|
|
||||||
);
|
|
||||||
|
|
||||||
final Locale selectedLocale = SelectedLanguageUtil.selectedLocale(
|
|
||||||
state, selectedLangParam
|
|
||||||
);
|
|
||||||
|
|
||||||
final SciPublicationsWithPublisherController controller = CdiUtil
|
|
||||||
.createCdiUtil()
|
|
||||||
.findBean(SciPublicationsWithPublisherController.class);
|
|
||||||
controller.savePublication(
|
|
||||||
publication.getPublicationId(), selectedLocale, data
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,93 +0,0 @@
|
||||||
/*
|
|
||||||
* 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 com.arsdigita.cms.contenttypes.ui;
|
|
||||||
|
|
||||||
import com.arsdigita.bebop.FormData;
|
|
||||||
import com.arsdigita.bebop.FormProcessException;
|
|
||||||
import com.arsdigita.bebop.PageState;
|
|
||||||
import com.arsdigita.bebop.event.FormInitListener;
|
|
||||||
import com.arsdigita.bebop.event.FormProcessListener;
|
|
||||||
import com.arsdigita.bebop.event.FormSectionEvent;
|
|
||||||
import com.arsdigita.bebop.parameters.StringParameter;
|
|
||||||
import com.arsdigita.cms.ItemSelectionModel;
|
|
||||||
import com.arsdigita.cms.ui.authoring.BasicItemForm;
|
|
||||||
import com.arsdigita.globalization.GlobalizedMessage;
|
|
||||||
|
|
||||||
import org.libreccm.cdi.utils.CdiUtil;
|
|
||||||
import org.scientificcms.publications.SciPublicationsConstants;
|
|
||||||
import org.scientificcms.publications.contenttypes.PublicationWithPublisherItem;
|
|
||||||
import org.scientificcms.publications.Publisher;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
|
||||||
*/
|
|
||||||
public class PublicationWithPublisherSetPublisherForm
|
|
||||||
extends BasicItemForm
|
|
||||||
implements FormInitListener, FormProcessListener {
|
|
||||||
|
|
||||||
private PublisherSearchWidget publisherSearch;
|
|
||||||
private final String PUBLISHER_SEARCH = "setPublisher";
|
|
||||||
|
|
||||||
public PublicationWithPublisherSetPublisherForm(
|
|
||||||
final ItemSelectionModel itemModel,
|
|
||||||
final StringParameter selectedLangParam
|
|
||||||
) {
|
|
||||||
super(
|
|
||||||
"PublicationWithPublisherSetPublisher",
|
|
||||||
itemModel,
|
|
||||||
selectedLangParam
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void addWidgets() {
|
|
||||||
|
|
||||||
publisherSearch = new PublisherSearchWidget(PUBLISHER_SEARCH);
|
|
||||||
publisherSearch.setLabel(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.with_publisher.publisher",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
)
|
|
||||||
);
|
|
||||||
add(publisherSearch);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void init(final FormSectionEvent fse) throws FormProcessException {
|
|
||||||
final PageState state = fse.getPageState();
|
|
||||||
|
|
||||||
setVisible(state, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void process(final FormSectionEvent fse)
|
|
||||||
throws FormProcessException {
|
|
||||||
final FormData data = fse.getFormData();
|
|
||||||
final PageState state = fse.getPageState();
|
|
||||||
final PublicationWithPublisherItem<?> publicationItem =
|
|
||||||
(PublicationWithPublisherItem) getItemSelectionModel().
|
|
||||||
getSelectedObject(state);
|
|
||||||
|
|
||||||
if (this.getSaveCancelSection().getSaveButton().isSelected(state)) {
|
|
||||||
final Publisher publisher = (Publisher) data.get(PUBLISHER_SEARCH);
|
|
||||||
|
|
||||||
final SciPublicationsWithPublisherController controller = CdiUtil
|
|
||||||
.createCdiUtil()
|
|
||||||
.findBean(SciPublicationsWithPublisherController.class);
|
|
||||||
controller.setPublisher(
|
|
||||||
publicationItem.getPublication().getPublicationId(),
|
|
||||||
publisher.getPublisherId()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
init(fse);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,277 +0,0 @@
|
||||||
/*
|
|
||||||
* 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 com.arsdigita.cms.contenttypes.ui;
|
|
||||||
|
|
||||||
import com.arsdigita.bebop.Component;
|
|
||||||
import com.arsdigita.bebop.ControlLink;
|
|
||||||
import com.arsdigita.bebop.Label;
|
|
||||||
import com.arsdigita.bebop.PageState;
|
|
||||||
import com.arsdigita.bebop.Table;
|
|
||||||
import com.arsdigita.bebop.Text;
|
|
||||||
import com.arsdigita.bebop.event.TableActionEvent;
|
|
||||||
import com.arsdigita.bebop.event.TableActionListener;
|
|
||||||
import com.arsdigita.bebop.parameters.StringParameter;
|
|
||||||
import com.arsdigita.bebop.table.TableCellRenderer;
|
|
||||||
import com.arsdigita.bebop.table.TableColumn;
|
|
||||||
import com.arsdigita.bebop.table.TableColumnModel;
|
|
||||||
import com.arsdigita.bebop.table.TableModel;
|
|
||||||
import com.arsdigita.bebop.table.TableModelBuilder;
|
|
||||||
import com.arsdigita.cms.ItemSelectionModel;
|
|
||||||
import com.arsdigita.globalization.GlobalizedMessage;
|
|
||||||
import com.arsdigita.util.LockableImpl;
|
|
||||||
|
|
||||||
import org.libreccm.cdi.utils.CdiUtil;
|
|
||||||
import org.libreccm.security.PermissionChecker;
|
|
||||||
import org.librecms.contentsection.privileges.ItemPrivileges;
|
|
||||||
import org.scientificcms.publications.contenttypes.PublicationWithPublisherItem;
|
|
||||||
import org.scientificcms.publications.SciPublicationsConstants;
|
|
||||||
import org.scientificcms.publications.Publisher;
|
|
||||||
import org.scientificcms.publications.PublicationWithPublisher;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
|
||||||
*/
|
|
||||||
public class PublicationWithPublisherSetPublisherSheet
|
|
||||||
extends Table
|
|
||||||
implements TableActionListener {
|
|
||||||
|
|
||||||
private final String TABLE_COL_EDIT = "table_col_edit";
|
|
||||||
private final String TABLE_COL_DEL = "table_col_del";
|
|
||||||
private final ItemSelectionModel itemModel;
|
|
||||||
|
|
||||||
public PublicationWithPublisherSetPublisherSheet(
|
|
||||||
final ItemSelectionModel itemModel,
|
|
||||||
final StringParameter selectedLangParam
|
|
||||||
) {
|
|
||||||
|
|
||||||
this.itemModel = itemModel;
|
|
||||||
|
|
||||||
setEmptyView(
|
|
||||||
new Label(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.with_publisher.publisher.none",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
final TableColumnModel columnModel = getColumnModel();
|
|
||||||
columnModel.add(
|
|
||||||
new TableColumn(
|
|
||||||
0,
|
|
||||||
new Label(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.with_publisher.publisher",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
)
|
|
||||||
),
|
|
||||||
TABLE_COL_EDIT
|
|
||||||
)
|
|
||||||
);
|
|
||||||
columnModel.add(
|
|
||||||
new TableColumn(
|
|
||||||
1,
|
|
||||||
new Label(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.with_publisher.publisher.remove",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
)
|
|
||||||
),
|
|
||||||
TABLE_COL_DEL
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
setModelBuilder(
|
|
||||||
new PublicationWithPublisherSetPublisherSheetModelBuilder(
|
|
||||||
itemModel
|
|
||||||
)
|
|
||||||
);
|
|
||||||
columnModel.get(0).setCellRenderer(new EditCellRenderer());
|
|
||||||
columnModel.get(1).setCellRenderer((new DeleteCellRenderer()));
|
|
||||||
|
|
||||||
addTableActionListener(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void cellSelected(final TableActionEvent event) {
|
|
||||||
PageState state = event.getPageState();
|
|
||||||
|
|
||||||
final PublicationWithPublisherItem<?> publicationItem
|
|
||||||
= (PublicationWithPublisherItem) itemModel
|
|
||||||
.getSelectedObject(state);
|
|
||||||
|
|
||||||
final TableColumn column = getColumnModel()
|
|
||||||
.get(event.getColumn()
|
|
||||||
.intValue());
|
|
||||||
|
|
||||||
if (column.getHeaderKey().toString().equals(TABLE_COL_EDIT)) {
|
|
||||||
// Nothing
|
|
||||||
} else if (column.getHeaderKey().toString().equals(TABLE_COL_DEL)) {
|
|
||||||
final SciPublicationsWithPublisherController controller = CdiUtil
|
|
||||||
.createCdiUtil()
|
|
||||||
.findBean(SciPublicationsWithPublisherController.class);
|
|
||||||
controller.unsetPublisher(
|
|
||||||
publicationItem.getPublication().getPublicationId(),
|
|
||||||
publicationItem.getPublication().getPublisher().getPublisherId()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void headSelected(final TableActionEvent event) {
|
|
||||||
//Nothing to do
|
|
||||||
}
|
|
||||||
|
|
||||||
private class PublicationWithPublisherSetPublisherSheetModelBuilder
|
|
||||||
extends LockableImpl
|
|
||||||
implements TableModelBuilder {
|
|
||||||
|
|
||||||
private ItemSelectionModel itemModel;
|
|
||||||
|
|
||||||
public PublicationWithPublisherSetPublisherSheetModelBuilder(
|
|
||||||
final ItemSelectionModel itemModel) {
|
|
||||||
this.itemModel = itemModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public TableModel makeModel(final Table table, final PageState state) {
|
|
||||||
table.getRowSelectionModel().clearSelection(state);
|
|
||||||
final PublicationWithPublisherItem<?> publicationItem
|
|
||||||
= (PublicationWithPublisherItem) itemModel
|
|
||||||
.getSelectedObject(state);
|
|
||||||
return new PublicationWithPublisherSetPublisherSheetModel(
|
|
||||||
table, state, publicationItem.getPublication()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private class PublicationWithPublisherSetPublisherSheetModel
|
|
||||||
implements TableModel {
|
|
||||||
|
|
||||||
private final Table table;
|
|
||||||
private final Publisher publisher;
|
|
||||||
private boolean m_done;
|
|
||||||
|
|
||||||
public PublicationWithPublisherSetPublisherSheetModel(
|
|
||||||
final Table table,
|
|
||||||
final PageState state,
|
|
||||||
final PublicationWithPublisher publication
|
|
||||||
) {
|
|
||||||
this.table = table;
|
|
||||||
publisher = publication.getPublisher();
|
|
||||||
if (publisher == null) {
|
|
||||||
m_done = false;
|
|
||||||
} else {
|
|
||||||
m_done = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getColumnCount() {
|
|
||||||
return table.getColumnModel().size();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean nextRow() {
|
|
||||||
boolean ret;
|
|
||||||
|
|
||||||
if (m_done) {
|
|
||||||
ret = true;
|
|
||||||
m_done = false;
|
|
||||||
} else {
|
|
||||||
ret = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object getElementAt(final int columnIndex) {
|
|
||||||
switch (columnIndex) {
|
|
||||||
case 0:
|
|
||||||
return publisher.getName();
|
|
||||||
case 1:
|
|
||||||
return new Label(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.with_publisher.publisher.remove",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
)
|
|
||||||
);
|
|
||||||
default:
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object getKeyAt(final int columnIndex) {
|
|
||||||
return publisher.getPublisherId();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private class EditCellRenderer
|
|
||||||
extends LockableImpl
|
|
||||||
implements TableCellRenderer {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Component getComponent(
|
|
||||||
final Table table,
|
|
||||||
final PageState state,
|
|
||||||
final Object value,
|
|
||||||
final boolean isSelected,
|
|
||||||
final Object key,
|
|
||||||
final int row,
|
|
||||||
final int column
|
|
||||||
) {
|
|
||||||
return new Text((String) value);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private class DeleteCellRenderer
|
|
||||||
extends LockableImpl
|
|
||||||
implements TableCellRenderer {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Component getComponent(
|
|
||||||
final Table table,
|
|
||||||
final PageState state,
|
|
||||||
final Object value,
|
|
||||||
final boolean isSelected,
|
|
||||||
final Object key,
|
|
||||||
final int row,
|
|
||||||
final int col
|
|
||||||
) {
|
|
||||||
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
|
|
||||||
final PermissionChecker permissionChecker = cdiUtil
|
|
||||||
.findBean(PermissionChecker.class);
|
|
||||||
final PublicationWithPublisherItem<?> publicationItem
|
|
||||||
= (PublicationWithPublisherItem) itemModel
|
|
||||||
.getSelectedItem(state);
|
|
||||||
final boolean canEdit = permissionChecker.isPermitted(
|
|
||||||
ItemPrivileges.EDIT, publicationItem
|
|
||||||
);
|
|
||||||
|
|
||||||
if (canEdit) {
|
|
||||||
final ControlLink link = new ControlLink((Label) value);
|
|
||||||
link.setConfirmation(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.with_publisher.publisher.remove.confirm",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
)
|
|
||||||
);
|
|
||||||
return link;
|
|
||||||
} else {
|
|
||||||
return new Text("");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,59 +0,0 @@
|
||||||
/*
|
|
||||||
* 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 com.arsdigita.cms.contenttypes.ui;
|
|
||||||
|
|
||||||
import com.arsdigita.bebop.parameters.StringParameter;
|
|
||||||
import com.arsdigita.cms.ItemSelectionModel;
|
|
||||||
import com.arsdigita.cms.ui.authoring.AuthoringKitWizard;
|
|
||||||
import com.arsdigita.cms.ui.authoring.BasicItemForm;
|
|
||||||
import com.arsdigita.cms.ui.authoring.SimpleEditStep;
|
|
||||||
import com.arsdigita.cms.ui.workflow.WorkflowLockedComponentAccess;
|
|
||||||
import com.arsdigita.globalization.GlobalizedMessage;
|
|
||||||
import org.scientificcms.publications.SciPublicationsConstants;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
|
||||||
*/
|
|
||||||
public class PublicationWithPublisherSetPublisherStep extends SimpleEditStep {
|
|
||||||
|
|
||||||
private String SET_PUBLICATION_PUBLISHER_STEP
|
|
||||||
= "setPublicationPublisherStep";
|
|
||||||
|
|
||||||
public PublicationWithPublisherSetPublisherStep(
|
|
||||||
final ItemSelectionModel itemModel,
|
|
||||||
final AuthoringKitWizard parent,
|
|
||||||
final StringParameter selectedLangParam
|
|
||||||
) {
|
|
||||||
this(itemModel, parent, selectedLangParam, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public PublicationWithPublisherSetPublisherStep(
|
|
||||||
final ItemSelectionModel itemModel,
|
|
||||||
final AuthoringKitWizard parent,
|
|
||||||
final StringParameter selectedLangParameter,
|
|
||||||
final String prefix) {
|
|
||||||
super(itemModel, parent, selectedLangParameter, prefix);
|
|
||||||
|
|
||||||
final BasicItemForm setPublisherForm
|
|
||||||
= new PublicationWithPublisherSetPublisherForm(
|
|
||||||
itemModel, selectedLangParameter);
|
|
||||||
add(SET_PUBLICATION_PUBLISHER_STEP,
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.with_publisher.setPublisher",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
),
|
|
||||||
new WorkflowLockedComponentAccess(setPublisherForm, itemModel),
|
|
||||||
setPublisherForm.getSaveCancelSection().getCancelButton());
|
|
||||||
|
|
||||||
final PublicationWithPublisherSetPublisherSheet sheet
|
|
||||||
= new PublicationWithPublisherSetPublisherSheet(
|
|
||||||
itemModel, selectedLangParameter
|
|
||||||
);
|
|
||||||
setDisplayComponent(sheet);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,79 +0,0 @@
|
||||||
/*
|
|
||||||
* 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 com.arsdigita.cms.contenttypes.ui;
|
|
||||||
|
|
||||||
import com.arsdigita.bebop.PageState;
|
|
||||||
import com.arsdigita.bebop.form.Widget;
|
|
||||||
import com.arsdigita.bebop.parameters.LongParameter;
|
|
||||||
import com.arsdigita.cms.CMS;
|
|
||||||
import com.arsdigita.xml.Element;
|
|
||||||
|
|
||||||
import org.libreccm.cdi.utils.CdiUtil;
|
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
|
||||||
*/
|
|
||||||
public class PublisherSearchWidget extends Widget {
|
|
||||||
|
|
||||||
public PublisherSearchWidget(final String name) {
|
|
||||||
super(new LongParameter(name));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isCompound() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected String getType() {
|
|
||||||
return "publisher-search-widget";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getElementTag() {
|
|
||||||
return "cms:publisher-search-widget";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void generateWidget(
|
|
||||||
final PageState state, final Element parent
|
|
||||||
) {
|
|
||||||
final Element widget = parent.newChildElement(getElementTag(),
|
|
||||||
CMS.CMS_XML_NS);
|
|
||||||
|
|
||||||
widget.addAttribute("name", getName());
|
|
||||||
|
|
||||||
final Long value = (Long) getValue(state);
|
|
||||||
if (value != null) {
|
|
||||||
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
|
|
||||||
final PublisherSearchWidgetController controller = cdiUtil
|
|
||||||
.findBean(PublisherSearchWidgetController.class);
|
|
||||||
|
|
||||||
final Map<String, String> data = controller.getData(value);
|
|
||||||
|
|
||||||
final Element selected = widget
|
|
||||||
.newChildElement("cms:selected-publisher", CMS.CMS_XML_NS);
|
|
||||||
selected.addAttribute(
|
|
||||||
"publisherId",
|
|
||||||
data.get(PublisherSearchWidgetController.PUBLISHER_ID)
|
|
||||||
);
|
|
||||||
selected.addAttribute(
|
|
||||||
"name",
|
|
||||||
data.get(PublisherSearchWidgetController.NAME)
|
|
||||||
);
|
|
||||||
selected.addAttribute(
|
|
||||||
"place",
|
|
||||||
data.get(PublisherSearchWidgetController.PLACE)
|
|
||||||
);
|
|
||||||
|
|
||||||
exportAttributes(widget);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,51 +0,0 @@
|
||||||
/*
|
|
||||||
* 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 com.arsdigita.cms.contenttypes.ui;
|
|
||||||
|
|
||||||
import org.scientificcms.publications.Publisher;
|
|
||||||
import org.scientificcms.publications.PublisherRepository;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import javax.enterprise.context.RequestScoped;
|
|
||||||
import javax.inject.Inject;
|
|
||||||
import javax.transaction.Transactional;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
|
||||||
*/
|
|
||||||
@RequestScoped
|
|
||||||
public class PublisherSearchWidgetController {
|
|
||||||
|
|
||||||
protected static final String PUBLISHER_ID = "publisherId";
|
|
||||||
protected static final String NAME = "name";
|
|
||||||
protected static final String PLACE = "place";
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
private PublisherRepository publisherRepository;
|
|
||||||
|
|
||||||
@Transactional(Transactional.TxType.REQUIRED)
|
|
||||||
public Map<String, String> getData(final long publisherId) {
|
|
||||||
|
|
||||||
final Publisher publisher = publisherRepository
|
|
||||||
.findById(publisherId)
|
|
||||||
.orElseThrow(
|
|
||||||
() -> new IllegalArgumentException(
|
|
||||||
String.format("No Publisher with ID %d found.", publisherId)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
final Map<String, String> data = new HashMap<>();
|
|
||||||
|
|
||||||
data.put(PUBLISHER_ID, Long.toString(publisher.getPublisherId()));
|
|
||||||
data.put(NAME, publisher.getName());
|
|
||||||
data.put(PLACE, publisher.getPlace());
|
|
||||||
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,90 +0,0 @@
|
||||||
/*
|
|
||||||
* 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 com.arsdigita.cms.contenttypes.ui;
|
|
||||||
|
|
||||||
import com.arsdigita.bebop.Component;
|
|
||||||
import com.arsdigita.bebop.Label;
|
|
||||||
import com.arsdigita.bebop.parameters.StringParameter;
|
|
||||||
import com.arsdigita.cms.ItemSelectionModel;
|
|
||||||
import com.arsdigita.cms.ui.authoring.AuthoringKitWizard;
|
|
||||||
import com.arsdigita.cms.ui.authoring.BasicPageForm;
|
|
||||||
import com.arsdigita.cms.ui.authoring.SimpleEditStep;
|
|
||||||
import com.arsdigita.cms.ui.workflow.WorkflowLockedComponentAccess;
|
|
||||||
import com.arsdigita.globalization.GlobalizedMessage;
|
|
||||||
import com.arsdigita.toolbox.ui.DomainObjectPropertySheet;
|
|
||||||
|
|
||||||
import org.scientificcms.publications.SciPublicationsConstants;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
|
||||||
*/
|
|
||||||
public class ReviewPropertiesStep extends ArticleInJournalPropertiesStep {
|
|
||||||
|
|
||||||
private final StringParameter selectedLangParam;
|
|
||||||
|
|
||||||
public ReviewPropertiesStep(
|
|
||||||
final ItemSelectionModel itemModel,
|
|
||||||
final AuthoringKitWizard parent,
|
|
||||||
final StringParameter selectedLangParam
|
|
||||||
) {
|
|
||||||
super(itemModel, parent, selectedLangParam);
|
|
||||||
this.selectedLangParam = selectedLangParam;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Component getReviewPropertySheet(
|
|
||||||
final ItemSelectionModel itemModel,
|
|
||||||
final StringParameter selectedLangParam
|
|
||||||
) {
|
|
||||||
final DomainObjectPropertySheet sheet
|
|
||||||
= (DomainObjectPropertySheet) ArticleInJournalPropertiesStep
|
|
||||||
.getArticleInJournalPropertySheet(itemModel, selectedLangParam);
|
|
||||||
|
|
||||||
return sheet;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void addBasicProperties(
|
|
||||||
final ItemSelectionModel itemModel,
|
|
||||||
final AuthoringKitWizard parent
|
|
||||||
) {
|
|
||||||
final SimpleEditStep basicProperties = new SimpleEditStep(
|
|
||||||
itemModel,
|
|
||||||
parent,
|
|
||||||
selectedLangParam,
|
|
||||||
EDIT_SHEET_NAME
|
|
||||||
);
|
|
||||||
|
|
||||||
BasicPageForm editBasicSheet = new ReviewPropertyForm(
|
|
||||||
itemModel, this, selectedLangParam
|
|
||||||
);
|
|
||||||
|
|
||||||
basicProperties.add(
|
|
||||||
EDIT_SHEET_NAME,
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.review.edit_basic_sheet",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
),
|
|
||||||
new WorkflowLockedComponentAccess(editBasicSheet, itemModel),
|
|
||||||
editBasicSheet.getSaveCancelSection().getCancelButton());
|
|
||||||
|
|
||||||
basicProperties.setDisplayComponent(
|
|
||||||
getReviewPropertySheet(itemModel, selectedLangParam)
|
|
||||||
);
|
|
||||||
|
|
||||||
getSegmentedPanel().addSegment(
|
|
||||||
new Label(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.publication.basic_properties",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
)
|
|
||||||
),
|
|
||||||
basicProperties
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,70 +0,0 @@
|
||||||
/*
|
|
||||||
* 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 com.arsdigita.cms.contenttypes.ui;
|
|
||||||
|
|
||||||
import com.arsdigita.bebop.FormProcessException;
|
|
||||||
import com.arsdigita.bebop.PageState;
|
|
||||||
import com.arsdigita.bebop.event.FormInitListener;
|
|
||||||
import com.arsdigita.bebop.event.FormProcessListener;
|
|
||||||
import com.arsdigita.bebop.event.FormSectionEvent;
|
|
||||||
import com.arsdigita.bebop.event.FormSubmissionListener;
|
|
||||||
import com.arsdigita.bebop.parameters.StringParameter;
|
|
||||||
import com.arsdigita.cms.ItemSelectionModel;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
|
||||||
*/
|
|
||||||
public class ReviewPropertyForm extends ArticleInJournalPropertyForm
|
|
||||||
implements FormProcessListener, FormInitListener, FormSubmissionListener {
|
|
||||||
|
|
||||||
public static final String ID = "ReviewEdit";
|
|
||||||
|
|
||||||
private ReviewPropertiesStep step;
|
|
||||||
|
|
||||||
public ReviewPropertyForm(
|
|
||||||
final ItemSelectionModel itemModel,
|
|
||||||
final StringParameter selectedLangParam
|
|
||||||
) {
|
|
||||||
this(itemModel, null, selectedLangParam);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ReviewPropertyForm(
|
|
||||||
final ItemSelectionModel itemModel,
|
|
||||||
final ReviewPropertiesStep step,
|
|
||||||
final StringParameter selectedLangParam
|
|
||||||
) {
|
|
||||||
super(itemModel, step, selectedLangParam);
|
|
||||||
this.step = step;
|
|
||||||
addSubmissionListener(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void addWidgets() {
|
|
||||||
super.addWidgets();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void init(final FormSectionEvent event) throws FormProcessException {
|
|
||||||
super.init(event);
|
|
||||||
|
|
||||||
final PageState state = event.getPageState();
|
|
||||||
getReviewed().setVisible(state, false);
|
|
||||||
|
|
||||||
// FormData data = fse.getFormData();
|
|
||||||
// Review review = (Review) initBasicWidgets(fse);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void process(final FormSectionEvent event)
|
|
||||||
throws FormProcessException {
|
|
||||||
super.process(event);
|
|
||||||
|
|
||||||
// FormData data = fse.getFormData();
|
|
||||||
// Review review = (Review) processBasicWidgets(fse);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,471 +0,0 @@
|
||||||
/*
|
|
||||||
* 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 com.arsdigita.cms.contenttypes.ui;
|
|
||||||
|
|
||||||
import org.librecms.assets.Person;
|
|
||||||
import org.librecms.assets.PersonRepository;
|
|
||||||
import org.scientificcms.publications.Authorship;
|
|
||||||
import org.scientificcms.publications.Publication;
|
|
||||||
import org.scientificcms.publications.PublicationManager;
|
|
||||||
import org.scientificcms.publications.PublicationRepository;
|
|
||||||
import org.scientificcms.publications.VolumeInSeries;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Locale;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Objects;
|
|
||||||
import java.util.Optional;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
import javax.enterprise.context.RequestScoped;
|
|
||||||
import javax.inject.Inject;
|
|
||||||
import javax.transaction.Transactional;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
|
||||||
*/
|
|
||||||
@RequestScoped
|
|
||||||
class SciPublicationsController implements Serializable {
|
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
public static final String NAME = "name";
|
|
||||||
|
|
||||||
public static final String TITLE = "title";
|
|
||||||
|
|
||||||
public static final String YEAR_OF_PUBLICATION = "yearOfPublication";
|
|
||||||
|
|
||||||
public static final String SHORT_DESCRIPTION = "shortDescription";
|
|
||||||
|
|
||||||
public static final String ABSTRACT = "abstract";
|
|
||||||
|
|
||||||
public static final String MISC = "misc";
|
|
||||||
|
|
||||||
public static final String YEAR_FIRST_PUBLISHED = "yearFirstPublished";
|
|
||||||
|
|
||||||
public static final String LANGUAGE_OF_PUBLICATION = "languageOfPublication";
|
|
||||||
|
|
||||||
public static final String LAUNCH_DATE = "launchDate";
|
|
||||||
|
|
||||||
public static final String AUTHORSHIP_ID = "authorshipId";
|
|
||||||
|
|
||||||
public static final String AUTHOR_NAME = "authorName";
|
|
||||||
|
|
||||||
public static final String AUTHORSHIP_IS_EDITOR = "isEditor";
|
|
||||||
|
|
||||||
public static final String AUTHORSHIP_ORDER = "order";
|
|
||||||
|
|
||||||
public static final String VOLUME_IN_SERIES = "volumeInSeries";
|
|
||||||
|
|
||||||
public static final String VOLUME_IN_SERIES_ID = "volumeInSeriesId";
|
|
||||||
|
|
||||||
public static final String VOLUME_IN_SERIES_TITLE = "volumeInSeriesTitle";
|
|
||||||
|
|
||||||
public static final String VOLUME_IN_SERIES_VOLUME = "volumeInSeriesVolume";
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
private PersonRepository personRepository;
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
private PublicationManager publicationManager;
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
private PublicationRepository publicationRepository;
|
|
||||||
|
|
||||||
@Transactional(Transactional.TxType.REQUIRED)
|
|
||||||
public void savePublication(final long publicationId,
|
|
||||||
final Locale selectedLocale,
|
|
||||||
final Map<String, Object> data) {
|
|
||||||
|
|
||||||
final Publication publication = publicationRepository
|
|
||||||
.findById(publicationId)
|
|
||||||
.orElseThrow(
|
|
||||||
() -> new IllegalArgumentException(
|
|
||||||
String.format(
|
|
||||||
"No Publication with ID %d found.", publicationId
|
|
||||||
)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
final Integer yearOfPublication = (Integer) data.get(
|
|
||||||
YEAR_OF_PUBLICATION
|
|
||||||
);
|
|
||||||
final Integer yearFirstPublished = (Integer) data.get(
|
|
||||||
YEAR_FIRST_PUBLISHED
|
|
||||||
);
|
|
||||||
final Locale languageOfPublication = (Locale) data.get(
|
|
||||||
LANGUAGE_OF_PUBLICATION
|
|
||||||
);
|
|
||||||
final String publicationAbstract = (String) data.get(ABSTRACT);
|
|
||||||
final String shortDescription = (String) data.get(SHORT_DESCRIPTION);
|
|
||||||
final String misc = (String) data.get(MISC);
|
|
||||||
|
|
||||||
publication.setYearOfPublication(yearOfPublication);
|
|
||||||
publication.setYearFirstPublished(yearFirstPublished);
|
|
||||||
publication.setLanguageOfPublication(languageOfPublication);
|
|
||||||
publication.getShortDescription().addValue(selectedLocale,
|
|
||||||
shortDescription);
|
|
||||||
publication.getPublicationAbstract().addValue(selectedLocale,
|
|
||||||
publicationAbstract);
|
|
||||||
publication.getMisc().addValue(selectedLocale, misc);
|
|
||||||
|
|
||||||
publicationRepository.save(publication);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Transactional(Transactional.TxType.REQUIRED)
|
|
||||||
public List<Map<String, Object>> getAuthors(final long publicationId) {
|
|
||||||
|
|
||||||
final Publication publication = publicationRepository
|
|
||||||
.findById(publicationId)
|
|
||||||
.orElseThrow(
|
|
||||||
() -> new IllegalArgumentException(
|
|
||||||
String.format(
|
|
||||||
"No Publication with ID %d found.", publicationId
|
|
||||||
)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
return publication
|
|
||||||
.getAuthorships()
|
|
||||||
.stream()
|
|
||||||
.map(this::buildAuthorshipEntry)
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
}
|
|
||||||
|
|
||||||
private Map<String, Object> buildAuthorshipEntry(
|
|
||||||
final Authorship authorship
|
|
||||||
) {
|
|
||||||
Objects.requireNonNull(authorship);
|
|
||||||
|
|
||||||
final Map<String, Object> result = new HashMap<>();
|
|
||||||
result.put(AUTHORSHIP_ID, authorship.getAuthorshipId());
|
|
||||||
result.put(
|
|
||||||
AUTHOR_NAME,
|
|
||||||
String.format(
|
|
||||||
"%s, %s",
|
|
||||||
authorship.getAuthor().getPersonName().getSurname(),
|
|
||||||
authorship.getAuthor().getPersonName().getGivenName()
|
|
||||||
)
|
|
||||||
);
|
|
||||||
result.put(AUTHORSHIP_IS_EDITOR, authorship.isEditor());
|
|
||||||
result.put(AUTHORSHIP_ORDER, authorship.getAuthorOrder());
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Transactional(Transactional.TxType.REQUIRED)
|
|
||||||
public Optional<Authorship> findAuthorship(
|
|
||||||
final long publicationId, final Object key
|
|
||||||
) {
|
|
||||||
final Publication publication = publicationRepository
|
|
||||||
.findById(publicationId)
|
|
||||||
.orElseThrow(
|
|
||||||
() -> new IllegalArgumentException(
|
|
||||||
String.format(
|
|
||||||
"No Publication with ID %d found.", publicationId
|
|
||||||
)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
final long authorshipId = (long) key;
|
|
||||||
|
|
||||||
return publication
|
|
||||||
.getAuthorships()
|
|
||||||
.stream()
|
|
||||||
.filter(authorship -> authorship.getAuthorshipId() == authorshipId)
|
|
||||||
.findAny();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Transactional(Transactional.TxType.REQUIRED)
|
|
||||||
public void addAuthor(
|
|
||||||
final long publicationId, final long authorId, final boolean isEditor
|
|
||||||
) {
|
|
||||||
|
|
||||||
final Publication publication = publicationRepository
|
|
||||||
.findById(publicationId)
|
|
||||||
.orElseThrow(
|
|
||||||
() -> new IllegalArgumentException(
|
|
||||||
String.format(
|
|
||||||
"No Publication with ID %d found.", publicationId
|
|
||||||
)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
final Person author = personRepository
|
|
||||||
.findById(authorId)
|
|
||||||
.orElseThrow(
|
|
||||||
() -> new IllegalArgumentException(
|
|
||||||
String.format("No Person with ID %d found.",
|
|
||||||
authorId)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
publicationManager.addAuthor(author, publication, isEditor);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Transactional(Transactional.TxType.REQUIRED)
|
|
||||||
public void updateAuthorship(
|
|
||||||
final long publicationId, final long authorId, final boolean isEditor
|
|
||||||
) {
|
|
||||||
final Publication publication = publicationRepository
|
|
||||||
.findById(publicationId)
|
|
||||||
.orElseThrow(
|
|
||||||
() -> new IllegalArgumentException(
|
|
||||||
String.format(
|
|
||||||
"No Publication with ID %d found.", publicationId
|
|
||||||
)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
final Person author = personRepository
|
|
||||||
.findById(authorId)
|
|
||||||
.orElseThrow(
|
|
||||||
() -> new IllegalArgumentException(
|
|
||||||
String.format("No Person with ID %d found.",
|
|
||||||
authorId)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
final Optional<Authorship> authorship = publication
|
|
||||||
.getAuthorships()
|
|
||||||
.stream()
|
|
||||||
.filter(current -> filterAuthorship(current, publication, author))
|
|
||||||
.findAny();
|
|
||||||
|
|
||||||
if (authorship.isPresent()) {
|
|
||||||
|
|
||||||
authorship.get().setEditor(isEditor);
|
|
||||||
publicationRepository.save(publication);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Transactional(Transactional.TxType.REQUIRED)
|
|
||||||
public void removeAuthor(
|
|
||||||
final long publicationId, final long authorshipId
|
|
||||||
) {
|
|
||||||
final Publication publication = publicationRepository
|
|
||||||
.findById(publicationId)
|
|
||||||
.orElseThrow(
|
|
||||||
() -> new IllegalArgumentException(
|
|
||||||
String.format(
|
|
||||||
"No Publication with ID %d found.", publicationId
|
|
||||||
)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
final Optional<Authorship> authorship = findAuthorship(publicationId,
|
|
||||||
authorshipId);
|
|
||||||
|
|
||||||
if (authorship.isPresent()) {
|
|
||||||
publicationManager.removeAuthor(
|
|
||||||
authorship.get().getAuthor(),
|
|
||||||
publication
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Transactional(Transactional.TxType.REQUIRED)
|
|
||||||
public boolean hasAuthor(final long publicationId, final long authorId) {
|
|
||||||
|
|
||||||
final Publication publication = publicationRepository
|
|
||||||
.findById(publicationId)
|
|
||||||
.orElseThrow(
|
|
||||||
() -> new IllegalArgumentException(
|
|
||||||
String.format(
|
|
||||||
"No Publication with ID %d found.", publicationId
|
|
||||||
)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
final Person author = personRepository
|
|
||||||
.findById(authorId)
|
|
||||||
.orElseThrow(
|
|
||||||
() -> new IllegalArgumentException(
|
|
||||||
String.format("No Person with ID %d found.",
|
|
||||||
authorId)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
return publication
|
|
||||||
.getAuthorships()
|
|
||||||
.stream()
|
|
||||||
.anyMatch(
|
|
||||||
current -> filterAuthorship(current, publication, author)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Transactional(Transactional.TxType.REQUIRED)
|
|
||||||
public void swapWithPrevAuthorship(
|
|
||||||
final long publicationId, final long authorshipId
|
|
||||||
) {
|
|
||||||
final Publication publication = publicationRepository
|
|
||||||
.findById(publicationId)
|
|
||||||
.orElseThrow(
|
|
||||||
() -> new IllegalArgumentException(
|
|
||||||
String.format(
|
|
||||||
"No Publication with ID %d found.", publicationId
|
|
||||||
)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
final List<Authorship> authorships = publication.getAuthorships();
|
|
||||||
Authorship authorship = null;
|
|
||||||
int index = -1;
|
|
||||||
for (int i = 0; i < authorships.size(); i++) {
|
|
||||||
|
|
||||||
if (authorships.get(i).getAuthorshipId() == authorshipId) {
|
|
||||||
authorship = authorships.get(i);
|
|
||||||
index = i;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (index > 0 && authorship != null) {
|
|
||||||
final long order = authorship.getAuthorOrder();
|
|
||||||
final Authorship prevAuthorship = authorships.get(index - 1);
|
|
||||||
final long prevOrder = prevAuthorship.getAuthorOrder();
|
|
||||||
|
|
||||||
authorship.setAuthorOrder(prevOrder);
|
|
||||||
prevAuthorship.setAuthorOrder(order);
|
|
||||||
|
|
||||||
publicationRepository.save(publication);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Transactional(Transactional.TxType.REQUIRED)
|
|
||||||
public void swapWithNextAuthorship(
|
|
||||||
final long publicationId, final long authorshipId
|
|
||||||
) {
|
|
||||||
final Publication publication = publicationRepository
|
|
||||||
.findById(publicationId)
|
|
||||||
.orElseThrow(
|
|
||||||
() -> new IllegalArgumentException(
|
|
||||||
String.format(
|
|
||||||
"No Publication with ID %d found.", publicationId
|
|
||||||
)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
final List<Authorship> authorships = publication.getAuthorships();
|
|
||||||
Authorship authorship = null;
|
|
||||||
int index = -1;
|
|
||||||
for (int i = 0; i < authorships.size(); i++) {
|
|
||||||
|
|
||||||
if (authorships.get(i).getAuthorshipId() == authorshipId) {
|
|
||||||
authorship = authorships.get(i);
|
|
||||||
index = i;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (index < authorships.size() && authorship != null) {
|
|
||||||
final long order = authorship.getAuthorOrder();
|
|
||||||
final Authorship nextAuthorship = authorships.get(index + 1);
|
|
||||||
final long nextOrder = nextAuthorship.getAuthorOrder();
|
|
||||||
|
|
||||||
authorship.setAuthorOrder(nextOrder);
|
|
||||||
nextAuthorship.setAuthorOrder(order);
|
|
||||||
|
|
||||||
publicationRepository.save(publication);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Transactional(Transactional.TxType.REQUIRED)
|
|
||||||
public List<Map<String, Object>> getVolumesInSeries(
|
|
||||||
final long publicationId
|
|
||||||
) {
|
|
||||||
final Publication publication = publicationRepository
|
|
||||||
.findById(publicationId)
|
|
||||||
.orElseThrow(
|
|
||||||
() -> new IllegalArgumentException(
|
|
||||||
String.format(
|
|
||||||
"No Publication with ID %d found.", publicationId
|
|
||||||
)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
return publication
|
|
||||||
.getSeries()
|
|
||||||
.stream()
|
|
||||||
.map(this::buildVolumeInSeriesEntry)
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
}
|
|
||||||
|
|
||||||
private Map<String, Object> buildVolumeInSeriesEntry(
|
|
||||||
final VolumeInSeries volumeInSeries
|
|
||||||
) {
|
|
||||||
Objects.requireNonNull(volumeInSeries);
|
|
||||||
|
|
||||||
final Map<String, Object> result = new HashMap<>();
|
|
||||||
result.put(VOLUME_IN_SERIES_ID, volumeInSeries.getVolumeId());
|
|
||||||
result.put(
|
|
||||||
VOLUME_IN_SERIES_TITLE, volumeInSeries.getSeries().getTitle()
|
|
||||||
);
|
|
||||||
result.put(VOLUME_IN_SERIES_VOLUME, volumeInSeries.getVolumeOfSeries());
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Transactional(Transactional.TxType.REQUIRED)
|
|
||||||
public Optional<VolumeInSeries> findVolumeInSeries(
|
|
||||||
final long publicationId, final Object key
|
|
||||||
) {
|
|
||||||
final Publication publication = publicationRepository
|
|
||||||
.findById(publicationId)
|
|
||||||
.orElseThrow(
|
|
||||||
() -> new IllegalArgumentException(
|
|
||||||
String.format(
|
|
||||||
"No Publication with ID %d found.", publicationId
|
|
||||||
)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
final long volumeId = (long) key;
|
|
||||||
|
|
||||||
return publication
|
|
||||||
.getSeries()
|
|
||||||
.stream()
|
|
||||||
.filter(series -> series.getVolumeId() == volumeId)
|
|
||||||
.findAny();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Transactional(Transactional.TxType.REQUIRED)
|
|
||||||
public void removeSeries(final long publicationId,
|
|
||||||
final long volumeInSeriesId) {
|
|
||||||
|
|
||||||
final Publication publication = publicationRepository
|
|
||||||
.findById(publicationId)
|
|
||||||
.orElseThrow(
|
|
||||||
() -> new IllegalArgumentException(
|
|
||||||
String.format(
|
|
||||||
"No Publication with ID %d found.", publicationId
|
|
||||||
)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
final Optional<VolumeInSeries> volumeInSeries = findVolumeInSeries(
|
|
||||||
publicationId, volumeInSeriesId);
|
|
||||||
|
|
||||||
if (volumeInSeries.isPresent()) {
|
|
||||||
publicationManager.removeSeries(
|
|
||||||
volumeInSeries.get().getSeries(),
|
|
||||||
publication
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean filterAuthorship(final Authorship authorship,
|
|
||||||
final Publication publication,
|
|
||||||
final Person author) {
|
|
||||||
|
|
||||||
return authorship.getPublication().equals(publication)
|
|
||||||
&& authorship.getAuthor().equals(author);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,141 +0,0 @@
|
||||||
/*
|
|
||||||
* 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 com.arsdigita.cms.contenttypes.ui;
|
|
||||||
|
|
||||||
import org.scientificcms.publications.PublicationWithPublisher;
|
|
||||||
import org.scientificcms.publications.PublicationWithPublisherRepository;
|
|
||||||
import org.scientificcms.publications.Publisher;
|
|
||||||
import org.scientificcms.publications.PublisherManager;
|
|
||||||
import org.scientificcms.publications.PublisherRepository;
|
|
||||||
|
|
||||||
import java.util.Locale;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import javax.enterprise.context.RequestScoped;
|
|
||||||
import javax.inject.Inject;
|
|
||||||
import javax.transaction.Transactional;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
|
||||||
*/
|
|
||||||
@RequestScoped
|
|
||||||
public class SciPublicationsWithPublisherController {
|
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
public static final String ISBN10 = "isbn10";
|
|
||||||
|
|
||||||
public static final String ISBN13 = "isbn13";
|
|
||||||
|
|
||||||
public static final String VOLUME = "volume";
|
|
||||||
|
|
||||||
public static final String NUMBER_OF_VOLUMES = "numberOfVolumes";
|
|
||||||
|
|
||||||
public static final String NUMBER_OF_PAGES = "numberOfPages";
|
|
||||||
|
|
||||||
public static final String EDITION = "edition";
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
private SciPublicationsController publicationsController;
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
private PublicationWithPublisherRepository publicationRepository;
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
private PublisherManager publisherManager;
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
private PublisherRepository publisherRepository;
|
|
||||||
|
|
||||||
@Transactional(Transactional.TxType.REQUIRED)
|
|
||||||
public void savePublication(final long publicationId,
|
|
||||||
final Locale selectedLocale,
|
|
||||||
final Map<String, Object> data) {
|
|
||||||
publicationsController.savePublication(publicationId, selectedLocale,
|
|
||||||
data);
|
|
||||||
|
|
||||||
final PublicationWithPublisher publication = publicationRepository
|
|
||||||
.findById(publicationId)
|
|
||||||
.orElseThrow(
|
|
||||||
() -> new IllegalArgumentException(
|
|
||||||
String.format(
|
|
||||||
"No PublicationWithPublisher with ID %d found.",
|
|
||||||
publicationId
|
|
||||||
)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
final String isbn10 = (String) data.get(ISBN10);
|
|
||||||
final String isbn13 = (String) data.get(ISBN13);
|
|
||||||
final Integer volume = (Integer) data.get(VOLUME);
|
|
||||||
final Integer numberOfVolumes = (Integer) data.get(NUMBER_OF_VOLUMES);
|
|
||||||
final Integer numberOfPages = (Integer) data.get(NUMBER_OF_PAGES);
|
|
||||||
final String edition = (String) data.get(EDITION);
|
|
||||||
|
|
||||||
publication.setIsbn10(isbn10);
|
|
||||||
publication.setIsbn13(isbn13);
|
|
||||||
publication.setVolume(volume);
|
|
||||||
publication.setNumberOfVolumes(numberOfVolumes);
|
|
||||||
publication.setNumberOfPages(numberOfPages);
|
|
||||||
publication.getEdition().addValue(selectedLocale, edition);
|
|
||||||
|
|
||||||
publicationRepository.save(publication);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPublisher(final long publicationId, final long publisherId) {
|
|
||||||
|
|
||||||
final PublicationWithPublisher publication = publicationRepository
|
|
||||||
.findById(publicationId)
|
|
||||||
.orElseThrow(
|
|
||||||
() -> new IllegalArgumentException(
|
|
||||||
String.format(
|
|
||||||
"No PublicationWithPublisher with ID %d found.",
|
|
||||||
publicationId
|
|
||||||
)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
final Publisher publisher = publisherRepository
|
|
||||||
.findById(publisherId)
|
|
||||||
.orElseThrow(
|
|
||||||
() -> new IllegalArgumentException(
|
|
||||||
String.format(
|
|
||||||
"No Publisher with ID %d found.", publisherId)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
publisherManager.addPublicationToPublisher(publication, publisher);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public void unsetPublisher(
|
|
||||||
final long publicationId, final long publisherId
|
|
||||||
) {
|
|
||||||
final PublicationWithPublisher publication = publicationRepository
|
|
||||||
.findById(publicationId)
|
|
||||||
.orElseThrow(
|
|
||||||
() -> new IllegalArgumentException(
|
|
||||||
String.format(
|
|
||||||
"No PublicationWithPublisher with ID %d found.",
|
|
||||||
publicationId
|
|
||||||
)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
final Publisher publisher = publisherRepository
|
|
||||||
.findById(publisherId)
|
|
||||||
.orElseThrow(
|
|
||||||
() -> new IllegalArgumentException(
|
|
||||||
String.format(
|
|
||||||
"No Publisher with ID %d found.", publisherId)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
publisherManager.removePublicationFromPublisher(publication, publisher);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,75 +0,0 @@
|
||||||
/*
|
|
||||||
* 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 com.arsdigita.cms.contenttypes.ui;
|
|
||||||
|
|
||||||
import com.arsdigita.bebop.PageState;
|
|
||||||
import com.arsdigita.bebop.form.Widget;
|
|
||||||
import com.arsdigita.bebop.parameters.LongParameter;
|
|
||||||
import com.arsdigita.cms.CMS;
|
|
||||||
import com.arsdigita.xml.Element;
|
|
||||||
|
|
||||||
import org.libreccm.cdi.utils.CdiUtil;
|
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
|
||||||
*/
|
|
||||||
public class SeriesSearchWidget extends Widget {
|
|
||||||
|
|
||||||
public SeriesSearchWidget(final String name) {
|
|
||||||
super(new LongParameter(name));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isCompound() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected String getType() {
|
|
||||||
return "series-search-widget";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getElementTag() {
|
|
||||||
return "cms:series-search-widget";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void generateWidget(
|
|
||||||
final PageState state, final Element parent
|
|
||||||
) {
|
|
||||||
final Element widget = parent.newChildElement(getElementTag(),
|
|
||||||
CMS.CMS_XML_NS);
|
|
||||||
|
|
||||||
widget.addAttribute("name", getName());
|
|
||||||
|
|
||||||
final Long value = (Long) getValue(state);
|
|
||||||
if (value != null) {
|
|
||||||
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
|
|
||||||
final SeriesSearchWidgetController controller = cdiUtil
|
|
||||||
.findBean(SeriesSearchWidgetController.class);
|
|
||||||
|
|
||||||
final Map<String, String> data = controller.getData(value);
|
|
||||||
|
|
||||||
final Element selected = widget
|
|
||||||
.newChildElement("cms:selected-series", CMS.CMS_XML_NS);
|
|
||||||
selected.addAttribute(
|
|
||||||
"series",
|
|
||||||
data.get(SeriesSearchWidgetController.SERIES_ID)
|
|
||||||
);
|
|
||||||
selected.addAttribute(
|
|
||||||
"title",
|
|
||||||
data.get(SeriesSearchWidgetController.TITLE)
|
|
||||||
);
|
|
||||||
|
|
||||||
exportAttributes(widget);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,58 +0,0 @@
|
||||||
/*
|
|
||||||
* 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 com.arsdigita.cms.contenttypes.ui;
|
|
||||||
|
|
||||||
import org.libreccm.l10n.GlobalizationHelper;
|
|
||||||
import org.scientificcms.publications.Series;
|
|
||||||
import org.scientificcms.publications.SeriesRepository;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import javax.enterprise.context.RequestScoped;
|
|
||||||
import javax.inject.Inject;
|
|
||||||
import javax.transaction.Transactional;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
|
||||||
*/
|
|
||||||
@RequestScoped
|
|
||||||
public class SeriesSearchWidgetController {
|
|
||||||
|
|
||||||
protected static final String SERIES_ID = "seriesId";
|
|
||||||
|
|
||||||
protected static final String TITLE = "title";
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
private SeriesRepository seriesRepository;
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
private GlobalizationHelper globalizationHelper;
|
|
||||||
|
|
||||||
@Transactional(Transactional.TxType.REQUIRED)
|
|
||||||
public Map<String, String> getData(final long seriesId) {
|
|
||||||
|
|
||||||
final Series series = seriesRepository
|
|
||||||
.findById(seriesId)
|
|
||||||
.orElseThrow(
|
|
||||||
() -> new IllegalArgumentException(
|
|
||||||
String.format("No Series with ID %d found.", seriesId)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
final Map<String, String> data = new HashMap<>();
|
|
||||||
|
|
||||||
data.put(SERIES_ID, Long.toString(series.getSeriesId()));
|
|
||||||
data.put(
|
|
||||||
TITLE,
|
|
||||||
globalizationHelper.getValueFromLocalizedString(series.getTitle())
|
|
||||||
);
|
|
||||||
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,59 +0,0 @@
|
||||||
/*
|
|
||||||
* 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 com.arsdigita.cms.contenttypes.ui;
|
|
||||||
|
|
||||||
import org.scientificcms.publications.PublicationRepository;
|
|
||||||
import org.scientificcms.publications.Talk;
|
|
||||||
|
|
||||||
import java.time.LocalDate;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import javax.enterprise.context.RequestScoped;
|
|
||||||
import javax.inject.Inject;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
|
||||||
*/
|
|
||||||
@RequestScoped
|
|
||||||
public class TalkController {
|
|
||||||
|
|
||||||
public static final String PLACE = "place";
|
|
||||||
|
|
||||||
public static final String DATE_OF_TALK = "dateOfTalk";
|
|
||||||
|
|
||||||
public static final String EVENT = "event";
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
private PublicationRepository publicationRepository;
|
|
||||||
|
|
||||||
public void saveTalk(final long talkId, final Map<String, Object> data) {
|
|
||||||
|
|
||||||
final Talk talk = publicationRepository
|
|
||||||
.findByIdAndType(talkId, Talk.class)
|
|
||||||
.orElseThrow(
|
|
||||||
() -> new IllegalArgumentException(
|
|
||||||
String.format(
|
|
||||||
"No Talk with ID %d found.", talkId
|
|
||||||
)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
if (data.containsKey(PLACE)) {
|
|
||||||
talk.setPlace((String) data.get(PLACE));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (data.containsKey(DATE_OF_TALK)) {
|
|
||||||
talk.setDateOfTalk((LocalDate) data.get(DATE_OF_TALK));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (data.containsKey(EVENT)) {
|
|
||||||
talk.setEvent((String) data.get(EVENT));
|
|
||||||
}
|
|
||||||
|
|
||||||
publicationRepository.save(talk);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,33 +0,0 @@
|
||||||
/*
|
|
||||||
* 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 com.arsdigita.cms.contenttypes.ui;
|
|
||||||
|
|
||||||
import com.arsdigita.bebop.parameters.StringParameter;
|
|
||||||
import com.arsdigita.cms.ItemSelectionModel;
|
|
||||||
import com.arsdigita.cms.ui.authoring.CreationSelector;
|
|
||||||
|
|
||||||
import org.scientificcms.publications.Talk;
|
|
||||||
import org.scientificcms.publications.contenttypes.TalkItem;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
|
||||||
*/
|
|
||||||
public class TalkCreateForm
|
|
||||||
extends AbstractPublicationCreateForm<Talk, TalkItem> {
|
|
||||||
|
|
||||||
public TalkCreateForm(final ItemSelectionModel itemModel,
|
|
||||||
final CreationSelector creationSelector,
|
|
||||||
final StringParameter selectedLanguageParam) {
|
|
||||||
super(itemModel, creationSelector, selectedLanguageParam);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected Talk createPublication() {
|
|
||||||
return new Talk();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,109 +0,0 @@
|
||||||
/*
|
|
||||||
* 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 com.arsdigita.cms.contenttypes.ui;
|
|
||||||
|
|
||||||
import com.arsdigita.bebop.Component;
|
|
||||||
import com.arsdigita.bebop.Label;
|
|
||||||
import com.arsdigita.bebop.parameters.StringParameter;
|
|
||||||
import com.arsdigita.cms.ItemSelectionModel;
|
|
||||||
import com.arsdigita.cms.ui.authoring.AuthoringKitWizard;
|
|
||||||
import com.arsdigita.cms.ui.authoring.BasicPageForm;
|
|
||||||
import com.arsdigita.cms.ui.authoring.SimpleEditStep;
|
|
||||||
import com.arsdigita.cms.ui.workflow.WorkflowLockedComponentAccess;
|
|
||||||
import com.arsdigita.globalization.GlobalizedMessage;
|
|
||||||
import com.arsdigita.toolbox.ui.DomainObjectPropertySheet;
|
|
||||||
|
|
||||||
import org.scientificcms.publications.SciPublicationsConstants;
|
|
||||||
import org.scientificcms.publications.Talk;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
|
||||||
*/
|
|
||||||
public class TalkPropertiesStep extends PublicationPropertiesStep {
|
|
||||||
|
|
||||||
private final StringParameter selectedLangParam;
|
|
||||||
|
|
||||||
public TalkPropertiesStep(
|
|
||||||
final ItemSelectionModel itemModel,
|
|
||||||
final AuthoringKitWizard parent,
|
|
||||||
final StringParameter selectedLangParam
|
|
||||||
) {
|
|
||||||
super(itemModel, parent, selectedLangParam);
|
|
||||||
this.selectedLangParam = selectedLangParam;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Component getTalkPropertiesSheet(
|
|
||||||
final ItemSelectionModel itemModel,
|
|
||||||
final StringParameter selectedLangParam
|
|
||||||
) {
|
|
||||||
|
|
||||||
final DomainObjectPropertySheet sheet
|
|
||||||
= (DomainObjectPropertySheet) getPublicationPropertySheet(
|
|
||||||
itemModel, selectedLangParam);
|
|
||||||
|
|
||||||
sheet.add(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.talk.place",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
),
|
|
||||||
TalkController.PLACE
|
|
||||||
);
|
|
||||||
sheet.add(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.talk.date",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
),
|
|
||||||
TalkController.DATE_OF_TALK
|
|
||||||
);
|
|
||||||
sheet.add(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.talk.event",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
),
|
|
||||||
TalkController.EVENT
|
|
||||||
);
|
|
||||||
|
|
||||||
return sheet;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void addBasicProperties(
|
|
||||||
final ItemSelectionModel itemModel,
|
|
||||||
final AuthoringKitWizard parent
|
|
||||||
) {
|
|
||||||
|
|
||||||
final SimpleEditStep basicProperties = new SimpleEditStep(
|
|
||||||
itemModel, parent, selectedLangParam, EDIT_SHEET_NAME);
|
|
||||||
|
|
||||||
final BasicPageForm editBasicSheet = new TalkPropertyForm(
|
|
||||||
itemModel, this, selectedLangParam
|
|
||||||
);
|
|
||||||
|
|
||||||
basicProperties.add(
|
|
||||||
EDIT_SHEET_NAME,
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.talk.edit_basic_sheet",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
),
|
|
||||||
new WorkflowLockedComponentAccess(editBasicSheet, itemModel),
|
|
||||||
editBasicSheet.getSaveCancelSection().getCancelButton());
|
|
||||||
|
|
||||||
basicProperties.setDisplayComponent(
|
|
||||||
getTalkPropertiesSheet(itemModel, selectedLangParam)
|
|
||||||
);
|
|
||||||
|
|
||||||
getSegmentedPanel().addSegment(
|
|
||||||
new Label(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.talk.basic_properties",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
)
|
|
||||||
),
|
|
||||||
basicProperties);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,168 +0,0 @@
|
||||||
/*
|
|
||||||
* 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 com.arsdigita.cms.contenttypes.ui;
|
|
||||||
|
|
||||||
import com.arsdigita.bebop.FormData;
|
|
||||||
import com.arsdigita.bebop.FormProcessException;
|
|
||||||
import com.arsdigita.bebop.PageState;
|
|
||||||
import com.arsdigita.bebop.event.FormInitListener;
|
|
||||||
import com.arsdigita.bebop.event.FormProcessListener;
|
|
||||||
import com.arsdigita.bebop.event.FormSectionEvent;
|
|
||||||
import com.arsdigita.bebop.event.FormSubmissionListener;
|
|
||||||
import com.arsdigita.bebop.form.Date;
|
|
||||||
import com.arsdigita.bebop.form.TextField;
|
|
||||||
import com.arsdigita.bebop.parameters.DateParameter;
|
|
||||||
import com.arsdigita.bebop.parameters.ParameterModel;
|
|
||||||
import com.arsdigita.bebop.parameters.StringParameter;
|
|
||||||
import com.arsdigita.cms.ItemSelectionModel;
|
|
||||||
import com.arsdigita.globalization.GlobalizedMessage;
|
|
||||||
|
|
||||||
import org.libreccm.cdi.utils.CdiUtil;
|
|
||||||
import org.scientificcms.publications.SciPublicationsConstants;
|
|
||||||
import org.scientificcms.publications.Talk;
|
|
||||||
import org.scientificcms.publications.contenttypes.TalkItem;
|
|
||||||
|
|
||||||
import java.time.LocalDate;
|
|
||||||
import java.time.ZoneId;
|
|
||||||
import java.util.Calendar;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
|
||||||
*/
|
|
||||||
public class TalkPropertyForm extends PublicationPropertyForm
|
|
||||||
implements FormInitListener, FormProcessListener, FormSubmissionListener {
|
|
||||||
|
|
||||||
private static final String ID = "TaskEdit";
|
|
||||||
|
|
||||||
public TalkPropertyForm(
|
|
||||||
final ItemSelectionModel itemModel,
|
|
||||||
final StringParameter selectedLangParameter
|
|
||||||
) {
|
|
||||||
this(itemModel, null, selectedLangParameter);
|
|
||||||
}
|
|
||||||
|
|
||||||
public TalkPropertyForm(
|
|
||||||
final ItemSelectionModel itemModel,
|
|
||||||
final TalkPropertiesStep step,
|
|
||||||
final StringParameter selectedLangParam
|
|
||||||
) {
|
|
||||||
super(itemModel, step, selectedLangParam);
|
|
||||||
addSubmissionListener(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void addWidgets() {
|
|
||||||
|
|
||||||
super.addWidgets();
|
|
||||||
|
|
||||||
final ParameterModel placeParameter = new StringParameter(
|
|
||||||
TalkController.PLACE
|
|
||||||
);
|
|
||||||
final TextField placeField = new TextField(placeParameter);
|
|
||||||
placeField
|
|
||||||
.setLabel(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.talk.place",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
)
|
|
||||||
);
|
|
||||||
add(placeField);
|
|
||||||
|
|
||||||
final ParameterModel dateParameter = new DateParameter(
|
|
||||||
TalkController.DATE_OF_TALK
|
|
||||||
);
|
|
||||||
final Date dateField = new Date(dateParameter);
|
|
||||||
final Calendar calendar = Calendar.getInstance();
|
|
||||||
final int currentYear = calendar.get(Calendar.YEAR);
|
|
||||||
dateField.setYearRange(currentYear - 10, currentYear + 1);
|
|
||||||
dateField
|
|
||||||
.setLabel(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.talk.date",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
)
|
|
||||||
);
|
|
||||||
add(dateField);
|
|
||||||
|
|
||||||
final ParameterModel eventParameter = new StringParameter(
|
|
||||||
TalkController.EVENT
|
|
||||||
);
|
|
||||||
final TextField eventField = new TextField(eventParameter);
|
|
||||||
eventField
|
|
||||||
.setLabel(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.talk.event",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
)
|
|
||||||
);
|
|
||||||
add(eventField);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void init(final FormSectionEvent event) throws FormProcessException {
|
|
||||||
|
|
||||||
super.init(event);
|
|
||||||
|
|
||||||
final FormData data = event.getFormData();
|
|
||||||
final TalkItem talkItem = (TalkItem) initBasicWidgets(event);
|
|
||||||
final Talk talk = talkItem.getPublication();
|
|
||||||
|
|
||||||
data.put(
|
|
||||||
TalkController.EVENT,
|
|
||||||
talk.getEvent()
|
|
||||||
);
|
|
||||||
final LocalDate localDateOfTalk = talk.getDateOfTalk();
|
|
||||||
final java.util.Date dateOfTalk = java.util.Date.from(
|
|
||||||
localDateOfTalk.atStartOfDay().atZone(
|
|
||||||
ZoneId.systemDefault()
|
|
||||||
).toInstant()
|
|
||||||
);
|
|
||||||
data.put(TalkController.DATE_OF_TALK, dateOfTalk);
|
|
||||||
data.put(TalkController.PLACE, talk.getPlace());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void process(final FormSectionEvent event)
|
|
||||||
throws FormProcessException {
|
|
||||||
|
|
||||||
super.process(event);
|
|
||||||
|
|
||||||
final FormData formData = event.getFormData();
|
|
||||||
final PageState state = event.getPageState();
|
|
||||||
final TalkItem talkItem = (TalkItem) processBasicWidgets(event);
|
|
||||||
|
|
||||||
if (talkItem != null
|
|
||||||
&& getSaveCancelSection().getSaveButton().isSelected(state)) {
|
|
||||||
|
|
||||||
final Map<String, Object> data = new HashMap<>();
|
|
||||||
|
|
||||||
final java.util.Date dateOfTalk = (java.util.Date) data.get(
|
|
||||||
TalkController.DATE_OF_TALK
|
|
||||||
);
|
|
||||||
final LocalDate localDateOfTalk = dateOfTalk
|
|
||||||
.toInstant().atZone(
|
|
||||||
ZoneId.systemDefault()
|
|
||||||
).toLocalDate();
|
|
||||||
data.put(TalkController.DATE_OF_TALK, localDateOfTalk);
|
|
||||||
|
|
||||||
data.put(TalkController.EVENT, data.get(TalkController.EVENT));
|
|
||||||
data.put(TalkController.PLACE, data.get(TalkController.PLACE));
|
|
||||||
|
|
||||||
final TalkController controller = CdiUtil
|
|
||||||
.createCdiUtil()
|
|
||||||
.findBean(TalkController.class);
|
|
||||||
|
|
||||||
controller.saveTalk(
|
|
||||||
talkItem.getPublication().getPublicationId(),
|
|
||||||
data
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,114 +0,0 @@
|
||||||
/*
|
|
||||||
* 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 com.arsdigita.cms.contenttypes.ui;
|
|
||||||
|
|
||||||
import org.librecms.assets.Organization;
|
|
||||||
import org.librecms.contentsection.AssetRepository;
|
|
||||||
import org.scientificcms.publications.PublicationRepository;
|
|
||||||
import org.scientificcms.publications.UnPublished;
|
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import javax.enterprise.context.RequestScoped;
|
|
||||||
import javax.inject.Inject;
|
|
||||||
import javax.transaction.Transactional;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
|
||||||
*/
|
|
||||||
@RequestScoped
|
|
||||||
public class UnPublishedController {
|
|
||||||
|
|
||||||
public static final String PLACE = "place";
|
|
||||||
|
|
||||||
public static final String NUMBER = "number";
|
|
||||||
|
|
||||||
public static final String NUMBER_OF_PAGES = "numberOfPages";
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
private AssetRepository assetRepository;
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
private PublicationRepository publicationRepository;
|
|
||||||
|
|
||||||
@Transactional(Transactional.TxType.REQUIRED)
|
|
||||||
public void saveUnPublished(
|
|
||||||
final long unpublishedId, final Map<String, Object> data
|
|
||||||
) {
|
|
||||||
final UnPublished unPublished = publicationRepository
|
|
||||||
.findByIdAndType(unpublishedId, UnPublished.class)
|
|
||||||
.orElseThrow(
|
|
||||||
() -> new IllegalArgumentException(
|
|
||||||
String.format(
|
|
||||||
"No UnPublished publication with ID %d found.",
|
|
||||||
unpublishedId
|
|
||||||
)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
if (data.containsKey(PLACE)) {
|
|
||||||
unPublished.setPlace((String) data.get(PLACE));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (data.containsKey(NUMBER)) {
|
|
||||||
unPublished.setNumber((String) data.get(NUMBER));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (data.containsKey(NUMBER_OF_PAGES)) {
|
|
||||||
unPublished.setNumberOfPages((Integer) data.get(NUMBER_OF_PAGES));
|
|
||||||
}
|
|
||||||
|
|
||||||
publicationRepository.save(unPublished);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Transactional(Transactional.TxType.REQUIRED)
|
|
||||||
public void setOrganzation(
|
|
||||||
final long unpublishedId, final long organizationId
|
|
||||||
) {
|
|
||||||
final UnPublished unPublished = publicationRepository
|
|
||||||
.findByIdAndType(unpublishedId, UnPublished.class)
|
|
||||||
.orElseThrow(
|
|
||||||
() -> new IllegalArgumentException(
|
|
||||||
String.format(
|
|
||||||
"No UnPublished publication with ID %d found.",
|
|
||||||
unpublishedId
|
|
||||||
)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
final Organization organization = assetRepository
|
|
||||||
.findById(organizationId, Organization.class)
|
|
||||||
.orElseThrow(
|
|
||||||
() -> new IllegalArgumentException(
|
|
||||||
String.format(
|
|
||||||
"No Organization with ID %d found.", organizationId
|
|
||||||
)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
unPublished.setOrganization(organization);
|
|
||||||
publicationRepository.save(unPublished);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Transactional(Transactional.TxType.REQUIRED)
|
|
||||||
public void unsetOrganization(final long unpublishedId) {
|
|
||||||
final UnPublished unPublished = publicationRepository
|
|
||||||
.findByIdAndType(unpublishedId, UnPublished.class)
|
|
||||||
.orElseThrow(
|
|
||||||
() -> new IllegalArgumentException(
|
|
||||||
String.format(
|
|
||||||
"No UnPublished publication with ID %d found.",
|
|
||||||
unpublishedId
|
|
||||||
)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
unPublished.setOrganization(null);
|
|
||||||
publicationRepository.save(unPublished);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,90 +0,0 @@
|
||||||
/*
|
|
||||||
* 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 com.arsdigita.cms.contenttypes.ui;
|
|
||||||
|
|
||||||
import com.arsdigita.bebop.FormData;
|
|
||||||
import com.arsdigita.bebop.FormProcessException;
|
|
||||||
import com.arsdigita.bebop.PageState;
|
|
||||||
import com.arsdigita.bebop.event.FormInitListener;
|
|
||||||
import com.arsdigita.bebop.event.FormProcessListener;
|
|
||||||
import com.arsdigita.bebop.event.FormSectionEvent;
|
|
||||||
import com.arsdigita.bebop.parameters.StringParameter;
|
|
||||||
import com.arsdigita.cms.ItemSelectionModel;
|
|
||||||
import com.arsdigita.cms.ui.assets.AssetSearchWidget;
|
|
||||||
import com.arsdigita.cms.ui.authoring.BasicItemForm;
|
|
||||||
import com.arsdigita.globalization.GlobalizedMessage;
|
|
||||||
|
|
||||||
import org.libreccm.cdi.utils.CdiUtil;
|
|
||||||
import org.librecms.assets.Organization;
|
|
||||||
import org.scientificcms.publications.SciPublicationsConstants;
|
|
||||||
import org.scientificcms.publications.contenttypes.PublicationItem;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
|
||||||
*/
|
|
||||||
public class UnPublishedOrganizationForm
|
|
||||||
extends BasicItemForm
|
|
||||||
implements FormProcessListener, FormInitListener {
|
|
||||||
|
|
||||||
private static final String ORGA_SEARCH = "unPublishedOrga";
|
|
||||||
|
|
||||||
private AssetSearchWidget orgaSearch;
|
|
||||||
|
|
||||||
public UnPublishedOrganizationForm(
|
|
||||||
final ItemSelectionModel itemModel,
|
|
||||||
final StringParameter selectedLangParam
|
|
||||||
) {
|
|
||||||
super("UnPublishedOrganizationForm", itemModel, selectedLangParam);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void addWidgets() {
|
|
||||||
|
|
||||||
orgaSearch = new AssetSearchWidget(ORGA_SEARCH, Organization.class);
|
|
||||||
orgaSearch.setLabel(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.unpublished.organization",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
)
|
|
||||||
);
|
|
||||||
add(orgaSearch);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void init(final FormSectionEvent event) throws FormProcessException {
|
|
||||||
final PageState state = event.getPageState();
|
|
||||||
|
|
||||||
setVisible(state, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void process(final FormSectionEvent event)
|
|
||||||
throws FormProcessException {
|
|
||||||
final FormData formData = event.getFormData();
|
|
||||||
final PageState state = event.getPageState();
|
|
||||||
final PublicationItem<?> publicationItem
|
|
||||||
= (PublicationItem) getItemSelectionModel()
|
|
||||||
.getSelectedItem(state);
|
|
||||||
|
|
||||||
if (getSaveCancelSection().getSaveButton().isSelected(state)) {
|
|
||||||
final Organization organization
|
|
||||||
= (Organization) formData
|
|
||||||
.get(ORGA_SEARCH);
|
|
||||||
final UnPublishedController controller = CdiUtil
|
|
||||||
.createCdiUtil()
|
|
||||||
.findBean(UnPublishedController.class);
|
|
||||||
controller.setOrganzation(
|
|
||||||
publicationItem.getPublication().getPublicationId(),
|
|
||||||
organization.getObjectId()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
init(event);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,266 +0,0 @@
|
||||||
/*
|
|
||||||
* 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 com.arsdigita.cms.contenttypes.ui;
|
|
||||||
|
|
||||||
import com.arsdigita.bebop.Component;
|
|
||||||
import com.arsdigita.bebop.ControlLink;
|
|
||||||
import com.arsdigita.bebop.Label;
|
|
||||||
import com.arsdigita.bebop.PageState;
|
|
||||||
import com.arsdigita.bebop.Table;
|
|
||||||
import com.arsdigita.bebop.Text;
|
|
||||||
import com.arsdigita.bebop.event.TableActionEvent;
|
|
||||||
import com.arsdigita.bebop.event.TableActionListener;
|
|
||||||
import com.arsdigita.bebop.table.TableCellRenderer;
|
|
||||||
import com.arsdigita.bebop.table.TableColumn;
|
|
||||||
import com.arsdigita.bebop.table.TableColumnModel;
|
|
||||||
import com.arsdigita.bebop.table.TableModel;
|
|
||||||
import com.arsdigita.bebop.table.TableModelBuilder;
|
|
||||||
import com.arsdigita.cms.ItemSelectionModel;
|
|
||||||
import com.arsdigita.cms.dispatcher.Utilities;
|
|
||||||
import com.arsdigita.globalization.GlobalizedMessage;
|
|
||||||
import com.arsdigita.util.LockableImpl;
|
|
||||||
|
|
||||||
import org.libreccm.cdi.utils.CdiUtil;
|
|
||||||
import org.libreccm.security.PermissionChecker;
|
|
||||||
import org.librecms.assets.Organization;
|
|
||||||
import org.librecms.contentsection.privileges.ItemPrivileges;
|
|
||||||
import org.scientificcms.publications.SciPublicationsConstants;
|
|
||||||
import org.scientificcms.publications.UnPublished;
|
|
||||||
import org.scientificcms.publications.contenttypes.PublicationItem;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
|
||||||
*/
|
|
||||||
public class UnPublishedOrganizationSheet
|
|
||||||
extends Table
|
|
||||||
implements TableActionListener {
|
|
||||||
|
|
||||||
private static final String TABLE_COL_EDIT = "table_col_edit";
|
|
||||||
|
|
||||||
private static final String TABLE_COL_DELETE = "table_col_delete";
|
|
||||||
|
|
||||||
private final ItemSelectionModel itemModel;
|
|
||||||
|
|
||||||
public UnPublishedOrganizationSheet(final ItemSelectionModel itemModel) {
|
|
||||||
super();
|
|
||||||
this.itemModel = itemModel;
|
|
||||||
|
|
||||||
setEmptyView(
|
|
||||||
new Label(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.unpublished.organization.none",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
final TableColumnModel columnModel = getColumnModel();
|
|
||||||
columnModel.add(
|
|
||||||
new TableColumn(
|
|
||||||
0,
|
|
||||||
new Label(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.unpublished.organization",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
)
|
|
||||||
),
|
|
||||||
TABLE_COL_EDIT
|
|
||||||
)
|
|
||||||
);
|
|
||||||
columnModel.add(
|
|
||||||
new TableColumn(
|
|
||||||
1,
|
|
||||||
new Label(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.unpublished.organization.remove",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
)
|
|
||||||
),
|
|
||||||
TABLE_COL_DELETE
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
setModelBuilder(
|
|
||||||
new UnPublishedOrganizationSheetModelBuilder(itemModel)
|
|
||||||
);
|
|
||||||
columnModel.get(0).setCellRenderer(new EditCellRenderer());
|
|
||||||
columnModel.get(1).setCellRenderer(new DeleteCellRenderer());
|
|
||||||
|
|
||||||
addTableActionListener(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void cellSelected(final TableActionEvent event) {
|
|
||||||
PageState state = event.getPageState();
|
|
||||||
|
|
||||||
final PublicationItem<?> publicationItem = (PublicationItem) itemModel
|
|
||||||
.getSelectedItem(state);
|
|
||||||
|
|
||||||
final TableColumn column = getColumnModel().get(event.getColumn());
|
|
||||||
if (column.getHeaderKey().toString().equals(TABLE_COL_EDIT)) {
|
|
||||||
// Nothing to do
|
|
||||||
} else if (column.getHeaderKey().toString().equals(TABLE_COL_DELETE)) {
|
|
||||||
final UnPublishedController controller = CdiUtil
|
|
||||||
.createCdiUtil()
|
|
||||||
.findBean(UnPublishedController.class);
|
|
||||||
controller.unsetOrganization(
|
|
||||||
publicationItem.getPublication().getPublicationId()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void headSelected(final TableActionEvent event) {
|
|
||||||
//Nothing to do
|
|
||||||
}
|
|
||||||
|
|
||||||
private class UnPublishedOrganizationSheetModelBuilder
|
|
||||||
extends LockableImpl
|
|
||||||
implements TableModelBuilder {
|
|
||||||
|
|
||||||
private final ItemSelectionModel itemModel;
|
|
||||||
|
|
||||||
public UnPublishedOrganizationSheetModelBuilder(
|
|
||||||
final ItemSelectionModel itemModel) {
|
|
||||||
this.itemModel = itemModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public TableModel makeModel(final Table table, final PageState state) {
|
|
||||||
table.getRowSelectionModel().clearSelection(state);
|
|
||||||
final PublicationItem<?> publicationItem
|
|
||||||
= (PublicationItem) itemModel
|
|
||||||
.getSelectedItem(state);
|
|
||||||
final UnPublished unPublished = (UnPublished) publicationItem
|
|
||||||
.getPublication();
|
|
||||||
return new UnPublishedOrganizationSheetModel(
|
|
||||||
table, state, unPublished
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private class UnPublishedOrganizationSheetModel implements TableModel {
|
|
||||||
|
|
||||||
private final Table table;
|
|
||||||
private final Organization orga;
|
|
||||||
private boolean done;
|
|
||||||
|
|
||||||
public UnPublishedOrganizationSheetModel(
|
|
||||||
final Table table,
|
|
||||||
final PageState state,
|
|
||||||
final UnPublished unPublished
|
|
||||||
) {
|
|
||||||
this.table = table;
|
|
||||||
orga = unPublished.getOrganization();
|
|
||||||
done = orga != null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getColumnCount() {
|
|
||||||
return table.getColumnModel().size();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean nextRow() {
|
|
||||||
boolean ret;
|
|
||||||
|
|
||||||
if (done) {
|
|
||||||
ret = true;
|
|
||||||
done = false;
|
|
||||||
} else {
|
|
||||||
ret = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object getElementAt(final int columnIndex) {
|
|
||||||
switch (columnIndex) {
|
|
||||||
case 0:
|
|
||||||
return orga.getTitle();
|
|
||||||
case 1:
|
|
||||||
return new Label(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.unpublished.organization.remove",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
)
|
|
||||||
);
|
|
||||||
default:
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object getKeyAt(final int columnIndex) {
|
|
||||||
return orga.getObjectId();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private class EditCellRenderer
|
|
||||||
extends LockableImpl
|
|
||||||
implements TableCellRenderer {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Component getComponent(
|
|
||||||
final Table table,
|
|
||||||
final PageState state,
|
|
||||||
final Object value,
|
|
||||||
final boolean isSelected,
|
|
||||||
final Object key,
|
|
||||||
final int row,
|
|
||||||
final int column
|
|
||||||
) {
|
|
||||||
return new Text((String) value);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private class DeleteCellRenderer
|
|
||||||
extends LockableImpl
|
|
||||||
implements TableCellRenderer {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Component getComponent(
|
|
||||||
final Table table,
|
|
||||||
final PageState state,
|
|
||||||
final Object value,
|
|
||||||
final boolean isSelected,
|
|
||||||
final Object key,
|
|
||||||
final int row,
|
|
||||||
final int column
|
|
||||||
) {
|
|
||||||
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
|
|
||||||
final PermissionChecker permissionChecker = cdiUtil
|
|
||||||
.findBean(PermissionChecker.class);
|
|
||||||
|
|
||||||
final PublicationItem<?> publicationItem
|
|
||||||
= (PublicationItem) itemModel
|
|
||||||
.getSelectedItem(state);
|
|
||||||
final boolean canEdit = permissionChecker.isPermitted(
|
|
||||||
ItemPrivileges.EDIT, publicationItem
|
|
||||||
);
|
|
||||||
|
|
||||||
if (canEdit) {
|
|
||||||
final ControlLink link = new ControlLink((Label) value);
|
|
||||||
link.setConfirmation(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.unpublished.organization.confirm_remove",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
)
|
|
||||||
);
|
|
||||||
return link;
|
|
||||||
} else {
|
|
||||||
return new Text("");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,62 +0,0 @@
|
||||||
/*
|
|
||||||
* 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 com.arsdigita.cms.contenttypes.ui;
|
|
||||||
|
|
||||||
import com.arsdigita.bebop.parameters.StringParameter;
|
|
||||||
import com.arsdigita.cms.ItemSelectionModel;
|
|
||||||
import com.arsdigita.cms.ui.authoring.AuthoringKitWizard;
|
|
||||||
import com.arsdigita.cms.ui.authoring.BasicItemForm;
|
|
||||||
import com.arsdigita.cms.ui.authoring.SimpleEditStep;
|
|
||||||
import com.arsdigita.cms.ui.workflow.WorkflowLockedComponentAccess;
|
|
||||||
import com.arsdigita.globalization.GlobalizedMessage;
|
|
||||||
|
|
||||||
import org.scientificcms.publications.SciPublicationsConstants;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
|
||||||
*/
|
|
||||||
public class UnPublishedOrganizationStep extends SimpleEditStep {
|
|
||||||
|
|
||||||
private static final String SET_UNPUBLISHED_ORGANIZATION_STEP
|
|
||||||
= "setUnPublishedOrganizationStep";
|
|
||||||
|
|
||||||
public UnPublishedOrganizationStep(
|
|
||||||
final ItemSelectionModel itemModel,
|
|
||||||
final AuthoringKitWizard parent,
|
|
||||||
final StringParameter selectedLangParam
|
|
||||||
) {
|
|
||||||
this(itemModel, parent, selectedLangParam, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public UnPublishedOrganizationStep(
|
|
||||||
final ItemSelectionModel itemModel,
|
|
||||||
final AuthoringKitWizard parent,
|
|
||||||
final StringParameter selectedLangParam,
|
|
||||||
final String prefix
|
|
||||||
) {
|
|
||||||
super(itemModel, parent, selectedLangParam, prefix);
|
|
||||||
|
|
||||||
final BasicItemForm setOrgaForm = new UnPublishedOrganizationForm(
|
|
||||||
itemModel, selectedLangParam
|
|
||||||
);
|
|
||||||
add(
|
|
||||||
SET_UNPUBLISHED_ORGANIZATION_STEP,
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.unpublished.setOrganization",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
),
|
|
||||||
new WorkflowLockedComponentAccess(setOrgaForm, itemModel),
|
|
||||||
setOrgaForm.getSaveCancelSection().getCancelButton());
|
|
||||||
|
|
||||||
final UnPublishedOrganizationSheet sheet
|
|
||||||
= new UnPublishedOrganizationSheet(
|
|
||||||
itemModel
|
|
||||||
);
|
|
||||||
setDisplayComponent(sheet);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,129 +0,0 @@
|
||||||
/*
|
|
||||||
* 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 com.arsdigita.cms.contenttypes.ui;
|
|
||||||
|
|
||||||
import com.arsdigita.bebop.Component;
|
|
||||||
import com.arsdigita.bebop.Label;
|
|
||||||
import com.arsdigita.bebop.parameters.StringParameter;
|
|
||||||
import com.arsdigita.cms.ItemSelectionModel;
|
|
||||||
import com.arsdigita.cms.ui.authoring.AuthoringKitWizard;
|
|
||||||
import com.arsdigita.cms.ui.authoring.BasicPageForm;
|
|
||||||
import com.arsdigita.cms.ui.authoring.SimpleEditStep;
|
|
||||||
import com.arsdigita.cms.ui.workflow.WorkflowLockedComponentAccess;
|
|
||||||
import com.arsdigita.globalization.GlobalizedMessage;
|
|
||||||
import com.arsdigita.toolbox.ui.DomainObjectPropertySheet;
|
|
||||||
|
|
||||||
import org.scientificcms.publications.SciPublicationsConstants;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
|
||||||
*/
|
|
||||||
public class UnPublishedPropertiesStep extends PublicationPropertiesStep {
|
|
||||||
|
|
||||||
private final StringParameter selectedLangParam;
|
|
||||||
|
|
||||||
public UnPublishedPropertiesStep(
|
|
||||||
final ItemSelectionModel itemModel,
|
|
||||||
final AuthoringKitWizard parent,
|
|
||||||
final StringParameter selectedLangParam
|
|
||||||
) {
|
|
||||||
super(itemModel, parent, selectedLangParam);
|
|
||||||
this.selectedLangParam = selectedLangParam;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Component getUnPublishedPropertySheet(
|
|
||||||
final ItemSelectionModel itemModel,
|
|
||||||
final StringParameter selectedLanParam
|
|
||||||
) {
|
|
||||||
final DomainObjectPropertySheet sheet
|
|
||||||
= (DomainObjectPropertySheet) PublicationPropertiesStep
|
|
||||||
.getPublicationPropertySheet(
|
|
||||||
itemModel, selectedLanParam
|
|
||||||
);
|
|
||||||
|
|
||||||
sheet.add(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.unpublished.place",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
),
|
|
||||||
UnPublishedController.PLACE
|
|
||||||
);
|
|
||||||
|
|
||||||
sheet.add(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.unpublished.number",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
),
|
|
||||||
UnPublishedController.NUMBER
|
|
||||||
);
|
|
||||||
|
|
||||||
sheet.add(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.unpublished.number_of_pages",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
),
|
|
||||||
UnPublishedController.NUMBER_OF_PAGES
|
|
||||||
);
|
|
||||||
|
|
||||||
return sheet;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void addBasicProperties(
|
|
||||||
final ItemSelectionModel itemModel,
|
|
||||||
final AuthoringKitWizard parent
|
|
||||||
) {
|
|
||||||
final SimpleEditStep basicProperties = new SimpleEditStep(
|
|
||||||
itemModel,
|
|
||||||
parent,
|
|
||||||
selectedLangParam,
|
|
||||||
EDIT_SHEET_NAME
|
|
||||||
);
|
|
||||||
|
|
||||||
final BasicPageForm editBasicSheet = new UnPublishedPropertyForm(
|
|
||||||
itemModel, this, selectedLangParam
|
|
||||||
);
|
|
||||||
|
|
||||||
basicProperties.add(
|
|
||||||
EDIT_SHEET_NAME,
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.unpublished.edit_basic_sheet",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
),
|
|
||||||
new WorkflowLockedComponentAccess(editBasicSheet, itemModel),
|
|
||||||
editBasicSheet.getSaveCancelSection().getCancelButton()
|
|
||||||
);
|
|
||||||
|
|
||||||
basicProperties.setDisplayComponent(
|
|
||||||
getUnPublishedPropertySheet(itemModel, selectedLangParam));
|
|
||||||
|
|
||||||
getSegmentedPanel().addSegment(
|
|
||||||
new Label(
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.publication.basic_properties",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
)
|
|
||||||
),
|
|
||||||
basicProperties);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void addSteps(
|
|
||||||
final ItemSelectionModel itemModel, final AuthoringKitWizard parent
|
|
||||||
) {
|
|
||||||
super.addSteps(itemModel, parent);
|
|
||||||
|
|
||||||
addStep(new UnPublishedOrganizationStep(
|
|
||||||
itemModel, parent, selectedLangParam),
|
|
||||||
new GlobalizedMessage(
|
|
||||||
"publications.ui.unpublished.organization",
|
|
||||||
SciPublicationsConstants.BUNDLE
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue