CCM NG: Started migration of UI for Lifecycle management in ccm-cms

git-svn-id: https://svn.libreccm.org/ccm/ccm_ng@4243 8810af33-2d31-482b-a856-94f89814c4df
pull/2/head
jensp 2016-09-01 12:43:07 +00:00
parent 5ed394bee2
commit 1dccc276d0
6 changed files with 341 additions and 33 deletions

View File

@ -0,0 +1,96 @@
/*
* Copyright (C) 2003-2004 Red Hat Inc. All Rights Reserved.
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
package com.arsdigita.cms.ui;
import com.arsdigita.bebop.Component;
import com.arsdigita.bebop.SingleSelectionModel;
import com.arsdigita.bebop.list.ListModelBuilder;
import com.arsdigita.bebop.tree.TreeModelBuilder;
import com.arsdigita.globalization.GlobalizedMessage;
import com.arsdigita.toolbox.ui.SelectionPanel;
import org.apache.log4j.Logger;
import org.librecms.CmsConstants;
/**
* A base component for use in CMS admin panes.
*
* @author Justin Ross <jross@redhat.com>
*/
public abstract class BaseAdminPane extends SelectionPanel {
/** Internal logger instance to faciliate debugging. Enable logging output
* by editing /WEB-INF/conf/log4j.properties int the runtime environment
* and set com.arsdigita.cms.ui.BaseAdminPane=DEBUG
* by uncommenting or adding the line. */
private static final Logger s_log = Logger.getLogger(BaseAdminPane.class);
protected BaseAdminPane() {
super();
}
protected BaseAdminPane(final Component title,
final Component selector) {
super(title, selector);
}
protected BaseAdminPane(final GlobalizedMessage title,
final Component selector) {
super(title, selector);
}
protected BaseAdminPane(final Component title,
final Component selector,
final SingleSelectionModel model) {
super(title, selector, model);
}
protected BaseAdminPane(final GlobalizedMessage title,
final Component selector,
final SingleSelectionModel model) {
super(title, selector, model);
}
protected BaseAdminPane(final Component title,
final ListModelBuilder builder) {
super(title, builder);
}
protected BaseAdminPane(final GlobalizedMessage title,
final ListModelBuilder builder) {
super(title, builder);
}
protected BaseAdminPane(final Component title,
final TreeModelBuilder builder) {
super(title, builder);
}
protected BaseAdminPane(final GlobalizedMessage title,
final TreeModelBuilder builder) {
super(title, builder);
}
protected static GlobalizedMessage gz(final String key) {
return new GlobalizedMessage(key, CmsConstants.CMS_BUNDLE);
}
protected static String lz(final String key) {
return (String) gz(key).localize();
}
}

View File

@ -24,9 +24,8 @@ import com.arsdigita.bebop.PageState;
import com.arsdigita.bebop.SingleSelectionModel; import com.arsdigita.bebop.SingleSelectionModel;
import com.arsdigita.bebop.event.FormSectionEvent; import com.arsdigita.bebop.event.FormSectionEvent;
import com.arsdigita.cms.CMS; import com.arsdigita.cms.CMS;
import com.arsdigita.cms.ContentSection; import org.librecms.contentsection.ContentSection;
import com.arsdigita.cms.SecurityManager; import org.librecms.lifecycle.LifecycleDefinition;
import com.arsdigita.cms.lifecycle.LifecycleDefinition;
import com.arsdigita.cms.ui.BaseAdminPane; import com.arsdigita.cms.ui.BaseAdminPane;
import com.arsdigita.cms.ui.BaseDeleteForm; import com.arsdigita.cms.ui.BaseDeleteForm;
import com.arsdigita.cms.ui.FormSecurityListener; import com.arsdigita.cms.ui.FormSecurityListener;

View File

