Search in sources :

Example 6 with Record1

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);
}
Also used : Condition(org.jooq.Condition) Record1(org.jooq.Record1)

Example 7 with Record1

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);
}
Also used : Condition(org.jooq.Condition) Record1(org.jooq.Record1)

Example 8 with Record1

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);
}
Also used : EntityReference(com.khartec.waltz.model.EntityReference) Record1(org.jooq.Record1)

Example 9 with Record1

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();
    }
}
Also used : EnrichedStructuralVariant(com.hartwig.hmftools.common.variant.structural.EnrichedStructuralVariant) ImmutableEnrichedStructuralVariant(com.hartwig.hmftools.common.variant.structural.ImmutableEnrichedStructuralVariant) InsertValuesStep21(org.jooq.InsertValuesStep21) Timestamp(java.sql.Timestamp) Date(java.util.Date) Record1(org.jooq.Record1)

Example 10 with Record1

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;
}
Also used : Record(org.jooq.Record) Record1(org.jooq.Record1) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

Record1 (org.jooq.Record1)58 Condition (org.jooq.Condition)22 AnnotationConfigApplicationContext (org.springframework.context.annotation.AnnotationConfigApplicationContext)16 DSLContext (org.jooq.DSLContext)14 Select (org.jooq.Select)10 ApplicationIdSelectorFactory (org.finos.waltz.data.application.ApplicationIdSelectorFactory)9 EntityReference (org.finos.waltz.model.EntityReference)8 IdSelectionOptions (org.finos.waltz.model.IdSelectionOptions)8 Record (org.jooq.Record)7 IdSelectionOptions (com.khartec.waltz.model.IdSelectionOptions)5 EntityKind (org.finos.waltz.model.EntityKind)5 EntityReference (com.khartec.waltz.model.EntityReference)4 List (java.util.List)4 Collectors (java.util.stream.Collectors)4 LogicalFlowDao (org.finos.waltz.data.logical_flow.LogicalFlowDao)4 EntityReference.mkRef (org.finos.waltz.model.EntityReference.mkRef)4 LogicalFlow (org.finos.waltz.model.logical_flow.LogicalFlow)4 DSL (org.jooq.impl.DSL)4 java.util (java.util)3 ArrayList (java.util.ArrayList)3