Ported more forms
parent
32b170318b
commit
d7079d279e
|
|
@ -114,9 +114,7 @@ public class ArticleInCollectedVolumeCollectedVolumeSheet
|
|||
= (ArticleInCollectedVolumeItem) itemModel
|
||||
.getSelectedObject(state);
|
||||
|
||||
final TableColumn column = getColumnModel().get(
|
||||
event.getColumn().intValue()
|
||||
);
|
||||
final TableColumn column = getColumnModel().get(event.getColumn());
|
||||
|
||||
if (column.getHeaderKey().toString().equals(TABLE_COL_EDIT)) {
|
||||
// Nothing
|
||||
|
|
@ -160,7 +158,6 @@ public class ArticleInCollectedVolumeCollectedVolumeSheet
|
|||
return new ArticleInCollectedVolumeCollectedVolumeSheetModel(
|
||||
table, state, article, selectedLangParam
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,10 +41,12 @@ public class ArticleInCollectedVolumeCollectedVolumeStep
|
|||
final StringParameter selectedLanguageParam,
|
||||
final String parameterSuffix
|
||||
) {
|
||||
super(itemSelectionModel,
|
||||
authoringKitWizard,
|
||||
selectedLanguageParam,
|
||||
parameterSuffix);
|
||||
super(
|
||||
itemSelectionModel,
|
||||
authoringKitWizard,
|
||||
selectedLanguageParam,
|
||||
parameterSuffix
|
||||
);
|
||||
|
||||
final BasicItemForm addCollectedVolumeForm
|
||||
= new ArticleInCollectedVolumeCollectedVolumeForm(
|
||||
|
|
@ -52,22 +54,22 @@ public class ArticleInCollectedVolumeCollectedVolumeStep
|
|||
selectedLanguageParam
|
||||
);
|
||||
|
||||
add(ADD_COLLECTED_VOLUME_STEP,
|
||||
add(
|
||||
ADD_COLLECTED_VOLUME_STEP,
|
||||
new GlobalizedMessage(
|
||||
"publications.ui.collectedVolume.addCollectedVolume",
|
||||
SciPublicationsConstants.BUNDLE
|
||||
),
|
||||
new WorkflowLockedComponentAccess(
|
||||
addCollectedVolumeForm,
|
||||
itemSelectionModel
|
||||
addCollectedVolumeForm, itemSelectionModel
|
||||
),
|
||||
addCollectedVolumeForm.getSaveCancelSection().getCancelButton());
|
||||
addCollectedVolumeForm.getSaveCancelSection().getCancelButton()
|
||||
);
|
||||
|
||||
final ArticleInCollectedVolumeCollectedVolumeSheet sheet
|
||||
= new ArticleInCollectedVolumeCollectedVolumeSheet(
|
||||
= new ArticleInCollectedVolumeCollectedVolumeSheet(
|
||||
itemSelectionModel, selectedLanguageParam);
|
||||
setDisplayComponent(sheet);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -138,8 +138,7 @@ public class ArticleInJournalController {
|
|||
|
||||
@Transactional(Transactional.TxType.REQUIRED)
|
||||
public void unsetJournal(
|
||||
final long articleId, final long journalId
|
||||
) {
|
||||
final long articleId) {
|
||||
final ArticleInJournal article = publicationRepository
|
||||
.findByIdAndType(articleId, ArticleInJournal.class)
|
||||
.orElseThrow(
|
||||
|
|
|
|||
|
|
@ -5,10 +5,89 @@
|
|||
*/
|
||||
package com.arsdigita.cms.contenttypes.ui;
|
||||
|
||||
import com.arsdigita.bebop.FormData;
|
||||
import com.arsdigita.bebop.FormProcessException;
|
||||
import com.arsdigita.bebop.PageState;
|
||||
import com.arsdigita.bebop.event.FormInitListener;
|
||||
import com.arsdigita.bebop.event.FormProcessListener;
|
||||
import com.arsdigita.bebop.event.FormSectionEvent;
|
||||
import com.arsdigita.bebop.parameters.StringParameter;
|
||||
import com.arsdigita.cms.ItemSelectionModel;
|
||||
import com.arsdigita.cms.ui.authoring.BasicItemForm;
|
||||
import com.arsdigita.globalization.GlobalizedMessage;
|
||||
|
||||
import org.libreccm.cdi.utils.CdiUtil;
|
||||
import org.scientificcms.publications.ArticleInJournal;
|
||||
import org.scientificcms.publications.Journal;
|
||||
import org.scientificcms.publications.SciPublicationsConstants;
|
||||
import org.scientificcms.publications.contenttypes.ArticleInJournalItem;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||
*/
|
||||
public class ArticleInJournalJournalForm {
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,10 +5,280 @@
|
|||
*/
|
||||
package com.arsdigita.cms.contenttypes.ui;
|
||||
|
||||
import com.arsdigita.bebop.Component;
|
||||
import com.arsdigita.bebop.ControlLink;
|
||||
import com.arsdigita.bebop.Label;
|
||||
import com.arsdigita.bebop.PageState;
|
||||
import com.arsdigita.bebop.Table;
|
||||
import com.arsdigita.bebop.Text;
|
||||
import com.arsdigita.bebop.event.TableActionEvent;
|
||||
import com.arsdigita.bebop.event.TableActionListener;
|
||||
import com.arsdigita.bebop.parameters.StringParameter;
|
||||
import com.arsdigita.bebop.table.TableCellRenderer;
|
||||
import com.arsdigita.bebop.table.TableColumn;
|
||||
import com.arsdigita.bebop.table.TableColumnModel;
|
||||
import com.arsdigita.bebop.table.TableModel;
|
||||
import com.arsdigita.bebop.table.TableModelBuilder;
|
||||
import com.arsdigita.cms.ItemSelectionModel;
|
||||
import com.arsdigita.globalization.GlobalizedMessage;
|
||||
import com.arsdigita.util.LockableImpl;
|
||||
|
||||
import org.libreccm.cdi.utils.CdiUtil;
|
||||
import org.libreccm.security.PermissionChecker;
|
||||
import org.librecms.contentsection.privileges.ItemPrivileges;
|
||||
import org.scientificcms.publications.Journal;
|
||||
import org.scientificcms.publications.SciPublicationsConstants;
|
||||
import org.scientificcms.publications.contenttypes.ArticleInJournalItem;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||
*/
|
||||
public class ArticleInJournalJournalSheet {
|
||||
|
||||
public class ArticleInJournalJournalSheet
|
||||
extends Table
|
||||
implements TableActionListener {
|
||||
|
||||
private final String TABLE_COL_EDIT = "table_col_edit";
|
||||
|
||||
private final String TABLE_COL_DEL = "table_col_del";
|
||||
|
||||
private ItemSelectionModel itemSelectionModel;
|
||||
|
||||
public ArticleInJournalJournalSheet(
|
||||
final ItemSelectionModel itemSelectionModel,
|
||||
final StringParameter selectedLangParam
|
||||
) {
|
||||
super();
|
||||
this.itemSelectionModel = itemSelectionModel;
|
||||
|
||||
setEmptyView(
|
||||
new Label(
|
||||
new GlobalizedMessage(
|
||||
"publications.ui.articleInJournal.journal.none",
|
||||
SciPublicationsConstants.BUNDLE
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
final TableColumnModel columnModel = getColumnModel();
|
||||
columnModel.add(
|
||||
new TableColumn(
|
||||
0,
|
||||
new Label(
|
||||
new GlobalizedMessage(
|
||||
"publications.ui.articleInJournal.journal",
|
||||
SciPublicationsConstants.BUNDLE
|
||||
)
|
||||
),
|
||||
TABLE_COL_EDIT
|
||||
)
|
||||
);
|
||||
columnModel.add(
|
||||
new TableColumn(
|
||||
1,
|
||||
new Label(
|
||||
new GlobalizedMessage(
|
||||
"publications.ui.articleInJournal.journal.remove",
|
||||
SciPublicationsConstants.BUNDLE
|
||||
)
|
||||
),
|
||||
TABLE_COL_DEL
|
||||
)
|
||||
);
|
||||
|
||||
setModelBuilder(
|
||||
new ArticleInJournalJournalSheetModelBuilder(
|
||||
itemSelectionModel, selectedLangParam
|
||||
)
|
||||
);
|
||||
columnModel.get(0).setCellRenderer(new EditCellRenderer());
|
||||
columnModel.get(1).setCellRenderer(new DeleteCellRenderer());
|
||||
|
||||
addTableActionListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cellSelected(final TableActionEvent event) {
|
||||
final PageState state = event.getPageState();
|
||||
|
||||
final ArticleInJournalItem article
|
||||
= (ArticleInJournalItem) itemSelectionModel
|
||||
.getSelectedObject(state);
|
||||
|
||||
final TableColumn column = getColumnModel().get(event.getColumn());
|
||||
|
||||
if (column.getHeaderKey().toString().equals(TABLE_COL_EDIT)) {
|
||||
// Nothing
|
||||
} else if (column.getHeaderKey().toString().equals(TABLE_COL_DEL)) {
|
||||
final ArticleInJournalController controller = CdiUtil
|
||||
.createCdiUtil()
|
||||
.findBean(ArticleInJournalController.class);
|
||||
controller.unsetJournal(article.getPublication().getPublicationId());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void headSelected(TableActionEvent event) {
|
||||
//Nothing to do
|
||||
}
|
||||
|
||||
private class ArticleInJournalJournalSheetModelBuilder
|
||||
extends LockableImpl
|
||||
implements TableModelBuilder {
|
||||
|
||||
private final ItemSelectionModel itemModel;
|
||||
private final StringParameter selectedLangParam;
|
||||
|
||||
public ArticleInJournalJournalSheetModelBuilder(
|
||||
final ItemSelectionModel itemModel,
|
||||
final StringParameter selectedLangParam
|
||||
) {
|
||||
this.itemModel = itemModel;
|
||||
this.selectedLangParam = selectedLangParam;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TableModel makeModel(final Table table, final PageState state) {
|
||||
table.getRowSelectionModel().clearSelection(state);
|
||||
final ArticleInJournalItem article
|
||||
= (ArticleInJournalItem) itemModel.
|
||||
getSelectedObject(state);
|
||||
return new ArticleInJournalJournalSheetModel(
|
||||
table, state, article, selectedLangParam);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private class ArticleInJournalJournalSheetModel implements TableModel {
|
||||
|
||||
private final Table table;
|
||||
|
||||
private final String journalTitle;
|
||||
|
||||
private final Long journalId;
|
||||
|
||||
private boolean done;
|
||||
|
||||
public ArticleInJournalJournalSheetModel(
|
||||
final Table table,
|
||||
final PageState state,
|
||||
final ArticleInJournalItem articleItem,
|
||||
final StringParameter selectedLangParam
|
||||
) {
|
||||
this.table = table;
|
||||
final Journal journal = articleItem
|
||||
.getPublication()
|
||||
.getJournal();
|
||||
if (journal == null) {
|
||||
done = false;
|
||||
journalTitle = null;
|
||||
journalId = null;
|
||||
} else {
|
||||
done = true;
|
||||
journalTitle = journal.getTitle();
|
||||
journalId = journal.getJournalId();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getColumnCount() {
|
||||
return table.getColumnModel().size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean nextRow() {
|
||||
boolean ret;
|
||||
|
||||
if (done) {
|
||||
ret = true;
|
||||
done = false;
|
||||
} else {
|
||||
ret = false;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getElementAt(final int columnIndex) {
|
||||
switch (columnIndex) {
|
||||
case 0:
|
||||
return journalTitle;
|
||||
case 1:
|
||||
return new Label(
|
||||
new GlobalizedMessage(
|
||||
"publications.ui.articleInCollectedVolume.collectedVolume.remove",
|
||||
SciPublicationsConstants.BUNDLE
|
||||
)
|
||||
);
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getKeyAt(final int columnIndex) {
|
||||
return journalId;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private class EditCellRenderer
|
||||
extends LockableImpl
|
||||
implements TableCellRenderer {
|
||||
|
||||
public Component getComponent(
|
||||
final Table table,
|
||||
final PageState state,
|
||||
final Object value,
|
||||
final boolean isSelected,
|
||||
final Object key,
|
||||
final int row,
|
||||
final int column
|
||||
) {
|
||||
return new Text((String) value);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private class DeleteCellRenderer
|
||||
extends LockableImpl
|
||||
implements TableCellRenderer {
|
||||
|
||||
public Component getComponent(
|
||||
final Table table,
|
||||
final PageState state,
|
||||
final Object value,
|
||||
final boolean isSelected,
|
||||
final Object key,
|
||||
final int row,
|
||||
final int column
|
||||
) {
|
||||
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
|
||||
final PermissionChecker permissionChecker = cdiUtil
|
||||
.findBean(PermissionChecker.class);
|
||||
final ArticleInJournalItem articleItem
|
||||
= (ArticleInJournalItem) itemSelectionModel
|
||||
.getSelectedItem(state);
|
||||
final boolean canEdit = permissionChecker.isPermitted(
|
||||
ItemPrivileges.EDIT, articleItem
|
||||
);
|
||||
|
||||
if (canEdit) {
|
||||
final ControlLink link = new ControlLink((Component) value);
|
||||
link.setConfirmation(
|
||||
new GlobalizedMessage(
|
||||
"publication.ui.articleInJournal.journal.confirm_remove",
|
||||
SciPublicationsConstants.BUNDLE
|
||||
)
|
||||
);
|
||||
return link;
|
||||
} else {
|
||||
return new Text("");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,15 +1,68 @@
|
|||
package com.arsdigita.cms.contenttypes.ui;
|
||||
|
||||
import com.arsdigita.bebop.parameters.StringParameter;
|
||||
import com.arsdigita.cms.ItemSelectionModel;
|
||||
import com.arsdigita.cms.ui.authoring.AuthoringKitWizard;
|
||||
import com.arsdigita.cms.ui.authoring.BasicItemForm;
|
||||
import com.arsdigita.cms.ui.authoring.SimpleEditStep;
|
||||
import com.arsdigita.cms.ui.workflow.WorkflowLockedComponentAccess;
|
||||
import com.arsdigita.globalization.GlobalizedMessage;
|
||||
|
||||
import org.scientificcms.publications.SciPublicationsConstants;
|
||||
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||
*/
|
||||
public class ArticleInJournalJournalStep {
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -113,7 +113,8 @@ public class ArticleInJournalPropertiesStep extends PublicationPropertiesStep {
|
|||
);
|
||||
|
||||
final BasicPageForm editBasicSheet = new ArticleInJournalPropertyForm(
|
||||
itemModel, this);
|
||||
itemModel, this, selectedLanguageParam
|
||||
);
|
||||
|
||||
basicProperties.add(
|
||||
EDIT_SHEET_NAME,
|
||||
|
|
@ -152,7 +153,9 @@ public class ArticleInJournalPropertiesStep extends PublicationPropertiesStep {
|
|||
super.addSteps(itemModel, parent);
|
||||
|
||||
addStep(
|
||||
new ArticleInJournalJournalStep(itemModel, parent),
|
||||
new ArticleInJournalJournalStep(
|
||||
itemModel, parent, selectedLanguageParam
|
||||
),
|
||||
new GlobalizedMessage(
|
||||
"publication.ui.articleInJournal.journal",
|
||||
SciPublicationsConstants.BUNDLE
|
||||
|
|
|
|||
|
|
@ -0,0 +1,15 @@
|
|||
/*
|
||||
* 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 <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||
*/
|
||||
public class CollectedVolumePropertiesStep
|
||||
extends PublicationWithPublisherPropertiesStep {
|
||||
|
||||
}
|
||||
|
|
@ -166,7 +166,6 @@ public class PublicationPropertiesStep extends SimpleEditStep {
|
|||
protected void addBasicProperties(
|
||||
final ItemSelectionModel itemModel, final AuthoringKitWizard parent
|
||||
) {
|
||||
|
||||
final SimpleEditStep basicProperties = new SimpleEditStep(
|
||||
itemModel,
|
||||
parent,
|
||||
|
|
|
|||
|
|
@ -0,0 +1,154 @@
|
|||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package com.arsdigita.cms.contenttypes.ui;
|
||||
|
||||
import com.arsdigita.bebop.Component;
|
||||
import com.arsdigita.bebop.Label;
|
||||
import com.arsdigita.bebop.parameters.StringParameter;
|
||||
import com.arsdigita.cms.ItemSelectionModel;
|
||||
import com.arsdigita.cms.ui.authoring.AuthoringKitWizard;
|
||||
import com.arsdigita.cms.ui.authoring.BasicPageForm;
|
||||
import com.arsdigita.cms.ui.authoring.SimpleEditStep;
|
||||
import com.arsdigita.cms.ui.workflow.WorkflowLockedComponentAccess;
|
||||
import com.arsdigita.globalization.GlobalizedMessage;
|
||||
import com.arsdigita.toolbox.ui.DomainObjectPropertySheet;
|
||||
|
||||
import org.scientificcms.publications.SciPublicationsConstants;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||
*/
|
||||
public class PublicationWithPublisherPropertiesStep
|
||||
extends PublicationPropertiesStep {
|
||||
|
||||
private final StringParameter selectedLangParam;
|
||||
|
||||
public PublicationWithPublisherPropertiesStep(
|
||||
final ItemSelectionModel itemModel,
|
||||
final AuthoringKitWizard parent,
|
||||
final StringParameter selectedLangParam
|
||||
) {
|
||||
super(itemModel, parent, selectedLangParam);
|
||||
this.selectedLangParam = selectedLangParam;
|
||||
}
|
||||
|
||||
public static Component getPublicationWithPublisherPropertySheet(
|
||||
final ItemSelectionModel itemModel,
|
||||
final StringParameter selectedLangParam
|
||||
) {
|
||||
final DomainObjectPropertySheet sheet
|
||||
= (DomainObjectPropertySheet) PublicationPropertiesStep
|
||||
.getPublicationPropertySheet(itemModel, selectedLangParam);
|
||||
|
||||
sheet.add(
|
||||
new GlobalizedMessage(
|
||||
"publications.ui.with_publisher.isbn10",
|
||||
SciPublicationsConstants.BUNDLE
|
||||
),
|
||||
SciPublicationsWithPublisherController.ISBN10
|
||||
);
|
||||
|
||||
sheet.add(
|
||||
new GlobalizedMessage(
|
||||
"publications.ui.with_publisher.isbn13",
|
||||
SciPublicationsConstants.BUNDLE
|
||||
),
|
||||
SciPublicationsWithPublisherController.ISBN13
|
||||
);
|
||||
|
||||
sheet.add(
|
||||
new GlobalizedMessage(
|
||||
"publications.ui.with_publisher.volume",
|
||||
SciPublicationsConstants.BUNDLE
|
||||
),
|
||||
SciPublicationsWithPublisherController.VOLUME
|
||||
);
|
||||
|
||||
sheet.add(
|
||||
new GlobalizedMessage(
|
||||
"publications.ui.with_publisher.number_of_volumes",
|
||||
SciPublicationsConstants.BUNDLE
|
||||
),
|
||||
SciPublicationsWithPublisherController.NUMBER_OF_VOLUMES
|
||||
);
|
||||
|
||||
sheet.add(new GlobalizedMessage(
|
||||
"publications.ui.with_publisher.number_of_pages",
|
||||
SciPublicationsConstants.BUNDLE
|
||||
),
|
||||
SciPublicationsWithPublisherController.NUMBER_OF_PAGES
|
||||
);
|
||||
|
||||
sheet.add(new GlobalizedMessage(
|
||||
"publications.ui.with_publisher.edition",
|
||||
SciPublicationsConstants.BUNDLE
|
||||
),
|
||||
SciPublicationsWithPublisherController.EDITION
|
||||
);
|
||||
|
||||
return sheet;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addBasicProperties(
|
||||
final ItemSelectionModel itemModel, final AuthoringKitWizard parent
|
||||
) {
|
||||
final SimpleEditStep basicProperties = new SimpleEditStep(
|
||||
itemModel,
|
||||
parent,
|
||||
selectedLangParam,
|
||||
EDIT_SHEET_NAME
|
||||
);
|
||||
|
||||
final BasicPageForm editBasicSheet
|
||||
= new PublicationWithPublisherPropertyForm(
|
||||
itemModel, this, selectedLangParam);
|
||||
|
||||
basicProperties.add(
|
||||
EDIT_SHEET_NAME,
|
||||
new GlobalizedMessage(
|
||||
"publications.ui.publication.edit_basic_sheet",
|
||||
SciPublicationsConstants.BUNDLE
|
||||
),
|
||||
new WorkflowLockedComponentAccess(editBasicSheet, itemModel),
|
||||
editBasicSheet.getSaveCancelSection().getCancelButton()
|
||||
);
|
||||
|
||||
basicProperties.setDisplayComponent(
|
||||
getPublicationWithPublisherPropertySheet(
|
||||
itemModel, selectedLangParam
|
||||
)
|
||||
);
|
||||
|
||||
getSegmentedPanel().addSegment(
|
||||
new Label(
|
||||
new GlobalizedMessage(
|
||||
"publications.ui.publication.basic_properties"
|
||||
)
|
||||
),
|
||||
basicProperties
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addSteps(
|
||||
final ItemSelectionModel itemModel, final AuthoringKitWizard parent
|
||||
) {
|
||||
super.addSteps(itemModel, parent);
|
||||
|
||||
addStep(
|
||||
new PublicationWithPublisherSetPublisherStep(
|
||||
itemModel, parent, selectedLangParam
|
||||
),
|
||||
new GlobalizedMessage(
|
||||
"publications.ui.with_publisher.publisher",
|
||||
SciPublicationsConstants.BUNDLE
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,334 @@
|
|||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package com.arsdigita.cms.contenttypes.ui;
|
||||
|
||||
import com.arsdigita.bebop.FormData;
|
||||
import com.arsdigita.bebop.FormProcessException;
|
||||
import com.arsdigita.bebop.PageState;
|
||||
import com.arsdigita.bebop.event.FormInitListener;
|
||||
import com.arsdigita.bebop.event.FormProcessListener;
|
||||
import com.arsdigita.bebop.event.FormSectionEvent;
|
||||
import com.arsdigita.bebop.event.FormSubmissionListener;
|
||||
import com.arsdigita.bebop.event.ParameterEvent;
|
||||
import com.arsdigita.bebop.event.ParameterListener;
|
||||
import com.arsdigita.bebop.form.TextField;
|
||||
import com.arsdigita.bebop.parameters.IntegerParameter;
|
||||
import com.arsdigita.bebop.parameters.ParameterData;
|
||||
import com.arsdigita.bebop.parameters.ParameterModel;
|
||||
import com.arsdigita.bebop.parameters.StringParameter;
|
||||
import com.arsdigita.cms.ItemSelectionModel;
|
||||
import com.arsdigita.cms.ui.authoring.SelectedLanguageUtil;
|
||||
import com.arsdigita.globalization.GlobalizedMessage;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.libreccm.cdi.utils.CdiUtil;
|
||||
import org.scientificcms.publications.PublicationWithPublisher;
|
||||
import org.scientificcms.publications.SciPublicationsConstants;
|
||||
import org.scientificcms.publications.contenttypes.PublicationWithPublisherItem;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||
*/
|
||||
public class PublicationWithPublisherPropertyForm
|
||||
extends PublicationPropertyForm
|
||||
implements FormProcessListener,
|
||||
FormInitListener,
|
||||
FormSubmissionListener {
|
||||
|
||||
private static final Logger LOGGER = LogManager.getLogger(
|
||||
PublicationWithPublisherPropertyForm.class
|
||||
);
|
||||
|
||||
public static final String ID = "PublicationWithPublisherEdit";
|
||||
|
||||
private static final String PUBLISHER_SEARCH = "publisher";
|
||||
|
||||
private final PublicationWithPublisherPropertiesStep step;
|
||||
|
||||
private final ItemSelectionModel itemModel;
|
||||
|
||||
private final StringParameter selectedLangParam;
|
||||
|
||||
private PublisherSearchWidget publisherSearch;
|
||||
|
||||
public PublicationWithPublisherPropertyForm(
|
||||
final ItemSelectionModel itemModel,
|
||||
final StringParameter selectedLangParam
|
||||
) {
|
||||
this(itemModel, null, selectedLangParam);
|
||||
}
|
||||
|
||||
public PublicationWithPublisherPropertyForm(
|
||||
ItemSelectionModel itemModel,
|
||||
PublicationWithPublisherPropertiesStep step,
|
||||
final StringParameter selectedLangParam
|
||||
) {
|
||||
super(itemModel, step, selectedLangParam);
|
||||
this.step = step;
|
||||
this.itemModel = itemModel;
|
||||
this.selectedLangParam = selectedLangParam;
|
||||
addSubmissionListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addWidgets() {
|
||||
|
||||
super.addWidgets();
|
||||
|
||||
final ParameterModel isbn10Param = new StringParameter(
|
||||
SciPublicationsWithPublisherController.ISBN10
|
||||
);
|
||||
final TextField isbn10 = new TextField(isbn10Param);
|
||||
isbn10.setMaxLength(17);
|
||||
isbn10.addValidationListener(new ParameterListener() {
|
||||
|
||||
public void validate(final ParameterEvent event)
|
||||
throws FormProcessException {
|
||||
ParameterData data = event.getParameterData();
|
||||
String value = (String) data.getValue();
|
||||
|
||||
if (value.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
value = value.replace("-", "");
|
||||
|
||||
if (value.length() != 10) {
|
||||
data.invalidate();
|
||||
data.addError(
|
||||
new GlobalizedMessage(
|
||||
"publications.ui.invalid_isbn10",
|
||||
SciPublicationsConstants.BUNDLE
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
try {
|
||||
Long num = Long.parseLong(value);
|
||||
} catch (NumberFormatException ex) {
|
||||
data.invalidate();
|
||||
data.addError(
|
||||
new GlobalizedMessage(
|
||||
"publications.ui.invalid_isbn10",
|
||||
SciPublicationsConstants.BUNDLE
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
isbn10.setLabel(new GlobalizedMessage(
|
||||
"publications.ui.with_publisher.isbn10"));
|
||||
add(isbn10);
|
||||
|
||||
final ParameterModel isbn13Param = new StringParameter(
|
||||
SciPublicationsWithPublisherController.ISBN13
|
||||
);
|
||||
final TextField isbn13 = new TextField(isbn13Param);
|
||||
isbn13.setMaxLength(17);
|
||||
isbn13.addValidationListener(new ParameterListener() {
|
||||
|
||||
public void validate(final ParameterEvent event)
|
||||
throws FormProcessException {
|
||||
ParameterData data = event.getParameterData();
|
||||
String value = (String) data.getValue();
|
||||
|
||||
if (value.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
value = value.replace("-", "");
|
||||
|
||||
if (value.length() != 13) {
|
||||
data.invalidate();
|
||||
data.addError(
|
||||
new GlobalizedMessage(
|
||||
"publications.ui.invalid_isbn13",
|
||||
SciPublicationsConstants.BUNDLE
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
try {
|
||||
Long num = Long.parseLong(value);
|
||||
} catch (NumberFormatException ex) {
|
||||
data.invalidate();
|
||||
data.addError(new GlobalizedMessage(
|
||||
"publications.ui.invalid_isbn13",
|
||||
SciPublicationsConstants.BUNDLE
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
isbn13.setLabel(new GlobalizedMessage(
|
||||
"publications.ui.with_publisher.isbn13"));
|
||||
add(isbn13);
|
||||
|
||||
final ParameterModel volumeParam = new IntegerParameter(
|
||||
SciPublicationsWithPublisherController.VOLUME
|
||||
);
|
||||
final TextField volume = new TextField(volumeParam);
|
||||
volume.setLabel(
|
||||
new GlobalizedMessage(
|
||||
"publications.ui.collected_volume.volume",
|
||||
SciPublicationsConstants.BUNDLE
|
||||
)
|
||||
);
|
||||
add(volume);
|
||||
|
||||
final ParameterModel numberOfVolumesParam = new IntegerParameter(
|
||||
SciPublicationsWithPublisherController.NUMBER_OF_VOLUMES
|
||||
);
|
||||
TextField numberOfVolumes = new TextField(numberOfVolumesParam);
|
||||
numberOfVolumes.setLabel(
|
||||
new GlobalizedMessage(
|
||||
"publications.ui.collected_volume.number_of_volumes",
|
||||
SciPublicationsConstants.BUNDLE
|
||||
)
|
||||
);
|
||||
add(numberOfVolumes);
|
||||
|
||||
final ParameterModel numberOfPagesParam = new IntegerParameter(
|
||||
SciPublicationsWithPublisherController.NUMBER_OF_PAGES
|
||||
);
|
||||
final TextField numberOfPages = new TextField(numberOfPagesParam);
|
||||
numberOfPages.setLabel(
|
||||
new GlobalizedMessage(
|
||||
"publications.ui.collected_volume.number_of_pages",
|
||||
SciPublicationsConstants.BUNDLE
|
||||
)
|
||||
);
|
||||
add(numberOfPages);
|
||||
|
||||
ParameterModel editionModel = new StringParameter(
|
||||
SciPublicationsWithPublisherController.EDITION
|
||||
);
|
||||
|
||||
final TextField edition = new TextField(editionModel);
|
||||
edition.setLabel(
|
||||
new GlobalizedMessage(
|
||||
"publications.ui.collected_volume.edition",
|
||||
SciPublicationsConstants.BUNDLE
|
||||
)
|
||||
);
|
||||
add(edition);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(final FormSectionEvent event) throws FormProcessException {
|
||||
|
||||
final FormData data = event.getFormData();
|
||||
super.init(event);
|
||||
|
||||
final PublicationWithPublisherItem<?> publicationItem
|
||||
= (PublicationWithPublisherItem) super
|
||||
.initBasicWidgets(event);
|
||||
|
||||
final PublicationWithPublisher publication = publicationItem
|
||||
.getPublication();
|
||||
|
||||
data.put(
|
||||
SciPublicationsWithPublisherController.ISBN10,
|
||||
publication.getIsbn10()
|
||||
);
|
||||
data.put(
|
||||
SciPublicationsWithPublisherController.ISBN13,
|
||||
publication.getIsbn10()
|
||||
);
|
||||
data.put(
|
||||
SciPublicationsWithPublisherController.VOLUME,
|
||||
publication.getVolume()
|
||||
);
|
||||
data.put(
|
||||
SciPublicationsWithPublisherController.NUMBER_OF_VOLUMES,
|
||||
publication.getNumberOfVolumes()
|
||||
);
|
||||
data.put(
|
||||
SciPublicationsWithPublisherController.NUMBER_OF_PAGES,
|
||||
publication.getNumberOfPages()
|
||||
);
|
||||
data.put(
|
||||
SciPublicationsWithPublisherController.EDITION,
|
||||
publication.getEdition()
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void process(final FormSectionEvent event)
|
||||
throws FormProcessException {
|
||||
|
||||
final FormData formData = event.getFormData();
|
||||
final PageState state = event.getPageState();
|
||||
super.process(event);
|
||||
|
||||
final PublicationWithPublisherItem<?> item
|
||||
= (PublicationWithPublisherItem) super
|
||||
.processBasicWidgets(event);
|
||||
|
||||
if ((item != null)
|
||||
&& getSaveCancelSection().getSaveButton().isSelected(state)) {
|
||||
final PublicationWithPublisher publication = item
|
||||
.getPublication();
|
||||
|
||||
final Map<String, Object> data = new HashMap<>();
|
||||
|
||||
data.put(
|
||||
SciPublicationsWithPublisherController.ISBN10,
|
||||
formData.get(SciPublicationsWithPublisherController.ISBN10)
|
||||
);
|
||||
|
||||
data.put(
|
||||
SciPublicationsWithPublisherController.ISBN13,
|
||||
formData.get(SciPublicationsWithPublisherController.ISBN13)
|
||||
);
|
||||
|
||||
data.put(
|
||||
SciPublicationsWithPublisherController.VOLUME,
|
||||
formData.get(SciPublicationsWithPublisherController.VOLUME)
|
||||
);
|
||||
|
||||
data.put(
|
||||
SciPublicationsWithPublisherController.NUMBER_OF_PAGES,
|
||||
formData.get(
|
||||
SciPublicationsWithPublisherController.NUMBER_OF_PAGES
|
||||
)
|
||||
);
|
||||
|
||||
data.put(
|
||||
SciPublicationsWithPublisherController.NUMBER_OF_VOLUMES,
|
||||
formData.get(
|
||||
SciPublicationsWithPublisherController.NUMBER_OF_VOLUMES
|
||||
)
|
||||
);
|
||||
|
||||
data.put(
|
||||
SciPublicationsWithPublisherController.EDITION,
|
||||
formData.get(SciPublicationsWithPublisherController.EDITION)
|
||||
);
|
||||
|
||||
final Locale selectedLocale = SelectedLanguageUtil.selectedLocale(
|
||||
state, selectedLangParam
|
||||
);
|
||||
|
||||
final SciPublicationsWithPublisherController controller = CdiUtil
|
||||
.createCdiUtil()
|
||||
.findBean(SciPublicationsWithPublisherController.class);
|
||||
controller.savePublication(
|
||||
publication.getPublicationId(), selectedLocale, data
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,87 @@
|
|||
/*
|
||||
* 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.scientificcms.publications.SciPublicationsConstants;
|
||||
|
||||
import java.util.concurrent.Flow.Publisher;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||
*/
|
||||
public class PublicationWithPublisherSetPublisherForm
|
||||
extends BasicItemForm
|
||||
implements FormInitListener, FormProcessListener {
|
||||
|
||||
private PublisherSearchWidget publisherSearch;
|
||||
private final String PUBLISHER_SEARCH = "setPublisher";
|
||||
|
||||
public PublicationWithPublisherSetPublisherForm(
|
||||
final ItemSelectionModel itemModel,
|
||||
final StringParameter selectedLangParam
|
||||
) {
|
||||
super(
|
||||
"PublicationWithPublisherSetPublisher",
|
||||
itemModel,
|
||||
selectedLangParam
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addWidgets() {
|
||||
|
||||
publisherSearch = new PublisherSearchWidget(PUBLISHER_SEARCH);
|
||||
publisherSearch.setLabel(
|
||||
new GlobalizedMessage(
|
||||
"publications.ui.with_publisher.publisher",
|
||||
SciPublicationsConstants.BUNDLE
|
||||
)
|
||||
);
|
||||
add(publisherSearch);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(final FormSectionEvent fse) throws FormProcessException {
|
||||
final PageState state = fse.getPageState();
|
||||
|
||||
setVisible(state, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void process(final FormSectionEvent fse)
|
||||
throws FormProcessException {
|
||||
final FormData data = fse.getFormData();
|
||||
final PageState state = fse.getPageState();
|
||||
final PublicationWithPublisherItem publication =
|
||||
(PublicationWithPublisherItem) getItemSelectionModel().
|
||||
getSelectedObject(state);
|
||||
|
||||
if (this.getSaveCancelSection().getSaveButton().isSelected(state)) {
|
||||
final Publisher publisher = (Publisher) data.get(PUBLISHER_SEARCH);
|
||||
|
||||
publication.setPublisher(publisher);
|
||||
itemSearch.publishCreatedItem(data, publisher);
|
||||
}
|
||||
|
||||
init(fse);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,58 @@
|
|||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package com.arsdigita.cms.contenttypes.ui;
|
||||
|
||||
import com.arsdigita.bebop.parameters.StringParameter;
|
||||
import com.arsdigita.cms.ItemSelectionModel;
|
||||
import com.arsdigita.cms.ui.authoring.AuthoringKitWizard;
|
||||
import com.arsdigita.cms.ui.authoring.BasicItemForm;
|
||||
import com.arsdigita.cms.ui.authoring.SimpleEditStep;
|
||||
import com.arsdigita.cms.ui.workflow.WorkflowLockedComponentAccess;
|
||||
import com.arsdigita.globalization.GlobalizedMessage;
|
||||
import org.scientificcms.publications.SciPublicationsConstants;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||
*/
|
||||
public class PublicationWithPublisherSetPublisherStep extends SimpleEditStep {
|
||||
|
||||
private String SET_PUBLICATION_PUBLISHER_STEP
|
||||
= "setPublicationPublisherStep";
|
||||
|
||||
public PublicationWithPublisherSetPublisherStep(
|
||||
final ItemSelectionModel itemModel,
|
||||
final AuthoringKitWizard parent,
|
||||
final StringParameter selectedLangParam
|
||||
) {
|
||||
this(itemModel, parent, selectedLangParam, null);
|
||||
}
|
||||
|
||||
public PublicationWithPublisherSetPublisherStep(
|
||||
final ItemSelectionModel itemModel,
|
||||
final AuthoringKitWizard parent,
|
||||
final StringParameter selectedLangParameter,
|
||||
final String prefix) {
|
||||
super(itemModel, parent, selectedLangParameter, prefix);
|
||||
|
||||
final BasicItemForm setPublisherForm
|
||||
= new PublicationWithPublisherSetPublisherForm(
|
||||
itemModel);
|
||||
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);
|
||||
setDisplayComponent(sheet);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,141 @@
|
|||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package com.arsdigita.cms.contenttypes.ui;
|
||||
|
||||
import org.scientificcms.publications.PublicationWithPublisher;
|
||||
import org.scientificcms.publications.PublicationWithPublisherRepository;
|
||||
import org.scientificcms.publications.Publisher;
|
||||
import org.scientificcms.publications.PublisherManager;
|
||||
import org.scientificcms.publications.PublisherRepository;
|
||||
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.enterprise.context.RequestScoped;
|
||||
import javax.inject.Inject;
|
||||
import javax.transaction.Transactional;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||
*/
|
||||
@RequestScoped
|
||||
public class SciPublicationsWithPublisherController {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public static final String ISBN10 = "isbn10";
|
||||
|
||||
public static final String ISBN13 = "isbn13";
|
||||
|
||||
public static final String VOLUME = "volume";
|
||||
|
||||
public static final String NUMBER_OF_VOLUMES = "numberOfVolumes";
|
||||
|
||||
public static final String NUMBER_OF_PAGES = "numberOfPages";
|
||||
|
||||
public static final String EDITION = "edition";
|
||||
|
||||
@Inject
|
||||
private SciPublicationsController publicationsController;
|
||||
|
||||
@Inject
|
||||
private PublicationWithPublisherRepository publicationRepository;
|
||||
|
||||
@Inject
|
||||
private PublisherManager publisherManager;
|
||||
|
||||
@Inject
|
||||
private PublisherRepository publisherRepository;
|
||||
|
||||
@Transactional(Transactional.TxType.REQUIRED)
|
||||
public void savePublication(final long publicationId,
|
||||
final Locale selectedLocale,
|
||||
final Map<String, Object> data) {
|
||||
publicationsController.savePublication(publicationId, selectedLocale,
|
||||
data);
|
||||
|
||||
final PublicationWithPublisher publication = publicationRepository
|
||||
.findById(publicationId)
|
||||
.orElseThrow(
|
||||
() -> new IllegalArgumentException(
|
||||
String.format(
|
||||
"No PublicationWithPublisher with ID %d found.",
|
||||
publicationId
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
final String isbn10 = (String) data.get(ISBN10);
|
||||
final String isbn13 = (String) data.get(ISBN13);
|
||||
final Integer volume = (Integer) data.get(VOLUME);
|
||||
final Integer numberOfVolumes = (Integer) data.get(NUMBER_OF_VOLUMES);
|
||||
final Integer numberOfPages = (Integer) data.get(NUMBER_OF_PAGES);
|
||||
final String edition = (String) data.get(EDITION);
|
||||
|
||||
publication.setIsbn10(isbn10);
|
||||
publication.setIsbn13(isbn13);
|
||||
publication.setVolume(volume);
|
||||
publication.setNumberOfVolumes(numberOfVolumes);
|
||||
publication.setNumberOfPages(numberOfPages);
|
||||
publication.getEdition().addValue(selectedLocale, edition);
|
||||
|
||||
publicationRepository.save(publication);
|
||||
}
|
||||
|
||||
public void setPublisher(final long publicationId, final long publisherId) {
|
||||
|
||||
final PublicationWithPublisher publication = publicationRepository
|
||||
.findById(publicationId)
|
||||
.orElseThrow(
|
||||
() -> new IllegalArgumentException(
|
||||
String.format(
|
||||
"No PublicationWithPublisher with ID %d found.",
|
||||
publicationId
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
final Publisher publisher = publisherRepository
|
||||
.findById(publisherId)
|
||||
.orElseThrow(
|
||||
() -> new IllegalArgumentException(
|
||||
String.format(
|
||||
"No Publisher with ID %d found.", publisherId)
|
||||
)
|
||||
);
|
||||
|
||||
publisherManager.addPublicationToPublisher(publication, publisher);
|
||||
|
||||
}
|
||||
|
||||
public void unsetPublisher(
|
||||
final long publicationId, final long publisherId
|
||||
) {
|
||||
final PublicationWithPublisher publication = publicationRepository
|
||||
.findById(publicationId)
|
||||
.orElseThrow(
|
||||
() -> new IllegalArgumentException(
|
||||
String.format(
|
||||
"No PublicationWithPublisher with ID %d found.",
|
||||
publicationId
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
final Publisher publisher = publisherRepository
|
||||
.findById(publisherId)
|
||||
.orElseThrow(
|
||||
() -> new IllegalArgumentException(
|
||||
String.format(
|
||||
"No Publisher with ID %d found.", publisherId)
|
||||
)
|
||||
);
|
||||
|
||||
publisherManager.removePublicationFromPublisher(publication, publisher);
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue