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));
}
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));
}
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();
}
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);
}
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;
}
Aggregations