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