当前位置: 首页>>代码示例>>Java>>正文


Java Ebean类代码示例

本文整理汇总了Java中io.ebean.Ebean的典型用法代码示例。如果您正苦于以下问题:Java Ebean类的具体用法?Java Ebean怎么用?Java Ebean使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Ebean类属于io.ebean包,在下文中一共展示了Ebean类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getActiveExams

import io.ebean.Ebean; //导入依赖的package包/类
@SubjectNotPresent
public Result getActiveExams(Optional<String> date) {
    PathProperties pp = PathProperties.parse("(course(name, code, credits, " +
            "gradeScale(description, externalRef, displayName), organisation(code, name, nameAbbreviation)) " +
            "name, examActiveStartDate, examActiveEndDate, duration, enrollInstruction, examLanguages(code, name) " +
            "gradeScale(description, externalRef, displayName), examOwners(firstName, lastName, email), " +
            "examType(type)" +
            ")");
    DateTime dateTime = date.isPresent() ?
            ISODateTimeFormat.dateTimeParser().parseDateTime(date.get()) :
            DateTime.now();
    Query<Exam> query = Ebean.find(Exam.class);
    query.apply(pp);
    List<Exam> exams = query.where()
            .eq("state", Exam.State.PUBLISHED)
            .lt("examActiveStartDate", dateTime)
            .ge("examActiveEndDate", dateTime)
            .eq("executionType.type", ExamExecutionType.Type.PUBLIC.toString())
            .findList();

    return ok(exams, pp);
}
 
开发者ID:CSCfi,项目名称:exam,代码行数:23,代码来源:ExamAPIController.java

示例2: getReservations

import io.ebean.Ebean; //导入依赖的package包/类
@SubjectNotPresent
public Result getReservations(Optional<String> start, Optional<String> end, Optional<Long> roomId) {
    PathProperties pp = PathProperties.parse("(startAt, endAt, noShow, " +
            "user(firstName, lastName, email, userIdentifier), " +
            "enrolment(exam(name, examOwners(firstName, lastName, email), parent(examOwners(firstName, lastName, email)))), " +
            "machine(name, ipAddress, otherIdentifier, room(name, roomCode)))");
    Query<Reservation> query = Ebean.find(Reservation.class);
    pp.apply(query);
    ExpressionList<Reservation> el = query.where()
            .isNotNull("enrolment")
            .ne("enrolment.exam.state", Exam.State.DELETED);
    if (start.isPresent()) {
        DateTime startDate = ISODateTimeFormat.dateTimeParser().parseDateTime(start.get());
        el = el.ge("startAt", startDate.toDate());
    }

    if (end.isPresent()) {
        DateTime endDate = ISODateTimeFormat.dateTimeParser().parseDateTime(end.get());
        el = el.lt("endAt", endDate.toDate());
    }
    if (roomId.isPresent()) {
        el = el.eq("machine.room.id", roomId.get());
    }
    Set<Reservation> reservations = el.orderBy("startAt").findSet();
    return ok(reservations, pp);
}
 
开发者ID:CSCfi,项目名称:exam,代码行数:27,代码来源:ReservationAPIController.java

示例3: getSubject

import io.ebean.Ebean; //导入依赖的package包/类
@Override
public CompletionStage<Optional<? extends Subject>> getSubject(final Http.Context context) {
    String token = BaseController.getToken(context).orElse("");
    Session session = cache.get(BaseController.SITNET_CACHE_KEY + token);
    User user = session == null ? null : Ebean.find(User.class, session.getUserId());
    // filter out roles not found in session
    if (user != null) {
        if (session.isTemporalStudent()) {
            user.getRoles().clear();
            user.getRoles().add(Ebean.find(Role.class).where().eq("name", Role.Name.STUDENT.toString()).findUnique());
        } else {
            user.setRoles(user.getRoles().stream()
                    .filter((r) -> r.getName().equals(session.getLoginRole()))
                    .collect(Collectors.toList()));
        }
    }
    return CompletableFuture.supplyAsync(() -> Optional.ofNullable(user));
}
 
