mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-14 05:23:14 +00:00
Merge pull request #75 from atmire/dspace3-workflow
[DS-1249] Configurable Workflow Improvements
This commit is contained in:
@@ -310,7 +310,8 @@ public class DescribeStep extends AbstractProcessingStep
|
||||
DCValue[] values = item.getMetadata(inputs[i].getSchema(),
|
||||
inputs[i].getElement(), inputs[i].getQualifier(), Item.ANY);
|
||||
|
||||
if (inputs[i].isRequired() && values.length == 0)
|
||||
if ((inputs[i].isRequired() && values.length == 0) &&
|
||||
inputs[i].isVisible(subInfo.isInWorkflow() ? DCInput.WORKFLOW_SCOPE : DCInput.SUBMISSION_SCOPE))
|
||||
{
|
||||
// since this field is missing add to list of error fields
|
||||
addErrorField(request, getFieldName(inputs[i]));
|
||||
|
@@ -86,7 +86,7 @@ public class UsageEvent extends Event {
|
||||
return objText + ":" + action.text();
|
||||
}catch(Exception e)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
return "";
|
||||
|
||||
|
@@ -15,12 +15,10 @@ import org.dspace.core.ConfigurationManager;
|
||||
import org.dspace.core.Email;
|
||||
import org.dspace.core.I18nUtil;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.dspace.eperson.EPerson;
|
||||
import org.dspace.eperson.Group;
|
||||
import org.dspace.xmlworkflow.state.Workflow;
|
||||
import org.dspace.xmlworkflow.storedcomponents.CollectionRole;
|
||||
|
||||
import javax.mail.MessagingException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.io.IOException;
|
||||
import java.sql.SQLException;
|
||||
@@ -211,9 +209,13 @@ public class WorkflowUtils extends Util{
|
||||
/*
|
||||
* Deletes a role group linked to a given role and a collection
|
||||
*/
|
||||
public static void deleteRoleGroup(Context context, int collectionID, String roleID) throws SQLException {
|
||||
CollectionRole ass = CollectionRole.find(context,collectionID,roleID);
|
||||
ass.delete();
|
||||
public static void deleteRoleGroup(Context context, Collection collection, String roleID) throws SQLException, IOException, WorkflowConfigurationException {
|
||||
Workflow workflow = WorkflowFactory.getWorkflow(collection);
|
||||
Role role = workflow.getRoles().get(roleID);
|
||||
if(role.getScope() == Role.Scope.COLLECTION){
|
||||
CollectionRole ass = CollectionRole.find(context, collection.getID(), roleID);
|
||||
ass.delete();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -236,6 +238,46 @@ public class WorkflowUtils extends Util{
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
public static HashMap<String, Role> getCollectionAndRepositoryRoles(Collection thisCollection) throws IOException, WorkflowConfigurationException {
|
||||
Workflow workflow = WorkflowFactory.getWorkflow(thisCollection);
|
||||
LinkedHashMap<String, Role> result = new LinkedHashMap<String, Role>();
|
||||
if(workflow != null){
|
||||
//Make sure we find one
|
||||
HashMap<String, Role> allRoles = workflow.getRoles();
|
||||
//We have retrieved all our roles, not get the ones which can be configured by the collection
|
||||
for(String roleId : allRoles.keySet()){
|
||||
Role role = allRoles.get(roleId);
|
||||
// We just require the roles which have a scope of collection
|
||||
if((role.getScope() == Role.Scope.COLLECTION || role.getScope() == Role.Scope.REPOSITORY) && !role.isInternal()){
|
||||
result.put(roleId, role);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
public static HashMap<String, Role> getAllExternalRoles(Collection thisCollection) throws IOException, WorkflowConfigurationException {
|
||||
Workflow workflow = WorkflowFactory.getWorkflow(thisCollection);
|
||||
LinkedHashMap<String, Role> result = new LinkedHashMap<String, Role>();
|
||||
if(workflow != null){
|
||||
//Make sure we find one
|
||||
HashMap<String, Role> allRoles = workflow.getRoles();
|
||||
//We have retrieved all our roles, not get the ones which can be configured by the collection
|
||||
for(String roleId : allRoles.keySet()){
|
||||
Role role = allRoles.get(roleId);
|
||||
// We just require the roles which have a scope of collection
|
||||
if(!role.isInternal()){
|
||||
result.put(roleId, role);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public static Group getRoleGroup(Context context, int collectionId, Role role) throws SQLException {
|
||||
if(role.getScope() == Role.Scope.REPOSITORY){
|
||||
return Group.findByName(context, role.getName());
|
||||
|
Reference in New Issue
Block a user