use of jooq.steve.db.tables.OcppTag in project steve by RWTH-i5-IDSG.
the class OcppTagRepositoryImpl method getOverview.
@Override
@SuppressWarnings("unchecked")
public List<Overview> getOverview(OcppTagQueryForm form) {
SelectQuery selectQuery = ctx.selectQuery();
selectQuery.addFrom(OCPP_TAG);
OcppTag parentTable = OCPP_TAG.as("parent");
selectQuery.addSelect(OCPP_TAG.OCPP_TAG_PK, parentTable.OCPP_TAG_PK, OCPP_TAG.ID_TAG, OCPP_TAG.PARENT_ID_TAG, OCPP_TAG.EXPIRY_DATE, OCPP_TAG.IN_TRANSACTION, OCPP_TAG.BLOCKED);
selectQuery.addJoin(parentTable, JoinType.LEFT_OUTER_JOIN, parentTable.ID_TAG.eq(OCPP_TAG.PARENT_ID_TAG));
if (form.isIdTagSet()) {
selectQuery.addConditions(OCPP_TAG.ID_TAG.eq(form.getIdTag()));
}
if (form.isParentIdTagSet()) {
selectQuery.addConditions(OCPP_TAG.PARENT_ID_TAG.eq(form.getParentIdTag()));
}
switch(form.getExpired()) {
case ALL:
break;
case TRUE:
selectQuery.addConditions(OCPP_TAG.EXPIRY_DATE.lessOrEqual(CustomDSL.utcTimestamp()));
break;
case FALSE:
selectQuery.addConditions(OCPP_TAG.EXPIRY_DATE.isNull().or(OCPP_TAG.EXPIRY_DATE.greaterThan(CustomDSL.utcTimestamp())));
break;
default:
throw new SteveException("Unknown enum type");
}
processBooleanType(selectQuery, OCPP_TAG.IN_TRANSACTION, form.getInTransaction());
processBooleanType(selectQuery, OCPP_TAG.BLOCKED, form.getBlocked());
return selectQuery.fetch().map(new UserMapper());
}
Aggregations