org.jooq.Record1 Java Examples

The following examples show how to use org.jooq.Record1. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AbstractIdSelectorFactory.java    From waltz with Apache License 2.0 6 votes vote down vote up
private Select<Record1<Long>> mkForSelf(IdSelectionOptions options) {

        Select<Record1<Long>> selector = null;
        switch (options.scope()) {
            case EXACT:
                selector = DSL.select(DSL.val(options.entityReference().id()));
                break;
            case CHILDREN:
                selector = DSL.select(ENTITY_HIERARCHY.ID)
                        .from(ENTITY_HIERARCHY)
                        .where(ENTITY_HIERARCHY.ANCESTOR_ID.eq(options.entityReference().id()))
                        .and(ENTITY_HIERARCHY.KIND.eq(entityKind.name()));
                break;
            case PARENTS:
                selector = DSL.select(ENTITY_HIERARCHY.ANCESTOR_ID)
                        .from(ENTITY_HIERARCHY)
                        .where(ENTITY_HIERARCHY.ID.eq(options.entityReference().id()))
                        .and(ENTITY_HIERARCHY.KIND.eq(entityKind.name()));
                break;
        }

        return selector;
    }
 
Example #2
Source File: LogicalFlowIdSelectorFactory.java    From waltz with Apache License 2.0 6 votes vote down vote up
private Select<Record1<Long>> mkForServer(IdSelectionOptions options) {
    ensureScopeIsExact(options);

    Condition lifecycleCondition = (options.entityLifecycleStatuses().contains(EntityLifecycleStatus.REMOVED)
                ? DSL.trueCondition()
                : PHYSICAL_FLOW.IS_REMOVED.isFalse())
            .and(mkLifecycleStatusCondition(options));

    long serverId = options.entityReference().id();
    return DSL
            .select(LOGICAL_FLOW.ID)
            .from(LOGICAL_FLOW)
            .innerJoin(PHYSICAL_FLOW)
            .on(PHYSICAL_FLOW.LOGICAL_FLOW_ID.eq(LOGICAL_FLOW.ID))
            .innerJoin(PHYSICAL_FLOW_PARTICIPANT)
            .on(PHYSICAL_FLOW_PARTICIPANT.PHYSICAL_FLOW_ID.eq(PHYSICAL_FLOW.ID))
            .where(PHYSICAL_FLOW_PARTICIPANT.PARTICIPANT_ENTITY_KIND.eq(EntityKind.SERVER.name()))
            .and(PHYSICAL_FLOW_PARTICIPANT.PARTICIPANT_ENTITY_ID.eq(serverId))
            .and(lifecycleCondition);
}
 
Example #3
Source File: RoadmapGenerator.java    From waltz with Apache License 2.0 6 votes vote down vote up
private void removeRoadmap(ApplicationContext ctx, String roadmapName) {
    DSLContext dsl = getDsl(ctx);

    dsl.select(ROADMAP.ID)
            .from(ROADMAP)
            .where(ROADMAP.NAME.eq(roadmapName))
            .fetchOptional(ROADMAP.ID)
            .ifPresent(rId -> {
                SelectConditionStep<Record1<Long>> scenarioIds = DSL
                        .select(SCENARIO.ID)
                        .from(SCENARIO)
                        .where(SCENARIO.ROADMAP_ID.eq(rId));

                dsl.deleteFrom(SCENARIO_AXIS_ITEM)
                        .where(SCENARIO_AXIS_ITEM.SCENARIO_ID.in(scenarioIds))
                        .execute();

                dsl.deleteFrom(SCENARIO_RATING_ITEM)
                        .where(SCENARIO_RATING_ITEM.SCENARIO_ID.in(scenarioIds))
                        .execute();

                dsl.deleteFrom(ROADMAP)
                        .where(ROADMAP.ID.eq(rId))
                        .execute();
            });
}
 
Example #4
Source File: DatabaseHandler.java    From FROST-Server with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * This method checks if the given user exists and has the given role.
 *
 * @param userName The username of the user to check the role for.
 * @param userPass The password of the user to check the role for.
 * @param roleName The role to check.
 * @return true if the user exists AND has the given password AND has the
 * given role.
 */
public boolean userHasRole(String userName, String userPass, String roleName) {
    maybeUpdateDatabase();
    try {
        Record1<Integer> one = getDslContext()
                .selectOne()
                .from(TableUsers.USERS)
                .leftJoin(TableUsersRoles.USER_ROLES)
                .on(TableUsers.USERS.userName.eq(TableUsersRoles.USER_ROLES.userName))
                .where(
                        TableUsers.USERS.userName.eq(userName)
                                .and(TableUsers.USERS.userPass.eq(userPass))
                                .and(TableUsersRoles.USER_ROLES.roleName.eq(roleName))
                ).fetchOne();
        return one != null;
    } catch (DataAccessException exc) {
        LOGGER.error("Failed to check user rights.", exc);
        return false;
    } finally {
        connectionProvider.doRollback();
    }
}
 
Example #5
Source File: DatabaseHandler.java    From FROST-Server with GNU Lesser General Public License v3.0 6 votes vote down vote up
public boolean isValidUser(String userName, String password) {
    maybeUpdateDatabase();
    try {
        Record1<Integer> one = getDslContext()
                .selectOne()
                .from(TableUsers.USERS)
                .where(
                        TableUsers.USERS.userName.eq(userName)
                                .and(TableUsers.USERS.userPass.eq(password))
                ).fetchOne();
        return one != null;
    } catch (DataAccessException exc) {
        LOGGER.error("Failed to check user credentials.", exc);
        return false;
    }
}
 
Example #6
Source File: EndUserAppIdSelectorFactory.java    From waltz with Apache License 2.0 6 votes vote down vote up
private Select<Record1<Long>> mkForPersonReportees(IdSelectionOptions options) {

        if (eucOmitted(options)) {
            return mkEmptySelect();
        }

        Select<Record1<String>> employeeId = mkEmployeeIdSelect(options.entityReference());
        SelectConditionStep<Record1<String>> reporteeIds = DSL.selectDistinct(personHierarchy.EMPLOYEE_ID)
                .from(personHierarchy)
                .where(personHierarchy.MANAGER_ID.eq(employeeId));

        Condition condition = involvement.ENTITY_KIND.eq(EntityKind.END_USER_APPLICATION.name())
                .and(involvement.EMPLOYEE_ID.eq(employeeId)
                        .or(involvement.EMPLOYEE_ID.in(reporteeIds)));

        return DSL
                .selectDistinct(involvement.ENTITY_ID)
                .from(involvement)
                .innerJoin(eua)
                .on(eua.ID.eq(involvement.ENTITY_ID))
                .where(condition);
    }
 
Example #7
Source File: PhysicalSpecificationIdSelectorFactory.java    From waltz with Apache License 2.0 6 votes vote down vote up
private Select<Record1<Long>> mkForServer(IdSelectionOptions options) {
    ensureScopeIsExact(options);

    long serverId = options.entityReference().id();

    return DSL
            .select(PHYSICAL_FLOW.SPECIFICATION_ID)
            .from(PHYSICAL_FLOW)
            .innerJoin(PHYSICAL_SPECIFICATION)
            .on(PHYSICAL_SPECIFICATION.ID.eq(PHYSICAL_FLOW.SPECIFICATION_ID))
            .innerJoin(PHYSICAL_FLOW_PARTICIPANT)
            .on(PHYSICAL_FLOW_PARTICIPANT.PHYSICAL_FLOW_ID.eq(PHYSICAL_FLOW.ID))
            .where(PHYSICAL_FLOW_PARTICIPANT.PARTICIPANT_ENTITY_KIND.eq(EntityKind.SERVER.name()))
            .and(PHYSICAL_FLOW_PARTICIPANT.PARTICIPANT_ENTITY_ID.eq(serverId))
            .and(getLifecycleCondition(options));

}
 
Example #8
Source File: RoadmapIdSelectorFactory.java    From waltz with Apache License 2.0 6 votes vote down vote up
@Override
public Select<Record1<Long>> apply(IdSelectionOptions options) {

    switch (options.entityReference().kind()) {
        case ORG_UNIT:
        case PERSON:
        case APP_GROUP:
            return mkViaRelationships(options);
        default:
            // update class comment if list of supported entities changes
            String msg = String.format(
                    "Cannot create Change Initiative Id selector from kind: %s",
                    options.entityReference().kind());
            throw new UnsupportedOperationException(msg);
    }
}
 