开发者ID:CSCfi,项目名称:exam,代码行数:19,代码来源:AuthorizationHandler.java

示例4: testGetSeveralCourses

import io.ebean.Ebean; //导入依赖的package包/类
@Test
@RunAsTeacher
@Ignore("currently not a valid test")
public void testGetSeveralCourses() throws Exception {
    // This is to make sure that we can import a course that shares the same prefix and has shorter code than a
    // course already found in db
    setUserOrg(null);

    Course course = new Course();
    course.setCode("21212190");
    course.save();

    CourseInfoServlet.jsonFile = new File("test/resources/courseUnitInfo.json");
    Result result = get("/app/courses?filter=code&q=2121219");
    assertThat(result.status()).isEqualTo(200);
    JsonNode node = Json.parse(contentAsString(result));
    assertThat(node).hasSize(2);
    Course c1 = deserialize(Course.class, node.get(0));
    assertThat(c1.getCode()).isEqualTo("21212190");
    Course c2 = deserialize(Course.class, node.get(1));
    assertThat(c2.getCode()).isEqualTo("2121219");
    assertThat(Ebean.find(Course.class).where().eq("code", "2121219")).isNotNull();
}
 
开发者ID:CSCfi,项目名称:exam,代码行数:24,代码来源:CourseInfoImportTest.java

示例5: testLoginAsNewUser

import io.ebean.Ebean; //导入依赖的package包/类
@Test
public void testLoginAsNewUser() throws Exception {
    String eppn = "[email protected]";
    User user = Ebean.find(User.class).where().eq("eppn", eppn).findUnique();
    assertThat(user).isNull();

    login(eppn);

    user = Ebean.find(User.class).where().eq("eppn", eppn).findUnique();
    assertThat(user).isNotNull();
    assertThat(user.getRoles()).hasSize(1);
    assertThat(user.getOrganisation()).isNotNull();
    assertThat(user.getRoles().get(0).getName()).isEqualTo(Role.Name.TEACHER.toString());
    assertThat(user.getFirstName()).isEqualTo("George");
    assertThat(user.getLastName()).isEqualTo("Lazenby");

}
 
开发者ID:CSCfi,项目名称:exam,代码行数:18,代码来源:SessionControllerTest.java

示例6: getNoShows

import io.ebean.Ebean; //导入依赖的package包/类
private Set<ExamEnrolment> getNoShows(User user, String filter) {
    ExpressionList<ExamEnrolment> noShows = Ebean.find(ExamEnrolment.class)
            .fetch("exam", "id, state, name")
            .fetch("exam.course", "code, name")
            .fetch("exam.examOwners", "firstName, lastName, id")
            .fetch("exam.examInspections.user", "firstName, lastName, id")
            .fetch("reservation")
            .where()
            .eq("user", user)
            .isNull("exam.parent")
            .eq("reservation.noShow", true);
    if (filter != null) {
        String condition = String.format("%%%s%%", filter);
        noShows = noShows.disjunction()
                .ilike("exam.name", condition)
                .ilike("exam.course.code", condition)
                .ilike("exam.examOwners.firstName", condition)
                .ilike("exam.examOwners.lastName", condition)
                .ilike("exam.examInspections.user.firstName", condition)
                .ilike("exam.examInspections.user.lastName", condition)
                .endJunction();
    }
    return noShows.findSet();
}
 
开发者ID:CSCfi,项目名称:exam,代码行数:25,代码来源:StudentActionsController.java

示例7: downloadQuestionAttachment

import io.ebean.Ebean; //导入依赖的package包/类
@Restrict({@Group("TEACHER"), @Group("ADMIN"), @Group("STUDENT")})
public Result downloadQuestionAttachment(Long id) {
    User user = getLoggedUser();
    Question question;
    if (user.hasRole("STUDENT", getSession())) {
        question = Ebean.find(Question.class).where()
                .idEq(id)
                .eq("examSectionQuestions.examSection.exam.creator", getLoggedUser())
                .findUnique();
    } else {
        question = Ebean.find(Question.class, id);
    }
    if (question == null || question.getAttachment() == null) {
        return notFound();
    }
    return serveAttachment(question.getAttachment());
}
 
