Search in sources :

Example 1 with AuthoritativeSource

use of com.khartec.waltz.model.authoritativesource.AuthoritativeSource 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 AuthoritativeSource

use of com.khartec.waltz.model.authoritativesource.AuthoritativeSource in project waltz by khartec.

the class FlowGenerator method main.

public static void main(String[] args) {
    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(DIConfiguration.class);
    AuthoritativeSourceDao authSourceDao = ctx.getBean(AuthoritativeSourceDao.class);
    ApplicationService applicationDao = ctx.getBean(ApplicationService.class);
    LogicalFlowService dataFlowDao = ctx.getBean(LogicalFlowService.class);
    OrganisationalUnitService orgUnitDao = ctx.getBean(OrganisationalUnitService.class);
    DSLContext dsl = ctx.getBean(DSLContext.class);
    List<AuthoritativeSource> authSources = authSourceDao.findByEntityKind(EntityKind.ORG_UNIT);
    List<Application> apps = applicationDao.findAll();
    List<OrganisationalUnit> orgUnits = orgUnitDao.findAll();
    Set<LogicalFlow> expectedFlows = authSources.stream().flatMap(a -> {
        long orgUnitId = a.parentReference().id();
        return IntStream.range(0, rnd.nextInt(40)).mapToObj(i -> ImmutableLogicalFlow.builder().source(a.applicationReference()).target(randomAppPick(apps, orgUnitId)).build());
    }).collect(toSet());
    Set<LogicalFlow> probableFlows = authSources.stream().flatMap(a -> IntStream.range(0, rnd.nextInt(30)).mapToObj(i -> ImmutableLogicalFlow.builder().source(a.applicationReference()).target(randomAppPick(apps, randomPick(orgUnits).id().get())).build())).collect(toSet());
    Set<LogicalFlow> randomFlows = apps.stream().flatMap(a -> IntStream.range(0, rnd.nextInt(5)).mapToObj(i -> {
        EntityReference target = randomAppPick(apps, randomPick(orgUnits).id().get());
        return ImmutableLogicalFlow.builder().source(a.entityReference()).target(target).lastUpdatedBy("admin").build();
    })).collect(toSet());
    dsl.deleteFrom(LOGICAL_FLOW).execute();
    Set<LogicalFlow> all = new HashSet<>();
    all.addAll(randomFlows);
    all.addAll(expectedFlows);
    all.addAll(probableFlows);
    System.out.println("--- saving: " + all.size());
    Set<LogicalFlowRecord> records = SetUtilities.map(all, df -> LogicalFlowDao.TO_RECORD_MAPPER.apply(df, dsl));
    dsl.batchStore(records).execute();
    System.out.println("--- done");
}
Also used : OrganisationalUnitService(com.khartec.waltz.service.orgunit.OrganisationalUnitService) IntStream(java.util.stream.IntStream) AuthoritativeSource(com.khartec.waltz.model.authoritativesource.AuthoritativeSource) SetUtilities(com.khartec.waltz.common.SetUtilities) OrganisationalUnit(com.khartec.waltz.model.orgunit.OrganisationalUnit) EntityReference(com.khartec.waltz.model.EntityReference) Random(java.util.Random) LogicalFlow(com.khartec.waltz.model.logical_flow.LogicalFlow) EntityKind(com.khartec.waltz.model.EntityKind) HashSet(java.util.HashSet) ImmutableLogicalFlow(com.khartec.waltz.model.logical_flow.ImmutableLogicalFlow) DIConfiguration(com.khartec.waltz.service.DIConfiguration) OrganisationalUnitService(com.khartec.waltz.service.orgunit.OrganisationalUnitService) LogicalFlowDao(com.khartec.waltz.data.logical_flow.LogicalFlowDao) DSLContext(org.jooq.DSLContext) ApplicationService(com.khartec.waltz.service.application.ApplicationService) LogicalFlowRecord(com.khartec.waltz.schema.tables.records.LogicalFlowRecord) Collectors.toSet(java.util.stream.Collectors.toSet) LOGICAL_FLOW(com.khartec.waltz.schema.tables.LogicalFlow.LOGICAL_FLOW) Application(com.khartec.waltz.model.application.Application) LogicalFlowService(com.khartec.waltz.service.logical_flow.LogicalFlowService) Set(java.util.Set) AuthoritativeSourceDao(com.khartec.waltz.data.authoritative_source.AuthoritativeSourceDao) AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) ListUtilities.randomPick(com.khartec.waltz.common.ListUtilities.randomPick) List(java.util.List) Collectors.toList(java.util.stream.Collectors.toList) AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) LogicalFlowRecord(com.khartec.waltz.schema.tables.records.LogicalFlowRecord) LogicalFlowService(com.khartec.waltz.service.logical_flow.LogicalFlowService) AuthoritativeSourceDao(com.khartec.waltz.data.authoritative_source.AuthoritativeSourceDao) DSLContext(org.jooq.DSLContext) AuthoritativeSource(com.khartec.waltz.model.authoritativesource.AuthoritativeSource) OrganisationalUnit(com.khartec.waltz.model.orgunit.OrganisationalUnit) LogicalFlow(com.khartec.waltz.model.logical_flow.LogicalFlow) ImmutableLogicalFlow(com.khartec.waltz.model.logical_flow.ImmutableLogicalFlow) EntityReference(com.khartec.waltz.model.EntityReference) Application(com.khartec.waltz.model.application.Application) ApplicationService(com.khartec.waltz.service.application.ApplicationService) HashSet(java.util.HashSet)