Example #9
Source File: GenericSelectorFactory.java    From waltz with Apache License 2.0 5 votes vote down vote up
/***
 * Apply a selector using the appropriate factory as defined by kind
 * @param kind
 * @param selectionOptions
 * @return
 */
private Select<Record1<Long>> applySelectorForKind(EntityKind kind, IdSelectionOptions selectionOptions) {
    switch (kind) {
        case APPLICATION:
            return applicationIdSelectorFactory.apply(selectionOptions);
        case CHANGE_INITIATIVE:
            return changeInitiativeIdSelectorFactory.apply(selectionOptions);
        case CHANGE_UNIT:
            return changeUnitIdSelectorFactory.apply(selectionOptions);
        case DATA_TYPE:
            return dataTypeIdSelectorFactory.apply(selectionOptions);
        case FLOW_DIAGRAM:
            return flowDiagramIdSelectorFactory.apply(selectionOptions);
        case LICENCE:
            return licenceIdSelectorFactory.apply(selectionOptions);
        case LOGICAL_DATA_FLOW:
            return logicalFlowIdSelectorFactory.apply(selectionOptions);
        case MEASURABLE:
            return measurableIdSelectorFactory.apply(selectionOptions);
        case ORG_UNIT:
            return organisationalUnitIdSelectorFactory.apply(selectionOptions);
        case ATTESTATION:
            return attestationIdSelectorFactory.apply(selectionOptions);
        case PHYSICAL_SPECIFICATION:
            return specificationIdSelectorFactory.apply(selectionOptions);
        //todo: (KS) Add support for Person
        default:
            throw new UnsupportedOperationException(String.format("Cannot make generic selector for kind: %s", kind));
    }
}
 
Example #10
Source File: LicenceIdSelectorFactory.java    From waltz with Apache License 2.0 5 votes vote down vote up
@Override
protected Select<Record1<Long>> mkForOptions(IdSelectionOptions options) {
    switch (options.entityReference().kind()) {
        case APPLICATION:
            return mkForApplication(options);
        case SOFTWARE:
            return mkForSoftwarePackage(options);
        case SOFTWARE_VERSION:
            return mkForSoftwareVersion(options);
        case LICENCE:
            return mkForLicence(options);
        case ACTOR:
        case APP_GROUP:
        case CHANGE_INITIATIVE:
        case FLOW_DIAGRAM:
        case MEASURABLE:
        case ORG_UNIT:
        case PERSON:
        case SCENARIO:
            Select<Record1<Long>> appSelector = applicationIdSelectorFactory.apply(options);
            return mkFromAppSelector(appSelector);
        default:
            String msg = String.format(
                    "Cannot create Licence Id selector from kind: %s",
                    options.entityReference().kind());
            throw new UnsupportedOperationException(msg);
    }
}
 
Example #11
Source File: AttestationRunService.java    From waltz with Apache License 2.0 5 votes vote down vote up
public AttestationCreateSummary getCreateSummary(AttestationRunCreateCommand command){

        Select<Record1<Long>> idSelector = mkIdSelector(command.targetEntityKind(), command.selectionOptions());

        Map<EntityReference, List<Person>> entityReferenceToPeople = getEntityReferenceToPeople(
                command.targetEntityKind(),
                command.selectionOptions(),
                command.involvementKindIds());

        int entityCount = attestationRunDao.getEntityCount(idSelector);

        int instanceCount = entityReferenceToPeople
                .keySet()
                .size();

        long recipientCount = entityReferenceToPeople.values()
                .stream()
                .flatMap(Collection::stream)
                .distinct()
                .count();

        return ImmutableAttestationCreateSummary.builder()
                .entityCount(entityCount)
                .instanceCount(instanceCount)
                .recipientCount(recipientCount)
                .build();

    }
 
Example #12
Source File: DataFlowHarness.java    From waltz with Apache License 2.0 5 votes vote down vote up
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 = new LogicalFlowIdSelectorFactory();

        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());

    }
 
Example #13
Source File: ChangeInitiativeIdSelectorFactory.java    From waltz with Apache License 2.0 5 votes vote down vote up
private Select<Record1<Long>> mkForOrgUnit(IdSelectionOptions options) {
    Select<Record1<Long>> ouSelector = organisationalUnitIdSelectorFactory.apply(options);

    return DSL
            .selectDistinct(CHANGE_INITIATIVE.ID)
            .from(CHANGE_INITIATIVE)
            .where(CHANGE_INITIATIVE.ORGANISATIONAL_UNIT_ID.in(ouSelector));
}
 
