Search in sources :

Example 1 with WorkspaceMaterialDeleteEvent

use of fi.otavanopisto.muikku.plugins.workspace.events.WorkspaceMaterialDeleteEvent in project muikku by otavanopisto.

the class WorkspaceMaterialController method deleteWorkspaceMaterial.

public void deleteWorkspaceMaterial(WorkspaceMaterial workspaceMaterial, boolean removeAnswers) throws WorkspaceMaterialContainsAnswersExeption {
    try {
        workspaceMaterialDeleteEvent.fire(new WorkspaceMaterialDeleteEvent(workspaceMaterial, removeAnswers));
        List<WorkspaceNode> childNodes = workspaceNodeDAO.listByParentSortByOrderNumber(workspaceMaterial);
        for (WorkspaceNode childNode : childNodes) {
            if (childNode instanceof WorkspaceMaterial) {
                deleteWorkspaceMaterial((WorkspaceMaterial) childNode, removeAnswers);
            } else if (childNode instanceof WorkspaceFolder) {
                deleteWorkspaceFolder((WorkspaceFolder) childNode);
            }
        }
    } catch (Exception e) {
        Throwable cause = e;
        while (cause != null) {
            cause = cause.getCause();
            if (cause instanceof WorkspaceMaterialContainsAnswersExeption) {
                throw (WorkspaceMaterialContainsAnswersExeption) cause;
            }
        }
        throw e;
    }
    workspaceMaterialDAO.delete(workspaceMaterial);
}
Also used : WorkspaceMaterialDeleteEvent(fi.otavanopisto.muikku.plugins.workspace.events.WorkspaceMaterialDeleteEvent) WorkspaceNode(fi.otavanopisto.muikku.plugins.workspace.model.WorkspaceNode) WorkspaceMaterial(fi.otavanopisto.muikku.plugins.workspace.model.WorkspaceMaterial) SAXNotSupportedException(org.xml.sax.SAXNotSupportedException) XPathExpressionException(javax.xml.xpath.XPathExpressionException) SAXException(org.xml.sax.SAXException) TransformerException(javax.xml.transform.TransformerException) SAXNotRecognizedException(org.xml.sax.SAXNotRecognizedException) TransformerConfigurationException(javax.xml.transform.TransformerConfigurationException) IOException(java.io.IOException) WorkspaceFolder(fi.otavanopisto.muikku.plugins.workspace.model.WorkspaceFolder)

Aggregations

WorkspaceMaterialDeleteEvent (fi.otavanopisto.muikku.plugins.workspace.events.WorkspaceMaterialDeleteEvent)1 WorkspaceFolder (fi.otavanopisto.muikku.plugins.workspace.model.WorkspaceFolder)1 WorkspaceMaterial (fi.otavanopisto.muikku.plugins.workspace.model.WorkspaceMaterial)1 WorkspaceNode (fi.otavanopisto.muikku.plugins.workspace.model.WorkspaceNode)1 IOException (java.io.IOException)1 TransformerConfigurationException (javax.xml.transform.TransformerConfigurationException)1 TransformerException (javax.xml.transform.TransformerException)1 XPathExpressionException (javax.xml.xpath.XPathExpressionException)1 SAXException (org.xml.sax.SAXException)1 SAXNotRecognizedException (org.xml.sax.SAXNotRecognizedException)1 SAXNotSupportedException (org.xml.sax.SAXNotSupportedException)1