Forms for UnPublished and GreyLiterature
parent
ea92d065ed
commit
6c0714804d
|
|
@ -0,0 +1,57 @@
|
||||||
|
/*
|
||||||
|
* To change this license header, choose License Headers in Project Properties.
|
||||||
|
* To change this template file, choose Tools | Templates
|
||||||
|
* and open the template in the editor.
|
||||||
|
*/
|
||||||
|
package com.arsdigita.cms.contenttypes.ui;
|
||||||
|
|
||||||
|
import org.scientificcms.publications.GreyLiterature;
|
||||||
|
import org.scientificcms.publications.PublicationRepository;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import javax.enterprise.context.RequestScoped;
|
||||||
|
import javax.inject.Inject;
|
||||||
|
import javax.transaction.Transactional;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||||
|
*/
|
||||||
|
@RequestScoped
|
||||||
|
public class GreyLiteratureController {
|
||||||
|
|
||||||
|
public static final String START_PAGE = "startPage";
|
||||||
|
public static final String END_PAGE = "endPage";
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private PublicationRepository publicationRepository;
|
||||||
|
|
||||||
|
@Transactional(Transactional.TxType.REQUIRED)
|
||||||
|
public void saveGreyLiterature(
|
||||||
|
final long greyLiteratureId, final Map<String, Object> data
|
||||||
|
) {
|
||||||
|
final GreyLiterature publication = publicationRepository
|
||||||
|
.findByIdAndType(greyLiteratureId, GreyLiterature.class
|
||||||
|
)
|
||||||
|
.orElseThrow(
|
||||||
|
() -> new IllegalArgumentException(
|
||||||
|
String.format(
|
||||||
|
"No GreyLiterature publication with ID %d found",
|
||||||
|
greyLiteratureId
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (data.containsKey(START_PAGE)) {
|
||||||
|
publication.setStartPage((Integer) data.get(START_PAGE));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data.containsKey(END_PAGE)) {
|
||||||
|
publication.setEndPage((Integer) data.get(END_PAGE));
|
||||||
|
}
|
||||||
|
|
||||||
|
publicationRepository.save(publication);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,111 @@
|
||||||
|
/*
|
||||||
|
* To change this license header, choose License Headers in Project Properties.
|
||||||
|
* To change this template file, choose Tools | Templates
|
||||||
|
* and open the template in the editor.
|
||||||
|
*/
|
||||||
|
package com.arsdigita.cms.contenttypes.ui;
|
||||||
|
|
||||||
|
import com.arsdigita.bebop.Component;
|
||||||
|
import com.arsdigita.bebop.Label;
|
||||||
|
import com.arsdigita.bebop.parameters.StringParameter;
|
||||||
|
import com.arsdigita.cms.ItemSelectionModel;
|
||||||
|
import com.arsdigita.cms.ui.authoring.AuthoringKitWizard;
|
||||||
|
import com.arsdigita.cms.ui.authoring.BasicPageForm;
|
||||||
|
import com.arsdigita.cms.ui.authoring.SimpleEditStep;
|
||||||
|
import com.arsdigita.cms.ui.workflow.WorkflowLockedComponentAccess;
|
||||||
|
import com.arsdigita.globalization.GlobalizedMessage;
|
||||||
|
import com.arsdigita.toolbox.ui.DomainObjectPropertySheet;
|
||||||
|
|
||||||
|
import org.scientificcms.publications.SciPublicationsConstants;
|
||||||
|
|
||||||
|
import static com.arsdigita.cms.contenttypes.ui.PublicationPropertiesStep.*;
|
||||||
|
import static com.arsdigita.cms.contenttypes.ui.UnPublishedPropertiesStep.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||||
|
*/
|
||||||
|
public class GreyLiteraturePropertiesStep extends UnPublishedPropertiesStep {
|
||||||
|
|
||||||
|
private final StringParameter selectedLangParam;
|
||||||
|
|
||||||
|
public GreyLiteraturePropertiesStep(
|
||||||
|
final ItemSelectionModel itemModel,
|
||||||
|
final AuthoringKitWizard parent,
|
||||||
|
final StringParameter selectedLangParam
|
||||||
|
) {
|
||||||
|
super(itemModel, parent, selectedLangParam);
|
||||||
|
this.selectedLangParam = selectedLangParam;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Component getGreyLiteraturePropertySheet(
|
||||||
|
final ItemSelectionModel itemModel,
|
||||||
|
final StringParameter selectedLangParam
|
||||||
|
) {
|
||||||
|
final DomainObjectPropertySheet sheet
|
||||||
|
= (DomainObjectPropertySheet) getUnPublishedPropertySheet(
|
||||||
|
itemModel, selectedLangParam
|
||||||
|
);
|
||||||
|
|
||||||
|
sheet.add(
|
||||||
|
new GlobalizedMessage(
|
||||||
|
"publications.ui.greyliterature.pages_from",
|
||||||
|
SciPublicationsConstants.BUNDLE
|
||||||
|
),
|
||||||
|
GreyLiteratureController.START_PAGE
|
||||||
|
);
|
||||||
|
|
||||||
|
sheet.add(
|
||||||
|
new GlobalizedMessage(
|
||||||
|
"publications.ui.greyliterature.pages_to",
|
||||||
|
SciPublicationsConstants.BUNDLE
|
||||||
|
),
|
||||||
|
GreyLiteratureController.END_PAGE);
|
||||||
|
|
||||||
|
return sheet;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void addBasicProperties(
|
||||||
|
final ItemSelectionModel itemModel,
|
||||||
|
final AuthoringKitWizard parent
|
||||||
|
) {
|
||||||
|
final SimpleEditStep basicProperties = new SimpleEditStep(
|
||||||
|
itemModel,
|
||||||
|
parent,
|
||||||
|
selectedLangParam,
|
||||||
|
EDIT_SHEET_NAME
|
||||||
|
);
|
||||||
|
|
||||||
|
final BasicPageForm editBasicSheet = new GreyLiteraturePropertyForm(
|
||||||
|
itemModel,
|
||||||
|
this,
|
||||||
|
selectedLangParam
|
||||||
|
);
|
||||||
|
|
||||||
|
basicProperties.add(
|
||||||
|
EDIT_SHEET_NAME,
|
||||||
|
new GlobalizedMessage(
|
||||||
|
"publications.ui.greyliterature.edit_basic_sheet",
|
||||||
|
SciPublicationsConstants.BUNDLE
|
||||||
|
),
|
||||||
|
new WorkflowLockedComponentAccess(
|
||||||
|
editBasicSheet,
|
||||||
|
itemModel
|
||||||
|
),
|
||||||
|
editBasicSheet.getSaveCancelSection().getCancelButton());
|
||||||
|
|
||||||
|
basicProperties.setDisplayComponent(
|
||||||
|
getGreyLiteraturePropertySheet(itemModel, selectedLangParam));
|
||||||
|
|
||||||
|
getSegmentedPanel().addSegment(
|
||||||
|
new Label(
|
||||||
|
new GlobalizedMessage(
|
||||||
|
"publications.ui.publication.basic_properties",
|
||||||
|
SciPublicationsConstants.BUNDLE
|
||||||
|
)
|
||||||
|
),
|
||||||
|
basicProperties);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,140 @@
|
||||||
|
/*
|
||||||
|
* To change this license header, choose License Headers in Project Properties.
|
||||||
|
* To change this template file, choose Tools | Templates
|
||||||
|
* and open the template in the editor.
|
||||||
|
*/
|
||||||
|
package com.arsdigita.cms.contenttypes.ui;
|
||||||
|
|
||||||
|
import com.arsdigita.bebop.FormData;
|
||||||
|
import com.arsdigita.bebop.FormProcessException;
|
||||||
|
import com.arsdigita.bebop.PageState;
|
||||||
|
import com.arsdigita.bebop.event.FormInitListener;
|
||||||
|
import com.arsdigita.bebop.event.FormProcessListener;
|
||||||
|
import com.arsdigita.bebop.event.FormSectionEvent;
|
||||||
|
import com.arsdigita.bebop.event.FormSubmissionListener;
|
||||||
|
import com.arsdigita.bebop.form.TextField;
|
||||||
|
import com.arsdigita.bebop.parameters.IntegerParameter;
|
||||||
|
import com.arsdigita.bebop.parameters.ParameterModel;
|
||||||
|
import com.arsdigita.bebop.parameters.StringParameter;
|
||||||
|
import com.arsdigita.cms.ItemSelectionModel;
|
||||||
|
import com.arsdigita.globalization.GlobalizedMessage;
|
||||||
|
|
||||||
|
import org.libreccm.cdi.utils.CdiUtil;
|
||||||
|
import org.scientificcms.publications.GreyLiterature;
|
||||||
|
import org.scientificcms.publications.SciPublicationsConstants;
|
||||||
|
import org.scientificcms.publications.contenttypes.GreyLiteratureItem;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||||
|
*/
|
||||||
|
public class GreyLiteraturePropertyForm extends UnPublishedPropertyForm
|
||||||
|
implements FormInitListener,
|
||||||
|
FormProcessListener, FormSubmissionListener {
|
||||||
|
|
||||||
|
public static final String ID = "GreyLiteratureEdit";
|
||||||
|
|
||||||
|
private GreyLiteraturePropertiesStep step;
|
||||||
|
|
||||||
|
public GreyLiteraturePropertyForm(
|
||||||
|
final ItemSelectionModel itemModel,
|
||||||
|
final StringParameter selectedLangParam
|
||||||
|
) {
|
||||||
|
this(itemModel, null, selectedLangParam);
|
||||||
|
}
|
||||||
|
|
||||||
|
public GreyLiteraturePropertyForm(
|
||||||
|
final ItemSelectionModel itemModel,
|
||||||
|
final GreyLiteraturePropertiesStep step,
|
||||||
|
final StringParameter selectedLangParam
|
||||||
|
) {
|
||||||
|
super(itemModel, step, selectedLangParam);
|
||||||
|
this.step = step;
|
||||||
|
addSubmissionListener(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void addWidgets() {
|
||||||
|
|
||||||
|
super.addWidgets();
|
||||||
|
|
||||||
|
final ParameterModel fromParam = new IntegerParameter(
|
||||||
|
GreyLiteratureController.START_PAGE
|
||||||
|
);
|
||||||
|
final TextField pagesFrom = new TextField(fromParam);
|
||||||
|
pagesFrom.setLabel(
|
||||||
|
new GlobalizedMessage(
|
||||||
|
"publications.ui.greyliterature.pages_from",
|
||||||
|
SciPublicationsConstants.BUNDLE
|
||||||
|
)
|
||||||
|
);
|
||||||
|
add(pagesFrom);
|
||||||
|
|
||||||
|
final ParameterModel toParam = new IntegerParameter(
|
||||||
|
GreyLiteratureController.END_PAGE);
|
||||||
|
final TextField pagesTo = new TextField(toParam);
|
||||||
|
pagesTo.setLabel(
|
||||||
|
new GlobalizedMessage(
|
||||||
|
"publications.ui.greyliterature.pages_to",
|
||||||
|
SciPublicationsConstants.BUNDLE
|
||||||
|
)
|
||||||
|
);
|
||||||
|
add(pagesTo);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void init(final FormSectionEvent event) throws FormProcessException {
|
||||||
|
super.init(event);
|
||||||
|
|
||||||
|
final FormData data = event.getFormData();
|
||||||
|
final GreyLiteratureItem greyItem
|
||||||
|
= (GreyLiteratureItem) initBasicWidgets(
|
||||||
|
event);
|
||||||
|
final GreyLiterature grey = greyItem.getPublication();
|
||||||
|
|
||||||
|
data.put(
|
||||||
|
GreyLiteratureController.START_PAGE, grey.getStartPage()
|
||||||
|
);
|
||||||
|
data.put(
|
||||||
|
GreyLiteratureController.END_PAGE, grey.getEndPage()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void process(final FormSectionEvent event)
|
||||||
|
throws FormProcessException {
|
||||||
|
super.process(event);
|
||||||
|
|
||||||
|
final FormData formData = event.getFormData();
|
||||||
|
final PageState state = event.getPageState();
|
||||||
|
final GreyLiteratureItem greyItem
|
||||||
|
= (GreyLiteratureItem) processBasicWidgets(
|
||||||
|
event);
|
||||||
|
|
||||||
|
if ((greyItem != null)
|
||||||
|
&& getSaveCancelSection().getSaveButton().isSelected(state)) {
|
||||||
|
|
||||||
|
final Map<String, Object> data = new HashMap<>();
|
||||||
|
data.put(
|
||||||
|
GreyLiteratureController.START_PAGE,
|
||||||
|
formData.get(GreyLiteratureController.START_PAGE)
|
||||||
|
);
|
||||||
|
data.put(
|
||||||
|
GreyLiteratureController.END_PAGE,
|
||||||
|
formData.get(GreyLiteratureController.END_PAGE)
|
||||||
|
);
|
||||||
|
|
||||||
|
final GreyLiteratureController controller = CdiUtil
|
||||||
|
.createCdiUtil()
|
||||||
|
.findBean(GreyLiteratureController.class);
|
||||||
|
controller.saveGreyLiterature(
|
||||||
|
greyItem.getPublication().getPublicationId(),
|
||||||
|
data
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,114 @@
|
||||||
|
/*
|
||||||
|
* To change this license header, choose License Headers in Project Properties.
|
||||||
|
* To change this template file, choose Tools | Templates
|
||||||
|
* and open the template in the editor.
|
||||||
|
*/
|
||||||
|
package com.arsdigita.cms.contenttypes.ui;
|
||||||
|
|
||||||
|
import org.librecms.assets.Organization;
|
||||||
|
import org.librecms.contentsection.AssetRepository;
|
||||||
|
import org.scientificcms.publications.PublicationRepository;
|
||||||
|
import org.scientificcms.publications.UnPublished;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import javax.enterprise.context.RequestScoped;
|
||||||
|
import javax.inject.Inject;
|
||||||
|
import javax.transaction.Transactional;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||||
|
*/
|
||||||
|
@RequestScoped
|
||||||
|
public class UnPublishedController extends PublicationPropertiesStep {
|
||||||
|
|
||||||
|
public static final String PLACE = "place";
|
||||||
|
|
||||||
|
public static final String NUMBER = "number";
|
||||||
|
|
||||||
|
public static final String NUMBER_OF_PAGES = "numberOfPages";
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private AssetRepository assetRepository;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private PublicationRepository publicationRepository;
|
||||||
|
|
||||||
|
@Transactional(Transactional.TxType.REQUIRED)
|
||||||
|
public void saveUnPublished(
|
||||||
|
final long unpublishedId, final Map<String, Object> data
|
||||||
|
) {
|
||||||
|
final UnPublished unPublished = publicationRepository
|
||||||
|
.findByIdAndType(unpublishedId, UnPublished.class)
|
||||||
|
.orElseThrow(
|
||||||
|
() -> new IllegalArgumentException(
|
||||||
|
String.format(
|
||||||
|
"No UnPublished publication with ID %d found.",
|
||||||
|
unpublishedId
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (data.containsKey(PLACE)) {
|
||||||
|
unPublished.setPlace((String) data.get(PLACE));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data.containsKey(NUMBER)) {
|
||||||
|
unPublished.setNumber((String) data.get(NUMBER));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data.containsKey(NUMBER_OF_PAGES)) {
|
||||||
|
unPublished.setNumberOfPages((Integer) data.get(NUMBER_OF_PAGES));
|
||||||
|
}
|
||||||
|
|
||||||
|
publicationRepository.save(unPublished);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Transactional(Transactional.TxType.REQUIRED)
|
||||||
|
public void setOrganzation(
|
||||||
|
final long unpublishedId, final long organizationId
|
||||||
|
) {
|
||||||
|
final UnPublished unPublished = publicationRepository
|
||||||
|
.findByIdAndType(unpublishedId, UnPublished.class)
|
||||||
|
.orElseThrow(
|
||||||
|
() -> new IllegalArgumentException(
|
||||||
|
String.format(
|
||||||
|
"No UnPublished publication with ID %d found.",
|
||||||
|
unpublishedId
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
final Organization organization = assetRepository
|
||||||
|
.findById(organizationId, Organization.class)
|
||||||
|
.orElseThrow(
|
||||||
|
() -> new IllegalArgumentException(
|
||||||
|
String.format(
|
||||||
|
"No Organization with ID %d found.", organizationId
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
unPublished.setOrganization(organization);
|
||||||
|
publicationRepository.save(unPublished);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Transactional(Transactional.TxType.REQUIRED)
|
||||||
|
public void unsetOrganization(final long unpublishedId) {
|
||||||
|
final UnPublished unPublished = publicationRepository
|
||||||
|
.findByIdAndType(unpublishedId, UnPublished.class)
|
||||||
|
.orElseThrow(
|
||||||
|
() -> new IllegalArgumentException(
|
||||||
|
String.format(
|
||||||
|
"No UnPublished publication with ID %d found.",
|
||||||
|
unpublishedId
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
unPublished.setOrganization(null);
|
||||||
|
publicationRepository.save(unPublished);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,90 @@
|
||||||
|
/*
|
||||||
|
* To change this license header, choose License Headers in Project Properties.
|
||||||
|
* To change this template file, choose Tools | Templates
|
||||||
|
* and open the template in the editor.
|
||||||
|
*/
|
||||||
|
package com.arsdigita.cms.contenttypes.ui;
|
||||||
|
|
||||||
|
import com.arsdigita.bebop.FormData;
|
||||||
|
import com.arsdigita.bebop.FormProcessException;
|
||||||
|
import com.arsdigita.bebop.PageState;
|
||||||
|
import com.arsdigita.bebop.event.FormInitListener;
|
||||||
|
import com.arsdigita.bebop.event.FormProcessListener;
|
||||||
|
import com.arsdigita.bebop.event.FormSectionEvent;
|
||||||
|
import com.arsdigita.bebop.parameters.StringParameter;
|
||||||
|
import com.arsdigita.cms.ItemSelectionModel;
|
||||||
|
import com.arsdigita.cms.ui.assets.AssetSearchWidget;
|
||||||
|
import com.arsdigita.cms.ui.authoring.BasicItemForm;
|
||||||
|
import com.arsdigita.globalization.GlobalizedMessage;
|
||||||
|
|
||||||
|
import org.libreccm.cdi.utils.CdiUtil;
|
||||||
|
import org.librecms.assets.Organization;
|
||||||
|
import org.scientificcms.publications.SciPublicationsConstants;
|
||||||
|
import org.scientificcms.publications.contenttypes.PublicationItem;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||||
|
*/
|
||||||
|
public class UnPublishedOrganizationForm
|
||||||
|
extends BasicItemForm
|
||||||
|
implements FormProcessListener, FormInitListener {
|
||||||
|
|
||||||
|
private static final String ORGA_SEARCH = "unPublishedOrga";
|
||||||
|
|
||||||
|
private AssetSearchWidget orgaSearch;
|
||||||
|
|
||||||
|
public UnPublishedOrganizationForm(
|
||||||
|
final ItemSelectionModel itemModel,
|
||||||
|
final StringParameter selectedLangParam
|
||||||
|
) {
|
||||||
|
super("UnPublishedOrganizationForm", itemModel, selectedLangParam);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addWidgets() {
|
||||||
|
|
||||||
|
orgaSearch = new AssetSearchWidget(ORGA_SEARCH, Organization.class);
|
||||||
|
orgaSearch.setLabel(
|
||||||
|
new GlobalizedMessage(
|
||||||
|
"publications.ui.unpublished.organization",
|
||||||
|
SciPublicationsConstants.BUNDLE
|
||||||
|
)
|
||||||
|
);
|
||||||
|
add(orgaSearch);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void init(final FormSectionEvent event) throws FormProcessException {
|
||||||
|
final PageState state = event.getPageState();
|
||||||
|
|
||||||
|
setVisible(state, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void process(final FormSectionEvent event)
|
||||||
|
throws FormProcessException {
|
||||||
|
final FormData formData = event.getFormData();
|
||||||
|
final PageState state = event.getPageState();
|
||||||
|
final PublicationItem<?> publicationItem
|
||||||
|
= (PublicationItem) getItemSelectionModel()
|
||||||
|
.getSelectedItem(state);
|
||||||
|
|
||||||
|
if (getSaveCancelSection().getSaveButton().isSelected(state)) {
|
||||||
|
final Organization organization
|
||||||
|
= (Organization) formData
|
||||||
|
.get(ORGA_SEARCH);
|
||||||
|
final UnPublishedController controller = CdiUtil
|
||||||
|
.createCdiUtil()
|
||||||
|
.findBean(UnPublishedController.class);
|
||||||
|
controller.setOrganzation(
|
||||||
|
publicationItem.getPublication().getPublicationId(),
|
||||||
|
organization.getObjectId()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
init(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,266 @@
|
||||||
|
/*
|
||||||
|
* To change this license header, choose License Headers in Project Properties.
|
||||||
|
* To change this template file, choose Tools | Templates
|
||||||
|
* and open the template in the editor.
|
||||||
|
*/
|
||||||
|
package com.arsdigita.cms.contenttypes.ui;
|
||||||
|
|
||||||
|
import com.arsdigita.bebop.Component;
|
||||||
|
import com.arsdigita.bebop.ControlLink;
|
||||||
|
import com.arsdigita.bebop.Label;
|
||||||
|
import com.arsdigita.bebop.PageState;
|
||||||
|
import com.arsdigita.bebop.Table;
|
||||||
|
import com.arsdigita.bebop.Text;
|
||||||
|
import com.arsdigita.bebop.event.TableActionEvent;
|
||||||
|
import com.arsdigita.bebop.event.TableActionListener;
|
||||||
|
import com.arsdigita.bebop.table.TableCellRenderer;
|
||||||
|
import com.arsdigita.bebop.table.TableColumn;
|
||||||
|
import com.arsdigita.bebop.table.TableColumnModel;
|
||||||
|
import com.arsdigita.bebop.table.TableModel;
|
||||||
|
import com.arsdigita.bebop.table.TableModelBuilder;
|
||||||
|
import com.arsdigita.cms.ItemSelectionModel;
|
||||||
|
import com.arsdigita.cms.dispatcher.Utilities;
|
||||||
|
import com.arsdigita.globalization.GlobalizedMessage;
|
||||||
|
import com.arsdigita.util.LockableImpl;
|
||||||
|
|
||||||
|
import org.libreccm.cdi.utils.CdiUtil;
|
||||||
|
import org.libreccm.security.PermissionChecker;
|
||||||
|
import org.librecms.assets.Organization;
|
||||||
|
import org.librecms.contentsection.privileges.ItemPrivileges;
|
||||||
|
import org.scientificcms.publications.SciPublicationsConstants;
|
||||||
|
import org.scientificcms.publications.UnPublished;
|
||||||
|
import org.scientificcms.publications.contenttypes.PublicationItem;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||||
|
*/
|
||||||
|
public class UnPublishedOrganizationSheet
|
||||||
|
extends Table
|
||||||
|
implements TableActionListener {
|
||||||
|
|
||||||
|
private static final String TABLE_COL_EDIT = "table_col_edit";
|
||||||
|
|
||||||
|
private static final String TABLE_COL_DELETE = "table_col_delete";
|
||||||
|
|
||||||
|
private final ItemSelectionModel itemModel;
|
||||||
|
|
||||||
|
public UnPublishedOrganizationSheet(final ItemSelectionModel itemModel) {
|
||||||
|
super();
|
||||||
|
this.itemModel = itemModel;
|
||||||
|
|
||||||
|
setEmptyView(
|
||||||
|
new Label(
|
||||||
|
new GlobalizedMessage(
|
||||||
|
"publications.ui.unpublished.organization.none",
|
||||||
|
SciPublicationsConstants.BUNDLE
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
final TableColumnModel columnModel = getColumnModel();
|
||||||
|
columnModel.add(
|
||||||
|
new TableColumn(
|
||||||
|
0,
|
||||||
|
new Label(
|
||||||
|
new GlobalizedMessage(
|
||||||
|
"publications.ui.unpublished.organization",
|
||||||
|
SciPublicationsConstants.BUNDLE
|
||||||
|
)
|
||||||
|
),
|
||||||
|
TABLE_COL_EDIT
|
||||||
|
)
|
||||||
|
);
|
||||||
|
columnModel.add(
|
||||||
|
new TableColumn(
|
||||||
|
1,
|
||||||
|
new Label(
|
||||||
|
new GlobalizedMessage(
|
||||||
|
"publications.ui.unpublished.organization.remove",
|
||||||
|
SciPublicationsConstants.BUNDLE
|
||||||
|
)
|
||||||
|
),
|
||||||
|
TABLE_COL_DELETE
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
setModelBuilder(
|
||||||
|
new UnPublishedOrganizationSheetModelBuilder(itemModel)
|
||||||
|
);
|
||||||
|
columnModel.get(0).setCellRenderer(new EditCellRenderer());
|
||||||
|
columnModel.get(1).setCellRenderer(new DeleteCellRenderer());
|
||||||
|
|
||||||
|
addTableActionListener(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void cellSelected(final TableActionEvent event) {
|
||||||
|
PageState state = event.getPageState();
|
||||||
|
|
||||||
|
final PublicationItem<?> publicationItem = (PublicationItem) itemModel
|
||||||
|
.getSelectedItem(state);
|
||||||
|
|
||||||
|
final TableColumn column = getColumnModel().get(event.getColumn());
|
||||||
|
if (column.getHeaderKey().toString().equals(TABLE_COL_EDIT)) {
|
||||||
|
// Nothing to do
|
||||||
|
} else if (column.getHeaderKey().toString().equals(TABLE_COL_DELETE)) {
|
||||||
|
final UnPublishedController controller = CdiUtil
|
||||||
|
.createCdiUtil()
|
||||||
|
.findBean(UnPublishedController.class);
|
||||||
|
controller.unsetOrganization(
|
||||||
|
publicationItem.getPublication().getPublicationId()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void headSelected(final TableActionEvent event) {
|
||||||
|
//Nothing to do
|
||||||
|
}
|
||||||
|
|
||||||
|
private class UnPublishedOrganizationSheetModelBuilder
|
||||||
|
extends LockableImpl
|
||||||
|
implements TableModelBuilder {
|
||||||
|
|
||||||
|
private final ItemSelectionModel itemModel;
|
||||||
|
|
||||||
|
public UnPublishedOrganizationSheetModelBuilder(
|
||||||
|
final ItemSelectionModel itemModel) {
|
||||||
|
this.itemModel = itemModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TableModel makeModel(final Table table, final PageState state) {
|
||||||
|
table.getRowSelectionModel().clearSelection(state);
|
||||||
|
final PublicationItem<?> publicationItem
|
||||||
|
= (PublicationItem) itemModel
|
||||||
|
.getSelectedItem(state);
|
||||||
|
final UnPublished unPublished = (UnPublished) publicationItem
|
||||||
|
.getPublication();
|
||||||
|
return new UnPublishedOrganizationSheetModel(
|
||||||
|
table, state, unPublished
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private class UnPublishedOrganizationSheetModel implements TableModel {
|
||||||
|
|
||||||
|
private final Table table;
|
||||||
|
private final Organization orga;
|
||||||
|
private boolean done;
|
||||||
|
|
||||||
|
public UnPublishedOrganizationSheetModel(
|
||||||
|
final Table table,
|
||||||
|
final PageState state,
|
||||||
|
final UnPublished unPublished
|
||||||
|
) {
|
||||||
|
this.table = table;
|
||||||
|
orga = unPublished.getOrganization();
|
||||||
|
done = orga != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getColumnCount() {
|
||||||
|
return table.getColumnModel().size();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean nextRow() {
|
||||||
|
boolean ret;
|
||||||
|
|
||||||
|
if (done) {
|
||||||
|
ret = true;
|
||||||
|
done = false;
|
||||||
|
} else {
|
||||||
|
ret = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object getElementAt(final int columnIndex) {
|
||||||
|
switch (columnIndex) {
|
||||||
|
case 0:
|
||||||
|
return orga.getTitle();
|
||||||
|
case 1:
|
||||||
|
return new Label(
|
||||||
|
new GlobalizedMessage(
|
||||||
|
"publications.ui.unpublished.organization.remove",
|
||||||
|
SciPublicationsConstants.BUNDLE
|
||||||
|
)
|
||||||
|
);
|
||||||
|
default:
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object getKeyAt(final int columnIndex) {
|
||||||
|
return orga.getObjectId();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private class EditCellRenderer
|
||||||
|
extends LockableImpl
|
||||||
|
implements TableCellRenderer {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Component getComponent(
|
||||||
|
final Table table,
|
||||||
|
final PageState state,
|
||||||
|
final Object value,
|
||||||
|
final boolean isSelected,
|
||||||
|
final Object key,
|
||||||
|
final int row,
|
||||||
|
final int column
|
||||||
|
) {
|
||||||
|
return new Text((String) value);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private class DeleteCellRenderer
|
||||||
|
extends LockableImpl
|
||||||
|
implements TableCellRenderer {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Component getComponent(
|
||||||
|
final Table table,
|
||||||
|
final PageState state,
|
||||||
|
final Object value,
|
||||||
|
final boolean isSelected,
|
||||||
|
final Object key,
|
||||||
|
final int row,
|
||||||
|
final int column
|
||||||
|
) {
|
||||||
|
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
|
||||||
|
final PermissionChecker permissionChecker = cdiUtil
|
||||||
|
.findBean(PermissionChecker.class);
|
||||||
|
|
||||||
|
final PublicationItem<?> publicationItem
|
||||||
|
= (PublicationItem) itemModel
|
||||||
|
.getSelectedItem(state);
|
||||||
|
final boolean canEdit = permissionChecker.isPermitted(
|
||||||
|
ItemPrivileges.EDIT, publicationItem
|
||||||
|
);
|
||||||
|
|
||||||
|
if (canEdit) {
|
||||||
|
final ControlLink link = new ControlLink((Label) value);
|
||||||
|
link.setConfirmation(
|
||||||
|
new GlobalizedMessage(
|
||||||
|
"publications.ui.unpublished.organization.confirm_remove",
|
||||||
|
SciPublicationsConstants.BUNDLE
|
||||||
|
)
|
||||||
|
);
|
||||||
|
return link;
|
||||||
|
} else {
|
||||||
|
return new Text("");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -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 UnPublishedOrganizationStep extends SimpleEditStep {
|
||||||
|
|
||||||
|
private static final String SET_UNPUBLISHED_ORGANIZATION_STEP
|
||||||
|
= "setUnPublishedOrganizationStep";
|
||||||
|
|
||||||
|
public UnPublishedOrganizationStep(
|
||||||
|
final ItemSelectionModel itemModel,
|
||||||
|
final AuthoringKitWizard parent,
|
||||||
|
final StringParameter selectedLangParam
|
||||||
|
) {
|
||||||
|
this(itemModel, parent, selectedLangParam, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public UnPublishedOrganizationStep(
|
||||||
|
final ItemSelectionModel itemModel,
|
||||||
|
final AuthoringKitWizard parent,
|
||||||
|
final StringParameter selectedLangParam,
|
||||||
|
final String prefix
|
||||||
|
) {
|
||||||
|
super(itemModel, parent, selectedLangParam, prefix);
|
||||||
|
|
||||||
|
final BasicItemForm setOrgaForm = new UnPublishedOrganizationForm(
|
||||||
|
itemModel, selectedLangParam
|
||||||
|
);
|
||||||
|
add(
|
||||||
|
SET_UNPUBLISHED_ORGANIZATION_STEP,
|
||||||
|
new GlobalizedMessage(
|
||||||
|
"publications.ui.unpublished.setOrganization",
|
||||||
|
SciPublicationsConstants.BUNDLE
|
||||||
|
),
|
||||||
|
new WorkflowLockedComponentAccess(setOrgaForm, itemModel),
|
||||||
|
setOrgaForm.getSaveCancelSection().getCancelButton());
|
||||||
|
|
||||||
|
final UnPublishedOrganizationSheet sheet
|
||||||
|
= new UnPublishedOrganizationSheet(
|
||||||
|
itemModel
|
||||||
|
);
|
||||||
|
setDisplayComponent(sheet);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,129 @@
|
||||||
|
/*
|
||||||
|
* To change this license header, choose License Headers in Project Properties.
|
||||||
|
* To change this template file, choose Tools | Templates
|
||||||
|
* and open the template in the editor.
|
||||||
|
*/
|
||||||
|
package com.arsdigita.cms.contenttypes.ui;
|
||||||
|
|
||||||
|
import com.arsdigita.bebop.Component;
|
||||||
|
import com.arsdigita.bebop.Label;
|
||||||
|
import com.arsdigita.bebop.parameters.StringParameter;
|
||||||
|
import com.arsdigita.cms.ItemSelectionModel;
|
||||||
|
import com.arsdigita.cms.ui.authoring.AuthoringKitWizard;
|
||||||
|
import com.arsdigita.cms.ui.authoring.BasicPageForm;
|
||||||
|
import com.arsdigita.cms.ui.authoring.SimpleEditStep;
|
||||||
|
import com.arsdigita.cms.ui.workflow.WorkflowLockedComponentAccess;
|
||||||
|
import com.arsdigita.globalization.GlobalizedMessage;
|
||||||
|
import com.arsdigita.toolbox.ui.DomainObjectPropertySheet;
|
||||||
|
|
||||||
|
import org.scientificcms.publications.SciPublicationsConstants;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||||
|
*/
|
||||||
|
public class UnPublishedPropertiesStep extends PublicationPropertiesStep {
|
||||||
|
|
||||||
|
private final StringParameter selectedLangParam;
|
||||||
|
|
||||||
|
public UnPublishedPropertiesStep(
|
||||||
|
final ItemSelectionModel itemModel,
|
||||||
|
final AuthoringKitWizard parent,
|
||||||
|
final StringParameter selectedLangParam
|
||||||
|
) {
|
||||||
|
super(itemModel, parent, selectedLangParam);
|
||||||
|
this.selectedLangParam = selectedLangParam;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Component getUnPublishedPropertySheet(
|
||||||
|
final ItemSelectionModel itemModel,
|
||||||
|
final StringParameter selectedLanParam
|
||||||
|
) {
|
||||||
|
final DomainObjectPropertySheet sheet
|
||||||
|
= (DomainObjectPropertySheet) PublicationPropertiesStep
|
||||||
|
.getPublicationPropertySheet(
|
||||||
|
itemModel, selectedLanParam
|
||||||
|
);
|
||||||
|
|
||||||
|
sheet.add(
|
||||||
|
new GlobalizedMessage(
|
||||||
|
"publications.ui.unpublished.place",
|
||||||
|
SciPublicationsConstants.BUNDLE
|
||||||
|
),
|
||||||
|
UnPublishedController.PLACE
|
||||||
|
);
|
||||||
|
|
||||||
|
sheet.add(
|
||||||
|
new GlobalizedMessage(
|
||||||
|
"publications.ui.unpublished.number",
|
||||||
|
SciPublicationsConstants.BUNDLE
|
||||||
|
),
|
||||||
|
UnPublishedController.NUMBER
|
||||||
|
);
|
||||||
|
|
||||||
|
sheet.add(
|
||||||
|
new GlobalizedMessage(
|
||||||
|
"publications.ui.unpublished.number_of_pages",
|
||||||
|
SciPublicationsConstants.BUNDLE
|
||||||
|
),
|
||||||
|
UnPublishedController.NUMBER_OF_PAGES
|
||||||
|
);
|
||||||
|
|
||||||
|
return sheet;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void addBasicProperties(
|
||||||
|
final ItemSelectionModel itemModel,
|
||||||
|
final AuthoringKitWizard parent
|
||||||
|
) {
|
||||||
|
final SimpleEditStep basicProperties = new SimpleEditStep(
|
||||||
|
itemModel,
|
||||||
|
parent,
|
||||||
|
selectedLangParam,
|
||||||
|
EDIT_SHEET_NAME
|
||||||
|
);
|
||||||
|
|
||||||
|
final BasicPageForm editBasicSheet = new UnPublishedPropertyForm(
|
||||||
|
itemModel, this, selectedLangParam
|
||||||
|
);
|
||||||
|
|
||||||
|
basicProperties.add(
|
||||||
|
EDIT_SHEET_NAME,
|
||||||
|
new GlobalizedMessage(
|
||||||
|
"publications.ui.unpublished.edit_basic_sheet",
|
||||||
|
SciPublicationsConstants.BUNDLE
|
||||||
|
),
|
||||||
|
new WorkflowLockedComponentAccess(editBasicSheet, itemModel),
|
||||||
|
editBasicSheet.getSaveCancelSection().getCancelButton()
|
||||||
|
);
|
||||||
|
|
||||||
|
basicProperties.setDisplayComponent(
|
||||||
|
getUnPublishedPropertySheet(itemModel, selectedLangParam));
|
||||||
|
|
||||||
|
getSegmentedPanel().addSegment(
|
||||||
|
new Label(
|
||||||
|
new GlobalizedMessage(
|
||||||
|
"publications.ui.publication.basic_properties",
|
||||||
|
SciPublicationsConstants.BUNDLE
|
||||||
|
)
|
||||||
|
),
|
||||||
|
basicProperties);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void addSteps(
|
||||||
|
final ItemSelectionModel itemModel, final AuthoringKitWizard parent
|
||||||
|
) {
|
||||||
|
super.addSteps(itemModel, parent);
|
||||||
|
|
||||||
|
addStep(new UnPublishedOrganizationStep(
|
||||||
|
itemModel, parent, selectedLangParam),
|
||||||
|
new GlobalizedMessage(
|
||||||
|
"publications.ui.unpublished.organization",
|
||||||
|
SciPublicationsConstants.BUNDLE
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,164 @@
|
||||||
|
/*
|
||||||
|
* To change this license header, choose License Headers in Project Properties.
|
||||||
|
* To change this template file, choose Tools | Templates
|
||||||
|
* and open the template in the editor.
|
||||||
|
*/
|
||||||
|
package com.arsdigita.cms.contenttypes.ui;
|
||||||
|
|
||||||
|
import com.arsdigita.bebop.FormData;
|
||||||
|
import com.arsdigita.bebop.FormProcessException;
|
||||||
|
import com.arsdigita.bebop.PageState;
|
||||||
|
import com.arsdigita.bebop.event.FormInitListener;
|
||||||
|
import com.arsdigita.bebop.event.FormProcessListener;
|
||||||
|
import com.arsdigita.bebop.event.FormSectionEvent;
|
||||||
|
import com.arsdigita.bebop.event.FormSubmissionListener;
|
||||||
|
import com.arsdigita.bebop.form.TextField;
|
||||||
|
import com.arsdigita.bebop.parameters.IntegerParameter;
|
||||||
|
import com.arsdigita.bebop.parameters.ParameterModel;
|
||||||
|
import com.arsdigita.bebop.parameters.StringParameter;
|
||||||
|
import com.arsdigita.cms.ItemSelectionModel;
|
||||||
|
import com.arsdigita.cms.ui.assets.AssetSearchWidget;
|
||||||
|
import com.arsdigita.globalization.GlobalizedMessage;
|
||||||
|
|
||||||
|
import org.libreccm.cdi.utils.CdiUtil;
|
||||||
|
import org.scientificcms.publications.SciPublicationsConstants;
|
||||||
|
import org.scientificcms.publications.UnPublished;
|
||||||
|
import org.scientificcms.publications.contenttypes.PublicationItem;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||||
|
*/
|
||||||
|
public class UnPublishedPropertyForm
|
||||||
|
extends PublicationPropertyForm
|
||||||
|
implements FormInitListener, FormProcessListener, FormSubmissionListener {
|
||||||
|
|
||||||
|
public static final String ID = "UnPublishedEdit";
|
||||||
|
|
||||||
|
private static final String ORGA_SEARCH = "organization";
|
||||||
|
|
||||||
|
private UnPublishedPropertiesStep step;
|
||||||
|
|
||||||
|
private AssetSearchWidget orgaSearch;
|
||||||
|
|
||||||
|
public UnPublishedPropertyForm(
|
||||||
|
final ItemSelectionModel itemModel,
|
||||||
|
final StringParameter selectedLangParam
|
||||||
|
) {
|
||||||
|
this(itemModel, null, selectedLangParam);
|
||||||
|
}
|
||||||
|
|
||||||
|
public UnPublishedPropertyForm(
|
||||||
|
final ItemSelectionModel itemModel,
|
||||||
|
final UnPublishedPropertiesStep step,
|
||||||
|
final StringParameter selectedLangParam
|
||||||
|
) {
|
||||||
|
super(itemModel, step, selectedLangParam);
|
||||||
|
this.step = step;
|
||||||
|
addSubmissionListener(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void addWidgets() {
|
||||||
|
|
||||||
|
super.addWidgets();
|
||||||
|
|
||||||
|
final ParameterModel placeParam = new StringParameter(
|
||||||
|
UnPublishedController.PLACE);
|
||||||
|
final TextField place = new TextField(placeParam);
|
||||||
|
place.setLabel(
|
||||||
|
new GlobalizedMessage(
|
||||||
|
"publications.ui.unpublished.place",
|
||||||
|
SciPublicationsConstants.BUNDLE
|
||||||
|
)
|
||||||
|
);
|
||||||
|
add(place);
|
||||||
|
|
||||||
|
ParameterModel numberParam = new StringParameter(
|
||||||
|
UnPublishedController.NUMBER
|
||||||
|
);
|
||||||
|
final TextField number = new TextField(numberParam);
|
||||||
|
number.setLabel(
|
||||||
|
new GlobalizedMessage(
|
||||||
|
"publications.ui.unpublished.number",
|
||||||
|
SciPublicationsConstants.BUNDLE
|
||||||
|
)
|
||||||
|
);
|
||||||
|
add(number);
|
||||||
|
|
||||||
|
final ParameterModel numberOfPagesParam = new IntegerParameter(
|
||||||
|
UnPublishedController.NUMBER_OF_PAGES
|
||||||
|
);
|
||||||
|
final TextField numberOfPages = new TextField(numberOfPagesParam);
|
||||||
|
numberOfPages.setLabel(
|
||||||
|
new GlobalizedMessage(
|
||||||
|
"publications.ui.unpublished.number_of_pages",
|
||||||
|
SciPublicationsConstants.BUNDLE
|
||||||
|
)
|
||||||
|
);
|
||||||
|
add(numberOfPages);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void init(final FormSectionEvent event) throws FormProcessException {
|
||||||
|
super.init(event);
|
||||||
|
|
||||||
|
final FormData data = event.getFormData();
|
||||||
|
final PublicationItem<?> publicationItem
|
||||||
|
= (PublicationItem) initBasicWidgets(event);
|
||||||
|
final UnPublished unPublished = (UnPublished) publicationItem
|
||||||
|
.getPublication();
|
||||||
|
|
||||||
|
data.put(
|
||||||
|
UnPublishedController.PLACE, unPublished.getPlace()
|
||||||
|
);
|
||||||
|
data.put(
|
||||||
|
UnPublishedController.NUMBER, unPublished.getNumber()
|
||||||
|
);
|
||||||
|
data.put(
|
||||||
|
UnPublishedController.NUMBER_OF_PAGES,
|
||||||
|
unPublished.getNumberOfPages()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void process(final FormSectionEvent event)
|
||||||
|
throws FormProcessException {
|
||||||
|
super.process(event);
|
||||||
|
|
||||||
|
final FormData formData = event.getFormData();
|
||||||
|
final PageState state = event.getPageState();
|
||||||
|
final PublicationItem<?> publicationItem
|
||||||
|
= (PublicationItem) initBasicWidgets(event);
|
||||||
|
|
||||||
|
if ((publicationItem != null)
|
||||||
|
&& getSaveCancelSection().getSaveButton().isSelected(state)) {
|
||||||
|
final UnPublished unpublished = (UnPublished) publicationItem
|
||||||
|
.getPublication();
|
||||||
|
|
||||||
|
final Map<String, Object> data = new HashMap<>();
|
||||||
|
data.put(
|
||||||
|
UnPublishedController.PLACE,
|
||||||
|
formData.get(UnPublishedController.PLACE)
|
||||||
|
);
|
||||||
|
data.put(
|
||||||
|
UnPublishedController.NUMBER,
|
||||||
|
formData.get(UnPublishedController.NUMBER)
|
||||||
|
);
|
||||||
|
data.put(
|
||||||
|
UnPublishedController.NUMBER_OF_PAGES,
|
||||||
|
formData.get(UnPublishedController.NUMBER_OF_PAGES)
|
||||||
|
);
|
||||||
|
|
||||||
|
final UnPublishedController controller = CdiUtil
|
||||||
|
.createCdiUtil()
|
||||||
|
.findBean(UnPublishedController.class);
|
||||||
|
controller.saveUnPublished(unpublished.getPublicationId(), data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue