Пример #1
0
 private void updateChargePointInternal(DSLContext ctx, ChargePointForm form, Integer addressPk) {
   ctx.update(CHARGE_BOX)
       .set(CHARGE_BOX.DESCRIPTION, form.getDescription())
       .set(CHARGE_BOX.LOCATION_LATITUDE, form.getLocationLatitude())
       .set(CHARGE_BOX.LOCATION_LONGITUDE, form.getLocationLongitude())
       .set(CHARGE_BOX.NOTE, form.getNote())
       .set(CHARGE_BOX.ADDRESS_PK, addressPk)
       .where(CHARGE_BOX.CHARGE_BOX_PK.equal(form.getChargeBoxPk()))
       .execute();
 }
Пример #2
0
 private int addChargePointInternal(DSLContext ctx, ChargePointForm form, Integer addressPk) {
   return ctx.insertInto(CHARGE_BOX)
       .set(CHARGE_BOX.CHARGE_BOX_ID, form.getChargeBoxId())
       .set(CHARGE_BOX.DESCRIPTION, form.getDescription())
       .set(CHARGE_BOX.LOCATION_LATITUDE, form.getLocationLatitude())
       .set(CHARGE_BOX.LOCATION_LONGITUDE, form.getLocationLongitude())
       .set(CHARGE_BOX.NOTE, form.getNote())
       .set(CHARGE_BOX.ADDRESS_PK, addressPk)
       .returning(CHARGE_BOX.CHARGE_BOX_PK)
       .fetchOne()
       .getChargeBoxPk();
 }
Пример #3
0
  @Override
  public int addChargePoint(ChargePointForm form) {
    return ctx.transactionResult(
        configuration -> {
          DSLContext ctx = DSL.using(configuration);
          try {
            Integer addressId = addressRepository.updateOrInsert(ctx, form.getAddress());
            return addChargePointInternal(ctx, form, addressId);

          } catch (DataAccessException e) {
            throw new SteveException(
                "Failed to add the charge point with chargeBoxId '%s'", form.getChargeBoxId(), e);
          }
        });
  }