Example #14
Source File: PhysicalFlowIdSelectorFactory.java    From waltz with Apache License 2.0 5 votes vote down vote up
private Select<Record1<Long>> mkForPhysicalSpecification(IdSelectionOptions options) {
    ensureScopeIsExact(options);
    long specificationId = options.entityReference().id();
    return DSL
            .select(PhysicalFlow.PHYSICAL_FLOW.ID)
            .from(PhysicalFlow.PHYSICAL_FLOW)
            .where(PhysicalFlow.PHYSICAL_FLOW.SPECIFICATION_ID.eq(specificationId));
}
 
Example #15
Source File: AuthoritativeSourceService.java    From waltz with Apache License 2.0 5 votes vote down vote up
public List<AuthoritativeSource> findAuthSources(IdSelectionOptions options) {
    Condition customSelectionCriteria;

    switch(options.entityReference().kind()) {
        case ORG_UNIT:
            GenericSelector orgUnitSelector = genericSelectorFactory.apply(options);
            customSelectionCriteria = AUTHORITATIVE_SOURCE.PARENT_ID.in(orgUnitSelector.selector())
                    .and(AuthoritativeSourceDao.SUPPLIER_APP.KIND.notIn(options.filters().omitApplicationKinds()));
            break;
        case DATA_TYPE:
            GenericSelector dataTypeSelector = genericSelectorFactory.apply(options);
            SelectConditionStep<Record1<String>> codeSelector = DSL
                    .select(DATA_TYPE.CODE)
                    .from(DATA_TYPE)
                    .where(DATA_TYPE.ID.in(dataTypeSelector.selector()));
            customSelectionCriteria = AUTHORITATIVE_SOURCE.DATA_TYPE.in(codeSelector)
                    .and(AuthoritativeSourceDao.SUPPLIER_APP.KIND.notIn(options.filters().omitApplicationKinds()));
            break;
        case APP_GROUP:
        case FLOW_DIAGRAM:
        case MEASURABLE:
        case PERSON:
            customSelectionCriteria = mkConsumerSelectionCondition(options);
            break;
        default:
            throw new UnsupportedOperationException("Cannot calculate auth sources for ref" + options.entityReference());
    }

    return authoritativeSourceDao.findAuthSources(customSelectionCriteria);

}
 
Example #16
Source File: AuthSourceRatingCalculator.java    From waltz with Apache License 2.0 5 votes vote down vote up
private int[] update(DataType dataType, EntityReference vantageRef) {
    LOG.debug("Updating ratings for auth source - dataType name: {}, id: {}, vantage point: {}",
            dataType.name(),
            dataType.id().get(),
            vantageRef);

    IdSelectionOptions selectorOptions = mkOpts(vantageRef, HierarchyQueryScope.CHILDREN);
    Select<Record1<Long>> selector = appIdSelectorFactory.apply(selectorOptions);
    Set<Long> dataTypeDescendents = entityHierarchyDao
            .findDesendents(dataType.entityReference())
            .stream()
            .map(d -> d.id().get())
            .collect(Collectors.toSet());

    Collection<DataTypeDecorator> impactedDecorators = logicalFlowDecoratorDao
            .findByEntityIdSelector(selector, Optional.of(EntityKind.APPLICATION))
            .stream()
            .filter(decorator -> dataTypeDescendents.contains(decorator.decoratorEntity().id()))
            .collect(toList());

    Collection<DataTypeDecorator> reRatedDecorators = ratingsCalculator.calculate(impactedDecorators);

    Set<DataTypeDecorator> modifiedDecorators = SetUtilities.minus(
            fromCollection(reRatedDecorators),
            fromCollection(impactedDecorators));

    LOG.debug("Need to update {} ratings due to auth source change - dataType name: {}, id: {}, parent: {}",
            modifiedDecorators.size(),
            dataType.name(),
            dataType.id().get(),
            vantageRef);

    return updateDecorators(modifiedDecorators);
}
 
Example #17
Source File: GenericSelectorFactory.java    From waltz with Apache License 2.0 5 votes vote down vote up
/***
 * This method evaluates a selector for the target kind which may not match the kind in selection options
 * Used when creating Survey or Attestation runs where the target kind may be different from the selection kind
 * @param targetKind
 * @param selectionOptions
 * @return
 */