开发者ID:CSCfi,项目名称:exam,代码行数:18,代码来源:AttachmentController.java

示例8: getRoomOpeningHours

import io.ebean.Ebean; //导入依赖的package包/类
@SubjectNotPresent
public Result getRoomOpeningHours(Long roomId, Optional<String> date) {
    if (!date.isPresent()) {
        return badRequest("no search date given");
    }
    LocalDate searchDate = ISODateTimeFormat.dateParser().parseLocalDate(date.get());
    PathProperties pp = PathProperties.parse("(*, defaultWorkingHours(*), calendarExceptionEvents(*))");
    Query<ExamRoom> query = Ebean.find(ExamRoom.class);
    pp.apply(query);
    ExamRoom room = query.where().idEq(roomId).findUnique();
    if (room == null) {
        return notFound("room not found");
    }
    room.setCalendarExceptionEvents(room.getCalendarExceptionEvents().stream().filter(ee -> {
        LocalDate start = new LocalDate(ee.getStartDate()).withDayOfMonth(1);
        LocalDate end = new LocalDate(ee.getEndDate()).dayOfMonth().withMaximumValue();
        return !start.isAfter(searchDate) && !end.isBefore(searchDate);

    }).collect(Collectors.toList()));
    return ok(room, pp);
}
 
开发者ID:CSCfi,项目名称:exam,代码行数:22,代码来源:ReservationAPIController.java

示例9: removeEnrolment

import io.ebean.Ebean; //导入依赖的package包/类
@Restrict({@Group("ADMIN"), @Group("STUDENT")})
public Result removeEnrolment(Long id) {
    User user = getLoggedUser();
    ExamEnrolment enrolment;
    if (user.hasRole("STUDENT", getSession())) {
        enrolment = Ebean.find(ExamEnrolment.class).fetch("exam")
                .where().idEq(id).eq("user", user).findUnique();
    } else {
        enrolment = Ebean.find(ExamEnrolment.class).fetch("exam")
                .where().idEq(id).findUnique();
    }
    if (enrolment == null) {
        return notFound("enrolment not found");
    }
    // Disallow removing enrolments to private exams created automatically for student
    if (enrolment.getExam().isPrivate()) {
        return forbidden();
    }
    if (enrolment.getReservation() != null) {
        return forbidden("sitnet_cancel_reservation_first");
    }
    enrolment.delete();
    return ok();
}
 
开发者ID:CSCfi,项目名称:exam,代码行数:25,代码来源:EnrolmentController.java

示例10: checkLocalExams

import io.ebean.Ebean; //导入依赖的package包/类
private void checkLocalExams() {
    List<ExamParticipation> participations = Ebean.find(ExamParticipation.class)
            .fetch("exam")
            .fetch("reservation")
            .fetch("reservation.machine.room")
            .where()
            .isNull("ended")
            .isNotNull("reservation")
            .findList();

    if (participations.isEmpty()) {
        Logger.debug("{}: ... none found.", getClass().getCanonicalName());
        return;
    }
    markEnded(participations);
}
 
开发者ID:CSCfi,项目名称:exam,代码行数:17,代码来源:ExamAutoSaverActor.java

示例11: reportAllExams

import io.ebean.Ebean; //导入依赖的package包/类
@Restrict({@Group("ADMIN")})
public Result reportAllExams(String from, String to) throws IOException {

    final DateTime start = DateTime.parse(from, DTF);
    final DateTime end = DateTime.parse(to, DTF);

    List<ExamParticipation> participations = Ebean.find(ExamParticipation.class)
            .fetch("exam")
            .where()
            .gt("started", start)
            .lt("ended", end)
            .disjunction()
            .eq("exam.state", Exam.State.GRADED)
            .eq("exam.state", Exam.State.GRADED_LOGGED)
            .eq("exam.state", Exam.State.ARCHIVED)
            .endJunction()
            .findList();

    Workbook wb = new XSSFWorkbook();
    generateParticipationSheet(wb, participations, true);
    response().setHeader("Content-Disposition", "attachment; filename=\"all_exams.xlsx\"");
    return ok(encode(wb));
}
 
