CCM NG: Admin UI for Pages Part I
git-svn-id: https://svn.libreccm.org/ccm/ccm_ng@5138 8810af33-2d31-482b-a856-94f89814c4dfccm-docs
parent
24d3b49a98
commit
c04a0d4adb
|
|
@ -42,7 +42,6 @@ import org.libreccm.cdi.utils.CdiUtil;
|
|||
import org.libreccm.security.PermissionChecker;
|
||||
import org.libreccm.security.Shiro;
|
||||
import org.libreccm.web.CcmApplication;
|
||||
import org.librecms.CmsConstants;
|
||||
import org.librecms.contentsection.ContentSection;
|
||||
import org.librecms.contentsection.ContentSectionRepository;
|
||||
import org.librecms.contentsection.privileges.ItemPrivileges;
|
||||
|
|
|
|||
|
|
@ -31,9 +31,12 @@ import com.arsdigita.cms.ui.WorkspaceContextBar;
|
|||
import com.arsdigita.globalization.GlobalizedMessage;
|
||||
import com.arsdigita.ui.CcmObjectSelectionModel;
|
||||
|
||||
import org.libreccm.cdi.utils.CdiUtil;
|
||||
import org.libreccm.security.PermissionChecker;
|
||||
import org.librecms.CmsConstants;
|
||||
import org.librecms.contentsection.ContentSection;
|
||||
import org.librecms.contentsection.ContentType;
|
||||
import org.librecms.pages.PagesPrivileges;
|
||||
|
||||
// ////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
|
|
@ -59,17 +62,18 @@ public class MainPage extends CMSApplicationPage implements ActionListener {
|
|||
|
||||
private final static String XSL_CLASS = "CMS Admin";
|
||||
|
||||
private TabbedPane m_tabbedPane;
|
||||
|
||||
private TasksPanel m_tasks;
|
||||
// private ItemSearch m_search;
|
||||
// private IdSearchTab m_IdSearch;
|
||||
private CcmObjectSelectionModel<ContentType> m_typeSel;
|
||||
private CcmObjectSelectionModel<ContentSection> m_sectionSel;
|
||||
|
||||
public static final String CONTENT_TYPE = "type_id";
|
||||
public static final String CONTENT_SECTION = "section_id";
|
||||
|
||||
private final CcmObjectSelectionModel<ContentType> typeSelection;
|
||||
private final CcmObjectSelectionModel<ContentSection> sectionSelection;
|
||||
|
||||
private final TabbedPane tabbedPane;
|
||||
|
||||
private TasksPane tasksPanel;
|
||||
// private ItemSearch m_search;
|
||||
// private IdSearchTab m_IdSearch;
|
||||
|
||||
/**
|
||||
* Construct a new MainPage.
|
||||
*
|
||||
|
|
@ -84,29 +88,28 @@ public class MainPage extends CMSApplicationPage implements ActionListener {
|
|||
|
||||
|
||||
/* Set the class attribute value (down in SimpleComponent). */
|
||||
setClassAttr("cms-admin");
|
||||
super.setClassAttr("cms-admin");
|
||||
|
||||
LongParameter typeId = new LongParameter(CONTENT_TYPE);
|
||||
addGlobalStateParam(typeId);
|
||||
m_typeSel = new CcmObjectSelectionModel(ContentType.class, typeId);
|
||||
final LongParameter typeId = new LongParameter(CONTENT_TYPE);
|
||||
super.addGlobalStateParam(typeId);
|
||||
typeSelection = new CcmObjectSelectionModel<>(ContentType.class, typeId);
|
||||
|
||||
LongParameter sectionId = new LongParameter(CONTENT_SECTION);
|
||||
addGlobalStateParam(sectionId);
|
||||
m_sectionSel = new CcmObjectSelectionModel(
|
||||
ContentSection.class,
|
||||
sectionId
|
||||
final LongParameter sectionId = new LongParameter(CONTENT_SECTION);
|
||||
super.addGlobalStateParam(sectionId);
|
||||
sectionSelection = new CcmObjectSelectionModel<>(ContentSection.class,
|
||||
sectionId
|
||||
);
|
||||
|
||||
add(new WorkspaceContextBar());
|
||||
add(new GlobalNavigation());
|
||||
super.add(new WorkspaceContextBar());
|
||||
super.add(new GlobalNavigation());
|
||||
|
||||
m_tasks = getTasksPane(m_typeSel, m_sectionSel);
|
||||
tasksPanel = getTasksPane(typeSelection, sectionSelection);
|
||||
// m_search = getSearchPane();
|
||||
// m_IdSearch = getIdSearchPane();
|
||||
|
||||
m_tabbedPane = createTabbedPane();
|
||||
m_tabbedPane.setIdAttr("page-body");
|
||||
add(m_tabbedPane);
|
||||
tabbedPane = createTabbedPane();
|
||||
tabbedPane.setIdAttr("page-body");
|
||||
super.add(tabbedPane);
|
||||
|
||||
// add(new DebugPanel());
|
||||
}
|
||||
|
|
@ -114,14 +117,20 @@ public class MainPage extends CMSApplicationPage implements ActionListener {
|
|||
/**
|
||||
* Creates, and then caches, the Tasks pane. Overriding this method to
|
||||
* return null will prevent this tab from appearing.
|
||||
*
|
||||
* @param typeModel
|
||||
* @param sectionModel
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
protected TasksPanel getTasksPane(
|
||||
CcmObjectSelectionModel<ContentType> typeModel,
|
||||
CcmObjectSelectionModel<ContentSection> sectionModel) {
|
||||
if (m_tasks == null) {
|
||||
m_tasks = new TasksPanel(typeModel, sectionModel);
|
||||
protected TasksPane getTasksPane(
|
||||
final CcmObjectSelectionModel<ContentType> typeModel,
|
||||
final CcmObjectSelectionModel<ContentSection> sectionModel) {
|
||||
|
||||
if (tasksPanel == null) {
|
||||
tasksPanel = new TasksPane(typeModel, sectionModel);
|
||||
}
|
||||
return m_tasks;
|
||||
return tasksPanel;
|
||||
}
|
||||
|
||||
// /**
|
||||
|
|
@ -154,20 +163,35 @@ public class MainPage extends CMSApplicationPage implements ActionListener {
|
|||
* Developers can override this method to add only the tabs they want, or to
|
||||
* add additional tabs after the default CMS tabs are added.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
protected TabbedPane createTabbedPane() {
|
||||
TabbedPane tabbedPane = new TabbedPane();
|
||||
tabbedPane.setClassAttr(XSL_CLASS);
|
||||
|
||||
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
|
||||
final PermissionChecker permissionChecker = cdiUtil
|
||||
.findBean(PermissionChecker.class);
|
||||
|
||||
final TabbedPane pane = new TabbedPane();
|
||||
pane.setClassAttr(XSL_CLASS);
|
||||
Label taskLabel = new Label(new GlobalizedMessage(
|
||||
"cms.ui.contentcenter.mainpage.taskssections",
|
||||
CmsConstants.CMS_BUNDLE));
|
||||
Label pagesLabel = new Label(new GlobalizedMessage(
|
||||
"cms.ui.contentcenter.mainpage.pages",
|
||||
CmsConstants.CMS_BUNDLE));
|
||||
Label searchLabel = new Label(new GlobalizedMessage(
|
||||
"cms.ui.contentcenter.mainpage.search", CmsConstants.CMS_BUNDLE));
|
||||
Label IdsearchLabel = new Label("ID Search");
|
||||
|
||||
addToPane(tabbedPane,
|
||||
addToPane(pane,
|
||||
taskLabel,
|
||||
getTasksPane(m_typeSel, m_sectionSel));
|
||||
getTasksPane(typeSelection, sectionSelection));
|
||||
|
||||
// if (permissionChecker.isPermitted(PagesPrivileges.ADMINISTER_PAGES)) {
|
||||
addToPane(pane,
|
||||
pagesLabel,
|
||||
new PagesPane());
|
||||
// }
|
||||
// addToPane(tabbedPane,
|
||||
// new Label(new GlobalizedMessage(
|
||||
// "cms.ui.contentcenter.mainpage.search",
|
||||
|
|
@ -177,8 +201,8 @@ public class MainPage extends CMSApplicationPage implements ActionListener {
|
|||
// IdsearchLabel,
|
||||
// getIdSearchPane());
|
||||
|
||||
tabbedPane.addActionListener(this);
|
||||
return tabbedPane;
|
||||
pane.addActionListener(this);
|
||||
return pane;
|
||||
}
|
||||
|
||||
// /**
|
||||
|
|
@ -200,13 +224,15 @@ public class MainPage extends CMSApplicationPage implements ActionListener {
|
|||
* Adds the specified component, with the specified Label as tab name, to
|
||||
* the tabbed pane only if it is not null.
|
||||
*
|
||||
* @param pane The pane to which to add the tab
|
||||
* @param tabName The name of the tab if it's added
|
||||
* @param comp The component to add to the pane
|
||||
* @param pane The pane to which to add the tab
|
||||
* @param tabName The name of the tab if it's added
|
||||
* @param component The component to add to the pane
|
||||
*/
|
||||
protected void addToPane(TabbedPane pane, Label tabName, Component comp) {
|
||||
if (comp != null) {
|
||||
pane.addTab(tabName, comp);
|
||||
protected void addToPane(final TabbedPane pane,
|
||||
final Label tabName,
|
||||
final Component component) {
|
||||
if (component != null) {
|
||||
pane.addTab(tabName, component);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -216,12 +242,14 @@ public class MainPage extends CMSApplicationPage implements ActionListener {
|
|||
*
|
||||
* @param event The event fired by selecting a tab
|
||||
*/
|
||||
public void actionPerformed(ActionEvent event) {
|
||||
PageState state = event.getPageState();
|
||||
Component pane = m_tabbedPane.getCurrentPane(state);
|
||||
@Override
|
||||
public void actionPerformed(final ActionEvent event) {
|
||||
|
||||
if (pane == m_tasks) {
|
||||
m_tasks.reset(state);
|
||||
final PageState state = event.getPageState();
|
||||
final Component pane = tabbedPane.getCurrentPane(state);
|
||||
|
||||
if (pane == tasksPanel) {
|
||||
tasksPanel.reset(state);
|
||||
}
|
||||
// else if (pane == m_search) {
|
||||
// m_search.reset(state);
|
||||
|
|
|
|||
|
|
@ -0,0 +1,266 @@
|
|||
/*
|
||||
* Copyright (C) 2017 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 com.arsdigita.cms.ui.contentcenter;
|
||||
|
||||
import com.arsdigita.bebop.Form;
|
||||
import com.arsdigita.bebop.FormData;
|
||||
import com.arsdigita.bebop.FormProcessException;
|
||||
import com.arsdigita.bebop.PageState;
|
||||
import com.arsdigita.bebop.ParameterSingleSelectionModel;
|
||||
import com.arsdigita.bebop.SaveCancelSection;
|
||||
import com.arsdigita.bebop.Text;
|
||||
import com.arsdigita.bebop.event.FormSectionEvent;
|
||||
import com.arsdigita.bebop.event.PrintEvent;
|
||||
import com.arsdigita.bebop.form.Option;
|
||||
import com.arsdigita.bebop.form.SingleSelect;
|
||||
|
||||
import com.arsdigita.bebop.form.TextField;
|
||||
import com.arsdigita.globalization.GlobalizedMessage;
|
||||
|
||||
import org.libreccm.categorization.Domain;
|
||||
import org.libreccm.categorization.DomainRepository;
|
||||
import org.libreccm.cdi.utils.CdiUtil;
|
||||
import org.libreccm.core.UnexpectedErrorException;
|
||||
import org.libreccm.sites.Site;
|
||||
import org.libreccm.sites.SiteRepository;
|
||||
import org.librecms.CmsConstants;
|
||||
import org.librecms.pages.Pages;
|
||||
import org.librecms.pages.PagesRepository;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.TooManyListenersException;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||
*/
|
||||
class PagesForm extends Form {
|
||||
|
||||
private final static String PRIMARY_URL_FIELD = "primaryUrl";
|
||||
private final static String SITE_SELECT = "site";
|
||||
private final static String CATEGORY_DOMAIN_SELECT = "categoryDomain";
|
||||
|
||||
private final PagesPane pagesPane;
|
||||
private final ParameterSingleSelectionModel<String> selectedPages;
|
||||
|
||||
private final TextField primaryUrlField;
|
||||
private final SingleSelect siteSelect;
|
||||
private final SingleSelect categoryDomainSelect;
|
||||
private final SaveCancelSection saveCancelSection;
|
||||
|
||||
PagesForm(final PagesPane pagesPane,
|
||||
final ParameterSingleSelectionModel<String> selectedPages) {
|
||||
|
||||
super("pagesForm");
|
||||
|
||||
this.pagesPane = pagesPane;
|
||||
this.selectedPages = selectedPages;
|
||||
|
||||
primaryUrlField = new TextField(PRIMARY_URL_FIELD);
|
||||
primaryUrlField.setLabel(new GlobalizedMessage(
|
||||
"cms.ui.pages.form.primary_url_field.label",
|
||||
CmsConstants.CMS_BUNDLE));
|
||||
super.add(primaryUrlField);
|
||||
|
||||
siteSelect = new SingleSelect(SITE_SELECT);
|
||||
try {
|
||||
siteSelect.addPrintListener(this::populateSiteSelect);
|
||||
} catch (TooManyListenersException ex) {
|
||||
throw new UnexpectedErrorException(ex);
|
||||
}
|
||||
siteSelect.setLabel(new GlobalizedMessage(
|
||||
"cms.ui.pages.form.site_select.label",
|
||||
CmsConstants.CMS_BUNDLE));
|
||||
super.add(siteSelect);
|
||||
|
||||
categoryDomainSelect = new SingleSelect(CATEGORY_DOMAIN_SELECT);
|
||||
try {
|
||||
categoryDomainSelect
|
||||
.addPrintListener(this::populateCategoryDomainSelect);
|
||||
} catch (TooManyListenersException ex) {
|
||||
throw new UnexpectedErrorException(ex);
|
||||
}
|
||||
categoryDomainSelect.setLabel(new GlobalizedMessage(
|
||||
"cms.ui.pages.form.category_domain_select.label",
|
||||
CmsConstants.CMS_BUNDLE));
|
||||
super.add(categoryDomainSelect);
|
||||
|
||||
saveCancelSection = new SaveCancelSection();
|
||||
super.add(saveCancelSection);
|
||||
|
||||
super.addInitListener(this::init);
|
||||
super.addValidationListener(this::validate);
|
||||
super.addProcessListener(this::process);
|
||||
}
|
||||
|
||||
private void populateSiteSelect(final PrintEvent event) {
|
||||
|
||||
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
|
||||
final SiteRepository siteRepository = cdiUtil
|
||||
.findBean(SiteRepository.class);
|
||||
|
||||
final List<Site> sites = siteRepository.findAll();
|
||||
|
||||
final SingleSelect target = (SingleSelect) event.getTarget();
|
||||
target.clearOptions();
|
||||
|
||||
for (final Site site : sites) {
|
||||
final Text label;
|
||||
if (site.isDefaultSite()) {
|
||||
label = new Text(String.format("%s *", site.getDomainOfSite()));
|
||||
} else {
|
||||
label = new Text(site.getDomainOfSite());
|
||||
}
|
||||
|
||||
target.addOption(new Option(Long.toString(site.getObjectId()),
|
||||
label));
|
||||
}
|
||||
|
||||
if (selectedPages.getSelectedKey(event.getPageState()) != null) {
|
||||
target.setDisabled();
|
||||
}
|
||||
}
|
||||
|
||||
private void populateCategoryDomainSelect(final PrintEvent event) {
|
||||
|
||||
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
|
||||
final DomainRepository domainRepo = cdiUtil
|
||||
.findBean(DomainRepository.class);
|
||||
|
||||
final List<Domain> categoryDomains = domainRepo.findAll();
|
||||
|
||||
final SingleSelect target = (SingleSelect) event.getTarget();
|
||||
target.clearOptions();
|
||||
|
||||
for (final Domain domain : categoryDomains) {
|
||||
|
||||
target.addOption(new Option(Long.toString(domain.getObjectId()),
|
||||
new Text(domain.getDomainKey())));
|
||||
}
|
||||
|
||||
if (selectedPages.getSelectedKey(event.getPageState()) != null) {
|
||||
target.setDisabled();
|
||||
}
|
||||
}
|
||||
|
||||
private void init(final FormSectionEvent event)
|
||||
throws FormProcessException {
|
||||
|
||||
final PageState state = event.getPageState();
|
||||
|
||||
if (selectedPages.getSelectedKey(state) != null) {
|
||||
|
||||
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
|
||||
final PagesRepository pagesRepo = cdiUtil
|
||||
.findBean(PagesRepository.class);
|
||||
|
||||
final Pages pages = pagesRepo
|
||||
.findById(Long.parseLong(selectedPages.getSelectedKey(state)))
|
||||
.orElseThrow(() -> new UnexpectedErrorException(String
|
||||
.format("No Pages with ID %s in the database.",
|
||||
selectedPages.getSelectedKey(state))));
|
||||
|
||||
primaryUrlField.setValue(state, pages.getPrimaryUrl());
|
||||
|
||||
siteSelect.setValue(state,
|
||||
Long.toString(pages.getSite().getObjectId()));
|
||||
|
||||
categoryDomainSelect
|
||||
.setValue(state,
|
||||
Long.toString(pages.getCategoryDomain().getObjectId()));
|
||||
}
|
||||
}
|
||||
|
||||
private void validate(final FormSectionEvent event)
|
||||
throws FormProcessException {
|
||||
|
||||
final PageState state = event.getPageState();
|
||||
|
||||
if (saveCancelSection.getSaveButton().isSelected(state)) {
|
||||
|
||||
final FormData data = event.getFormData();
|
||||
|
||||
final String primaryUrl = data.getString(PRIMARY_URL_FIELD);
|
||||
if (primaryUrl == null
|
||||
|| primaryUrl.isEmpty()
|
||||
|| primaryUrl.matches("\\s*")) {
|
||||
|
||||
data.addError(PRIMARY_URL_FIELD,
|
||||
new GlobalizedMessage(
|
||||
"cms.ui.pages.form.primary_url_field.error",
|
||||
CmsConstants.CMS_BUNDLE));
|
||||
}
|
||||
|
||||
final String selectedSite = data.getString(SITE_SELECT);
|
||||
if (selectedSite == null
|
||||
|| selectedSite.isEmpty()) {
|
||||
|
||||
data.addError(PRIMARY_URL_FIELD,
|
||||
new GlobalizedMessage(
|
||||
"cms.ui.pages.form.site_select.error",
|
||||
CmsConstants.CMS_BUNDLE));
|
||||
}
|
||||
|
||||
final String selectedDomain = data.getString(CATEGORY_DOMAIN_SELECT);
|
||||
if (selectedDomain == null
|
||||
|| selectedDomain.isEmpty()) {
|
||||
|
||||
data.addError(PRIMARY_URL_FIELD,
|
||||
new GlobalizedMessage(
|
||||
"cms.ui.pages.form.category_domain_select.error",
|
||||
CmsConstants.CMS_BUNDLE));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void process(final FormSectionEvent event)
|
||||
throws FormProcessException {
|
||||
|
||||
final PageState state = event.getPageState();
|
||||
|
||||
if (saveCancelSection.getSaveButton().isSelected(state)) {
|
||||
|
||||
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
|
||||
final PagesPaneController controller = cdiUtil
|
||||
.findBean(PagesPaneController.class);
|
||||
|
||||
final FormData data = event.getFormData();
|
||||
|
||||
final String primaryUrl = data.getString(PRIMARY_URL_FIELD);
|
||||
final String selectedSiteId = data.getString(SITE_SELECT);
|
||||
final String selectedDomainId = data.getString(
|
||||
CATEGORY_DOMAIN_SELECT);
|
||||
|
||||
if (selectedPages.getSelectedKey(state) == null) {
|
||||
controller.createPages(primaryUrl,
|
||||
Long.parseLong(selectedSiteId),
|
||||
Long.parseLong(selectedDomainId));
|
||||
} else {
|
||||
controller
|
||||
.updatePages(
|
||||
Long.parseLong(selectedPages.getSelectedKey(state)),
|
||||
primaryUrl);
|
||||
}
|
||||
}
|
||||
|
||||
pagesPane.showPagesTable(state);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,372 @@
|
|||
/*
|
||||
* Copyright (C) 2017 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 com.arsdigita.cms.ui.contentcenter;
|
||||
|
||||
import com.arsdigita.bebop.ActionLink;
|
||||
import com.arsdigita.bebop.BoxPanel;
|
||||
import com.arsdigita.bebop.Component;
|
||||
import com.arsdigita.bebop.ControlLink;
|
||||
import com.arsdigita.bebop.FormProcessException;
|
||||
import com.arsdigita.bebop.Label;
|
||||
import com.arsdigita.bebop.Link;
|
||||
import com.arsdigita.bebop.Page;
|
||||
import com.arsdigita.bebop.PageState;
|
||||
import com.arsdigita.bebop.ParameterSingleSelectionModel;
|
||||
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.parameters.StringParameter;
|
||||
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.ui.CMSContainer;
|
||||
import com.arsdigita.globalization.GlobalizedMessage;
|
||||
import com.arsdigita.util.LockableImpl;
|
||||
|
||||
import org.libreccm.cdi.utils.CdiUtil;
|
||||
import org.libreccm.core.UnexpectedErrorException;
|
||||
import org.libreccm.security.PermissionChecker;
|
||||
import org.librecms.CmsConstants;
|
||||
import org.librecms.pages.Pages;
|
||||
import org.librecms.pages.PagesPrivileges;
|
||||
import org.librecms.pages.PagesRepository;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||
*/
|
||||
class PagesPane extends CMSContainer {
|
||||
|
||||
private final ParameterSingleSelectionModel<String> selectedPages;
|
||||
|
||||
private final ActionLink addPagesLink;
|
||||
private final PagesTable pagesTable;
|
||||
private final PagesForm pagesForm;
|
||||
|
||||
PagesPane() {
|
||||
|
||||
super();
|
||||
|
||||
selectedPages = new ParameterSingleSelectionModel<>(
|
||||
new StringParameter("selectedPages"));
|
||||
|
||||
addPagesLink = new ActionLink(new GlobalizedMessage(
|
||||
"cms.ui.contentcenter.pages.add_link",
|
||||
CmsConstants.CMS_BUNDLE));
|
||||
addPagesLink.addActionListener(event -> {
|
||||
showPagesForm(event.getPageState());
|
||||
});
|
||||
pagesTable = new PagesTable();
|
||||
pagesForm = new PagesForm(this, selectedPages);
|
||||
|
||||
final BoxPanel panel = new BoxPanel(BoxPanel.VERTICAL);
|
||||
panel.add(addPagesLink);
|
||||
panel.add(pagesTable);
|
||||
panel.add(pagesForm);
|
||||
|
||||
super.add(panel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void register(final Page page) {
|
||||
super.register(page);
|
||||
|
||||
page.addGlobalStateParam(selectedPages.getStateParameter());
|
||||
|
||||
page.setVisibleDefault(addPagesLink, true);
|
||||
page.setVisibleDefault(pagesTable, true);
|
||||
page.setVisibleDefault(pagesForm, false);
|
||||
}
|
||||
|
||||
protected void showPagesForm(final PageState state) {
|
||||
|
||||
addPagesLink.setVisible(state, false);
|
||||
pagesTable.setVisible(state, false);
|
||||
pagesForm.setVisible(state, true);
|
||||
}
|
||||
|
||||
protected void showPagesTable(final PageState state) {
|
||||
|
||||
addPagesLink.setVisible(state, true);
|
||||
pagesTable.setVisible(state, true);
|
||||
pagesForm.setVisible(state, false);
|
||||
|
||||
selectedPages.clearSelection(state);
|
||||
}
|
||||
|
||||
private class PagesTable extends Table {
|
||||
|
||||
public static final int COL_SITE = 0;
|
||||
public static final int COL_EDIT = 1;
|
||||
public static final int COL_DELETE = 2;
|
||||
|
||||
public PagesTable() {
|
||||
|
||||
super();
|
||||
|
||||
final TableColumnModel columnModel = super.getColumnModel();
|
||||
|
||||
columnModel
|
||||
.add(new TableColumn(
|
||||
COL_SITE,
|
||||
new Label(new GlobalizedMessage(
|
||||
"cms.ui.contentcenter.pagestable.columns.site.header",
|
||||
CmsConstants.CMS_BUNDLE))));
|
||||
columnModel
|
||||
.add(new TableColumn(
|
||||
COL_EDIT,
|
||||
new Label(new GlobalizedMessage(
|
||||
"cms.ui.contentcenter.pagestable.columns.edit.header",
|
||||
CmsConstants.CMS_BUNDLE))));
|
||||
columnModel
|
||||
.add(new TableColumn(
|
||||
COL_DELETE,
|
||||
new Label(new GlobalizedMessage(
|
||||
"cms.ui.contentcenter.pagestable.columns.delete.header",
|
||||
CmsConstants.CMS_BUNDLE))));
|
||||
|
||||
columnModel
|
||||
.get(COL_SITE)
|
||||
.setCellRenderer(new 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);
|
||||
|
||||
// return new ControlLink((String) value);
|
||||
final Pages pages = (Pages) value;
|
||||
if (permissionChecker.isPermitted(
|
||||
PagesPrivileges.ADMINISTER_PAGES)) {
|
||||
return new Link(pages.getSite().getDomainOfSite(),
|
||||
pages.getPrimaryUrl());
|
||||
} else {
|
||||
return new Text(pages.getSite().getDomainOfSite());
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
columnModel
|
||||
.get(COL_EDIT)
|
||||
.setCellRenderer(new 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);
|
||||
|
||||
if (permissionChecker.isPermitted(
|
||||
PagesPrivileges.ADMINISTER_PAGES)) {
|
||||
|
||||
final ControlLink link = new ControlLink(
|
||||
(Component) value);
|
||||
return link;
|
||||
} else {
|
||||
return new Text("");
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
columnModel
|
||||
.get(COL_DELETE)
|
||||
.setCellRenderer(new 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);
|
||||
|
||||
if (permissionChecker.isPermitted(
|
||||
PagesPrivileges.ADMINISTER_PAGES)) {
|
||||
|
||||
final ControlLink link = new ControlLink(
|
||||
(Component) value);
|
||||
link.setConfirmation(new GlobalizedMessage(
|
||||
"cms.ui.contentcenter.pages.delete.confirm",
|
||||
CmsConstants.CMS_BUNDLE));
|
||||
return link;
|
||||
} else {
|
||||
return new Text("");
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
super.addTableActionListener(new TableActionListener() {
|
||||
|
||||
@Override
|
||||
public void cellSelected(final TableActionEvent event)
|
||||
throws FormProcessException {
|
||||
|
||||
final PageState state = event.getPageState();
|
||||
|
||||
final int column = event.getColumn();
|
||||
final String key = (String) event.getRowKey();
|
||||
|
||||
switch (column) {
|
||||
case COL_EDIT:
|
||||
selectedPages.setSelectedKey(state, key);
|
||||
showPagesForm(state);
|
||||
break;
|
||||
case COL_DELETE: {
|
||||
deletePages(key);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
throw new UnexpectedErrorException(
|
||||
"Illegal column index.");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void headSelected(final TableActionEvent event) {
|
||||
|
||||
//Nothing
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
super.setModelBuilder(new PagesTableModelBuilder());
|
||||
|
||||
super.setEmptyView(new Label(new GlobalizedMessage(
|
||||
"cms.ui.contentcenter.pages.none", CmsConstants.CMS_BUNDLE)));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void deletePages(final String pagesId) {
|
||||
|
||||
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
|
||||
final PagesRepository pagesRepo = cdiUtil
|
||||
.findBean(PagesRepository.class);
|
||||
|
||||
final Pages pages = pagesRepo
|
||||
.findById(Long.parseLong(pagesId))
|
||||
.orElseThrow(() -> new UnexpectedErrorException(String
|
||||
.format("No Pages with ID %d in the database.",
|
||||
pagesId)));
|
||||
|
||||
pagesRepo.delete(pages);
|
||||
}
|
||||
|
||||
private class PagesTableModelBuilder
|
||||
extends LockableImpl
|
||||
implements TableModelBuilder {
|
||||
|
||||
@Override
|
||||
public TableModel makeModel(final Table table, final PageState state) {
|
||||
|
||||
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
|
||||
final PagesRepository pagesRepo = cdiUtil
|
||||
.findBean(PagesRepository.class);
|
||||
|
||||
final List<Pages> pages = pagesRepo.findAll();
|
||||
return new PagesTableModel(pages);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private class PagesTableModel implements TableModel {
|
||||
|
||||
private final Iterator<Pages> iterator;
|
||||
private Pages current;
|
||||
|
||||
public PagesTableModel(final List<Pages> pages) {
|
||||
|
||||
iterator = pages.iterator();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getColumnCount() {
|
||||
return 3;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean nextRow() {
|
||||
|
||||
if (iterator.hasNext()) {
|
||||
current = iterator.next();
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getElementAt(final int columnIndex) {
|
||||
|
||||
switch (columnIndex) {
|
||||
case PagesTable.COL_SITE:
|
||||
return current;
|
||||
case PagesTable.COL_EDIT:
|
||||
return new Label(new GlobalizedMessage(
|
||||
"cms.ui.contentcenter.pages.edit.label",
|
||||
CmsConstants.CMS_BUNDLE));
|
||||
case PagesTable.COL_DELETE:
|
||||
return new Label(new GlobalizedMessage(
|
||||
"cms.ui.contentcenter.pages.delete.label",
|
||||
CmsConstants.CMS_BUNDLE));
|
||||
default:
|
||||
throw new IllegalArgumentException("Illegal column index.");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getKeyAt(final int columnIndex) {
|
||||
|
||||
return current.getObjectId();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,97 @@
|
|||
/*
|
||||
* Copyright (C) 2017 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 com.arsdigita.cms.ui.contentcenter;
|
||||
|
||||
import org.libreccm.categorization.Domain;
|
||||
import org.libreccm.categorization.DomainRepository;
|
||||
import org.libreccm.core.UnexpectedErrorException;
|
||||
import org.libreccm.sites.Site;
|
||||
import org.libreccm.sites.SiteManager;
|
||||
import org.libreccm.sites.SiteRepository;
|
||||
import org.librecms.pages.Pages;
|
||||
import org.librecms.pages.PagesManager;
|
||||
import org.librecms.pages.PagesRepository;
|
||||
|
||||
import javax.enterprise.context.RequestScoped;
|
||||
import javax.inject.Inject;
|
||||
import javax.transaction.Transactional;
|
||||
|
||||
import static org.primefaces.component.calendar.Calendar.PropertyKeys.*;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||
*/
|
||||
@RequestScoped
|
||||
class PagesPaneController {
|
||||
|
||||
@Inject
|
||||
private DomainRepository domainRepo;
|
||||
|
||||
@Inject
|
||||
private PagesRepository pagesRepo;
|
||||
|
||||
@Inject
|
||||
private PagesManager pagesManager;
|
||||
|
||||
@Inject
|
||||
private SiteManager siteManager;
|
||||
|
||||
@Inject
|
||||
private SiteRepository siteRepo;
|
||||
|
||||
@Transactional(Transactional.TxType.REQUIRED)
|
||||
protected void createPages(final String primaryUrl,
|
||||
final long siteId,
|
||||
final long categoryDomainId) {
|
||||
|
||||
final Site site = siteRepo
|
||||
.findById(siteId)
|
||||
.orElseThrow(() -> new UnexpectedErrorException(String
|
||||
.format("No Site with ID %d in the database.",
|
||||
siteId)));
|
||||
|
||||
final Domain domain = domainRepo
|
||||
.findById(categoryDomainId)
|
||||
.orElseThrow(() -> new UnexpectedErrorException(String
|
||||
.format("No (Category) Domain with ID %d in the database.",
|
||||
categoryDomainId)));
|
||||
|
||||
final Pages pages = pagesManager.createPages(primaryUrl, site, domain);
|
||||
pages.setPrimaryUrl(primaryUrl);
|
||||
|
||||
pagesRepo.save(pages);
|
||||
}
|
||||
|
||||
@Transactional(Transactional.TxType.REQUIRED)
|
||||
protected void updatePages(final long pagesId,
|
||||
final String primaryUrl) {
|
||||
|
||||
final Pages pages = pagesRepo
|
||||
.findById(pagesId)
|
||||
.orElseThrow(() -> new UnexpectedErrorException(String
|
||||
.format("No Pages with ID %d in the database.",
|
||||
pagesId)));
|
||||
|
||||
pages.setPrimaryUrl(primaryUrl);
|
||||
|
||||
pagesRepo.save(pages);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -48,11 +48,7 @@ import org.librecms.CmsConstants;
|
|||
import org.librecms.contentsection.ContentSection;
|
||||
import org.librecms.contentsection.ContentType;
|
||||
|
||||
/**
|
||||
*
|
||||
* @version $Id$
|
||||
*/
|
||||
public class TasksPanel extends CMSContainer {
|
||||
public class TasksPane extends CMSContainer {
|
||||
|
||||
// The default number of rows to show
|
||||
private static final int DEFAULT_MAX_ROWS = 15;
|
||||
|
|
@ -110,7 +106,7 @@ public class TasksPanel extends CMSContainer {
|
|||
* @param sectionModel
|
||||
*
|
||||
*/
|
||||
public TasksPanel(CcmObjectSelectionModel typeModel,
|
||||
public TasksPane(CcmObjectSelectionModel typeModel,
|
||||
CcmObjectSelectionModel sectionModel) {
|
||||
this(DEFAULT_MAX_ROWS, typeModel, sectionModel);
|
||||
}
|
||||
|
|
@ -125,7 +121,7 @@ public class TasksPanel extends CMSContainer {
|
|||
* @pre maxRows != null
|
||||
*
|
||||
*/
|
||||
public TasksPanel(int maxRows,
|
||||
public TasksPane(int maxRows,
|
||||
CcmObjectSelectionModel typeModel,
|
||||
CcmObjectSelectionModel sectionModel) {
|
||||
super();
|
||||
|
|
@ -47,16 +47,20 @@ public class PagesManager implements Serializable {
|
|||
|
||||
@RequiresPrivilege(PagesPrivileges.ADMINISTER_PAGES)
|
||||
@Transactional(Transactional.TxType.REQUIRED)
|
||||
public Pages createPages(final Site site,
|
||||
public Pages createPages(final String primaryUrl,
|
||||
final Site site,
|
||||
final Domain domain) {
|
||||
|
||||
final Pages pages = new Pages();
|
||||
pages.setCategoryDomain(domain);
|
||||
|
||||
siteManager.addApplicationToSite(site, pages);
|
||||
pages.setPrimaryUrl(primaryUrl);
|
||||
|
||||
pagesRepo.save(pages);
|
||||
|
||||
pages.setCategoryDomain(domain);
|
||||
pagesRepo.save(pages);
|
||||
|
||||
siteManager.addApplicationToSite(site, pages);
|
||||
|
||||
return pages;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ import org.libreccm.security.RequiresPrivilege;
|
|||
import org.libreccm.sites.SiteRepository;
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
import javax.enterprise.context.RequestScoped;
|
||||
import javax.inject.Inject;
|
||||
|
|
@ -39,6 +40,8 @@ import javax.transaction.Transactional;
|
|||
@RequestScoped
|
||||
public class PagesRepository extends AbstractEntityRepository<Long, Pages> {
|
||||
|
||||
private static final long serialVersionUID = 7256268720843315037L;
|
||||
|
||||
@Inject
|
||||
private SiteRepository siteRepo;
|
||||
|
||||
|
|
@ -84,6 +87,15 @@ public class PagesRepository extends AbstractEntityRepository<Long, Pages> {
|
|||
return pages.getObjectId() == 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initNewEntity(final Pages pages) {
|
||||
|
||||
super.initNewEntity(pages);
|
||||
|
||||
pages.setUuid(UUID.randomUUID().toString());
|
||||
pages.setApplicationType(Pages.class.getName());
|
||||
}
|
||||
|
||||
@RequiresPrivilege(CoreConstants.PRIVILEGE_ADMIN)
|
||||
@Override
|
||||
public void save(final Pages pages) {
|
||||
|
|
|
|||
|
|
@ -476,3 +476,18 @@ cms.ui.pagemodel.components.greetingitem_component.title=Greeting Item
|
|||
cms.ui.pagemodel.components.greetingitem_component.desc=Output the index item of the current category.
|
||||
cms.ui.pagemodel.components.itemlist_component.title=Item List
|
||||
cms.ui.pagemodel.components.itemlist_component.desc=Outputs a list of all content items (without the index item) assigned to the current category.
|
||||
cms.ui.contentcenter.mainpage.pages=Pages
|
||||
cms.ui.contentcenter.pages.none=No pages available
|
||||
cms.ui.contentcenter.pages.delete.confirm=Are you sure to delete this page tree?
|
||||
cms.ui.contentcenter.pagestable.columns.site.header=Site
|
||||
cms.ui.contentcenter.pagestable.columns.delete.header=Delete
|
||||
cms.ui.contentcenter.pages.delete.label=Delete
|
||||
cms.ui.pages.form.primary_url_field.label=Primary URL
|
||||
cms.ui.pages.form.site_select.label=Site
|
||||
cms.ui.pages.form.category_domain_select.label=Category System
|
||||
cms.ui.pages.form.primary_url_field.error=Primary URL can't be empty.
|
||||
cms.ui.pages.form.site_select.error=A Pages must be associated with a Site.
|
||||
cms.ui.pages.form.category_domain_select.error=A Page tree needs a category system.
|
||||
cms.ui.contentcenter.pagestable.columns.edit.header=Edit
|
||||
cms.ui.contentcenter.pages.edit.label=Edit
|
||||
cms.ui.contentcenter.pages.add_link=Add page tree
|
||||
|
|
|
|||
|
|
@ -473,3 +473,18 @@ cms.ui.pagemodel.components.greetingitem_component.title=Greeting Item
|
|||
cms.ui.pagemodel.components.greetingitem_component.desc=Gibt das Index-Item der aktuellen Kategorie aus.
|
||||
cms.ui.pagemodel.components.itemlist_component.title=Item Liste
|
||||
cms.ui.pagemodel.components.itemlist_component.desc=Gibt eine Liste aller ContentItems aus, die der aktuellen Kategorie zugeordnet sind.
|
||||
cms.ui.contentcenter.mainpage.pages=Seiten
|
||||
cms.ui.contentcenter.pages.none=Keine Seiten vorhanden
|
||||
cms.ui.contentcenter.pages.delete.confirm=Sind Sie sicher, dass Sie diesen Seitenbaum l\u00f6schen wollen?
|
||||
cms.ui.contentcenter.pagestable.columns.site.header=Site
|
||||
cms.ui.contentcenter.pagestable.columns.delete.header=L\u00f6schen
|
||||
cms.ui.contentcenter.pages.delete.label=L\u00f6schen
|
||||
cms.ui.pages.form.primary_url_field.label=Prim\u00e4re URL
|
||||
cms.ui.pages.form.site_select.label=Site
|
||||
cms.ui.pages.form.category_domain_select.label=Kategoriensystem
|
||||
cms.ui.pages.form.primary_url_field.error=Die prim\u00e4re URL darf nicht leer sein.
|
||||
cms.ui.pages.form.site_select.error=Ein Seitenbaum muss einer Site zugewiesen sein.
|
||||
cms.ui.pages.form.category_domain_select.error=Ein Seitenbaum ben\u00f6tigt ein Kategoriensystem.
|
||||
cms.ui.contentcenter.pagestable.columns.edit.header=Bearbeiten
|
||||
cms.ui.contentcenter.pages.edit.label=Bearbeiten
|
||||
cms.ui.contentcenter.pages.add_link=Seitenbaum hinzuf\u00fcgen
|
||||
|
|
|
|||
|
|
@ -432,3 +432,18 @@ cms.ui.pagemodel.components.greetingitem_component.title=Greeting Item
|
|||
cms.ui.pagemodel.components.greetingitem_component.desc=Output the index item of the current category.
|
||||
cms.ui.pagemodel.components.itemlist_component.title=Item List
|
||||
cms.ui.pagemodel.components.itemlist_component.desc=Outputs a list of all content items (without the index item) assigned to the current category.
|
||||
cms.ui.contentcenter.mainpage.pages=Pages
|
||||
cms.ui.contentcenter.pages.none=No pages available
|
||||
cms.ui.contentcenter.pages.delete.confirm=Are you sure to delete this page tree?
|
||||
cms.ui.contentcenter.pagestable.columns.site.header=Site
|
||||
cms.ui.contentcenter.pagestable.columns.delete.header=Delete
|
||||
cms.ui.contentcenter.pages.delete.label=Delete
|
||||
cms.ui.pages.form.primary_url_field.label=Primary URL
|
||||
cms.ui.pages.form.site_select.label=Site
|
||||
cms.ui.pages.form.category_domain_select.label=Category System
|
||||
cms.ui.pages.form.primary_url_field.error=Primary URL can't be empty.
|
||||
cms.ui.pages.form.site_select.error=A Pages must be associated with a Site.
|
||||
cms.ui.pages.form.category_domain_select.error=A Page tree needs a category system.
|
||||
cms.ui.contentcenter.pagestable.columns.edit.header=Edit
|
||||
cms.ui.contentcenter.pages.edit.label=Edit
|
||||
cms.ui.contentcenter.pages.add_link=Add page tree
|
||||
|
|
|
|||
|
|
@ -29,7 +29,6 @@ import com.arsdigita.bebop.parameters.ParameterModel;
|
|||
* @author Rory Solomon
|
||||
* @author Michael Pih
|
||||
* @author Christian Brechbühler (christian@arsdigita.com)
|
||||
* @version $Id$
|
||||
*/
|
||||
public class SingleSelect extends Select {
|
||||
|
||||
|
|
|
|||
|
|
@ -27,8 +27,10 @@ import javax.enterprise.context.RequestScoped;
|
|||
import javax.persistence.NoResultException;
|
||||
import javax.persistence.TypedQuery;
|
||||
import javax.transaction.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
@ -38,6 +40,8 @@ import java.util.Optional;
|
|||
public class ApplicationRepository
|
||||
extends AbstractEntityRepository<Long, CcmApplication> {
|
||||
|
||||
private static final long serialVersionUID = 165550885824851765L;
|
||||
|
||||
@Override
|
||||
public Class<CcmApplication> getEntityClass() {
|
||||
return CcmApplication.class;
|
||||
|
|
@ -48,6 +52,14 @@ public class ApplicationRepository
|
|||
return application.getObjectId() == 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initNewEntity(final CcmApplication application) {
|
||||
|
||||
super.initNewEntity(application);
|
||||
application.setUuid(UUID.randomUUID().toString());
|
||||
application.setApplicationType(application.getClass().getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the application mounted at the provided {@code path}.
|
||||
*
|
||||
|
|
|
|||
Loading…
Reference in New Issue