removed not null condition from plan&description status

This commit is contained in:
CITE\spapacharalampous 2024-08-29 11:07:57 +03:00
parent 43a1ee470b
commit b2bfade43e
12 changed files with 61 additions and 21 deletions

View File

@ -4,7 +4,7 @@ import jakarta.persistence.*;
import org.hibernate.annotations.Type;
import org.opencdmp.commons.enums.DescriptionStatus;
import org.opencdmp.commons.enums.IsActive;
import org.opencdmp.data.converters.enums.DescriptionStatusConverter;
import org.opencdmp.data.converters.enums.DescriptionStatusNullableConverter;
import org.opencdmp.data.converters.enums.IsActiveConverter;
import org.opencdmp.data.tenant.TenantScopedBaseEntity;
import org.opencdmp.data.types.SQLXMLType;
@ -42,8 +42,8 @@ public class DescriptionStatusEntity extends TenantScopedBaseEntity {
private IsActive isActive;
public static final String _isActive = "isActive";
@Column(name = "internal_status", nullable = false)
@Convert(converter = DescriptionStatusConverter.class)
@Column(name = "internal_status", nullable = true)
@Convert(converter = DescriptionStatusNullableConverter.class)
private DescriptionStatus internalStatus;
public static final String _internalStatus = "internalStatus";

View File

@ -5,7 +5,7 @@ import org.hibernate.annotations.Type;
import org.opencdmp.commons.enums.IsActive;
import org.opencdmp.commons.enums.PlanStatus;
import org.opencdmp.data.converters.enums.IsActiveConverter;
import org.opencdmp.data.converters.enums.PlanStatusConverter;
import org.opencdmp.data.converters.enums.PlanStatusNullableConverter;
import org.opencdmp.data.tenant.TenantScopedBaseEntity;
import org.opencdmp.data.types.SQLXMLType;
@ -42,8 +42,8 @@ public class PlanStatusEntity extends TenantScopedBaseEntity {
private IsActive isActive;
public static final String _isActive = "isActive";
@Column(name = "internal_status", nullable = false)
@Convert(converter = PlanStatusConverter.class)
@Column(name = "internal_status", nullable = true)
@Convert(converter = PlanStatusNullableConverter.class)
private PlanStatus internalStatus;
public static final String _internalStatus = "internalStatus";

View File

@ -0,0 +1,24 @@
package org.opencdmp.data.converters.enums;
import jakarta.persistence.Converter;
import org.opencdmp.commons.enums.DescriptionStatus;
@Converter
public class DescriptionStatusNullableConverter extends DatabaseEnumConverter<DescriptionStatus, Short> {
@Override
protected DescriptionStatus of(Short i) {
return DescriptionStatus.of(i);
}
@Override
public Short convertToDatabaseColumn(DescriptionStatus value) {
if (value == null) return null;
return value.getValue();
}
@Override
public DescriptionStatus convertToEntityAttribute(Short dbData) {
return dbData == null ? null : this.of(dbData);
}
}

View File

@ -0,0 +1,24 @@
package org.opencdmp.data.converters.enums;
import jakarta.persistence.Converter;
import org.opencdmp.commons.enums.PlanStatus;
@Converter
public class PlanStatusNullableConverter extends DatabaseEnumConverter<PlanStatus, Short> {
@Override
protected PlanStatus of(Short i) {
return PlanStatus.of(i);
}
@Override
public Short convertToDatabaseColumn(PlanStatus value) {
if (value == null) return null;
return value.getValue();
}
@Override
public PlanStatus convertToEntityAttribute(Short dbData) {
return dbData == null ? null : this.of(dbData);
}
}

View File

@ -93,13 +93,10 @@ public class DescriptionStatusPersist {
.iff(() -> !this.isEmpty(item.getName()))
.must(() -> this.lessEqualLength(item.getName(), DescriptionStatusEntity._nameLength))
.failOn(DescriptionStatusPersist._name).failWith(this.messageSource.getMessage("Validation_Required", new Object[]{DescriptionStatusPersist._name}, LocaleContextHolder.getLocale())),
this.spec()
.must(() -> !this.isNull(item.getInternalStatus()))
.failOn(DescriptionStatusPersist._internalStatus).failWith(this.messageSource.getMessage("Validation_Required", new Object[]{DescriptionStatusPersist._internalStatus}, LocaleContextHolder.getLocale())),
this.spec()
.iff(() -> item.getInternalStatus() == org.opencdmp.commons.enums.DescriptionStatus.Finalized)
.must(() -> !this.isNull(item.getDefinition()))
.failOn(DescriptionStatusPersist._internalStatus).failWith(this.messageSource.getMessage("Validation_Required", new Object[]{DescriptionStatusPersist._internalStatus}, LocaleContextHolder.getLocale())),
.failOn(DescriptionStatusPersist._definition).failWith(this.messageSource.getMessage("Validation_Required", new Object[]{DescriptionStatusPersist._definition}, LocaleContextHolder.getLocale())),
this.refSpec()
.iff(() -> !this.isNull(item.getDefinition()))
.on(DescriptionStatusPersist._definition)

View File

@ -105,9 +105,6 @@ public class PlanStatusPersist {
.iff(() -> !this.isEmpty(item.getName()))
.must(() -> this.lessEqualLength(item.getName(), PlanStatusEntity._nameLength))
.failOn(org.opencdmp.model.persist.planstatus.PlanStatusPersist._name).failWith(this.messageSource.getMessage("Validation_MaxLength", new Object[]{org.opencdmp.model.persist.planstatus.PlanStatusPersist._name}, LocaleContextHolder.getLocale())),
this.spec()
.must(() -> !this.isNull(item.getInternalStatus()))
.failOn(org.opencdmp.model.persist.planstatus.PlanStatusPersist._internalStatus).failWith(this.messageSource.getMessage("Validation_Required", new Object[]{org.opencdmp.model.persist.planstatus.PlanStatusPersist._internalStatus}, LocaleContextHolder.getLocale())),
this.spec()
.iff(() -> item.getInternalStatus() == org.opencdmp.commons.enums.PlanStatus.Finalized)
.must(() -> !this.isNull(item.getDefinition()))

View File

@ -12,7 +12,7 @@ BEGIN
created_at timestamp without time zone NOT NULL,
updated_at timestamp without time zone NOT NULL,
is_active smallint NOT NULL,
internal_status smallint NOT NULL,
internal_status smallint,
tenant uuid,
definition xml,
CONSTRAINT "PlanStatus_pkey" PRIMARY KEY (id),

View File

@ -12,7 +12,7 @@ BEGIN
created_at timestamp without time zone NOT NULL,
updated_at timestamp without time zone NOT NULL,
is_active smallint NOT NULL,
internal_status smallint NOT NULL,
internal_status smallint,
definition xml,
tenant uuid,
CONSTRAINT "DescriptionStatus_pkey" PRIMARY KEY (id),

View File

@ -36,12 +36,11 @@
</div>
<div class="col-12">
<mat-form-field class="w-100">
<mat-label>{{'DESCRIPTION-STATUS-EDITOR.FIELDS.INTERNAL-STATUS' | translate}}*</mat-label>
<mat-label>{{'DESCRIPTION-STATUS-EDITOR.FIELDS.INTERNAL-STATUS' | translate}}</mat-label>
<mat-select [formControl]="formGroup.controls.internalStatus">
<mat-option *ngFor="let internalStatus of internalStatusEnum" [value]="internalStatus">{{enumUtils.toDescriptionStatusString(internalStatus)}}</mat-option>
</mat-select>
<mat-error *ngIf="formGroup.controls.internalStatus.hasError('backendError')">{{formGroup.controls.internalStatus.getError('backendError').message}}</mat-error>
<mat-error *ngIf="formGroup.controls.internalStatus.hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>
</div>
<div class="col-12">

View File

@ -68,7 +68,7 @@ export class DescriptionStatusEditorModel extends BaseEditorModel implements Des
baseValidationArray.push({ key: 'id', validators: [BackendErrorValidator(this.validationErrorModel, 'id')] });
baseValidationArray.push({ key: 'name', validators: [Validators.required, BackendErrorValidator(this.validationErrorModel, 'name')] });
baseValidationArray.push({ key: 'description', validators: [BackendErrorValidator(this.validationErrorModel, 'description')] });
baseValidationArray.push({ key: 'internalStatus', validators: [Validators.required, BackendErrorValidator(this.validationErrorModel, 'internalStatus')] });
baseValidationArray.push({ key: 'internalStatus', validators: [BackendErrorValidator(this.validationErrorModel, 'internalStatus')] });
baseValidationArray.push({ key: 'hash', validators: [] });
baseValidationArray.push({ key: 'definition', validators: [BackendErrorValidator(this.validationErrorModel, 'definition')] });
baseValidationArray.push({ key: 'authorization', validators: [BackendErrorValidator(this.validationErrorModel, 'definition.authorization')] });

View File

@ -36,12 +36,11 @@
</div>
<div class="col-12">
<mat-form-field class="w-100">
<mat-label>{{'PLAN-STATUS-EDITOR.FIELDS.INTERNAL-STATUS' | translate}}*</mat-label>
<mat-label>{{'PLAN-STATUS-EDITOR.FIELDS.INTERNAL-STATUS' | translate}}</mat-label>
<mat-select [formControl]="formGroup.controls.internalStatus">
<mat-option *ngFor="let internalStatus of internalStatusEnum" [value]="internalStatus">{{enumUtils.toPlanStatusString(internalStatus)}}</mat-option>
</mat-select>
<mat-error *ngIf="formGroup.controls.internalStatus.hasError('backendError')">{{formGroup.controls.internalStatus.getError('backendError').message}}</mat-error>
<mat-error *ngIf="formGroup.controls.internalStatus.hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>
</div>
<div class="col-12">

View File

@ -69,7 +69,7 @@ export class PlanStatusEditorModel extends BaseEditorModel implements PlanStatus
baseValidationArray.push({ key: 'id', validators: [BackendErrorValidator(this.validationErrorModel, 'id')] });
baseValidationArray.push({ key: 'name', validators: [Validators.required, BackendErrorValidator(this.validationErrorModel, 'name')] });
baseValidationArray.push({ key: 'description', validators: [BackendErrorValidator(this.validationErrorModel, 'description')] });
baseValidationArray.push({ key: 'internalStatus', validators: [Validators.required, BackendErrorValidator(this.validationErrorModel, 'internalStatus')] });
baseValidationArray.push({ key: 'internalStatus', validators: [BackendErrorValidator(this.validationErrorModel, 'internalStatus')] });
baseValidationArray.push({ key: 'hash', validators: [] });
baseValidationArray.push({ key: 'definition', validators: [BackendErrorValidator(this.validationErrorModel, 'definition')] });
baseValidationArray.push({ key: 'authorization', validators: [BackendErrorValidator(this.validationErrorModel, 'definition.authorization')] });