use of jooq.steve.db.tables.records.AddressRecord in project steve by RWTH-i5-IDSG.
the class ChargePointRepositoryImpl method getDetails.
@Override
public ChargePoint.Details getDetails(int chargeBoxPk) {
ChargeBoxRecord cbr = ctx.selectFrom(CHARGE_BOX).where(CHARGE_BOX.CHARGE_BOX_PK.equal(chargeBoxPk)).fetchOne();
if (cbr == null) {
throw new SteveException("Charge point not found");
}
AddressRecord ar = addressRepository.get(ctx, cbr.getAddressPk());
return new ChargePoint.Details(cbr, ar);
}
use of jooq.steve.db.tables.records.AddressRecord in project steve by RWTH-i5-IDSG.
the class UserRepositoryImpl method getDetails.
@Override
public User.Details getDetails(int userPk) {
// -------------------------------------------------------------------------
// 1. user table
// -------------------------------------------------------------------------
UserRecord ur = ctx.selectFrom(USER).where(USER.USER_PK.equal(userPk)).fetchOne();
if (ur == null) {
throw new SteveException("There is no user with id '%s'", userPk);
}
// -------------------------------------------------------------------------
// 2. address table
// -------------------------------------------------------------------------
AddressRecord ar = addressRepository.get(ctx, ur.getAddressPk());
// -------------------------------------------------------------------------
// 3. ocpp_tag table
// -------------------------------------------------------------------------
String ocppIdTag = null;
if (ur.getOcppTagPk() != null) {
Record1<String> record = ctx.select(OCPP_TAG.ID_TAG).from(OCPP_TAG).where(OCPP_TAG.OCPP_TAG_PK.eq(ur.getOcppTagPk())).fetchOne();
if (record != null) {
ocppIdTag = record.value1();
}
}
return User.Details.builder().userRecord(ur).address(ar).ocppIdTag(Optional.ofNullable(ocppIdTag)).build();
}
Aggregations