public GenericSelector applyForKind(EntityKind targetKind, IdSelectionOptions selectionOptions) {
    checkNotNull(targetKind, "targetKind cannot be null");

    ImmutableGenericSelector.Builder builder = ImmutableGenericSelector.builder()
            .kind(targetKind);

    Select<Record1<Long>> ids = applySelectorForKind(targetKind, selectionOptions);
    builder.selector(ids);

    return builder.build();
}
 
Example #18
Source File: FlowDiagramIdSelectorFactory.java    From waltz with Apache License 2.0 5 votes vote down vote up
private Select<Record1<Long>> mkForPhysicalSpecification(IdSelectionOptions options) {
    ensureScopeIsExact(options);
    long specificationId = options.entityReference().id();
    return DSL
            .select(FLOW_DIAGRAM_ENTITY.DIAGRAM_ID)
            .from(FLOW_DIAGRAM_ENTITY)
            .innerJoin(PHYSICAL_FLOW)
            .on(FLOW_DIAGRAM_ENTITY.ENTITY_ID.eq(PHYSICAL_FLOW.ID)
                    .and(FLOW_DIAGRAM_ENTITY.ENTITY_KIND.eq(EntityKind.PHYSICAL_FLOW.name())))
            .where(PHYSICAL_FLOW.SPECIFICATION_ID.eq(specificationId));
}
 
Example #19
Source File: LootTrackerPlugin.java    From plugins with GNU General Public License v3.0 5 votes vote down vote up
private void userUuid(String name)
{
	if (userUuidMap.get(name) == null)
	{
		DSLContext dslContext = databaseManager.getDsl();

		dslContext
			.insertInto(
				USER,
				USER.UNIQUEID,
				USER.USERNAME
			)
			.values(
				UUID.randomUUID(),
				name
			)
			.onConflict(USER.USERNAME)
			.doNothing()
			.execute();

		Record1<UUID> user = dslContext
			.select(USER.UNIQUEID)
			.from(USER)
			.where(USER.USERNAME.eq(name))
			.fetchOne();

		userUuidMap.put(name, user.get(USER.UNIQUEID));
	}
}
 
Example #20
Source File: PersonHierarchyService.java    From waltz with Apache License 2.0 5 votes vote down vote up
public double countRoots() {
    SelectConditionStep<Record1<String>> rootSelector = DSL
            .selectDistinct(PERSON_HIERARCHY.MANAGER_ID)
            .from(PERSON_HIERARCHY)
            .where(PERSON_HIERARCHY.LEVEL.eq(1));

    return dsl.fetchCount(rootSelector);
}
 
Example #21
Source File: TagService.java    From waltz with Apache License 2.0 5 votes vote down vote up
public List<Tag> findTagsForEntityKindAndTargetSelector(EntityKind targetEntityKind,
                                                        IdSelectionOptions targetEntityIdSelectionOptions) {
    checkNotNull(targetEntityKind, "targetEntityKind cannot be null");
    checkNotNull(targetEntityIdSelectionOptions, "targetEntityIdSelectionOptions cannot be null");

    Select<Record1<Long>> targetEntityIdSelector = genericSelectorFactory
            .applyForKind(targetEntityKind, targetEntityIdSelectionOptions)
            .selector();
    return tagDao.findTagsForEntityKindAndTargetSelector(targetEntityKind, targetEntityIdSelector);
}
 
Example #22
Source File: ChangeUnitIdSelectorFactory.java    From waltz with Apache License 2.0 5 votes vote down vote up
private Select<Record1<Long>> mkForDirectEntity(IdSelectionOptions options) {
    ensureScopeIsExact(options);
    EntityReference ref = options.entityReference();
    return DSL
            .select(CHANGE_UNIT.ID)
            .from(CHANGE_UNIT)
            .where(CHANGE_UNIT.SUBJECT_ENTITY_ID.eq(ref.id()))
            .and(CHANGE_UNIT.SUBJECT_ENTITY_KIND.eq(ref.kind().name()));
}
 
Example #23
Source File: AssetCostService.java    From waltz with Apache License 2.0 5 votes vote down vote up
public List<Tuple2<Long, BigDecimal>> calculateCombinedAmountsForSelector(IdSelectionOptions options) {
    checkNotNull(options, "options cannot be null");

    Select<Record1<Long>> appIdSelector = idSelectorFactory.apply(options);

    return assetCostDao
            .findLatestYear()
            .map(y -> assetCostDao.calculateCombinedAmountsForSelector(y, appIdSelector))
            .orElse(Collections.emptyList());
}
 
