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