use of org.jooq.Record1 in project waltz by khartec.
the class AttestationInstanceService method findAttestationInstanceSummaryForSelector.
public Set<ApplicationAttestationSummaryCounts> findAttestationInstanceSummaryForSelector(ApplicationAttestationInstanceInfo applicationAttestationInstanceInfo) {
Condition condition = getApplicationAttestationFilterCondition(applicationAttestationInstanceInfo.filters());
ApplicationIdSelectorFactory applicationIdSelectorFactory = new ApplicationIdSelectorFactory();
Select<Record1<Long>> appIds = applicationIdSelectorFactory.apply(applicationAttestationInstanceInfo.selectionOptions());
return attestationInstanceDao.findAttestationInstanceSummaryForSelector(appIds, condition);
}
use of org.jooq.Record1 in project torodb by torodb.
the class AbstractMetaDataWriteInterface method writeMetaInfo.
@Override
public String writeMetaInfo(DSLContext dsl, MetaInfoKey key, String newValue) {
Condition c = kvTable.KEY.eq(key.getKeyName());
Optional<String> oldValue = dsl.select(kvTable.VALUE).from(kvTable).where(c).fetchOptional().map(Record1::value1);
if (oldValue.isPresent()) {
int updatedRows = dsl.update(kvTable).set(kvTable.KEY, key.getKeyName()).set(kvTable.VALUE, newValue).where(c).execute();
assert updatedRows == 1;
} else {
int newRows = dsl.insertInto(kvTable, kvTable.KEY, kvTable.VALUE).values(key.getKeyName(), newValue).execute();
assert newRows == 1;
}
return oldValue.orElse(null);
}
use of org.jooq.Record1 in project waltz by khartec.
the class SurveyRunService method generateSurveyInstanceRecipients.
public List<SurveyInstanceRecipient> generateSurveyInstanceRecipients(long surveyRunId) {
SurveyRun surveyRun = surveyRunDao.getById(surveyRunId);
checkNotNull(surveyRun, "surveyRun " + surveyRunId + " not found");
SurveyTemplate surveyTemplate = surveyTemplateDao.getById(surveyRun.surveyTemplateId());
checkNotNull(surveyTemplate, "surveyTemplate " + surveyRun.surveyTemplateId() + " not found");
IdSelectorFactory idSelectorFactory = idSelectorFactoryProvider.getForKind(surveyTemplate.targetEntityKind());
Select<Record1<Long>> idSelector = idSelectorFactory.apply(surveyRun.selectionOptions());
Map<EntityReference, List<Person>> entityRefToPeople = involvementDao.findPeopleByEntitySelectorAndInvolvement(surveyTemplate.targetEntityKind(), idSelector, surveyRun.involvementKindIds());
return entityRefToPeople.entrySet().stream().flatMap(e -> e.getValue().stream().map(p -> ImmutableSurveyInstanceRecipient.builder().surveyInstance(ImmutableSurveyInstance.builder().surveyEntity(e.getKey()).surveyRunId(surveyRun.id().get()).status(SurveyInstanceStatus.NOT_STARTED).dueDate(surveyRun.dueDate()).build()).person(p).build())).distinct().collect(toList());
}
use of org.jooq.Record1 in project waltz by khartec.
the class AuthSourceRatingCalculator method update.
private int[] update(DataType dataType, EntityReference vantageRef) {
LOG.info("Updating ratings for auth source - dataType: {}, vantage point: {}", dataType, vantageRef);
IdSelectionOptions selectorOptions = mkOpts(vantageRef, HierarchyQueryScope.CHILDREN);
Select<Record1<Long>> selector = appIdSelectorFactory.apply(selectorOptions);
Collection<LogicalFlowDecorator> impactedDecorators = logicalFlowDecoratorDao.findByEntityIdSelectorAndKind(EntityKind.APPLICATION, selector, EntityKind.DATA_TYPE).stream().filter(decorator -> decorator.decoratorEntity().id() == dataType.id().get()).collect(toList());
Collection<LogicalFlowDecorator> reRatedDecorators = ratingsCalculator.calculate(impactedDecorators);
Set<LogicalFlowDecorator> modifiedDecorators = SetUtilities.minus(fromCollection(reRatedDecorators), fromCollection(impactedDecorators));
LOG.info("Need to update {} ratings due to auth source change - dataType: {}, parent: {}", modifiedDecorators.size(), dataType, vantageRef);
return updateDecorators(modifiedDecorators);
}
use of org.jooq.Record1 in project waltz by khartec.
the class PhysicalSpecificationIdSelectorFactory method mkForFlowDiagram.
private Select<Record1<Long>> mkForFlowDiagram(IdSelectionOptions options) {
ensureScopeIsExact(options);
Select<Record1<Long>> flowSelector = physicalFlowIdSelectorFactory.apply(options);
Condition condition = PHYSICAL_FLOW.ID.in(flowSelector);
return selectViaPhysicalFlowJoin(condition);
}
Aggregations