use of fi.otavanopisto.muikku.plugins.material.model.QueryOrganizerField in project muikku by otavanopisto.
the class QueryOrganizerFieldController method updateQueryOrganizerField.
public QueryOrganizerField updateQueryOrganizerField(Material material, MaterialField field, boolean removeAnswers) throws MaterialFieldMetaParsingExeption {
ObjectMapper objectMapper = new ObjectMapper();
OrganizerFieldMeta organizerFieldMeta;
try {
organizerFieldMeta = objectMapper.readValue(field.getContent(), OrganizerFieldMeta.class);
} catch (IOException e) {
throw new MaterialFieldMetaParsingExeption("Could not parse select field meta", e);
}
QueryOrganizerField queryField = queryOrganizerFieldDAO.findByMaterialAndName(material, organizerFieldMeta.getName());
// -> fi.otavanopisto.muikku.plugins.workspace.QueryFieldChangeListener
queryFieldUpdateEvent.fire(new QueryFieldUpdateEvent(queryField, field, removeAnswers));
return queryField;
}
use of fi.otavanopisto.muikku.plugins.material.model.QueryOrganizerField in project muikku by otavanopisto.
the class QueryOrganizerFieldDAO method findByMaterialAndName.
public QueryOrganizerField findByMaterialAndName(Material material, String name) {
EntityManager entityManager = getEntityManager();
CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
CriteriaQuery<QueryOrganizerField> criteria = criteriaBuilder.createQuery(QueryOrganizerField.class);
Root<QueryOrganizerField> root = criteria.from(QueryOrganizerField.class);
criteria.select(root);
criteria.where(criteriaBuilder.and(criteriaBuilder.equal(root.get(QueryOrganizerField_.material), material), criteriaBuilder.equal(root.get(QueryOrganizerField_.name), name)));
return getSingleResult(entityManager.createQuery(criteria));
}
use of fi.otavanopisto.muikku.plugins.material.model.QueryOrganizerField in project muikku by otavanopisto.
the class QueryOrganizerFieldDAO method create.
public QueryOrganizerField create(Material material, String name) {
QueryOrganizerField queryOrganizerField = new QueryOrganizerField();
queryOrganizerField.setMaterial(material);
queryOrganizerField.setName(name);
return persist(queryOrganizerField);
}
Aggregations