Example #24
Source File: LogicalFlowIdSelectorFactory.java    From waltz with Apache License 2.0 5 votes vote down vote up
private Select<Record1<Long>> mkForPhysicalSpecification(IdSelectionOptions options) {
    ensureScopeIsExact(options);
    return DSL.select(LOGICAL_FLOW.ID)
            .from(LOGICAL_FLOW)
            .innerJoin(PHYSICAL_FLOW)
            .on(PHYSICAL_FLOW.LOGICAL_FLOW_ID.eq(LOGICAL_FLOW.ID))
            .where(PHYSICAL_FLOW.SPECIFICATION_ID.eq(options.entityReference().id()))
            .and(LOGICAL_NOT_REMOVED);
}
 
Example #25
Source File: ChangeUnitIdSelectorFactory.java    From waltz with Apache License 2.0 5 votes vote down vote up
private Select<Record1<Long>> mkForChangeSet(IdSelectionOptions options) {
    ensureScopeIsExact(options);
    return DSL
            .select(CHANGE_UNIT.ID)
            .from(CHANGE_UNIT)
            .where(CHANGE_UNIT.CHANGE_SET_ID.eq(options.entityReference().id()));
}
 
Example #26
Source File: UserDao.java    From waltz with Apache License 2.0 5 votes vote down vote up
public String getPassword(String userName) {
    Record1<String> possiblePassword = dsl.select(USER.PASSWORD)
            .from(USER)
            .where(USER.USER_NAME.equalIgnoreCase(userName))
            .fetchOne();

    if (possiblePassword != null) {
        return possiblePassword.value1();
    } else {
        return null;
    }
}
 
Example #27
Source File: ChangeSetIdSelectorFactory.java    From waltz with Apache License 2.0 5 votes vote down vote up
private Select<Record1<Long>> mkByChangeUnitSelector(IdSelectionOptions options) {
    checkNotNull(options, "options cannot be null");

    Select<Record1<Long>> cuSelector = changeUnitIdSelectorFactory.apply(options);
    return DSL.selectDistinct(CHANGE_UNIT.CHANGE_SET_ID)
            .from(CHANGE_UNIT)
            .where(CHANGE_UNIT.ID.in(cuSelector));
}
 
Example #28
Source File: LogicalFlowIdSelectorFactory.java    From waltz with Apache License 2.0 5 votes vote down vote up
private Select<Record1<Long>> mkForTagBasedOnPhysicalFlowTags(IdSelectionOptions options) {
    ensureScopeIsExact(options);

    return DSL
            .select(LOGICAL_FLOW.ID)
            .from(LOGICAL_FLOW)
            .innerJoin(PHYSICAL_FLOW)
            .on(PHYSICAL_FLOW.LOGICAL_FLOW_ID.eq(LOGICAL_FLOW.ID))
            .innerJoin(TAG_USAGE)
            .on(TAG_USAGE.ENTITY_ID.eq(PHYSICAL_FLOW.ID)
                    .and(TAG_USAGE.ENTITY_KIND.eq(EntityKind.PHYSICAL_FLOW.name())))
            .where(TAG_USAGE.TAG_ID.eq(options.entityReference().id()))
            .and(mkLifecycleStatusCondition(options));
}
 
Example #29
Source File: MeasurableComplexityService.java    From waltz with Apache License 2.0 5 votes vote down vote up
public List<ComplexityScore> findByAppIdSelector(Select<Record1<Long>> idSelector, double baseline) {
    return measurableComplexityDao.findScoresForAppIdSelector(idSelector)
            .stream()
            .map(tally -> tallyToComplexityScore(
                    ComplexityKind.MEASURABLE,
                    tally,
                    baseline))
            .collect(Collectors.toList());
}
 
Example #30
Source File: AbstractIdSelectorFactory.java    From waltz with Apache License 2.0 5 votes vote down vote up
@Override
public Select<Record1<Long>> apply(IdSelectionOptions options) {
    EntityKind queryKind = options.entityReference().kind();
    if (entityKind == queryKind) {
        return mkForSelf(options);
    } else {
        return mkForOptions(options);
    }
}