Forms for Assets
parent
ea40c42185
commit
6e63d2d9e2
|
|
@ -5,9 +5,13 @@
|
|||
*/
|
||||
package org.scientificcms.publications.assets;
|
||||
|
||||
import org.scientificcms.publications.assets.ui.JournalForm;
|
||||
|
||||
import org.hibernate.envers.Audited;
|
||||
import org.librecms.assets.AssetType;
|
||||
import org.librecms.contentsection.Asset;
|
||||
import org.scientificcms.publications.Journal;
|
||||
import org.scientificcms.publications.SciPublicationsConstants;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
|
|
@ -27,6 +31,13 @@ import static org.scientificcms.publications.SciPublicationsConstants.*;
|
|||
@Entity
|
||||
@Table(name = "JOURNAL_ASSETS", schema = DB_SCHEMA)
|
||||
@Audited
|
||||
@AssetType(
|
||||
assetForm = JournalForm.class,
|
||||
labelBundle = SciPublicationsConstants.BUNDLE,
|
||||
labelKey = "journal.label",
|
||||
descriptionBundle = SciPublicationsConstants.BUNDLE,
|
||||
descriptionKey = "journal.description"
|
||||
)
|
||||
public class JournalAsset extends Asset {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
|
|
|||
|
|
@ -6,8 +6,11 @@
|
|||
package org.scientificcms.publications.assets;
|
||||
|
||||
import org.hibernate.envers.Audited;
|
||||
import org.librecms.assets.AssetType;
|
||||
import org.librecms.contentsection.Asset;
|
||||
import org.scientificcms.publications.Publisher;
|
||||
import org.scientificcms.publications.SciPublicationsConstants;
|
||||
import org.scientificcms.publications.assets.ui.PublisherForm;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
|
|
@ -28,6 +31,13 @@ import static org.scientificcms.publications.SciPublicationsConstants.*;
|
|||
@Entity
|
||||
@Table(name = "PUBLISHER_ASSETS", schema = DB_SCHEMA)
|
||||
@Audited
|
||||
@AssetType(
|
||||
assetForm = PublisherForm.class,
|
||||
labelBundle = SciPublicationsConstants.BUNDLE,
|
||||
labelKey = "publisher.label",
|
||||
descriptionBundle = SciPublicationsConstants.BUNDLE,
|
||||
descriptionKey = "publisher.description"
|
||||
)
|
||||
public class PublisherAsset extends Asset {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
|
|
|||
|
|
@ -6,8 +6,11 @@
|
|||
package org.scientificcms.publications.assets;
|
||||
|
||||
import org.hibernate.envers.Audited;
|
||||
import org.librecms.assets.AssetType;
|
||||
import org.librecms.contentsection.Asset;
|
||||
import org.scientificcms.publications.SciPublicationsConstants;
|
||||
import org.scientificcms.publications.Series;
|
||||
import org.scientificcms.publications.assets.ui.SeriesForm;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
|
|
@ -26,6 +29,13 @@ import static org.scientificcms.publications.SciPublicationsConstants.*;
|
|||
@Entity
|
||||
@Table(name = "SERIES_ASSETS", schema = DB_SCHEMA)
|
||||
@Audited
|
||||
@AssetType(
|
||||
assetForm = SeriesForm.class,
|
||||
labelBundle = SciPublicationsConstants.BUNDLE,
|
||||
labelKey = "journal.label",
|
||||
descriptionBundle = SciPublicationsConstants.BUNDLE,
|
||||
descriptionKey = "journal.description"
|
||||
)
|
||||
public class SeriesAsset extends Asset {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,208 @@
|
|||
/*
|
||||
* 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.assets.ui;
|
||||
|
||||
import com.arsdigita.bebop.FormProcessException;
|
||||
import com.arsdigita.bebop.PageState;
|
||||
import com.arsdigita.bebop.event.FormSectionEvent;
|
||||
import com.arsdigita.bebop.event.ParameterEvent;
|
||||
import com.arsdigita.bebop.event.ParameterListener;
|
||||
import com.arsdigita.bebop.form.TextArea;
|
||||
import com.arsdigita.bebop.form.TextField;
|
||||
import com.arsdigita.bebop.parameters.IntegerParameter;
|
||||
import com.arsdigita.bebop.parameters.ParameterData;
|
||||
import com.arsdigita.bebop.parameters.ParameterModel;
|
||||
import com.arsdigita.bebop.parameters.StringParameter;
|
||||
import com.arsdigita.cms.ui.assets.AbstractAssetForm;
|
||||
import com.arsdigita.cms.ui.assets.AssetPane;
|
||||
import com.arsdigita.globalization.GlobalizedMessage;
|
||||
|
||||
import org.scientificcms.publications.SciPublicationsConstants;
|
||||
import org.scientificcms.publications.assets.JournalAsset;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||
*/
|
||||
public class JournalForm extends AbstractAssetForm<JournalAsset> {
|
||||
|
||||
private TextField symbolField;
|
||||
|
||||
private TextField issnField;
|
||||
|
||||
private TextField firstYearField;
|
||||
|
||||
private TextField lastYearField;
|
||||
|
||||
private TextArea descriptionArea;
|
||||
|
||||
public JournalForm(final AssetPane assetPane) {
|
||||
super(assetPane);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addWidgets() {
|
||||
|
||||
super.addWidgets();
|
||||
|
||||
final ParameterModel symbolModel = new StringParameter(
|
||||
JournalFormController.SYMBOL
|
||||
);
|
||||
symbolField = new TextField(symbolModel);
|
||||
symbolField.setLabel(
|
||||
new GlobalizedMessage(
|
||||
"publications.ui.journal.symbol",
|
||||
SciPublicationsConstants.BUNDLE
|
||||
)
|
||||
);
|
||||
add(symbolField);
|
||||
|
||||
final ParameterModel issnParam = new StringParameter(
|
||||
JournalFormController.ISSN
|
||||
);
|
||||
issnField = new TextField(issnParam);
|
||||
issnField.addValidationListener(new ParameterListener() {
|
||||
|
||||
@Override
|
||||
public void validate(final ParameterEvent event) throws
|
||||
FormProcessException {
|
||||
final ParameterData data = event.getParameterData();
|
||||
String value = (String) data.getValue();
|
||||
|
||||
if (value.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
value = value.replace("-", "");
|
||||
|
||||
if (value.length() != 8) {
|
||||
data.invalidate();
|
||||
data.addError(
|
||||
new GlobalizedMessage(
|
||||
"publications.ui.invalid_issn",
|
||||
SciPublicationsConstants.BUNDLE
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
try {
|
||||
final Long num = Long.parseLong(value);
|
||||
} catch (NumberFormatException ex) {
|
||||
data.invalidate();
|
||||
data.addError(
|
||||
new GlobalizedMessage(
|
||||
"publications.ui.invalid_issn",
|
||||
SciPublicationsConstants.BUNDLE
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
issnField.setLabel(
|
||||
new GlobalizedMessage(
|
||||
"publications.ui.journal.issn", SciPublicationsConstants.BUNDLE
|
||||
)
|
||||
);
|
||||
add(issnField);
|
||||
|
||||
final ParameterModel firstYearParam = new IntegerParameter(
|
||||
JournalFormController.FIRST_YEAR
|
||||
);
|
||||
firstYearField = new TextField(firstYearParam);
|
||||
firstYearField.setLabel(
|
||||
new GlobalizedMessage(
|
||||
"publications.ui.journal.firstYearOfPublication",
|
||||
SciPublicationsConstants.BUNDLE
|
||||
)
|
||||
);
|
||||
add(firstYearField);
|
||||
|
||||
final ParameterModel lastYearParam = new IntegerParameter(
|
||||
JournalFormController.LAST_YEAR
|
||||
);
|
||||
lastYearField = new TextField(lastYearParam);
|
||||
lastYearField.setLabel(
|
||||
new GlobalizedMessage(
|
||||
"publications.ui.journal.lastYearOfPublication",
|
||||
SciPublicationsConstants.BUNDLE
|
||||
)
|
||||
);
|
||||
add(lastYearField);
|
||||
|
||||
final ParameterModel descriptionParam = new StringParameter(
|
||||
JournalFormController.DESCRIPTION
|
||||
);
|
||||
descriptionArea = new TextArea(descriptionParam);
|
||||
descriptionArea.setLabel(
|
||||
new GlobalizedMessage(
|
||||
"publications.ui.journal.abstract",
|
||||
SciPublicationsConstants.BUNDLE
|
||||
)
|
||||
);
|
||||
descriptionArea.setCols(60);
|
||||
descriptionArea.setRows(18);
|
||||
add(descriptionArea);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Class<JournalAsset> getAssetClass() {
|
||||
return JournalAsset.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void showLocale(final PageState state) {
|
||||
final Long selectedAssetId = getSelectedAssetId(state);
|
||||
|
||||
if (selectedAssetId != null) {
|
||||
final Map<String, Object> data = getController()
|
||||
.getAssetData(
|
||||
selectedAssetId, getAssetClass(), getSelectedLocale(state)
|
||||
);
|
||||
|
||||
descriptionArea
|
||||
.setValue(
|
||||
state,
|
||||
data.get(JournalFormController.DESCRIPTION)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Map<String, Object> collectData(
|
||||
final FormSectionEvent event) throws FormProcessException {
|
||||
|
||||
final PageState state = event.getPageState();
|
||||
|
||||
final Map<String, Object> data = new HashMap<>();
|
||||
|
||||
data.put(
|
||||
JournalFormController.DESCRIPTION, descriptionArea.getValue(state)
|
||||
);
|
||||
|
||||
data.put(
|
||||
JournalFormController.FIRST_YEAR, firstYearField.getValue(state)
|
||||
);
|
||||
|
||||
data.put(
|
||||
JournalFormController.ISSN, issnField.getValue(state)
|
||||
);
|
||||
|
||||
data.put(
|
||||
JournalFormController.LAST_YEAR, lastYearField.getValue(state)
|
||||
);
|
||||
|
||||
data.put(
|
||||
JournalFormController.SYMBOL, symbolField.getValue(state)
|
||||
);
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,88 @@
|
|||
/*
|
||||
* 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.assets.ui;
|
||||
|
||||
import com.arsdigita.cms.ui.assets.AbstractAssetFormController;
|
||||
import com.arsdigita.cms.ui.assets.IsControllerForAssetType;
|
||||
|
||||
import org.scientificcms.publications.Journal;
|
||||
import org.scientificcms.publications.assets.JournalAsset;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.enterprise.context.RequestScoped;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||
*/
|
||||
@RequestScoped
|
||||
@IsControllerForAssetType(JournalAsset.class)
|
||||
public class JournalFormController
|
||||
extends AbstractAssetFormController<JournalAsset> {
|
||||
|
||||
protected static final String SYMBOL = "symbol";
|
||||
|
||||
protected static final String ISSN = "issn";
|
||||
|
||||
protected static final String FIRST_YEAR = "firstYear";
|
||||
|
||||
protected static final String LAST_YEAR = "lastYear";
|
||||
|
||||
protected static final String DESCRIPTION = "description";
|
||||
|
||||
|
||||
@Override
|
||||
protected Map<String, Object> getAssetData(
|
||||
final JournalAsset asset, final Locale selectedLocale
|
||||
) {
|
||||
final Map<String, Object> data = new HashMap<>();
|
||||
|
||||
final Journal journal = asset.getJournal();
|
||||
|
||||
data.put(SYMBOL, journal.getSymbol());
|
||||
data.put(ISSN, journal.getIssn());
|
||||
data.put(FIRST_YEAR, journal.getFirstYear());
|
||||
data.put(LAST_YEAR, journal.getLastYear());
|
||||
data.put(DESCRIPTION, journal.getDescription().getValue(selectedLocale));
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateAssetProperties(
|
||||
final JournalAsset asset,
|
||||
final Locale selectedLocale,
|
||||
final Map<String, Object> data
|
||||
) {
|
||||
final Journal journal = asset.getJournal();
|
||||
|
||||
if (data.containsKey(SYMBOL)) {
|
||||
journal.setSymbol((String) data.get(SYMBOL));
|
||||
}
|
||||
|
||||
if (data.containsKey(ISSN)) {
|
||||
journal.setIssn((String) data.get(ISSN));
|
||||
}
|
||||
|
||||
if (data.containsKey(FIRST_YEAR)) {
|
||||
journal.setFirstYear((Integer) data.get(FIRST_YEAR));
|
||||
}
|
||||
|
||||
if (data.containsKey(LAST_YEAR)) {
|
||||
journal.setLastYear((Integer) data.get(LAST_YEAR));
|
||||
}
|
||||
|
||||
if (data.containsKey(DESCRIPTION)) {
|
||||
journal.getDescription().addValue(
|
||||
selectedLocale, (String) data.get(DESCRIPTION)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,99 @@
|
|||
/*
|
||||
* 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.assets.ui;
|
||||
|
||||
import com.arsdigita.bebop.FormProcessException;
|
||||
import com.arsdigita.bebop.PageState;
|
||||
import com.arsdigita.bebop.event.FormSectionEvent;
|
||||
import com.arsdigita.bebop.form.TextField;
|
||||
import com.arsdigita.bebop.parameters.NotEmptyValidationListener;
|
||||
import com.arsdigita.bebop.parameters.NotNullValidationListener;
|
||||
import com.arsdigita.bebop.parameters.ParameterModel;
|
||||
import com.arsdigita.bebop.parameters.StringParameter;
|
||||
import com.arsdigita.cms.ui.assets.AbstractAssetForm;
|
||||
import com.arsdigita.cms.ui.assets.AssetPane;
|
||||
import com.arsdigita.globalization.GlobalizedMessage;
|
||||
|
||||
import org.scientificcms.publications.SciPublicationsConstants;
|
||||
import org.scientificcms.publications.assets.PublisherAsset;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||
*/
|
||||
public class PublisherForm extends AbstractAssetForm<PublisherAsset> {
|
||||
|
||||
private TextField nameField;
|
||||
|
||||
private TextField placeField;
|
||||
|
||||
public PublisherForm(final AssetPane assetPane) {
|
||||
super(assetPane);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addWidgets() {
|
||||
final ParameterModel nameParam = new StringParameter(
|
||||
PublisherFormController.NAME
|
||||
);
|
||||
nameField = new TextField(nameParam);
|
||||
nameField.setLabel(
|
||||
new GlobalizedMessage(
|
||||
"publications.ui.publisher.name",
|
||||
SciPublicationsConstants.BUNDLE
|
||||
)
|
||||
);
|
||||
nameField.addValidationListener(new NotNullValidationListener());
|
||||
nameField.addValidationListener(new NotEmptyValidationListener());
|
||||
add(nameField);
|
||||
|
||||
final ParameterModel placeParam = new StringParameter(
|
||||
PublisherFormController.PLACE
|
||||
);
|
||||
placeField = new TextField(placeParam);
|
||||
placeField.setLabel(
|
||||
new GlobalizedMessage(
|
||||
"publications.ui.publisher.place",
|
||||
SciPublicationsConstants.BUNDLE
|
||||
)
|
||||
);
|
||||
add(placeField);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Class<PublisherAsset> getAssetClass() {
|
||||
return PublisherAsset.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void showLocale(final PageState state) {
|
||||
// Nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Map<String, Object> collectData(final FormSectionEvent event)
|
||||
throws FormProcessException {
|
||||
|
||||
final PageState state = event.getPageState();
|
||||
|
||||
final Map<String, Object> data = new HashMap<>();
|
||||
|
||||
data.put(
|
||||
PublisherFormController.NAME, nameField.getValue(state)
|
||||
);
|
||||
|
||||
data.put(
|
||||
PublisherFormController.PLACE, placeField.getValue(state)
|
||||
);
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -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 org.scientificcms.publications.assets.ui;
|
||||
|
||||
import com.arsdigita.cms.ui.assets.AbstractAssetFormController;
|
||||
import com.arsdigita.cms.ui.assets.IsControllerForAssetType;
|
||||
|
||||
import org.scientificcms.publications.Publisher;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.enterprise.context.RequestScoped;
|
||||
|
||||
import org.scientificcms.publications.assets.PublisherAsset;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||
*/
|
||||
@RequestScoped
|
||||
@IsControllerForAssetType(PublisherAsset.class)
|
||||
public class PublisherFormController
|
||||
extends AbstractAssetFormController<PublisherAsset> {
|
||||
|
||||
protected static final String NAME = "name";
|
||||
|
||||
protected static final String PLACE = "place";
|
||||
|
||||
@Override
|
||||
protected Map<String, Object> getAssetData(
|
||||
final PublisherAsset asset,
|
||||
final Locale selectedLocale
|
||||
) {
|
||||
final Map<String, Object> data = new HashMap<>();
|
||||
|
||||
final Publisher publisher = asset.getPublisher();
|
||||
|
||||
data.put(NAME, publisher.getName());
|
||||
data.put(PLACE, publisher.getPlace());
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void updateAssetProperties(
|
||||
final PublisherAsset asset,
|
||||
final Locale selectedLocale,
|
||||
final Map<String, Object> data
|
||||
) {
|
||||
final Publisher publisher = asset.getPublisher();
|
||||
|
||||
publisher.setName((String) data.get(NAME));
|
||||
publisher.setPlace((String) data.get(PLACE));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,115 @@
|
|||
/*
|
||||
* 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.assets.ui;
|
||||
|
||||
import com.arsdigita.bebop.FormProcessException;
|
||||
import com.arsdigita.bebop.PageState;
|
||||
import com.arsdigita.bebop.event.FormSectionEvent;
|
||||
import com.arsdigita.bebop.form.TextArea;
|
||||
import com.arsdigita.bebop.form.TextField;
|
||||
import com.arsdigita.bebop.parameters.ParameterModel;
|
||||
import com.arsdigita.bebop.parameters.StringParameter;
|
||||
import com.arsdigita.cms.ui.assets.AbstractAssetForm;
|
||||
import com.arsdigita.cms.ui.assets.AssetPane;
|
||||
import com.arsdigita.globalization.GlobalizedMessage;
|
||||
|
||||
import org.scientificcms.publications.SciPublicationsConstants;
|
||||
import org.scientificcms.publications.assets.SeriesAsset;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||
*/
|
||||
public class SeriesForm extends AbstractAssetForm<SeriesAsset> {
|
||||
|
||||
private TextField titleField;
|
||||
|
||||
private TextArea descriptionArea;
|
||||
|
||||
public SeriesForm(final AssetPane assetPane) {
|
||||
super(assetPane);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addWidgets() {
|
||||
super.addWidgets();
|
||||
|
||||
final ParameterModel titleParam = new StringParameter(
|
||||
SeriesFormController.TITLE
|
||||
);
|
||||
titleField = new TextField(titleParam);
|
||||
titleField.setLabel(
|
||||
new GlobalizedMessage(
|
||||
"publications.ui.series.title",
|
||||
SciPublicationsConstants.BUNDLE
|
||||
)
|
||||
);
|
||||
add(titleField);
|
||||
|
||||
final ParameterModel descriptionParam = new StringParameter(
|
||||
SeriesFormController.DESCRIPTION
|
||||
);
|
||||
descriptionArea = new TextArea(descriptionParam);
|
||||
descriptionArea.setLabel(
|
||||
new GlobalizedMessage(
|
||||
"publications.ui.series.abstract",
|
||||
SciPublicationsConstants.BUNDLE
|
||||
)
|
||||
);
|
||||
descriptionArea.setCols(60);
|
||||
descriptionArea.setRows(18);
|
||||
add(descriptionArea);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Class<SeriesAsset> getAssetClass() {
|
||||
return SeriesAsset.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void showLocale(final PageState state) {
|
||||
final Long selectedAssetId = getSelectedAssetId(state);
|
||||
|
||||
if (selectedAssetId != null) {
|
||||
final Map<String, Object> data = getController()
|
||||
.getAssetData(
|
||||
selectedAssetId, getAssetClass(), getSelectedLocale(state)
|
||||
);
|
||||
|
||||
titleField.setValue(
|
||||
state,
|
||||
data.get(SeriesFormController.TITLE)
|
||||
);
|
||||
|
||||
descriptionArea.setValue(
|
||||
state,
|
||||
data.get(SeriesFormController.DESCRIPTION)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Map<String, Object> collectData(FormSectionEvent event)
|
||||
throws FormProcessException {
|
||||
final PageState state = event.getPageState();
|
||||
|
||||
final Map<String, Object> data = new HashMap<>();
|
||||
|
||||
data.put(
|
||||
SeriesFormController.DESCRIPTION, descriptionArea.getValue(state)
|
||||
);
|
||||
|
||||
data.put(
|
||||
SeriesFormController.TITLE, titleField.getValue(state)
|
||||
);
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -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 org.scientificcms.publications.assets.ui;
|
||||
|
||||
import com.arsdigita.cms.ui.assets.AbstractAssetFormController;
|
||||
import com.arsdigita.cms.ui.assets.IsControllerForAssetType;
|
||||
|
||||
import org.scientificcms.publications.Series;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.enterprise.context.RequestScoped;
|
||||
|
||||
import org.scientificcms.publications.assets.SeriesAsset;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||
*/
|
||||
@RequestScoped
|
||||
@IsControllerForAssetType(SeriesAsset.class)
|
||||
public class SeriesFormController
|
||||
extends AbstractAssetFormController<SeriesAsset> {
|
||||
|
||||
protected static final String TITLE = "title";
|
||||
|
||||
protected static final String DESCRIPTION = "description";
|
||||
|
||||
@Override
|
||||
protected Map<String, Object> getAssetData(
|
||||
final SeriesAsset asset,
|
||||
final Locale selectedLocale
|
||||
) {
|
||||
final Series series = asset.getSeries();
|
||||
|
||||
final Map<String, Object> data = new HashMap<>();
|
||||
|
||||
data.put(TITLE, series.getTitle().getValue(selectedLocale));
|
||||
data.put(DESCRIPTION, series.getDescription().getValue(selectedLocale));
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateAssetProperties(
|
||||
final SeriesAsset asset,
|
||||
final Locale selectedLocale,
|
||||
final Map<String, Object> data
|
||||
) {
|
||||
final Series series = asset.getSeries();
|
||||
|
||||
series.getTitle().addValue(selectedLocale, (String) data.get(TITLE));
|
||||
series.getDescription().addValue(
|
||||
selectedLocale, (String) data.get(DESCRIPTION)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue