/**
* The contents of this file are subject to the license and copyright
* detailed in the LICENSE and NOTICE files at the root of the source
* tree and available online at
*
* http://www.dspace.org/license/
*/
package org.dspace.xmlworkflow.state.actions.processingaction;
import org.dspace.app.util.Util;
import org.dspace.authorize.AuthorizeException;
import org.dspace.core.Context;
import org.dspace.xmlworkflow.WorkflowException;
import org.dspace.xmlworkflow.WorkflowRequirementsManager;
import org.dspace.xmlworkflow.state.Step;
import org.dspace.xmlworkflow.state.actions.ActionResult;
import org.dspace.xmlworkflow.storedcomponents.XmlWorkflowItem;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.sql.SQLException;
/**
*
* This action will allow multiple users to rate a certain item
* if the mean of this score is higher then the minimum score the
* item will be sent to the next action/step else it will be rejected
*
* @author Bram De Schouwer (bram.deschouwer at dot com)
* @author Kevin Van de Velde (kevin at atmire dot com)
* @author Ben Bosman (ben at atmire dot com)
* @author Mark Diggory (markd at atmire dot com)
*/
public class ScoreReviewAction extends ProcessingAction{
@Override
public void activate(Context c, XmlWorkflowItem wf) throws SQLException, IOException, AuthorizeException, WorkflowException {
}
@Override
public ActionResult execute(Context c, XmlWorkflowItem wfi, Step step, HttpServletRequest request) throws SQLException, AuthorizeException, IOException, WorkflowException {
if(request.getParameter("submit_score") != null){
int score = Util.getIntParameter(request, "score");
//Add our score to the metadata
wfi.getItem().addMetadata(WorkflowRequirementsManager.WORKFLOW_SCHEMA, "score", null, null, String.valueOf(score));
wfi.getItem().update();
return new ActionResult(ActionResult.TYPE.TYPE_OUTCOME, ActionResult.OUTCOME_COMPLETE);
}else{
//We have pressed the leave button so return to our submission page
return new ActionResult(ActionResult.TYPE.TYPE_SUBMISSION_PAGE);
}
}
}