Search in sources :

Example 1 with DataType

use of com.khartec.waltz.model.datatype.DataType in project waltz by khartec.

the class AuthoritativeSourceService method logRemoval.

private void logRemoval(long id, String username) {
    AuthoritativeSource authSource = getById(id);
    if (authSource == null) {
        return;
    }
    OrganisationalUnit orgUnit = organisationalUnitDao.getById(authSource.parentReference().id());
    DataType dataType = dataTypeDao.getByCode(authSource.dataType());
    Application app = applicationDao.getById(authSource.applicationReference().id());
    if (app != null && dataType != null && orgUnit != null) {
        String msg = String.format("Removed %s as an authoritative source for type: %s for org: %s", app.name(), dataType.name(), orgUnit.name());
        tripleLog(username, orgUnit, dataType, app, msg, Operation.REMOVE);
    }
}
Also used : AuthoritativeSource(com.khartec.waltz.model.authoritativesource.AuthoritativeSource) NonAuthoritativeSource(com.khartec.waltz.model.authoritativesource.NonAuthoritativeSource) DataType(com.khartec.waltz.model.datatype.DataType) OrganisationalUnit(com.khartec.waltz.model.orgunit.OrganisationalUnit) Application(com.khartec.waltz.model.application.Application)

Example 2 with DataType

use of com.khartec.waltz.model.datatype.DataType 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 3 with DataType

use of com.khartec.waltz.model.datatype.DataType in project waltz by khartec.

the class AuthoritativeSourceService method logInsert.

private void logInsert(AuthoritativeSourceCreateCommand command, String username) {
    OrganisationalUnit orgUnit = organisationalUnitDao.getById(command.orgUnitId());
    DataType dataType = dataTypeDao.getById(command.dataTypeId());
    Application app = applicationDao.getById(command.applicationId());
    if (app != null && dataType != null && orgUnit != null) {
        String msg = String.format("Registered %s as an authoritative source for type: %s for org: %s", app.name(), dataType.name(), orgUnit.name());
        tripleLog(username, orgUnit, dataType, app, msg, Operation.ADD);
    }
}
Also used : DataType(com.khartec.waltz.model.datatype.DataType) OrganisationalUnit(com.khartec.waltz.model.orgunit.OrganisationalUnit) Application(com.khartec.waltz.model.application.Application)

Example 4 with DataType

use of com.khartec.waltz.model.datatype.DataType in project waltz by khartec.

the class AuthoritativeSourceService method logUpdate.

private void logUpdate(AuthoritativeSourceUpdateCommand command, String username) {
    AuthoritativeSource authSource = getById(command.id().get());
    if (authSource == null) {
        return;
    }
    OrganisationalUnit orgUnit = organisationalUnitDao.getById(authSource.parentReference().id());
    DataType dataType = dataTypeDao.getByCode(authSource.dataType());
    Application app = applicationDao.getById(authSource.applicationReference().id());
    if (app != null && dataType != null && orgUnit != null) {
        String msg = String.format("Updated %s as an authoritative source for type: %s for org: %s", app.name(), dataType.name(), orgUnit.name());
        tripleLog(username, orgUnit, dataType, app, msg, Operation.UPDATE);
    }
}
Also used : AuthoritativeSource(com.khartec.waltz.model.authoritativesource.AuthoritativeSource) NonAuthoritativeSource(com.khartec.waltz.model.authoritativesource.NonAuthoritativeSource) DataType(com.khartec.waltz.model.datatype.DataType) OrganisationalUnit(com.khartec.waltz.model.orgunit.OrganisationalUnit) Application(com.khartec.waltz.model.application.Application)

Example 5 with DataType

use of com.khartec.waltz.model.datatype.DataType in project waltz by khartec.

the class LogicalFlowDecoratorRatingsCalculator method calculate.

public Collection<LogicalFlowDecorator> calculate(Collection<LogicalFlowDecorator> decorators) {
    List<LogicalFlow> flows = loadFlows(decorators).stream().filter(f -> f.target().kind() == EntityKind.APPLICATION && f.source().kind() == EntityKind.APPLICATION).collect(toList());
    if (isEmpty(flows))
        return Collections.emptyList();
    List<Application> targetApps = loadTargetApplications(flows);
    List<DataType> dataTypes = dataTypeDao.getAll();
    Map<Long, DataType> typesById = indexById(dataTypes);
    Map<Long, LogicalFlow> flowsById = indexById(flows);
    Map<Long, Application> targetAppsById = indexById(targetApps);
    AuthoritativeSourceResolver resolver = createResolver(targetApps);
    return decorators.stream().map(decorator -> {
        try {
            if (decorator.decoratorEntity().kind() != EntityKind.DATA_TYPE) {
                return decorator;
            } else {
                AuthoritativenessRating rating = lookupRating(typesById, flowsById, targetAppsById, resolver, decorator);
                return ImmutableLogicalFlowDecorator.copyOf(decorator).withRating(rating);
            }
        } catch (Exception e) {
            LOG.warn("Failed to calculate rating for decorator: {}, reason: {}", decorator, e.getMessage());
            return null;
        }
    }).filter(Objects::nonNull).collect(Collectors.toSet());
}
Also used : java.util(java.util) AuthoritativeSourceResolver(com.khartec.waltz.service.authoritative_source.AuthoritativeSourceResolver) LoggerFactory(org.slf4j.LoggerFactory) Autowired(org.springframework.beans.factory.annotation.Autowired) EntityReference(com.khartec.waltz.model.EntityReference) AuthoritativeRatingVantagePoint(com.khartec.waltz.model.authoritativesource.AuthoritativeRatingVantagePoint) LogicalFlow(com.khartec.waltz.model.logical_flow.LogicalFlow) EntityKind(com.khartec.waltz.model.EntityKind) ImmutableLogicalFlowDecorator(com.khartec.waltz.model.data_flow_decorator.ImmutableLogicalFlowDecorator) Service(org.springframework.stereotype.Service) LogicalFlowDao(com.khartec.waltz.data.logical_flow.LogicalFlowDao) ApplicationService(com.khartec.waltz.service.application.ApplicationService) Application(com.khartec.waltz.model.application.Application) Logger(org.slf4j.Logger) Checks.checkNotNull(com.khartec.waltz.common.Checks.checkNotNull) AuthoritativenessRating(com.khartec.waltz.model.rating.AuthoritativenessRating) AuthoritativeSourceDao(com.khartec.waltz.data.authoritative_source.AuthoritativeSourceDao) Collectors(java.util.stream.Collectors) DataTypeDao(com.khartec.waltz.data.data_type.DataTypeDao) LogicalFlowDecorator(com.khartec.waltz.model.data_flow_decorator.LogicalFlowDecorator) Collectors.toList(java.util.stream.Collectors.toList) SetUtilities.map(com.khartec.waltz.common.SetUtilities.map) DataType(com.khartec.waltz.model.datatype.DataType) ListUtilities.isEmpty(com.khartec.waltz.common.ListUtilities.isEmpty) IdUtilities.indexById(com.khartec.waltz.model.utils.IdUtilities.indexById) AuthoritativeSourceResolver(com.khartec.waltz.service.authoritative_source.AuthoritativeSourceResolver) LogicalFlow(com.khartec.waltz.model.logical_flow.LogicalFlow) DataType(com.khartec.waltz.model.datatype.DataType) AuthoritativenessRating(com.khartec.waltz.model.rating.AuthoritativenessRating) Application(com.khartec.waltz.model.application.Application)

Aggregations

DataType (com.khartec.waltz.model.datatype.DataType)5 Application (com.khartec.waltz.model.application.Application)4 OrganisationalUnit (com.khartec.waltz.model.orgunit.OrganisationalUnit)3 Checks.checkNotNull (com.khartec.waltz.common.Checks.checkNotNull)2 DataTypeDao (com.khartec.waltz.data.data_type.DataTypeDao)2 EntityKind (com.khartec.waltz.model.EntityKind)2 EntityReference (com.khartec.waltz.model.EntityReference)2 AuthoritativeSource (com.khartec.waltz.model.authoritativesource.AuthoritativeSource)2 NonAuthoritativeSource (com.khartec.waltz.model.authoritativesource.NonAuthoritativeSource)2 LogicalFlowDecorator (com.khartec.waltz.model.data_flow_decorator.LogicalFlowDecorator)2 Collectors.toList (java.util.stream.Collectors.toList)2 Logger (org.slf4j.Logger)2 LoggerFactory (org.slf4j.LoggerFactory)2 Autowired (org.springframework.beans.factory.annotation.Autowired)2 Service (org.springframework.stereotype.Service)2 ListUtilities.isEmpty (com.khartec.waltz.common.ListUtilities.isEmpty)1 SetUtilities (com.khartec.waltz.common.SetUtilities)1 SetUtilities.fromCollection (com.khartec.waltz.common.SetUtilities.fromCollection)1 SetUtilities.map (com.khartec.waltz.common.SetUtilities.map)1 ApplicationIdSelectorFactory (com.khartec.waltz.data.application.ApplicationIdSelectorFactory)1