use of org.jooq.Record1 in project waltz by khartec.
the class AuthoritativeSourceService method findNonAuthSources.
public List<NonAuthoritativeSource> findNonAuthSources(EntityReference parentRef) {
Condition customSelectionCriteria;
switch(parentRef.kind()) {
case DATA_TYPE:
Select<Record1<Long>> dtSelector = dataTypeIdSelectorFactory.apply(mkOpts(parentRef, HierarchyQueryScope.CHILDREN));
customSelectionCriteria = LOGICAL_FLOW_DECORATOR.DECORATOR_ENTITY_ID.in(dtSelector);
break;
case ORG_UNIT:
Select<Record1<Long>> ouSelector = organisationalUnitIdSelectorFactory.apply(mkOpts(parentRef, HierarchyQueryScope.CHILDREN));
customSelectionCriteria = AuthoritativeSourceDao.CONSUMER_APP.ORGANISATIONAL_UNIT_ID.in(ouSelector);
break;
case MEASURABLE:
case PERSON:
customSelectionCriteria = mkConsumerSelectionCondition(parentRef, HierarchyQueryScope.CHILDREN);
break;
case APP_GROUP:
case FLOW_DIAGRAM:
customSelectionCriteria = mkConsumerSelectionCondition(parentRef, HierarchyQueryScope.EXACT);
break;
default:
throw new UnsupportedOperationException("Cannot calculate non-auth sources for ref" + parentRef);
}
return authoritativeSourceDao.findNonAuthSources(customSelectionCriteria);
}
use of org.jooq.Record1 in project waltz by khartec.
the class AuthoritativeSourceService method findAuthSources.
public List<AuthoritativeSource> findAuthSources(EntityReference parentRef) {
Condition customSelectionCriteria;
switch(parentRef.kind()) {
case ORG_UNIT:
Select<Record1<Long>> ouSelector = organisationalUnitIdSelectorFactory.apply(mkOpts(parentRef, HierarchyQueryScope.PARENTS));
customSelectionCriteria = AUTHORITATIVE_SOURCE.PARENT_ID.in(ouSelector);
break;
case DATA_TYPE:
Select<Record1<Long>> dtSelector = dataTypeIdSelectorFactory.apply(mkOpts(parentRef, HierarchyQueryScope.CHILDREN));
SelectConditionStep<Record1<String>> codeSelector = DSL.select(DATA_TYPE.CODE).from(DATA_TYPE).where(DATA_TYPE.ID.in(dtSelector));
customSelectionCriteria = AUTHORITATIVE_SOURCE.DATA_TYPE.in(codeSelector);
break;
case MEASURABLE:
case PERSON:
customSelectionCriteria = mkConsumerSelectionCondition(parentRef, HierarchyQueryScope.CHILDREN);
break;
case APP_GROUP:
case FLOW_DIAGRAM:
customSelectionCriteria = mkConsumerSelectionCondition(parentRef, HierarchyQueryScope.EXACT);
break;
default:
throw new UnsupportedOperationException("Cannot calculate auth sources for ref" + parentRef);
}
return authoritativeSourceDao.findAuthSources(customSelectionCriteria);
}
use of org.jooq.Record1 in project waltz by khartec.
the class ChangeInitiativeIdSelectorFactory method mkForRef.
private Select<Record1<Long>> mkForRef(IdSelectionOptions options) {
EntityReference ref = options.entityReference();
Select<Record1<Long>> aToB = selectDistinct(ENTITY_RELATIONSHIP.ID_A).from(ENTITY_RELATIONSHIP).where(ENTITY_RELATIONSHIP.KIND_A.eq(EntityKind.CHANGE_INITIATIVE.name())).and(ENTITY_RELATIONSHIP.KIND_B.eq(ref.kind().name())).and(ENTITY_RELATIONSHIP.ID_B.eq(ref.id()));
Select<Record1<Long>> bToA = selectDistinct(ENTITY_RELATIONSHIP.ID_B).from(ENTITY_RELATIONSHIP).where(ENTITY_RELATIONSHIP.KIND_B.eq(EntityKind.CHANGE_INITIATIVE.name())).and(ENTITY_RELATIONSHIP.KIND_A.eq(ref.kind().name())).and(ENTITY_RELATIONSHIP.ID_A.eq(ref.id()));
return aToB.union(bToA);
}
use of org.jooq.Record1 in project hmftools by hartwigmedical.
the class StructuralVariantDAO method write.
void write(@NotNull final String sample, @NotNull final List<EnrichedStructuralVariant> variants) {
Timestamp timestamp = new Timestamp(new Date().getTime());
final Result<Record1<UInteger>> breakendsToDelete = context.select(STRUCTURALVARIANTBREAKEND.ID).from(STRUCTURALVARIANTBREAKEND).innerJoin(STRUCTURALVARIANT).on(STRUCTURALVARIANT.ID.eq(STRUCTURALVARIANTBREAKEND.STRUCTURALVARIANTID)).where(STRUCTURALVARIANT.SAMPLEID.eq(sample)).fetch();
// first delete annotations
context.delete(STRUCTURALVARIANTDISRUPTION).where(STRUCTURALVARIANTDISRUPTION.BREAKENDID.in(breakendsToDelete)).execute();
context.delete(STRUCTURALVARIANTFUSION).where(STRUCTURALVARIANTFUSION.FIVEPRIMEBREAKENDID.in(breakendsToDelete)).execute();
context.delete(STRUCTURALVARIANTBREAKEND).where(STRUCTURALVARIANTBREAKEND.ID.in(breakendsToDelete)).execute();
// and then the structural variants
context.delete(STRUCTURALVARIANT).where(STRUCTURALVARIANT.SAMPLEID.eq(sample)).execute();
for (List<EnrichedStructuralVariant> batch : Iterables.partition(variants, DB_BATCH_INSERT_SIZE)) {
InsertValuesStep21 inserter = context.insertInto(STRUCTURALVARIANT, STRUCTURALVARIANT.SAMPLEID, STRUCTURALVARIANT.STARTCHROMOSOME, STRUCTURALVARIANT.ENDCHROMOSOME, STRUCTURALVARIANT.STARTPOSITION, STRUCTURALVARIANT.ENDPOSITION, STRUCTURALVARIANT.STARTORIENTATION, STRUCTURALVARIANT.ENDORIENTATION, STRUCTURALVARIANT.STARTHOMOLOGYSEQUENCE, STRUCTURALVARIANT.ENDHOMOLOGYSEQUENCE, STRUCTURALVARIANT.INSERTSEQUENCE, STRUCTURALVARIANT.TYPE, STRUCTURALVARIANT.STARTAF, STRUCTURALVARIANT.ADJUSTEDSTARTAF, STRUCTURALVARIANT.ADJUSTEDSTARTCOPYNUMBER, STRUCTURALVARIANT.ADJUSTEDSTARTCOPYNUMBERCHANGE, STRUCTURALVARIANT.ENDAF, STRUCTURALVARIANT.ADJUSTEDENDAF, STRUCTURALVARIANT.ADJUSTEDENDCOPYNUMBER, STRUCTURALVARIANT.ADJUSTEDENDCOPYNUMBERCHANGE, STRUCTURALVARIANT.PLOIDY, STRUCTURALVARIANT.MODIFIED);
batch.forEach(entry -> addRecord(timestamp, inserter, sample, entry));
inserter.execute();
}
}
use of org.jooq.Record1 in project hmftools by hartwigmedical.
the class StructuralVariantDAO method getSamplesList.
@NotNull
public final List<String> getSamplesList(@NotNull final String sampleSearch) {
final Result<Record1<String>> result = sampleSearch.equals("") ? context.select(STRUCTURALVARIANT.SAMPLEID).from(STRUCTURALVARIANT).groupBy(STRUCTURALVARIANT.SAMPLEID).fetch() : context.select(STRUCTURALVARIANT.SAMPLEID).from(STRUCTURALVARIANT).where(STRUCTURALVARIANT.SAMPLEID.like(sampleSearch)).groupBy(STRUCTURALVARIANT.SAMPLEID).fetch();
List<String> samplesList = Lists.newArrayList();
for (Record record : result) {
samplesList.add(record.getValue(STRUCTURALVARIANT.SAMPLEID));
}
return samplesList;
}
Aggregations