First part of MVC based UI for SciProject
parent
e284631d4d
commit
8dad903963
|
|
@ -0,0 +1,188 @@
|
||||||
|
* Copyright (C) 2022 LibreCCM Foundation.
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation; either
|
||||||
|
* version 2.1 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This library is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with this library; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||||
|
* MA 02110-1301 USA
|
||||||
|
*/
|
||||||
|
package org.scientificcms.contenttypes.sciproject.ui;
|
||||||
|
|
||||||
|
import org.libreccm.l10n.GlobalizationHelper;
|
||||||
|
import org.libreccm.l10n.LocalizedString;
|
||||||
|
import org.libreccm.security.AuthorizationRequired;
|
||||||
|
import org.libreccm.workflow.Workflow;
|
||||||
|
import org.librecms.contentsection.ContentItemManager;
|
||||||
|
import org.librecms.contentsection.ContentItemRepository;
|
||||||
|
import org.librecms.ui.contentsections.documents.AbstractMvcDocumentCreateStep;
|
||||||
|
|
||||||
|
import org.scientificcms.contenttypes.sciproject.SciProject;
|
||||||
|
|
||||||
|
import javax.enterprise.context.RequestScoped;
|
||||||
|
import javax.inject.Inject;
|
||||||
|
import javax.inject.Named;
|
||||||
|
import javax.transaction.Transactional;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create step for a {@link SciProject}
|
||||||
|
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||||
|
*/
|
||||||
|
@RequestScoped
|
||||||
|
@Named("SciProjectCreateStep")
|
||||||
|
public class ProjectCreateStep
|
||||||
|
extends AbstractMvcDocumentCreateStep<SciProject> {
|
||||||
|
|
||||||
|
private static final String FORM_PARAM_NAME = "name";
|
||||||
|
|
||||||
|
private static final String FORM_PARAM_TITLE = "title";
|
||||||
|
|
||||||
|
private static final String FORM_PARAM_STARTDATE = "startDate";
|
||||||
|
|
||||||
|
private static final String FORM_PARAM_ENDDATE = "startDate";
|
||||||
|
|
||||||
|
private static final String FORM_PARAM_SUMMARY = "summary";
|
||||||
|
|
||||||
|
private static final String FORM_PARAM_INITIAL_LOCALE = "locale";
|
||||||
|
|
||||||
|
private static final String FORM_PARAM_SELECTED_WORKFLOW = "workflow";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides functions for working with content items.
|
||||||
|
*/
|
||||||
|
@Inject
|
||||||
|
private ContentItemManager itemManager;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used to save the event.
|
||||||
|
*/
|
||||||
|
@Inject
|
||||||
|
private ContentItemRepository itemRepo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides functions for working with {@link LocalizedString}s.
|
||||||
|
*/
|
||||||
|
@Inject
|
||||||
|
private GlobalizationHelper globalizationHelper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Name of the project.
|
||||||
|
*/
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Title of the project.
|
||||||
|
*/
|
||||||
|
private String title;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The start date of the project.
|
||||||
|
*/
|
||||||
|
private String startDate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The end date of the project
|
||||||
|
*/
|
||||||
|
private String endDate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The short description of the project.
|
||||||
|
*/
|
||||||
|
private String shortDescription;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The initial locale of the project.
|
||||||
|
*/
|
||||||
|
private String initialLocale;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The workflow to use for the new project.
|
||||||
|
*/
|
||||||
|
private String selectedWorkflow;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getDocumentType() {
|
||||||
|
return SciProject.class.getName();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getDescription() {
|
||||||
|
return globalizationHelper
|
||||||
|
.getLocalizedTextsUtil(getBundle())
|
||||||
|
.getText("createstep.description");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getBundle() {
|
||||||
|
return SciProjectStepsConstants.BUNDLE;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTitle() {
|
||||||
|
return getTitle();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getStartDate() {
|
||||||
|
return startDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getEndDate() {
|
||||||
|
return endDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getShortDescription() {
|
||||||
|
return shortDescription;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getInitialLocale() {
|
||||||
|
return initialLocale;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Transactional(Transactional.TxType.REQUIRED)
|
||||||
|
public String getSelectedWorkflow() {
|
||||||
|
if (selectedWorkflow == null || selectedWorkflow.isEmpty()) {
|
||||||
|
return getContentSection()
|
||||||
|
.getContentTypes()
|
||||||
|
.stream()
|
||||||
|
.filter(
|
||||||
|
type -> type.getContentItemClass().equals(
|
||||||
|
Event.class.getName()
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.findAny()
|
||||||
|
.map(type -> type.getDefaultWorkflow())
|
||||||
|
.map(
|
||||||
|
workflow -> globalizationHelper.getValueFromLocalizedString(
|
||||||
|
workflow.getName()
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.orElse("");
|
||||||
|
} else {
|
||||||
|
return selectedWorkflow;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String showCreateStep() {
|
||||||
|
return "org/scientificcms/contenttypes/sciproject/ui/create-sciproject.xhtml";
|
||||||
|
}
|
||||||
|
|
||||||
|
@AuthorizationRequired
|
||||||
|
@Transactional(Transactional.TxType.REQUIRED)
|
||||||
|
@Override
|
||||||
|
public String createItem(final Map<String, String[]> formParams) {
|
||||||
|
// ToDo
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -0,0 +1,34 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2022 LibreCCM Foundation.
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation; either
|
||||||
|
* version 2.1 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This library is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with this library; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||||
|
* MA 02110-1301 USA
|
||||||
|
*/
|
||||||
|
package org.scientificcms.contenttypes.sciproject.ui;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constants for the authoring steps for editing an {@link Event}.
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||||
|
*/
|
||||||
|
public final class SciProjectStepsConstants {
|
||||||
|
|
||||||
|
private SciProjectStepsConstants() {
|
||||||
|
// Nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final String BUNDLE
|
||||||
|
= "org.scientificcms.contentypes.sciproject.ui.SciProjectBundle";
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue