Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Workflow enhancements: restart, archive and edit workflow #117

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
38e0138
RF41373: Restart and archiving a workflow
veggiematts Apr 11, 2016
e4ba09f
RF41373: Restart and archiving a workflow
veggiematts Apr 19, 2016
491085e
RF41373: Restart and archiving a workflow
veggiematts Apr 21, 2016
914cde5
RF41373: Restart and archiving a workflow
veggiematts Apr 26, 2016
e4d497f
RF41373: Restart and archiving a workflow
veggiematts Apr 28, 2016
39b524e
RF41373: Restart and archiving a workflow
veggiematts Apr 28, 2016
e43bf53
RF41373: Restart and archiving a workflow
veggiematts Apr 28, 2016
2afd3c5
RF41373: Restart and archiving a workflow
veggiematts May 3, 2016
777f562
RF41380: Add a step in a resource workflow
veggiematts May 10, 2016
080fa3e
RF41380: Add a step in a resource workflow
veggiematts May 11, 2016
a71aeeb
RF41380: Add a step in a resource workflow
veggiematts May 12, 2016
33a2e80
RF41380: Add a step in a resource workflow
veggiematts May 12, 2016
20362a2
RF41373: Restart and archiving a workflow
veggiematts May 19, 2016
80d48e3
RF41380: Add a step in a resource workflow
veggiematts May 19, 2016
0eafef7
RF41380: Add a step in a resource workflow
veggiematts May 19, 2016
73829b1
RF41380: Add a step in a resource workflow
veggiematts May 20, 2016
f5085fe
RF41380: Add a step in a resource workflow
veggiematts May 20, 2016
0d69556
RF41380: Add a step in a resource workflow
veggiematts May 20, 2016
d1712d5
RF41380: Add a step in a resource workflow
veggiematts May 25, 2016
722e881
RF41380: Add a step in a resource workflow
veggiematts May 26, 2016
169d96a
RF41380: Add a step in a resource workflow
veggiematts May 27, 2016
6ff1624
Merge branch 'RF41373_restart_and_archiving_a_workflow' into RF41380_…
veggiematts Jun 8, 2016
185559d
RF41380: Add a step in a resource workflow
veggiematts May 25, 2016
f43d696
RF41380: Add a step in a resource workflow
veggiematts Jun 23, 2016
5cdab1f
RF41380: Add a step in a resource workflow
veggiematts Jul 4, 2016
144f758
RF41380 [Follow-up]: Add a step in a resource workflow
veggiematts Jul 7, 2016
021a61f
RF41380: Add a step in a resource workflow
veggiematts Jul 12, 2016
7499f17
RF41373: Restart and archiving a workflow
veggiematts Jul 27, 2016
cdf556b
RF41373: Restart and archiving a workflow
veggiematts Aug 31, 2016
6dff0db
Merge branch 'RF41380_Add_a_step_in_a_resource_workflow_with_archivin…
veggiematts Sep 13, 2016
3656bc9
Merge remote-tracking branch 'origin/master' into RF41380_Add_a_step_…
veggiematts Nov 21, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion resources/admin/classes/domain/AcquisitionType.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,16 @@ public function getNumberOfChildren(){

}

public function getAcquisitionTypeIDByName($name) {
$query = "SELECT acquisitionTypeID from AcquisitionType WHERE UPPER(shortName) = '" . strtoupper($name) . "';";

$result = $this->db->processQuery($query, 'assoc');

return $result['acquisitionTypeID'];

}


}

