diff --git a/pom.xml b/pom.xml index cfadd49..1091aa6 100644 --- a/pom.xml +++ b/pom.xml @@ -118,15 +118,15 @@ org.apache.maven.plugins maven-assembly-plugin - 3.1.1 + 3.3.0 org.apache.maven.plugins maven-compiler-plugin - 3.8.0 + 3.8.1 - 1.8 - 1.8 + 11 + 11 true true ${project.build.sourceEncoding} @@ -135,31 +135,31 @@ org.apache.maven.plugins maven-ear-plugin - 3.0.1 + 3.0.2 org.apache.maven.plugins maven-enforcer-plugin - 3.0.0-M2 + 3.0.0-M3 org.apache.maven.plugins maven-jar-plugin - 3.1.1 + 3.2.0 org.apache.maven.plugins maven-javadoc-plugin - 3.1.0 + 3.2.0 org.apache.maven.plugins maven-pmd-plugin - 3.11.0 + 3.13.0 true utf-8 - 1.8 + 11 org.codehaus.mojo javancss-maven-plugin - 2.1 org.apache.maven.plugins maven-project-info-reports-plugin - 2.8 diff --git a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/AbstractPublicationCreateForm.java b/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/AbstractPublicationCreateForm.java deleted file mode 100644 index add170c..0000000 --- a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/AbstractPublicationCreateForm.java +++ /dev/null @@ -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 Jens Pelzetter - * @param

- * @param - */ -public abstract class AbstractPublicationCreateForm

