Search in sources :

Example 1 with Criticality

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

the class AppGenerator method main.

public static void main(String[] args) throws IOException {
    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(DIConfiguration.class);
    DSLContext dsl = ctx.getBean(DSLContext.class);
    ApplicationService applicationDao = ctx.getBean(ApplicationService.class);
    OrganisationalUnitService ouDao = ctx.getBean(OrganisationalUnitService.class);
    List<String> animals = IOUtilities.readLines(AppGenerator.class.getClassLoader().getResourceAsStream("animals.txt"));
    OrganisationalUnit[] organisationalUnits = ouDao.findAll().toArray(new OrganisationalUnit[0]);
    List<AppRegistrationRequest> registrationRequests = new ArrayList<>();
    for (int i = 0; i < 5000; i++) {
        String animal = randomPick(animals.toArray(new String[0])) + " - " + i;
        OrganisationalUnit organisationalUnit = randomPick(organisationalUnits);
        LifecyclePhase phase = rnd.nextInt(10) > 7 ? randomPick(LifecyclePhase.values()) : LifecyclePhase.PRODUCTION;
        Criticality businessCriticality = rnd.nextInt(10) > 7 ? randomPick(Criticality.values()) : Criticality.HIGH;
        AppRegistrationRequest app = ImmutableAppRegistrationRequest.builder().name(animal).assetCode("wltz-0" + i).description("All about " + animal).applicationKind(randomPick(ApplicationKind.values())).lifecyclePhase(phase).overallRating(randomPick(RagRating.R, RagRating.A, RagRating.A, RagRating.G, RagRating.G)).organisationalUnitId(organisationalUnit.id().get()).businessCriticality(businessCriticality).build();
        registrationRequests.add(app);
    }
    dsl.deleteFrom(AUTHORITATIVE_SOURCE).execute();
    dsl.deleteFrom(APPLICATION).execute();
    registrationRequests.forEach(a -> applicationDao.registerApp(a, "admin"));
}
Also used : OrganisationalUnitService(com.khartec.waltz.service.orgunit.OrganisationalUnitService) AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) ArrayList(java.util.ArrayList) DSLContext(org.jooq.DSLContext) OrganisationalUnit(com.khartec.waltz.model.orgunit.OrganisationalUnit) LifecyclePhase(com.khartec.waltz.model.application.LifecyclePhase) AppRegistrationRequest(com.khartec.waltz.model.application.AppRegistrationRequest) ImmutableAppRegistrationRequest(com.khartec.waltz.model.application.ImmutableAppRegistrationRequest) ApplicationService(com.khartec.waltz.service.application.ApplicationService) Criticality(com.khartec.waltz.model.Criticality)

Example 2 with Criticality

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

the class PhysicalFlowUploadService method validateCommand.

private PhysicalFlowValidateCommandResponse validateCommand(PhysicalFlowValidateCommand cmd) {
    checkNotNull(cmd, "cmd cannot be null");
    Map<String, String> errors = new HashMap<>();
    // resolve entity refs - source, target, owner
    EntityReference source = getEntityRefByString(cmd.source());
    EntityReference target = getEntityRefByString(cmd.target());
    EntityReference owner = getEntityRefByString(cmd.owner());
    if (source == null) {
        errors.put("source", String.format("%s not found", cmd.source()));
    }
    if (target == null) {
        errors.put("target", String.format("%s not found", cmd.target()));
    }
    if (owner == null) {
        errors.put("owner", String.format("%s not found", cmd.owner()));
    }
    // resolve enums - format, frequency, transport, criticality
    DataFormatKind format = DataFormatKind.parse(cmd.format(), (s) -> null);
    if (format == null) {
        errors.put("format", String.format("%s is not a recognised value", cmd.format()));
    }
    FrequencyKind frequency = FrequencyKind.parse(cmd.frequency(), (s) -> null);
    if (frequency == null) {
        errors.put("frequency", String.format("%s is not a recognised value", cmd.frequency()));
    }
    TransportKind transport = TransportKind.parse(cmd.transport(), (s) -> null);
    if (transport == null) {
        errors.put("transport", String.format("%s is not a recognised value", cmd.transport()));
    }
    Criticality criticality = Criticality.parse(cmd.criticality(), (s) -> null);
    if (criticality == null) {
        errors.put("criticality", String.format("%s is not a recognised value", cmd.criticality()));
    }
    // check for nulls or duplicates in other fields
    if (isEmpty(cmd.name())) {
        errors.put("name", "name not provided");
    }
    Integer basisOffset = parseBasisOffset(cmd.basisOffset());
    if (basisOffset == null) {
        errors.put("basisOffset", String.format("%s is not a recognised value, expect this to be a number", cmd.basisOffset()));
    }
    ImmutablePhysicalFlowParsed parsedFlow = ImmutablePhysicalFlowParsed.builder().source(source).target(target).owner(owner).name(cmd.name()).format(format).specDescription(cmd.specDescription()).specExternalId(cmd.specExternalId()).frequency(frequency).transport(transport).criticality(criticality).description(cmd.description()).externalId(cmd.externalId()).basisOffset(basisOffset).build();
    return ImmutablePhysicalFlowValidateCommandResponse.builder().parsedFlow(parsedFlow).errors(errors).originalCommand(cmd).outcome(errors.size() > 0 ? CommandOutcome.FAILURE : CommandOutcome.SUCCESS).build();
}
Also used : HashMap(java.util.HashMap) DataFormatKind(com.khartec.waltz.model.physical_specification.DataFormatKind) EntityReference(com.khartec.waltz.model.EntityReference) Criticality(com.khartec.waltz.model.Criticality)

Aggregations

Criticality (com.khartec.waltz.model.Criticality)2 EntityReference (com.khartec.waltz.model.EntityReference)1 AppRegistrationRequest (com.khartec.waltz.model.application.AppRegistrationRequest)1 ImmutableAppRegistrationRequest (com.khartec.waltz.model.application.ImmutableAppRegistrationRequest)1 LifecyclePhase (com.khartec.waltz.model.application.LifecyclePhase)1 OrganisationalUnit (com.khartec.waltz.model.orgunit.OrganisationalUnit)1 DataFormatKind (com.khartec.waltz.model.physical_specification.DataFormatKind)1 ApplicationService (com.khartec.waltz.service.application.ApplicationService)1 OrganisationalUnitService (com.khartec.waltz.service.orgunit.OrganisationalUnitService)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 DSLContext (org.jooq.DSLContext)1 AnnotationConfigApplicationContext (org.springframework.context.annotation.AnnotationConfigApplicationContext)1