Search in sources :

Example 1 with CourseIdentifierSchoolDataIdentifier

use of fi.otavanopisto.muikku.model.coursemeta.CourseIdentifierSchoolDataIdentifier in project muikku by otavanopisto.

the class CourseIdentifierSchoolDataIdentifierDAO method findByDataSourceAndIdentifier.

public CourseIdentifierSchoolDataIdentifier findByDataSourceAndIdentifier(SchoolDataSource dataSource, String identifier) {
    EntityManager entityManager = getEntityManager();
    CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
    CriteriaQuery<CourseIdentifierSchoolDataIdentifier> criteria = criteriaBuilder.createQuery(CourseIdentifierSchoolDataIdentifier.class);
    Root<CourseIdentifierSchoolDataIdentifier> root = criteria.from(CourseIdentifierSchoolDataIdentifier.class);
    criteria.select(root);
    criteria.where(criteriaBuilder.and(criteriaBuilder.equal(root.get(CourseIdentifierSchoolDataIdentifier_.dataSource), dataSource), criteriaBuilder.equal(root.get(CourseIdentifierSchoolDataIdentifier_.identifier), identifier)));
    return getSingleResult(entityManager.createQuery(criteria));
}
Also used : CriteriaBuilder(javax.persistence.criteria.CriteriaBuilder) EntityManager(javax.persistence.EntityManager) CourseIdentifierSchoolDataIdentifier(fi.otavanopisto.muikku.model.coursemeta.CourseIdentifierSchoolDataIdentifier)

Example 2 with CourseIdentifierSchoolDataIdentifier

use of fi.otavanopisto.muikku.model.coursemeta.CourseIdentifierSchoolDataIdentifier in project muikku by otavanopisto.

the class CourseIdentifierSchoolDataIdentifierDAO method findByDataSourceAndUserEntity.

public CourseIdentifierSchoolDataIdentifier findByDataSourceAndUserEntity(SchoolDataSource dataSource, CourseIdentifierEntity courseIdentifierEntity) {
    EntityManager entityManager = getEntityManager();
    CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
    CriteriaQuery<CourseIdentifierSchoolDataIdentifier> criteria = criteriaBuilder.createQuery(CourseIdentifierSchoolDataIdentifier.class);
    Root<CourseIdentifierSchoolDataIdentifier> root = criteria.from(CourseIdentifierSchoolDataIdentifier.class);
    criteria.select(root);
    criteria.where(criteriaBuilder.and(criteriaBuilder.equal(root.get(CourseIdentifierSchoolDataIdentifier_.dataSource), dataSource), criteriaBuilder.equal(root.get(CourseIdentifierSchoolDataIdentifier_.courseIdentifierEntity), courseIdentifierEntity)));
    return getSingleResult(entityManager.createQuery(criteria));
}
Also used : CriteriaBuilder(javax.persistence.criteria.CriteriaBuilder) EntityManager(javax.persistence.EntityManager) CourseIdentifierSchoolDataIdentifier(fi.otavanopisto.muikku.model.coursemeta.CourseIdentifierSchoolDataIdentifier)

Example 3 with CourseIdentifierSchoolDataIdentifier

use of fi.otavanopisto.muikku.model.coursemeta.CourseIdentifierSchoolDataIdentifier in project muikku by otavanopisto.

the class CourseIdentifierSchoolDataIdentifierDAO method listByCourseIdentifierEntity.

public List<CourseIdentifierSchoolDataIdentifier> listByCourseIdentifierEntity(CourseIdentifierEntity courseIdentifierEntity) {
    EntityManager entityManager = getEntityManager();
    CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
    CriteriaQuery<CourseIdentifierSchoolDataIdentifier> criteria = criteriaBuilder.createQuery(CourseIdentifierSchoolDataIdentifier.class);
    Root<CourseIdentifierSchoolDataIdentifier> root = criteria.from(CourseIdentifierSchoolDataIdentifier.class);
    criteria.select(root);
    criteria.where(criteriaBuilder.equal(root.get(CourseIdentifierSchoolDataIdentifier_.courseIdentifierEntity), courseIdentifierEntity));
    return entityManager.createQuery(criteria).getResultList();
}
Also used : CriteriaBuilder(javax.persistence.criteria.CriteriaBuilder) EntityManager(javax.persistence.EntityManager) CourseIdentifierSchoolDataIdentifier(fi.otavanopisto.muikku.model.coursemeta.CourseIdentifierSchoolDataIdentifier)

Example 4 with CourseIdentifierSchoolDataIdentifier

use of fi.otavanopisto.muikku.model.coursemeta.CourseIdentifierSchoolDataIdentifier in project muikku by otavanopisto.

the class CourseIdentifierSchoolDataIdentifierDAO method create.

public CourseIdentifierSchoolDataIdentifier create(SchoolDataSource dataSource, String identifier, CourseIdentifierEntity courseIdentifierEntity) {
    CourseIdentifierSchoolDataIdentifier courseIdentifierSchoolDataIdentifier = new CourseIdentifierSchoolDataIdentifier();
    courseIdentifierSchoolDataIdentifier.setDataSource(dataSource);
    courseIdentifierSchoolDataIdentifier.setIdentifier(identifier);
    courseIdentifierSchoolDataIdentifier.setCourseIdentifierEntity(courseIdentifierEntity);
    return persist(courseIdentifierSchoolDataIdentifier);
}
Also used : CourseIdentifierSchoolDataIdentifier(fi.otavanopisto.muikku.model.coursemeta.CourseIdentifierSchoolDataIdentifier)

Example 5 with CourseIdentifierSchoolDataIdentifier

use of fi.otavanopisto.muikku.model.coursemeta.CourseIdentifierSchoolDataIdentifier in project muikku by otavanopisto.

the class CourseIdentifierEntityController method findCourseIdentifierEntityBySchoolDataSourceAndIdentifier.

public CourseIdentifierEntity findCourseIdentifierEntityBySchoolDataSourceAndIdentifier(String dataSource, String identifier) {
    SchoolDataSource schoolDataSource = schoolDataSourceDAO.findByIdentifier(dataSource);
    if (dataSource == null) {
        logger.severe("Could not find datasource " + dataSource);
        return null;
    }
    CourseIdentifierSchoolDataIdentifier schoolDataIdentifier = courseIdentifierSchoolDataIdentifierDAO.findByDataSourceAndIdentifier(schoolDataSource, identifier);
    if (schoolDataIdentifier != null) {
        return schoolDataIdentifier.getCourseIdentifierEntity();
    }
    return null;
}
Also used : SchoolDataSource(fi.otavanopisto.muikku.model.base.SchoolDataSource) CourseIdentifierSchoolDataIdentifier(fi.otavanopisto.muikku.model.coursemeta.CourseIdentifierSchoolDataIdentifier)

Aggregations

CourseIdentifierSchoolDataIdentifier (fi.otavanopisto.muikku.model.coursemeta.CourseIdentifierSchoolDataIdentifier)5 EntityManager (javax.persistence.EntityManager)3 CriteriaBuilder (javax.persistence.criteria.CriteriaBuilder)3 SchoolDataSource (fi.otavanopisto.muikku.model.base.SchoolDataSource)1