Search in sources :

Example 21 with EntityReference

use of com.khartec.waltz.model.EntityReference 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);
}
Also used : Logger(org.slf4j.Logger) SetUtilities.fromCollection(com.khartec.waltz.common.SetUtilities.fromCollection) SetUtilities(com.khartec.waltz.common.SetUtilities) ApplicationIdSelectorFactory(com.khartec.waltz.data.application.ApplicationIdSelectorFactory) LogicalFlowDecoratorDao(com.khartec.waltz.data.data_flow_decorator.LogicalFlowDecoratorDao) Checks.checkNotNull(com.khartec.waltz.common.Checks.checkNotNull) LogicalFlowDecoratorRatingsCalculator(com.khartec.waltz.service.data_flow_decorator.LogicalFlowDecoratorRatingsCalculator) Collection(java.util.Collection) LoggerFactory(org.slf4j.LoggerFactory) HierarchyQueryScope(com.khartec.waltz.model.HierarchyQueryScope) Autowired(org.springframework.beans.factory.annotation.Autowired) Set(java.util.Set) EntityReference(com.khartec.waltz.model.EntityReference) EntityKind(com.khartec.waltz.model.EntityKind) DataTypeDao(com.khartec.waltz.data.data_type.DataTypeDao) LogicalFlowDecorator(com.khartec.waltz.model.data_flow_decorator.LogicalFlowDecorator) Collectors.toList(java.util.stream.Collectors.toList) IdSelectionOptions(com.khartec.waltz.model.IdSelectionOptions) Record1(org.jooq.Record1) Service(org.springframework.stereotype.Service) DataType(com.khartec.waltz.model.datatype.DataType) IdSelectionOptions.mkOpts(com.khartec.waltz.model.IdSelectionOptions.mkOpts) Select(org.jooq.Select) LogicalFlowDecorator(com.khartec.waltz.model.data_flow_decorator.LogicalFlowDecorator) IdSelectionOptions(com.khartec.waltz.model.IdSelectionOptions) Record1(org.jooq.Record1)

Example 22 with EntityReference

use of com.khartec.waltz.model.EntityReference in project waltz by khartec.

the class ChangeInitiativeService method mkEntityRelationshipKey.

private EntityRelationshipKey mkEntityRelationshipKey(long changeInitiativeId, EntityRelationshipChangeCommand command, boolean validate) {
    EntityReference entityReference = command.entityReference();
    RelationshipKind relationship = command.relationship();
    return EntityRelationshipUtilities.mkEntityRelationshipKey(mkRef(CHANGE_INITIATIVE, changeInitiativeId), entityReference, relationship, validate).orElseThrow(() -> new RuntimeException(String.format("Could not build a valid relationship for kind: %s between %s and %s", relationship, CHANGE_INITIATIVE, entityReference.kind())));
}
Also used : EntityReference(com.khartec.waltz.model.EntityReference)

Example 23 with EntityReference

use of com.khartec.waltz.model.EntityReference in project waltz by khartec.

the class LogicalFlowDecoratorRatingsCalculator method lookupRating.

private AuthoritativenessRating lookupRating(Map<Long, DataType> typesById, Map<Long, LogicalFlow> flowsById, Map<Long, Application> targetAppsById, AuthoritativeSourceResolver resolver, LogicalFlowDecorator decorator) {
    LogicalFlow flow = flowsById.get(decorator.dataFlowId());
    EntityReference vantagePoint = lookupVantagePoint(targetAppsById, flow);
    EntityReference source = flow.source();
    String dataTypeCode = lookupDataTypeCode(typesById, decorator);
    return resolver.resolve(vantagePoint, source, dataTypeCode);
}
Also used : LogicalFlow(com.khartec.waltz.model.logical_flow.LogicalFlow) EntityReference(com.khartec.waltz.model.EntityReference)

Example 24 with EntityReference

use of com.khartec.waltz.model.EntityReference in project waltz by khartec.

the class SurveyQuestionResponseDao method mkRecord.

private SurveyQuestionResponseRecord mkRecord(SurveyInstanceQuestionResponse response) {
    SurveyQuestionResponse questionResponse = response.questionResponse();
    Optional<EntityReference> entityResponse = questionResponse.entityResponse();
    SurveyQuestionResponseRecord record = dsl.newRecord(SURVEY_QUESTION_RESPONSE);
    record.setSurveyInstanceId(response.surveyInstanceId());
    record.setQuestionId(questionResponse.questionId());
    record.setPersonId(response.personId());
    record.setLastUpdatedAt(Timestamp.valueOf(response.lastUpdatedAt()));
    record.setComment(questionResponse.comment().map(c -> ifEmpty(c, null)).orElse(null));
    record.setStringResponse(questionResponse.stringResponse().map(s -> ifEmpty(s, null)).orElse(null));
    record.setNumberResponse(questionResponse.numberResponse().map(BigDecimal::valueOf).orElse(null));
    record.setBooleanResponse(questionResponse.booleanResponse().orElse(null));
    record.setDateResponse(questionResponse.dateResponse().map(DateTimeUtilities::toSqlDate).orElse(null));
    record.setEntityResponseKind(entityResponse.map(er -> er.kind().name()).orElse(null));
    record.setEntityResponseId(entityResponse.map(er -> er.id()).orElse(null));
    return record;
}
Also used : SurveyQuestionResponseRecord(com.khartec.waltz.schema.tables.records.SurveyQuestionResponseRecord) DateTimeUtilities(com.khartec.waltz.common.DateTimeUtilities) EntityReference(com.khartec.waltz.model.EntityReference) ImmutableSurveyQuestionResponse(com.khartec.waltz.model.survey.ImmutableSurveyQuestionResponse) SurveyQuestionResponse(com.khartec.waltz.model.survey.SurveyQuestionResponse) BigDecimal(java.math.BigDecimal)

Example 25 with EntityReference

use of com.khartec.waltz.model.EntityReference 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());
}
Also used : LogicalFlowIdSelectorFactory(com.khartec.waltz.data.logical_flow.LogicalFlowIdSelectorFactory) AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) LogicalFlowService(com.khartec.waltz.service.logical_flow.LogicalFlowService) LogicalFlow(com.khartec.waltz.model.logical_flow.LogicalFlow) EntityReference(com.khartec.waltz.model.EntityReference) DSLContext(org.jooq.DSLContext) LogicalFlowDao(com.khartec.waltz.data.logical_flow.LogicalFlowDao) IdSelectionOptions(com.khartec.waltz.model.IdSelectionOptions) Record1(org.jooq.Record1)

Aggregations

EntityReference (com.khartec.waltz.model.EntityReference)33 EntityKind (com.khartec.waltz.model.EntityKind)11 DSLContext (org.jooq.DSLContext)9 AnnotationConfigApplicationContext (org.springframework.context.annotation.AnnotationConfigApplicationContext)9 List (java.util.List)8 ListUtilities.newArrayList (com.khartec.waltz.common.ListUtilities.newArrayList)6 Collection (java.util.Collection)6 LogicalFlowDao (com.khartec.waltz.data.logical_flow.LogicalFlowDao)5 Autowired (org.springframework.beans.factory.annotation.Autowired)5 Checks.checkNotNull (com.khartec.waltz.common.Checks.checkNotNull)4 SetUtilities (com.khartec.waltz.common.SetUtilities)4 IdSelectionOptions (com.khartec.waltz.model.IdSelectionOptions)4 LogicalFlow (com.khartec.waltz.model.logical_flow.LogicalFlow)4 LOGICAL_FLOW (com.khartec.waltz.schema.tables.LogicalFlow.LOGICAL_FLOW)4 DIConfiguration (com.khartec.waltz.service.DIConfiguration)4 EntityReference.mkRef (com.khartec.waltz.model.EntityReference.mkRef)3 ImmutableEntityReference (com.khartec.waltz.model.ImmutableEntityReference)3 Application (com.khartec.waltz.model.application.Application)3 OrganisationalUnit (com.khartec.waltz.model.orgunit.OrganisationalUnit)3 LogicalFlowService (com.khartec.waltz.service.logical_flow.LogicalFlowService)3