Ported forms for CollectedVolume

pull/1/head
Jens Pelzetter 2019-11-17 18:00:49 +01:00
parent a562636296
commit 8cd3ff1683
8 changed files with 920 additions and 15 deletions

View File

@ -0,0 +1,102 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.arsdigita.cms.contenttypes.ui;
import com.arsdigita.bebop.FormData;
import com.arsdigita.bebop.FormProcessException;
import com.arsdigita.bebop.PageState;
import com.arsdigita.bebop.event.FormInitListener;
import com.arsdigita.bebop.event.FormProcessListener;
import com.arsdigita.bebop.event.FormSectionEvent;
import com.arsdigita.bebop.parameters.StringParameter;
import com.arsdigita.cms.ItemSelectionModel;
import com.arsdigita.cms.ui.authoring.BasicItemForm;
import com.arsdigita.globalization.GlobalizedMessage;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.libreccm.cdi.utils.CdiUtil;
import org.scientificcms.publications.ArticleInCollectedVolume;
import org.scientificcms.publications.SciPublicationsConstants;
import org.scientificcms.publications.contenttypes.CollectedVolumeItem;
/**
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
public class CollectedVolumeArticlesAddForm
extends BasicItemForm
implements FormProcessListener,
FormInitListener {
private static final Logger LOGGER = LogManager.getLogger(
CollectedVolumeArticlesAddForm.class
);
private final String ARTICLE_SEARCH = "articles";
private final ItemSelectionModel itemModel;
private PublicationSearchWidget articleSearch;
public CollectedVolumeArticlesAddForm(
final ItemSelectionModel itemModel,
final StringParameter selectedLangParam
) {
super("ArticlesAddForm", itemModel, selectedLangParam);
this.itemModel = itemModel;
}
@Override
protected void addWidgets() {
articleSearch = new PublicationSearchWidget(
ARTICLE_SEARCH, ArticleInCollectedVolume.class
);
articleSearch.setLabel(
new GlobalizedMessage(
"publications.ui.collected_volume.articles.select_article",
SciPublicationsConstants.BUNDLE
)
);
add(articleSearch);
}
@Override
public void init(final FormSectionEvent event) throws FormProcessException {
final PageState state = event.getPageState();
setVisible(state, true);
}
@Override
public void process(final FormSectionEvent event)
throws FormProcessException {
final FormData formData = event.getFormData();
final PageState state = event.getPageState();
final CollectedVolumeItem collectedVolumeItem
= (CollectedVolumeItem) getItemSelectionModel()
.getSelectedItem(state);
if (this.getSaveCancelSection().getSaveButton().isSelected(state)) {
final ArticleInCollectedVolume article
= (ArticleInCollectedVolume) formData
.get(ARTICLE_SEARCH);
final CollectedVolumeController controller = CdiUtil
.createCdiUtil()
.findBean(CollectedVolumeController.class);
controller.addArticle(
collectedVolumeItem.getPublication().getPublicationId(),
article.getPublicationId()
);
}
init(event);
}
}

View File

@ -0,0 +1,62 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.arsdigita.cms.contenttypes.ui;
import com.arsdigita.bebop.parameters.StringParameter;
import com.arsdigita.cms.ItemSelectionModel;
import com.arsdigita.cms.ui.authoring.AuthoringKitWizard;
import com.arsdigita.cms.ui.authoring.BasicItemForm;
import com.arsdigita.cms.ui.authoring.SimpleEditStep;
import com.arsdigita.cms.ui.workflow.WorkflowLockedComponentAccess;
import com.arsdigita.globalization.GlobalizedMessage;
import org.scientificcms.publications.SciPublicationsConstants;
/**
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
public class CollectedVolumeArticlesStep extends SimpleEditStep {
private static final String ADD_ARTICLE_SHEET_NAME = "addArticle";
public CollectedVolumeArticlesStep(
final ItemSelectionModel itemModel,
final AuthoringKitWizard parent,
final StringParameter selectedLangParam
) {
this(itemModel, parent, selectedLangParam, null);
}
public CollectedVolumeArticlesStep(
final ItemSelectionModel itemModel,
final AuthoringKitWizard parent,
final StringParameter selectedLangParam,
final String prefix
) {
super(itemModel, parent, selectedLangParam, prefix);
final BasicItemForm addArticleSheet = new CollectedVolumeArticlesAddForm(
itemModel, selectedLangParam
);
add(
ADD_ARTICLE_SHEET_NAME,
new GlobalizedMessage(
"publications.ui.collected_volume.add_article",
SciPublicationsConstants.BUNDLE
),
new WorkflowLockedComponentAccess(addArticleSheet, itemModel),
addArticleSheet.getSaveCancelSection().getCancelButton());
final CollectedVolumeArticlesTable articlesTable
= new CollectedVolumeArticlesTable(
itemModel,
selectedLangParam
);
setDisplayComponent(articlesTable);
}
}

View File

@ -0,0 +1,323 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.arsdigita.cms.contenttypes.ui;
import com.arsdigita.bebop.Component;
import com.arsdigita.bebop.ControlLink;
import com.arsdigita.bebop.Label;
import com.arsdigita.bebop.PageState;
import com.arsdigita.bebop.Table;
import com.arsdigita.bebop.Text;
import com.arsdigita.bebop.event.TableActionEvent;
import com.arsdigita.bebop.event.TableActionListener;
import com.arsdigita.bebop.parameters.StringParameter;
import com.arsdigita.bebop.table.TableCellRenderer;
import com.arsdigita.bebop.table.TableColumn;
import com.arsdigita.bebop.table.TableColumnModel;
import com.arsdigita.bebop.table.TableModel;
import com.arsdigita.bebop.table.TableModelBuilder;
import com.arsdigita.cms.ItemSelectionModel;
import com.arsdigita.globalization.GlobalizedMessage;
import com.arsdigita.util.LockableImpl;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.libreccm.cdi.utils.CdiUtil;
import org.libreccm.security.PermissionChecker;
import org.librecms.contentsection.privileges.ItemPrivileges;
import org.scientificcms.publications.ArticleInCollectedVolume;
import org.scientificcms.publications.CollectedVolume;
import org.scientificcms.publications.SciPublicationsConstants;
import org.scientificcms.publications.contenttypes.CollectedVolumeItem;
import java.util.Iterator;
import java.util.List;
/**
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
public class CollectedVolumeArticlesTable
extends Table
implements TableActionListener {
private static final Logger LOGGER = LogManager.getLogger(
CollectedVolumeArticlesTable.class
);
private final String TABLE_COL_EDIT = "table_col_edit";
private final String TABLE_COL_DEL = "table_col_del";
private final ItemSelectionModel itemModel;
public CollectedVolumeArticlesTable(
final ItemSelectionModel itemModel,
final StringParameter selectedLangParam
) {
super();
this.itemModel = itemModel;
setEmptyView(
new Label(
new GlobalizedMessage(
"publications.ui.collected_volume.no_articles",
SciPublicationsConstants.BUNDLE
)
)
);
TableColumnModel colModel = getColumnModel();
colModel.add(new TableColumn(
0,
new Label(
new GlobalizedMessage(
"publications.ui.collected_volume.article",
SciPublicationsConstants.BUNDLE
)),
TABLE_COL_EDIT));
colModel.add(new TableColumn(
1,
new Label(
new GlobalizedMessage(
"publications.ui.collected_volume.article.remove",
SciPublicationsConstants.BUNDLE
)
),
TABLE_COL_DEL));
setModelBuilder(
new CollectedVolumeArticlesTableModelBuilder(itemModel));
colModel.get(0).setCellRenderer(new EditCellRenderer());
colModel.get(1).setCellRenderer(new DeleteCellRenderer());
addTableActionListener(this);
}
@Override
public void cellSelected(final TableActionEvent event) {
final PageState state = event.getPageState();
final CollectedVolumeController controller = CdiUtil
.createCdiUtil()
.findBean(CollectedVolumeController.class);
final ArticleInCollectedVolume article = controller
.findArticle((Long) event.getRowKey());
final CollectedVolumeItem collectedVolumeItem
= (CollectedVolumeItem) itemModel
.getSelectedObject(state);
final CollectedVolume collectedVolume = collectedVolumeItem
.getPublication();
final List<ArticleInCollectedVolume> articles = collectedVolume
.getArticles();
final TableColumn column = getColumnModel().get(event.getColumn());
if (column.getHeaderKey().toString().equals(TABLE_COL_EDIT)) {
// Nothing
} else if (column.getHeaderKey().toString().equals(TABLE_COL_DEL)) {
controller.removeArticle(
collectedVolume.getPublicationId(),
article.getPublicationId()
);
}
// else if (column.getHeaderKey().toString().equals(TABLE_COL_UP)) {
// controller.swapWithPreviousArticle(
// collectedVolume.getPublicationId(),
// article.getPublicationId()
// );
// } else if (column.getHeaderKey().toString().equals(TABLE_COL_DOWN)) {
// controller.swapWithNextArticle(
// collectedVolume.getPublicationId(),
// article.getPublicationId()
// );
// }
}
@Override
public void headSelected(TableActionEvent event) {
//Nothing to do.
}
private class CollectedVolumeArticlesTableModelBuilder
extends LockableImpl
implements TableModelBuilder {
private final ItemSelectionModel itemModel;
public CollectedVolumeArticlesTableModelBuilder(
final ItemSelectionModel itemModel
) {
this.itemModel = itemModel;
}
@Override
public TableModel makeModel(final Table table, final PageState state) {
table.getRowSelectionModel().clearSelection(state);
final CollectedVolumeItem collectedVolumeItem
= (CollectedVolumeItem) itemModel
.getSelectedItem(state);
return new CollectedVolumeArticlesTableModel(
table, state, collectedVolumeItem.getPublication()
);
}
}
private class CollectedVolumeArticlesTableModel implements TableModel {
private final Table table;
private final Iterator<ArticleInCollectedVolume> articles;
private ArticleInCollectedVolume article;
private CollectedVolumeArticlesTableModel(
final Table table,
final PageState state,
final CollectedVolume collectedVolume
) {
this.table = table;
articles = collectedVolume.getArticles().iterator();
}
@Override
public int getColumnCount() {
return table.getColumnModel().size();
}
@Override
public boolean nextRow() {
return articles != null && articles.hasNext();
}
@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("");
}
}
}
}

View File

@ -0,0 +1,133 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.arsdigita.cms.contenttypes.ui;
import org.scientificcms.publications.ArticleInCollectedVolume;
import org.scientificcms.publications.CollectedVolume;
import org.scientificcms.publications.CollectedVolumeManager;
import org.scientificcms.publications.PublicationRepository;
import java.util.Locale;
import java.util.Map;
import javax.enterprise.context.RequestScoped;
import javax.inject.Inject;
import javax.transaction.Transactional;
/**
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
@RequestScoped
public class CollectedVolumeController {
public static final String PEER_REVIEWED = "peerReviewed";
@Inject
private CollectedVolumeManager collectedVolumeManager;
@Inject
private PublicationRepository publicationRepository;
@Transactional(Transactional.TxType.REQUIRED)
public void save(
final long collectedVolumeId,
final Locale selectedLocale,
final Map<String, Object> data
) {
final CollectedVolume collectedVolume = publicationRepository
.findByIdAndType(collectedVolumeId, CollectedVolume.class)
.orElseThrow(
() -> new IllegalArgumentException(
String.format(
"No CollectedVolume with ID %d found.",
collectedVolumeId
)
)
);
if (data.get(PEER_REVIEWED) != null) {
final Boolean reviewed = (Boolean) data.get(PEER_REVIEWED);
collectedVolume.setPeerReviewed(reviewed);
}
publicationRepository.save(collectedVolume);
}
public ArticleInCollectedVolume findArticle(final long articleId) {
return publicationRepository
.findByIdAndType(articleId, ArticleInCollectedVolume.class)
.orElseThrow(
() -> new IllegalArgumentException(
String.format(
"No ArticleInCollectedVolume with ID %d found.",
articleId
)
)
);
}
public void addArticle(
final long collectedVolumeId, final long articleId
) {
final CollectedVolume collectedVolume = publicationRepository
.findByIdAndType(collectedVolumeId, CollectedVolume.class)
.orElseThrow(
() -> new IllegalArgumentException(
String.format(
"No CollectedVolume with ID %d found",
collectedVolumeId
)
)
);
final ArticleInCollectedVolume article = publicationRepository
.findByIdAndType(articleId, ArticleInCollectedVolume.class)
.orElseThrow(
() -> new IllegalArgumentException(
String.format(
"No ArticleInCollectedVolume with ID %d found.",
articleId
)
)
);
collectedVolumeManager.addArticleToCollectedVolume(
article, collectedVolume
);
}
public void removeArticle(
final long collectedVolumeId, final long articleId
) {
final CollectedVolume collectedVolume = publicationRepository
.findByIdAndType(collectedVolumeId, CollectedVolume.class)
.orElseThrow(
() -> new IllegalArgumentException(
String.format(
"No CollectedVolume with ID %d found",
collectedVolumeId
)
)
);
final ArticleInCollectedVolume article = publicationRepository
.findByIdAndType(articleId, ArticleInCollectedVolume.class)
.orElseThrow(
() -> new IllegalArgumentException(
String.format(
"No ArticleInCollectedVolume with ID %d found.",
articleId
)
)
);
collectedVolumeManager.removeArticleFromCollectedVolume(
article, collectedVolume
);
}
}

View File

@ -5,11 +5,140 @@
*/
package com.arsdigita.cms.contenttypes.ui;
import com.arsdigita.bebop.Component;
import com.arsdigita.bebop.Label;
import com.arsdigita.bebop.PageState;
import com.arsdigita.bebop.parameters.StringParameter;
import com.arsdigita.cms.ItemSelectionModel;
import com.arsdigita.cms.ui.authoring.AuthoringKitWizard;
import com.arsdigita.cms.ui.authoring.BasicPageForm;
import com.arsdigita.cms.ui.authoring.SimpleEditStep;
import com.arsdigita.cms.ui.workflow.WorkflowLockedComponentAccess;
import com.arsdigita.domain.DomainService;
import com.arsdigita.globalization.GlobalizedMessage;
import com.arsdigita.toolbox.ui.DomainObjectPropertySheet;
import org.scientificcms.publications.SciPublicationsConstants;
import static com.arsdigita.cms.contenttypes.ui.PublicationPropertiesStep.*;
/**
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
public class CollectedVolumePropertiesStep
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();
}
}
}
}

View File

@ -0,0 +1,155 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.arsdigita.cms.contenttypes.ui;
import com.arsdigita.bebop.FormData;
import com.arsdigita.bebop.FormProcessException;
import com.arsdigita.bebop.Label;
import com.arsdigita.bebop.PageState;
import com.arsdigita.bebop.event.FormInitListener;
import com.arsdigita.bebop.event.FormProcessListener;
import com.arsdigita.bebop.event.FormSectionEvent;
import com.arsdigita.bebop.event.FormSubmissionListener;
import com.arsdigita.bebop.form.CheckboxGroup;
import com.arsdigita.bebop.form.Option;
import com.arsdigita.bebop.parameters.StringParameter;
import com.arsdigita.cms.ItemSelectionModel;
import com.arsdigita.cms.ui.authoring.SelectedLanguageUtil;
import com.arsdigita.globalization.GlobalizedMessage;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.libreccm.cdi.utils.CdiUtil;
import org.scientificcms.publications.CollectedVolume;
import org.scientificcms.publications.SciPublicationsConstants;
import org.scientificcms.publications.contenttypes.CollectedVolumeItem;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
/**
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
public class CollectedVolumePropertyForm
extends PublicationWithPublisherPropertyForm
implements FormProcessListener,
FormInitListener,
FormSubmissionListener {
private static final Logger LOGGER = LogManager.getLogger(
CollectedVolumePropertyForm.class
);
private static final String ID = "CollectedVolumeEdit";
private final StringParameter selectedLangParam;
private final CollectedVolumePropertiesStep step;
private CheckboxGroup reviewed;
public CollectedVolumePropertyForm(
final ItemSelectionModel itemModel,
final StringParameter selectedLangParam
) {
this(itemModel, null, selectedLangParam);
}
public CollectedVolumePropertyForm(
final ItemSelectionModel itemModel,
CollectedVolumePropertiesStep step,
final StringParameter selectedLangParam
) {
super(itemModel, step, selectedLangParam);
this.step = step;
this.selectedLangParam = selectedLangParam;
addSubmissionListener(this);
}
@Override
protected void addWidgets() {
super.addWidgets();
reviewed = new CheckboxGroup("reviewedGroup");
reviewed.addOption(
new Option(
CollectedVolumeController.PEER_REVIEWED,
new Label(
new GlobalizedMessage(
"publications.ui.collectedVolume.reviewed",
SciPublicationsConstants.BUNDLE
)
)
)
);
reviewed.setLabel(
new GlobalizedMessage(
"publications.ui.collectedVolume.reviewed",
SciPublicationsConstants.BUNDLE
)
);
add(reviewed);
}
@Override
public void init(final FormSectionEvent event) throws FormProcessException {
super.init(event);
final FormData data = event.getFormData();
final CollectedVolumeItem collectedVolumeItem
= (CollectedVolumeItem) super
.initBasicWidgets(event);
final CollectedVolume collectedVolume = collectedVolumeItem
.getPublication();
if ((collectedVolume.getPeerReviewed() != null)
&& (collectedVolume.getPeerReviewed())) {
reviewed.setValue(
event.getPageState(),
new String[]{CollectedVolumeController.PEER_REVIEWED}
);
} else {
reviewed.setValue(event.getPageState(), null);
}
}
@Override
public void process(final FormSectionEvent event) throws
FormProcessException {
super.process(event);
final PageState state = event.getPageState();
final CollectedVolumeItem collectedVolumeItem
= (CollectedVolumeItem) super
.processBasicWidgets(event);
if ((collectedVolumeItem != null)
&& getSaveCancelSection().getSaveButton().isSelected(state)) {
final CollectedVolumeController controller = CdiUtil
.createCdiUtil()
.findBean(CollectedVolumeController.class);
final Map<String, Object> data = new HashMap<>();
if (reviewed.getValue(state.getPageState()) == null) {
data.put(CollectedVolumeController.PEER_REVIEWED, false);
} else {
data.put(CollectedVolumeController.PEER_REVIEWED, true);
}
controller.save(
collectedVolumeItem.getPublication().getPublicationId(),
SelectedLanguageUtil.selectedLocale(
state, selectedLangParam
),
data);
}
}
}

View File

@ -73,5 +73,5 @@ public class CollectedVolumeManager implements Serializable {
publicationRepository.save(article);
publicationRepository.save(collectedVolume);
}
}

View File

@ -154,10 +154,11 @@ public class PublicationManager {
@AuthorizationRequired
@RequiresPrivilege(ItemPrivileges.EDIT)
@Transactional(Transactional.TxType.REQUIRED)
public void moveAuthorToPosition(final Publication ofPublication,
final Person author,
final int toPosition) {
public void moveAuthorToPosition(
final Publication ofPublication,
final Person author,
final int toPosition
) {
Objects.requireNonNull(ofPublication);
Objects.requireNonNull(author);
if (toPosition < 0) {
@ -357,20 +358,20 @@ public class PublicationManager {
) {
Objects.requireNonNull(series);
Objects.requireNonNull(fromPublication);
final Optional<VolumeInSeries> result = fromPublication
.getSeries()
.stream()
.filter(volume -> volume.getSeries().equals(series))
.findAny();
.getSeries()
.stream()
.filter(volume -> volume.getSeries().equals(series))
.findAny();
if (!result.isPresent()) {
return;
}
final VolumeInSeries remove = result.get();
fromPublication.removeSeries(remove);
entityManager.remove(remove);
publicationRepository.save(fromPublication);
}