开发者ID:CSCfi,项目名称:exam,代码行数:24,代码来源:StatisticsController.java

示例12: enrollExamList

import io.ebean.Ebean; //导入依赖的package包/类
@Restrict({@Group("ADMIN"), @Group("STUDENT")})
public Result enrollExamList(String code) {

    List<Exam> exams = Ebean.find(Exam.class)
            .fetch("creator", "firstName, lastName")
            .fetch("examLanguages")
            .fetch("examOwners", "firstName, lastName")
            .fetch("examInspections.user", "firstName, lastName")
            .fetch("course", "code, name")
            .where()
            .eq("course.code", code)
            .eq("executionType.type", ExamExecutionType.Type.PUBLIC.toString())
            .eq("state", Exam.State.PUBLISHED)
            .ge("examActiveEndDate", new Date())
            .findList();

    return ok(exams);
}
 
开发者ID:CSCfi,项目名称:exam,代码行数:19,代码来源:EnrolmentController.java

示例13: send

import io.ebean.Ebean; //导入依赖的package包/类
private void send(ExamEnrolment enrolment) throws IOException {
    String ref = enrolment.getReservation().getExternalRef();
    Logger.debug("Sending back assessment for reservation " + ref);
    URL url = parseUrl(ref);
    WSRequest request = wsClient.url(url.toString());
    ExternalExam ee = enrolment.getExternalExam();
    Function<WSResponse, Void> onSuccess = response -> {
        if (response.getStatus() != 201) {
            Logger.error("Failed in sending assessment for reservation " + ref);
        } else {
            ee.setSent(DateTime.now());
            ee.update();
            Logger.info("Assessment for reservation " + ref + " processed successfully");
        }
        return null;
    };
    String json = Ebean.json().toJson(ee, PathProperties.parse("(*, creator(id))"));
    ObjectMapper om = new ObjectMapper();
    JsonNode node = om.readTree(json);
    request.post(node).thenApplyAsync(onSuccess);
}
 
开发者ID:CSCfi,项目名称:exam,代码行数:22,代码来源:AssessmentSenderActor.java

示例14: setUp

import io.ebean.Ebean; //导入依赖的package包/类
@Override
@Before
public void setUp() throws Exception {
    super.setUp();
    Ebean.deleteAll(Ebean.find(ExamEnrolment.class).findList());
    exam = Ebean.find(Exam.class).where().eq("state", Exam.State.PUBLISHED).findList().get(0);
    user = Ebean.find(User.class, userId);
    user.setLanguage(Ebean.find(Language.class, "en"));
    user.update();
    room = Ebean.find(ExamRoom.class, 1L);
    room.setRoomInstructionEN("information in English here");
    room.update();
    enrolment = new ExamEnrolment();
    enrolment.setExam(exam);
    enrolment.setUser(user);
    enrolment.save();

    reservation = new Reservation();
    reservation.setUser(user);
}
 
开发者ID:CSCfi,项目名称:exam,代码行数:21,代码来源:CalendarControllerTest.java

示例15: getParticipationsForExamAndUser

import io.ebean.Ebean; //导入依赖的package包/类
@Restrict({@Group("TEACHER"), @Group("ADMIN")})
public Result getParticipationsForExamAndUser(Long eid, Long uid) {
    List<ExamParticipation> participations = Ebean.find(ExamParticipation.class)
            .fetch("exam", "id, state")
            .fetch("exam.grade", "id, name")
            .where()
            .eq("user.id", uid)
            .eq("exam.parent.id", eid)
            .disjunction()
            .eq("exam.state", Exam.State.ABORTED)
            .eq("exam.state", Exam.State.GRADED)
            .eq("exam.state", Exam.State.GRADED_LOGGED)
            .eq("exam.state", Exam.State.ARCHIVED)
            .endJunction()
            .findList();
    return ok(participations);
}
 
开发者ID:CSCfi,项目名称:exam,代码行数:18,代码来源:ReviewController.java


注:本文中的io.ebean.Ebean类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。