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);
}
}
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");
}
}
}
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();
}
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);
}
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());
}
}
Aggregations