Search in sources :

Example 11 with WorkspaceMaterialField

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

the class WorkspaceMaterialFieldDAO method findByWorkspaceMaterialAndQueryFieldAndEmbedId.

public WorkspaceMaterialField findByWorkspaceMaterialAndQueryFieldAndEmbedId(WorkspaceMaterial workspaceMaterial, QueryField queryField, String embedId) {
    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.and(criteriaBuilder.equal(root.get(WorkspaceMaterialField_.workspaceMaterial), workspaceMaterial), criteriaBuilder.equal(root.get(WorkspaceMaterialField_.queryField), queryField), criteriaBuilder.equal(root.get(WorkspaceMaterialField_.embedId), embedId)));
    return getSingleResult(entityManager.createQuery(criteria));
}
Also used : CriteriaBuilder(javax.persistence.criteria.CriteriaBuilder) EntityManager(javax.persistence.EntityManager) WorkspaceMaterialField(fi.otavanopisto.muikku.plugins.workspace.model.WorkspaceMaterialField)

Example 12 with WorkspaceMaterialField

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

the class WorkspaceMaterialFieldDAO method listByWorkspaceMaterial.

public List<WorkspaceMaterialField> listByWorkspaceMaterial(WorkspaceMaterial workspaceMaterial) {
    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_.workspaceMaterial), workspaceMaterial));
    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 13 with WorkspaceMaterialField

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

the class QueryFieldChangeListener method onQueryMultiSelectFieldUpdate.

public void onQueryMultiSelectFieldUpdate(@Observes QueryFieldUpdateEvent event) {
    if (event.getMaterialField().getType().equals("application/vnd.muikku.field.multiselect")) {
        QueryField queryField = event.getQueryField();
        List<WorkspaceMaterialField> workspaceMaterialFields = workspaceMaterialFieldController.listWorkspaceMaterialFieldsByQueryField(queryField);
        for (WorkspaceMaterialField workspaceMaterialField : workspaceMaterialFields) {
            workspaceMaterialFieldController.updateWorkspaceMaterialField(workspaceMaterialField, event.getMaterialField(), event.getRemoveAnswers());
        }
    }
}
Also used : QueryField(fi.otavanopisto.muikku.plugins.material.model.QueryField) WorkspaceMaterialField(fi.otavanopisto.muikku.plugins.workspace.model.WorkspaceMaterialField)

Example 14 with WorkspaceMaterialField

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

the class QueryFieldChangeListener method onQueryOrganizerFieldUpdate.

public void onQueryOrganizerFieldUpdate(@Observes QueryFieldUpdateEvent event) {
    if (event.getMaterialField().getType().equals("application/vnd.muikku.field.organizer")) {
        QueryField queryField = event.getQueryField();
        List<WorkspaceMaterialField> workspaceMaterialFields = workspaceMaterialFieldController.listWorkspaceMaterialFieldsByQueryField(queryField);
        for (WorkspaceMaterialField workspaceMaterialField : workspaceMaterialFields) {
            workspaceMaterialFieldController.updateWorkspaceMaterialField(workspaceMaterialField, event.getMaterialField(), event.getRemoveAnswers());
        }
    }
}
Also used : QueryField(fi.otavanopisto.muikku.plugins.material.model.QueryField) WorkspaceMaterialField(fi.otavanopisto.muikku.plugins.workspace.model.WorkspaceMaterialField)

Example 15 with WorkspaceMaterialField

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

the class QueryFieldChangeListener method onQuerySorterFieldUpdate.

public void onQuerySorterFieldUpdate(@Observes QueryFieldUpdateEvent event) {
    if (event.getMaterialField().getType().equals("application/vnd.muikku.field.sorter")) {
        QueryField queryField = event.getQueryField();
        List<WorkspaceMaterialField> workspaceMaterialFields = workspaceMaterialFieldController.listWorkspaceMaterialFieldsByQueryField(queryField);
        for (WorkspaceMaterialField workspaceMaterialField : workspaceMaterialFields) {
            workspaceMaterialFieldController.updateWorkspaceMaterialField(workspaceMaterialField, event.getMaterialField(), 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