Search in sources :

Example 11 with WorkspaceMaterialEvaluation

use of fi.otavanopisto.muikku.plugins.evaluation.model.WorkspaceMaterialEvaluation in project muikku by otavanopisto.

the class AcceptanceTestsRESTService method deleteWorkspaceMaterial.

@DELETE
@Path("/workspaces/{WORKSPACEENTITYID}/htmlmaterials/{WORKSPACEMATERIALID}")
@RESTPermit(handling = Handling.UNSECURED)
public Response deleteWorkspaceMaterial(@PathParam("WORKSPACEENTITYID") Long workspaceEntityId, @PathParam("WORKSPACEMATERIALID") Long workspaceMaterialId) {
    WorkspaceMaterial workspaceMaterial = workspaceMaterialController.findWorkspaceMaterialById(workspaceMaterialId);
    if (workspaceMaterial == null) {
        return Response.status(Status.NOT_FOUND).entity("Not Found").build();
    }
    HtmlMaterial htmlMaterial = htmlMaterialController.findHtmlMaterialById(workspaceMaterial.getMaterialId());
    if (htmlMaterial == null) {
        return Response.status(Status.BAD_REQUEST).entity("Not a html material").build();
    }
    try {
        workspaceMaterialController.deleteWorkspaceMaterial(workspaceMaterial, true);
    } catch (WorkspaceMaterialContainsAnswersExeption e) {
        return Response.status(Status.INTERNAL_SERVER_ERROR).entity(e.getMessage()).build();
    }
    List<WorkspaceMaterialEvaluation> evaluations = evaluationController.listWorkspaceMaterialEvaluationsByWorkspaceMaterialId(workspaceMaterialId);
    for (WorkspaceMaterialEvaluation evaluation : evaluations) {
        evaluationController.deleteWorkspaceMaterialEvaluation(evaluation);
    }
    htmlMaterialController.deleteHtmlMaterial(htmlMaterial);
    return Response.noContent().build();
}
Also used : WorkspaceMaterialEvaluation(fi.otavanopisto.muikku.plugins.evaluation.model.WorkspaceMaterialEvaluation) WorkspaceMaterialContainsAnswersExeption(fi.otavanopisto.muikku.plugins.workspace.WorkspaceMaterialContainsAnswersExeption) HtmlMaterial(fi.otavanopisto.muikku.plugins.material.model.HtmlMaterial) WorkspaceMaterial(fi.otavanopisto.muikku.plugins.workspace.model.WorkspaceMaterial) Path(javax.ws.rs.Path) DELETE(javax.ws.rs.DELETE) RESTPermit(fi.otavanopisto.security.rest.RESTPermit)

Aggregations

WorkspaceMaterialEvaluation (fi.otavanopisto.muikku.plugins.evaluation.model.WorkspaceMaterialEvaluation)11 WorkspaceMaterial (fi.otavanopisto.muikku.plugins.workspace.model.WorkspaceMaterial)6 RESTPermit (fi.otavanopisto.security.rest.RESTPermit)6 Path (javax.ws.rs.Path)6 UserEntity (fi.otavanopisto.muikku.model.users.UserEntity)5 WorkspaceUserEntity (fi.otavanopisto.muikku.model.workspace.WorkspaceUserEntity)5 SupplementationRequest (fi.otavanopisto.muikku.plugins.evaluation.model.SupplementationRequest)3 RestAssessment (fi.otavanopisto.muikku.plugins.evaluation.rest.model.RestAssessment)3 RestSupplementationRequest (fi.otavanopisto.muikku.plugins.evaluation.rest.model.RestSupplementationRequest)3 WorkspaceGradingScale (fi.otavanopisto.muikku.plugins.evaluation.rest.model.WorkspaceGradingScale)3 SchoolDataIdentifier (fi.otavanopisto.muikku.schooldata.SchoolDataIdentifier)3 CompositeGradingScale (fi.otavanopisto.muikku.schooldata.entity.CompositeGradingScale)3 GradingScale (fi.otavanopisto.muikku.schooldata.entity.GradingScale)3 GradingScaleItem (fi.otavanopisto.muikku.schooldata.entity.GradingScaleItem)3 EntityManager (javax.persistence.EntityManager)3 CriteriaBuilder (javax.persistence.criteria.CriteriaBuilder)3 WorkspaceMaterialReply (fi.otavanopisto.muikku.plugins.workspace.model.WorkspaceMaterialReply)2 WorkspaceMaterialReplyState (fi.otavanopisto.muikku.plugins.workspace.model.WorkspaceMaterialReplyState)2 User (fi.otavanopisto.muikku.schooldata.entity.User)2 WorkspaceUser (fi.otavanopisto.muikku.schooldata.entity.WorkspaceUser)2