Search in sources :

Example 6 with QueryMultiSelectFieldOption

use of fi.otavanopisto.muikku.plugins.material.model.QueryMultiSelectFieldOption in project muikku by otavanopisto.

the class QueryMultiSelectFieldOptionDAO method findByFieldAndName.

public QueryMultiSelectFieldOption findByFieldAndName(QueryMultiSelectField selectField, String name) {
    EntityManager entityManager = getEntityManager();
    CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
    CriteriaQuery<QueryMultiSelectFieldOption> criteria = criteriaBuilder.createQuery(QueryMultiSelectFieldOption.class);
    Root<QueryMultiSelectFieldOption> root = criteria.from(QueryMultiSelectFieldOption.class);
    criteria.select(root);
    criteria.where(criteriaBuilder.and(criteriaBuilder.equal(root.get(QueryMultiSelectFieldOption_.field), selectField), criteriaBuilder.equal(root.get(QueryMultiSelectFieldOption_.name), name)));
    return getSingleResult(entityManager.createQuery(criteria));
}
Also used : CriteriaBuilder(javax.persistence.criteria.CriteriaBuilder) EntityManager(javax.persistence.EntityManager) QueryMultiSelectFieldOption(fi.otavanopisto.muikku.plugins.material.model.QueryMultiSelectFieldOption)

Example 7 with QueryMultiSelectFieldOption

use of fi.otavanopisto.muikku.plugins.material.model.QueryMultiSelectFieldOption in project muikku by otavanopisto.

the class QueryMultiSelectFieldOptionDAO method create.

public QueryMultiSelectFieldOption create(String name, String text, QueryMultiSelectField field) {
    QueryMultiSelectFieldOption queryMultiSelectFieldOption = new QueryMultiSelectFieldOption();
    queryMultiSelectFieldOption.setName(name);
    queryMultiSelectFieldOption.setText(text);
    queryMultiSelectFieldOption.setField(field);
    return persist(queryMultiSelectFieldOption);
}
Also used : QueryMultiSelectFieldOption(fi.otavanopisto.muikku.plugins.material.model.QueryMultiSelectFieldOption)

Aggregations

QueryMultiSelectFieldOption (fi.otavanopisto.muikku.plugins.material.model.QueryMultiSelectFieldOption)7 ObjectMapper (org.codehaus.jackson.map.ObjectMapper)3 MultiSelectFieldMeta (fi.otavanopisto.muikku.plugins.material.fieldmeta.MultiSelectFieldMeta)2 MultiSelectFieldOptionMeta (fi.otavanopisto.muikku.plugins.material.fieldmeta.MultiSelectFieldOptionMeta)2 QueryMultiSelectField (fi.otavanopisto.muikku.plugins.material.model.QueryMultiSelectField)2 WorkspaceMaterialMultiSelectFieldAnswer (fi.otavanopisto.muikku.plugins.workspace.model.WorkspaceMaterialMultiSelectFieldAnswer)2 IOException (java.io.IOException)2 EntityManager (javax.persistence.EntityManager)2 CriteriaBuilder (javax.persistence.criteria.CriteriaBuilder)2 MaterialFieldMetaParsingExeption (fi.otavanopisto.muikku.plugins.material.MaterialFieldMetaParsingExeption)1 QueryFieldDeleteEvent (fi.otavanopisto.muikku.plugins.material.events.QueryFieldDeleteEvent)1 QueryFieldUpdateEvent (fi.otavanopisto.muikku.plugins.material.events.QueryFieldUpdateEvent)1 WorkspaceMaterialMultiSelectFieldAnswerOption (fi.otavanopisto.muikku.plugins.workspace.model.WorkspaceMaterialMultiSelectFieldAnswerOption)1 ArrayList (java.util.ArrayList)1