Dmp-Profile Delete + Enum

This commit is contained in:
Diamantis Tziotzios 2019-02-13 17:51:16 +02:00
parent b498a53441
commit 8a67f0c7f1
4 changed files with 43 additions and 2 deletions

View File

@ -62,6 +62,7 @@ public class DMPProfileDaoImpl extends DatabaseAccess<DMPProfile> implements DMP
QueryableList<DMPProfile> query = getDatabaseService().getQueryable(DMPProfile.class);
if (criteria.getLike() != null && !criteria.getLike().isEmpty())
query.where((builder, root) -> builder.like(builder.upper(root.get("label")), "%" + criteria.getLike().toUpperCase() + "%"));
query.where(((builder, root) -> builder.notEqual(root.get("status"), DMPProfile.Status.DELETED.getValue())));
return query;
}
}

View File

@ -17,6 +17,33 @@ import java.util.UUID;
@Table(name = "\"DMPProfile\"")
public class DMPProfile implements DataEntity<DMPProfile, UUID> {
public enum Status {
SAVED((short) 0), FINALIZED((short) 1), DELETED((short) 99);
private short value;
private Status(short value) {
this.value = value;
}
public short getValue() {
return value;
}
public static Status fromInteger(int value) {
switch (value) {
case 0:
return SAVED;
case 1:
return FINALIZED;
case 99:
return DELETED;
default:
throw new RuntimeException("Unsupported Dmp Profile Status");
}
}
}
@Id
@GeneratedValue
@GenericGenerator(name = "uuid2", strategy = "uuid2")
@ -109,6 +136,7 @@ public class DMPProfile implements DataEntity<DMPProfile, UUID> {
this.modified = new Date();
this.definition = entity.getDefinition();
this.label = entity.getLabel();
this.status= entity.getStatus();
}
@Override

View File

@ -0,0 +1,5 @@
export enum DmpProfileStatus {
Draft = 0,
Finalized = 1,
Deleted = 99
}

View File

@ -13,6 +13,7 @@ import { DmpProfileService } from '../../../../core/services/dmp/dmp-profile.ser
import { SnackBarNotificationLevel, UiNotificationService } from '../../../../core/services/notification/ui-notification-service';
import { EnumUtils } from '../../../../core/services/utilities/enum-utils.service';
import { DmpProfileEditorModel, DmpProfileFieldEditorModel } from './dmp-profile-editor.model';
import { DmpProfileStatus } from '../../../../core/common/enum/dmp-profile-status';
@Component({
selector: 'app-dmp-profile-editor-component',
@ -173,6 +174,12 @@ export class DmpProfileEditorComponent extends BaseComponent implements AfterVie
}
delete() {
//TODO
this.formGroup.get('status').setValue(DmpProfileStatus.Deleted);
this.dmpProfileService.createDmp(this.formGroup.value)
.pipe(takeUntil(this._destroyed))
.subscribe(
complete => this.onCallbackSuccess(),
error => this.onCallbackError(error)
);
}
}