@ -0,0 +1,35 @@
/*
* Copyright (C) 2003-2004 Red Hat Inc. All Rights Reserved.
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
package com.arsdigita.cms.ui.lifecycle;
import com.arsdigita.bebop.PageState;
import com.arsdigita.bebop.RequestLocal;
import org.librecms.lifecycle.LifecycleDefinition;
import org.apache.log4j.Logger;
public abstract class LifecycleDefinitionRequestLocal extends RequestLocal {
private static final Logger s_log = Logger.getLogger
(LifecycleDefinitionRequestLocal.class);
public final LifecycleDefinition getLifecycleDefinition
(final PageState state) {
return (LifecycleDefinition) get(state);
}
}

View File

@ -0,0 +1,81 @@
/*
* Copyright (C) 2003-2004 Red Hat Inc. All Rights Reserved.
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
package com.arsdigita.cms.ui.lifecycle;
import com.arsdigita.bebop.PageState;
import com.arsdigita.bebop.list.ListModel;
import com.arsdigita.bebop.list.ListModelBuilder;
import com.arsdigita.cms.CMS;
import org.librecms.contentsection.ContentSection;
import com.arsdigita.util.LockableImpl;
import com.arsdigita.util.UncheckedWrapperException;
import java.util.List;
import java.util.NoSuchElementException;
import org.librecms.lifecycle.LifecycleDefinition;
/**
* Loads all the current lifecycles from the database so that they may be
* displayed in a list.
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
* @author <a href="mailto:pihman@arsdigita.com">Michael Pih</a>
* @author <a href="mailto:flattop@arsdigita.com">Jack Chung</a>
*/
public final class LifecycleListModelBuilder extends LockableImpl
implements ListModelBuilder {
@Override
public final ListModel makeModel(final com.arsdigita.bebop.List list,
final PageState state) {
return new Model(state);
}
private class Model implements ListModel {
private List<LifecycleDefinition> m_cycles;
public Model(final PageState state) {
m_cycles = getCollection(state);
}
private List<LifecycleDefinition> getCollection(final PageState state) {
final ContentSection section = CMS.getContext().getContentSection();
final List<LifecycleDefinition> cycles = section.get
getLifecycleDefinitions();
cycles.addOrder("upper(label)");
return cycles;
}
public boolean next() throws NoSuchElementException {
return m_cycles.next();
}
public Object getElement() {
return m_cycles.getLifecycleDefinition().getLabel();
}
public String getKey() {
return m_cycles.getLifecycleDefinition().getID().toString();
}
}
}

View File

