Search in sources :

Example 11 with Application

use of com.khartec.waltz.model.application.Application in project waltz by khartec.

the class ApplicationService method findRelated.

public Map<AssetCodeRelationshipKind, List<Application>> findRelated(long appId) {
    List<Application> related = applicationDao.findRelatedByApplicationId(appId);
    Optional<Application> foundApp = related.stream().filter(app -> app.id().equals(Optional.of(appId))).findFirst();
    if (foundApp.isPresent()) {
        Application app = foundApp.get();
        Function<Application, AssetCodeRelationshipKind> classifier = relatedApp -> {
            boolean sameParent = relatedApp.parentAssetCode().equals(app.parentAssetCode());
            boolean sameCode = relatedApp.assetCode().equals(app.assetCode());
            boolean isParent = relatedApp.assetCode().equals(app.parentAssetCode());
            boolean isChild = relatedApp.parentAssetCode().equals(app.assetCode());
            if (sameCode) {
                return AssetCodeRelationshipKind.SHARING;
            } else if (isParent) {
                return AssetCodeRelationshipKind.PARENT;
            } else if (isChild) {
                return AssetCodeRelationshipKind.CHILD;
            } else if (sameParent && app.parentAssetCode().isPresent()) {
                return AssetCodeRelationshipKind.SIBLING;
            } else {
                return AssetCodeRelationshipKind.NONE;
            }
        };
        Map<AssetCodeRelationshipKind, List<Application>> grouped = related.stream().filter(// can do simple ref check here
        relatedApp -> relatedApp != app).collect(Collectors.groupingBy(classifier));
        return grouped;
    } else {
        return emptyMap();
    }
}
Also used : ApplicationIdSelectorFactory(com.khartec.waltz.data.application.ApplicationIdSelectorFactory) AppRegistrationResponse(com.khartec.waltz.model.application.AppRegistrationResponse) ImmutableEntityReference(com.khartec.waltz.model.ImmutableEntityReference) Autowired(org.springframework.beans.factory.annotation.Autowired) EntityReference(com.khartec.waltz.model.EntityReference) AppRegistrationRequest(com.khartec.waltz.model.application.AppRegistrationRequest) AssetCodeRelationshipKind(com.khartec.waltz.model.application.AssetCodeRelationshipKind) Function(java.util.function.Function) EntityKind(com.khartec.waltz.model.EntityKind) EntityAliasDao(com.khartec.waltz.data.entity_alias.EntityAliasDao) IdSelectionOptions(com.khartec.waltz.model.IdSelectionOptions) Record1(org.jooq.Record1) Checks.checkNotEmpty(com.khartec.waltz.common.Checks.checkNotEmpty) Service(org.springframework.stereotype.Service) Map(java.util.Map) EntitySearchOptions(com.khartec.waltz.model.entity_search.EntitySearchOptions) Select(org.jooq.Select) Application(com.khartec.waltz.model.application.Application) Collections.emptyMap(java.util.Collections.emptyMap) ApplicationDao(com.khartec.waltz.data.application.ApplicationDao) Checks.checkNotNull(com.khartec.waltz.common.Checks.checkNotNull) Collection(java.util.Collection) ApplicationSearchDao(com.khartec.waltz.data.application.search.ApplicationSearchDao) Tally(com.khartec.waltz.model.tally.Tally) Collectors(java.util.stream.Collectors) List(java.util.List) Optional(java.util.Optional) EntityTagDao(com.khartec.waltz.data.entity_tag.EntityTagDao) AssetCodeRelationshipKind(com.khartec.waltz.model.application.AssetCodeRelationshipKind) List(java.util.List) Application(com.khartec.waltz.model.application.Application)

Example 12 with Application

use of com.khartec.waltz.model.application.Application 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 13 with Application

use of com.khartec.waltz.model.application.Application 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 14 with Application

use of com.khartec.waltz.model.application.Application in project waltz by khartec.

the class LogicalFlowDecoratorRatingsCalculator method lookupVantagePoint.

private EntityReference lookupVantagePoint(Map<Long, Application> targetAppsById, LogicalFlow flow) {
    Application targetApp = targetAppsById.get(flow.target().id());
    long targetOrgUnitId = targetApp.organisationalUnitId();
    return EntityReference.mkRef(EntityKind.ORG_UNIT, targetOrgUnitId);
}
Also used : Application(com.khartec.waltz.model.application.Application)

Example 15 with Application

use of com.khartec.waltz.model.application.Application 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

Application (com.khartec.waltz.model.application.Application)17 OrganisationalUnit (com.khartec.waltz.model.orgunit.OrganisationalUnit)8 DSLContext (org.jooq.DSLContext)8 EntityKind (com.khartec.waltz.model.EntityKind)7 EntityReference (com.khartec.waltz.model.EntityReference)6 List (java.util.List)6 AnnotationConfigApplicationContext (org.springframework.context.annotation.AnnotationConfigApplicationContext)6 ApplicationDao (com.khartec.waltz.data.application.ApplicationDao)4 AuthoritativeSource (com.khartec.waltz.model.authoritativesource.AuthoritativeSource)4 DataType (com.khartec.waltz.model.datatype.DataType)4 DIConfiguration (com.khartec.waltz.service.DIConfiguration)4 ApplicationService (com.khartec.waltz.service.application.ApplicationService)4 Collectors (java.util.stream.Collectors)4 Collectors.toList (java.util.stream.Collectors.toList)4 AuthoritativeSourceDao (com.khartec.waltz.data.authoritative_source.AuthoritativeSourceDao)3 LogicalFlowDao (com.khartec.waltz.data.logical_flow.LogicalFlowDao)3 ImmutableEntityReference (com.khartec.waltz.model.ImmutableEntityReference)3 EntitySearchOptions (com.khartec.waltz.model.entity_search.EntitySearchOptions)3 LogicalFlow (com.khartec.waltz.model.logical_flow.LogicalFlow)3 IntStream (java.util.stream.IntStream)3