Search in sources :

Example 1 with ApplicationRecord

use of org.finos.waltz.schema.tables.records.ApplicationRecord in project waltz by khartec.

the class ApplicationDao method update.

public int update(Application application) {
    checkNotNull(application, "application must not be null");
    LOG.info("Updating application: " + application);
    ApplicationRecord record = dsl.newRecord(APPLICATION);
    record.setName(application.name());
    record.setDescription(application.description());
    record.setAssetCode(ExternalIdValue.orElse(application.assetCode(), ""));
    record.setParentAssetCode(ExternalIdValue.orElse(application.parentAssetCode(), ""));
    record.setOrganisationalUnitId(application.organisationalUnitId());
    record.setLifecyclePhase(application.lifecyclePhase().name());
    record.setKind(application.applicationKind().name());
    record.setOverallRating(application.overallRating().name());
    record.setProvenance(application.provenance());
    record.setBusinessCriticality(application.businessCriticality().name());
    record.setIsRemoved(application.isRemoved());
    Long appId = application.id().orElseThrow(() -> new IllegalArgumentException("Cannot update an application without an id"));
    return dsl.executeUpdate(record, APPLICATION.ID.eq(appId));
}
Also used : ApplicationRecord(org.finos.waltz.schema.tables.records.ApplicationRecord)

Example 2 with ApplicationRecord

use of org.finos.waltz.schema.tables.records.ApplicationRecord in project waltz by khartec.

the class ApplicationDao method registerApp.

public AppRegistrationResponse registerApp(AppRegistrationRequest request) {
    checkNotEmpty(request.name(), "Cannot register app with no name");
    LOG.info("Registering new application: " + request);
    ApplicationRecord record = dsl.newRecord(APPLICATION);
    record.setName(request.name());
    record.setDescription(request.description());
    record.setAssetCode(request.assetCode().orElse(""));
    record.setParentAssetCode(request.parentAssetCode().orElse(""));
    record.setOrganisationalUnitId(request.organisationalUnitId());
    record.setKind(request.applicationKind().name());
    record.setLifecyclePhase(request.lifecyclePhase().name());
    record.setOverallRating(request.overallRating().name());
    record.setUpdatedAt(Timestamp.from(Instant.now()));
    record.setBusinessCriticality(request.businessCriticality().name());
    record.setProvenance(request.provenance());
    try {
        int count = record.insert();
        if (count == 1) {
            return ImmutableAppRegistrationResponse.builder().id(record.getId()).message("created").originalRequest(request).build();
        } else {
            return ImmutableAppRegistrationResponse.builder().message("Failed").originalRequest(request).build();
        }
    } catch (DataAccessException dae) {
        return ImmutableAppRegistrationResponse.builder().message("Could not create app because: " + dae.getMessage()).originalRequest(request).build();
    }
}
Also used : DataAccessException(org.jooq.exception.DataAccessException) ApplicationRecord(org.finos.waltz.schema.tables.records.ApplicationRecord)

Aggregations

ApplicationRecord (org.finos.waltz.schema.tables.records.ApplicationRecord)2 DataAccessException (org.jooq.exception.DataAccessException)1