?>
?>
95 changes: 87 additions & 8 deletions resources/admin/classes/domain/Resource.php
Original file line number Diff line number Diff line change
Expand Up @@ -1845,7 +1845,7 @@ public function removeResourceSteps() {

$query = "DELETE
FROM ResourceStep
WHERE resourceID = '" . $this->resourceID . "'";
WHERE resourceID = '" . $this->resourceID . "' AND archivingDate IS NOT NULL";

$result = $this->db->processQuery($query);
}
Expand Down Expand Up @@ -1949,7 +1949,7 @@ public function getResourceSteps() {

$query = "SELECT * FROM ResourceStep
WHERE resourceID = '" . $this->resourceID . "'
ORDER BY displayOrderSequence, stepID";
ORDER BY (archivingDate IS NOT NULL), archivingDate DESC, displayOrderSequence, stepID";

$result = $this->db->processQuery($query, 'assoc');

Expand All @@ -1966,6 +1966,65 @@ public function getResourceSteps() {

}

public function getCurrentWorkflowID() {
$query = "SELECT Step.workflowID FROM Step, ResourceStep
WHERE ResourceStep.resourceID = '" . $this->resourceID . "'
AND ResourceStep.archivingDate IS NULL
AND ResourceStep.stepID = Step.stepID LIMIT 1";

$result = $this->db->processQuery($query, 'assoc');
return $result['workflowID'];
}

public function getCurrentWorkflowResourceSteps(){
$query = "SELECT * FROM ResourceStep
WHERE resourceID = '" . $this->resourceID . "'
AND archivingDate IS NULL ORDER BY displayOrderSequence, stepID";

$result = $this->db->processQuery($query, 'assoc');

$objects = array();

//need to do this since it could be that there's only one request and this is how the dbservice returns result
if (isset($result['resourceStepID'])){
$object = new ResourceStep(new NamedArguments(array('primaryKey' => $result['resourceStepID'])));
array_push($objects, $object);
}else{
foreach ($result as $row) {
$object = new ResourceStep(new NamedArguments(array('primaryKey' => $row['resourceStepID'])));
array_push($objects, $object);
}
}

return $objects;

}

public function isCurrentWorkflowComplete() {
$steps = $this->getCurrentWorkflowResourceSteps();
foreach ($steps as $step) {
if (!$step->isComplete()) return false;
}
return true;
}


public function getDistinctWorkflows() {
$query = "SELECT DISTINCT archivingDate FROM ResourceStep
WHERE resourceID = '" . $this->resourceID . "'
AND archivingDate IS NOT NULL
ORDER BY archivingDate ASC";

$result = $this->db->processQuery($query, 'assoc');

return $result;

}


public function getArchivedResourceSteps() {
return $this->getResourceSteps(true);
}


//returns first steps (object) in the workflow for this resource
Expand All @@ -1974,6 +2033,7 @@ public function getFirstSteps() {
$query = "SELECT * FROM ResourceStep
WHERE resourceID = '" . $this->resourceID . "'
AND (priorStepID is null OR priorStepID = '0')
AND archivingDate IS NULL
ORDER BY stepID";

$result = $this->db->processQuery($query, 'assoc');
Expand All @@ -1990,15 +2050,22 @@ public function getFirstSteps() {
return $objects;
}

public function archiveWorkflow() {

// And archive the workflow
$query = "UPDATE ResourceStep SET archivingDate=NOW() WHERE archivingDate IS NULL AND resourceID = '" . $this->resourceID . "'";
$result = $this->db->processQuery($query);
}

public function deleteWorkflow() {
$query = "DELETE FROM ResourceStep WHERE archivingDate IS NULL AND resourceID = '" . $this->resourceID . "'";
$result = $this->db->processQuery($query);
}

//enters resource into new workflow
public function enterNewWorkflow() {
public function enterNewWorkflow($workflowID = null){
$config = new Configuration();

//remove any current workflow steps
$this->removeResourceSteps();

//make sure this resource is marked in progress in case it was archived
$status = new Status();
$this->statusID = $status->getIDFromName('progress');
Expand All @@ -2007,11 +2074,23 @@ public function enterNewWorkflow() {

//Determine the workflow this resource belongs to
$workflowObj = new Workflow();
$workflowID = $workflowObj->getWorkflowID($this->resourceTypeID, $this->resourceFormatID, $this->acquisitionTypeID);

if ($workflowID) {
if ($workflowID == null) {
$workflowID = $workflowObj->getWorkflowID($this->resourceTypeID, $this->resourceFormatID, $this->acquisitionTypeID);
}
if ($workflowID){

$workflow = new Workflow(new NamedArguments(array('primaryKey' => $workflowID)));
$resourceTypeObj = new ResourceType();
$resourceFormatObj = new ResourceFormat();
$acquisitionTypeObj = new AcquisitionType();

//set new resourceType, resourceFormat and acquisitionType for the resource, according to the selected workflow
$this->resourceTypeID = ($workflow->resourceTypeIDValue != null) ? $workflow->resourceTypeIDValue : $resourceTypeObj->getResourceTypeIDByName('any');
$this->resourceFormatID = ($workflow->resourceFormatIDValue != null) ? $workflow->resourceFormatIDValue : $resourceFormatObj->getResourceFormatIDByName('any');
$this->acquisitionTypeID = ($workflow->acquisitionTypeIDValue != null) ? $workflow->acquisitionTypeIDValue : $acquisitionTypeObj->getAcquisitionTypeIDByName('any');

$this->save();

//Copy all of the step attributes for this workflow to a new resource step
foreach ($workflow->getSteps() as $step) {
Expand Down
12 changes: 11 additions & 1 deletion resources/admin/classes/domain/ResourceFormat.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,18 @@ public function getNumberOfChildren(){

}

public function getResourceFormatIDByName($name) {
$query = "SELECT resourceFormatID from ResourceFormat WHERE UPPER(shortName) = '" . strtoupper($name) . "';";

$result = $this->db->processQuery($query, 'assoc');

return $result['resourceFormatID'];

}




}

?>
?>
6 changes: 4 additions & 2 deletions resources/admin/classes/domain/ResourceStep.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,9 @@ public function getPriorStep(){
}



public function isComplete() {
return $this->stepEndDate ? true : false;
}


//returns array of resource step objects
Expand Down Expand Up @@ -241,4 +243,4 @@ public function sendReassignedStepNotification(){

}

?>
?>
10 changes: 9 additions & 1 deletion resources/admin/classes/domain/ResourceType.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,15 @@ public function getNumberOfChildren(){

}

public function getResourceTypeIDByName($name) {
$query = "SELECT resourceTypeID from ResourceType WHERE UPPER(shortName) = '" . strtoupper($name) . "';";

$result = $this->db->processQuery($query, 'assoc');

return $result['resourceTypeID'];

}

}

?>
?>
2 changes: 2 additions & 0 deletions resources/ajax_forms/getAdminWorkflowForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
<td style='vertical-align:top;text-align:left;font-weight:bold;'><label for='acquisitionTypeID'><?php echo _("Acquisition Type:");?></label></td>
<td>
<select name='acquisitionTypeID' id='acquisitionTypeID' style='width:100px;' class='changeSelect' >
<option value=''></option>
<?php
foreach ($acquisitionTypeArray as $acquisitionType){
if (!(trim(strval($acquisitionType['acquisitionTypeID'])) != trim(strval($workflow->acquisitionTypeIDValue)))){
Expand All @@ -74,6 +75,7 @@
<td style='vertical-align:top;text-align:left;font-weight:bold;'><label for='resourceFormatID'><?php echo _("Format:");?></label></td>
<td>
<select name='resourceFormatID' id='resourceFormatID' style='width:100px;' class='changeSelect'>
<option value=''></option>
<?php
foreach ($resourceFormatArray as $resourceFormat){
if (!(trim(strval($resourceFormat['resourceFormatID'])) != trim(strval($workflow->resourceFormatIDValue)))){
Expand Down
Loading