Example 3 with AuthoritativeSource

use of com.khartec.waltz.model.authoritativesource.AuthoritativeSource in project waltz by khartec.

the class AuthoritativeSourceService method remove.

public int remove(long id, String username) {
    logRemoval(id, username);
    AuthoritativeSource authSourceToDelete = getById(id);
    int deletedCount = authoritativeSourceDao.remove(id);
    ratingCalculator.update(authSourceToDelete.dataType(), authSourceToDelete.parentReference());
    return deletedCount;
}
Also used : AuthoritativeSource(com.khartec.waltz.model.authoritativesource.AuthoritativeSource) NonAuthoritativeSource(com.khartec.waltz.model.authoritativesource.NonAuthoritativeSource)

Example 4 with AuthoritativeSource

use of com.khartec.waltz.model.authoritativesource.AuthoritativeSource in project waltz by khartec.

the class AuthoritativeSourceService method update.

public int update(AuthoritativeSourceUpdateCommand command, String username) {
    int updateCount = authoritativeSourceDao.update(command);
    AuthoritativeSource updatedAuthSource = getById(command.id().get());
    ratingCalculator.update(updatedAuthSource.dataType(), updatedAuthSource.parentReference());
    logUpdate(command, username);
    return updateCount;
}
Also used : AuthoritativeSource(com.khartec.waltz.model.authoritativesource.AuthoritativeSource) NonAuthoritativeSource(com.khartec.waltz.model.authoritativesource.NonAuthoritativeSource)

Example 5 with AuthoritativeSource

use of com.khartec.waltz.model.authoritativesource.AuthoritativeSource 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)

Aggregations

AuthoritativeSource (com.khartec.waltz.model.authoritativesource.AuthoritativeSource)7 OrganisationalUnit (com.khartec.waltz.model.orgunit.OrganisationalUnit)5 Application (com.khartec.waltz.model.application.Application)4 NonAuthoritativeSource (com.khartec.waltz.model.authoritativesource.NonAuthoritativeSource)4 OrganisationalUnitService (com.khartec.waltz.service.orgunit.OrganisationalUnitService)3 DSLContext (org.jooq.DSLContext)3 AnnotationConfigApplicationContext (org.springframework.context.annotation.AnnotationConfigApplicationContext)3 ListUtilities.randomPick (com.khartec.waltz.common.ListUtilities.randomPick)2 SetUtilities (com.khartec.waltz.common.SetUtilities)2 AuthoritativeSourceDao (com.khartec.waltz.data.authoritative_source.AuthoritativeSourceDao)2 LogicalFlowDao (com.khartec.waltz.data.logical_flow.LogicalFlowDao)2 EntityKind (com.khartec.waltz.model.EntityKind)2 EntityReference (com.khartec.waltz.model.EntityReference)2 DataType (com.khartec.waltz.model.datatype.DataType)2 ImmutableLogicalFlow (com.khartec.waltz.model.logical_flow.ImmutableLogicalFlow)2 LogicalFlow (com.khartec.waltz.model.logical_flow.LogicalFlow)2 LOGICAL_FLOW (com.khartec.waltz.schema.tables.LogicalFlow.LOGICAL_FLOW)2 LogicalFlowRecord (com.khartec.waltz.schema.tables.records.LogicalFlowRecord)2 DIConfiguration (com.khartec.waltz.service.DIConfiguration)2 ApplicationService (com.khartec.waltz.service.application.ApplicationService)2