use of org.jooq.Record1 in project waltz by khartec.
the class ChangeInitiativeHarness method main.
public static void main(String[] args) throws ParseException {
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(DIConfiguration.class);
DSLContext dsl = ctx.getBean(DSLContext.class);
ChangeInitiativeDao dao = ctx.getBean(ChangeInitiativeDao.class);
ChangeInitiative changeInitiative = dao.getById(1L);
System.out.println(changeInitiative);
SelectConditionStep<Record1<Long>> ouHier = dsl.selectDistinct(ENTITY_HIERARCHY.ANCESTOR_ID).from(ENTITY_HIERARCHY).where(ENTITY_HIERARCHY.ID.eq(210L).and(ENTITY_HIERARCHY.KIND.eq(EntityKind.ORG_UNIT.name())));
SelectConditionStep<Record1<Long>> baseIdSelector = dsl.selectDistinct(CHANGE_INITIATIVE.ID).from(CHANGE_INITIATIVE).where(CHANGE_INITIATIVE.ORGANISATIONAL_UNIT_ID.in(ouHier));
SelectConditionStep<Record1<Long>> ciHier = dsl.selectDistinct(ENTITY_HIERARCHY.ANCESTOR_ID).from(ENTITY_HIERARCHY).where(ENTITY_HIERARCHY.ID.in(baseIdSelector).and(ENTITY_HIERARCHY.KIND.eq(EntityKind.CHANGE_INITIATIVE.name())));
dsl.select(CHANGE_INITIATIVE.NAME).from(CHANGE_INITIATIVE).where(CHANGE_INITIATIVE.ID.in(ciHier)).forEach(System.out::println);
}
use of org.jooq.Record1 in project waltz by khartec.
the class DataFlowHarness method main.
public static void main(String[] args) throws ParseException {
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(DIConfiguration.class);
DSLContext dsl = ctx.getBean(DSLContext.class);
LogicalFlowService service = ctx.getBean(LogicalFlowService.class);
LogicalFlowDao dao = ctx.getBean(LogicalFlowDao.class);
LogicalFlowIdSelectorFactory factory = ctx.getBean(LogicalFlowIdSelectorFactory.class);
IdSelectionOptions options = IdSelectionOptions.mkOpts(EntityReference.mkRef(EntityKind.ORG_UNIT, 5000), HierarchyQueryScope.CHILDREN);
Select<Record1<Long>> selector = factory.apply(options);
System.out.println(selector);
List<LogicalFlow> flows = dao.findBySelector(selector);
flows.forEach(System.out::println);
// by data type
EntityReference dataType = EntityReference.mkRef(EntityKind.DATA_TYPE, 6000);
IdSelectionOptions dataTypeOptions = IdSelectionOptions.mkOpts(dataType, HierarchyQueryScope.CHILDREN);
List<LogicalFlow> byDataTypeFlows = service.findBySelector(dataTypeOptions);
byDataTypeFlows.forEach(System.out::println);
System.out.println(byDataTypeFlows.size());
}
use of org.jooq.Record1 in project waltz by khartec.
the class EndUserAppIdSelectorFactory method mkForOrgUnit.
@Override
protected Select<Record1<Long>> mkForOrgUnit(EntityReference ref, HierarchyQueryScope scope) {
IdSelectionOptions ouSelectorOptions = ImmutableIdSelectionOptions.builder().entityReference(ref).scope(scope).build();
Select<Record1<Long>> ouSelector = orgUnitIdSelectorFactory.apply(ouSelectorOptions);
return dsl.selectDistinct(eua.ID).from(eua).where(dsl.renderInlined(eua.ORGANISATIONAL_UNIT_ID.in(ouSelector)));
}
use of org.jooq.Record1 in project waltz by khartec.
the class LogicalFlowIdSelectorFactory method wrapAppIdSelector.
private Select<Record1<Long>> wrapAppIdSelector(IdSelectionOptions options) {
Select<Record1<Long>> appIdSelector = applicationIdSelectorFactory.apply(options);
Condition sourceCondition = LOGICAL_FLOW.SOURCE_ENTITY_ID.in(appIdSelector).and(LOGICAL_FLOW.SOURCE_ENTITY_KIND.eq(EntityKind.APPLICATION.name()));
Condition targetCondition = LOGICAL_FLOW.TARGET_ENTITY_ID.in(appIdSelector).and(LOGICAL_FLOW.TARGET_ENTITY_KIND.eq(EntityKind.APPLICATION.name()));
return DSL.select(LOGICAL_FLOW.ID).from(LOGICAL_FLOW).where(sourceCondition.or(targetCondition)).and(NOT_REMOVED);
}
use of org.jooq.Record1 in project steve by RWTH-i5-IDSG.
the class OcppServerRepositoryImpl method insertTransaction.
@Override
public Integer insertTransaction(InsertTransactionParams p) {
return ctx.transactionResult(configuration -> {
DSLContext ctx = DSL.using(configuration);
insertIgnoreConnector(ctx, p.getChargeBoxId(), p.getConnectorId());
// it is important to insert idTag before transaction, since the transaction table references it
boolean unknownTagInserted = insertIgnoreIdTag(ctx, p);
SelectConditionStep<Record1<Integer>> connectorPkQuery = DSL.select(CONNECTOR.CONNECTOR_PK).from(CONNECTOR).where(CONNECTOR.CHARGE_BOX_ID.equal(p.getChargeBoxId())).and(CONNECTOR.CONNECTOR_ID.equal(p.getConnectorId()));
// -------------------------------------------------------------------------
// Step 1: Insert transaction
// -------------------------------------------------------------------------
int transactionId = ctx.insertInto(TRANSACTION).set(CONNECTOR_STATUS.CONNECTOR_PK, connectorPkQuery).set(TRANSACTION.ID_TAG, p.getIdTag()).set(TRANSACTION.START_TIMESTAMP, p.getStartTimestamp()).set(TRANSACTION.START_VALUE, p.getStartMeterValue()).returning(TRANSACTION.TRANSACTION_PK).fetchOne().getTransactionPk();
if (unknownTagInserted) {
log.warn("The transaction '{}' contains an unknown idTag '{}' which was inserted into DB " + "to prevent information loss and has been blocked", transactionId, p.getIdTag());
}
if (p.isSetReservationId()) {
reservationRepository.used(ctx, connectorPkQuery, p.getIdTag(), p.getReservationId(), transactionId);
}
// -------------------------------------------------------------------------
// Step 3: Set connector status to "Occupied"
// -------------------------------------------------------------------------
insertConnectorStatus(ctx, connectorPkQuery, p.getStartTimestamp(), p.getStatusUpdate());
return transactionId;
});
}
Aggregations