Search in sources :

Example 6 with QuerySelectFieldOption

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

the class QuerySelectFieldOptionDAO method create.

public QuerySelectFieldOption create(String name, String text, QuerySelectField field) {
    QuerySelectFieldOption querySelectFieldOption = new QuerySelectFieldOption();
    querySelectFieldOption.setName(name);
    querySelectFieldOption.setText(text);
    querySelectFieldOption.setSelectField(field);
    return persist(querySelectFieldOption);
}
Also used : QuerySelectFieldOption(fi.otavanopisto.muikku.plugins.material.model.QuerySelectFieldOption)

Example 7 with QuerySelectFieldOption

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

the class QuerySelectFieldOptionDAO method listBySelectField.

public List<QuerySelectFieldOption> listBySelectField(QuerySelectField selectField) {
    EntityManager entityManager = getEntityManager();
    CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
    CriteriaQuery<QuerySelectFieldOption> criteria = criteriaBuilder.createQuery(QuerySelectFieldOption.class);
    Root<QuerySelectFieldOption> root = criteria.from(QuerySelectFieldOption.class);
    criteria.select(root);
    criteria.where(criteriaBuilder.equal(root.get(QuerySelectFieldOption_.selectField), selectField));
    return entityManager.createQuery(criteria).getResultList();
}
Also used : CriteriaBuilder(javax.persistence.criteria.CriteriaBuilder) EntityManager(javax.persistence.EntityManager) QuerySelectFieldOption(fi.otavanopisto.muikku.plugins.material.model.QuerySelectFieldOption)

Aggregations

QuerySelectFieldOption (fi.otavanopisto.muikku.plugins.material.model.QuerySelectFieldOption)7 EntityManager (javax.persistence.EntityManager)3 CriteriaBuilder (javax.persistence.criteria.CriteriaBuilder)3 SelectFieldMeta (fi.otavanopisto.muikku.plugins.material.fieldmeta.SelectFieldMeta)2 SelectFieldOptionMeta (fi.otavanopisto.muikku.plugins.material.fieldmeta.SelectFieldOptionMeta)2 QuerySelectField (fi.otavanopisto.muikku.plugins.material.model.QuerySelectField)2 IOException (java.io.IOException)2 ObjectMapper (org.codehaus.jackson.map.ObjectMapper)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 MultiSelectFieldMeta (fi.otavanopisto.muikku.plugins.material.fieldmeta.MultiSelectFieldMeta)1 MultiSelectFieldOptionMeta (fi.otavanopisto.muikku.plugins.material.fieldmeta.MultiSelectFieldOptionMeta)1 WorkspaceMaterialSelectFieldAnswer (fi.otavanopisto.muikku.plugins.workspace.model.WorkspaceMaterialSelectFieldAnswer)1 ArrayList (java.util.ArrayList)1