use of de.rwth.idsg.steve.SteveException 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();
}
use of de.rwth.idsg.steve.SteveException in project steve by RWTH-i5-IDSG.
the class UserRepositoryImpl method update.
@Override
public void update(UserForm form) {
ctx.transaction(configuration -> {
DSLContext ctx = DSL.using(configuration);
try {
Integer addressId = addressRepository.updateOrInsert(ctx, form.getAddress());
updateInternal(ctx, form, addressId);
} catch (DataAccessException e) {
throw new SteveException("Failed to update the user", e);
}
});
}
Aggregations