First part of migrated forms for ArticleInJournal
parent
b70c4783c8
commit
32b170318b
|
|
@ -41,23 +41,23 @@ public class ArticleInCollectedVolumeController {
|
|||
/**
|
||||
* Save a changed {@link ArticleInCollectedVolume}.
|
||||
*
|
||||
* @param publicationId The ID of the article.
|
||||
* @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 publicationId,
|
||||
final long articleId,
|
||||
final Locale selectedLocale,
|
||||
final Map<String, Object> data
|
||||
) {
|
||||
final ArticleInCollectedVolume article = publicationRepository
|
||||
.findByIdAndType(publicationId, ArticleInCollectedVolume.class)
|
||||
.findByIdAndType(articleId, ArticleInCollectedVolume.class)
|
||||
.orElseThrow(
|
||||
() -> new IllegalArgumentException(
|
||||
String.format(
|
||||
"No ArticleInCollectedVolume with ID %d found.",
|
||||
publicationId
|
||||
articleId
|
||||
)
|
||||
)
|
||||
);
|
||||
|
|
@ -83,7 +83,7 @@ public class ArticleInCollectedVolumeController {
|
|||
}
|
||||
|
||||
/**
|
||||
* Set the value of {@link ArticleInCollectedVolume#collectedVolume}
|
||||
* Set the value of the {@link ArticleInCollectedVolume#collectedVolume}
|
||||
* property to a {@link CollectedVolume}.
|
||||
*
|
||||
* @param articleId The ID of the article to use.
|
||||
|
|
|
|||
|
|
@ -180,15 +180,15 @@ public class ArticleInCollectedVolumePropertyForm
|
|||
|
||||
data.put(
|
||||
ArticleInCollectedVolumeController.START_PAGE,
|
||||
data.get(ArticleInCollectedVolumeController.START_PAGE)
|
||||
formData.get(ArticleInCollectedVolumeController.START_PAGE)
|
||||
);
|
||||
data.put(
|
||||
ArticleInCollectedVolumeController.END_PAGE,
|
||||
data.get(ArticleInCollectedVolumeController.END_PAGE)
|
||||
formData.get(ArticleInCollectedVolumeController.END_PAGE)
|
||||
);
|
||||
data.put(
|
||||
ArticleInCollectedVolumeController.CHAPTER,
|
||||
data.get(ArticleInCollectedVolumeController.CHAPTER)
|
||||
formData.get(ArticleInCollectedVolumeController.CHAPTER)
|
||||
);
|
||||
|
||||
if (reviewed.getValue(event.getPageState()) == null) {
|
||||
|
|
@ -203,20 +203,19 @@ public class ArticleInCollectedVolumePropertyForm
|
|||
);
|
||||
}
|
||||
|
||||
final Locale selectedLocale = SelectedLanguageUtil.selectedLocale(
|
||||
final Locale selectedLocale = SelectedLanguageUtil.selectedLocale(
|
||||
state, selectedLangParam
|
||||
);
|
||||
|
||||
final ArticleInCollectedVolumeController controller = CdiUtil
|
||||
.createCdiUtil()
|
||||
.findBean(ArticleInCollectedVolumeController.class);
|
||||
|
||||
final ArticleInCollectedVolumeController controller = CdiUtil
|
||||
.createCdiUtil()
|
||||
.findBean(ArticleInCollectedVolumeController.class);
|
||||
controller.saveArticle(
|
||||
articleItem.getPublication().getPublicationId(),
|
||||
selectedLocale,
|
||||
data
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,157 @@
|
|||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package com.arsdigita.cms.contenttypes.ui;
|
||||
|
||||
import org.scientificcms.publications.ArticleInJournal;
|
||||
import org.scientificcms.publications.ArticleInJournalManager;
|
||||
import org.scientificcms.publications.Journal;
|
||||
import org.scientificcms.publications.JournalRepository;
|
||||
import org.scientificcms.publications.PublicationRepository;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.enterprise.context.RequestScoped;
|
||||
import javax.inject.Inject;
|
||||
import javax.transaction.Transactional;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||
*/
|
||||
@RequestScoped
|
||||
public class ArticleInJournalController {
|
||||
|
||||
public static final String VOLUME = "volume";
|
||||
|
||||
public static final String ISSUE = "issue";
|
||||
|
||||
public static final String START_PAGE = "startPage";
|
||||
|
||||
public static final String END_PAGE = "endPage";
|
||||
|
||||
public static final String PUBLICATION_DATE = "publicationDate";
|
||||
|
||||
public static final String PEER_REVIEWED = "reviewed";
|
||||
|
||||
@Inject
|
||||
private ArticleInJournalManager articleManager;
|
||||
|
||||
@Inject
|
||||
private JournalRepository journalRepository;
|
||||
|
||||
@Inject
|
||||
private PublicationRepository publicationRepository;
|
||||
|
||||
/**
|
||||
* Save a changed {@link ArticleInJournal}.
|
||||
*
|
||||
* @param articleId The ID of the article.
|
||||
* @param selectedLocale The locale selected in the UI.
|
||||
* @param data The data to set on the article.
|
||||
*/
|
||||
@Transactional(Transactional.TxType.REQUIRED)
|
||||
public void saveArticle(
|
||||
final long articleId,
|
||||
final Locale selectedLocale,
|
||||
final Map<String, Object> data
|
||||
) {
|
||||
final ArticleInJournal article = publicationRepository
|
||||
.findByIdAndType(articleId, ArticleInJournal.class)
|
||||
.orElseThrow(
|
||||
() -> new IllegalArgumentException(
|
||||
String.format(
|
||||
"No ArticleInJournal with ID %d found.",
|
||||
articleId
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
if (data.get(VOLUME) != null) {
|
||||
final Integer volume = (Integer) data.get(VOLUME);
|
||||
article.setVolume(volume);
|
||||
}
|
||||
if (data.get(ISSUE) != null) {
|
||||
final String issue = (String) data.get(ISSUE);
|
||||
article.setIssue(issue);
|
||||
}
|
||||
if (data.get(START_PAGE) != null) {
|
||||
final Integer startPage = (Integer) data.get(START_PAGE);
|
||||
article.setStartPage(startPage);
|
||||
}
|
||||
if (data.get(END_PAGE) != null) {
|
||||
final Integer endPage = (Integer) data.get(END_PAGE);
|
||||
article.setStartPage(endPage);
|
||||
}
|
||||
if (data.get(PUBLICATION_DATE) != null) {
|
||||
final LocalDate publicationDate = (LocalDate) data.get(
|
||||
PUBLICATION_DATE
|
||||
);
|
||||
article.setPublicationDate(publicationDate);
|
||||
}
|
||||
if (data.get(PEER_REVIEWED) != null) {
|
||||
final Boolean peerReviewed = (Boolean) data.get(PEER_REVIEWED);
|
||||
article.setPeerReviewed(peerReviewed);
|
||||
}
|
||||
|
||||
publicationRepository.save(article);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the value of the {@link ArticleInJournal#journal} property to a
|
||||
* {@link Journal}.
|
||||
*
|
||||
* @param articleId The ID of the article to use.
|
||||
* @param journalId The ID of the journal to use.
|
||||
*/
|
||||
@Transactional(Transactional.TxType.REQUIRED)
|
||||
public void setJournal(
|
||||
final long articleId, final long journalId
|
||||
) {
|
||||
final ArticleInJournal article = publicationRepository
|
||||
.findByIdAndType(articleId, ArticleInJournal.class)
|
||||
.orElseThrow(
|
||||
() -> new IllegalArgumentException(
|
||||
String.format(
|
||||
"No ArticleInJournal with ID %d found.",
|
||||
articleId
|
||||
)
|
||||
)
|
||||
);
|
||||
final Journal journal = journalRepository
|
||||
.findById(journalId)
|
||||
.orElseThrow(
|
||||
() -> new IllegalArgumentException(
|
||||
String.format(
|
||||
"No Journal with ID %d found",
|
||||
journalId
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
articleManager.setJournal(article, journal);
|
||||
}
|
||||
|
||||
@Transactional(Transactional.TxType.REQUIRED)
|
||||
public void unsetJournal(
|
||||
final long articleId, final long journalId
|
||||
) {
|
||||
final ArticleInJournal article = publicationRepository
|
||||
.findByIdAndType(articleId, ArticleInJournal.class)
|
||||
.orElseThrow(
|
||||
() -> new IllegalArgumentException(
|
||||
String.format(
|
||||
"No ArticleInJournal with ID %d found.",
|
||||
articleId
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
articleManager.unsetJournal(article);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
/*
|
||||
* 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 ArticleInJournalJournalForm {
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
/*
|
||||
* 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 ArticleInJournalJournalSheet {
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
package com.arsdigita.cms.contenttypes.ui;
|
||||
|
||||
/*
|
||||
* 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 {
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,199 @@
|
|||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package com.arsdigita.cms.contenttypes.ui;
|
||||
|
||||
import com.arsdigita.bebop.Component;
|
||||
import com.arsdigita.bebop.Label;
|
||||
import com.arsdigita.bebop.PageState;
|
||||
import com.arsdigita.bebop.parameters.StringParameter;
|
||||
import com.arsdigita.cms.ItemSelectionModel;
|
||||
import com.arsdigita.cms.ui.authoring.AuthoringKitWizard;
|
||||
import com.arsdigita.cms.ui.authoring.BasicPageForm;
|
||||
import com.arsdigita.cms.ui.authoring.SimpleEditStep;
|
||||
import com.arsdigita.cms.ui.workflow.WorkflowLockedComponentAccess;
|
||||
import com.arsdigita.globalization.GlobalizedMessage;
|
||||
import com.arsdigita.toolbox.ui.DomainObjectPropertySheet;
|
||||
|
||||
import org.librecms.CmsConstants;
|
||||
import org.scientificcms.publications.ArticleInJournal;
|
||||
import org.scientificcms.publications.SciPublicationsConstants;
|
||||
|
||||
import java.text.DateFormat;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||
*/
|
||||
public class ArticleInJournalPropertiesStep extends PublicationPropertiesStep {
|
||||
|
||||
private final StringParameter selectedLanguageParam;
|
||||
|
||||
public ArticleInJournalPropertiesStep(
|
||||
final ItemSelectionModel itemModel,
|
||||
final AuthoringKitWizard parent,
|
||||
final StringParameter selectedLanguageParam
|
||||
) {
|
||||
super(itemModel, parent, selectedLanguageParam);
|
||||
|
||||
this.selectedLanguageParam = selectedLanguageParam;
|
||||
}
|
||||
|
||||
public static Component getArticleInJournalPropertySheet(
|
||||
final ItemSelectionModel itemModel,
|
||||
final StringParameter selectedLanguageParameter
|
||||
) {
|
||||
final DomainObjectPropertySheet sheet
|
||||
= (DomainObjectPropertySheet) PublicationPropertiesStep
|
||||
.getPublicationPropertySheet(
|
||||
itemModel,
|
||||
selectedLanguageParameter
|
||||
);
|
||||
|
||||
sheet.add(
|
||||
new GlobalizedMessage(
|
||||
"publications.ui.articleinjournal.volume",
|
||||
SciPublicationsConstants.BUNDLE
|
||||
),
|
||||
ArticleInJournalController.VOLUME
|
||||
);
|
||||
|
||||
sheet.add(new GlobalizedMessage(
|
||||
"publications.ui.articleinjournal.issue",
|
||||
SciPublicationsConstants.BUNDLE
|
||||
),
|
||||
ArticleInJournalController.ISSUE);
|
||||
|
||||
sheet.add(
|
||||
new GlobalizedMessage(
|
||||
"publications.ui.articleinjournal.pages_from",
|
||||
SciPublicationsConstants.BUNDLE
|
||||
),
|
||||
ArticleInJournalController.START_PAGE
|
||||
);
|
||||
|
||||
sheet.add(
|
||||
new GlobalizedMessage(
|
||||
"publications.ui.articleinjournal.pages_to",
|
||||
SciPublicationsConstants.BUNDLE
|
||||
),
|
||||
ArticleInJournalController.END_PAGE
|
||||
);
|
||||
|
||||
sheet.add(
|
||||
new GlobalizedMessage(
|
||||
"publications.ui.articleinjournal.publication_date",
|
||||
SciPublicationsConstants.BUNDLE
|
||||
),
|
||||
ArticleInJournalController.PUBLICATION_DATE,
|
||||
ArticleInJournalPropertiesStep::formatPublicationDate
|
||||
);
|
||||
|
||||
sheet.add(new GlobalizedMessage(
|
||||
"publications.ui.articleinjournal.reviewed"
|
||||
),
|
||||
ArticleInJournalController.PEER_REVIEWED,
|
||||
ArticleInJournalPropertiesStep::formatReviewed
|
||||
);
|
||||
|
||||
return sheet;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addBasicProperties(final ItemSelectionModel itemModel,
|
||||
final AuthoringKitWizard parent
|
||||
) {
|
||||
final SimpleEditStep basicProperties = new SimpleEditStep(
|
||||
itemModel,
|
||||
parent,
|
||||
selectedLanguageParam,
|
||||
EDIT_SHEET_NAME
|
||||
);
|
||||
|
||||
final BasicPageForm editBasicSheet = new ArticleInJournalPropertyForm(
|
||||
itemModel, this);
|
||||
|
||||
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),
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,273 @@
|
|||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package com.arsdigita.cms.contenttypes.ui;
|
||||
|
||||
import com.arsdigita.bebop.FormData;
|
||||
import com.arsdigita.bebop.FormProcessException;
|
||||
import com.arsdigita.bebop.Label;
|
||||
import com.arsdigita.bebop.PageState;
|
||||
import com.arsdigita.bebop.event.FormInitListener;
|
||||
import com.arsdigita.bebop.event.FormProcessListener;
|
||||
import com.arsdigita.bebop.event.FormSectionEvent;
|
||||
import com.arsdigita.bebop.event.FormSubmissionListener;
|
||||
import com.arsdigita.bebop.form.CheckboxGroup;
|
||||
import com.arsdigita.bebop.form.Option;
|
||||
import com.arsdigita.bebop.form.TextField;
|
||||
import com.arsdigita.bebop.parameters.DateParameter;
|
||||
import com.arsdigita.bebop.parameters.IntegerParameter;
|
||||
import com.arsdigita.bebop.parameters.ParameterModel;
|
||||
import com.arsdigita.bebop.parameters.StringParameter;
|
||||
import com.arsdigita.cms.ItemSelectionModel;
|
||||
import com.arsdigita.cms.ui.authoring.SelectedLanguageUtil;
|
||||
import com.arsdigita.globalization.GlobalizedMessage;
|
||||
|
||||
import org.libreccm.cdi.utils.CdiUtil;
|
||||
import org.scientificcms.publications.ArticleInJournal;
|
||||
import org.scientificcms.publications.SciPublicationsConstants;
|
||||
import org.scientificcms.publications.contenttypes.ArticleInJournalItem;
|
||||
|
||||
import java.util.Calendar;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||
*/
|
||||
public class ArticleInJournalPropertyForm
|
||||
extends PublicationPropertyForm
|
||||
implements FormInitListener,
|
||||
FormProcessListener,
|
||||
FormSubmissionListener {
|
||||
|
||||
public static final String ID = "ArticleInJournalEdit";
|
||||
|
||||
private static final String REVIEWED = "reviewed";
|
||||
|
||||
private final ArticleInJournalPropertiesStep propertiesStep;
|
||||
|
||||
private final StringParameter selectedLanguageParam;
|
||||
|
||||
private CheckboxGroup reviewed;
|
||||
|
||||
public ArticleInJournalPropertyForm(
|
||||
final ItemSelectionModel itemModel,
|
||||
final StringParameter selectedLanguageParam
|
||||
) {
|
||||
this(itemModel, null, selectedLanguageParam);
|
||||
}
|
||||
|
||||
public ArticleInJournalPropertyForm(
|
||||
final ItemSelectionModel itemModel,
|
||||
final ArticleInJournalPropertiesStep propertiesStep,
|
||||
final StringParameter selectedLanguageParam
|
||||
) {
|
||||
|
||||
super(itemModel, propertiesStep, selectedLanguageParam);
|
||||
this.propertiesStep = propertiesStep;
|
||||
this.selectedLanguageParam = selectedLanguageParam;
|
||||
addSubmissionListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addWidgets() {
|
||||
|
||||
super.addWidgets();
|
||||
|
||||
final ParameterModel volumeParam = new IntegerParameter(
|
||||
ArticleInJournalController.VOLUME
|
||||
);
|
||||
final TextField volume = new TextField(volumeParam);
|
||||
volume.setLabel(
|
||||
new GlobalizedMessage(
|
||||
"publications.ui.articleinjournal.volume",
|
||||
SciPublicationsConstants.BUNDLE
|
||||
)
|
||||
);
|
||||
add(volume);
|
||||
|
||||
final ParameterModel issueParam = new StringParameter(
|
||||
ArticleInJournalController.ISSUE
|
||||
);
|
||||
final TextField issue = new TextField(issueParam);
|
||||
issue.setLabel(
|
||||
new GlobalizedMessage(
|
||||
"publications.ui.articleinjournal.issue",
|
||||
SciPublicationsConstants.BUNDLE
|
||||
)
|
||||
);
|
||||
add(issue);
|
||||
|
||||
final ParameterModel pagesFromParam = new IntegerParameter(
|
||||
ArticleInJournalController.START_PAGE
|
||||
);
|
||||
final TextField startPage = new TextField(pagesFromParam);
|
||||
startPage.setLabel(
|
||||
new GlobalizedMessage(
|
||||
"publications.ui.articleinjournal.pages_from",
|
||||
SciPublicationsConstants.BUNDLE
|
||||
)
|
||||
);
|
||||
add(startPage);
|
||||
|
||||
final ParameterModel pagesToParam = new IntegerParameter(
|
||||
ArticleInJournalController.END_PAGE
|
||||
);
|
||||
final TextField endPage = new TextField(pagesToParam);
|
||||
endPage.setLabel(
|
||||
new GlobalizedMessage(
|
||||
"publications.ui.articleinjournal.pages_to",
|
||||
SciPublicationsConstants.BUNDLE
|
||||
)
|
||||
);
|
||||
add(endPage);
|
||||
|
||||
final Calendar today = new GregorianCalendar();
|
||||
final ParameterModel pubDateParam = new DateParameter(
|
||||
ArticleInJournalController.PUBLICATION_DATE
|
||||
);
|
||||
final com.arsdigita.bebop.form.Date pubDate
|
||||
= new com.arsdigita.bebop.form.Date(
|
||||
pubDateParam
|
||||
);
|
||||
pubDate.setYearAsc(false);
|
||||
pubDate.setYearRange(1900, today.get(Calendar.YEAR) + 2);
|
||||
pubDate.setLabel(
|
||||
new GlobalizedMessage(
|
||||
"publications.ui.articleinjournal.publicationDate",
|
||||
SciPublicationsConstants.BUNDLE
|
||||
)
|
||||
);
|
||||
add(pubDate);
|
||||
|
||||
reviewed = new CheckboxGroup("reviewedGroup");
|
||||
reviewed.addOption(new Option(
|
||||
REVIEWED,
|
||||
new Label(
|
||||
new GlobalizedMessage(
|
||||
"publications.ui.articleinjournal.reviewed",
|
||||
SciPublicationsConstants.BUNDLE)
|
||||
)
|
||||
)
|
||||
);
|
||||
reviewed.setLabel(
|
||||
new GlobalizedMessage(
|
||||
"publications.ui.articleinjournal.reviewed"
|
||||
)
|
||||
);
|
||||
add(reviewed);
|
||||
}
|
||||
|
||||
protected final CheckboxGroup getReviewed() {
|
||||
return reviewed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(final FormSectionEvent event) throws FormProcessException {
|
||||
super.init(event);
|
||||
|
||||
final FormData data = event.getFormData();
|
||||
final ArticleInJournalItem articleItem
|
||||
= (ArticleInJournalItem) initBasicWidgets(
|
||||
event);
|
||||
final ArticleInJournal article = articleItem.getPublication();
|
||||
|
||||
data.put(ArticleInJournalController.VOLUME, article.getVolume());
|
||||
data.put(ArticleInJournalController.ISSUE, article.getIssue());
|
||||
data.put(ArticleInJournalController.START_PAGE, article.getStartPage());
|
||||
data.put(ArticleInJournalController.END_PAGE, article.getEndPage());
|
||||
data.put(ArticleInJournalController.PUBLICATION_DATE,
|
||||
article.getPublicationDate());
|
||||
|
||||
if ((article.getPeerReviewed() != null)
|
||||
&& (article.getPeerReviewed())) {
|
||||
reviewed.setValue(event.getPageState(), new String[]{REVIEWED});
|
||||
} else {
|
||||
reviewed.setValue(event.getPageState(), null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void process(final FormSectionEvent event)
|
||||
throws FormProcessException {
|
||||
|
||||
super.process(event);
|
||||
|
||||
final FormData formData = event.getFormData();
|
||||
final PageState state = event.getPageState();
|
||||
final ArticleInJournalItem articleItem
|
||||
= (ArticleInJournalItem) processBasicWidgets(
|
||||
event
|
||||
);
|
||||
|
||||
if ((articleItem != null)
|
||||
&& getSaveCancelSection().getSaveButton().isSelected(event
|
||||
.getPageState()
|
||||
)) {
|
||||
|
||||
final Map<String, Object> data = new HashMap<>();
|
||||
|
||||
data.put(
|
||||
ArticleInJournalController.VOLUME,
|
||||
formData.get(ArticleInJournalController.VOLUME
|
||||
)
|
||||
);
|
||||
|
||||
data.put(
|
||||
ArticleInJournalController.ISSUE,
|
||||
formData.get(ArticleInJournalController.ISSUE
|
||||
)
|
||||
);
|
||||
|
||||
data.put(
|
||||
ArticleInJournalController.START_PAGE,
|
||||
formData.get(ArticleInJournalController.START_PAGE
|
||||
)
|
||||
);
|
||||
|
||||
data.put(
|
||||
ArticleInJournalController.END_PAGE,
|
||||
formData.get(ArticleInJournalController.END_PAGE
|
||||
)
|
||||
);
|
||||
|
||||
data.put(
|
||||
ArticleInJournalController.PUBLICATION_DATE,
|
||||
formData.get(ArticleInJournalController.PUBLICATION_DATE
|
||||
)
|
||||
);
|
||||
|
||||
if (reviewed.getValue(event.getPageState()) == null) {
|
||||
data.put(
|
||||
ArticleInCollectedVolumeController.PEER_REVIEWED,
|
||||
Boolean.FALSE
|
||||
);
|
||||
} else {
|
||||
data.put(
|
||||
ArticleInCollectedVolumeController.PEER_REVIEWED,
|
||||
Boolean.TRUE
|
||||
);
|
||||
}
|
||||
|
||||
final Locale selectedLocale = SelectedLanguageUtil.selectedLocale(
|
||||
state, selectedLanguageParam
|
||||
);
|
||||
|
||||
final ArticleInJournalController controller = CdiUtil
|
||||
.createCdiUtil()
|
||||
.findBean(ArticleInJournalController.class);
|
||||
controller.saveArticle(
|
||||
articleItem.getPublication().getPublicationId(),
|
||||
selectedLocale,
|
||||
data
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -163,10 +163,11 @@ public class PublicationPropertiesStep extends SimpleEditStep {
|
|||
return segmentedPanel;
|
||||
}
|
||||
|
||||
protected void addBasicProperties(final ItemSelectionModel itemModel,
|
||||
final AuthoringKitWizard parent) {
|
||||
protected void addBasicProperties(
|
||||
final ItemSelectionModel itemModel, final AuthoringKitWizard parent
|
||||
) {
|
||||
|
||||
SimpleEditStep basicProperties = new SimpleEditStep(
|
||||
final SimpleEditStep basicProperties = new SimpleEditStep(
|
||||
itemModel,
|
||||
parent,
|
||||
selectedLangParameter,
|
||||
|
|
|
|||
|
|
@ -0,0 +1,78 @@
|
|||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package org.scientificcms.publications;
|
||||
|
||||
import org.libreccm.security.AuthorizationRequired;
|
||||
import org.libreccm.security.RequiresPrivilege;
|
||||
import org.librecms.contentsection.privileges.ItemPrivileges;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
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 ArticleInJournalManager {
|
||||
|
||||
@Inject
|
||||
private JournalRepository journalRepository;
|
||||
|
||||
@Inject
|
||||
private PublicationRepository publicationRepository;
|
||||
|
||||
/**
|
||||
* Set the {@link ArticleInJournal#journal} to the provided {@link Journal}
|
||||
* and update the list of articles of the provided {@link Journal}.
|
||||
*
|
||||
* @param ofArticle
|
||||
* @param toJournal
|
||||
*/
|
||||
@AuthorizationRequired
|
||||
@RequiresPrivilege(ItemPrivileges.EDIT)
|
||||
@Transactional(Transactional.TxType.REQUIRED)
|
||||
public void setJournal(
|
||||
final ArticleInJournal ofArticle,
|
||||
final Journal toJournal
|
||||
) {
|
||||
Objects.requireNonNull(ofArticle);
|
||||
Objects.requireNonNull(toJournal);
|
||||
|
||||
ofArticle.setJournal(toJournal);
|
||||
toJournal.addArticle(ofArticle);
|
||||
publicationRepository.save(ofArticle);
|
||||
journalRepository.save(toJournal);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unset the {@link ArticleInJournal#journal} and remove the article from
|
||||
* the {@link CollectedVolume}.
|
||||
*
|
||||
* @param ofArticle
|
||||
*/
|
||||
@AuthorizationRequired
|
||||
@RequiresPrivilege(ItemPrivileges.EDIT)
|
||||
@Transactional(Transactional.TxType.REQUIRED)
|
||||
public void unsetJournal(
|
||||
final ArticleInJournal ofArticle
|
||||
) {
|
||||
Objects.requireNonNull(ofArticle);
|
||||
|
||||
if (ofArticle.getJournal() != null) {
|
||||
final Journal journal = ofArticle.getJournal();
|
||||
ofArticle.setJournal(null);
|
||||
journal.removeArticle(ofArticle);
|
||||
|
||||
publicationRepository.save(ofArticle);
|
||||
journalRepository.save(journal);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue