[DS-968] XML configurable workflow

git-svn-id: http://scm.dspace.org/svn/repo/dspace/trunk@6532 9c30dcfa-912a-0410-8fc2-9e0234be79fd
This commit is contained in:
Ben Bosman
2011-08-05 14:22:20 +00:00
parent d2964aa470
commit e7efc9c689
11 changed files with 160 additions and 91 deletions

View File

@@ -62,10 +62,10 @@ public class WorkflowRequirementsManager {
ipu.update(); ipu.update();
int totalUsers = InProgressUser.getNumberOfInProgressUsers(c, wfi.getID()) + InProgressUser.getNumberOfFinishedUsers(c, wfi.getID()); int totalUsers = InProgressUser.getNumberOfInProgressUsers(c, wfi.getID()) + InProgressUser.getNumberOfFinishedUsers(c, wfi.getID());
if(totalUsers == step.getRequiredUsers()){ if(totalUsers == step.getRequiredUsers()){
//If enough users have claimed/finished this step then remove the tasks //If enough users have claimed/finished this step then remove the tasks
XmlWorkflowManager.deleteAllPooledTasks(c, wfi); XmlWorkflowManager.deleteAllPooledTasks(c, wfi);
} }
wfi.update(); wfi.update();
} }

View File

@@ -175,11 +175,13 @@ public class XmlWorkflowManager {
public static WorkflowActionConfig processOutcome(Context c, EPerson user, Workflow workflow, Step currentStep, WorkflowActionConfig currentActionConfig, ActionResult currentOutcome, XmlWorkflowItem wfi, boolean enteredNewStep) throws IOException, WorkflowConfigurationException, AuthorizeException, SQLException, WorkflowException { public static WorkflowActionConfig processOutcome(Context c, EPerson user, Workflow workflow, Step currentStep, WorkflowActionConfig currentActionConfig, ActionResult currentOutcome, XmlWorkflowItem wfi, boolean enteredNewStep) throws IOException, WorkflowConfigurationException, AuthorizeException, SQLException, WorkflowException {
if(currentOutcome.getType() == ActionResult.TYPE.TYPE_PAGE || currentOutcome.getType() == ActionResult.TYPE.TYPE_ERROR){ if(currentOutcome.getType() == ActionResult.TYPE.TYPE_PAGE || currentOutcome.getType() == ActionResult.TYPE.TYPE_ERROR){
//Our outcome is a page or an error, so return our current action //Our outcome is a page or an error, so return our current action
c.restoreAuthSystemState();
return currentActionConfig; return currentActionConfig;
}else }else
if(currentOutcome.getType() == ActionResult.TYPE.TYPE_CANCEL || currentOutcome.getType() == ActionResult.TYPE.TYPE_SUBMISSION_PAGE){ if(currentOutcome.getType() == ActionResult.TYPE.TYPE_CANCEL || currentOutcome.getType() == ActionResult.TYPE.TYPE_SUBMISSION_PAGE){
//We either pressed the cancel button or got an order to return to the submission page, so don't return an action //We either pressed the cancel button or got an order to return to the submission page, so don't return an action
//By not returning an action we ensure ourselfs that we go back to the submission page //By not returning an action we ensure ourselfs that we go back to the submission page
c.restoreAuthSystemState();
return null; return null;
}else }else
if (currentOutcome.getType() == ActionResult.TYPE.TYPE_OUTCOME) { if (currentOutcome.getType() == ActionResult.TYPE.TYPE_OUTCOME) {
@@ -196,19 +198,29 @@ public class XmlWorkflowManager {
return nextActionConfig; return nextActionConfig;
} else if( nextActionConfig.requiresUI() && enteredNewStep){ } else if( nextActionConfig.requiresUI() && enteredNewStep){
//We have entered a new step and have encountered a UI, return null since the current user doesn't have anything to do with this //We have entered a new step and have encountered a UI, return null since the current user doesn't have anything to do with this
c.restoreAuthSystemState();
return null; return null;
} else { } else {
ActionResult newOutcome = nextActionConfig.getProcessingAction().execute(c, wfi, currentStep, null); ActionResult newOutcome = nextActionConfig.getProcessingAction().execute(c, wfi, currentStep, null);
return processOutcome(c, user, workflow, currentStep, nextActionConfig, newOutcome, wfi, enteredNewStep); return processOutcome(c, user, workflow, currentStep, nextActionConfig, newOutcome, wfi, enteredNewStep);
} }
}else{ }else
if(enteredNewStep){
// If the user finished his/her step, we keep processing until there is a UI step action or no step at all
Step nextStep = workflow.getNextStep(c, wfi, currentStep, currentOutcome.getResult());
c.turnOffAuthorisationSystem();
return processNextStep(c, user, workflow, currentOutcome, wfi, nextStep);
} else {
//
ClaimedTask task = ClaimedTask.findByWorkflowIdAndEPerson(c, wfi.getID(), user.getID());
//Check if we have a task for this action (might not be the case with automatic steps)
//First add it to our list of finished users, since no more actions remain //First add it to our list of finished users, since no more actions remain
WorkflowRequirementsManager.addFinishedUser(c, wfi, user); WorkflowRequirementsManager.addFinishedUser(c, wfi, user);
c.turnOffAuthorisationSystem(); c.turnOffAuthorisationSystem();
//Check if our requirements have been met //Check if our requirements have been met
if((currentStep.isFinished(c, wfi) && currentOutcome.getResult() == ActionResult.OUTCOME_COMPLETE) || currentOutcome.getResult() != ActionResult.OUTCOME_COMPLETE){ if((currentStep.isFinished(c, wfi) && currentOutcome.getResult() == ActionResult.OUTCOME_COMPLETE) || currentOutcome.getResult() != ActionResult.OUTCOME_COMPLETE){
//Clear all the metadata that might be saved by this step //Delete all the table rows containing the users who performed this task
WorkflowRequirementsManager.clearInProgressUsers(c, wfi); WorkflowRequirementsManager.clearInProgressUsers(c, wfi);
//Remove all the tasks //Remove all the tasks
XmlWorkflowManager.deleteAllTasks(c, wfi); XmlWorkflowManager.deleteAllTasks(c, wfi);
@@ -216,32 +228,9 @@ public class XmlWorkflowManager {
Step nextStep = workflow.getNextStep(c, wfi, currentStep, currentOutcome.getResult()); Step nextStep = workflow.getNextStep(c, wfi, currentStep, currentOutcome.getResult());
if(nextStep!=null){ return processNextStep(c, user, workflow, currentOutcome, wfi, nextStep);
nextActionConfig = nextStep.getUserSelectionMethod();
nextActionConfig.getProcessingAction().activate(c, wfi);
// nextActionConfig.getProcessingAction().generateTasks();
if (nextActionConfig.requiresUI()) {
//Since a new step has been started, stop executing actions once one with a user interface is present.
c.restoreAuthSystemState();
return null;
} else {
ActionResult newOutcome = nextActionConfig.getProcessingAction().execute(c, wfi, nextStep, null);
c.restoreAuthSystemState();
return processOutcome(c, user, workflow, nextStep, nextActionConfig, newOutcome, wfi, true);
}
}else{
if(currentOutcome.getResult() != ActionResult.OUTCOME_COMPLETE){
c.restoreAuthSystemState();
throw new WorkflowException("No alternate step was found for outcome: " + currentOutcome.getResult());
}
archive(c, wfi);
c.restoreAuthSystemState();
return null;
}
}else{ }else{
//We are done with our actions so go to the submissions page but remove action ClaimedAction first //We are done with our actions so go to the submissions page but remove action ClaimedAction first
ClaimedTask task = ClaimedTask.findByWorkflowIdAndEPerson(c, wfi.getID(), user.getID());
deleteClaimedTask(c, wfi, task); deleteClaimedTask(c, wfi, task);
c.restoreAuthSystemState(); c.restoreAuthSystemState();
return null; return null;
@@ -254,6 +243,33 @@ public class XmlWorkflowManager {
throw new WorkflowException("Invalid step outcome"); throw new WorkflowException("Invalid step outcome");
} }
private static WorkflowActionConfig processNextStep(Context c, EPerson user, Workflow workflow, ActionResult currentOutcome, XmlWorkflowItem wfi, Step nextStep) throws SQLException, IOException, AuthorizeException, WorkflowException, WorkflowConfigurationException {
WorkflowActionConfig nextActionConfig;
if(nextStep!=null){
nextActionConfig = nextStep.getUserSelectionMethod();
nextActionConfig.getProcessingAction().activate(c, wfi);
// nextActionConfig.getProcessingAction().generateTasks();
if (nextActionConfig.requiresUI()) {
//Since a new step has been started, stop executing actions once one with a user interface is present.
c.restoreAuthSystemState();
return null;
} else {
ActionResult newOutcome = nextActionConfig.getProcessingAction().execute(c, wfi, nextStep, null);
c.restoreAuthSystemState();
return processOutcome(c, user, workflow, nextStep, nextActionConfig, newOutcome, wfi, true);
}
}else{
if(currentOutcome.getResult() != ActionResult.OUTCOME_COMPLETE){
c.restoreAuthSystemState();
throw new WorkflowException("No alternate step was found for outcome: " + currentOutcome.getResult());
}
archive(c, wfi);
c.restoreAuthSystemState();
return null;
}
}
/** /**
* Commit the contained item to the main archive. The item is associated * Commit the contained item to the main archive. The item is associated
@@ -593,6 +609,10 @@ public class XmlWorkflowManager {
// Add to item as a DC field // Add to item as a DC field
myitem.addMetadata(MetadataSchema.DC_SCHEMA, "description", "provenance", "en", provDescription); myitem.addMetadata(MetadataSchema.DC_SCHEMA, "description", "provenance", "en", provDescription);
//Clear any workflow schema related metadata
myitem.clearMetadata(WorkflowRequirementsManager.WORKFLOW_SCHEMA, Item.ANY, Item.ANY, Item.ANY);
myitem.update(); myitem.update();
//Restore permissions for the submitter //Restore permissions for the submitter

View File

@@ -82,6 +82,9 @@ public class RestartWorkflow {
if (line.hasOption('e')) // eperson if (line.hasOption('e')) // eperson
{ {
eperson = line.getOptionValue('e'); eperson = line.getOptionValue('e');
}else{
System.out.println("The -e (eperson) option is mandatory !");
System.exit(1);
} }
// find the EPerson, assign to context // find the EPerson, assign to context

View File

@@ -59,7 +59,7 @@ public class ScoreEvaluationAction extends ProcessingAction{
//Wether or not we have passed, clear our score information //Wether or not we have passed, clear our score information
wfi.getItem().clearMetadata(WorkflowRequirementsManager.WORKFLOW_SCHEMA, "score", null, Item.ANY); wfi.getItem().clearMetadata(WorkflowRequirementsManager.WORKFLOW_SCHEMA, "score", null, Item.ANY);
String provDescription = getProvenanceStartId() + " Approved for entry into archive with a score of: " + totalScoreCount; String provDescription = getProvenanceStartId() + " Approved for entry into archive with a score of: " + scoreMean;
wfi.getItem().addMetadata(MetadataSchema.DC_SCHEMA, "description", "provenance", "en", provDescription); wfi.getItem().addMetadata(MetadataSchema.DC_SCHEMA, "description", "provenance", "en", provDescription);
wfi.getItem().update(); wfi.getItem().update();
} }

View File

@@ -10,6 +10,7 @@ package org.dspace.xmlworkflow.storedcomponents;
import org.dspace.content.Collection; import org.dspace.content.Collection;
import org.dspace.content.Item; import org.dspace.content.Item;
import org.dspace.content.InProgressSubmission; import org.dspace.content.InProgressSubmission;
import org.dspace.core.ConfigurationManager;
import org.dspace.core.Context; import org.dspace.core.Context;
import org.dspace.core.LogManager; import org.dspace.core.LogManager;
import org.dspace.storage.rdbms.TableRow; import org.dspace.storage.rdbms.TableRow;
@@ -28,7 +29,7 @@ import java.io.IOException;
/** /**
* Class representing an item going through the workflow process in DSpace * Class representing an item going through the workflow process in DSpace
* *
* @author Bram De Schouwer (bram.deschouwer at dot com) * @author Bram De Schouwer (bram.deschouwer at dot com)
* @author Kevin Van de Velde (kevin at atmire dot com) * @author Kevin Van de Velde (kevin at atmire dot com)
* @author Ben Bosman (ben at atmire dot com) * @author Ben Bosman (ben at atmire dot com)
@@ -179,46 +180,45 @@ public class XmlWorkflowItem implements InProgressSubmission {
if(collectionId != -1){ if(collectionId != -1){
query.append("WHERE collection_id=").append(collectionId); query.append("WHERE collection_id=").append(collectionId);
} }
int offset = (page - 1) * pagesize;
query.append(" LIMIT ").append(pagesize).append(" OFFSET ").append((page - 1) * pagesize); if ("oracle".equals(ConfigurationManager.getProperty("db.name"))) {
TableRowIterator tri = DatabaseManager.queryTable(c, "xmlwf_workflowitem", // First prepare the query to generate row numbers
query.toString()); if (pagesize > 0 || offset > 0) {
query.insert(0, "SELECT /*+ FIRST_ROWS(n) */ rec.*, ROWNUM rnum FROM (");
try query.append(") ");
{ }
// make a list of workflow items // Restrict the number of rows returned based on the limit
while (tri.hasNext()) if (pagesize > 0) {
{ query.append("rec WHERE rownum<=? ");
TableRow row = tri.next(); // If we also have an offset, then convert the limit into the maximum row number
XmlWorkflowItem wi = new XmlWorkflowItem(c, row); if (offset > 0) {
wfItems.add(wi); pagesize += offset;
}
}
// Return only the records after the specified offset (row number)
if (offset > 0) {
query.insert(0, "SELECT * FROM (");
query.append(") WHERE rnum>?");
}
} else {
if (pagesize > 0) {
query.append(" LIMIT ? ");
}
if (offset > 0) {
query.append(" OFFSET ? ");
} }
} }
finally String queryString = query.toString();
{ Object[] paramArr = new Object[]{};
if (tri != null) if (pagesize > 0 && offset > 0) {
tri.close(); paramArr = new Object[]{pagesize, offset};
} else if (pagesize > 0) {
paramArr = new Object[]{pagesize};
} else if (offset > 0) {
paramArr = new Object[]{offset};
} }
// Get all the epeople that match the query
XmlWorkflowItem[] wfArray = new XmlWorkflowItem[wfItems.size()]; TableRowIterator tri = DatabaseManager.query(c, queryString, paramArr);
wfArray = (XmlWorkflowItem[]) wfItems.toArray(wfArray);
return wfArray;
}
/**
* return all workflowitems in one step
*
* @param c active context
* @return WorkflowItem [] of all workflows in system
*/
public static XmlWorkflowItem[] findAllInStep(Context c, int page, int pagesize, String step_id) throws SQLException, AuthorizeException, IOException, WorkflowConfigurationException {
List wfItems = new ArrayList();
TableRowIterator tri = DatabaseManager.queryTable(c, "xmlwf_workflowitem",
"SELECT * FROM xmlwf_workflowitem, xmlwf_claimtask, xmlwf_pooltask " +
"WHERE (xmlwf_workflowitem.workflowitem_id=xmlwf_claimtask.workflowitem_id AND xmlwf_claimtask="+step_id+") " +
"OR (xmlwf_workflowitem.workflowitem_id=xmlwf_pooltask.workflowitem_id AND xmlwf_pooltask="+step_id+") LIMIT "+pagesize+" OFFSET "+ ((page-1)*pagesize));
try try
{ {
// make a list of workflow items // make a list of workflow items

View File

@@ -189,7 +189,7 @@ public class Submissions extends AbstractDSpaceTransformer
} }
} }
Division unfinished = division.addInteractiveDivision("unfinished-submisions", contextPath+"/submit", Division.METHOD_POST); Division unfinished = division.addDivision("unfinished-submisions");
unfinished.setHead(T_s_head2); unfinished.setHead(T_s_head2);
Para p = unfinished.addPara(); Para p = unfinished.addPara();
p.addContent(T_s_info2a); p.addContent(T_s_info2a);

View File

@@ -118,19 +118,19 @@
<message key="xmlui.XMLWorkflow.default.editstep.claimaction">Accept/Edit/Reject</message> <message key="xmlui.XMLWorkflow.default.editstep.claimaction">Accept/Edit/Reject</message>
<message key="xmlui.XMLWorkflow.default.editstep.editaction">Accept/Edit/Reject</message> <message key="xmlui.XMLWorkflow.default.editstep.editaction">Accept/Edit/Reject</message>
<message key="xmlui.XMLWorkflow.default.finaleditstep">Final Accept/Edit/Reject</message> <message key="xmlui.XMLWorkflow.default.finaleditstep">Final Accept/Edit</message>
<message key="xmlui.XMLWorkflow.default.finaleditstep.claimaction">Final Accept/Edit/Reject</message> <message key="xmlui.XMLWorkflow.default.finaleditstep.claimaction">Final Accept/Edit</message>
<message key="xmlui.XMLWorkflow.default.finaleditstep.finaleditaction">Final Accept/Edit/Reject</message> <message key="xmlui.XMLWorkflow.default.finaleditstep.finaleditaction">Final Accept/Edit</message>
<message key="xmlui.XMLWorkflow.default.selectSingleReviewer.selectReviewerStep.claimaction">Assign reviewer step</message> <message key="xmlui.XMLWorkflow.selectSingleReviewer.selectReviewerStep.claimaction">Assign reviewer step</message>
<message key="xmlui.XMLWorkflow.default.selectSingleReviewer.selectReviewerStep.selectrevieweraction">Assign reviewer</message> <message key="xmlui.XMLWorkflow.selectSingleReviewer.selectReviewerStep.selectrevieweraction">Assign reviewer</message>
<message key="xmlui.XMLWorkflow.default.selectSingleReviewer.singleUserReviewStep">Single user review step</message> <message key="xmlui.XMLWorkflow.selectSingleReviewer.singleUserReviewStep">Single user review step</message>
<message key="xmlui.XMLWorkflow.default.selectSingleReviewer.singleUserReviewStep.singleuserreviewaction">Review submission</message> <message key="xmlui.XMLWorkflow.selectSingleReviewer.singleUserReviewStep.singleuserreviewaction">Review submission</message>
<message key="xmlui.XMLWorkflow.default.scoreReview.scoreReviewStep.claimaction">Score review</message> <message key="xmlui.XMLWorkflow.scoreReview.scoreReviewStep.claimaction">Score review</message>
<message key="xmlui.XMLWorkflow.default.scoreReview.scoreReviewStep.scorereviewaction">Score review</message> <message key="xmlui.XMLWorkflow.scoreReview.scoreReviewStep.scorereviewaction">Score review</message>
<message key="xmlui.XMLWorkflow.default.scoreReview.scoreReviewStep">Score review</message> <message key="xmlui.XMLWorkflow.scoreReview.scoreReviewStep">Score review</message>
</catalogue> </catalogue>

View File

@@ -1,24 +1,27 @@
-- Convert workflow groups: -- Convert workflow groups:
-- TODO: is 'to_number' ok? do not forget to change role_id values -- TODO: is 'to_number' ok? do not forget to change role_id values
INSERT INTO xmlwf_collectionrole (role_id, group_id, collection_id) INSERT INTO xmlwf_collectionrole (collectionrole_id, role_id, group_id, collection_id)
SELECT SELECT
xmlwf_collectionrole_seq.nextval as collectionrole_id,
'reviewer' AS role_id, 'reviewer' AS role_id,
eperson_group_id AS group_id, eperson_group_id AS group_id,
to_number(replace(replace(name, 'COLLECTION_', ''), '_WORKFLOW_STEP_1', '')) AS collection_id to_number(replace(replace(name, 'COLLECTION_', ''), '_WORKFLOW_STEP_1', '')) AS collection_id
FROM epersongroup FROM epersongroup
WHERE name LIKE 'COLLECTION_%_WORKFLOW_STEP_1'; WHERE name LIKE 'COLLECTION_%_WORKFLOW_STEP_1';
INSERT INTO xmlwf_collectionrole (role_id, group_id, collection_id) INSERT INTO xmlwf_collectionrole (collectionrole_id, role_id, group_id, collection_id)
SELECT SELECT
xmlwf_collectionrole_seq.nextval as collectionrole_id,
'editor' AS role_id, 'editor' AS role_id,
eperson_group_id AS group_id, eperson_group_id AS group_id,
to_number(replace(replace(name, 'COLLECTION_', ''), '_WORKFLOW_STEP_2', '')) AS collection_id to_number(replace(replace(name, 'COLLECTION_', ''), '_WORKFLOW_STEP_2', '')) AS collection_id
FROM epersongroup FROM epersongroup
WHERE name LIKE 'COLLECTION_%_WORKFLOW_STEP_2'; WHERE name LIKE 'COLLECTION_%_WORKFLOW_STEP_2';
INSERT INTO xmlwf_collectionrole (role_id, group_id, collection_id) INSERT INTO xmlwf_collectionrole (collectionrole_id, role_id, group_id, collection_id)
SELECT SELECT
xmlwf_collectionrole_seq.nextval as collectionrole_id,
'finaleditor' AS role_id, 'finaleditor' AS role_id,
eperson_group_id AS group_id, eperson_group_id AS group_id,
to_number(replace(replace(name, 'COLLECTION_', ''), '_WORKFLOW_STEP_3', '')) AS collection_id to_number(replace(replace(name, 'COLLECTION_', ''), '_WORKFLOW_STEP_3', '')) AS collection_id
@@ -39,8 +42,9 @@ FROM workflowitem;
-- Migrate claimed tasks -- Migrate claimed tasks
INSERT INTO xmlwf_claimtask (workflowitem_id, workflow_id, step_id, action_id, owner_id) INSERT INTO xmlwf_claimtask (claimtask_id,workflowitem_id, workflow_id, step_id, action_id, owner_id)
SELECT SELECT
xmlwf_claimtask_seq.nextval AS claimtask_id,
workflow_id AS workflowitem_id, workflow_id AS workflowitem_id,
'default' AS workflow_id, 'default' AS workflow_id,
'reviewstep' AS step_id, 'reviewstep' AS step_id,
@@ -48,8 +52,9 @@ workflow_id AS workflowitem_id,
owner AS owner_id owner AS owner_id
FROM workflowitem WHERE owner IS NOT NULL AND state = 2; FROM workflowitem WHERE owner IS NOT NULL AND state = 2;
INSERT INTO xmlwf_claimtask (workflowitem_id, workflow_id, step_id, action_id, owner_id) INSERT INTO xmlwf_claimtask (claimtask_id,workflowitem_id, workflow_id, step_id, action_id, owner_id)
SELECT SELECT
xmlwf_claimtask_seq.nextval AS claimtask_id,
workflow_id AS workflowitem_id, workflow_id AS workflowitem_id,
'default' AS workflow_id, 'default' AS workflow_id,
'editstep' AS step_id, 'editstep' AS step_id,
@@ -57,8 +62,9 @@ workflow_id AS workflowitem_id,
owner AS owner_id owner AS owner_id
FROM workflowitem WHERE owner IS NOT NULL AND state = 4; FROM workflowitem WHERE owner IS NOT NULL AND state = 4;
INSERT INTO xmlwf_claimtask (workflowitem_id, workflow_id, step_id, action_id, owner_id) INSERT INTO xmlwf_claimtask (claimtask_id,workflowitem_id, workflow_id, step_id, action_id, owner_id)
SELECT SELECT
xmlwf_claimtask_seq.nextval AS claimtask_id,
workflow_id AS workflowitem_id, workflow_id AS workflowitem_id,
'default' AS workflow_id, 'default' AS workflow_id,
'finaleditstep' AS step_id, 'finaleditstep' AS step_id,
@@ -68,8 +74,9 @@ FROM workflowitem WHERE owner IS NOT NULL AND state = 6;
-- Migrate pooled tasks -- Migrate pooled tasks
INSERT INTO xmlwf_pooltask (workflowitem_id, workflow_id, step_id, action_id, group_id) INSERT INTO xmlwf_pooltask (pooltask_id,workflowitem_id, workflow_id, step_id, action_id, group_id)
SELECT SELECT
xmlwf_pooltask_seq.nextval AS pooltask_id,
workflowitem.workflow_id AS workflowitem_id, workflowitem.workflow_id AS workflowitem_id,
'default' AS workflow_id, 'default' AS workflow_id,
'reviewstep' AS step_id, 'reviewstep' AS step_id,
@@ -78,8 +85,9 @@ xmlwf_collectionrole.group_id AS group_id
FROM workflowitem INNER JOIN xmlwf_collectionrole ON workflowitem.collection_id = xmlwf_collectionrole.collection_id FROM workflowitem INNER JOIN xmlwf_collectionrole ON workflowitem.collection_id = xmlwf_collectionrole.collection_id
WHERE workflowitem.owner IS NULL AND workflowitem.state = 1 AND xmlwf_collectionrole.role_id = 'reviewer'; WHERE workflowitem.owner IS NULL AND workflowitem.state = 1 AND xmlwf_collectionrole.role_id = 'reviewer';
INSERT INTO xmlwf_pooltask (workflowitem_id, workflow_id, step_id, action_id, group_id) INSERT INTO xmlwf_pooltask (pooltask_id,workflowitem_id, workflow_id, step_id, action_id, group_id)
SELECT SELECT
xmlwf_pooltask_seq.nextval AS pooltask_id,
workflowitem.workflow_id AS workflowitem_id, workflowitem.workflow_id AS workflowitem_id,
'default' AS workflow_id, 'default' AS workflow_id,
'editstep' AS step_id, 'editstep' AS step_id,
@@ -88,8 +96,9 @@ xmlwf_collectionrole.group_id AS group_id
FROM workflowitem INNER JOIN xmlwf_collectionrole ON workflowitem.collection_id = xmlwf_collectionrole.collection_id FROM workflowitem INNER JOIN xmlwf_collectionrole ON workflowitem.collection_id = xmlwf_collectionrole.collection_id
WHERE workflowitem.owner IS NULL AND workflowitem.state = 3 AND xmlwf_collectionrole.role_id = 'editor'; WHERE workflowitem.owner IS NULL AND workflowitem.state = 3 AND xmlwf_collectionrole.role_id = 'editor';
INSERT INTO xmlwf_pooltask (workflowitem_id, workflow_id, step_id, action_id, group_id) INSERT INTO xmlwf_pooltask (pooltask_id,workflowitem_id, workflow_id, step_id, action_id, group_id)
SELECT SELECT
xmlwf_pooltask_seq.nextval AS pooltask_id,
workflowitem.workflow_id AS workflowitem_id, workflowitem.workflow_id AS workflowitem_id,
'default' AS workflow_id, 'default' AS workflow_id,
'finaleditstep' AS step_id, 'finaleditstep' AS step_id,
@@ -98,6 +107,21 @@ xmlwf_collectionrole.group_id AS group_id
FROM workflowitem INNER JOIN xmlwf_collectionrole ON workflowitem.collection_id = xmlwf_collectionrole.collection_id FROM workflowitem INNER JOIN xmlwf_collectionrole ON workflowitem.collection_id = xmlwf_collectionrole.collection_id
WHERE workflowitem.owner IS NULL AND workflowitem.state = 5 AND xmlwf_collectionrole.role_id = 'finaleditor'; WHERE workflowitem.owner IS NULL AND workflowitem.state = 5 AND xmlwf_collectionrole.role_id = 'finaleditor';
-- Delete resource policies for workflowitems before creating new ones
DELETE FROM resourcepolicy
WHERE resource_type_id = 2 AND resource_id IN
(SELECT item_id FROM workflowitem);
DELETE FROM resourcepolicy
WHERE resource_type_id = 1 AND resource_id IN
(SELECT item2bundle.bundle_id FROM
(workflowitem INNER JOIN item2bundle ON workflowitem.item_id = item2bundle.item_id));
DELETE FROM resourcepolicy
WHERE resource_type_id = 0 AND resource_id IN
(SELECT bundle2bitstream.bitstream_id FROM
((workflowitem INNER JOIN item2bundle ON workflowitem.item_id = item2bundle.item_id)
INNER JOIN bundle2bitstream ON item2bundle.bundle_id = bundle2bitstream.bundle_id);
-- Create policies for claimtasks -- Create policies for claimtasks
-- public static final int BITSTREAM = 0; -- public static final int BITSTREAM = 0;
-- public static final int BUNDLE = 1; -- public static final int BUNDLE = 1;

View File

@@ -104,4 +104,4 @@ ADD CONSTRAINT xmlwf_in_progress_user_unique UNIQUE (workflowitem_id, user_id);
CREATE INDEX xmlwf_ipu_wf_fk_idx ON xmlwf_in_progress_user(workflowitem_id); CREATE INDEX xmlwf_ipu_wf_fk_idx ON xmlwf_in_progress_user(workflowitem_id);
CREATE INDEX xmlwf_ipu_epers_fk_idx ON xmlwf_in_progress_user(user_id); CREATE INDEX xmlwf_ipu_epers_fk_idx ON xmlwf_in_progress_user(user_id);
-- TODO: it seems like this index is already created by the 'unique' constraint in the table creation -- TODO: it seems like this index is already created by the 'unique' constraint in the table creation
-- CREATE INDEX xmlwf_ipu_wf_epers_fk_idx ON xmlwf_in_progress_user(workflowitem_id,user_id); -- CREATE INDEX xmlwf_ipu_wf_epers_fk_idx ON xmlwf_in_progress_user(workflowitem_id,user_id);

View File

@@ -96,6 +96,22 @@ xmlwf_collectionrole.group_id AS group_id
FROM workflowitem INNER JOIN xmlwf_collectionrole ON workflowitem.collection_id = xmlwf_collectionrole.collection_id FROM workflowitem INNER JOIN xmlwf_collectionrole ON workflowitem.collection_id = xmlwf_collectionrole.collection_id
WHERE workflowitem.owner IS NULL AND workflowitem.state = 5 AND xmlwf_collectionrole.role_id = 'finaleditor'; WHERE workflowitem.owner IS NULL AND workflowitem.state = 5 AND xmlwf_collectionrole.role_id = 'finaleditor';
-- Delete existing workflowitem policies
DELETE FROM resourcepolicy
WHERE resource_type_id = 2 AND resource_id IN
(SELECT item_id FROM workflowitem);
DELETE FROM resourcepolicy
WHERE resource_type_id = 1 AND resource_id IN
(SELECT item2bundle.bundle_id FROM
(workflowitem INNER JOIN item2bundle ON workflowitem.item_id = item2bundle.item_id));
DELETE FROM resourcepolicy
WHERE resource_type_id = 0 AND resource_id IN
(SELECT bundle2bitstream.bitstream_id FROM
((workflowitem INNER JOIN item2bundle ON workflowitem.item_id = item2bundle.item_id)
INNER JOIN bundle2bitstream ON item2bundle.bundle_id = bundle2bitstream.bundle_id));
-- Create policies for claimtasks -- Create policies for claimtasks
-- public static final int BITSTREAM = 0; -- public static final int BITSTREAM = 0;
@@ -228,12 +244,18 @@ FROM (((xmlwf_workflowitem INNER JOIN item ON xmlwf_workflowitem.item_id = item.
INSERT INTO xmlwf_in_progress_user (in_progress_user_id, workflowitem_id, user_id, finished) INSERT INTO xmlwf_in_progress_user (in_progress_user_id, workflowitem_id, user_id, finished)
SELECT SELECT
getnextid('xmlwf_in_progress_user') AS in_progress_user_id, getnextid('xmlwf_in_progress_user') AS in_progress_user_id,
xmlwf_workflowitem.item_id AS workflowitem_id, xmlwf_workflowitem.workflowitem_id AS workflowitem_id,
xmlwf_claimtask.owner_id AS user_id, xmlwf_claimtask.owner_id AS user_id,
BOOL(0) as finished BOOL(0) as finished
FROM FROM
(xmlwf_claimtask INNER JOIN xmlwf_workflowitem ON xmlwf_workflowitem.workflowitem_id = xmlwf_claimtask.workflowitem_id); (xmlwf_claimtask INNER JOIN xmlwf_workflowitem ON xmlwf_workflowitem.workflowitem_id = xmlwf_claimtask.workflowitem_id);
-- Delete the old tasks and workflowitems
-- This is important because otherwise the item can not be deleted
DELETE FROM tasklistitem;
DELETE FROM workflowitem;
-- Update the sequences -- Update the sequences
SELECT setval('xmlwf_workflowitem_seq', max(workflowitem_id)) FROM xmlwf_workflowitem; SELECT setval('xmlwf_workflowitem_seq', max(workflowitem_id)) FROM xmlwf_workflowitem;
SELECT setval('xmlwf_collectionrole_seq', max(collectionrole_id)) FROM xmlwf_collectionrole; SELECT setval('xmlwf_collectionrole_seq', max(collectionrole_id)) FROM xmlwf_collectionrole;