Default Workflows für ContentSections

* Es wird jetzt der Standard-Arbeitsablauf richtig gesetzt und gespeichert

Es ist ein DB-Update notwendig

git-svn-id: https://svn.libreccm.org/ccm/trunk@1602 8810af33-2d31-482b-a856-94f89814c4df
master
quasi 2012-04-18 09:29:52 +00:00
parent 291b599cf2
commit dd52779f3c
4 changed files with 76 additions and 10 deletions

View File

@ -239,6 +239,9 @@ association {
to section_workflow_template_map.section_id,
join section_workflow_template_map.wf_template_id
to cw_process_definitions.process_def_id;
// Save the default workflow template for a content section
Boolean[1..1] isDefault = section_workflow_template_map.is_default;
}

View File

@ -90,6 +90,7 @@ import org.apache.log4j.Logger;
*
* @author <a href="mailto:pihman@arsdigita.com">Michael Pih</a>
* @author <a href="mailto:flattop@arsdigita.com">Jack Chung</a>
* @author Sören Bernstein (quasi@barkhof.uni-bremen.de)
* @version $Revision: #37 $ $DateTime: 2004/08/17 23:15:09 $
* @version $Id: ContentSection.java 2209 2011-06-22 07:59:10Z pboy $
*/
@ -899,7 +900,11 @@ public class ContentSection extends Application {
* @param template The workflow template
*/
public void addWorkflowTemplate(WorkflowTemplate template) {
template.addToAssociation(getWorkflowTemplatesAssociation());
this.addWorkflowTemplate(template, false);
}
public void addWorkflowTemplate(WorkflowTemplate template, boolean isDefault) {
DataObject link = template.addToAssociation(getWorkflowTemplatesAssociation());
link.set("isDefault", isDefault);
}
/**
@ -911,6 +916,67 @@ public class ContentSection extends Application {
template.removeFromAssociation(getWorkflowTemplatesAssociation());
}
/**
* Set a <code>WorkflowTemplate</code> as default for this ContentSection by label
*
* @param wf The label of a workflow template to set as new default workflow template
*/
public void setDefaultWorkflowTemplate(String wf) {
TaskCollection taskColl = getWorkflowTemplates();
while (taskColl.next()) {
if(((WorkflowTemplate) taskColl.getTask()).getLabel().equals(wf)) {
((DataObject) taskColl.get("link")).set("isDefault", true);
} else {
((DataObject) taskColl.get("link")).set("isDefault", false);
}
}
}
/**
* Set a <code>WorkflowTemplate</code> as default for this ContentSection
*
* @param wf The workflow template to set as new default workflow template
*/
public void setDefaultWorkflowTemplate(WorkflowTemplate wf) {
TaskCollection taskColl = getWorkflowTemplates();
while (taskColl.next()) {
if(((WorkflowTemplate) taskColl.getTask()).equals(wf)) {
((DataObject) taskColl.get("link")).set("isDefault", true);
} else {
((DataObject) taskColl.get("link")).set("isDefault", false);
}
}
}
/**
* Get the default workflow template for this content section
*
* @return the default workflow template or null, if this method fails
*/
public WorkflowTemplate getDefaultWorkflowTemplate() {
TaskCollection taskColl = getWorkflowTemplates();
while(taskColl.next()) {
if(((Boolean) taskColl.get("link.isDefault"))) {
WorkflowTemplate wf = (WorkflowTemplate) taskColl.getTask();
taskColl.close();
return wf;
}
}
// If we get here, there is no default workflow template set for this section
// To solve this, we fetch the first item and set it as default
taskColl = getWorkflowTemplates();
while(taskColl.next()) {
WorkflowTemplate wf = (WorkflowTemplate) taskColl.getTask();
((DataObject) taskColl.get("link")).set("isDefault", true);
taskColl.close();
return wf;
}
// OK, now we're screwed
return null;
}
private DataAssociation getWorkflowTemplatesAssociation() {
return (DataAssociation) get(WF_TEMPLATES);
}

View File

@ -112,7 +112,7 @@ public final class ContentSectionSetup {
// Setup the access controls
setup.registerRoles(defaultRoles);
setup.registerWorkflows(defaultWorkflows);
setup.registerWorkflowTemplates(defaultWorkflows);
setup.registerViewers(isPubliclyViewable);
setup.registerPublicationCycles();
setup.registerResolvers(itemResolverClassName, templateResolverClassName);
@ -322,7 +322,7 @@ public final class ContentSectionSetup {
m_section.save();
}
private void registerWorkflows(List workflows) {
private void registerWorkflowTemplates(List workflows) {
Iterator workflowsIter = workflows.iterator();
@ -399,6 +399,7 @@ public final class ContentSectionSetup {
// If this workflow should be the default or is the first one
// save it for easy access in registerContentType
if(m_wf == null || (workflow.containsKey("isDefault") && workflow.get("isDefault").equals("true"))) {
m_section.setDefaultWorkflowTemplate(wf);
m_wf = wf;
}
}
@ -416,7 +417,7 @@ public final class ContentSectionSetup {
ContentSectionConfig config = new ContentSectionConfig();
config.load();
registerWorkflows(config.getDefaultWorkflows());
registerWorkflowTemplates(config.getDefaultWorkflows());
}

View File

@ -55,6 +55,7 @@ import org.apache.log4j.Logger;
* that can be used by content types to reduce code duplication.
*
* @author Rafael H. Schloming &lt;rhs@mit.edu&gt;
* @authro Sören Bernstein (quasi@barkhof.uni-bremen.de)
* @version $Revision: #754 $ $Date: 2005/09/02 $ $Author: pboy $
**/
public abstract class AbstractContentTypeLoader extends PackageLoader {
@ -111,12 +112,7 @@ public abstract class AbstractContentTypeLoader extends PackageLoader {
ldc.close();
}
TaskCollection tc = section.getWorkflowTemplates();
WorkflowTemplate wf = null;
if (tc.next()) {
wf = (WorkflowTemplate) tc.getTask();
tc.close();
}
WorkflowTemplate wf = section.getDefaultWorkflowTemplate();
for (Iterator it = types.iterator(); it.hasNext();) {
final ContentType type = (ContentType) it.next();