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


Java Ebean.save方法代码示例

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


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

示例1: addSoftware

import io.ebean.Ebean; //导入方法依赖的package包/类
@Restrict(@Group({"ADMIN"}))
public Result addSoftware(String name) {
    Software software = bindForm(Software.class);
    software.setStatus("ACTIVE");
    software.setName(name);
    Ebean.save(software);

    return ok(Json.toJson(software));
}
 
开发者ID:CSCfi,项目名称:exam,代码行数:10,代码来源:ExamMachineController.java

示例2: removeReservation

import io.ebean.Ebean; //导入方法依赖的package包/类
@Restrict({@Group("ADMIN"), @Group("STUDENT")})
public Result removeReservation(long id) throws NotFoundException {
    User user = getLoggedUser();
    final ExamEnrolment enrolment = Ebean.find(ExamEnrolment.class)
            .fetch("reservation")
            .fetch("reservation.machine")
            .fetch("reservation.machine.room")
            .where()
            .eq("user.id", user.getId())
            .eq("reservation.id", id)
            .findUnique();
    if (enrolment == null) {
        throw new NotFoundException(String.format("No reservation with id %d for current user.", id));
    }
    // Removal not permitted if reservation is in the past or ongoing
    final Reservation reservation = enrolment.getReservation();
    DateTime now = AppUtil.adjustDST(DateTime.now(), reservation);
    if (reservation.toInterval().isBefore(now) || reservation.toInterval().contains(now)) {
        return forbidden("sitnet_reservation_in_effect");
    }
    enrolment.setReservation(null);
    enrolment.setReservationCanceled(true);
    Ebean.save(enrolment);
    Ebean.delete(Reservation.class, id);

    // send email asynchronously
    final boolean isStudentUser = user.equals(enrolment.getUser());
    system.scheduler().scheduleOnce(Duration.create(1, TimeUnit.SECONDS), () -> {
        emailComposer.composeReservationCancellationNotification(enrolment.getUser(), reservation, "", isStudentUser, enrolment);
        Logger.info("Reservation cancellation confirmation email sent");
    }, system.dispatcher());
    return ok("removed");
}
 
开发者ID:CSCfi,项目名称:exam,代码行数:34,代码来源:CalendarController.java

示例3: makeNewReservation

import io.ebean.Ebean; //导入方法依赖的package包/类
private CompletionStage<Result> makeNewReservation(ExamEnrolment enrolment, Reservation reservation, User user) {
    Ebean.save(reservation);
    enrolment.setReservation(reservation);
    enrolment.setReservationCanceled(false);
    Ebean.save(enrolment);
    Exam exam = enrolment.getExam();
    // Send some emails asynchronously
    system.scheduler().scheduleOnce(Duration.create(1, TimeUnit.SECONDS), () -> {
        emailComposer.composeReservationNotification(user, reservation, exam, false);
        Logger.info("Reservation confirmation email sent to {}", user.getEmail());
    }, system.dispatcher());

    return wrapAsPromise(ok("ok"));
}
 
开发者ID:CSCfi,项目名称:exam,代码行数:15,代码来源:CalendarController.java

示例4: requestRemoval

import io.ebean.Ebean; //导入方法依赖的package包/类
private CompletionStage<Result> requestRemoval(String ref, User user) throws IOException {
    final ExamEnrolment enrolment = Ebean.find(ExamEnrolment.class)
            .fetch("reservation")
            .fetch("reservation.machine")
            .fetch("reservation.machine.room")
            .where()
            .eq("user.id", user.getId())
            .eq("reservation.externalRef", ref)
            .findUnique();
    if (enrolment == null) {
        return CompletableFuture.supplyAsync(() -> Results.notFound(String.format("No reservation with ref %s for current user.", ref)));
    }
    // Removal not permitted if reservation is in the past or ongoing
    final Reservation reservation = enrolment.getReservation();
    DateTime now = AppUtil.adjustDST(DateTime.now(), reservation.getExternalReservation());
    if (reservation.toInterval().isBefore(now) || reservation.toInterval().contains(now)) {
        return CompletableFuture.supplyAsync(() -> Results.forbidden("sitnet_reservation_in_effect"));
    }
    // good to go
    ExternalReservation external = reservation.getExternalReservation();
    URL url = parseUrl(external.getOrgRef(), external.getRoomRef(), ref);
    WSRequest request = wsClient.url(url.toString());
    Function<WSResponse, Result> onSuccess = response -> {
        if (response.getStatus() != 200) {
            JsonNode root = response.asJson();
            return Results.internalServerError(root.get("message").asText("Connection refused"));
        }
        enrolment.setReservation(null);
        enrolment.setReservationCanceled(true);
        Ebean.save(enrolment);
        reservation.delete();

        // send email asynchronously
        boolean isStudentUser = user.equals(enrolment.getUser());
        system.scheduler().scheduleOnce(Duration.create(1, TimeUnit.SECONDS), () -> {
            emailComposer.composeReservationCancellationNotification(enrolment.getUser(), reservation, "", isStudentUser, enrolment);
            Logger.info("Reservation cancellation confirmation email sent");
        }, system.dispatcher());

        return Results.ok();
    };
    return request.delete().thenApplyAsync(onSuccess);
}
 
开发者ID:CSCfi,项目名称:exam,代码行数:44,代码来源:ExternalReservationHandlerImpl.java

示例5: handleExternalReservation

import io.ebean.Ebean; //导入方法依赖的package包/类
private void handleExternalReservation(ExamEnrolment enrolment, JsonNode node, DateTime start, DateTime end,
                                       User user, String orgRef, String roomRef) {
    Reservation oldReservation = enrolment.getReservation();
    final Reservation reservation = new Reservation();
    reservation.setEndAt(end);
    reservation.setStartAt(start);
    reservation.setUser(user);
    reservation.setExternalRef(node.get("id").asText());

    // If this is due in less than a day, make sure we won't send a reminder
    if (start.minusDays(1).isBeforeNow()) {
        reservation.setReminderSent(true);
    }

    ExternalReservation external = new ExternalReservation();
    external.setOrgRef(orgRef);
    external.setRoomRef(roomRef);
    JsonNode machineNode = node.get("machine");
    JsonNode roomNode = machineNode.get("room");
    external.setMachineName(machineNode.get("name").asText());
    external.setRoomName(roomNode.get("name").asText());
    external.setRoomCode(roomNode.get("roomCode").asText());
    external.setRoomTz(roomNode.get("localTimezone").asText());
    external.setRoomInstruction(roomNode.path("roomInstruction").asText(null));
    external.setRoomInstructionEN(roomNode.path("roomInstructionEN").asText(null));
    external.setRoomInstructionSV(roomNode.path("roomInstructionSV").asText(null));
    external.save();
    reservation.setExternalReservation(external);
    Ebean.save(reservation);
    enrolment.setReservation(reservation);
    enrolment.setReservationCanceled(false);
    Ebean.save(enrolment);

    // Finally nuke the old reservation if any
    if (oldReservation != null) {
        Ebean.delete(oldReservation);
    }
    Exam exam = enrolment.getExam();
    // Attach the external machine data just so that email can be generated
    reservation.setMachine(parseExternalMachineData(machineNode));
    // Send some emails asynchronously
    system.scheduler().scheduleOnce(Duration.create(1, TimeUnit.SECONDS), () -> {
        emailComposer.composeReservationNotification(user, reservation, exam, false);
        Logger.info("Reservation confirmation email sent to {}", user.getEmail());
    }, system.dispatcher());
}
 
开发者ID:CSCfi,项目名称:exam,代码行数:47,代码来源:ExternalCalendarController.java


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