@ -18,7 +18,6 @@
*/ */
package org.librecms.contentsection; package org.librecms.contentsection;
import org.libreccm.categorization.Category; import org.libreccm.categorization.Category;
import org.libreccm.security.Role; import org.libreccm.security.Role;
import org.libreccm.web.CcmApplication; import org.libreccm.web.CcmApplication;
@ -42,6 +41,8 @@ import java.util.ArrayList;
import javax.persistence.NamedQueries; import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery; import javax.persistence.NamedQuery;
import javax.persistence.OneToMany; import javax.persistence.OneToMany;
import org.libreccm.workflow.WorkflowTemplate;
import org.librecms.lifecycle.LifecycleDefinition;
import static org.librecms.CmsConstants.*; import static org.librecms.CmsConstants.*;
@ -53,14 +54,14 @@ import static org.librecms.CmsConstants.*;
@Table(name = "CONTENT_SECTIONS", schema = DB_SCHEMA) @Table(name = "CONTENT_SECTIONS", schema = DB_SCHEMA)
@NamedQueries({ @NamedQueries({
@NamedQuery( @NamedQuery(
name = "ContentSection.findByLabel", name = "ContentSection.findByLabel",
query = "SELECT s FROM ContentSection s WHERE s.label = :label"), query = "SELECT s FROM ContentSection s WHERE s.label = :label"),
@NamedQuery( @NamedQuery(
name = "ContentSection.findPermissions", name = "ContentSection.findPermissions",
query = "SELECT p FROM Permission p " query = "SELECT p FROM Permission p "
+ "WHERE (p.object = :section " + "WHERE (p.object = :section "
+ " OR p.object = :rootDocumentsFolder) " + " OR p.object = :rootDocumentsFolder) "
+ "AND p.grantee = :role") + "AND p.grantee = :role")
}) })
//@ApplicationType( //@ApplicationType(
// name = CONTENT_SECTION_APP_TYPE, // name = CONTENT_SECTION_APP_TYPE,
@ -122,6 +123,30 @@ public class ContentSection extends CcmApplication implements Serializable {
@OneToMany(mappedBy = "contentSection") @OneToMany(mappedBy = "contentSection")
private List<ContentType> contentTypes; private List<ContentType> contentTypes;
@OneToMany
@JoinTable(
name = "CONTENT_SECTION_LIFECYCLE_DEFINITIONS",
joinColumns = {
@JoinColumn(name = "CONTENT_SECTION_ID")
},
inverseJoinColumns = {
@JoinColumn(name = "LIFECYCLE_DEFINITION_ID")
}
)
private List<LifecycleDefinition> lifecycleDefinitions;
@OneToMany
@JoinTable(
name = "CONTENT_SECTION_WORKFLOW_TEMPLATES",
joinColumns = {
@JoinColumn(name = "CONTENT_SECTION_ID")
},
inverseJoinColumns = {
@JoinColumn(name = "WORKFLOW_TEMPLATE_ID")
}
)
private List<WorkflowTemplate> workflowTemplates;
public ContentSection() { public ContentSection() {
roles = new ArrayList<>(); roles = new ArrayList<>();
} }
@ -235,6 +260,40 @@ public class ContentSection extends CcmApplication implements Serializable {
contentTypes.remove(contentType); contentTypes.remove(contentType);
} }
public List<LifecycleDefinition> getLifecycleDefinitions() {
return Collections.unmodifiableList(lifecycleDefinitions);
}
protected void setLifecycleDefinitions(
final List<LifecycleDefinition> lifecycleDefinitions) {
this.lifecycleDefinitions = lifecycleDefinitions;
}
protected void addLifecycleDefinition(final LifecycleDefinition definition) {
lifecycleDefinitions.add(definition);
}
protected void removeLifecycleDefinition(
final LifecycleDefinition definition) {
lifecycleDefinitions.remove(definition);
}
public List<WorkflowTemplate> getWorkflowTemplates() {
return Collections.unmodifiableList(workflowTemplates);
}
protected void setWorkflowTemplates(final List<WorkflowTemplate> workflowTemplates) {
this.workflowTemplates = workflowTemplates;
}
protected void addWorkflowTemplate(final WorkflowTemplate template) {
workflowTemplates.add(template);
}
protected void removeWorkflowTemplate(final WorkflowTemplate template) {
workflowTemplates.remove(template);
}
@Override @Override
public int hashCode() { public int hashCode() {
int hash = super.hashCode(); int hash = super.hashCode();
@ -301,23 +360,23 @@ public class ContentSection extends CcmApplication implements Serializable {
@Override @Override
public String toString(final String data) { public String toString(final String data) {
return super.toString(String.format( return super.toString(String.format(
", label = \"%s\", " ", label = \"%s\", "
+ "rootDocumentsFolder = \"%s\", " + "rootDocumentsFolder = \"%s\", "
+ "rootAssetsFolder = \"%s\", " + "rootAssetsFolder = \"%s\", "
+ "pageResolverClass = \"%s\", " + "pageResolverClass = \"%s\", "
+ "itemResolverClass = \"%s\", " + "itemResolverClass = \"%s\", "
+ "templateResolverClass = \"%s\", " + "templateResolverClass = \"%s\", "
+ "xmlGeneratorClass = \"%s\", " + "xmlGeneratorClass = \"%s\", "
+ "defaultLocale = \"%s\"%s", + "defaultLocale = \"%s\"%s",
label, label,
Objects.toString(rootDocumentsFolder), Objects.toString(rootDocumentsFolder),
Objects.toString(rootAssetsFolder), Objects.toString(rootAssetsFolder),
pageResolverClass, pageResolverClass,
itemResolverClass, itemResolverClass,
templateResolverClass, templateResolverClass,
xmlGeneratorClass, xmlGeneratorClass,
Objects.toString(defaultLocale), Objects.toString(defaultLocale),
data)); data));
} }
} }

View File

@ -41,6 +41,7 @@ import javax.inject.Inject;
import javax.persistence.EntityManager; import javax.persistence.EntityManager;
import javax.persistence.TypedQuery; import javax.persistence.TypedQuery;
import javax.transaction.Transactional; import javax.transaction.Transactional;
import org.librecms.lifecycle.LifecycleDefinition;
import static org.librecms.CmsConstants.*; import static org.librecms.CmsConstants.*;
import static org.librecms.contentsection.ContentSection.*; import static org.librecms.contentsection.ContentSection.*;
@ -275,6 +276,43 @@ public class ContentSectionManager {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
@AuthorizationRequired
@RequiresPrivilege(CoreConstants.ADMIN_PRIVILEGE)
@Transactional(Transactional.TxType.REQUIRED)
public void addLifecycleDefinitionToContentSection(
final LifecycleDefinition definition,
final ContentSection section) {
throw new UnsupportedOperationException();
}
@AuthorizationRequired
@RequiresPrivilege(CoreConstants.ADMIN_PRIVILEGE)
@Transactional(Transactional.TxType.REQUIRED)
public void removeLifecycleDefinitionFromContentSection(
final LifecycleDefinition definition,
final ContentSection contentSection) {
throw new UnsupportedOperationException();
}
@AuthorizationRequired
@RequiresPrivilege(CoreConstants.ADMIN_PRIVILEGE)
@Transactional(Transactional.TxType.REQUIRED)
public void addWorkflowTemplateToContentSection(
final LifecycleDefinition definition,
final ContentSection section) {
throw new UnsupportedOperationException();
}
@AuthorizationRequired
@RequiresPrivilege(CoreConstants.ADMIN_PRIVILEGE)
@Transactional(Transactional.TxType.REQUIRED)
public void removeWorkflowTemplateFromContentSection(
final LifecycleDefinition definition,
final ContentSection contentSection) {
throw new UnsupportedOperationException();
}
public ItemResolver getItemResolver(final ContentSection section) { public ItemResolver getItemResolver(final ContentSection section) {
try { try {
final Class<ItemResolver> itemResolverClazz = (Class<ItemResolver>) Class. final Class<ItemResolver> itemResolverClazz = (Class<ItemResolver>) Class.