use of fi.otavanopisto.muikku.model.coursemeta.CourseIdentifierEntity in project muikku by otavanopisto.
the class CourseIdentifierEntityDAO method create.
public CourseIdentifierEntity create(Boolean archived) {
CourseIdentifierEntity courseIdentifierEntity = new CourseIdentifierEntity();
courseIdentifierEntity.setArchived(archived);
getEntityManager().persist(courseIdentifierEntity);
return courseIdentifierEntity;
}
use of fi.otavanopisto.muikku.model.coursemeta.CourseIdentifierEntity in project muikku by otavanopisto.
the class DefaultSchoolDataMetaListener method onSchoolDataCourseIdentifierDiscoveredEvent.
public synchronized void onSchoolDataCourseIdentifierDiscoveredEvent(@Observes SchoolDataCourseIdentifierDiscoveredEvent event) {
String discoverId = "CI-" + event.getDataSource() + "/" + event.getIdentifier();
if (discoveredCourseIdentifiers.containsKey(discoverId)) {
event.setDiscoveredCourseIdentifierEntityId(discoveredCourseIdentifiers.get(discoverId));
return;
}
CourseIdentifierEntity entity = courseIdentifierEntityController.findCourseIdentifierEntityBySchoolDataSourceAndIdentifier(event.getDataSource(), event.getIdentifier());
if (entity == null) {
entity = courseIdentifierEntityController.createCourseIdentifierEntity(event.getDataSource(), event.getIdentifier());
discoveredCourseIdentifiers.put(discoverId, entity.getId());
event.setDiscoveredCourseIdentifierEntityId(entity.getId());
} else {
logger.warning("CourseIdentifierEntity " + event.getIdentifier() + "/" + event.getDataSource() + " already exists");
}
}
use of fi.otavanopisto.muikku.model.coursemeta.CourseIdentifierEntity in project muikku by otavanopisto.
the class CourseIdentifierEntityController method createCourseIdentifierEntity.
public CourseIdentifierEntity createCourseIdentifierEntity(String dataSource, String identifier) {
SchoolDataSource schoolDataSource = schoolDataSourceDAO.findByIdentifier(dataSource);
if (dataSource == null) {
logger.severe("Could not find datasource " + dataSource);
return null;
}
CourseIdentifierEntity courseIdentifierEntity = courseIdentifierEntityDAO.create(Boolean.FALSE);
courseIdentifierSchoolDataIdentifierDAO.create(schoolDataSource, identifier, courseIdentifierEntity);
return courseIdentifierEntity;
}
Aggregations