> - 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(); - -} diff --git a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/ArticleInCollectedVolumeCollectedVolumeForm.java b/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/ArticleInCollectedVolumeCollectedVolumeForm.java deleted file mode 100644 index 199f207..0000000 --- a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/ArticleInCollectedVolumeCollectedVolumeForm.java +++ /dev/null @@ -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 Jens Pelzetter - */ -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); - } - -} diff --git a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/ArticleInCollectedVolumeCollectedVolumeSheet.java b/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/ArticleInCollectedVolumeCollectedVolumeSheet.java deleted file mode 100644 index cca05d4..0000000 --- a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/ArticleInCollectedVolumeCollectedVolumeSheet.java +++ /dev/null @@ -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 Jens Pelzetter - */ -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(""); - } - } - - } - -} diff --git a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/ArticleInCollectedVolumeCollectedVolumeStep.java b/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/ArticleInCollectedVolumeCollectedVolumeStep.java deleted file mode 100644 index 2e7531d..0000000 --- a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/ArticleInCollectedVolumeCollectedVolumeStep.java +++ /dev/null @@ -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 Jens Pelzetter - */ -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); - } - -} diff --git a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/ArticleInCollectedVolumeController.java b/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/ArticleInCollectedVolumeController.java deleted file mode 100644 index 7f7973b..0000000 --- a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/ArticleInCollectedVolumeController.java +++ /dev/null @@ -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 Jens Pelzetter - */ -@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 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); - } - -} diff --git a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/ArticleInCollectedVolumeCreateForm.java b/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/ArticleInCollectedVolumeCreateForm.java deleted file mode 100644 index 766feea..0000000 --- a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/ArticleInCollectedVolumeCreateForm.java +++ /dev/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.ArticleInCollectedVolume; -import org.scientificcms.publications.contenttypes.ArticleInCollectedVolumeItem; - -/** - * - * @author Jens Pelzetter - */ -public class ArticleInCollectedVolumeCreateForm - extends AbstractPublicationCreateForm { - - public ArticleInCollectedVolumeCreateForm( - final ItemSelectionModel itemModel, - final CreationSelector creationSelector, - final StringParameter selectedLanguageParam - ) { - super(itemModel, creationSelector, selectedLanguageParam); - } - - @Override - protected ArticleInCollectedVolume createPublication() { - return new ArticleInCollectedVolume(); - } - -} diff --git a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/ArticleInCollectedVolumePropertiesStep.java b/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/ArticleInCollectedVolumePropertiesStep.java deleted file mode 100644 index bf4c179..0000000 --- a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/ArticleInCollectedVolumePropertiesStep.java +++ /dev/null @@ -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 Jens Pelzetter - */ -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; - } - -} diff --git a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/ArticleInCollectedVolumePropertyForm.java b/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/ArticleInCollectedVolumePropertyForm.java deleted file mode 100644 index a80e57e..0000000 --- a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/ArticleInCollectedVolumePropertyForm.java +++ /dev/null @@ -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 Jens Pelzetter - */ -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 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 - ); - } - } - -} diff --git a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/ArticleInJournalController.java b/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/ArticleInJournalController.java deleted file mode 100644 index 268e189..0000000 --- a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/ArticleInJournalController.java +++ /dev/null @@ -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 Jens Pelzetter - */ -@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 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); - } - -} diff --git a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/ArticleInJournalCreateForm.java b/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/ArticleInJournalCreateForm.java deleted file mode 100644 index 0111a6d..0000000 --- a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/ArticleInJournalCreateForm.java +++ /dev/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.ArticleInJournal; -import org.scientificcms.publications.contenttypes.ArticleInJournalItem; - -/** - * - * @author Jens Pelzetter - */ -public class ArticleInJournalCreateForm - extends AbstractPublicationCreateForm { - - public ArticleInJournalCreateForm( - final ItemSelectionModel itemModel, - final CreationSelector creationSelector, - final StringParameter selectedLanguageParam - ) { - super(itemModel, creationSelector, selectedLanguageParam); - } - - @Override - protected ArticleInJournal createPublication() { - return new ArticleInJournal(); - } - -} diff --git a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/ArticleInJournalJournalForm.java b/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/ArticleInJournalJournalForm.java deleted file mode 100644 index 3df2902..0000000 --- a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/ArticleInJournalJournalForm.java +++ /dev/null @@ -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 Jens Pelzetter - */ -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); - } - -} diff --git a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/ArticleInJournalJournalSheet.java b/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/ArticleInJournalJournalSheet.java deleted file mode 100644 index 5f0bb5c..0000000 --- a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/ArticleInJournalJournalSheet.java +++ /dev/null @@ -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 Jens Pelzetter - */ -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(""); - } - } - - } - -} diff --git a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/ArticleInJournalJournalStep.java b/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/ArticleInJournalJournalStep.java deleted file mode 100644 index 2d6c555..0000000 --- a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/ArticleInJournalJournalStep.java +++ /dev/null @@ -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 Jens Pelzetter - */ -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); - } - -} diff --git a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/ArticleInJournalPropertiesStep.java b/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/ArticleInJournalPropertiesStep.java deleted file mode 100644 index 28b0a32..0000000 --- a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/ArticleInJournalPropertiesStep.java +++ /dev/null @@ -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 Jens Pelzetter - */ -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(); - } - } - -} diff --git a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/ArticleInJournalPropertyForm.java b/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/ArticleInJournalPropertyForm.java deleted file mode 100644 index 9991ef0..0000000 --- a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/ArticleInJournalPropertyForm.java +++ /dev/null @@ -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 Jens Pelzetter - */ -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 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 - ); - } - } - -} diff --git a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/CollectedVolumeArticlesAddForm.java b/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/CollectedVolumeArticlesAddForm.java deleted file mode 100644 index b492a17..0000000 --- a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/CollectedVolumeArticlesAddForm.java +++ /dev/null @@ -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 Jens Pelzetter - */ -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); - } - -} diff --git a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/CollectedVolumeArticlesStep.java b/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/CollectedVolumeArticlesStep.java deleted file mode 100644 index f374816..0000000 --- a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/CollectedVolumeArticlesStep.java +++ /dev/null @@ -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 Jens Pelzetter - */ -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); - } - -} diff --git a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/CollectedVolumeArticlesTable.java b/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/CollectedVolumeArticlesTable.java deleted file mode 100644 index 9881d3b..0000000 --- a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/CollectedVolumeArticlesTable.java +++ /dev/null @@ -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 Jens Pelzetter - */ -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 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(""); - } - } - - } - -} diff --git a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/CollectedVolumeController.java b/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/CollectedVolumeController.java deleted file mode 100644 index f883ce9..0000000 --- a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/CollectedVolumeController.java +++ /dev/null @@ -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 Jens Pelzetter - */ -@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 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 - ); - } - -} diff --git a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/CollectedVolumeCreateForm.java b/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/CollectedVolumeCreateForm.java deleted file mode 100644 index 1b0d10b..0000000 --- a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/CollectedVolumeCreateForm.java +++ /dev/null @@ -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 Jens Pelzetter - */ -public class CollectedVolumeCreateForm - extends AbstractPublicationCreateForm { - - public CollectedVolumeCreateForm( - final ItemSelectionModel itemModel, - final CreationSelector creationSelector, - final StringParameter selectedLanguageParam - ) { - super(itemModel, creationSelector, selectedLanguageParam); - } - - @Override - protected CollectedVolume createPublication() { - return new CollectedVolume(); - } - -} diff --git a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/CollectedVolumePropertiesStep.java b/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/CollectedVolumePropertiesStep.java deleted file mode 100644 index 5ad7904..0000000 --- a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/CollectedVolumePropertiesStep.java +++ /dev/null @@ -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 Jens Pelzetter - */ -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(); - } - } - - } - -} diff --git a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/CollectedVolumePropertyForm.java b/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/CollectedVolumePropertyForm.java deleted file mode 100644 index 9ae4029..0000000 --- a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/CollectedVolumePropertyForm.java +++ /dev/null @@ -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 Jens Pelzetter - */ -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 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); - } - } - -} diff --git a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/ExpertiseController.java b/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/ExpertiseController.java deleted file mode 100644 index fc8fe5f..0000000 --- a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/ExpertiseController.java +++ /dev/null @@ -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 Jens Pelzetter - */ -@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 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); - } - -} diff --git a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/ExpertiseCreateForm.java b/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/ExpertiseCreateForm.java deleted file mode 100644 index edd039a..0000000 --- a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/ExpertiseCreateForm.java +++ /dev/null @@ -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 Jens Pelzetter - */ -public class ExpertiseCreateForm - extends AbstractPublicationCreateForm{ - - public ExpertiseCreateForm(final ItemSelectionModel itemModel, - final CreationSelector creationSelector, - final StringParameter selectedLanguageParam) { - super(itemModel, creationSelector, selectedLanguageParam); - } - - @Override - protected Expertise createPublication() { - return new Expertise(); - } - -} diff --git a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/ExpertiseOrdererForm.java b/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/ExpertiseOrdererForm.java deleted file mode 100644 index c6119da..0000000 --- a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/ExpertiseOrdererForm.java +++ /dev/null @@ -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 Jens Pelzetter - */ -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); - } - -} diff --git a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/ExpertiseOrdererSheet.java b/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/ExpertiseOrdererSheet.java deleted file mode 100644 index 6e73018..0000000 --- a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/ExpertiseOrdererSheet.java +++ /dev/null @@ -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 Jens Pelzetter - */ -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(""); - } - } - - } - -} diff --git a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/ExpertiseOrdererStep.java b/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/ExpertiseOrdererStep.java deleted file mode 100644 index d33d506..0000000 --- a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/ExpertiseOrdererStep.java +++ /dev/null @@ -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 Jens Pelzetter - */ -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); - } - -} diff --git a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/ExpertiseOrganizationForm.java b/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/ExpertiseOrganizationForm.java deleted file mode 100644 index 4d12011..0000000 --- a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/ExpertiseOrganizationForm.java +++ /dev/null @@ -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 Jens Pelzetter - */ -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); - } - -} diff --git a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/ExpertiseOrganizationSheet.java b/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/ExpertiseOrganizationSheet.java deleted file mode 100644 index fedacb1..0000000 --- a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/ExpertiseOrganizationSheet.java +++ /dev/null @@ -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 Jens Pelzetter - */ -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(""); - } - } - - } - -} diff --git a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/ExpertiseOrganizationStep.java b/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/ExpertiseOrganizationStep.java deleted file mode 100644 index ce23177..0000000 --- a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/ExpertiseOrganizationStep.java +++ /dev/null @@ -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 Jens Pelzetter - */ -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); - } - -} diff --git a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/ExpertisePropertiesStep.java b/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/ExpertisePropertiesStep.java deleted file mode 100644 index 4302825..0000000 --- a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/ExpertisePropertiesStep.java +++ /dev/null @@ -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 Jens Pelzetter - */ -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 - ) - ); - } - -} diff --git a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/ExpertisePropertyForm.java b/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/ExpertisePropertyForm.java deleted file mode 100644 index 96bb25e..0000000 --- a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/ExpertisePropertyForm.java +++ /dev/null @@ -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 Jens Pelzetter - */ -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 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 - ); - } - } - -} diff --git a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/GreyLiteratureController.java b/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/GreyLiteratureController.java deleted file mode 100644 index f6b2f51..0000000 --- a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/GreyLiteratureController.java +++ /dev/null @@ -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 Jens Pelzetter - */ -@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 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); - } - -} diff --git a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/GreyLiteratureCreateForm.java b/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/GreyLiteratureCreateForm.java deleted file mode 100644 index bb1a75c..0000000 --- a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/GreyLiteratureCreateForm.java +++ /dev/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.GreyLiterature; -import org.scientificcms.publications.contenttypes.GreyLiteratureItem; - -/** - * - * @author Jens Pelzetter - */ -public class GreyLiteratureCreateForm - extends AbstractPublicationCreateForm { - - public GreyLiteratureCreateForm( - final ItemSelectionModel itemModel, - final CreationSelector creationSelector, - final StringParameter selectedLanguageParam - ) { - super(itemModel, creationSelector, selectedLanguageParam); - } - - @Override - protected GreyLiterature createPublication() { - return new GreyLiterature(); - } - -} diff --git a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/GreyLiteraturePropertiesStep.java b/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/GreyLiteraturePropertiesStep.java deleted file mode 100644 index 02960e6..0000000 --- a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/GreyLiteraturePropertiesStep.java +++ /dev/null @@ -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 Jens Pelzetter - */ -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); - } - -} diff --git a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/GreyLiteraturePropertyForm.java b/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/GreyLiteraturePropertyForm.java deleted file mode 100644 index 1511b6c..0000000 --- a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/GreyLiteraturePropertyForm.java +++ /dev/null @@ -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 Jens Pelzetter - */ -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 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 - ); - } - } - -} diff --git a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/InProceedingsController.java b/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/InProceedingsController.java deleted file mode 100644 index dad38ca..0000000 --- a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/InProceedingsController.java +++ /dev/null @@ -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 Jens Pelzetter - */ -@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 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); - } - -} diff --git a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/InProceedingsCreateForm.java b/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/InProceedingsCreateForm.java deleted file mode 100644 index f879e1a..0000000 --- a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/InProceedingsCreateForm.java +++ /dev/null @@ -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 Jens Pelzetter - */ -public class InProceedingsCreateForm - extends AbstractPublicationCreateForm { - - public InProceedingsCreateForm(final ItemSelectionModel itemModel, - final CreationSelector creationSelector, - final StringParameter selectedLanguageParam) { - super(itemModel, creationSelector, selectedLanguageParam); - } - - @Override - protected InProceedings createPublication() { - return new InProceedings(); - } - -} diff --git a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/InProceedingsProceedingsForm.java b/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/InProceedingsProceedingsForm.java deleted file mode 100644 index 51897c1..0000000 --- a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/InProceedingsProceedingsForm.java +++ /dev/null @@ -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 Jens Pelzetter - */ -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); - } - -} diff --git a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/InProceedingsProceedingsSheet.java b/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/InProceedingsProceedingsSheet.java deleted file mode 100644 index 45fa24e..0000000 --- a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/InProceedingsProceedingsSheet.java +++ /dev/null @@ -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 Jens Pelzetter - */ -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(""); - } - } - - } - -} diff --git a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/InProceedingsProceedingsStep.java b/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/InProceedingsProceedingsStep.java deleted file mode 100644 index 0f6b055..0000000 --- a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/InProceedingsProceedingsStep.java +++ /dev/null @@ -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 Jens Pelzetter - */ -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); - } - -} diff --git a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/InProceedingsPropertiesStep.java b/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/InProceedingsPropertiesStep.java deleted file mode 100644 index 28193f4..0000000 --- a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/InProceedingsPropertiesStep.java +++ /dev/null @@ -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 Jens Pelzetter - */ -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 - ) - ); - } - -} diff --git a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/InProceedingsPropertyForm.java b/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/InProceedingsPropertyForm.java deleted file mode 100644 index 607e9e6..0000000 --- a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/InProceedingsPropertyForm.java +++ /dev/null @@ -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 Jens Pelzetter - */ -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 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 - ); - } - } - -} diff --git a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/InternetArticleController.java b/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/InternetArticleController.java deleted file mode 100644 index 849aa52..0000000 --- a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/InternetArticleController.java +++ /dev/null @@ -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 Jens Pelzetter - */ -@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 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); - } - -} diff --git a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/InternetArticleCreateForm.java b/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/InternetArticleCreateForm.java deleted file mode 100644 index 47f29e1..0000000 --- a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/InternetArticleCreateForm.java +++ /dev/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 Jens Pelzetter - */ -public class InternetArticleCreateForm - extends AbstractPublicationCreateForm { - - public InternetArticleCreateForm( - final ItemSelectionModel itemModel, - final CreationSelector creationSelector, - final StringParameter selectedLanguageParam - ) { - super(itemModel, creationSelector, selectedLanguageParam); - } - - @Override - protected InternetArticle createPublication() { - return new InternetArticle(); - } - -} diff --git a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/InternetArticleOrganizationForm.java b/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/InternetArticleOrganizationForm.java deleted file mode 100644 index b934949..0000000 --- a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/InternetArticleOrganizationForm.java +++ /dev/null @@ -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 Jens Pelzetter - */ -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); - } - -} diff --git a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/InternetArticleOrganizationSheet.java b/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/InternetArticleOrganizationSheet.java deleted file mode 100644 index c1743f1..0000000 --- a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/InternetArticleOrganizationSheet.java +++ /dev/null @@ -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 Jens Pelzetter - */ -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(""); - } - } - - } - -} diff --git a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/InternetArticleOrganizationStep.java b/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/InternetArticleOrganizationStep.java deleted file mode 100644 index f71ee82..0000000 --- a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/InternetArticleOrganizationStep.java +++ /dev/null @@ -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 Jens Pelzetter - */ -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); - } - -} diff --git a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/InternetArticlePropertiesStep.java b/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/InternetArticlePropertiesStep.java deleted file mode 100644 index d5dd2c4..0000000 --- a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/InternetArticlePropertiesStep.java +++ /dev/null @@ -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 Jens Pelzetter - */ -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 - ) - ); - } - -} diff --git a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/InternetArticlePropertyForm.java b/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/InternetArticlePropertyForm.java deleted file mode 100644 index a38aac7..0000000 --- a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/InternetArticlePropertyForm.java +++ /dev/null @@ -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 Jens Pelzetter - */ -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 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 - ); - } - } - -} diff --git a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/JournalSearchWidget.java b/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/JournalSearchWidget.java deleted file mode 100644 index 1e15514..0000000 --- a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/JournalSearchWidget.java +++ /dev/null @@ -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 Jens Pelzetter - */ -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 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); - } - } - -} diff --git a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/JournalSearchWidgetController.java b/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/JournalSearchWidgetController.java deleted file mode 100644 index 3ea56be..0000000 --- a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/JournalSearchWidgetController.java +++ /dev/null @@ -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 Jens Pelzetter - */ -@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 getData(final long journalId) { - - final Journal journal = journalRepository - .findById(journalId) - .orElseThrow( - () -> new IllegalArgumentException( - String.format("No Journal with ID %d found.", journalId) - ) - ); - - final Map 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; - } - -} diff --git a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/MonographController.java b/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/MonographController.java deleted file mode 100644 index 20d2683..0000000 --- a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/MonographController.java +++ /dev/null @@ -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 Jens Pelzetter - */ -@RequestScoped -public class MonographController { - - public static final String REVIEWED = "reviewed"; - - @Inject - private PublicationRepository publicationRepository; - - public void saveMonograph( - final long monographId, final Map 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); - } - -} diff --git a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/MonographCreateForm.java b/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/MonographCreateForm.java deleted file mode 100644 index d630a12..0000000 --- a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/MonographCreateForm.java +++ /dev/null @@ -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 Jens Pelzetter - */ -public class MonographCreateForm - extends AbstractPublicationCreateForm { - - public MonographCreateForm(final ItemSelectionModel itemModel, - final CreationSelector creationSelector, - final StringParameter selectedLanguageParam) { - super(itemModel, creationSelector, selectedLanguageParam); - } - - @Override - protected Monograph createPublication() { - return new Monograph(); - } - -} diff --git a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/MonographPropertiesStep.java b/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/MonographPropertiesStep.java deleted file mode 100644 index db5d43e..0000000 --- a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/MonographPropertiesStep.java +++ /dev/null @@ -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 Jens Pelzetter - */ -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(); - } - } - - } - -} diff --git a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/MonographPropertyForm.java b/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/MonographPropertyForm.java deleted file mode 100644 index f9b046c..0000000 --- a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/MonographPropertyForm.java +++ /dev/null @@ -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 Jens Pelzetter - */ -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 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 - ); - } - } - -} diff --git a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/ProceedingsController.java b/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/ProceedingsController.java deleted file mode 100644 index 803950d..0000000 --- a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/ProceedingsController.java +++ /dev/null @@ -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 Jens Pelzetter - */ -@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 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); - } - -} diff --git a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/ProceedingsCreateForm.java b/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/ProceedingsCreateForm.java deleted file mode 100644 index aa2fbce..0000000 --- a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/ProceedingsCreateForm.java +++ /dev/null @@ -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 Jens Pelzetter - */ -public class ProceedingsCreateForm - extends AbstractPublicationCreateForm{ - - public ProceedingsCreateForm(final ItemSelectionModel itemModel, - final CreationSelector creationSelector, - final StringParameter selectedLanguageParam) { - super(itemModel, creationSelector, selectedLanguageParam); - } - - @Override - protected Proceedings createPublication() { - return new Proceedings(); - } - -} diff --git a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/ProceedingsOrganizerForm.java b/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/ProceedingsOrganizerForm.java deleted file mode 100644 index 13401fc..0000000 --- a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/ProceedingsOrganizerForm.java +++ /dev/null @@ -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 Jens Pelzetter - */ -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); - } - -} diff --git a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/ProceedingsOrganizerSheet.java b/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/ProceedingsOrganizerSheet.java deleted file mode 100644 index 5044535..0000000 --- a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/ProceedingsOrganizerSheet.java +++ /dev/null @@ -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 Jens Pelzetter - */ -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(""); - } - } - - } - - -} diff --git a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/ProceedingsOrganizerStep.java b/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/ProceedingsOrganizerStep.java deleted file mode 100644 index e173042..0000000 --- a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/ProceedingsOrganizerStep.java +++ /dev/null @@ -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 Jens Pelzetter - */ -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); - } - -} diff --git a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/ProceedingsPapersAddForm.java b/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/ProceedingsPapersAddForm.java deleted file mode 100644 index 4fff112..0000000 --- a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/ProceedingsPapersAddForm.java +++ /dev/null @@ -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 Jens Pelzetter - */ -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); - } - -} diff --git a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/ProceedingsPapersStep.java b/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/ProceedingsPapersStep.java deleted file mode 100644 index 55ab63f..0000000 --- a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/ProceedingsPapersStep.java +++ /dev/null @@ -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 Jens Pelzetter - */ -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); - - } - -} diff --git a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/ProceedingsPapersTable.java b/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/ProceedingsPapersTable.java deleted file mode 100644 index 3520c91..0000000 --- a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/ProceedingsPapersTable.java +++ /dev/null @@ -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 Jens Pelzetter - */ -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 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(""); - } - } - - } - -} diff --git a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/ProceedingsPropertiesStep.java b/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/ProceedingsPropertiesStep.java deleted file mode 100644 index d4cc2c9..0000000 --- a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/ProceedingsPropertiesStep.java +++ /dev/null @@ -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 Jens Pelzetter - */ -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 - ) - ); - } - -} diff --git a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/ProceedingsPropertyForm.java b/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/ProceedingsPropertyForm.java deleted file mode 100644 index 9a69cfa..0000000 --- a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/ProceedingsPropertyForm.java +++ /dev/null @@ -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 Jens Pelzetter - */ -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 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 - ); - } - } - -} diff --git a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/PublicationAuthorAddForm.java b/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/PublicationAuthorAddForm.java deleted file mode 100644 index 1a6816f..0000000 --- a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/PublicationAuthorAddForm.java +++ /dev/null @@ -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 Jens Pelzetter - */ -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 - ) - ); - } - } - } - -} diff --git a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/PublicationAuthorsPropertyStep.java b/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/PublicationAuthorsPropertyStep.java deleted file mode 100644 index 0ad034c..0000000 --- a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/PublicationAuthorsPropertyStep.java +++ /dev/null @@ -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 Jens Pelzetter - */ -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; - } - - - -} diff --git a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/PublicationAuthorsTable.java b/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/PublicationAuthorsTable.java deleted file mode 100644 index da9a22c..0000000 --- a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/PublicationAuthorsTable.java +++ /dev/null @@ -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 Jens Pelzetter - */ -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> iterator; - - private Map 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> authorships = controller - .getAuthors(selected.getPublication().getPublicationId() - ); - - if ((authorships.size() - 1) == row) { - return new Label(); - } else { - final ControlLink link = new ControlLink("down"); - return link; - } - } - - } - -} diff --git a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/PublicationPropertiesStep.java b/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/PublicationPropertiesStep.java deleted file mode 100644 index efa1901..0000000 --- a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/PublicationPropertiesStep.java +++ /dev/null @@ -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 Jens Pelzetter - */ -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("

%s
", str); - } - } - - } - -} diff --git a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/PublicationPropertyForm.java b/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/PublicationPropertyForm.java deleted file mode 100644 index 23ccb44..0000000 --- a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/PublicationPropertyForm.java +++ /dev/null @@ -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 Jens Pelzetter - */ -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() { - - @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 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 - ); - } - -} diff --git a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/PublicationSearchWidget.java b/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/PublicationSearchWidget.java deleted file mode 100644 index 8624f32..0000000 --- a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/PublicationSearchWidget.java +++ /dev/null @@ -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 Jens Pelzetter - */ -public class PublicationSearchWidget extends Widget { - - private Class type; - - public PublicationSearchWidget(final String name) { - super(new LongParameter(name)); - } - - public PublicationSearchWidget( - final String name, final Class 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 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); - } - } - -} diff --git a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/PublicationSearchWidgetController.java b/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/PublicationSearchWidgetController.java deleted file mode 100644 index 5db10ac..0000000 --- a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/PublicationSearchWidgetController.java +++ /dev/null @@ -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 Jens Pelzetter - */ -@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 getData(final long publicationId) { - - final Publication publication = publicationRepository - .findById(publicationId) - .orElseThrow( - () -> new IllegalArgumentException( - String.format("No Publication with ID %d found.", - publicationId) - ) - ); - - final Map 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; - } - -} diff --git a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/PublicationSeriesAddForm.java b/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/PublicationSeriesAddForm.java deleted file mode 100644 index 1490365..0000000 --- a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/PublicationSeriesAddForm.java +++ /dev/null @@ -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 Jens Pelzetter - */ -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); - } - -} diff --git a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/PublicationSeriesPropertyStep.java b/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/PublicationSeriesPropertyStep.java deleted file mode 100644 index aa250c3..0000000 --- a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/PublicationSeriesPropertyStep.java +++ /dev/null @@ -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 Jens Pelzetter - */ -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); - } - -} diff --git a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/PublicationSeriesTable.java b/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/PublicationSeriesTable.java deleted file mode 100644 index f28f642..0000000 --- a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/PublicationSeriesTable.java +++ /dev/null @@ -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 Jens Pelzetter - */ -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> iterator; - - private Map 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(""); - } - } - - } - -} diff --git a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/PublicationWithPublisherPropertiesStep.java b/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/PublicationWithPublisherPropertiesStep.java deleted file mode 100644 index 055816a..0000000 --- a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/PublicationWithPublisherPropertiesStep.java +++ /dev/null @@ -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 Jens Pelzetter - */ -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 - ) - ); - } - -} diff --git a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/PublicationWithPublisherPropertyForm.java b/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/PublicationWithPublisherPropertyForm.java deleted file mode 100644 index 5a5e1f0..0000000 --- a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/PublicationWithPublisherPropertyForm.java +++ /dev/null @@ -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 Jens Pelzetter - */ -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 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 - ); - } - } - -} diff --git a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/PublicationWithPublisherSetPublisherForm.java b/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/PublicationWithPublisherSetPublisherForm.java deleted file mode 100644 index 9a3d576..0000000 --- a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/PublicationWithPublisherSetPublisherForm.java +++ /dev/null @@ -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 Jens Pelzetter - */ -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); - } - - - -} diff --git a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/PublicationWithPublisherSetPublisherSheet.java b/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/PublicationWithPublisherSetPublisherSheet.java deleted file mode 100644 index bfe9f7b..0000000 --- a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/PublicationWithPublisherSetPublisherSheet.java +++ /dev/null @@ -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 Jens Pelzetter - */ -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(""); - } - } - - } - -} diff --git a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/PublicationWithPublisherSetPublisherStep.java b/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/PublicationWithPublisherSetPublisherStep.java deleted file mode 100644 index fb26e4f..0000000 --- a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/PublicationWithPublisherSetPublisherStep.java +++ /dev/null @@ -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 Jens Pelzetter - */ -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); - } - -} diff --git a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/PublisherSearchWidget.java b/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/PublisherSearchWidget.java deleted file mode 100644 index 32a8bc1..0000000 --- a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/PublisherSearchWidget.java +++ /dev/null @@ -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 Jens Pelzetter - */ -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 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); - } - } - -} diff --git a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/PublisherSearchWidgetController.java b/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/PublisherSearchWidgetController.java deleted file mode 100644 index b6ff605..0000000 --- a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/PublisherSearchWidgetController.java +++ /dev/null @@ -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 Jens Pelzetter - */ -@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 getData(final long publisherId) { - - final Publisher publisher = publisherRepository - .findById(publisherId) - .orElseThrow( - () -> new IllegalArgumentException( - String.format("No Publisher with ID %d found.", publisherId) - ) - ); - - final Map data = new HashMap<>(); - - data.put(PUBLISHER_ID, Long.toString(publisher.getPublisherId())); - data.put(NAME, publisher.getName()); - data.put(PLACE, publisher.getPlace()); - - return data; - } -} diff --git a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/ReviewPropertiesStep.java b/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/ReviewPropertiesStep.java deleted file mode 100644 index 6cd2216..0000000 --- a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/ReviewPropertiesStep.java +++ /dev/null @@ -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 Jens Pelzetter - */ -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 - ); - } - -} diff --git a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/ReviewPropertyForm.java b/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/ReviewPropertyForm.java deleted file mode 100644 index 09ec983..0000000 --- a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/ReviewPropertyForm.java +++ /dev/null @@ -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 Jens Pelzetter - */ -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); - } - -} diff --git a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/SciPublicationsController.java b/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/SciPublicationsController.java deleted file mode 100644 index 93cd9c9..0000000 --- a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/SciPublicationsController.java +++ /dev/null @@ -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 Jens Pelzetter - */ -@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 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> 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 buildAuthorshipEntry( - final Authorship authorship - ) { - Objects.requireNonNull(authorship); - - final Map 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 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 = 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 = 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 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 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> 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 buildVolumeInSeriesEntry( - final VolumeInSeries volumeInSeries - ) { - Objects.requireNonNull(volumeInSeries); - - final Map 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 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 = 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); - } - -} diff --git a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/SciPublicationsWithPublisherController.java b/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/SciPublicationsWithPublisherController.java deleted file mode 100644 index 398a61c..0000000 --- a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/SciPublicationsWithPublisherController.java +++ /dev/null @@ -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 Jens Pelzetter - */ -@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 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); - } - -} diff --git a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/SeriesSearchWidget.java b/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/SeriesSearchWidget.java deleted file mode 100644 index 5f5c40d..0000000 --- a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/SeriesSearchWidget.java +++ /dev/null @@ -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 Jens Pelzetter - */ -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 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); - } - } - -} diff --git a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/SeriesSearchWidgetController.java b/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/SeriesSearchWidgetController.java deleted file mode 100644 index 46de996..0000000 --- a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/SeriesSearchWidgetController.java +++ /dev/null @@ -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 Jens Pelzetter - */ -@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 getData(final long seriesId) { - - final Series series = seriesRepository - .findById(seriesId) - .orElseThrow( - () -> new IllegalArgumentException( - String.format("No Series with ID %d found.", seriesId) - ) - ); - - final Map data = new HashMap<>(); - - data.put(SERIES_ID, Long.toString(series.getSeriesId())); - data.put( - TITLE, - globalizationHelper.getValueFromLocalizedString(series.getTitle()) - ); - - return data; - } - -} diff --git a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/TalkController.java b/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/TalkController.java deleted file mode 100644 index cbce567..0000000 --- a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/TalkController.java +++ /dev/null @@ -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 Jens Pelzetter - */ -@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 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); - } -} diff --git a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/TalkCreateForm.java b/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/TalkCreateForm.java deleted file mode 100644 index e0ac972..0000000 --- a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/TalkCreateForm.java +++ /dev/null @@ -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 Jens Pelzetter - */ -public class TalkCreateForm - extends AbstractPublicationCreateForm { - - public TalkCreateForm(final ItemSelectionModel itemModel, - final CreationSelector creationSelector, - final StringParameter selectedLanguageParam) { - super(itemModel, creationSelector, selectedLanguageParam); - } - - @Override - protected Talk createPublication() { - return new Talk(); - } - -} diff --git a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/TalkPropertiesStep.java b/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/TalkPropertiesStep.java deleted file mode 100644 index 3a45c86..0000000 --- a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/TalkPropertiesStep.java +++ /dev/null @@ -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 Jens Pelzetter - */ -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); - } - -} diff --git a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/TalkPropertyForm.java b/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/TalkPropertyForm.java deleted file mode 100644 index 0773a44..0000000 --- a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/TalkPropertyForm.java +++ /dev/null @@ -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 Jens Pelzetter - */ -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 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 - ); - } - } - -} diff --git a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/UnPublishedController.java b/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/UnPublishedController.java deleted file mode 100644 index 0a38f24..0000000 --- a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/UnPublishedController.java +++ /dev/null @@ -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 Jens Pelzetter - */ -@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 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); - } - -} diff --git a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/UnPublishedOrganizationForm.java b/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/UnPublishedOrganizationForm.java deleted file mode 100644 index f45b194..0000000 --- a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/UnPublishedOrganizationForm.java +++ /dev/null @@ -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 Jens Pelzetter - */ -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); - } - -} diff --git a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/UnPublishedOrganizationSheet.java b/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/UnPublishedOrganizationSheet.java deleted file mode 100644 index 13162f9..0000000 --- a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/UnPublishedOrganizationSheet.java +++ /dev/null @@ -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 Jens Pelzetter - */ -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(""); - } - } - - } - -} diff --git a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/UnPublishedOrganizationStep.java b/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/UnPublishedOrganizationStep.java deleted file mode 100644 index b14897e..0000000 --- a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/UnPublishedOrganizationStep.java +++ /dev/null @@ -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 Jens Pelzetter - */ -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); - } - -} diff --git a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/UnPublishedPropertiesStep.java b/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/UnPublishedPropertiesStep.java deleted file mode 100644 index 5c3ee0c..0000000 --- a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/UnPublishedPropertiesStep.java +++ /dev/null @@ -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 Jens Pelzetter - */ -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 - ) - ); - } - -} diff --git a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/UnPublishedPropertyForm.java b/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/UnPublishedPropertyForm.java deleted file mode 100644 index 0a87dee..0000000 --- a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/UnPublishedPropertyForm.java +++ /dev/null @@ -1,164 +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.cms.ui.assets.AssetSearchWidget; -import com.arsdigita.globalization.GlobalizedMessage; - -import org.libreccm.cdi.utils.CdiUtil; -import org.scientificcms.publications.SciPublicationsConstants; -import org.scientificcms.publications.UnPublished; -import org.scientificcms.publications.contenttypes.PublicationItem; - -import java.util.HashMap; -import java.util.Map; - -/** - * - * @author Jens Pelzetter - */ -public class UnPublishedPropertyForm - extends PublicationPropertyForm - implements FormInitListener, FormProcessListener, FormSubmissionListener { - - public static final String ID = "UnPublishedEdit"; - - private static final String ORGA_SEARCH = "organization"; - - private UnPublishedPropertiesStep step; - - private AssetSearchWidget orgaSearch; - - public UnPublishedPropertyForm( - final ItemSelectionModel itemModel, - final StringParameter selectedLangParam - ) { - this(itemModel, null, selectedLangParam); - } - - public UnPublishedPropertyForm( - final ItemSelectionModel itemModel, - final UnPublishedPropertiesStep step, - final StringParameter selectedLangParam - ) { - super(itemModel, step, selectedLangParam); - this.step = step; - addSubmissionListener(this); - } - - @Override - protected void addWidgets() { - - super.addWidgets(); - - final ParameterModel placeParam = new StringParameter( - UnPublishedController.PLACE); - final TextField place = new TextField(placeParam); - place.setLabel( - new GlobalizedMessage( - "publications.ui.unpublished.place", - SciPublicationsConstants.BUNDLE - ) - ); - add(place); - - ParameterModel numberParam = new StringParameter( - UnPublishedController.NUMBER - ); - final TextField number = new TextField(numberParam); - number.setLabel( - new GlobalizedMessage( - "publications.ui.unpublished.number", - SciPublicationsConstants.BUNDLE - ) - ); - add(number); - - final ParameterModel numberOfPagesParam = new IntegerParameter( - UnPublishedController.NUMBER_OF_PAGES - ); - final TextField numberOfPages = new TextField(numberOfPagesParam); - numberOfPages.setLabel( - new GlobalizedMessage( - "publications.ui.unpublished.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 PublicationItem publicationItem - = (PublicationItem) initBasicWidgets(event); - final UnPublished unPublished = (UnPublished) publicationItem - .getPublication(); - - data.put( - UnPublishedController.PLACE, unPublished.getPlace() - ); - data.put( - UnPublishedController.NUMBER, unPublished.getNumber() - ); - data.put( - UnPublishedController.NUMBER_OF_PAGES, - unPublished.getNumberOfPages() - ); - } - - @Override - public void process(final FormSectionEvent event) - throws FormProcessException { - super.process(event); - - final FormData formData = event.getFormData(); - final PageState state = event.getPageState(); - final PublicationItem publicationItem - = (PublicationItem) initBasicWidgets(event); - - if ((publicationItem != null) - && getSaveCancelSection().getSaveButton().isSelected(state)) { - final UnPublished unpublished = (UnPublished) publicationItem - .getPublication(); - - final Map data = new HashMap<>(); - data.put( - UnPublishedController.PLACE, - formData.get(UnPublishedController.PLACE) - ); - data.put( - UnPublishedController.NUMBER, - formData.get(UnPublishedController.NUMBER) - ); - data.put( - UnPublishedController.NUMBER_OF_PAGES, - formData.get(UnPublishedController.NUMBER_OF_PAGES) - ); - - final UnPublishedController controller = CdiUtil - .createCdiUtil() - .findBean(UnPublishedController.class); - controller.saveUnPublished(unpublished.getPublicationId(), data); - } - } - -} diff --git a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/WorkingPaperController.java b/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/WorkingPaperController.java deleted file mode 100644 index 1ca8cfd..0000000 --- a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/WorkingPaperController.java +++ /dev/null @@ -1,50 +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.WorkingPaper; - -import java.util.Map; - -import javax.enterprise.context.RequestScoped; -import javax.inject.Inject; -import javax.transaction.Transactional; - -/** - * - * @author Jens Pelzetter - */ -@RequestScoped -public class WorkingPaperController { - - public static final String PEER_REVIEWED = "reviewed"; - - @Inject - private PublicationRepository publicationRepository; - - @Transactional(Transactional.TxType.REQUIRED) - public void saveWorkingPaper( - final long workingPaperId, final Map data - ) { - final WorkingPaper workingPaper = publicationRepository - .findByIdAndType(workingPaperId, WorkingPaper.class) - .orElseThrow( - () -> new IllegalArgumentException( - String.format( - "No WorkingPaper with Id %d found.", workingPaperId - ) - ) - ); - - if (data.containsKey(PEER_REVIEWED)) { - workingPaper.setPeerReviewed((Boolean) data.get(PEER_REVIEWED)); - } - - publicationRepository.save(workingPaper); - } - -} diff --git a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/WorkingPaperCreateForm.java b/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/WorkingPaperCreateForm.java deleted file mode 100644 index 6aedba1..0000000 --- a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/WorkingPaperCreateForm.java +++ /dev/null @@ -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.WorkingPaper; -import org.scientificcms.publications.contenttypes.WorkingPaperItem; - -/** - * - * @author Jens Pelzetter - */ -public class WorkingPaperCreateForm - extends AbstractPublicationCreateForm { - - public WorkingPaperCreateForm(final ItemSelectionModel itemModel, - final CreationSelector creationSelector, - final StringParameter selectedLanguageParam) { - super(itemModel, creationSelector, selectedLanguageParam); - } - - @Override - protected WorkingPaper createPublication() { - return new WorkingPaper(); - } - -} diff --git a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/WorkingPaperPropertiesStep.java b/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/WorkingPaperPropertiesStep.java deleted file mode 100644 index 16dae17..0000000 --- a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/WorkingPaperPropertiesStep.java +++ /dev/null @@ -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 Jens Pelzetter - */ -public class WorkingPaperPropertiesStep extends UnPublishedPropertiesStep { - - private final StringParameter selectedLangParam; - - public WorkingPaperPropertiesStep( - final ItemSelectionModel itemModel, - final AuthoringKitWizard parent, - final StringParameter selectedLangParam) { - super(itemModel, parent, selectedLangParam); - this.selectedLangParam = selectedLangParam; - } - - public static Component getWorkingPaperPropertySheet( - final ItemSelectionModel itemModel, - final StringParameter selectedLangParam - ) { - final DomainObjectPropertySheet sheet - = (DomainObjectPropertySheet) getUnPublishedPropertySheet( - itemModel, selectedLangParam - ); - - sheet.add( - new GlobalizedMessage( - "publications.ui.workingpaper.reviewed", - SciPublicationsConstants.BUNDLE - ), - WorkingPaperController.PEER_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 - ); - - BasicPageForm editBasicSheet = new WorkingPaperPropertyForm( - itemModel, this, selectedLangParam - ); - - basicProperties.add( - EDIT_SHEET_NAME, - new GlobalizedMessage( - "publications.ui.workingpaper.edit_basic_sheet", - SciPublicationsConstants.BUNDLE - ), - new WorkflowLockedComponentAccess(editBasicSheet, itemModel), - editBasicSheet.getSaveCancelSection().getCancelButton()); - - basicProperties.setDisplayComponent( - getWorkingPaperPropertySheet(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.workingpaper.reviewed.yes", - SciPublicationsConstants.BUNDLE - ).localize(); - } else { - return (String) new GlobalizedMessage( - "publications.ui.workingpaper.reviewed.no", - SciPublicationsConstants.BUNDLE - ).localize(); - } - } - - } - -} diff --git a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/WorkingPaperPropertyForm.java b/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/WorkingPaperPropertyForm.java deleted file mode 100644 index 022cc7a..0000000 --- a/sci-publications/src/main/java/com/arsdigita/cms/contenttypes/ui/WorkingPaperPropertyForm.java +++ /dev/null @@ -1,135 +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.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.SciPublicationsConstants; -import org.scientificcms.publications.WorkingPaper; -import org.scientificcms.publications.contenttypes.WorkingPaperItem; - -import java.util.HashMap; -import java.util.Map; - -/** - * - * @author Jens Pelzetter - */ -public class WorkingPaperPropertyForm - extends UnPublishedPropertyForm - implements FormInitListener, - FormProcessListener, - FormSubmissionListener { - - public static final String ID = "WorkingPaperEdit"; - - private final WorkingPaperPropertiesStep step; - - private CheckboxGroup reviewed; - - public WorkingPaperPropertyForm( - final ItemSelectionModel itemModel, - final StringParameter selectedLangParam - ) { - this(itemModel, null, selectedLangParam); - } - - public WorkingPaperPropertyForm( - ItemSelectionModel itemModel, - WorkingPaperPropertiesStep step, - final StringParameter selectedLangParam - ) { - super(itemModel, step, selectedLangParam); - this.step = step; - addSubmissionListener(this); - } - - @Override - protected void addWidgets() { - - super.addWidgets(); - - reviewed = new CheckboxGroup("reviewedGroup"); - reviewed.addOption( - new Option( - WorkingPaperController.PEER_REVIEWED, - new Label( - new GlobalizedMessage( - "publications.ui.workingpaper.reviewed", - SciPublicationsConstants.BUNDLE - ) - ) - ) - ); - reviewed.setLabel( - new GlobalizedMessage( - "publications.ui.workingpaper.reviewed", - SciPublicationsConstants.BUNDLE - ) - ); - add(reviewed); - } - - @Override - public void init(final FormSectionEvent event) throws FormProcessException { - super.init(event); - - final WorkingPaperItem paperItem = (WorkingPaperItem) super - .initBasicWidgets(event); - final WorkingPaper paper = paperItem.getPublication(); - - if ((paper.getPeerReviewed() != null) && (paper.getPeerReviewed())) { - reviewed.setValue( - event.getPageState(), - new String[]{WorkingPaperController.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 WorkingPaperItem paperItem = (WorkingPaperItem) super - .processBasicWidgets(event); - - if ((paperItem != null) - && getSaveCancelSection().getSaveButton().isSelected(state)) { - - final Map data = new HashMap<>(); - if (reviewed.getValue(event.getPageState()) == null) { - data.put(WorkingPaperController.PEER_REVIEWED, false); - } else { - data.put(WorkingPaperController.PEER_REVIEWED, true); - } - - final WorkingPaperController controller = CdiUtil - .createCdiUtil() - .findBean(WorkingPaperController.class); - - controller.saveWorkingPaper( - paperItem.getPublication().getPublicationId(), data - ); - } - } - -} diff --git a/sci-publications/src/main/java/org/scientificcms/publications/assets/ui/JournalFormController.java b/sci-publications/src/main/java/org/scientificcms/publications/assets/ui/JournalFormController.java index d4b77b2..fe63457 100644 --- a/sci-publications/src/main/java/org/scientificcms/publications/assets/ui/JournalFormController.java +++ b/sci-publications/src/main/java/org/scientificcms/publications/assets/ui/JournalFormController.java @@ -79,7 +79,7 @@ public class JournalFormController } if (data.containsKey(DESCRIPTION)) { - journal.getDescription().addValue( + journal.getDescription().putValue( selectedLocale, (String) data.get(DESCRIPTION) ); } diff --git a/sci-publications/src/main/java/org/scientificcms/publications/assets/ui/SeriesFormController.java b/sci-publications/src/main/java/org/scientificcms/publications/assets/ui/SeriesFormController.java index e90b4a4..bad9f12 100644 --- a/sci-publications/src/main/java/org/scientificcms/publications/assets/ui/SeriesFormController.java +++ b/sci-publications/src/main/java/org/scientificcms/publications/assets/ui/SeriesFormController.java @@ -54,8 +54,8 @@ public class SeriesFormController ) { final Series series = asset.getSeries(); - series.getTitle().addValue(selectedLocale, (String) data.get(TITLE)); - series.getDescription().addValue( + series.getTitle().putValue(selectedLocale, (String) data.get(TITLE)); + series.getDescription().putValue( selectedLocale, (String) data.get(DESCRIPTION) ); } diff --git a/sci-publications/src/test/java/org/scientificcms/publications/EqualsAndHashCodeTest.java b/sci-publications/src/test/java/org/scientificcms/publications/EqualsAndHashCodeTest.java index 5a3c62d..9eb609a 100644 --- a/sci-publications/src/test/java/org/scientificcms/publications/EqualsAndHashCodeTest.java +++ b/sci-publications/src/test/java/org/scientificcms/publications/EqualsAndHashCodeTest.java @@ -8,7 +8,6 @@ package org.scientificcms.publications; import nl.jqno.equalsverifier.EqualsVerifierApi; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; -import org.libreccm.tests.categories.UnitTest; import org.libreccm.testutils.EqualsVerifier; import org.librecms.assets.Organization; import org.librecms.assets.Person; @@ -22,7 +21,6 @@ import java.util.Locale; * @author Jens Pelzetter */ @RunWith(Parameterized.class) -@org.junit.experimental.categories.Category(UnitTest.class) public class EqualsAndHashCodeTest extends EqualsVerifier { @Parameterized.Parameters(name = "{0}") @@ -57,9 +55,9 @@ public class EqualsAndHashCodeTest extends EqualsVerifier { protected void addPrefabValues(final EqualsVerifierApi verifier) { final CollectedVolume volume1 = new CollectedVolume(); - volume1.getTitle().addValue(Locale.ENGLISH, "Test 1"); + volume1.getTitle().putValue(Locale.ENGLISH, "Test 1"); final CollectedVolume volume2 = new CollectedVolume(); - volume2.getTitle().addValue(Locale.ENGLISH, "Test 2"); + volume2.getTitle().putValue(Locale.ENGLISH, "Test 2"); verifier.withPrefabValues(CollectedVolume.class, volume1, volume2); final Person author1 = new Person(); @@ -69,9 +67,9 @@ public class EqualsAndHashCodeTest extends EqualsVerifier { verifier.withPrefabValues(Person.class, author1, author2); final Publication publication1 = new Publication(); - publication1.getTitle().addValue(Locale.ENGLISH, "Alpha"); + publication1.getTitle().putValue(Locale.ENGLISH, "Alpha"); final Publication publication2 = new Publication(); - publication2.getTitle().addValue(Locale.ENGLISH, "Bravo"); + publication2.getTitle().putValue(Locale.ENGLISH, "Bravo"); verifier.withPrefabValues(Publication.class, publication1, publication2); final Journal journal1 = new Journal(); @@ -97,17 +95,17 @@ public class EqualsAndHashCodeTest extends EqualsVerifier { organization2); final Proceedings proceedings1 = new Proceedings(); - proceedings1.getTitle().addValue(Locale.ENGLISH, "Proceedings 1"); + proceedings1.getTitle().putValue(Locale.ENGLISH, "Proceedings 1"); final Proceedings proceedings2 = new Proceedings(); - proceedings2.getTitle().addValue(Locale.ENGLISH, "Proceedings 2"); + proceedings2.getTitle().putValue(Locale.ENGLISH, "Proceedings 2"); verifier.withPrefabValues(Proceedings.class, proceedings1, proceedings2); final Series series1 = new Series(); - series1.getTitle().addValue(Locale.ENGLISH, "Series Alpha"); + series1.getTitle().putValue(Locale.ENGLISH, "Series Alpha"); final Series series2 = new Series(); - series2.getTitle().addValue(Locale.ENGLISH, "Series Bravo"); + series2.getTitle().putValue(Locale.ENGLISH, "Series Bravo"); verifier.withPrefabValues(Series.class, series1, series2); } diff --git a/sci-publications/src/test/java/org/scientificcms/publications/assets/EqualsAndHashCodeTest.java b/sci-publications/src/test/java/org/scientificcms/publications/assets/EqualsAndHashCodeTest.java index 95d6dc4..ff36b42 100644 --- a/sci-publications/src/test/java/org/scientificcms/publications/assets/EqualsAndHashCodeTest.java +++ b/sci-publications/src/test/java/org/scientificcms/publications/assets/EqualsAndHashCodeTest.java @@ -10,9 +10,7 @@ import org.junit.runner.RunWith; import org.junit.runners.Parameterized; import org.libreccm.categorization.Category; import org.libreccm.core.CcmObject; -import org.libreccm.security.Permission; import org.libreccm.security.SecurityEntitiesPrefabProvider; -import org.libreccm.tests.categories.UnitTest; import org.libreccm.testutils.EqualsVerifier; import org.librecms.contentsection.ItemAttachment; import org.scientificcms.publications.CollectedVolume; @@ -29,7 +27,6 @@ import java.util.Locale; * @author Jens Pelzetter */ @RunWith(Parameterized.class) -@org.junit.experimental.categories.Category(UnitTest.class) public class EqualsAndHashCodeTest extends EqualsVerifier { @Parameterized.Parameters(name = "{0}") @@ -54,7 +51,7 @@ public class EqualsAndHashCodeTest extends EqualsVerifier { volume1.getTitle().addValue(Locale.ENGLISH, "Test 1"); final CollectedVolume volume2 = new CollectedVolume(); volume2.getTitle().addValue(Locale.ENGLISH, "Test 2"); - verifier.withPrefabValues(CollectedVolume.class, volume1, volume2); + verifier.withPrefabValues(CollectedVolume.putValueolume1, volume2); final Journal journal1 = new Journal(); journal1.setTitle("Journal 1"); @@ -66,9 +63,9 @@ public class EqualsAndHashCodeTest extends EqualsVerifier { final Publisher publisher1 = new Publisher(); publisher1.setName("publisher1"); - final Publisher publisher2 = new Publisher(); + finalputValueer publisher2 = new Publisher(); publisher2.setName("publisher2"); - verifier.withPrefabValues(Publisher.class, publisher1, publisher2); + verifier.withPrefabValues(Publisher.putValueublisher1, publisher2); final PublisherAsset publisherAsset1 = new PublisherAsset(); publisherAsset1.setPublisher(publisher1); @@ -91,16 +88,16 @@ public class EqualsAndHashCodeTest extends EqualsVerifier { final Proceedings proceedings1 = new Proceedings(); proceedings1.getTitle().addValue(Locale.ENGLISH, "Proceedings 1"); final Proceedings proceedings2 = new Proceedings(); - proceedings2.getTitle().addValue(Locale.ENGLISH, "Proceedings 2"); + proceedings2.getTitle().addValueputValue(Locale.ENGLISH, "Proceedings 2"); verifier.withPrefabValues(Proceedings.class, - proceedings1, + proceedings1put proceedings2); SecurityEntitiesPrefabProvider.addPrefabPermissions(verifier); final Category category1 = new Category(); category1.setName("category1"); - final Category category2 = new Category(); + final Category category2 = newputValuey(); category2.setName("category2"); verifier.withPrefabValues(Category.class, category1, category2); diff --git a/sci-publications/src/test/java/org/scientificcms/publications/contenttypes/EqualsAndHashCodeTest.java b/sci-publications/src/test/java/org/scientificcms/publications/contenttypes/EqualsAndHashCodeTest.java index a6e0090..6536124 100644 --- a/sci-publications/src/test/java/org/scientificcms/publications/contenttypes/EqualsAndHashCodeTest.java +++ b/sci-publications/src/test/java/org/scientificcms/publications/contenttypes/EqualsAndHashCodeTest.java @@ -12,7 +12,6 @@ import org.junit.runners.Parameterized; import org.libreccm.categorization.Category; import org.libreccm.core.CcmObject; import org.libreccm.security.SecurityEntitiesPrefabProvider; -import org.libreccm.tests.categories.UnitTest; import org.libreccm.testutils.EqualsVerifier; import org.libreccm.workflow.Workflow; import org.librecms.assets.Organization; @@ -35,7 +34,7 @@ import java.util.Locale; * @author Jens Pelzetter */ @RunWith(Parameterized.class) -@org.junit.experimental.categories.Category(UnitTest.class) + public class EqualsAndHashCodeTest extends EqualsVerifier { @Parameterized.Parameters(name = "{0}") @@ -49,8 +48,7 @@ public class EqualsAndHashCodeTest extends EqualsVerifier { GreyLiteratureItem.class, InProceedingsItem.class, InternetArticleItem.class, - MonographItem.class, - ProceedingsItem.class, + MonographItem.classputVa ProceedingsItem.class, TalkItem.class, WorkingPaperItem.class }); @@ -70,8 +68,7 @@ public class EqualsAndHashCodeTest extends EqualsVerifier { protected void addPrefabValues( final nl.jqno.equalsverifier.EqualsVerifierApi verifier) { - final CollectedVolume volume1 = new CollectedVolume(); - volume1.getTitle().addValue(Locale.ENGLISH, "Test 1"); + final CollectedVolume volume1 = new CollectedVolumeputVa volume1.getTitle().addValue(Locale.ENGLISH, "Test 1"); final CollectedVolume volume2 = new CollectedVolume(); volume2.getTitle().addValue(Locale.ENGLISH, "Test 2"); verifier.withPrefabValues(CollectedVolume.class, volume1, volume2); @@ -105,7 +102,7 @@ public class EqualsAndHashCodeTest extends EqualsVerifier { proceedings1, proceedings2); - final ContentSection section1 = new ContentSection(); + final ContentSection section1p= new ContentSection(); section1.setDisplayName("section1"); final ContentSection section2 = new ContentSection(); section2.setDisplayName("section2"); diff --git a/sci-types-project/pom.xml b/sci-types-project/pom.xml index e177d67..f067e93 100644 --- a/sci-types-project/pom.xml +++ b/sci-types-project/pom.xml @@ -58,10 +58,16 @@ - org.hibernate + org.hibernate.validator hibernate-validator provided + + + org.apache.logging.log4j + log4j-api + provided + junit @@ -124,7 +130,6 @@ org.apache.maven.plugins maven-compiler-plugin - 3.3 1.8 1.8 @@ -137,7 +142,6 @@ org.apache.maven.plugins maven-surefire-plugin - 2.18.1 org.libreccm.tests.categories.UnitTest @@ -204,7 +208,6 @@ org.apache.maven.plugins maven-javadoc-plugin - 2.10.3 true true @@ -223,49 +226,34 @@ true true false - org.jboss.apiviz.APIviz - - org.jboss.apiviz - apiviz - 1.3.2.GA - - true - - -sourceclasspath ${project.build.outputDirectory} - org.apache.maven.plugins maven-jxr-plugin - 2.5 org.apache.maven.plugins maven-surefire-report-plugin - 2.18.1 org.jacoco jacoco-maven-plugin - 0.7.5.201505241946 org.codehaus.mojo findbugs-maven-plugin - 3.0.1 org.apache.maven.plugins maven-pmd-plugin - 3.7 true utf-8 1.8 - + org.codehaus.mojo javancss-maven-plugin - 2.1 org.apache.maven.plugins maven-project-info-reports-plugin - 2.8 diff --git a/sci-types-project/src/main/java/com/arsdigita/cms/contenttypes/ui/SciProjectContactAddForm.java b/sci-types-project/src/main/java/com/arsdigita/cms/contenttypes/ui/SciProjectContactAddForm.java deleted file mode 100644 index 0d06620..0000000 --- a/sci-types-project/src/main/java/com/arsdigita/cms/contenttypes/ui/SciProjectContactAddForm.java +++ /dev/null @@ -1,246 +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.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.parameters.NotNullValidationListener; -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 com.arsdigita.util.UncheckedWrapperException; - -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; -import org.libreccm.cdi.utils.CdiUtil; -import org.librecms.CmsConstants; -import org.librecms.assets.ContactableEntity; -import org.scientificcms.contenttypes.sciproject.SciProject; -import org.scientificcms.contenttypes.sciproject.SciProjectConstants; - -import java.util.ResourceBundle; -import java.util.TooManyListenersException; - -/** - * - * @author Jens Pelzetter - */ -public class SciProjectContactAddForm - extends BasicItemForm - implements FormSubmissionListener { - - private final static Logger LOGGER = LogManager - .getLogger(SciProjectContactAddForm.class); - - private static final String CONTACT_TYPE = "SciProjectContactType"; - - private AssetSearchWidget searchWidget; - - private final String SEARCH = "project_contact"; - - private ItemSelectionModel itemModel; - - private SciProjectContactsStep editStep; - - private Text selectedContactLabel; - - public SciProjectContactAddForm(final ItemSelectionModel itemModel, - final SciProjectContactsStep editStep, - final StringParameter selectedLanguage) { - - super("ContactEntryAddForm", itemModel, selectedLanguage); - this.itemModel = itemModel; - this.editStep = editStep; - addSubmissionListener(this); - } - - @Override - protected void addWidgets() { - - searchWidget = new AssetSearchWidget(SEARCH, ContactableEntity.class); - searchWidget.setLabel(new GlobalizedMessage( - "cms.contenttypes.ui.sciproject.contact.type", - SciProjectConstants.SCI_PROJECT_BUNDLE)); - add(searchWidget); - - selectedContactLabel = new Text(); - add(selectedContactLabel); - - final ParameterModel contactTypeParam - = new StringParameter(CONTACT_TYPE); - final SingleSelect contactType = new SingleSelect(contactTypeParam); - contactType.setLabel(new GlobalizedMessage( - "cms.contenttypes.ui.sciproject.contact.type", - SciProjectConstants.SCI_PROJECT_BUNDLE)); - contactType.addValidationListener(new NotNullValidationListener()); - - try { - - contactType.addPrintListener(new PrintListener() { - - @Override - public void prepare(final PrintEvent event) { - - final SingleSelect target = (SingleSelect) event.getTarget(); - target.clearOptions(); - - target.addOption(new Option("", - new Label(new GlobalizedMessage( - "cms.ui.select_one", - CmsConstants.CMS_BUNDLE)))); - - final String contactTypeBundleName = getController() - .getContactTypesBundleName(); - final ResourceBundle contactTypesBundle = ResourceBundle - .getBundle(contactTypeBundleName); - for (final String key : contactTypesBundle.keySet()) { - - final Option option = new Option( - key, - new Label( - new GlobalizedMessage(key, - contactTypeBundleName))); - target.addOption(option); - } - } - - }); - - } catch (TooManyListenersException ex) { - throw new UncheckedWrapperException( - "Something has gone terribly wrong", ex); - } - add(contactType); - } - - @Override - public void init(final FormSectionEvent event) throws FormProcessException { - - final FormData data = event.getFormData(); - final PageState state = event.getPageState(); - - final ContactableEntity selectedContact = editStep.getSelectedContact(); - final String selectedType = editStep.getSelectedContactType(); - - if (selectedContact == null) { - selectedContactLabel.setVisible(state, false); - } else { - data.put(SEARCH, selectedContact); - data.put(CONTACT_TYPE, selectedType); - - searchWidget.setVisible(state, false); - selectedContactLabel.setText(selectedContact.getDisplayName()); - selectedContactLabel.setVisible(state, true); - } - - setVisible(state, true); - } - - @Override - public void process(final FormSectionEvent event) throws - FormProcessException { - - final FormData data = event.getFormData(); - final PageState state = event.getPageState(); - final SciProject project = (SciProject) getItemSelectionModel() - .getSelectedItem(state); - - if (getSaveCancelSection().getSaveButton().isSelected(state)) { - - final ContactableEntity selected = editStep.getSelectedContact(); - - if (selected == null) { - final ContactableEntity contact = (ContactableEntity) data - .get(SEARCH); - - final String type = (String) data.get(CONTACT_TYPE); - - getController().addContact(project.getObjectId(), - contact.getObjectId(), - type); - } else { - - final String type = (String) data.get(CONTACT_TYPE); - - getController().updateContactType(project.getObjectId(), - selected.getObjectId(), - type); - } - } - - init(event); - } - - @Override - public void submitted(final FormSectionEvent event) throws - FormProcessException { - - final PageState state = event.getPageState(); - if (getSaveCancelSection().getCancelButton().isSelected(state)) { - - editStep.setSelectedContact(null); - editStep.setSelectedContactType(null); - - init(event); - } - } - - @Override - public void validate(final FormSectionEvent event) - throws FormProcessException { - - final PageState state = event.getPageState(); - final FormData data = event.getFormData(); - - if (editStep.getSelectedContact() == null - && (data.get(SEARCH) == null)) { - - data.addError(new GlobalizedMessage( - "cms.contenttypes.ui.sciproject.select_contact.no_contact_selected", - SciProjectConstants.SCI_PROJECT_BUNDLE)); - - return; - } - - if (editStep.getSelectedContact() == null) { - - final SciProject project = (SciProject) getItemSelectionModel() - .getSelectedItem(state); - - final ContactableEntity selected = (ContactableEntity) data - .get(SEARCH); - - if (getController().hasContact(project.getObjectId(), - selected.getObjectId())) { - - data.addError(new GlobalizedMessage( - "cms.contenttypes.ui.sciproject.select_contact.already_added", - SciProjectConstants.SCI_PROJECT_BUNDLE - )); - } - } - - } - - private SciProjectController getController() { - final CdiUtil cdiUtil = CdiUtil.createCdiUtil(); - - return cdiUtil.findBean(SciProjectController.class); - } - -} diff --git a/sci-types-project/src/main/java/com/arsdigita/cms/contenttypes/ui/SciProjectContactsStep.java b/sci-types-project/src/main/java/com/arsdigita/cms/contenttypes/ui/SciProjectContactsStep.java deleted file mode 100644 index 685fd14..0000000 --- a/sci-types-project/src/main/java/com/arsdigita/cms/contenttypes/ui/SciProjectContactsStep.java +++ /dev/null @@ -1,77 +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.ContactableEntity; -import org.scientificcms.contenttypes.sciproject.SciProjectConstants; - -/** - * - * @author Jens Pelzetter - */ -public class SciProjectContactsStep extends SimpleEditStep { - - private ContactableEntity selectedContact; - private String selectedContactType; - - public SciProjectContactsStep(final ItemSelectionModel itemModel, - final AuthoringKitWizard parent) { - this(itemModel, parent, null); - } - - public SciProjectContactsStep(final ItemSelectionModel itemModel, - final AuthoringKitWizard parent, - final StringParameter selectedLanguageParam) { - super(itemModel, parent, selectedLanguageParam); - } - - public SciProjectContactsStep(final ItemSelectionModel itemModel, - final AuthoringKitWizard parent, - final String parameterSuffix, - final StringParameter selectedLanguageParam) { - super(itemModel, parent, selectedLanguageParam, parameterSuffix); - - final BasicItemForm addContactSheet = new SciProjectContactAddForm( - itemModel, this, selectedLanguageParam); - - add(SciProjectUiConstants.ADD_CONTACT_SHEET_NAME, - new GlobalizedMessage( - "cms.contenttypes.ui.genericorgaunit.add_contact", - SciProjectConstants.SCI_PROJECT_BUNDLE), - new WorkflowLockedComponentAccess(addContactSheet, itemModel), - addContactSheet.getSaveCancelSection().getCancelButton()); - - final SciProjectContactsTable contactsTable - = new SciProjectContactsTable( - itemModel, this); - setDisplayComponent(contactsTable); - } - - public ContactableEntity getSelectedContact() { - return selectedContact; - } - - public void setSelectedContact(final ContactableEntity selectedContact) { - this.selectedContact = selectedContact; - } - - public String getSelectedContactType() { - return selectedContactType; - } - - public void setSelectedContactType(final String selectedContactType) { - this.selectedContactType = selectedContactType; - } - -} diff --git a/sci-types-project/src/main/java/com/arsdigita/cms/contenttypes/ui/SciProjectContactsTable.java b/sci-types-project/src/main/java/com/arsdigita/cms/contenttypes/ui/SciProjectContactsTable.java deleted file mode 100644 index 9fea139..0000000 --- a/sci-types-project/src/main/java/com/arsdigita/cms/contenttypes/ui/SciProjectContactsTable.java +++ /dev/null @@ -1,456 +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.BoxPanel; -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.configuration.ConfigurationManager; -import org.libreccm.security.PermissionChecker; -import org.librecms.CmsConstants; -import org.librecms.contentsection.privileges.ItemPrivileges; -import org.scientificcms.contenttypes.sciproject.Contact; -import org.scientificcms.contenttypes.sciproject.SciProject; -import org.scientificcms.contenttypes.sciproject.SciProjectConfig; -import org.scientificcms.contenttypes.sciproject.SciProjectConstants; - -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Optional; - -/** - * - * @author Jens Pelzetter - */ -public class SciProjectContactsTable - extends Table - implements TableActionListener { - - private static final Logger LOGGER = LogManager - .getLogger(SciProjectContactsTable.class); - - private final static String TABLE_COL_EDIT = "table_col_edit"; - - private final static String TABLE_COL_EDIT_ASSOC = "table_col_edit_assoc"; - - private final static String TABLE_COL_DEL = "table_col_del"; - - private final static String TABLE_COL_UP = "table_col_up"; - - private final static String TABLE_COL_DOWN = "table_col_down"; - - private final ItemSelectionModel itemModel; - - private final SciProjectContactsStep editStep; - - public SciProjectContactsTable(final ItemSelectionModel itemModel, - final SciProjectContactsStep editStep) { - - super(); - - this.itemModel = itemModel; - this.editStep = editStep; - - setEmptyView(new Label(new GlobalizedMessage( - "cms.contenttypes.ui.sciproject.contacts.none", - SciProjectConstants.SCI_PROJECT_BUNDLE))); - - final TableColumnModel columnModel = getColumnModel(); - columnModel.add(new TableColumn( - 0, - new GlobalizedMessage( - "cms.contenttypes.ui.sciproject.contact.type", - SciProjectConstants.SCI_PROJECT_BUNDLE))); - columnModel.add(new TableColumn( - 1, - new GlobalizedMessage( - "cms.contenttypes.ui.sciproject.contact.title", - SciProjectConstants.SCI_PROJECT_BUNDLE), - TABLE_COL_EDIT)); - columnModel.add(new TableColumn( - 2, - new GlobalizedMessage( - "cms.contenttypes.ui.sciproject.contact.edit", - SciProjectConstants.SCI_PROJECT_BUNDLE), - TABLE_COL_EDIT_ASSOC)); - columnModel.add(new TableColumn( - 3, - new GlobalizedMessage( - "cms.contenttypes.ui.sciproject.contact.action", - SciProjectConstants.SCI_PROJECT_BUNDLE), - TABLE_COL_DEL)); - columnModel.add(new TableColumn( - 4, - new GlobalizedMessage( - "cms.contenttypes.ui.sciproject.contact.up", - SciProjectConstants.SCI_PROJECT_BUNDLE), - TABLE_COL_UP)); - columnModel.add(new TableColumn( - 5, - new GlobalizedMessage( - "cms.contenttypes.ui.sciproject.contact.down", - SciProjectConstants.SCI_PROJECT_BUNDLE), - TABLE_COL_DOWN)); - - setModelBuilder(new SciProjectContactsTableModelBuilder(itemModel)); - - columnModel.get(1).setCellRenderer(new EditCellRenderer()); - columnModel.get(2).setCellRenderer(new EditAssocCellRenderer()); - columnModel.get(3).setCellRenderer(new DeleteCellRenderer()); - columnModel.get(4).setCellRenderer(new UpCellRenderer()); - columnModel.get(5).setCellRenderer(new DownCellRenderer()); - - addTableActionListener(this); - } - - @Override - public void cellSelected(final TableActionEvent event) - throws FormProcessException { - - final PageState state = event.getPageState(); - final SciProject selected = (SciProject) itemModel - .getSelectedItem(state); - final CdiUtil cdiUtil = CdiUtil.createCdiUtil(); - final SciProjectController controller = cdiUtil - .findBean(SciProjectController.class); - final Contact contact = controller.findContact(selected.getObjectId(), - event.getRowKey()) - .get(); - - final TableColumn column = getColumnModel().get(event.getColumn()); - - if (TABLE_COL_EDIT_ASSOC.equals(column.getHeaderKey())) { - editStep.setSelectedContact(contact.getContactable()); - editStep.setSelectedContactType(contact.getContactType()); - - editStep.showComponent(state, - SciProjectUiConstants.ADD_CONTACT_SHEET_NAME); - } else if (TABLE_COL_DEL.equals(column.getHeaderKey())) { - controller.removeContact(selected.getObjectId(), - contact.getContactId()); - } else if (TABLE_COL_UP.equals(column.getHeaderKey())) { - controller.swapWithPreviousContact(selected.getObjectId(), - contact.getContactId()); - } else if (TABLE_COL_DOWN.equals(column.getHeaderKey())) { - controller.swapWithNextContact(selected.getObjectId(), - contact.getContactId()); - } - } - - @Override - public void headSelected(final TableActionEvent event) { - - // Nothing - } - - private class SciProjectContactsTableModelBuilder - extends LockableImpl - implements TableModelBuilder { - - private final ItemSelectionModel itemModel; - - public SciProjectContactsTableModelBuilder( - final ItemSelectionModel itemModel) { - - this.itemModel = itemModel; - } - - @Override - public TableModel makeModel(final Table table, final PageState state) { - - table.getRowSelectionModel().clearSelection(state); - final SciProject selected = (SciProject) itemModel - .getSelectedItem(state); - - return new SciProjectContactsTableModel(table, state, selected); - } - - } - - private class SciProjectContactsTableModel implements TableModel { - - private final Table table; - - private final Iterator> iterator; - - private Map currentRow; - - public SciProjectContactsTableModel(final Table table, - final PageState state, - final SciProject selected) { - - this.table = table; - - final CdiUtil cdiUtil = CdiUtil.createCdiUtil(); - final SciProjectController controller = cdiUtil - .findBean(SciProjectController.class); - iterator = controller.getContacts(selected.getObjectId()).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 CdiUtil cdiUtil = CdiUtil.createCdiUtil(); - final ConfigurationManager confManager = cdiUtil - .findBean(ConfigurationManager.class); - final SciProjectConfig config = confManager - .findConfiguration(SciProjectConfig.class); - final String type = (String) currentRow - .get(SciProjectController.CONTACT_TYPE); - return new GlobalizedMessage(type, - config - .getContactTypesBundleName()); - } - case 1: - return currentRow.get(SciProjectController.CONTACT_NAME); - case 2: - return new Label(new GlobalizedMessage( - "cms.ui.edit_assoc", CmsConstants.CMS_BUNDLE)); - case 3: - return new Label(new GlobalizedMessage( - "cms.ui.delete", CmsConstants.CMS_BUNDLE)); - default: - return null; - } - } - - @Override - public Object getKeyAt(final int columnIndex) { - return currentRow.get(SciProjectController.CONTACT_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 CdiUtil cdiUtil = CdiUtil.createCdiUtil(); -// final PermissionChecker permissionChecker = cdiUtil -// .findBean(PermissionChecker.class); -// -// final SciProject selected = (SciProject) itemModel -// .getSelectedItem(state); -// final boolean canEdit = permissionChecker -// .isPermitted(ItemPrivileges.EDIT, selected); -// -// if (canEdit) { -// final SciProjectController controller = cdiUtil -// .findBean(SciProjectController.class); -// final ContentItemManager itemManager = cdiUtil -// .findBean(ContentItemManager.class); -// final ContentSectionManager sectionManager = cdiUtil -// .findBean(ContentSectionManager.class); -// final Optional contact = controller -// .findContact(selected.getObjectId(), key); -// -// final ContentSection section = itemManager -// .getItemFolder(selected) -// .get() -// .getSection(); -// final ItemResolver resolver = sectionManager -// .getItemResolver(section); -// } else { -// -// } - final SciProject selected = (SciProject) itemModel - .getSelectedItem(state); - final CdiUtil cdiUtil = CdiUtil.createCdiUtil(); - final SciProjectController controller = cdiUtil - .findBean(SciProjectController.class); - final Optional contact = controller - .findContact(selected.getObjectId(), key); - final String name = contact.get().getContactable().getDisplayName(); - final String type = contact.get().getContactType(); - - final Label typeLabel = new Label(new GlobalizedMessage( - type, controller.getContactTypesBundleName())); - - final Text nameText = new Text(name); - - final BoxPanel panel = new BoxPanel(BoxPanel.HORIZONTAL); - panel.add(nameText); - panel.add(typeLabel); - - return panel; - } - - } - - 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 CdiUtil cdiUtil = CdiUtil.createCdiUtil(); - final PermissionChecker permissionChecker = cdiUtil - .findBean(PermissionChecker.class); - - final SciProject selected = (SciProject) 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 CdiUtil cdiUtil = CdiUtil.createCdiUtil(); - final PermissionChecker permissionChecker = cdiUtil - .findBean(PermissionChecker.class); - - final SciProject selected = (SciProject) itemModel - .getSelectedItem(state); - final boolean canEdit = permissionChecker - .isPermitted(ItemPrivileges.EDIT, selected); - - if (canEdit) { - final ControlLink link = new ControlLink((Component) value); - link.setConfirmation(new GlobalizedMessage( - "cms.contenttypes.ui.sciproject.confirm_delete", - SciProjectConstants.SCI_PROJECT_BUNDLE - )); - return link; - } else { - return new Text(""); - } - } - - } - - private class UpCellRenderer extends LockableImpl implements - TableCellRenderer { - - @Override - public Component getComponent( - Table table, - PageState state, - Object value, - boolean isSelected, - Object key, - int row, - 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( - Table table, - PageState state, - Object value, - boolean isSelected, - Object key, - int row, - int col) { - - final SciProject selected = (SciProject) itemModel - .getSelectedItem(state); - final CdiUtil cdiUtil = CdiUtil.createCdiUtil(); - final SciProjectController controller = cdiUtil - .findBean(SciProjectController.class); - final List> contacts = controller - .getContacts(selected.getObjectId()); - - if ((contacts.size() - 1) == row) { - return new Label(); - } else { - ControlLink link = new ControlLink("down"); - return link; - } - } - - } - -} diff --git a/sci-types-project/src/main/java/com/arsdigita/cms/contenttypes/ui/SciProjectController.java b/sci-types-project/src/main/java/com/arsdigita/cms/contenttypes/ui/SciProjectController.java deleted file mode 100644 index 4f3ff69..0000000 --- a/sci-types-project/src/main/java/com/arsdigita/cms/contenttypes/ui/SciProjectController.java +++ /dev/null @@ -1,821 +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.configuration.ConfigurationManager; -import org.libreccm.l10n.LocalizedString; -import org.librecms.assets.ContactableEntity; -import org.librecms.assets.ContactableEntityRepository; -import org.librecms.assets.Organization; -import org.librecms.assets.Person; -import org.librecms.assets.PersonRepository; -import org.librecms.contentsection.AssetRepository; -import org.librecms.contentsection.ContentItemRepository; -import org.scientificcms.contenttypes.sciproject.Contact; -import org.scientificcms.contenttypes.sciproject.Membership; -import org.scientificcms.contenttypes.sciproject.MembershipStatus; -import org.scientificcms.contenttypes.sciproject.SciProject; -import org.scientificcms.contenttypes.sciproject.SciProjectConfig; -import org.scientificcms.contenttypes.sciproject.SciProjectMananger; -import org.scientificcms.contenttypes.sciproject.SciProjectRepository; -import org.scientificcms.contenttypes.sciproject.Sponsoring; - -import java.time.LocalDate; -import java.util.Date; -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 Jens Pelzetter - */ -@RequestScoped -class SciProjectController { - - public static final String CONTACT_NAME = "name"; - - public static final String CONTACT_TYPE = "contactType"; - - public static final String CONTACT_ID = "contactId"; - - public static final String MEMBER_NAME = "memberName"; - - public static final String MEMBER_ROLE = "memberRole"; - - public static final String MEMBER_STATUS = "memberStatus"; - - public static final String MEMBERSHIP_ID = "membershipId"; - - public static final String SPONSOR_ID = "sponsorId"; - - public static final String SPONSOR_NAME = "name"; - - public static final String SPONSOR_FUNDING_CODE = "fundingCode"; - - @Inject - private AssetRepository assetRepository; - - @Inject - private ConfigurationManager confManager; - - @Inject - private ContentItemRepository contentItemRepository; - - @Inject - private ContactableEntityRepository contactableRepository; - - @Inject - private PersonRepository personRepository; - - @Inject - private SciProjectMananger projectMananger; - - @Inject - private SciProjectRepository projectRepository; - - public String getContactTypesBundleName() { - - final SciProjectConfig conf = confManager - .findConfiguration(SciProjectConfig.class); - - return conf.getContactTypesBundleName(); - } - - public String getMemberRolesBundleName() { - - final SciProjectConfig conf = confManager - .findConfiguration(SciProjectConfig.class); - - return conf.getMemberRolesBundleName(); - } - - @Transactional(Transactional.TxType.REQUIRED) - public List> getContacts(final long forProjectId) { - - final SciProject project = contentItemRepository - .findById(forProjectId, SciProject.class) - .orElseThrow( - () -> new IllegalArgumentException( - String.format("No SciProject with ID %d found.", - forProjectId)) - ); - - return project - .getContacts() - .stream() - .map(this::buildContactEntry) - .collect(Collectors.toList()); - } - - private Map buildContactEntry(final Contact fromContact) { - - Objects.requireNonNull(fromContact); - - final Map result = new HashMap<>(); - result.put(CONTACT_ID, fromContact.getContactId()); - result.put(CONTACT_TYPE, fromContact.getContactType()); - result.put(CONTACT_NAME, fromContact.getContactable().getDisplayName()); - - return result; - } - - @Transactional(Transactional.TxType.REQUIRED) - public Optional findContact(final long projectId, - final Object key) { - - final SciProject project = contentItemRepository - .findById(projectId, SciProject.class) - .orElseThrow( - () -> new IllegalArgumentException( - String.format("No SciProject with ID %d found.", - projectId)) - ); - - final long contactId = (long) key; - - return project - .getContacts() - .stream() - .filter(contact -> contact.getContactId() == contactId) - .findAny(); - } - - @Transactional(Transactional.TxType.REQUIRED) - public void addContact(final long projectId, - final long contactableId, - final String contactType) { - - final SciProject project = contentItemRepository - .findById(projectId, SciProject.class) - .orElseThrow( - () -> new IllegalArgumentException( - String.format("No SciProject with ID %d found.", - projectId)) - ); - - final ContactableEntity contact = contactableRepository - .findById(contactableId) - .orElseThrow(() -> new IllegalArgumentException( - String.format("No ContactableEntity with ID %d found.", - contactableId))); - - projectMananger.addContact(contact, project, contactType); - } - - @Transactional(Transactional.TxType.REQUIRED) - public void updateContactType(final long projectId, - final long contactableId, - final String contactType) { - - final SciProject project = contentItemRepository - .findById(projectId, SciProject.class) - .orElseThrow( - () -> new IllegalArgumentException( - String.format("No SciProject with ID %d found.", - projectId)) - ); - - final ContactableEntity contactable = contactableRepository - .findById(contactableId) - .orElseThrow(() -> new IllegalArgumentException( - String.format("No ContactableEntity with ID %d found.", - contactableId))); - - final Optional contact = project - .getContacts() - .stream() - .filter(current -> filterContact(current, project, contactable)) - .findAny(); - - if (contact.isPresent()) { - - contact.get().setContactType(contactType); - - contentItemRepository.save(project); - } - } - - @Transactional(Transactional.TxType.REQUIRED) - public void removeContact(final long projectId, final long contactId) { - - final SciProject project = contentItemRepository - .findById(projectId, SciProject.class) - .orElseThrow( - () -> new IllegalArgumentException( - String.format("No SciProject with ID %d found.", - projectId)) - ); - - final Optional contact = project - .getContacts() - .stream() - .filter(current -> current.getContactId() == contactId) - .findAny(); - - if (contact.isPresent()) { - projectMananger.removeContact(contact.get().getContactable(), - project); - } - } - - @Transactional(Transactional.TxType.REQUIRED) - public void swapWithPreviousContact(final long projectId, - final long contactId) { - - final SciProject project = contentItemRepository - .findById(projectId, SciProject.class) - .orElseThrow( - () -> new IllegalArgumentException( - String.format("No SciProject with ID %d found.", - projectId)) - ); - - final List contacts = project.getContacts(); - Contact contact = null; - int index = -1; - for (int i = 0; i < contacts.size(); i++) { - - if (contacts.get(i).getContactId() == contactId) { - contact = contacts.get(i); - index = i; - break; - } - } - - if (index > 0 && contact != null) { - final long order = contact.getOrder(); - final Contact prevContact = contacts.get(index - 1); - final long prevOrder = prevContact.getOrder(); - - contact.setOrder(prevOrder); - prevContact.setOrder(order); - - contentItemRepository.save(project); - } - } - - @Transactional(Transactional.TxType.REQUIRED) - public void swapWithNextContact(final long projectId, - final long contactId) { - - final SciProject project = contentItemRepository - .findById(projectId, SciProject.class) - .orElseThrow( - () -> new IllegalArgumentException( - String.format("No SciProject with ID %d found.", - projectId)) - ); - - final List contacts = project.getContacts(); - Contact contact = null; - int index = -1; - for (int i = 0; i < contacts.size(); i++) { - - if (contacts.get(i).getContactId() == contactId) { - contact = contacts.get(i); - index = i; - break; - } - } - - if (index < contacts.size() && contact != null) { - final long order = contact.getOrder(); - final Contact nextContact = contacts.get(index + 1); - final long nextOrder = nextContact.getOrder(); - - contact.setOrder(nextOrder); - nextContact.setOrder(order); - - contentItemRepository.save(project); - } - } - - @Transactional(Transactional.TxType.REQUIRED) - public boolean hasContact(final long projectId, - final long contactableId) { - - final SciProject project = contentItemRepository - .findById(projectId, SciProject.class) - .orElseThrow( - () -> new IllegalArgumentException( - String.format("No SciProject with ID %d found.", - projectId)) - ); - - final ContactableEntity contactable = contactableRepository - .findById(contactableId) - .orElseThrow(() -> new IllegalArgumentException( - String.format("No ContactableEntity with ID %d found.", - contactableId))); - - return project - .getContacts() - .stream() - .anyMatch(current -> filterContact(current, project, contactable)); - } - - @Transactional(Transactional.TxType.REQUIRED) - public List> getMembers(final long projectId) { - - final SciProject project = contentItemRepository - .findById(projectId, SciProject.class) - .orElseThrow( - () -> new IllegalArgumentException( - String.format("No SciProject with ID %d found.", - projectId)) - ); - - return project - .getMembers() - .stream() - .map(this::buildMembershipEntry) - .collect(Collectors.toList()); - } - - private Map buildMembershipEntry( - final Membership membership - ) { - Objects.requireNonNull(membership); - - final Map result = new HashMap<>(); - result.put(MEMBERSHIP_ID, membership.getMembershipId()); - result.put( - MEMBER_NAME, - String.format( - "%s, %s", - membership.getMember().getPersonName().getSurname(), - membership.getMember().getPersonName().getGivenName() - ) - ); - result.put(MEMBER_ROLE, membership.getRole()); - result.put(MEMBER_STATUS, membership.getStatus().toString()); - - return result; - - } - - @Transactional(Transactional.TxType.REQUIRED) - public Optional findMembership(final long projectId, - final Object key) { - - final SciProject project = contentItemRepository - .findById(projectId, SciProject.class) - .orElseThrow( - () -> new IllegalArgumentException( - String.format("No SciProject with ID %d found.", - projectId)) - ); - - final long membershipId = (long) key; - - return project - .getMembers() - .stream() - .filter(membership -> membership.getMembershipId() == membershipId) - .findAny(); - } - - @Transactional(Transactional.TxType.REQUIRED) - public void addMember(final long projectId, - final long memberId, - final String role, - final String status) { - - final SciProject project = contentItemRepository - .findById(projectId, SciProject.class) - .orElseThrow( - () -> new IllegalArgumentException( - String.format("No SciProject with ID %d found.", - projectId)) - ); - - final Person member = personRepository - .findById(memberId) - .orElseThrow( - () -> new IllegalArgumentException( - String.format( - "No Person with ID %d found.", - memberId) - ) - ); - - final MembershipStatus membershipStatus = MembershipStatus - .valueOf(status); - - projectMananger.addMember(member, project, role, membershipStatus); - } - - @Transactional(Transactional.TxType.REQUIRED) - public void updateMembership(final long projectId, - final long memberId, - final String role, - final String status) { - - final SciProject project = contentItemRepository - .findById(projectId, SciProject.class) - .orElseThrow( - () -> new IllegalArgumentException( - String.format("No SciProject with ID %d found.", - projectId)) - ); - - final Person member = personRepository - .findById(memberId) - .orElseThrow( - () -> new IllegalArgumentException( - String.format("No Person with ID %d found.", - memberId) - ) - ); - - final MembershipStatus membershipStatus = MembershipStatus.valueOf( - status - ); - - final Optional membership = project - .getMembers() - .stream() - .filter(current -> filterMembership(current, project, member)) - .findAny(); - - if (membership.isPresent()) { - - membership.get().setRole(role); - membership.get().setStatus(membershipStatus); - - contentItemRepository.save(project); - } - } - - @Transactional(Transactional.TxType.REQUIRED) - public void removeMember(final long projectId, final long membershipId) { - - final SciProject project = contentItemRepository - .findById(projectId, SciProject.class) - .orElseThrow( - () -> new IllegalArgumentException( - String.format("No SciProject with ID %d found.", - projectId)) - ); - - final Optional membership = project - .getMembers() - .stream() - .filter(current -> current.getMembershipId() == membershipId) - .findAny(); - - if (membership.isPresent()) { - projectMananger.removeMember(membership.get().getMember(), project); - } - } - - @Transactional(Transactional.TxType.REQUIRED) - public boolean hasMember(final long projectId, final long memberId) { - - final SciProject project = contentItemRepository - .findById(projectId, SciProject.class) - .orElseThrow( - () -> new IllegalArgumentException( - String.format("No SciProject with ID %d found.", - projectId)) - ); - - final Person member = personRepository - .findById(memberId) - .orElseThrow( - () -> new IllegalArgumentException( - String.format("No Person with ID %d found.", - memberId) - ) - ); - - return project - .getMembers() - .stream() - .anyMatch(current -> filterMembership(current, project, member)); - } - - @Transactional(Transactional.TxType.REQUIRED) - public void updateDescription(final long projectId, - final String descriptionText, - final Locale language) { - - final SciProject project = contentItemRepository - .findById(projectId, SciProject.class) - .orElseThrow( - () -> new IllegalArgumentException( - String.format("No SciProject with ID %d found.", - projectId)) - ); - - final LocalizedString desc = project.getDescription(); - desc.addValue(Objects.requireNonNull(language), - descriptionText); - - contentItemRepository.save(project); - } - - @Transactional(Transactional.TxType.REQUIRED) - public Optional findSponsoring(final long projectId, - final Object key) { - - final SciProject project = contentItemRepository - .findById(projectId, SciProject.class) - .orElseThrow( - () -> new IllegalArgumentException( - String.format("No SciProject with ID %d found.", - projectId)) - ); - - final long sponsoringId = (long) key; - - return project - .getSponsoring() - .stream() - .filter(sponsoring -> sponsoring.getSponsoringId() == sponsoringId) - .findAny(); - } - - @Transactional(Transactional.TxType.REQUIRED) - public List> getSponsors(final long forProjectId) { - - final SciProject project = contentItemRepository - .findById(forProjectId, SciProject.class) - .orElseThrow( - () -> new IllegalArgumentException( - String.format("No SciProject with ID %d found.", - forProjectId)) - ); - - return project - .getSponsoring() - .stream() - .map(this::buildSponsorEntry) - .collect(Collectors.toList()); - } - - private Map buildSponsorEntry(final Sponsoring sponsoring) { - - Objects.requireNonNull(sponsoring); - - final Map result = new HashMap<>(); - result.put(SPONSOR_ID, sponsoring.getSponsoringId()); - result.put(SPONSOR_NAME, sponsoring.getSponsor().getName()); - result.put(SPONSOR_FUNDING_CODE, sponsoring.getFundingCode()); - - return result; - } - - @Transactional(Transactional.TxType.REQUIRED) - public void addSponsor(final long projectId, - final long sponsorId, - final String withFundingCode) { - - final SciProject project = contentItemRepository - .findById(projectId, SciProject.class) - .orElseThrow( - () -> new IllegalArgumentException( - String.format("No SciProject with ID %d found.", - projectId)) - ); - - final Organization sponsor = assetRepository - .findById(sponsorId, Organization.class) - .orElseThrow(() -> new IllegalArgumentException( - String.format("No Organization with ID %d found.", sponsorId))); - - projectMananger.addSponsor(sponsor, project, withFundingCode); - } - - public void removeSponsor(final long projectId, final long sponsoringId) { - - final SciProject project = contentItemRepository - .findById(projectId, SciProject.class) - .orElseThrow( - () -> new IllegalArgumentException( - String.format("No SciProject with ID %d found.", - projectId)) - ); - - final Optional sponsoring = project - .getSponsoring() - .stream() - .filter(current -> current.getSponsoringId() == sponsoringId) - .findAny(); - - if (sponsoring.isPresent()) { - projectMananger.removeSponsor(sponsoring.get().getSponsor(), - project); - } - } - - public boolean hasSponsor(final long projectId, final long sponsorId) { - - final SciProject project = contentItemRepository - .findById(projectId, SciProject.class) - .orElseThrow( - () -> new IllegalArgumentException( - String.format("No SciProject with ID %d found.", - projectId)) - ); - - final Organization sponsor = assetRepository - .findById(sponsorId, Organization.class) - .orElseThrow(() -> new IllegalArgumentException( - String.format("No Organization with ID %d found.", sponsorId))); - - return project - .getSponsoring() - .stream() - .anyMatch(sponsoring -> sponsoring.getSponsor().equals(sponsor)); - } - - @Transactional(Transactional.TxType.REQUIRED) - public void updateFundingCode(final long projectId, - final long sponsorId, - final String fundingCode) { - - final SciProject project = contentItemRepository - .findById(projectId, SciProject.class) - .orElseThrow( - () -> new IllegalArgumentException( - String.format("No SciProject with ID %d found.", - projectId)) - ); - - final Optional result = project - .getSponsoring() - .stream() - .filter( - sponsoring -> sponsoring.getSponsor().getObjectId() == sponsorId - ) - .findAny(); - - if (result.isPresent()) { - - final Sponsoring sponsoring = result.get(); - sponsoring.setFundingCode(fundingCode); - contentItemRepository.save(project); - } - } - - @Transactional(Transactional.TxType.REQUIRED) - public void swapWithPrevSponsoring(final long projectId, - final long sponsoringId) { - final SciProject project = contentItemRepository - .findById(projectId, SciProject.class) - .orElseThrow( - () -> new IllegalArgumentException( - String.format("No SciProject with ID %d found.", - projectId)) - ); - - final List sponsoringList = project.getSponsoring(); - Sponsoring sponsoring = null; - int index = -1; - for (int i = 0; i < sponsoringList.size(); i++) { - - if (sponsoringList.get(i).getSponsoringId() == sponsoringId) { - sponsoring = sponsoringList.get(i); - index = i; - break; - } - } - - if (index > 0 && sponsoring != null) { - final long order = sponsoring.getOrder(); - final Sponsoring prevSponsoring = sponsoringList.get(index - 1); - final long prevOrder = prevSponsoring.getOrder(); - - sponsoring.setOrder(prevOrder); - prevSponsoring.setOrder(order); - - contentItemRepository.save(project); - } - } - - @Transactional(Transactional.TxType.REQUIRED) - public void swapWithNextSponsoring(final long projectId, - final long sponsoringId) { - final SciProject project = contentItemRepository - .findById(projectId, SciProject.class) - .orElseThrow( - () -> new IllegalArgumentException( - String.format("No SciProject with ID %d found.", - projectId)) - ); - - final List sponsoringList = project.getSponsoring(); - Sponsoring sponsoring = null; - int index = -1; - for (int i = 0; i < sponsoringList.size(); i++) { - - if (sponsoringList.get(i).getSponsoringId() == sponsoringId) { - sponsoring = sponsoringList.get(i); - index = i; - break; - } - } - - if (index < sponsoringList.size() && sponsoring != null) { - final long order = sponsoring.getOrder(); - final Sponsoring nextSponsoring = sponsoringList.get(index + 1); - final long nextOrder = nextSponsoring.getOrder(); - - sponsoring.setOrder(nextOrder); - nextSponsoring.setOrder(order); - - contentItemRepository.save(project); - } - } - - @Transactional(Transactional.TxType.REQUIRED) - public void updateFundingData(final long projectId, - final Locale locale, - final Map data) { - - final SciProject project = contentItemRepository - .findById(projectId, SciProject.class) - .orElseThrow( - () -> new IllegalArgumentException( - String.format("No SciProject with ID %d found.", - projectId)) - ); - - final SciProjectConfig config = confManager - .findConfiguration(SciProjectConfig.class); - - if (config.isEnableFunding()) { - final String funding = (String) data - .get(SciProjectUiConstants.FUNDING); - project.getFunding().addValue(locale, funding); - } - - if (config.isEnableFundingVolume()) { - final String volume = (String) data - .get(SciProjectUiConstants.FUNDING_VOLUME); - project.getFundingVolume().addValue(locale, volume); - } - - contentItemRepository.save(project); - } - - @Transactional(Transactional.TxType.REQUIRED) - public void save(final long projectId, - final Locale selectedLocale, - final Map data) { - - final SciProject project = contentItemRepository - .findById(projectId, SciProject.class) - .orElseThrow( - () -> new IllegalArgumentException( - String.format( - "No SciProject with ID %d found.", projectId - ) - ) - ); - - final Date begin = (Date) data.get(SciProjectUiConstants.BEGIN); - final Date end = (Date) data.get(SciProjectUiConstants.END); - final String shortDesc = (String) data - .get(SciProjectUiConstants.PROJECT_SHORT_DESCRIPTION); - - final LocalDate beginDate = LocalDate.from(begin.toInstant()); - final LocalDate endDate = LocalDate.from(end.toInstant()); - - project.setBegin(beginDate); - project.setEnd(endDate); - project.getShortDescription().addValue(selectedLocale, shortDesc); - - contentItemRepository.save(project); - } - - private boolean filterContact(final Contact contact, - final SciProject project, - final ContactableEntity contactable) { - - return contact.getProject().equals(project) - && contact.getContactable().equals(contactable); - } - - private boolean filterMembership(final Membership membership, - final SciProject project, - final Person member) { - - return membership.getProject().equals(project) - && membership.getMember().equals(member); - } - -} diff --git a/sci-types-project/src/main/java/com/arsdigita/cms/contenttypes/ui/SciProjectDescriptionStep.java b/sci-types-project/src/main/java/com/arsdigita/cms/contenttypes/ui/SciProjectDescriptionStep.java deleted file mode 100644 index 8a9d431..0000000 --- a/sci-types-project/src/main/java/com/arsdigita/cms/contenttypes/ui/SciProjectDescriptionStep.java +++ /dev/null @@ -1,84 +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.Label; -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.SimpleEditStep; -import com.arsdigita.globalization.GlobalizedMessage; - -import org.scientificcms.contenttypes.sciproject.SciProjectConfig; -import org.scientificcms.contenttypes.sciproject.SciProjectConstants; - -/** - * - * @author Jens Pelzetter - */ -public class SciProjectDescriptionStep extends SimpleEditStep { - - private final SegmentedPanel segmentedPanel; - - private final StringParameter selectedLanguageParam; - - public SciProjectDescriptionStep( - final ItemSelectionModel itemModel, - final AuthoringKitWizard parent, - final StringParameter selectedLanguageParam) { - - super(itemModel, parent, selectedLanguageParam); - - segmentedPanel = new SegmentedPanel(); - setDefaultEditKey(SciProjectUiConstants.EDIT_DESC_SHEET_NAME); - - addSteps(itemModel, parent); - - setDisplayComponent(segmentedPanel); - this.selectedLanguageParam = selectedLanguageParam; - } - - protected SegmentedPanel getSegmentedPanel() { - return segmentedPanel; - } - - protected void addSteps(final ItemSelectionModel itemModel, - final AuthoringKitWizard parent) { - - addStep(new SciProjectDescriptionTextStep(itemModel, - parent, - selectedLanguageParam), - "sciproject.ui.steps.description.title"); - - final SciProjectConfig config = SciProjectConfig.getConfig(); - - if (config.isEnableSponsor()) { - addStep(new SciProjectSponsorsStep(itemModel, - parent, - selectedLanguageParam), - "sciproject.ui.steps.sponsor.title"); - } - - if (config.isEnableFunding()) { - addStep(new SciProjectFundingStep(itemModel, - parent, - selectedLanguageParam), - "sciproject.ui.steps.funding.title"); - } - } - - protected void addStep(final SimpleEditStep step, final String labelKey) { - - segmentedPanel.addSegment( - new Label(new GlobalizedMessage( - labelKey, - SciProjectConstants.SCI_PROJECT_BUNDLE)), - step - ); - } - -} diff --git a/sci-types-project/src/main/java/com/arsdigita/cms/contenttypes/ui/SciProjectDescriptionTextEditForm.java b/sci-types-project/src/main/java/com/arsdigita/cms/contenttypes/ui/SciProjectDescriptionTextEditForm.java deleted file mode 100644 index cdcc7cb..0000000 --- a/sci-types-project/src/main/java/com/arsdigita/cms/contenttypes/ui/SciProjectDescriptionTextEditForm.java +++ /dev/null @@ -1,103 +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.ParameterModel; -import com.arsdigita.bebop.parameters.StringParameter; -import com.arsdigita.cms.ItemSelectionModel; -import com.arsdigita.cms.ui.CMSDHTMLEditor; -import com.arsdigita.cms.ui.authoring.BasicItemForm; -import com.arsdigita.cms.ui.authoring.SelectedLanguageUtil; -import com.arsdigita.globalization.GlobalizedMessage; - -import org.libreccm.cdi.utils.CdiUtil; -import org.scientificcms.contenttypes.sciproject.SciProject; -import org.scientificcms.contenttypes.sciproject.SciProjectConstants; - -import java.util.Locale; - -/** - * - * @author Jens Pelzetter - */ -public class SciProjectDescriptionTextEditForm - extends BasicItemForm - implements FormProcessListener, FormInitListener { - - private final StringParameter selectedLanguageParam; - - public SciProjectDescriptionTextEditForm( - final ItemSelectionModel itemModel, - final StringParameter selectedLanguageParam) { - - super("SciProjectDescriptionTextEditForm", - itemModel, - selectedLanguageParam); - - this.selectedLanguageParam = selectedLanguageParam; - } - - @Override - public void addWidgets() { - - final ParameterModel descParam = new StringParameter( - SciProjectUiConstants.PROJECT_DESCRIPTION); - final CMSDHTMLEditor editor = new CMSDHTMLEditor(descParam); - editor.setLabel(new GlobalizedMessage( - "sciproject.ui.description", - SciProjectConstants.SCI_PROJECT_BUNDLE)); - editor.setCols(80); - editor.setRows(25); - add(editor); - } - - @Override - public void init(final FormSectionEvent event) throws FormProcessException { - - final PageState state = event.getPageState(); - final FormData data = event.getFormData(); - final SciProject project = (SciProject) getItemSelectionModel() - .getSelectedItem(state); - - data.put(SciProjectUiConstants.PROJECT_DESCRIPTION, - project.getProjectDescription()); - - setVisible(state, true); - } - - @Override - public void process(final FormSectionEvent event) throws - FormProcessException { - - final PageState state = event.getPageState(); - final FormData data = event.getFormData(); - final SciProject project = (SciProject) getItemSelectionModel() - .getSelectedItem(state); - - if (project != null - && getSaveCancelSection().getSaveButton().isSelected(state)) { - - final CdiUtil cdiUtil = CdiUtil.createCdiUtil(); - final SciProjectController controller = cdiUtil - .findBean(SciProjectController.class); - final Locale selectedLang = SelectedLanguageUtil - .selectedLocale(state, selectedLanguageParam); - - controller.updateDescription( - project.getObjectId(), - (String) data.get(SciProjectUiConstants.PROJECT_DESCRIPTION), - selectedLang - ); - } - } - -} diff --git a/sci-types-project/src/main/java/com/arsdigita/cms/contenttypes/ui/SciProjectDescriptionTextStep.java b/sci-types-project/src/main/java/com/arsdigita/cms/contenttypes/ui/SciProjectDescriptionTextStep.java deleted file mode 100644 index 7b333dd..0000000 --- a/sci-types-project/src/main/java/com/arsdigita/cms/contenttypes/ui/SciProjectDescriptionTextStep.java +++ /dev/null @@ -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.Component; -import com.arsdigita.bebop.parameters.StringParameter; -import com.arsdigita.cms.ItemSelectionModel; -import com.arsdigita.cms.ui.authoring.AuthoringKitWizard; -import com.arsdigita.cms.ui.authoring.BasicItemForm; -import com.arsdigita.cms.ui.authoring.SimpleEditStep; -import com.arsdigita.cms.ui.workflow.WorkflowLockedComponentAccess; -import com.arsdigita.globalization.GlobalizedMessage; -import com.arsdigita.toolbox.ui.DomainObjectPropertySheet; - -import org.scientificcms.contenttypes.sciproject.SciProjectConstants; - -/** - * - * @author Jens Pelzetter - */ -public class SciProjectDescriptionTextStep extends SimpleEditStep { - - public SciProjectDescriptionTextStep( - final ItemSelectionModel itemModel, - final AuthoringKitWizard parent, - final StringParameter selectedLanguageParam) { - - this(itemModel, parent, selectedLanguageParam, null); - } - - public SciProjectDescriptionTextStep( - final ItemSelectionModel itemModel, - final AuthoringKitWizard parent, - final StringParameter selectedLanguageParam, - final String suffix) { - - super(itemModel, parent, selectedLanguageParam, suffix); - - final BasicItemForm descTextEditSheet - = new SciProjectDescriptionTextEditForm( - itemModel, selectedLanguageParam); - add(SciProjectUiConstants.EDIT_DESC_TEXT_SHEET_NAME, - new GlobalizedMessage("sciproject.ui.desc.text.edit", - SciProjectConstants.SCI_PROJECT_BUNDLE), - new WorkflowLockedComponentAccess(descTextEditSheet, itemModel), - descTextEditSheet.getSaveCancelSection().getCancelButton()); - - final SciProjectDescriptionUploadForm uploadDescForm - = new SciProjectDescriptionUploadForm( - itemModel, - selectedLanguageParam); - add(SciProjectUiConstants.UPLOAD_DESC_TEXT_SHEET_NAME, - new GlobalizedMessage("sciproject.ui.desc.upload", - SciProjectConstants.SCI_PROJECT_BUNDLE), - new WorkflowLockedComponentAccess(uploadDescForm, itemModel), - uploadDescForm.getSaveCancelSection().getCancelButton()); - - setDisplayComponent( - getSciProjectEditDescTextSheet(itemModel, - selectedLanguageParam) - ); - } - - public static Component getSciProjectEditDescTextSheet( - final ItemSelectionModel itemModel, - final StringParameter selectedLanguageParam) { - - final DomainObjectPropertySheet sheet = new DomainObjectPropertySheet( - itemModel); - - sheet.add(new GlobalizedMessage( - "sciproject.ui.desc", SciProjectConstants.SCI_PROJECT_BUNDLE), - SciProjectUiConstants.PROJECT_DESCRIPTION); - - return sheet; - } - -} diff --git a/sci-types-project/src/main/java/com/arsdigita/cms/contenttypes/ui/SciProjectDescriptionUploadForm.java b/sci-types-project/src/main/java/com/arsdigita/cms/contenttypes/ui/SciProjectDescriptionUploadForm.java deleted file mode 100644 index 2193f1d..0000000 --- a/sci-types-project/src/main/java/com/arsdigita/cms/contenttypes/ui/SciProjectDescriptionUploadForm.java +++ /dev/null @@ -1,71 +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.parameters.StringParameter; -import com.arsdigita.cms.ItemSelectionModel; -import com.arsdigita.cms.ui.authoring.SelectedLanguageUtil; -import com.arsdigita.cms.ui.contenttypes.AbstractTextUploadForm; -import com.arsdigita.globalization.GlobalizedMessage; - -import org.libreccm.cdi.utils.CdiUtil; -import org.scientificcms.contenttypes.sciproject.SciProject; -import org.scientificcms.contenttypes.sciproject.SciProjectConstants; - -import java.util.Locale; - -import static com.arsdigita.cms.ui.authoring.SelectedLanguageUtil.*; - -/** - * - * @author Jens Pelzetter - */ -public class SciProjectDescriptionUploadForm extends AbstractTextUploadForm { - - private StringParameter selectedLanguageParam; - - public SciProjectDescriptionUploadForm( - final ItemSelectionModel itemModel, - final StringParameter selectedLanguageParam) { - - super(itemModel); - } - - @Override - public GlobalizedMessage getLabelText() { - return new GlobalizedMessage("sciproject.ui.description.upload", - SciProjectConstants.SCI_PROJECT_BUNDLE); - } - - @Override - public GlobalizedMessage getMimeTypeLabel() { - return new GlobalizedMessage( - "sciproject.ui.description.upload.mimetype", - SciProjectConstants.SCI_PROJECT_BUNDLE); - } - - @Override - public void setText(final ItemSelectionModel itemModel, - final PageState state, - final String text) { - - final CdiUtil cdiUtil = CdiUtil.createCdiUtil(); - final SciProjectController controller = cdiUtil - .findBean(SciProjectController.class); - - final SciProject project = (SciProject) itemModel - .getSelectedItem(state); - - final Locale locale = SelectedLanguageUtil - .selectedLocale(state, selectedLanguageParam); - - controller.updateDescription(project.getObjectId(), - text, - locale); - } - -} diff --git a/sci-types-project/src/main/java/com/arsdigita/cms/contenttypes/ui/SciProjectFundingEditForm.java b/sci-types-project/src/main/java/com/arsdigita/cms/contenttypes/ui/SciProjectFundingEditForm.java deleted file mode 100644 index d9f38fd..0000000 --- a/sci-types-project/src/main/java/com/arsdigita/cms/contenttypes/ui/SciProjectFundingEditForm.java +++ /dev/null @@ -1,159 +0,0 @@ -/* ; - * Copyright (c) 2013 Jens Pelzetter - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ -package com.arsdigita.cms.contenttypes.ui; - -import com.arsdigita.bebop.FormData; -import com.arsdigita.bebop.FormProcessException; -import com.arsdigita.bebop.PageState; -import com.arsdigita.bebop.event.FormInitListener; -import com.arsdigita.bebop.event.FormProcessListener; -import com.arsdigita.bebop.event.FormSectionEvent; -import com.arsdigita.bebop.form.TextArea; -import com.arsdigita.bebop.form.TextField; -import com.arsdigita.bebop.parameters.ParameterModel; -import com.arsdigita.bebop.parameters.StringInRangeValidationListener; -import com.arsdigita.bebop.parameters.StringParameter; -import com.arsdigita.cms.ItemSelectionModel; - -import com.arsdigita.cms.ui.CMSDHTMLEditor; -import com.arsdigita.cms.ui.authoring.BasicItemForm; -import com.arsdigita.cms.ui.authoring.SelectedLanguageUtil; -import com.arsdigita.globalization.GlobalizedMessage; - -import org.libreccm.cdi.utils.CdiUtil; -import org.scientificcms.contenttypes.sciproject.SciProject; -import org.scientificcms.contenttypes.sciproject.SciProjectConfig; -import org.scientificcms.contenttypes.sciproject.SciProjectConstants; - -import java.util.HashMap; -import java.util.Locale; -import java.util.Map; - -/** - * - * @author Jens Pelzetter - */ -public class SciProjectFundingEditForm - extends BasicItemForm - implements FormProcessListener, FormInitListener { - - private final static SciProjectConfig CONFIG = SciProjectConfig.getConfig(); - - private final StringParameter selectedLanguageParam; - - public SciProjectFundingEditForm( - final ItemSelectionModel itemModel, - final StringParameter selectedLanguageParam) { - - super("SciProjectFundingForm", itemModel, selectedLanguageParam); - this.selectedLanguageParam = selectedLanguageParam; - } - - @Override - public void addWidgets() { - - if (CONFIG.isEnableFunding()) { - final ParameterModel fundingParam = new StringParameter( - SciProjectUiConstants.FUNDING); - final TextArea funding; - if (CONFIG.isEnableFundingDhtml()) { - funding = new CMSDHTMLEditor(fundingParam); - } else { - funding = new TextArea(fundingParam); - } - funding.setLabel(new GlobalizedMessage( - "sciproject.ui.funding", - SciProjectConstants.SCI_PROJECT_BUNDLE)); - funding.setCols(75); - funding.setRows(8); - add(funding); - } - - if (CONFIG.isEnableFundingVolume()) { - final ParameterModel fundingVolumeParam = new StringParameter( - SciProjectUiConstants.FUNDING_VOLUME); - final TextField fundingVolume = new TextField(fundingVolumeParam); - fundingVolume.addValidationListener( - new StringInRangeValidationListener( - 0, - CONFIG.getFundingVolumeLength())); - fundingVolume.setLabel(new GlobalizedMessage( - "sciproject.ui.funding.volume", - SciProjectConstants.SCI_PROJECT_BUNDLE)); - add(fundingVolume); - } - } - - @Override - public void init(final FormSectionEvent event) throws FormProcessException { - final PageState state = event.getPageState(); - final FormData data = event.getFormData(); - final Locale locale = SelectedLanguageUtil - .selectedLocale(state, selectedLanguageParam); - final SciProject project = (SciProject) getItemSelectionModel() - .getSelectedObject(state); - - if (CONFIG.isEnableFunding()) { - data.put(SciProjectUiConstants.FUNDING, - project.getFunding().getValue(locale)); - } - - if (CONFIG.isEnableFundingVolume()) { - data.put(SciProjectUiConstants.FUNDING_VOLUME, - project.getFundingVolume().getValue(locale)); - } - - setVisible(state, true); - - } - - @Override - public void process(final FormSectionEvent event) throws - FormProcessException { - final PageState state = event.getPageState(); - final FormData formData = event.getFormData(); - final Locale locale = SelectedLanguageUtil - .selectedLocale(state, selectedLanguageParam); - final SciProject project = (SciProject) getItemSelectionModel() - .getSelectedObject(state); - - if ((project != null) - && getSaveCancelSection().getSaveButton().isSelected(state)) { - - final Map data = new HashMap<>(); - - if (CONFIG.isEnableFunding()) { - data.put(SciProjectUiConstants.FUNDING, - formData.get(SciProjectUiConstants.FUNDING)); - } - if (CONFIG.isEnableFundingVolume()) { - data.put(SciProjectUiConstants.FUNDING_VOLUME, - formData.get(SciProjectUiConstants.FUNDING_VOLUME)); - } - - final SciProjectController controller = CdiUtil - .createCdiUtil() - .findBean(SciProjectController.class); - controller.updateFundingData(project.getObjectId(), locale, data); - } - - init(event); - } - -} diff --git a/sci-types-project/src/main/java/com/arsdigita/cms/contenttypes/ui/SciProjectFundingStep.java b/sci-types-project/src/main/java/com/arsdigita/cms/contenttypes/ui/SciProjectFundingStep.java deleted file mode 100644 index d9b8466..0000000 --- a/sci-types-project/src/main/java/com/arsdigita/cms/contenttypes/ui/SciProjectFundingStep.java +++ /dev/null @@ -1,83 +0,0 @@ -package com.arsdigita.cms.contenttypes.ui; - -import com.arsdigita.bebop.Component; -import com.arsdigita.bebop.parameters.StringParameter; -import com.arsdigita.cms.ItemSelectionModel; - -import com.arsdigita.cms.ui.authoring.AuthoringKitWizard; -import com.arsdigita.cms.ui.authoring.BasicItemForm; -import com.arsdigita.cms.ui.authoring.SimpleEditStep; -import com.arsdigita.cms.ui.workflow.WorkflowLockedComponentAccess; -import com.arsdigita.globalization.GlobalizedMessage; -import com.arsdigita.toolbox.ui.DomainObjectPropertySheet; - -import org.scientificcms.contenttypes.sciproject.SciProjectConfig; -import org.scientificcms.contenttypes.sciproject.SciProjectConstants; - -/** - * - * @author Jens Pelzetter - * @version $Id: SciProjectFundingStep.java 2334 2013-10-03 07:51:31Z jensp $ - */ -public class SciProjectFundingStep extends SimpleEditStep { - - private static final String EDIT_PROJECT_FUNDING_SHEET_NAME - = "editProjectFunding"; - - private static final String UPLOAD_PROJECT_FUNDING_SHEET_NAME - = "uploadProjectFunding"; - - public SciProjectFundingStep(final ItemSelectionModel itemModel, - final AuthoringKitWizard parent, - final StringParameter selectedLanguageParam) { - this(itemModel, parent, selectedLanguageParam, null); - } - - public SciProjectFundingStep(final ItemSelectionModel itemModel, - final AuthoringKitWizard parent, - final StringParameter selectedLanguageParam, - final String prefix) { - super(itemModel, parent, selectedLanguageParam, prefix); - - final BasicItemForm editFundingForm = new SciProjectFundingEditForm( - itemModel, selectedLanguageParam); - add(EDIT_PROJECT_FUNDING_SHEET_NAME, - new GlobalizedMessage("sciproject.ui.funding.edit", - SciProjectConstants.SCI_PROJECT_BUNDLE), - new WorkflowLockedComponentAccess(editFundingForm, itemModel), - editFundingForm.getSaveCancelSection().getCancelButton()); - - final SciProjectFundingUploadForm uploadFundingForm - = new SciProjectFundingUploadForm( - itemModel, selectedLanguageParam); - add(UPLOAD_PROJECT_FUNDING_SHEET_NAME, - new GlobalizedMessage("sciproject.ui.funding.upload", - SciProjectConstants.SCI_PROJECT_BUNDLE), - new WorkflowLockedComponentAccess(uploadFundingForm, itemModel), - uploadFundingForm.getSaveCancelSection().getCancelButton()); - - setDisplayComponent(getSciProjectEditFundingSheet(itemModel)); - } - - public static Component getSciProjectEditFundingSheet( - final ItemSelectionModel itemModel) { - final DomainObjectPropertySheet sheet = new DomainObjectPropertySheet( - itemModel); - - if (SciProjectConfig.getConfig().isEnableFunding()) { - sheet.add( - new GlobalizedMessage("sciproject.ui.funding", - SciProjectConstants.SCI_PROJECT_BUNDLE), - SciProjectUiConstants.FUNDING); - } - if (SciProjectConfig.getConfig().isEnableFundingVolume()) { - sheet.add( - new GlobalizedMessage("sciproject.ui.funding.volume", - SciProjectConstants.SCI_PROJECT_BUNDLE), - SciProjectUiConstants.FUNDING_VOLUME); - } - - return sheet; - } - -} diff --git a/sci-types-project/src/main/java/com/arsdigita/cms/contenttypes/ui/SciProjectFundingUploadForm.java b/sci-types-project/src/main/java/com/arsdigita/cms/contenttypes/ui/SciProjectFundingUploadForm.java deleted file mode 100644 index a9ff692..0000000 --- a/sci-types-project/src/main/java/com/arsdigita/cms/contenttypes/ui/SciProjectFundingUploadForm.java +++ /dev/null @@ -1,66 +0,0 @@ -package com.arsdigita.cms.contenttypes.ui; - -import com.arsdigita.bebop.PageState; -import com.arsdigita.bebop.parameters.StringParameter; -import com.arsdigita.cms.ItemSelectionModel; -import com.arsdigita.cms.ui.authoring.SelectedLanguageUtil; -import com.arsdigita.cms.ui.contenttypes.AbstractTextUploadForm; -import com.arsdigita.globalization.GlobalizedMessage; - -import org.libreccm.cdi.utils.CdiUtil; -import org.scientificcms.contenttypes.sciproject.SciProject; -import org.scientificcms.contenttypes.sciproject.SciProjectConstants; - -import java.util.HashMap; -import java.util.Locale; -import java.util.Map; - -/** - * - * @author Jens Pelzetter - * jensp $ - */ -public class SciProjectFundingUploadForm extends AbstractTextUploadForm { - - private final StringParameter selectedLanguageParam; - - public SciProjectFundingUploadForm( - final ItemSelectionModel itemModel, - final StringParameter selectedLanguageParam) { - - super(itemModel); - this.selectedLanguageParam = selectedLanguageParam; - } - - @Override - public GlobalizedMessage getLabelText() { - return new GlobalizedMessage("sciproject.ui.funding.upload", - SciProjectConstants.SCI_PROJECT_BUNDLE); - } - - @Override - public GlobalizedMessage getMimeTypeLabel() { - return new GlobalizedMessage("sciproject.ui.funding.upload.mimetype", - SciProjectConstants.SCI_PROJECT_BUNDLE); - } - - @Override - public void setText(final ItemSelectionModel itemModel, - final PageState state, - final String text) { - - final SciProject project = (SciProject) itemModel.getSelectedObject( - state); - final Locale locale = SelectedLanguageUtil - .selectedLocale(state, - selectedLanguageParam); - - final Map data = new HashMap<>(); - data.put(SciProjectUiConstants.FUNDING, text); - CdiUtil - .createCdiUtil() - .findBean(SciProjectController.class) - .updateFundingData(project.getObjectId(), locale, data); - } - -} diff --git a/sci-types-project/src/main/java/com/arsdigita/cms/contenttypes/ui/SciProjectMemberAddForm.java b/sci-types-project/src/main/java/com/arsdigita/cms/contenttypes/ui/SciProjectMemberAddForm.java deleted file mode 100644 index 0779901..0000000 --- a/sci-types-project/src/main/java/com/arsdigita/cms/contenttypes/ui/SciProjectMemberAddForm.java +++ /dev/null @@ -1,309 +0,0 @@ -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.parameters.NotNullValidationListener; -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 com.arsdigita.util.UncheckedWrapperException; - -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; -import org.libreccm.cdi.utils.CdiUtil; -import org.librecms.CmsConstants; -import org.librecms.assets.Person; -import org.scientificcms.contenttypes.sciproject.MembershipStatus; -import org.scientificcms.contenttypes.sciproject.SciProject; -import org.scientificcms.contenttypes.sciproject.SciProjectConstants; - -import java.util.ResourceBundle; -import java.util.TooManyListenersException; - -/** - * - * @author Jens Pelzetter - * @version $Id: SciProjectMemberAddForm.java 1170 2011-10-17 19:23:23Z jensp $ - */ -public class SciProjectMemberAddForm - extends BasicItemForm - implements FormProcessListener, FormInitListener, FormSubmissionListener { - - private static final Logger LOGGER = LogManager.getLogger( - SciProjectMemberAddForm.class); - - private final SciProjectMembersStep membersStep; - - private AssetSearchWidget personSearchWidget; - - private Text selectedPersonLabel; - - public SciProjectMemberAddForm( - final ItemSelectionModel itemModel, - final SciProjectMembersStep membersStep, - final StringParameter selectedLanguageParam) { - - super("SciProjectMemberAddForm", itemModel, selectedLanguageParam); - - this.membersStep = membersStep; - addSubmissionListener(this); - } - - @Override - public void addWidgets() { - - personSearchWidget = new AssetSearchWidget( - SciProjectUiConstants.MEMBER_SEARCH, - Person.class - ); - personSearchWidget.setLabel(new GlobalizedMessage( - "sciproject.ui.select_member", - SciProjectConstants.SCI_PROJECT_BUNDLE - )); - add(personSearchWidget); - - selectedPersonLabel = new Text(); - add(selectedPersonLabel); - - final ParameterModel roleParam = new StringParameter( - SciProjectUiConstants.MEMBER_ROLE - ); - final SingleSelect roleSelect = new SingleSelect(roleParam); - roleSelect.setLabel(new GlobalizedMessage( - "sciproject.ui.member.role", - SciProjectConstants.SCI_PROJECT_BUNDLE - )); - roleSelect.addValidationListener(new NotNullValidationListener()); - - try { - - roleSelect.addPrintListener(new PrintListener() { - - @Override - public void prepare(final PrintEvent event) { - final SingleSelect target = (SingleSelect) event.getTarget(); - target.clearOptions(); - - target.addOption(new Option("", - new Label(new GlobalizedMessage( - "cms.ui.select_one", - CmsConstants.CMS_BUNDLE)))); - - final String rolesBundleName = getController() - .getMemberRolesBundleName(); - final ResourceBundle rolesBundle = ResourceBundle - .getBundle(rolesBundleName); - for (final String key : rolesBundle.keySet()) { - - final Option option = new Option( - key, - new Label(new GlobalizedMessage(key, - rolesBundleName)) - ); - target.addOption(option); - } - } - - }); - - } catch (TooManyListenersException ex) { - throw new UncheckedWrapperException(ex); - } - add(roleSelect); - - final ParameterModel statusModel = new StringParameter( - SciProjectUiConstants.MEMBER_STATUS - ); - final SingleSelect statusSelect = new SingleSelect(statusModel); - statusSelect.setLabel(new GlobalizedMessage( - "sciproject.ui.member.status", - SciProjectConstants.SCI_PROJECT_BUNDLE - )); - statusSelect.addValidationListener(new NotNullValidationListener()); - try { - statusSelect.addPrintListener(new PrintListener() { - - @Override - public void prepare(final PrintEvent event) { - - final SingleSelect target = (SingleSelect) event.getTarget(); - target.clearOptions(); - - target.addOption(new Option("", - new Label(new GlobalizedMessage( - "cms.ui.select_one", - CmsConstants.CMS_BUNDLE)))); - - for (MembershipStatus status : MembershipStatus.values()) { - - final Option option = new Option( - status.toString(), - new Label(new GlobalizedMessage( - String.format("sciproject.membership.status.%s", - status.toString()), - SciProjectConstants.SCI_PROJECT_BUNDLE - )) - ); - target.addOption(option); - } - } - - }); - } catch (TooManyListenersException ex) { - throw new UncheckedWrapperException( - "Something has gone terribly wrong", ex); - } - add(statusSelect); - } - - @Override - public void init(final FormSectionEvent event) throws FormProcessException { - - final FormData formData = event.getFormData(); - final PageState state = event.getPageState(); - - final Person member = membersStep.getSelectedMember(state); - final String role = membersStep.getSelectedMemberRole(state); - final String status = membersStep.getSelectedMemberStatus(state); - - if (member == null) { - personSearchWidget.setVisible(state, true); - selectedPersonLabel.setVisible(state, false); - } else { - formData.put(SciProjectUiConstants.MEMBER_SEARCH, member); - formData.put(SciProjectUiConstants.MEMBER_ROLE, role); - formData.put(SciProjectUiConstants.MEMBER_STATUS, status); - - personSearchWidget.setVisible(state, false); - selectedPersonLabel.setVisible(state, true); - selectedPersonLabel.setText( - String.format( - "%s, %s", - member.getPersonName().getSurname(), - member.getPersonName().getGivenName() - ) - ); - } - setVisible(state, true); - } - - @Override - public void process(final FormSectionEvent event) - throws FormProcessException { - - final FormData formData = event.getFormData(); - final PageState state = event.getPageState(); - - final SciProject project = (SciProject) getItemSelectionModel() - .getSelectedItem(state); - - if (getSaveCancelSection().getSaveButton().isSelected(state)) { - - final Person selected = membersStep.getSelectedMember(state); - - if (selected == null) { - - final Person person = (Person) formData - .get(SciProjectUiConstants.MEMBER_SEARCH); - - final String role = (String) formData - .get(SciProjectUiConstants.MEMBER_ROLE); - final String status = (String) formData - .get(SciProjectUiConstants.MEMBER_STATUS); - - getController().addMember(project.getObjectId(), - person.getObjectId(), - role, - status); - - } else { - - final String role = (String) formData - .get(SciProjectUiConstants.MEMBER_ROLE); - final String status = (String) formData - .get(SciProjectUiConstants.MEMBER_STATUS); - - getController().updateMembership(project.getObjectId(), - selected.getObjectId(), - role, - status); - } - } - - init(event); - } - - @Override - public void submitted(final FormSectionEvent event) throws - FormProcessException { - - final PageState state = event.getPageState(); - if (getSaveCancelSection().getCancelButton().isSelected(state)) { - - membersStep.setSelectedMember(state, null); - membersStep.setSelectedMemberRole(state, null); - membersStep.setSelectedMemberStatus(state, null); - - init(event); - } - } - - @Override - public void validate(final FormSectionEvent event) - throws FormProcessException { - - final PageState state = event.getPageState(); - final FormData data = event.getFormData(); - - if (membersStep.getSelectedMember(state) == null - && data.get(SciProjectUiConstants.MEMBER_SEARCH) == null) { - - data.addError( - new GlobalizedMessage( - "sciproject.ui.member.no_person_selected", - SciProjectConstants.SCI_PROJECT_BUNDLE - ) - ); - return; - } - - if (membersStep.getSelectedMember(state) == null) { - - final SciProject project = (SciProject) getItemSelectionModel() - .getSelectedItem(state); - - final Person person = (Person) data - .get(SciProjectUiConstants.MEMBER_SEARCH); - - if (getController().hasMember(project.getObjectId(), - person.getObjectId())) { - - data.addError(new GlobalizedMessage( - "cms.contenttypes.ui.sciproject.select_member.already_added", - SciProjectConstants.SCI_PROJECT_BUNDLE - )); - } - } - } - - private SciProjectController getController() { - final CdiUtil cdiUtil = CdiUtil.createCdiUtil(); - - return cdiUtil.findBean(SciProjectController.class); - } - -} diff --git a/sci-types-project/src/main/java/com/arsdigita/cms/contenttypes/ui/SciProjectMembersStep.java b/sci-types-project/src/main/java/com/arsdigita/cms/contenttypes/ui/SciProjectMembersStep.java deleted file mode 100644 index 43dd4c2..0000000 --- a/sci-types-project/src/main/java/com/arsdigita/cms/contenttypes/ui/SciProjectMembersStep.java +++ /dev/null @@ -1,109 +0,0 @@ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ -package com.arsdigita.cms.contenttypes.ui; - -import com.arsdigita.bebop.Page; -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.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.contenttypes.sciproject.SciProjectConstants; - -/** - * - * @author Jens Pelzetter - */ -public class SciProjectMembersStep extends SimpleEditStep { - - private static final String ADD_PROJECT_MEMBER_SHEET_NAME - = "SciProjectAddMember"; - - public static final String SELECTED_PERSON = "selected-person"; - -// private final AssetSelectionModel selectedPerson; - private Person selectedMember; - - private String selectedMembershipRole; - - private String selectedMembershipStatus; - - public SciProjectMembersStep( - final ItemSelectionModel itemModel, - final AuthoringKitWizard parent, - final StringParameter selectedLanguageParameter) { - - this(itemModel, parent, selectedLanguageParameter, null); - } - - public SciProjectMembersStep( - final ItemSelectionModel itemModel, - final AuthoringKitWizard parent, - final StringParameter selectedLanguageParameter, - final String prefix) { - super(itemModel, parent, selectedLanguageParameter, prefix); - - final BasicItemForm addMemberSheet = new SciProjectMemberAddForm( - itemModel, this, selectedLanguageParameter - ); - add(ADD_PROJECT_MEMBER_SHEET_NAME, - new GlobalizedMessage("sciproject.ui.members.add", - SciProjectConstants.SCI_PROJECT_BUNDLE), - new WorkflowLockedComponentAccess(addMemberSheet, itemModel), - addMemberSheet.getSaveCancelSection().getCancelButton()); - - final SciProjectMembersTable memberTable = new SciProjectMembersTable( - itemModel, this); - setDisplayComponent(memberTable); - -// selectedPerson = new ItemSelectionModel(SELECTED_PERSON); - } - - @Override - public void register(final Page page) { - super.register(page); - -// page.addGlobalStateParam(selectedPerson.getStateParameter()); - } - - public Person getSelectedMember(final PageState state) { - return selectedMember; - } - - public void setSelectedMember(final PageState state, - final Person selectedMember) { - this.selectedMember = selectedMember; - } - - public String getSelectedMemberRole(final PageState state) { - return selectedMembershipRole; - } - - public void setSelectedMemberRole(final PageState state, - final String selectedPersonRole) { - this.selectedMembershipRole = selectedPersonRole; - } - - public String getSelectedMemberStatus(final PageState state) { - return selectedMembershipStatus; - } - - public void setSelectedMemberStatus(final PageState state, - final String selectedPersonStatus) { - this.selectedMembershipStatus = selectedPersonStatus; - } - - public void showEditComponent(final PageState state) { - showComponent(state, ADD_PROJECT_MEMBER_SHEET_NAME); - } - -} diff --git a/sci-types-project/src/main/java/com/arsdigita/cms/contenttypes/ui/SciProjectMembersTable.java b/sci-types-project/src/main/java/com/arsdigita/cms/contenttypes/ui/SciProjectMembersTable.java deleted file mode 100644 index 19518d8..0000000 --- a/sci-types-project/src/main/java/com/arsdigita/cms/contenttypes/ui/SciProjectMembersTable.java +++ /dev/null @@ -1,365 +0,0 @@ -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.configuration.ConfigurationManager; -import org.libreccm.security.PermissionChecker; -import org.librecms.CmsConstants; -import org.librecms.contentsection.privileges.ItemPrivileges; -import org.scientificcms.contenttypes.sciproject.Membership; -import org.scientificcms.contenttypes.sciproject.SciProject; -import org.scientificcms.contenttypes.sciproject.SciProjectConfig; -import org.scientificcms.contenttypes.sciproject.SciProjectConstants; - -import java.util.Iterator; -import java.util.Map; - -/** - * - * @author Jens Pelzetter - * @version $Id: SciProjectMembersTable.java 1170 2011-10-17 19:23:23Z jensp $ - */ -public class SciProjectMembersTable - extends Table - implements TableActionListener { - - private static final Logger LOGGER = LogManager - .getLogger(SciProjectMembersTable.class); - - private static final String TABLE_COL_EDIT = "table_col_edit"; - - private static final String TABLE_COL_EDIT_LINK = "table_col_edit_link"; - - private static final String TABLE_COL_DEL = "table_col_del"; - - private final ItemSelectionModel itemModel; - - private final SciProjectMembersStep membersStep; - - public SciProjectMembersTable(final ItemSelectionModel itemModel, - final SciProjectMembersStep membersStep) { - - super(); - - this.itemModel = itemModel; - this.membersStep = membersStep; - - setEmptyView(new Label(new GlobalizedMessage( - "cms.contenttypes.ui.sciproject.members.none", - SciProjectConstants.SCI_PROJECT_BUNDLE))); - - final TableColumnModel columnModel = getColumnModel(); - columnModel.add(new TableColumn( - 0, - new GlobalizedMessage( - "cms.contenttypes.ui.sciproject.persons.name", - SciProjectConstants.SCI_PROJECT_BUNDLE - ), - TABLE_COL_EDIT)); - columnModel.add( - new TableColumn( - 1, - new GlobalizedMessage( - "cms.contenttypes.ui.sciproject.persons.role", - SciProjectConstants.SCI_PROJECT_BUNDLE - ) - ) - ); - columnModel.add( - new TableColumn( - 2, - new GlobalizedMessage( - "cms.contenttypes.ui.sciproject.persons.status", - SciProjectConstants.SCI_PROJECT_BUNDLE) - ) - ); - columnModel.add( - new TableColumn( - 3, - new GlobalizedMessage( - "cms.contenttypes.ui.genericorganunit.persons.edit", - SciProjectConstants.SCI_PROJECT_BUNDLE - ), - TABLE_COL_EDIT_LINK) - ); - columnModel.add( - new TableColumn( - 4, - new GlobalizedMessage( - "cms.contenttypes.ui.sciproject.persons.delete", - SciProjectConstants.SCI_PROJECT_BUNDLE - ), - TABLE_COL_DEL) - ); - - setModelBuilder(new SciProjectMembersTableModelBuilder(itemModel)); - - columnModel.get(0).setCellRenderer(new EditCellRenderer()); - columnModel.get(3).setCellRenderer(new EditLinkCellRenderer()); - columnModel.get(4).setCellRenderer(new DeleteCellRenderer()); - - addTableActionListener(this); - } - - private class SciProjectMembersTableModelBuilder - extends LockableImpl - implements TableModelBuilder { - - private final ItemSelectionModel itemModel; - - public SciProjectMembersTableModelBuilder( - final ItemSelectionModel itemModel) { - - this.itemModel = itemModel; - } - - @Override - public TableModel makeModel(final Table table, final PageState state) { - - table.getRowSelectionModel().clearSelection(state); - final SciProject selected = (SciProject) itemModel - .getSelectedItem(state); - return new SciProjectMembersTableModel(table, state, selected); - } - - } - - private class SciProjectMembersTableModel implements TableModel { - - private final Table table; - - private final Iterator> iterator; - - private Map currentRow; - - public SciProjectMembersTableModel(final Table table, - final PageState state, - final SciProject selected) { - - this.table = table; - - final CdiUtil cdiUtil = CdiUtil.createCdiUtil(); - final SciProjectController controller = cdiUtil - .findBean(SciProjectController.class); - iterator = controller.getMembers(selected.getObjectId()).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(SciProjectController.MEMBER_NAME); - case 1: - final CdiUtil cdiUtil = CdiUtil.createCdiUtil(); - final ConfigurationManager confManager = cdiUtil - .findBean(ConfigurationManager.class); - final SciProjectConfig config = confManager - .findConfiguration(SciProjectConfig.class); - final String role = (String) currentRow - .get(SciProjectController.MEMBER_ROLE); - return new GlobalizedMessage(role, - config - .getMemberRolesBundleName()); - case 2: - return currentRow.get(SciProjectController.MEMBER_STATUS); - case 3: - return new Label(new GlobalizedMessage( - "cms.ui.edit_assoc", CmsConstants.CMS_BUNDLE)); - case 4: - return new Label(new GlobalizedMessage( - "cms.ui.delete", CmsConstants.CMS_BUNDLE)); - default: - return null; - } - } - - @Override - public Object getKeyAt(final int columnIndex) { - - return currentRow.get(SciProjectController.MEMBERSHIP_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 SciProject selected = (SciProject) itemModel - .getSelectedItem(state); - final CdiUtil cdiUtil = CdiUtil.createCdiUtil(); - final SciProjectController controller = cdiUtil - .findBean(SciProjectController.class); - final Membership membership = controller - .findMembership(selected.getObjectId(), key) - .get(); - - return new Text(String.format( - "%s, %s", - membership.getMember().getPersonName().getSurname(), - membership.getMember().getPersonName().getGivenName() - )); - } - - } - - private class EditLinkCellRenderer - 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 SciProject selected = (SciProject) 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 CdiUtil cdiUtil = CdiUtil.createCdiUtil(); - final PermissionChecker permissionChecker = cdiUtil - .findBean(PermissionChecker.class); - - final SciProject selected = (SciProject) itemModel - .getSelectedItem(state); - final boolean canEdit = permissionChecker - .isPermitted(ItemPrivileges.EDIT, selected); - - if (canEdit) { - final ControlLink link = new ControlLink((Component) value); - link.setConfirmation(new GlobalizedMessage( - "cms.contenttypes.ui.sciproject.confirm_delete", - SciProjectConstants.SCI_PROJECT_BUNDLE - )); - return link; - } else { - return new Text(""); - } - } - - } - - @Override - public void cellSelected(final TableActionEvent event) - throws FormProcessException { - - final PageState state = event.getPageState(); - final SciProject selected = (SciProject) itemModel - .getSelectedItem(state); - final CdiUtil cdiUtil = CdiUtil.createCdiUtil(); - final SciProjectController controller = cdiUtil - .findBean(SciProjectController.class); - - final Membership membership = controller - .findMembership(selected.getObjectId(), event.getRowKey()) - .get(); - - final TableColumn column = getColumnModel() - .get(event.getColumn().intValue()); - - if (TABLE_COL_EDIT.equals(column.getHeaderKey())) { - // Nothing - } else if (TABLE_COL_EDIT_LINK.equals(column.getHeaderKey())) { - membersStep.setSelectedMember(state, membership.getMember()); - membersStep.setSelectedMemberRole(state, membership.getRole()); - membersStep.setSelectedMemberStatus( - state, - membership.getStatus().toString() - ); - membersStep - .showComponent(state, - SciProjectUiConstants.ADD_MEMBER_SHEET_NAME); - } else if (TABLE_COL_DEL.equals(column.getHeaderKey())) { - controller.removeMember(selected.getObjectId(), - membership.getMembershipId()); - } - } - - @Override - public void headSelected(final TableActionEvent event) { - - // Nothing - } - -} diff --git a/sci-types-project/src/main/java/com/arsdigita/cms/contenttypes/ui/SciProjectPropertiesStep.java b/sci-types-project/src/main/java/com/arsdigita/cms/contenttypes/ui/SciProjectPropertiesStep.java deleted file mode 100644 index f897be8..0000000 --- a/sci-types-project/src/main/java/com/arsdigita/cms/contenttypes/ui/SciProjectPropertiesStep.java +++ /dev/null @@ -1,187 +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.globalization.GlobalizedMessage; -import com.arsdigita.toolbox.ui.DomainObjectPropertySheet; - -import org.librecms.CmsConstants; -import org.scientificcms.contenttypes.sciproject.SciProject; -import org.scientificcms.contenttypes.sciproject.SciProjectConstants; - -import java.text.DateFormat; - -/** - * - * @author Jens Pelzetter - */ -public class SciProjectPropertiesStep extends SimpleEditStep { - - private SegmentedPanel segmentedPanel; - - public SciProjectPropertiesStep( - final ItemSelectionModel itemModel, - final AuthoringKitWizard parent, - final StringParameter selectedLanguageParam) { - - super(itemModel, parent, selectedLanguageParam); - - segmentedPanel = new SegmentedPanel(); - setDefaultEditKey(SciProjectUiConstants.EDIT_CONTACT_SHEET_NAME); - - addBasicProperties(itemModel, parent, selectedLanguageParam); - addSteps(itemModel, parent); - - setDisplayComponent(segmentedPanel); - } - - public static Component getSciProjectPropertySheet( - final ItemSelectionModel itemModel) { - final DomainObjectPropertySheet sheet = new DomainObjectPropertySheet( - itemModel);; - - sheet.add(new GlobalizedMessage( - "org.scientificcms.contenttypes.sciproject.name", - SciProjectConstants.SCI_PROJECT_BUNDLE), - SciProjectUiConstants.NAME); - sheet.add(new GlobalizedMessage( - "cms.contenttypes.ui.genericorgaunit.title", - SciProjectConstants.SCI_PROJECT_BUNDLE), - SciProjectUiConstants.TITLE); - - sheet.add(new GlobalizedMessage("sciproject.ui.begin", - SciProjectConstants.SCI_PROJECT_BUNDLE - ), - SciProjectUiConstants.BEGIN, - new DomainObjectPropertySheet.AttributeFormatter() { - - @Override - public String format(final Object obj, - final String attribute, - final PageState state) { - final SciProject project = (SciProject) obj; - if (project.getBegin() == null) { - return (String) new GlobalizedMessage( - "cms.ui.unknown", - CmsConstants.CMS_BUNDLE) - .localize(); - } else { - return DateFormat.getDateInstance(DateFormat.LONG) - .format( - project.getBegin()); - } - } - - }); - sheet.add(new GlobalizedMessage("sciproject.ui.end", - SciProjectConstants.SCI_PROJECT_BUNDLE), - SciProjectUiConstants.END, - new DomainObjectPropertySheet.AttributeFormatter() { - - public String format(final Object obj, - final String attribute, - final PageState state) { - final SciProject project = (SciProject) obj; - if (project.getEnd() == null) { - return (String) new GlobalizedMessage( - "cms.ui.unknown", - CmsConstants.CMS_BUNDLE) - .localize(); - } else { - return DateFormat.getDateInstance(DateFormat.LONG) - .format(project. - getEnd()); - } - } - - }); - sheet.add(new GlobalizedMessage("sciproject.ui.shortdesc", - SciProjectConstants.SCI_PROJECT_BUNDLE), - SciProjectUiConstants.PROJECT_SHORT_DESCRIPTION - ); - - return sheet; - } - - protected void addBasicProperties( - final ItemSelectionModel itemModel, - final AuthoringKitWizard parent, - final StringParameter selectedLanguageParameter) { - final SimpleEditStep basicProperties = new SimpleEditStep( - itemModel, - parent, - selectedLanguageParameter, - SciProjectUiConstants.EDIT_CONTACT_SHEET_NAME - ); - - final BasicPageForm editBasicSheet = new SciProjectPropertyForm( - itemModel, - this, - selectedLanguageParameter); - - basicProperties.add(SciProjectUiConstants.EDIT_CONTACT_SHEET_NAME, - new GlobalizedMessage("sciproject.ui.edit_basic_sheet", - SciProjectConstants.SCI_PROJECT_BUNDLE - ), - new WorkflowLockedComponentAccess(editBasicSheet, itemModel), - editBasicSheet.getSaveCancelSection().getCancelButton()); - - basicProperties.setDisplayComponent( - getSciProjectPropertySheet(itemModel)); - - segmentedPanel.addSegment( - new Label(new GlobalizedMessage( - "sciproject.ui.edit_basic_properties", - SciProjectConstants.SCI_PROJECT_BUNDLE) - ), - basicProperties); - } - - protected void addSteps(final ItemSelectionModel itemModel, - final AuthoringKitWizard parent) { - - addStep(new SciProjectContactsStep(itemModel, parent), - new GlobalizedMessage("sciproject.ui.contacts", - SciProjectConstants.SCI_PROJECT_BUNDLE)); -//// addStep(new GenericOrganizationalUnitContactPropertiesStep(itemModel, -//// parent), -//// SciProjectGlobalizationUtil.globalize("sciproject.ui.contacts")); -// - } - - /** - * Helper method for editing a step. - * - * @param step - * @param labelKey - */ - protected void addStep(final SimpleEditStep step, final String labelKey) { - segmentedPanel.addSegment( - new Label(new GlobalizedMessage(labelKey, - CmsConstants.CMS_BUNDLE)), - step); - } - - protected void addStep(final SimpleEditStep step, - final GlobalizedMessage label) { - segmentedPanel.addSegment(new Label(label), step); - } - - protected SegmentedPanel getSegmentedPanel() { - return segmentedPanel; - } - -} diff --git a/sci-types-project/src/main/java/com/arsdigita/cms/contenttypes/ui/SciProjectPropertyForm.java b/sci-types-project/src/main/java/com/arsdigita/cms/contenttypes/ui/SciProjectPropertyForm.java deleted file mode 100644 index 5e64437..0000000 --- a/sci-types-project/src/main/java/com/arsdigita/cms/contenttypes/ui/SciProjectPropertyForm.java +++ /dev/null @@ -1,161 +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.parameters.DateParameter; -import com.arsdigita.bebop.parameters.StringParameter; -import com.arsdigita.cms.ItemSelectionModel; -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.scientificcms.contenttypes.sciproject.SciProject; -import org.scientificcms.contenttypes.sciproject.SciProjectConstants; - -import java.time.ZoneId; -import java.util.HashMap; -import java.util.Locale; -import java.util.Map; - -/** - * - * @author Jens Pelzetter - */ -public class SciProjectPropertyForm - extends BasicPageForm - implements FormProcessListener, FormInitListener, FormSubmissionListener { - - private static final Logger LOGGER = LogManager - .getLogger(SciProjectPropertyForm.class); - - public static final String ID = "SciProject_edit"; - - private SciProjectPropertiesStep step; - - private final StringParameter selectedLanguageParameter; - - public SciProjectPropertyForm( - final ItemSelectionModel itemModel, - final StringParameter selectedLanguageParameter) { - - this(itemModel, null, selectedLanguageParameter); - } - - public SciProjectPropertyForm( - final ItemSelectionModel itemModel, - final SciProjectPropertiesStep step, - final StringParameter selectedLanguageParameter) { - super(ID, itemModel, selectedLanguageParameter); - this.step = step; - this.selectedLanguageParameter = selectedLanguageParameter; - addSubmissionListener(this); - } - - @Override - protected void addWidgets() { - - super.addWidgets(); - - final DateParameter beginParam = new DateParameter( - SciProjectUiConstants.BEGIN); - final Date begin = new Date(beginParam); - begin.setLabel(new GlobalizedMessage( - "sciproject.ui.begin", SciProjectConstants.SCI_PROJECT_BUNDLE)); - - final DateParameter endParam = new DateParameter( - SciProjectUiConstants.END); - final Date end = new Date(endParam); - - throw new UnsupportedOperationException("ToDo"); - } - - @Override - public void init(final FormSectionEvent event) throws FormProcessException { - - final FormData data = event.getFormData(); - final SciProject project = (SciProject) super.initBasicWidgets(event); - - data.put( - SciProjectUiConstants.BEGIN, - java.util.Date.from( - project.getBegin().atStartOfDay().atZone( - ZoneId.systemDefault()).toInstant() - ) - ); - data.put( - SciProjectUiConstants.END, - java.util.Date.from( - project.getEnd().atStartOfDay().atZone( - ZoneId.systemDefault()).toInstant() - ) - ); - final Locale selectedLangauge = SelectedLanguageUtil.selectedLocale( - event.getPageState(), selectedLanguageParameter - ); - data.put( - SciProjectUiConstants.PROJECT_SHORT_DESCRIPTION, - project.getShortDescription().getValue(selectedLangauge) - ); - } - - @Override - public void process(final FormSectionEvent event) - throws FormProcessException { - - final PageState state = event.getPageState(); - final FormData formData = event.getFormData(); - - final SciProject project = (SciProject) super - .processBasicWidgets(event); - - if (project != null - && getSaveCancelSection().getSaveButton().isSelected(state)) { - - final CdiUtil cdiUtil = CdiUtil.createCdiUtil(); - final SciProjectController controller = cdiUtil - .findBean(SciProjectController.class); - - final Map data = new HashMap<>(); - data.put(SciProjectUiConstants.BEGIN, - formData.get(SciProjectUiConstants.BEGIN)); - data.put(SciProjectUiConstants.END, - formData.get(SciProjectUiConstants.END)); - data.put( - SciProjectUiConstants.PROJECT_SHORT_DESCRIPTION, - formData.get(SciProjectUiConstants.PROJECT_SHORT_DESCRIPTION)); - - final Locale selectedLangauge = SelectedLanguageUtil - .selectedLocale(state, selectedLanguageParameter); - - controller.save(project.getObjectId(), selectedLangauge, data); - } - } - - @Override - public void submitted(final FormSectionEvent event) - throws FormProcessException { - - final PageState state = event.getPageState(); - - if (step != null - && getSaveCancelSection().getCancelButton().isSelected(state)) { - - step.cancelStreamlinedCreation(state); - } - } - -} diff --git a/sci-types-project/src/main/java/com/arsdigita/cms/contenttypes/ui/SciProjectSponsorForm.java b/sci-types-project/src/main/java/com/arsdigita/cms/contenttypes/ui/SciProjectSponsorForm.java deleted file mode 100644 index 0b8234a..0000000 --- a/sci-types-project/src/main/java/com/arsdigita/cms/contenttypes/ui/SciProjectSponsorForm.java +++ /dev/null @@ -1,214 +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.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.TextField; -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.cms.ui.authoring.SelectedLanguageUtil; -import com.arsdigita.cms.ui.authoring.SimpleEditStep; -import com.arsdigita.globalization.GlobalizedMessage; - -import org.libreccm.cdi.utils.CdiUtil; -import org.librecms.assets.Organization; -import org.scientificcms.contenttypes.sciproject.SciProject; -import org.scientificcms.contenttypes.sciproject.SciProjectConstants; - -/** - * - * @author Jens Pelzetter - */ -public class SciProjectSponsorForm - extends BasicItemForm - implements FormInitListener, FormProcessListener, FormSubmissionListener { - - private final SimpleEditStep editStep; - - private AssetSearchWidget itemSearch; - - private TextField fundingCode; - - private Text selectedSponsorLabel; - - private StringParameter selectedLanguageParam; - - public SciProjectSponsorForm(final ItemSelectionModel itemModel, - final SimpleEditStep editStep, - final StringParameter selectedLanguageParam) { - super("SciProjectSetSponsor", itemModel, selectedLanguageParam); - this.editStep = editStep; - addSubmissionListener(this); - } - - @Override - public void addWidgets() { - - itemSearch = new AssetSearchWidget( - SciProjectUiConstants.SPONSOR_SEARCH, - Organization.class); - itemSearch.setLabel(new GlobalizedMessage( - "sciproject.ui.sponsor", SciProjectConstants.SCI_PROJECT_BUNDLE)); - add(itemSearch); - - selectedSponsorLabel = new Text(); - add(selectedSponsorLabel); - - fundingCode = new TextField(SciProjectUiConstants.FUNDING_CODE); - fundingCode.setLabel(new GlobalizedMessage( - "sciproject.ui.sponsor_fundingcode", - SciProjectConstants.SCI_PROJECT_BUNDLE)); - add(fundingCode); - } - - @Override - public void init(final FormSectionEvent event) throws FormProcessException { - - final FormData data = event.getFormData(); - final PageState state = event.getPageState(); - - final Organization sponsor = ((SciProjectSponsorsStep) editStep). - getSelectedSponsor(); - final String sponsorFundingCode = ((SciProjectSponsorsStep) editStep). - getSelectedSponsorFundingCode(); - - if (sponsor == null) { - itemSearch.setVisible(state, true); - selectedSponsorLabel.setVisible(state, false); - } else { - data.put(SciProjectUiConstants.SPONSOR_SEARCH, sponsor); - if ((sponsorFundingCode == null) || sponsorFundingCode.isEmpty()) { - fundingCode.setValue(state, null); - } else { - fundingCode.setValue(state, sponsorFundingCode); - } - - itemSearch.setVisible(state, false); - selectedSponsorLabel - .setText( - sponsor.getTitle().getValue( - SelectedLanguageUtil.selectedLocale( - state, selectedLanguageParam) - ) - ); - selectedSponsorLabel.setVisible(state, true); - } - - setVisible(state, true); - } - - @Override - public void process(final FormSectionEvent event) - throws FormProcessException { - - final FormData data = event.getFormData(); - final PageState state = event.getPageState(); - final SciProject project = (SciProject) getItemSelectionModel() - .getSelectedObject(state); - - if (getSaveCancelSection().getSaveButton().isSelected(state)) { - final Organization sponsor = ((SciProjectSponsorsStep) editStep). - getSelectedSponsor(); - - String sponsorFundingCode; - if (fundingCode.getValue(state) == null) { - sponsorFundingCode = null; - } else { - sponsorFundingCode = (String) fundingCode.getValue(state); - } - - final CdiUtil cdiUtil = CdiUtil.createCdiUtil(); - final SciProjectController controller = cdiUtil - .findBean(SciProjectController.class); - if (sponsor == null) { - final Organization sponsorToAdd = (Organization) data - .get(SciProjectUiConstants.SPONSOR_SEARCH); - - if ((sponsorFundingCode == null) || sponsorFundingCode.isEmpty()) { - controller.addSponsor(project.getObjectId(), - sponsorToAdd.getObjectId(), - ""); - } else { - controller.addSponsor(project.getObjectId(), - sponsorToAdd.getObjectId(), - sponsorFundingCode); - } - } else { - - controller.updateFundingCode(project.getObjectId(), - sponsor.getObjectId(), - sponsorFundingCode); - } - } - - init(event); - } - - @Override - public void submitted(final FormSectionEvent event) - throws FormProcessException { - - if (getSaveCancelSection() - .getCancelButton() - .isSelected(event.getPageState())) { - - ((SciProjectSponsorsStep) editStep).setSelectedSponsor(null); - ((SciProjectSponsorsStep) editStep) - .setSelectedSponsorFundingCode(null); - - init(event); - } - } - - @Override - public void validate(final FormSectionEvent event) - throws FormProcessException { - - final PageState state = event.getPageState(); - final FormData data = event.getFormData(); - boolean editing = false; //Are we editing the association? - - if ((((SciProjectSponsorsStep) editStep).getSelectedSponsor() == null) - && (data.get(SciProjectUiConstants.SPONSOR_SEARCH) == null)) { - data.addError(new GlobalizedMessage( - "sciproject.ui.sponsor_no_sponsor_selected", - SciProjectConstants.SCI_PROJECT_BUNDLE)); - return; - } - - final SciProject project = (SciProject) getItemSelectionModel() - .getSelectedObject(state); - Organization sponsor = (Organization) data - .get(SciProjectUiConstants.SPONSOR_SEARCH); - if (sponsor == null) { - sponsor = ((SciProjectSponsorsStep) editStep).getSelectedSponsor(); - editing = true; - } - - if (!editing) { - final CdiUtil cdiUtil = CdiUtil.createCdiUtil(); - final SciProjectController controller = cdiUtil - .findBean(SciProjectController.class); - - if (controller.hasSponsor(project.getObjectId(), - sponsor.getObjectId())) { - data.addError(new GlobalizedMessage( - "sciproject.ui.sponsor.already_added", - SciProjectConstants.SCI_PROJECT_BUNDLE)); - } - } - } - -} diff --git a/sci-types-project/src/main/java/com/arsdigita/cms/contenttypes/ui/SciProjectSponsorSheet.java b/sci-types-project/src/main/java/com/arsdigita/cms/contenttypes/ui/SciProjectSponsorSheet.java deleted file mode 100644 index 16c4dd9..0000000 --- a/sci-types-project/src/main/java/com/arsdigita/cms/contenttypes/ui/SciProjectSponsorSheet.java +++ /dev/null @@ -1,395 +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.cms.ui.authoring.SimpleEditStep; -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.contenttypes.sciproject.Contact; -import org.scientificcms.contenttypes.sciproject.SciProject; -import org.scientificcms.contenttypes.sciproject.SciProjectConstants; -import org.scientificcms.contenttypes.sciproject.Sponsoring; - -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Optional; - -/** - * - * @author Jens Pelzetter - */ -public class SciProjectSponsorSheet - extends Table implements TableActionListener { - - 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"; - - private final String SELECTED_PROJECT - = "selected_project_sponsor_association_project"; - - private final String SELECTED_SPONSOR - = "selected_project_sponsor_association_sponsor"; - - private final ItemSelectionModel itemModel; - - private final SciProjectSponsorsStep editStep; - - public SciProjectSponsorSheet(final ItemSelectionModel itemModel, - final SciProjectSponsorsStep editStep) { - - super(); - this.itemModel = itemModel; - this.editStep = editStep; - - setEmptyView(new Label(new GlobalizedMessage( - "sciproject.ui.sponsor_none", - SciProjectConstants.SCI_PROJECT_BUNDLE))); - - final TableColumnModel columnModel = getColumnModel(); - columnModel.add(new TableColumn( - 0, - new GlobalizedMessage("sciproject.ui.sponsor_name", - SciProjectConstants.SCI_PROJECT_BUNDLE), - TABLE_COL_EDIT)); - columnModel.add(new TableColumn( - 1, - new GlobalizedMessage("sciproject.ui.sponsor_fundingcode", - SciProjectConstants.SCI_PROJECT_BUNDLE))); - columnModel.add(new TableColumn( - 2, - new GlobalizedMessage("sciproject.ui.sponsor_edit_assoc", - SciProjectConstants.SCI_PROJECT_BUNDLE), - TABLE_COL_EDIT_ASSOC)); - columnModel.add(new TableColumn( - 3, - new GlobalizedMessage("sciproject.ui.sponsor_remove", - SciProjectConstants.SCI_PROJECT_BUNDLE), - TABLE_COL_DEL)); - columnModel.add(new TableColumn( - 4, - new GlobalizedMessage( - "sciproject.ui.sponsor.up", - SciProjectConstants.SCI_PROJECT_BUNDLE), - TABLE_COL_UP)); - columnModel.add(new TableColumn( - 5, - new GlobalizedMessage( - "sciproject.ui.sponsor.down", - SciProjectConstants.SCI_PROJECT_BUNDLE), - TABLE_COL_DOWN)); - - setModelBuilder(new ModelBuilder(itemModel)); - - columnModel.get(0).setCellRenderer(new EditCellRenderer()); - columnModel.get(2).setCellRenderer(new EditAssocCellRenderer()); - columnModel.get(3).setCellRenderer(new DeleteCellRenderer()); - columnModel.get(4).setCellRenderer(new UpCellRenderer()); - columnModel.get(5).setCellRenderer(new DownCellRenderer()); - - addTableActionListener(this); - - } - - @Override - public void cellSelected(final TableActionEvent event) throws - FormProcessException { - - final PageState state = event.getPageState(); - final SciProject selected = (SciProject) itemModel - .getSelectedItem(state); - final CdiUtil cdiUtil = CdiUtil.createCdiUtil(); - final SciProjectController controller = cdiUtil - .findBean(SciProjectController.class); - final Sponsoring sponsoring = controller - .findSponsoring(selected.getObjectId(), event.getRowKey()) - .get(); - - final TableColumn column = getColumnModel().get(event.getColumn()); - - if (TABLE_COL_EDIT_ASSOC.equals(column.getHeaderKey())) { - editStep.setSelectedSponsor(sponsoring.getSponsor()); - editStep.setSelectedSponsorFundingCode(sponsoring.getFundingCode()); - - editStep.showComponent(state, - SciProjectUiConstants.ADD_CONTACT_SHEET_NAME); - } else if (TABLE_COL_DEL.equals(column.getHeaderKey())) { - controller.removeContact(selected.getObjectId(), - sponsoring.getSponsoringId()); - } else if (TABLE_COL_UP.equals(column.getHeaderKey())) { - controller.swapWithPreviousContact(selected.getObjectId(), - sponsoring.getSponsoringId()); - } else if (TABLE_COL_DOWN.equals(column.getHeaderKey())) { - controller.swapWithNextContact(selected.getObjectId(), - sponsoring.getSponsoringId()); - } - } - - @Override - public void headSelected(final TableActionEvent event) { - - // Nothing - } - - private class ModelBuilder - extends LockableImpl implements TableModelBuilder { - - private final ItemSelectionModel itemModel; - - public ModelBuilder(final ItemSelectionModel itemModel) { - this.itemModel = itemModel; - } - - @Override - public TableModel makeModel(final Table table, final PageState state) { - - table.getRowSelectionModel().clearSelection(state); - final SciProject project = (SciProject) itemModel - .getSelectedObject(state); - return new Model(table, state, project); - } - - } - - private class Model implements TableModel { - - private final Table table; - - private final Iterator> sponsors; - - private Map currentRow; - - public Model(final Table table, final PageState state, - final SciProject project) { - this.table = table; - - final CdiUtil cdiUtil = CdiUtil.createCdiUtil(); - final SciProjectController controller = cdiUtil - .findBean(SciProjectController.class); - - sponsors = controller.getSponsors(project.getObjectId()).iterator(); - } - - @Override - public int getColumnCount() { - return table.getColumnModel().size(); - } - - @Override - public boolean nextRow() { - - if (sponsors.hasNext()) { - currentRow = sponsors.next(); - return true; - } else { - return false; - } - } - - @Override - public Object getElementAt(final int columnIndex) { - switch (columnIndex) { - case 0: - return currentRow.get(SciProjectController.SPONSOR_NAME); - case 1: - return currentRow - .get(SciProjectController.SPONSOR_FUNDING_CODE); - case 2: - return new Label(new GlobalizedMessage( - "sciproject.ui.sponsor.edit_assoc", - SciProjectConstants.SCI_PROJECT_BUNDLE)); - case 3: - return new Label(new GlobalizedMessage( - "sciproject.ui.sponsor.remove", - SciProjectConstants.SCI_PROJECT_BUNDLE)); - default: - return null; - } - } - - @Override - public Object getKeyAt(final int columnIndex) { - return currentRow.get(SciProjectController.SPONSOR_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) { - - final SciProject selected = (SciProject) itemModel - .getSelectedItem(state); - final CdiUtil cdiUtil = CdiUtil.createCdiUtil(); - final SciProjectController controller = cdiUtil - .findBean(SciProjectController.class); - final Optional sponsoring = controller - .findSponsoring(selected.getObjectId(), key); - - return new Text(sponsoring.get().getSponsor().getName()); - } - - } - - 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 CdiUtil cdiUtil = CdiUtil.createCdiUtil(); - final PermissionChecker permissionChecker = cdiUtil - .findBean(PermissionChecker.class); - - final SciProject selected = (SciProject) 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( - Table table, - PageState state, - Object value, - boolean isSelected, - Object key, - int row, - int col) { - - final CdiUtil cdiUtil = CdiUtil.createCdiUtil(); - final PermissionChecker permissionChecker = cdiUtil - .findBean(PermissionChecker.class); - - final SciProject selected = (SciProject) itemModel - .getSelectedItem(state); - final boolean canEdit = permissionChecker - .isPermitted(ItemPrivileges.EDIT, selected); - - if (canEdit) { - final ControlLink link = new ControlLink((Component) value); - link.setConfirmation(new GlobalizedMessage( - "cms.contenttypes.ui.sciproject.confirm_delete", - SciProjectConstants.SCI_PROJECT_BUNDLE - )); - return link; - } else { - return new Text(""); - } - } - - } - - private class UpCellRenderer extends LockableImpl implements - TableCellRenderer { - - @Override - public Component getComponent( - Table table, - PageState state, - Object value, - boolean isSelected, - Object key, - int row, - int col) { - - if (0 == row) { - return new Label(); - } else { - ControlLink link = new ControlLink("up"); - return link; - } - - } - - } - - private class DownCellRenderer extends LockableImpl implements - TableCellRenderer { - - @Override - public Component getComponent( - Table table, - PageState state, - Object value, - boolean isSelected, - Object key, - int row, - int col) { - - final SciProject selected = (SciProject) itemModel - .getSelectedItem(state); - final CdiUtil cdiUtil = CdiUtil.createCdiUtil(); - final SciProjectController controller = cdiUtil - .findBean(SciProjectController.class); - final List> contacts = controller - .getContacts(selected.getObjectId()); - - if ((contacts.size() - 1) == row) { - return new Label(); - } else { - ControlLink link = new ControlLink("down"); - return link; - } - } - - } - -} diff --git a/sci-types-project/src/main/java/com/arsdigita/cms/contenttypes/ui/SciProjectSponsorsStep.java b/sci-types-project/src/main/java/com/arsdigita/cms/contenttypes/ui/SciProjectSponsorsStep.java deleted file mode 100644 index babf6e1..0000000 --- a/sci-types-project/src/main/java/com/arsdigita/cms/contenttypes/ui/SciProjectSponsorsStep.java +++ /dev/null @@ -1,73 +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.Organization; -import org.scientificcms.contenttypes.sciproject.SciProjectConstants; - -/** - * - * @author Jens Pelzetter - */ -public class SciProjectSponsorsStep extends SimpleEditStep { - - private Organization selectedSponsor; - - private String selectedSponsorFundingCode; - - public SciProjectSponsorsStep(final ItemSelectionModel itemModel, - final AuthoringKitWizard parent, - final StringParameter selectedLanguageParam) { - this(itemModel, parent, selectedLanguageParam, null); - } - - public SciProjectSponsorsStep(final ItemSelectionModel itemModel, - final AuthoringKitWizard parent, - final StringParameter selectedLanguageParam, - final String prefix) { - - super(itemModel, parent, selectedLanguageParam, prefix); - - final BasicItemForm sponsorForm = new SciProjectSponsorForm( - itemModel, this, selectedLanguageParam); - add(SciProjectUiConstants.SPONSOR_STEP, - new GlobalizedMessage("sciproject.ui.sponsor.add", - SciProjectConstants.SCI_PROJECT_BUNDLE), - new WorkflowLockedComponentAccess(sponsorForm, itemModel), - sponsorForm.getSaveCancelSection().getCancelButton()); - - final SciProjectSponsorSheet sheet = new SciProjectSponsorSheet( - itemModel, this); - setDisplayComponent(sheet); - } - - protected Organization getSelectedSponsor() { - return selectedSponsor; - } - - protected void setSelectedSponsor( - final Organization selectedSponsor) { - this.selectedSponsor = selectedSponsor; - } - - protected String getSelectedSponsorFundingCode() { - return selectedSponsorFundingCode; - } - - protected void setSelectedSponsorFundingCode( - final String selectedSponsorFundingCode) { - this.selectedSponsorFundingCode = selectedSponsorFundingCode; - } - -} diff --git a/sci-types-project/src/main/java/com/arsdigita/cms/contenttypes/ui/SciProjectUiConstants.java b/sci-types-project/src/main/java/com/arsdigita/cms/contenttypes/ui/SciProjectUiConstants.java deleted file mode 100644 index 0d88278..0000000 --- a/sci-types-project/src/main/java/com/arsdigita/cms/contenttypes/ui/SciProjectUiConstants.java +++ /dev/null @@ -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; - -/** - * - * @author Jens Pelzetter - */ -public final class SciProjectUiConstants { - - public static final String ADD_CONTACT_SHEET_NAME = "addContact"; - - public static final String ADD_MEMBER_SHEET_NAME = "addMember"; - - public static final String BEGIN = "begin"; - - public static final String EDIT_CONTACT_SHEET_NAME = "edit"; - - public static final String EDIT_DESC_SHEET_NAME = "editProjectDesc"; - - public static final String EDIT_DESC_TEXT_SHEET_NAME = "editProjectDescText"; - - public static final String FUNDING = "funding"; - - public static final String FUNDING_VOLUME = "fundingVolume"; - - public static final String FUNDING_CODE = "fundingCode"; - - public static final String END = "end"; - - public static final String NAME = "name"; - - public static final String MEMBER_ROLE = "memberRole"; - - public static final String MEMBER_SEARCH = "memberSearch"; - - public static final String MEMBER_STATUS = "memberStatus"; - - public static final String PROJECT_SHORT_DESCRIPTION = "shortDescription"; - - public static final String PROJECT_DESCRIPTION = "description"; - - public static final String SPONSOR_STEP = "SciProjectSponsorStep"; - - public static final String SPONSOR_SEARCH = "setSponsor"; - - public static final String TITLE = "title"; - - public static final String UPLOAD_DESC_TEXT_SHEET_NAME - = "uploadProjectDescText"; - - private SciProjectUiConstants() { - // Nothing - } - -} diff --git a/sci-types-project/src/main/java/org/scientificcms/contenttypes/sciproject/SciProject.java b/sci-types-project/src/main/java/org/scientificcms/contenttypes/sciproject/SciProject.java index e872f74..fbf2e1c 100644 --- a/sci-types-project/src/main/java/org/scientificcms/contenttypes/sciproject/SciProject.java +++ b/sci-types-project/src/main/java/org/scientificcms/contenttypes/sciproject/SciProject.java @@ -5,11 +5,6 @@ */ package org.scientificcms.contenttypes.sciproject; -import com.arsdigita.cms.contenttypes.ui.SciProjectDescriptionStep; -import com.arsdigita.cms.contenttypes.ui.SciProjectMembersStep; -import com.arsdigita.cms.contenttypes.ui.SciProjectPropertiesStep; -import com.arsdigita.cms.ui.authoring.PageCreateForm; - import javax.persistence.Entity; import org.hibernate.envers.Audited; @@ -51,35 +46,6 @@ import static org.scientificcms.contenttypes.sciproject.SciProjectConstants.*; labelBundle = "org.scientificcms.contenttypes.SciProject", descriptionBundle = "org.scientificcms.contenttypes.SciProject" ) -@AuthoringKit( - createComponent = PageCreateForm.class, - steps = { - @AuthoringStep( - component = SciProjectPropertiesStep.class, - labelBundle = SciProjectConstants.SCI_PROJECT_BUNDLE, - labelKey = "cms.contenttypes.shared.basic_properties.title", - descriptionBundle = SciProjectConstants.SCI_PROJECT_BUNDLE, - descriptionKey = "cms.contenttypes.shared.basic_properties" - + ".description", - order = 1 - ), - @AuthoringStep( - component = SciProjectMembersStep.class, - labelBundle = SciProjectConstants.SCI_PROJECT_BUNDLE, - labelKey = "sciproject.membersstep.label", - descriptionBundle = SciProjectConstants.SCI_PROJECT_BUNDLE, - descriptionKey = "sciproject.membersstep.description", - order = 2 - ), - @AuthoringStep( - component = SciProjectDescriptionStep.class, - labelBundle = SciProjectConstants.SCI_PROJECT_BUNDLE, - labelKey = "sciproject.descriptionstep.label", - descriptionBundle = SciProjectConstants.SCI_PROJECT_BUNDLE, - descriptionKey = "sciproject.descriptionstep.description", - order = 3 - ) - }) @NamedQueries({ @NamedQuery( name = "SciProject.findWhereBeginIsBefore", diff --git a/sci-types-project/src/main/java/org/scientificcms/contenttypes/sciproject/SciProjectImExporter.java b/sci-types-project/src/main/java/org/scientificcms/contenttypes/sciproject/SciProjectImExporter.java index a6141a0..7533b7d 100644 --- a/sci-types-project/src/main/java/org/scientificcms/contenttypes/sciproject/SciProjectImExporter.java +++ b/sci-types-project/src/main/java/org/scientificcms/contenttypes/sciproject/SciProjectImExporter.java @@ -19,7 +19,7 @@ import javax.enterprise.context.RequestScoped; public class SciProjectImExporter extends AbstractContentItemImExporter{ @Override - protected Class getEntityClass() { + public Class getEntityClass() { return SciProject.class; } diff --git a/sci-types-project/src/test/java/org/scientificcms/contenttypes/sciproject/EqualsAndHashCodeTest.java b/sci-types-project/src/test/java/org/scientificcms/contenttypes/sciproject/EqualsAndHashCodeTest.java index 065fe10..a472c63 100644 --- a/sci-types-project/src/test/java/org/scientificcms/contenttypes/sciproject/EqualsAndHashCodeTest.java +++ b/sci-types-project/src/test/java/org/scientificcms/contenttypes/sciproject/EqualsAndHashCodeTest.java @@ -13,7 +13,6 @@ import org.libreccm.categorization.Category; import org.libreccm.core.CcmObject; import org.libreccm.l10n.LocalizedString; import org.libreccm.security.SecurityEntitiesPrefabProvider; -import org.libreccm.tests.categories.UnitTest; import org.libreccm.testutils.EqualsVerifier; import org.libreccm.workflow.Workflow; import org.librecms.assets.ContactableEntity; @@ -35,7 +34,6 @@ import java.util.Locale; * @author Jens Pelzetter */ @RunWith(Parameterized.class) -@org.junit.experimental.categories.Category(UnitTest.class) public class EqualsAndHashCodeTest extends EqualsVerifier { @Parameterized.Parameters(name = "{0}") @@ -162,12 +160,12 @@ public class EqualsAndHashCodeTest extends EqualsVerifier { final Workflow workflow1 = new Workflow(); final LocalizedString workflow1Name = new LocalizedString(); - workflow1Name.addValue(Locale.ROOT, "workflow1"); + workflow1Name.putValue(Locale.ROOT, "workflow1"); workflow1.setName(workflow1Name); final Workflow workflow2 = new Workflow(); final LocalizedString workflow2Name = new LocalizedString(); - workflow2Name.addValue(Locale.ROOT, "workflow2"); + workflow2Name.putValue(Locale.ROOT, "workflow2"); workflow2.setName(workflow2Name); verifier.withPrefabValues(Workflow.class, workflow1, workflow2); diff --git a/scicms-bundle-devel-wildfly/pom.xml b/scicms-bundle-devel-wildfly/pom.xml index 4b1f85a..2d1d56b 100644 --- a/scicms-bundle-devel-wildfly/pom.xml +++ b/scicms-bundle-devel-wildfly/pom.xml @@ -100,7 +100,7 @@ install-node-and-npm - v8.11.4 + v14.17.0 + org.libreccm ccm-pagemodelseditor @@ -198,6 +198,62 @@ assets/ + + org.libreccm + ccm-core + jar + + themes/ + + + + org.libreccm + ccm-core + jar + + WEB-INF/ + + + + org.libreccm + ccm-shortcuts + jar + + WEB-INF/ + + + + org.libreccm + ccm-core + jar + + resources/ + + + + org.librecms + ccm-cms + jar + + WEB-INF/ + + + + org.librecms + ccm-cms + jar + + assets/ + + + + org.librecms + ccm-cms + jar + + icons/ + + org.librecms ccm-cms @@ -217,14 +273,107 @@ + + + org.apache.maven.plugins + maven-clean-plugin + + true + + + ${project.build.directory} + + wildfly*/** + + + + + + + + org.codehaus.mojo + properties-maven-plugin + + + read-runtime-properties + initialize + + read-project-properties + + + + ${project.basedir}/runtime.example.properties + ${project.basedir}/runtime.properties + + true + + + + - +
+ + + org.wildfly.plugins + wildfly-jar-maven-plugin + + + -agentlib:jdwp=transport=dt_socket,server=y,suspend=${libreccm.debug.suspend},address=${libreccm.debug.port} + + + -Dorg.wildfly.datasources.postgresql.database=${libreccm.database.name} + -Dorg.wildfly.datasources.postgresql.host=${libreccm.database.host} + -Dorg.wildfly.datasources.postgresql.jndi-name=java:/comp/env/jdbc/libreccm/db + -Dorg.wildfly.datasources.postgresql.password=${libreccm.database.password} + -Dorg.wildfly.datasources.postgresql.port=${libreccm.database.port} + -Dorg.wildfly.datasources.postgresql.user-name=${libreccm.database.user} + + + + wildfly@maven(org.jboss.universe:community-universe)#24.0.1.Final + + + org.wildfly + wildfly-datasources-galleon-pack + 2.0.2.Final + + + + cdi + datasources + ejb + jaxrs + jpa + jsf + jsonp + logging + mail + management + postgresql-datasource + + + false + + + + + package + + + + diff --git a/scientificcms/pom.xml b/scientificcms/pom.xml index 95ec7ab..3b3d5df 100644 --- a/scientificcms/pom.xml +++ b/scientificcms/pom.xml @@ -4,10 +4,10 @@ 4.0.0 - scientificcms-parent - org.scientificcms - 7.0.0-SNAPSHOT - + scientificcms-parent + org.scientificcms + 7.0.0-SNAPSHOT + UTF-8 @@ -43,7 +43,7 @@ - org.hibernate + org.hibernate.validator hibernate-validator provided @@ -109,10 +109,9 @@ org.apache.maven.plugins maven-compiler-plugin - 3.3 - 1.7 - 1.7 + 11 + 11 true true ${project.build.sourceEncoding} @@ -122,16 +121,14 @@ org.apache.maven.plugins maven-surefire-plugin - 2.18.1 org.libreccm.tests.categories.UnitTest - + org.jacoco jacoco-maven-plugin - 0.7.5.201505241946 default-prepare-agent @@ -187,7 +184,6 @@ org.apache.maven.plugins maven-javadoc-plugin - 2.10.3 true true @@ -206,47 +202,34 @@ true true false - org.jboss.apiviz.APIviz - - org.jboss.apiviz - apiviz - 1.3.2.GA - - true - -sourceclasspath ${project.build.outputDirectory} org.apache.maven.plugins maven-jxr-plugin - 2.5 org.apache.maven.plugins maven-surefire-report-plugin - 2.18.1 org.jacoco jacoco-maven-plugin - 0.7.5.201505241946 org.codehaus.mojo findbugs-maven-plugin - 3.0.1 org.apache.maven.plugins maven-pmd-plugin - 3.7 true utf-8 1.8 - + org.codehaus.mojo javancss-maven-plugin - 2.1 org.apache.maven.plugins maven-project-info-reports-plugin - 2.8 dependencies - licenses + licenses