Forms for editing publications of type Expertise
parent
8cd3ff1683
commit
ea92d065ed
|
|
@ -0,0 +1,133 @@
|
||||||
|
/*
|
||||||
|
* To change this license header, choose License Headers in Project Properties.
|
||||||
|
* To change this template file, choose Tools | Templates
|
||||||
|
* and open the template in the editor.
|
||||||
|
*/
|
||||||
|
package com.arsdigita.cms.contenttypes.ui;
|
||||||
|
|
||||||
|
import org.librecms.assets.Organization;
|
||||||
|
import org.librecms.contentsection.AssetRepository;
|
||||||
|
import org.scientificcms.publications.Expertise;
|
||||||
|
import org.scientificcms.publications.PublicationRepository;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import javax.enterprise.context.RequestScoped;
|
||||||
|
import javax.inject.Inject;
|
||||||
|
import javax.transaction.Transactional;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||||
|
*/
|
||||||
|
@RequestScoped
|
||||||
|
public class ExpertiseController {
|
||||||
|
|
||||||
|
public static final String PLACE = "place";
|
||||||
|
public static final String NUMBER_OF_PAGES = "numberOfPages";
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private AssetRepository assetRepository;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private PublicationRepository publicationRepository;
|
||||||
|
|
||||||
|
@Transactional(Transactional.TxType.REQUIRED)
|
||||||
|
public void save(final long expertiseId, final Map<String, Object> data) {
|
||||||
|
final Expertise expertise = publicationRepository
|
||||||
|
.findByIdAndType(expertiseId, Expertise.class)
|
||||||
|
.orElseThrow(
|
||||||
|
() -> new IllegalArgumentException(
|
||||||
|
String.format("No Expertise with ID %d found.", expertiseId)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (data.containsKey(PLACE)) {
|
||||||
|
expertise.setPlace((String) data.get(PLACE));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data.containsKey(NUMBER_OF_PAGES)) {
|
||||||
|
expertise.setNumberOfPages((Integer) data.get(NUMBER_OF_PAGES));
|
||||||
|
}
|
||||||
|
|
||||||
|
publicationRepository.save(expertise);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
public void setOrderer(final long expertiseId, final long ordererId) {
|
||||||
|
final Expertise expertise = publicationRepository
|
||||||
|
.findByIdAndType(expertiseId, Expertise.class)
|
||||||
|
.orElseThrow(
|
||||||
|
() -> new IllegalArgumentException(
|
||||||
|
String.format("No Expertise with ID %d found.", expertiseId)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
final Organization orderer = assetRepository
|
||||||
|
.findById(ordererId, Organization.class)
|
||||||
|
.orElseThrow(
|
||||||
|
() -> new IllegalArgumentException(
|
||||||
|
String.format(
|
||||||
|
"No Organization with ID %d found.", ordererId
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
expertise.setOrderer(orderer);
|
||||||
|
publicationRepository.save(expertise);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
public void unsetOrderer(final long expertiseId) {
|
||||||
|
final Expertise expertise = publicationRepository
|
||||||
|
.findByIdAndType(expertiseId, Expertise.class)
|
||||||
|
.orElseThrow(
|
||||||
|
() -> new IllegalArgumentException(
|
||||||
|
String.format("No Expertise with ID %d found.", expertiseId)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
expertise.setOrderer(null);
|
||||||
|
publicationRepository.save(expertise);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
public void setOrganization(
|
||||||
|
final long expertiseId, final long organizationId
|
||||||
|
) {
|
||||||
|
final Expertise expertise = publicationRepository
|
||||||
|
.findByIdAndType(expertiseId, Expertise.class)
|
||||||
|
.orElseThrow(
|
||||||
|
() -> new IllegalArgumentException(
|
||||||
|
String.format("No Expertise with ID %d found.", expertiseId)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
final Organization organization = assetRepository
|
||||||
|
.findById(organizationId, Organization.class)
|
||||||
|
.orElseThrow(
|
||||||
|
() -> new IllegalArgumentException(
|
||||||
|
String.format(
|
||||||
|
"No Organization with ID %d found.", organizationId
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
expertise.setOrganization(organization);
|
||||||
|
publicationRepository.save(expertise);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
public void unsetOrganization(final long expertiseId) {
|
||||||
|
final Expertise expertise = publicationRepository
|
||||||
|
.findByIdAndType(expertiseId, Expertise.class)
|
||||||
|
.orElseThrow(
|
||||||
|
() -> new IllegalArgumentException(
|
||||||
|
String.format("No Expertise with ID %d found.", expertiseId)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
expertise.setOrganization(null);
|
||||||
|
publicationRepository.save(expertise);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,91 @@
|
||||||
|
/*
|
||||||
|
* To change this license header, choose License Headers in Project Properties.
|
||||||
|
* To change this template file, choose Tools | Templates
|
||||||
|
* and open the template in the editor.
|
||||||
|
*/
|
||||||
|
package com.arsdigita.cms.contenttypes.ui;
|
||||||
|
|
||||||
|
import com.arsdigita.bebop.FormData;
|
||||||
|
import com.arsdigita.bebop.FormProcessException;
|
||||||
|
import com.arsdigita.bebop.PageState;
|
||||||
|
import com.arsdigita.bebop.event.FormInitListener;
|
||||||
|
import com.arsdigita.bebop.event.FormProcessListener;
|
||||||
|
import com.arsdigita.bebop.event.FormSectionEvent;
|
||||||
|
import com.arsdigita.bebop.parameters.StringParameter;
|
||||||
|
import com.arsdigita.cms.ItemSelectionModel;
|
||||||
|
import com.arsdigita.cms.ui.assets.AssetSearchWidget;
|
||||||
|
import com.arsdigita.cms.ui.authoring.BasicItemForm;
|
||||||
|
import com.arsdigita.globalization.GlobalizedMessage;
|
||||||
|
|
||||||
|
import org.hibernate.resource.beans.container.internal.CdiBasedBeanContainer;
|
||||||
|
import org.libreccm.cdi.utils.CdiUtil;
|
||||||
|
import org.librecms.assets.Organization;
|
||||||
|
import org.scientificcms.publications.SciPublicationsConstants;
|
||||||
|
import org.scientificcms.publications.contenttypes.ExpertiseItem;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||||
|
*/
|
||||||
|
public class ExpertiseOrdererForm
|
||||||
|
extends BasicItemForm
|
||||||
|
implements FormProcessListener, FormInitListener {
|
||||||
|
|
||||||
|
private static final String ORGA_SEARCH = "expertiseOrderer";
|
||||||
|
|
||||||
|
private AssetSearchWidget orgaSearch;
|
||||||
|
|
||||||
|
private final ItemSelectionModel itemModel;
|
||||||
|
|
||||||
|
public ExpertiseOrdererForm(
|
||||||
|
final ItemSelectionModel itemModel,
|
||||||
|
final StringParameter selectedLangParam
|
||||||
|
) {
|
||||||
|
super("ExpertiseOrdererForm", itemModel, selectedLangParam);
|
||||||
|
this.itemModel = itemModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void addWidgets() {
|
||||||
|
orgaSearch = new AssetSearchWidget(
|
||||||
|
ORGA_SEARCH, Organization.class
|
||||||
|
);
|
||||||
|
orgaSearch.setLabel(
|
||||||
|
new GlobalizedMessage(
|
||||||
|
"publications.ui.expertise.orderer",
|
||||||
|
SciPublicationsConstants.BUNDLE
|
||||||
|
)
|
||||||
|
);
|
||||||
|
add(orgaSearch);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void init(final FormSectionEvent event) throws FormProcessException {
|
||||||
|
final PageState state = event.getPageState();
|
||||||
|
|
||||||
|
setVisible(state, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void process(final FormSectionEvent event)
|
||||||
|
throws FormProcessException {
|
||||||
|
final PageState state = event.getPageState();
|
||||||
|
final ExpertiseItem expertise = (ExpertiseItem) itemModel.
|
||||||
|
getSelectedItem(state);
|
||||||
|
|
||||||
|
if (getSaveCancelSection().getSaveButton().isSelected(state)) {
|
||||||
|
final Organization orderer = (Organization) orgaSearch
|
||||||
|
.getValue(state);
|
||||||
|
final ExpertiseController controller = CdiUtil
|
||||||
|
.createCdiUtil()
|
||||||
|
.findBean(ExpertiseController.class);
|
||||||
|
controller.setOrderer(
|
||||||
|
expertise.getPublication().getPublicationId(),
|
||||||
|
orderer.getObjectId()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
init(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -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.globalization.GlobalizedMessage;
|
||||||
|
import com.arsdigita.util.LockableImpl;
|
||||||
|
|
||||||
|
import org.libreccm.cdi.utils.CdiUtil;
|
||||||
|
import org.libreccm.security.PermissionChecker;
|
||||||
|
import org.librecms.assets.Organization;
|
||||||
|
import org.librecms.contentsection.privileges.ItemPrivileges;
|
||||||
|
import org.scientificcms.publications.Expertise;
|
||||||
|
import org.scientificcms.publications.SciPublicationsConstants;
|
||||||
|
import org.scientificcms.publications.contenttypes.ExpertiseItem;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||||
|
*/
|
||||||
|
public class ExpertiseOrdererSheet
|
||||||
|
extends Table
|
||||||
|
implements TableActionListener {
|
||||||
|
|
||||||
|
private static final String TABLE_COL_EDIT = "table_col_edit";
|
||||||
|
|
||||||
|
private static final String TABLE_COL_DEL = "table_col_del";
|
||||||
|
|
||||||
|
private final ItemSelectionModel itemModel;
|
||||||
|
|
||||||
|
public ExpertiseOrdererSheet(final ItemSelectionModel itemModel) {
|
||||||
|
super();
|
||||||
|
|
||||||
|
this.itemModel = itemModel;
|
||||||
|
|
||||||
|
setEmptyView(
|
||||||
|
new Label(
|
||||||
|
new GlobalizedMessage(
|
||||||
|
"publications.ui.expertise.orderer.none",
|
||||||
|
SciPublicationsConstants.BUNDLE
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
final TableColumnModel columnModel = getColumnModel();
|
||||||
|
columnModel.add(
|
||||||
|
new TableColumn(
|
||||||
|
0,
|
||||||
|
new Label(
|
||||||
|
new GlobalizedMessage(
|
||||||
|
"publications.ui.expertise.orderer",
|
||||||
|
SciPublicationsConstants.BUNDLE
|
||||||
|
)
|
||||||
|
),
|
||||||
|
TABLE_COL_EDIT
|
||||||
|
)
|
||||||
|
);
|
||||||
|
columnModel.add(
|
||||||
|
new TableColumn(
|
||||||
|
1,
|
||||||
|
new Label(
|
||||||
|
new GlobalizedMessage(
|
||||||
|
"publications.ui.expertise.orderer.remove",
|
||||||
|
SciPublicationsConstants.BUNDLE
|
||||||
|
)
|
||||||
|
),
|
||||||
|
TABLE_COL_DEL
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
setModelBuilder(new ExpertiseOrganizationSheetModelBuilder(itemModel));
|
||||||
|
columnModel.get(0).setCellRenderer(new EditCellRenderer());
|
||||||
|
columnModel.get(1).setCellRenderer(new DeleteCellRenderer());
|
||||||
|
|
||||||
|
addTableActionListener(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void cellSelected(final TableActionEvent event) {
|
||||||
|
final PageState state = event.getPageState();
|
||||||
|
|
||||||
|
final ExpertiseItem expertiseItem = (ExpertiseItem) itemModel
|
||||||
|
.getSelectedItem(state);
|
||||||
|
|
||||||
|
final TableColumn column = getColumnModel().get(event.getColumn());
|
||||||
|
|
||||||
|
if (column.getHeaderKey().toString().equals(TABLE_COL_EDIT)) {
|
||||||
|
// Nothing
|
||||||
|
} else if (column.getHeaderKey().toString().equals(TABLE_COL_DEL)) {
|
||||||
|
final ExpertiseController controller = CdiUtil
|
||||||
|
.createCdiUtil()
|
||||||
|
.findBean(ExpertiseController.class);
|
||||||
|
controller.unsetOrderer(
|
||||||
|
expertiseItem.getPublication().getPublicationId()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void headSelected(final TableActionEvent event) {
|
||||||
|
//Nothing to do
|
||||||
|
}
|
||||||
|
|
||||||
|
private class ExpertiseOrganizationSheetModelBuilder
|
||||||
|
extends LockableImpl
|
||||||
|
implements TableModelBuilder {
|
||||||
|
|
||||||
|
private final ItemSelectionModel itemModel;
|
||||||
|
|
||||||
|
public ExpertiseOrganizationSheetModelBuilder(
|
||||||
|
final ItemSelectionModel itemModel
|
||||||
|
) {
|
||||||
|
this.itemModel = itemModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public final TableModel makeModel(
|
||||||
|
final Table table, final PageState state
|
||||||
|
) {
|
||||||
|
table.getRowSelectionModel().clearSelection(state);
|
||||||
|
final ExpertiseItem expertiseItem = (ExpertiseItem) itemModel
|
||||||
|
.getSelectedItem(state);
|
||||||
|
return new ExpertiseOrganizationSheetModel(
|
||||||
|
table, state, expertiseItem.getPublication()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private class ExpertiseOrganizationSheetModel implements TableModel {
|
||||||
|
|
||||||
|
private final Table table;
|
||||||
|
private final Organization orderer;
|
||||||
|
private boolean done;
|
||||||
|
|
||||||
|
public ExpertiseOrganizationSheetModel(
|
||||||
|
final Table table,
|
||||||
|
final PageState state,
|
||||||
|
final Expertise expertise
|
||||||
|
) {
|
||||||
|
this.table = table;
|
||||||
|
orderer = expertise.getOrderer();
|
||||||
|
done = orderer != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getColumnCount() {
|
||||||
|
return table.getColumnModel().size();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean nextRow() {
|
||||||
|
boolean ret;
|
||||||
|
|
||||||
|
if (done) {
|
||||||
|
ret = true;
|
||||||
|
done = false;
|
||||||
|
} else {
|
||||||
|
ret = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object getElementAt(final int columnIndex) {
|
||||||
|
switch (columnIndex) {
|
||||||
|
case 0:
|
||||||
|
return orderer.getTitle();
|
||||||
|
case 1:
|
||||||
|
return new Label(
|
||||||
|
new GlobalizedMessage(
|
||||||
|
"publications.ui.expertise.orderer.remove",
|
||||||
|
SciPublicationsConstants.BUNDLE
|
||||||
|
)
|
||||||
|
);
|
||||||
|
default:
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object getKeyAt(final int columnIndex) {
|
||||||
|
return orderer.getObjectId();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private class EditCellRenderer
|
||||||
|
extends LockableImpl
|
||||||
|
implements TableCellRenderer {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public final Component getComponent(
|
||||||
|
final Table table,
|
||||||
|
final PageState state,
|
||||||
|
final Object value,
|
||||||
|
final boolean isSelected,
|
||||||
|
final Object key,
|
||||||
|
final int row,
|
||||||
|
final int column
|
||||||
|
) {
|
||||||
|
return new Text((String) value);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private class DeleteCellRenderer
|
||||||
|
extends LockableImpl
|
||||||
|
implements TableCellRenderer {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Component getComponent(
|
||||||
|
final Table table,
|
||||||
|
final PageState state,
|
||||||
|
final Object value,
|
||||||
|
final boolean isSelected,
|
||||||
|
final Object key,
|
||||||
|
final int row,
|
||||||
|
final int col
|
||||||
|
) {
|
||||||
|
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
|
||||||
|
|
||||||
|
final PermissionChecker permissionChecker = cdiUtil
|
||||||
|
.findBean(PermissionChecker.class);
|
||||||
|
|
||||||
|
final ExpertiseItem expertiseItem = (ExpertiseItem) itemModel
|
||||||
|
.getSelectedItem(state);
|
||||||
|
|
||||||
|
final boolean canEdit = permissionChecker.isPermitted(
|
||||||
|
ItemPrivileges.DELETE, expertiseItem
|
||||||
|
);
|
||||||
|
|
||||||
|
if (canEdit) {
|
||||||
|
final ControlLink link = new ControlLink((Component) value);
|
||||||
|
link.setConfirmation(
|
||||||
|
new GlobalizedMessage(
|
||||||
|
"publication.ui.expertise.orderer.remove.confirm",
|
||||||
|
SciPublicationsConstants.BUNDLE
|
||||||
|
)
|
||||||
|
);
|
||||||
|
return link;
|
||||||
|
} else {
|
||||||
|
return new Text("");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,63 @@
|
||||||
|
/*
|
||||||
|
* 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 ExpertiseOrdererStep extends SimpleEditStep {
|
||||||
|
|
||||||
|
private static final String SET_EXPERTISE_ORDERER_STEP
|
||||||
|
= "setExpertiseOrdererStep";
|
||||||
|
|
||||||
|
public ExpertiseOrdererStep(
|
||||||
|
final ItemSelectionModel itemModel,
|
||||||
|
final AuthoringKitWizard parent,
|
||||||
|
final StringParameter selectedLangParam
|
||||||
|
) {
|
||||||
|
this(itemModel, parent, selectedLangParam, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ExpertiseOrdererStep(
|
||||||
|
final ItemSelectionModel itemModel,
|
||||||
|
final AuthoringKitWizard parent,
|
||||||
|
final StringParameter selectedLangParam,
|
||||||
|
final String prefix
|
||||||
|
) {
|
||||||
|
super(itemModel, parent, selectedLangParam, prefix);
|
||||||
|
|
||||||
|
final BasicItemForm setOrdererForm = new ExpertiseOrdererForm(
|
||||||
|
itemModel,
|
||||||
|
selectedLangParam
|
||||||
|
);
|
||||||
|
add(
|
||||||
|
SET_EXPERTISE_ORDERER_STEP,
|
||||||
|
new GlobalizedMessage(
|
||||||
|
"publications.ui.expertise.setOrderer",
|
||||||
|
SciPublicationsConstants.BUNDLE
|
||||||
|
),
|
||||||
|
new WorkflowLockedComponentAccess(setOrdererForm, itemModel),
|
||||||
|
setOrdererForm.getSaveCancelSection().getCancelButton()
|
||||||
|
);
|
||||||
|
|
||||||
|
final ExpertiseOrdererSheet sheet = new ExpertiseOrdererSheet(
|
||||||
|
itemModel
|
||||||
|
);
|
||||||
|
setDisplayComponent(sheet);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,89 @@
|
||||||
|
/*
|
||||||
|
* To change this license header, choose License Headers in Project Properties.
|
||||||
|
* To change this template file, choose Tools | Templates
|
||||||
|
* and open the template in the editor.
|
||||||
|
*/
|
||||||
|
package com.arsdigita.cms.contenttypes.ui;
|
||||||
|
|
||||||
|
import com.arsdigita.bebop.FormProcessException;
|
||||||
|
import com.arsdigita.bebop.PageState;
|
||||||
|
import com.arsdigita.bebop.event.FormInitListener;
|
||||||
|
import com.arsdigita.bebop.event.FormProcessListener;
|
||||||
|
import com.arsdigita.bebop.event.FormSectionEvent;
|
||||||
|
import com.arsdigita.bebop.parameters.StringParameter;
|
||||||
|
import com.arsdigita.cms.ItemSelectionModel;
|
||||||
|
import com.arsdigita.cms.ui.assets.AssetSearchWidget;
|
||||||
|
import com.arsdigita.cms.ui.authoring.BasicItemForm;
|
||||||
|
import com.arsdigita.globalization.GlobalizedMessage;
|
||||||
|
|
||||||
|
import org.libreccm.cdi.utils.CdiUtil;
|
||||||
|
import org.librecms.assets.Organization;
|
||||||
|
import org.scientificcms.publications.SciPublicationsConstants;
|
||||||
|
import org.scientificcms.publications.contenttypes.ExpertiseItem;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||||
|
*/
|
||||||
|
public class ExpertiseOrganizationForm
|
||||||
|
extends BasicItemForm
|
||||||
|
implements FormProcessListener, FormInitListener {
|
||||||
|
|
||||||
|
private static final String ORGA_SEARCH = "expertiseOrganization";
|
||||||
|
|
||||||
|
private AssetSearchWidget orgaSearch;
|
||||||
|
|
||||||
|
private final ItemSelectionModel itemModel;
|
||||||
|
|
||||||
|
public ExpertiseOrganizationForm(
|
||||||
|
final ItemSelectionModel itemModel,
|
||||||
|
final StringParameter selectedLangParam
|
||||||
|
) {
|
||||||
|
super("ExpertiseOrganizationForm", itemModel, selectedLangParam);
|
||||||
|
this.itemModel = itemModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void addWidgets() {
|
||||||
|
orgaSearch = new AssetSearchWidget(
|
||||||
|
ORGA_SEARCH, Organization.class
|
||||||
|
);
|
||||||
|
orgaSearch.setLabel(
|
||||||
|
new GlobalizedMessage(
|
||||||
|
"publications.ui.expertise.orderer",
|
||||||
|
SciPublicationsConstants.BUNDLE
|
||||||
|
)
|
||||||
|
);
|
||||||
|
add(orgaSearch);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void init(final FormSectionEvent event) throws FormProcessException {
|
||||||
|
final PageState state = event.getPageState();
|
||||||
|
|
||||||
|
setVisible(state, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void process(final FormSectionEvent event)
|
||||||
|
throws FormProcessException {
|
||||||
|
final PageState state = event.getPageState();
|
||||||
|
final ExpertiseItem expertise = (ExpertiseItem) itemModel.
|
||||||
|
getSelectedItem(state);
|
||||||
|
|
||||||
|
if (getSaveCancelSection().getSaveButton().isSelected(state)) {
|
||||||
|
final Organization organization = (Organization) orgaSearch
|
||||||
|
.getValue(state);
|
||||||
|
final ExpertiseController controller = CdiUtil
|
||||||
|
.createCdiUtil()
|
||||||
|
.findBean(ExpertiseController.class);
|
||||||
|
controller.setOrganization(
|
||||||
|
expertise.getPublication().getPublicationId(),
|
||||||
|
organization.getObjectId()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
init(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -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.globalization.GlobalizedMessage;
|
||||||
|
import com.arsdigita.util.LockableImpl;
|
||||||
|
|
||||||
|
import org.libreccm.cdi.utils.CdiUtil;
|
||||||
|
import org.libreccm.security.PermissionChecker;
|
||||||
|
import org.librecms.assets.Organization;
|
||||||
|
import org.librecms.contentsection.privileges.ItemPrivileges;
|
||||||
|
import org.scientificcms.publications.Expertise;
|
||||||
|
import org.scientificcms.publications.SciPublicationsConstants;
|
||||||
|
import org.scientificcms.publications.contenttypes.ExpertiseItem;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||||
|
*/
|
||||||
|
public class ExpertiseOrganizationSheet extends Table
|
||||||
|
implements TableActionListener {
|
||||||
|
|
||||||
|
private static final String TABLE_COL_EDIT = "table_col_edit";
|
||||||
|
|
||||||
|
private static final String TABLE_COL_DEL = "table_col_del";
|
||||||
|
|
||||||
|
private final ItemSelectionModel itemModel;
|
||||||
|
|
||||||
|
public ExpertiseOrganizationSheet(final ItemSelectionModel itemModel) {
|
||||||
|
super();
|
||||||
|
|
||||||
|
this.itemModel = itemModel;
|
||||||
|
|
||||||
|
setEmptyView(
|
||||||
|
new Label(
|
||||||
|
new GlobalizedMessage(
|
||||||
|
"publications.ui.expertise.organization.none",
|
||||||
|
SciPublicationsConstants.BUNDLE
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
final TableColumnModel columnModel = getColumnModel();
|
||||||
|
columnModel.add(
|
||||||
|
new TableColumn(
|
||||||
|
0,
|
||||||
|
new Label(
|
||||||
|
new GlobalizedMessage(
|
||||||
|
"publications.ui.expertise.organization",
|
||||||
|
SciPublicationsConstants.BUNDLE
|
||||||
|
)
|
||||||
|
),
|
||||||
|
TABLE_COL_EDIT
|
||||||
|
)
|
||||||
|
);
|
||||||
|
columnModel.add(
|
||||||
|
new TableColumn(
|
||||||
|
1,
|
||||||
|
new Label(
|
||||||
|
new GlobalizedMessage(
|
||||||
|
"publications.ui.expertise.organization.remove",
|
||||||
|
SciPublicationsConstants.BUNDLE
|
||||||
|
)
|
||||||
|
),
|
||||||
|
TABLE_COL_DEL
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
setModelBuilder(new ExpertiseOrganizationSheetModelBuilder(itemModel));
|
||||||
|
columnModel.get(0).setCellRenderer(new EditCellRenderer());
|
||||||
|
columnModel.get(1).setCellRenderer(new DeleteCellRenderer());
|
||||||
|
|
||||||
|
addTableActionListener(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void cellSelected(final TableActionEvent event) {
|
||||||
|
final PageState state = event.getPageState();
|
||||||
|
|
||||||
|
final ExpertiseItem expertiseItem = (ExpertiseItem) itemModel
|
||||||
|
.getSelectedItem(state);
|
||||||
|
|
||||||
|
final TableColumn column = getColumnModel().get(event.getColumn());
|
||||||
|
|
||||||
|
if (column.getHeaderKey().toString().equals(TABLE_COL_EDIT)) {
|
||||||
|
// Nothing
|
||||||
|
} else if (column.getHeaderKey().toString().equals(TABLE_COL_DEL)) {
|
||||||
|
final ExpertiseController controller = CdiUtil
|
||||||
|
.createCdiUtil()
|
||||||
|
.findBean(ExpertiseController.class);
|
||||||
|
controller.unsetOrganization(
|
||||||
|
expertiseItem.getPublication().getPublicationId()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void headSelected(final TableActionEvent event) {
|
||||||
|
//Nothing to do
|
||||||
|
}
|
||||||
|
|
||||||
|
private class ExpertiseOrganizationSheetModelBuilder
|
||||||
|
extends LockableImpl
|
||||||
|
implements TableModelBuilder {
|
||||||
|
|
||||||
|
private final ItemSelectionModel itemModel;
|
||||||
|
|
||||||
|
public ExpertiseOrganizationSheetModelBuilder(
|
||||||
|
final ItemSelectionModel itemModel
|
||||||
|
) {
|
||||||
|
this.itemModel = itemModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public final TableModel makeModel(
|
||||||
|
final Table table, final PageState state
|
||||||
|
) {
|
||||||
|
table.getRowSelectionModel().clearSelection(state);
|
||||||
|
final ExpertiseItem expertiseItem = (ExpertiseItem) itemModel
|
||||||
|
.getSelectedItem(state);
|
||||||
|
return new ExpertiseOrganizationSheetModel(
|
||||||
|
table, state, expertiseItem.getPublication()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private class ExpertiseOrganizationSheetModel implements TableModel {
|
||||||
|
|
||||||
|
private final Table table;
|
||||||
|
private final Organization organization;
|
||||||
|
private boolean done;
|
||||||
|
|
||||||
|
public ExpertiseOrganizationSheetModel(
|
||||||
|
final Table table,
|
||||||
|
final PageState state,
|
||||||
|
final Expertise expertise
|
||||||
|
) {
|
||||||
|
this.table = table;
|
||||||
|
organization = expertise.getOrganization();
|
||||||
|
done = organization != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getColumnCount() {
|
||||||
|
return table.getColumnModel().size();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean nextRow() {
|
||||||
|
boolean ret;
|
||||||
|
|
||||||
|
if (done) {
|
||||||
|
ret = true;
|
||||||
|
done = false;
|
||||||
|
} else {
|
||||||
|
ret = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object getElementAt(final int columnIndex) {
|
||||||
|
switch (columnIndex) {
|
||||||
|
case 0:
|
||||||
|
return organization.getTitle();
|
||||||
|
case 1:
|
||||||
|
return new Label(
|
||||||
|
new GlobalizedMessage(
|
||||||
|
"publications.ui.expertise.organization.remove",
|
||||||
|
SciPublicationsConstants.BUNDLE
|
||||||
|
)
|
||||||
|
);
|
||||||
|
default:
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object getKeyAt(final int columnIndex) {
|
||||||
|
return organization.getObjectId();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private class EditCellRenderer
|
||||||
|
extends LockableImpl
|
||||||
|
implements TableCellRenderer {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public final Component getComponent(
|
||||||
|
final Table table,
|
||||||
|
final PageState state,
|
||||||
|
final Object value,
|
||||||
|
final boolean isSelected,
|
||||||
|
final Object key,
|
||||||
|
final int row,
|
||||||
|
final int column
|
||||||
|
) {
|
||||||
|
return new Text((String) value);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private class DeleteCellRenderer
|
||||||
|
extends LockableImpl
|
||||||
|
implements TableCellRenderer {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Component getComponent(
|
||||||
|
final Table table,
|
||||||
|
final PageState state,
|
||||||
|
final Object value,
|
||||||
|
final boolean isSelected,
|
||||||
|
final Object key,
|
||||||
|
final int row,
|
||||||
|
final int col
|
||||||
|
) {
|
||||||
|
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
|
||||||
|
|
||||||
|
final PermissionChecker permissionChecker = cdiUtil
|
||||||
|
.findBean(PermissionChecker.class);
|
||||||
|
|
||||||
|
final ExpertiseItem expertiseItem = (ExpertiseItem) itemModel
|
||||||
|
.getSelectedItem(state);
|
||||||
|
|
||||||
|
final boolean canEdit = permissionChecker.isPermitted(
|
||||||
|
ItemPrivileges.DELETE, expertiseItem
|
||||||
|
);
|
||||||
|
|
||||||
|
if (canEdit) {
|
||||||
|
final ControlLink link = new ControlLink((Component) value);
|
||||||
|
link.setConfirmation(
|
||||||
|
new GlobalizedMessage(
|
||||||
|
"publication.ui.expertise.organization.remove.confirm",
|
||||||
|
SciPublicationsConstants.BUNDLE
|
||||||
|
)
|
||||||
|
);
|
||||||
|
return link;
|
||||||
|
} else {
|
||||||
|
return new Text("");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,63 @@
|
||||||
|
/*
|
||||||
|
* 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 ExpertiseOrganizationStep extends SimpleEditStep {
|
||||||
|
|
||||||
|
private static final String SET_EXPERTISE_ORGANIZATION_STEP
|
||||||
|
= "setExpertiseOrganizationStep";
|
||||||
|
|
||||||
|
public ExpertiseOrganizationStep(
|
||||||
|
final ItemSelectionModel itemModel,
|
||||||
|
final AuthoringKitWizard parent,
|
||||||
|
final StringParameter selectedLangParam
|
||||||
|
) {
|
||||||
|
this(itemModel, parent, selectedLangParam, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ExpertiseOrganizationStep(
|
||||||
|
final ItemSelectionModel itemModel,
|
||||||
|
final AuthoringKitWizard parent,
|
||||||
|
final StringParameter selectedLangParam,
|
||||||
|
final String prefix
|
||||||
|
) {
|
||||||
|
super(itemModel, parent, selectedLangParam, prefix);
|
||||||
|
|
||||||
|
final BasicItemForm setOrgaForm = new ExpertiseOrganizationForm(
|
||||||
|
itemModel, selectedLangParam
|
||||||
|
);
|
||||||
|
add(
|
||||||
|
SET_EXPERTISE_ORGANIZATION_STEP,
|
||||||
|
new GlobalizedMessage(
|
||||||
|
"publications.ui.expertise.setOrganization",
|
||||||
|
SciPublicationsConstants.BUNDLE
|
||||||
|
),
|
||||||
|
new WorkflowLockedComponentAccess(
|
||||||
|
setOrgaForm, itemModel),
|
||||||
|
setOrgaForm.getSaveCancelSection().getCancelButton()
|
||||||
|
);
|
||||||
|
|
||||||
|
final ExpertiseOrganizationSheet sheet = new ExpertiseOrganizationSheet(
|
||||||
|
itemModel
|
||||||
|
);
|
||||||
|
setDisplayComponent(sheet);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,131 @@
|
||||||
|
/*
|
||||||
|
* 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 ExpertisePropertiesStep extends PublicationPropertiesStep {
|
||||||
|
|
||||||
|
private final StringParameter selectedLangParam;
|
||||||
|
|
||||||
|
public ExpertisePropertiesStep(
|
||||||
|
final ItemSelectionModel itemModel,
|
||||||
|
final AuthoringKitWizard parent,
|
||||||
|
final StringParameter selectedLangParam
|
||||||
|
) {
|
||||||
|
super(itemModel, parent, selectedLangParam);
|
||||||
|
this.selectedLangParam = selectedLangParam;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Component getExpertisePropertySheet(
|
||||||
|
final ItemSelectionModel itemModel,
|
||||||
|
final StringParameter selectedLangParam
|
||||||
|
) {
|
||||||
|
final DomainObjectPropertySheet sheet
|
||||||
|
= (DomainObjectPropertySheet) getPublicationPropertySheet(
|
||||||
|
itemModel, selectedLangParam);
|
||||||
|
|
||||||
|
sheet.add(
|
||||||
|
new GlobalizedMessage(
|
||||||
|
"publications.ui.expertise.place",
|
||||||
|
SciPublicationsConstants.BUNDLE
|
||||||
|
),
|
||||||
|
ExpertiseController.PLACE
|
||||||
|
);
|
||||||
|
|
||||||
|
sheet.add(
|
||||||
|
new GlobalizedMessage(
|
||||||
|
"publications.ui.expertise.number_of_pages",
|
||||||
|
SciPublicationsConstants.BUNDLE
|
||||||
|
),
|
||||||
|
ExpertiseController.NUMBER_OF_PAGES
|
||||||
|
);
|
||||||
|
|
||||||
|
return sheet;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void addBasicProperties(
|
||||||
|
final ItemSelectionModel itemModel,
|
||||||
|
final AuthoringKitWizard parent
|
||||||
|
) {
|
||||||
|
final SimpleEditStep basicProperties = new SimpleEditStep(
|
||||||
|
itemModel,
|
||||||
|
parent,
|
||||||
|
selectedLangParam,
|
||||||
|
EDIT_SHEET_NAME
|
||||||
|
);
|
||||||
|
|
||||||
|
final BasicPageForm editBasicSheet
|
||||||
|
= new ExpertisePropertyForm(
|
||||||
|
itemModel, this, selectedLangParam
|
||||||
|
);
|
||||||
|
|
||||||
|
basicProperties.add(
|
||||||
|
EDIT_SHEET_NAME,
|
||||||
|
new GlobalizedMessage(
|
||||||
|
"publications.ui.expertise.edit_basic_sheet",
|
||||||
|
SciPublicationsConstants.BUNDLE
|
||||||
|
),
|
||||||
|
new WorkflowLockedComponentAccess(
|
||||||
|
editBasicSheet,
|
||||||
|
itemModel
|
||||||
|
),
|
||||||
|
editBasicSheet.getSaveCancelSection().getCancelButton()
|
||||||
|
);
|
||||||
|
|
||||||
|
basicProperties.setDisplayComponent(
|
||||||
|
getExpertisePropertySheet(itemModel, selectedLangParam)
|
||||||
|
);
|
||||||
|
|
||||||
|
getSegmentedPanel().addSegment(
|
||||||
|
new Label(
|
||||||
|
new GlobalizedMessage(
|
||||||
|
"publications.ui.publication.basic_properties"
|
||||||
|
)
|
||||||
|
),
|
||||||
|
basicProperties
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void addSteps(
|
||||||
|
final ItemSelectionModel itemModel, final AuthoringKitWizard parent
|
||||||
|
) {
|
||||||
|
super.addSteps(itemModel, parent);
|
||||||
|
|
||||||
|
addStep(
|
||||||
|
new ExpertiseOrganizationStep(itemModel, parent, selectedLangParam),
|
||||||
|
new GlobalizedMessage(
|
||||||
|
"publications.ui.expertise.setOrganization",
|
||||||
|
SciPublicationsConstants.BUNDLE
|
||||||
|
)
|
||||||
|
);
|
||||||
|
addStep(
|
||||||
|
new ExpertiseOrdererStep(itemModel, parent, selectedLangParam),
|
||||||
|
new GlobalizedMessage(
|
||||||
|
"publications.ui.expertise.setOrderer",
|
||||||
|
SciPublicationsConstants.BUNDLE
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -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 com.arsdigita.bebop.FormData;
|
||||||
|
import com.arsdigita.bebop.FormProcessException;
|
||||||
|
import com.arsdigita.bebop.PageState;
|
||||||
|
import com.arsdigita.bebop.event.FormInitListener;
|
||||||
|
import com.arsdigita.bebop.event.FormProcessListener;
|
||||||
|
import com.arsdigita.bebop.event.FormSectionEvent;
|
||||||
|
import com.arsdigita.bebop.event.FormSubmissionListener;
|
||||||
|
import com.arsdigita.bebop.form.TextField;
|
||||||
|
import com.arsdigita.bebop.parameters.IntegerParameter;
|
||||||
|
import com.arsdigita.bebop.parameters.ParameterModel;
|
||||||
|
import com.arsdigita.bebop.parameters.StringParameter;
|
||||||
|
import com.arsdigita.cms.ItemSelectionModel;
|
||||||
|
import com.arsdigita.globalization.GlobalizedMessage;
|
||||||
|
|
||||||
|
import org.libreccm.cdi.utils.CdiUtil;
|
||||||
|
import org.scientificcms.publications.Expertise;
|
||||||
|
import org.scientificcms.publications.SciPublicationsConstants;
|
||||||
|
import org.scientificcms.publications.contenttypes.ExpertiseItem;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||||
|
*/
|
||||||
|
public class ExpertisePropertyForm
|
||||||
|
extends PublicationPropertyForm
|
||||||
|
implements FormInitListener, FormProcessListener, FormSubmissionListener {
|
||||||
|
|
||||||
|
public static final String ID = "ExpertiseEdit";
|
||||||
|
|
||||||
|
private final ExpertisePropertiesStep step;
|
||||||
|
|
||||||
|
public ExpertisePropertyForm(
|
||||||
|
final ItemSelectionModel itemModel,
|
||||||
|
final StringParameter selectedLangParam
|
||||||
|
) {
|
||||||
|
this(itemModel, null, selectedLangParam);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ExpertisePropertyForm(
|
||||||
|
final ItemSelectionModel itemModel,
|
||||||
|
final ExpertisePropertiesStep step,
|
||||||
|
final StringParameter selectedLangParam
|
||||||
|
) {
|
||||||
|
super(itemModel, step, selectedLangParam);
|
||||||
|
this.step = step;
|
||||||
|
addSubmissionListener(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void addWidgets() {
|
||||||
|
|
||||||
|
super.addWidgets();
|
||||||
|
|
||||||
|
final ParameterModel placeParam = new StringParameter(
|
||||||
|
ExpertiseController.PLACE
|
||||||
|
);
|
||||||
|
final TextField place = new TextField(placeParam);
|
||||||
|
place.setLabel(
|
||||||
|
new GlobalizedMessage(
|
||||||
|
"publications.ui.expertise.place",
|
||||||
|
SciPublicationsConstants.BUNDLE
|
||||||
|
)
|
||||||
|
);
|
||||||
|
add(place);
|
||||||
|
|
||||||
|
final ParameterModel numberOfPagesParam = new IntegerParameter(
|
||||||
|
ExpertiseController.NUMBER_OF_PAGES
|
||||||
|
);
|
||||||
|
final TextField numberOfPages = new TextField(numberOfPagesParam);
|
||||||
|
numberOfPages.setLabel(
|
||||||
|
new GlobalizedMessage(
|
||||||
|
"publications.ui.expertise.number_of_pages",
|
||||||
|
SciPublicationsConstants.BUNDLE
|
||||||
|
)
|
||||||
|
);
|
||||||
|
add(numberOfPages);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void init(final FormSectionEvent event) throws FormProcessException {
|
||||||
|
super.init(event);
|
||||||
|
|
||||||
|
final FormData data = event.getFormData();
|
||||||
|
final ExpertiseItem expertiseItem = (ExpertiseItem) initBasicWidgets(
|
||||||
|
event);
|
||||||
|
|
||||||
|
final Expertise expertise = expertiseItem.getPublication();
|
||||||
|
|
||||||
|
data.put(ExpertiseController.PLACE, expertise.getPlace());
|
||||||
|
data.put(
|
||||||
|
ExpertiseController.NUMBER_OF_PAGES,
|
||||||
|
expertise.getNumberOfPages()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void process(final FormSectionEvent event)
|
||||||
|
throws FormProcessException {
|
||||||
|
super.process(event);
|
||||||
|
|
||||||
|
final FormData formData = event.getFormData();
|
||||||
|
final PageState state = event.getPageState();
|
||||||
|
final ExpertiseItem expertiseItem = (ExpertiseItem) processBasicWidgets(
|
||||||
|
event
|
||||||
|
);
|
||||||
|
|
||||||
|
if ((expertiseItem != null)
|
||||||
|
&& getSaveCancelSection().getSaveButton().isSelected(state)) {
|
||||||
|
|
||||||
|
final Map<String, Object> data = new HashMap<>();
|
||||||
|
data.put(
|
||||||
|
ExpertiseController.PLACE,
|
||||||
|
formData.get(ExpertiseController.PLACE)
|
||||||
|
);
|
||||||
|
data.put(
|
||||||
|
ExpertiseController.NUMBER_OF_PAGES,
|
||||||
|
formData.get(ExpertiseController.NUMBER_OF_PAGES)
|
||||||
|
);
|
||||||
|
|
||||||
|
final ExpertiseController controller = CdiUtil
|
||||||
|
.createCdiUtil()
|
||||||
|
.findBean(ExpertiseController.class);
|
||||||
|
|
||||||
|
controller.save(
|
||||||
|
expertiseItem.getPublication().getPublicationId(),
|
||||||
|
data
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue