Search in sources :

Example 1 with WorkspaceMaterialField

use of fi.otavanopisto.muikku.plugins.workspace.model.WorkspaceMaterialField in project muikku by otavanopisto.

the class WorkspaceMaterialDeleteListener method onWorkspaceMaterialDelete.

public void onWorkspaceMaterialDelete(@Observes WorkspaceMaterialDeleteEvent event) {
    WorkspaceMaterial workspaceMaterial = event.getWorkspaceNode();
    List<WorkspaceMaterialField> workspaceMaterialFields = workspaceMaterialFieldController.listWorkspaceMaterialFieldsByWorkspaceMaterial(workspaceMaterial);
    for (WorkspaceMaterialField workspaceMaterialField : workspaceMaterialFields) {
        workspaceMaterialFieldController.deleteWorkspaceMaterialField(workspaceMaterialField, event.getRemoveAnswers());
    }
    List<WorkspaceMaterialReply> workspaceMaterialReplies = workspaceMaterialReplyController.listWorkspaceMaterialRepliesByWorkspaceMaterial(workspaceMaterial);
    for (WorkspaceMaterialReply workspaceMaterialReply : workspaceMaterialReplies) {
        workspaceMaterialReplyController.deleteWorkspaceMaterialReply(workspaceMaterialReply);
    }
}
Also used : WorkspaceMaterialReply(fi.otavanopisto.muikku.plugins.workspace.model.WorkspaceMaterialReply) WorkspaceMaterialField(fi.otavanopisto.muikku.plugins.workspace.model.WorkspaceMaterialField) WorkspaceMaterial(fi.otavanopisto.muikku.plugins.workspace.model.WorkspaceMaterial)

Example 2 with WorkspaceMaterialField

use of fi.otavanopisto.muikku.plugins.workspace.model.WorkspaceMaterialField in project muikku by otavanopisto.

the class WorkspaceMaterialFieldChangeListener method onWorkspaceMaterialFieldDelete.

// Delete
public void onWorkspaceMaterialFieldDelete(@Observes WorkspaceMaterialFieldDeleteEvent event) throws WorkspaceMaterialContainsAnswersExeption {
    WorkspaceMaterialField materialField = event.getWorkspaceMaterialField();
    List<WorkspaceMaterialFieldAnswer> answers = workspaceMaterialFieldAnswerController.listWorkspaceMaterialFieldAnswersByField(materialField);
    if (event.getRemoveAnswers()) {
        for (WorkspaceMaterialFieldAnswer answer : answers) {
            deleteFieldAnswer(answer);
        }
    } else {
        if (!answers.isEmpty()) {
            throw new WorkspaceMaterialContainsAnswersExeption("Could not remove workspace material field because it contains answers");
        }
    }
}
Also used : WorkspaceMaterialFieldAnswer(fi.otavanopisto.muikku.plugins.workspace.model.WorkspaceMaterialFieldAnswer) WorkspaceMaterialField(fi.otavanopisto.muikku.plugins.workspace.model.WorkspaceMaterialField)

Example 3 with WorkspaceMaterialField

use of fi.otavanopisto.muikku.plugins.workspace.model.WorkspaceMaterialField in project muikku by otavanopisto.

the class WorkspaceMaterialFieldDAO method listByQueryField.

public List<WorkspaceMaterialField> listByQueryField(QueryField queryField) {
    EntityManager entityManager = getEntityManager();
    CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
    CriteriaQuery<WorkspaceMaterialField> criteria = criteriaBuilder.createQuery(WorkspaceMaterialField.class);
    Root<WorkspaceMaterialField> root = criteria.from(WorkspaceMaterialField.class);
    criteria.select(root);
    criteria.where(criteriaBuilder.equal(root.get(WorkspaceMaterialField_.queryField), queryField));
    return entityManager.createQuery(criteria).getResultList();
}
Also used : CriteriaBuilder(javax.persistence.criteria.CriteriaBuilder) EntityManager(javax.persistence.EntityManager) WorkspaceMaterialField(fi.otavanopisto.muikku.plugins.workspace.model.WorkspaceMaterialField)

Example 4 with WorkspaceMaterialField

use of fi.otavanopisto.muikku.plugins.workspace.model.WorkspaceMaterialField in project muikku by otavanopisto.

the class WorkspaceMaterialFieldDAO method create.

public WorkspaceMaterialField create(QueryField field, WorkspaceMaterial workspaceMaterial, String embedId) {
    WorkspaceMaterialField workspaceMaterialField = new WorkspaceMaterialField();
    workspaceMaterialField.setEmbedId(embedId);
    workspaceMaterialField.setWorkspaceMaterial(workspaceMaterial);
    workspaceMaterialField.setQueryField(field);
    return persist(workspaceMaterialField);
}
Also used : WorkspaceMaterialField(fi.otavanopisto.muikku.plugins.workspace.model.WorkspaceMaterialField)

Example 5 with WorkspaceMaterialField

use of fi.otavanopisto.muikku.plugins.workspace.model.WorkspaceMaterialField in project muikku by otavanopisto.

the class QueryFieldChangeListener method onQueryFieldDelete.

public void onQueryFieldDelete(@Observes QueryFieldDeleteEvent event) {
    QueryField queryField = event.getQueryField();
    List<WorkspaceMaterialField> workspaceMaterialFields = workspaceMaterialFieldController.listWorkspaceMaterialFieldsByQueryField(queryField);
    for (WorkspaceMaterialField workspaceMaterialField : workspaceMaterialFields) {
        workspaceMaterialFieldController.deleteWorkspaceMaterialField(workspaceMaterialField, event.getRemoveAnswers());
    }
}
Also used : QueryField(fi.otavanopisto.muikku.plugins.material.model.QueryField) WorkspaceMaterialField(fi.otavanopisto.muikku.plugins.workspace.model.WorkspaceMaterialField)

Aggregations

WorkspaceMaterialField (fi.otavanopisto.muikku.plugins.workspace.model.WorkspaceMaterialField)16 QueryField (fi.otavanopisto.muikku.plugins.material.model.QueryField)6 WorkspaceMaterial (fi.otavanopisto.muikku.plugins.workspace.model.WorkspaceMaterial)3 IOException (java.io.IOException)3 EntityManager (javax.persistence.EntityManager)3 CriteriaBuilder (javax.persistence.criteria.CriteriaBuilder)3 ObjectMapper (org.codehaus.jackson.map.ObjectMapper)3 UserEntity (fi.otavanopisto.muikku.model.users.UserEntity)2 MaterialFieldMetaParsingExeption (fi.otavanopisto.muikku.plugins.material.MaterialFieldMetaParsingExeption)2 Material (fi.otavanopisto.muikku.plugins.material.model.Material)2 WorkspaceFieldIOException (fi.otavanopisto.muikku.plugins.workspace.fieldio.WorkspaceFieldIOException)2 ArrayList (java.util.ArrayList)2 WorkspaceUserEntity (fi.otavanopisto.muikku.model.workspace.WorkspaceUserEntity)1 OrganizerFieldMeta (fi.otavanopisto.muikku.plugins.material.fieldmeta.OrganizerFieldMeta)1 SorterFieldMeta (fi.otavanopisto.muikku.plugins.material.fieldmeta.SorterFieldMeta)1 HtmlMaterial (fi.otavanopisto.muikku.plugins.material.model.HtmlMaterial)1 WebSocketMessage (fi.otavanopisto.muikku.plugins.websocket.WebSocketMessage)1 WorkspaceMaterialFieldCreateEvent (fi.otavanopisto.muikku.plugins.workspace.events.WorkspaceMaterialFieldCreateEvent)1 WorkspaceMaterialFieldAnswer (fi.otavanopisto.muikku.plugins.workspace.model.WorkspaceMaterialFieldAnswer)1 WorkspaceMaterialOrganizerFieldAnswer (fi.otavanopisto.muikku.plugins.workspace.model.WorkspaceMaterialOrganizerFieldAnswer)1