bug fixes

(cherry picked from commit 846405435c)
This commit is contained in:
Bernaldo Mihasi 2023-10-05 09:33:28 +03:00 committed by Diamantis Tziotzios
parent f841c2a2cc
commit b7f68f1a7e
7 changed files with 72 additions and 20 deletions

View File

@ -528,7 +528,7 @@ public class DataManagementPlanManager {
}
if(this.dataManagementProfileManager.fieldInBlueprint(newDmp.getProfile(), SystemFieldType.GRANT, principal)) {
if (newDmp.getGrant().getType().equals(Grant.GrantType.INTERNAL.getValue())) {
if (newDmp.getGrant() != null && newDmp.getGrant().getType().equals(Grant.GrantType.INTERNAL.getValue())) {
checkIfUserCanEditGrant(newDmp, user);
}
assignGrandUserIfInternal(newDmp, user);
@ -547,7 +547,9 @@ public class DataManagementPlanManager {
}
if(this.dataManagementProfileManager.fieldInBlueprint(newDmp.getProfile(), SystemFieldType.GRANT, principal)) {
apiContext.getOperationsContext().getDatabaseRepository().getGrantDao().createOrUpdate(newDmp.getGrant());
if (newDmp.getGrant() != null) {
apiContext.getOperationsContext().getDatabaseRepository().getGrantDao().createOrUpdate(newDmp.getGrant());
}
}
newDmp = apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().createOrUpdate(newDmp);
@ -717,7 +719,7 @@ public class DataManagementPlanManager {
newDmp.setId(null);
if(this.dataManagementProfileManager.fieldInBlueprint(newDmp.getProfile(), SystemFieldType.GRANT, principal)) {
if (newDmp.getGrant().getType().equals(Grant.GrantType.INTERNAL.getValue())) {
if (newDmp.getGrant() != null && newDmp.getGrant().getType().equals(Grant.GrantType.INTERNAL.getValue())) {
checkIfUserCanEditGrant(newDmp, user);
}
assignGrandUserIfInternal(newDmp, user);
@ -729,13 +731,15 @@ public class DataManagementPlanManager {
assignProjectUserIfInternal(newDmp, user);
}
if(this.dataManagementProfileManager.fieldInBlueprint(newDmp.getProfile(), SystemFieldType.GRANT, principal)) {
if (newDmp.getGrant().getStartdate() == null) {
newDmp.getGrant().setStartdate(new Date());
if (newDmp.getGrant() != null) {
if (newDmp.getGrant().getStartdate() == null) {
newDmp.getGrant().setStartdate(new Date());
}
if (newDmp.getGrant().getEnddate() == null) {
newDmp.getGrant().setEnddate(Date.from(Instant.now().plus(365, ChronoUnit.DAYS)));
}
databaseRepository.getGrantDao().createOrUpdate(newDmp.getGrant());
}
if (newDmp.getGrant().getEnddate() == null) {
newDmp.getGrant().setEnddate(Date.from(Instant.now().plus(365, ChronoUnit.DAYS)));
}
databaseRepository.getGrantDao().createOrUpdate(newDmp.getGrant());
}
DMP tempDmp = databaseRepository.getDmpDao().createOrUpdate(newDmp);
newDmp.setId(tempDmp.getId());
@ -804,7 +808,7 @@ public class DataManagementPlanManager {
newDmp.setId(null);
if(this.dataManagementProfileManager.fieldInBlueprint(newDmp.getProfile(), SystemFieldType.GRANT, principal)) {
if (newDmp.getGrant().getType().equals(Grant.GrantType.INTERNAL.getValue())) {
if (newDmp.getGrant() != null && newDmp.getGrant().getType().equals(Grant.GrantType.INTERNAL.getValue())) {
checkIfUserCanEditGrant(newDmp, user);
}
assignGrandUserIfInternal(newDmp, user);
@ -816,7 +820,9 @@ public class DataManagementPlanManager {
assignProjectUserIfInternal(newDmp, user);
}
if(this.dataManagementProfileManager.fieldInBlueprint(newDmp.getProfile(), SystemFieldType.GRANT, principal)) {
databaseRepository.getGrantDao().createOrUpdate(newDmp.getGrant());
if (newDmp.getGrant() != null) {
databaseRepository.getGrantDao().createOrUpdate(newDmp.getGrant());
}
}
DMP tempDmp = databaseRepository.getDmpDao().createOrUpdate(newDmp);
newDmp.setId(tempDmp.getId());
@ -2306,19 +2312,19 @@ public class DataManagementPlanManager {
}
private void assignGrandUserIfInternal(DMP dmp, UserInfo user) {
if (dmp.getGrant().getCreationUser() == null && (dmp.getGrant().getReference() != null && dmp.getGrant().getReference().startsWith("dmp:"))) {
if (dmp.getGrant() != null && dmp.getGrant().getCreationUser() == null && (dmp.getGrant().getReference() != null && dmp.getGrant().getReference().startsWith("dmp:"))) {
dmp.getGrant().setCreationUser(user);
}
}
private void assignFunderUserIfInternal(DMP dmp, UserInfo user) {
if (dmp.getGrant().getFunder().getCreationUser() == null && ( dmp.getGrant().getFunder().getReference() != null && dmp.getGrant().getFunder().getReference().startsWith("dmp:"))) {
if (dmp.getGrant() != null && dmp.getGrant().getFunder() != null && dmp.getGrant().getFunder().getCreationUser() == null && ( dmp.getGrant().getFunder().getReference() != null && dmp.getGrant().getFunder().getReference().startsWith("dmp:"))) {
dmp.getGrant().getFunder().setCreationUser(user);
}
}
private void assignProjectUserIfInternal(DMP dmp, UserInfo user) {
if (dmp.getProject().getCreationUser() == null && (dmp.getProject().getReference() != null && dmp.getProject().getReference().startsWith("dmp:"))) {
if (dmp.getProject() != null && dmp.getProject().getCreationUser() == null && (dmp.getProject().getReference() != null && dmp.getProject().getReference().startsWith("dmp:"))) {
dmp.getProject().setCreationUser(user);
}
}
@ -2398,7 +2404,7 @@ public class DataManagementPlanManager {
* */
private void checkIfUserCanEditGrant(DMP dmp, UserInfo user) throws Exception{
if (dmp.getGrant().getId() != null) {
if (dmp.getGrant() != null && dmp.getGrant().getId() != null) {
Grant grant = apiContext.getOperationsContext().getDatabaseRepository().getGrantDao().find(dmp.getGrant().getId());
if (grant.getFunder() != null && dmp.getGrant().getFunder() != null
&& !grant.getFunder().getId().equals(dmp.getGrant().getFunder().getId())) {

View File

@ -16,7 +16,7 @@ public class AssociatedProfileImportModels {
public UUID getId() { return id; }
public void setId(UUID id) { this.id = id; }
@XmlElement(name = "profilelabel")
@XmlElement(name = "profileLabel")
public String getLabel() { return label; }
public void setLabel(String label) { this.label = label; }

View File

@ -302,7 +302,7 @@ public class DataManagementPlanEditorModel implements DataModel<DMP, DataManagem
if (this.grant != null) {
if (this.grant.getExistGrant() != null && this.grant.getLabel() == null && this.grant.getDescription() == null)
dataManagementPlanEntity.setGrant(this.grant.getExistGrant().toDataModel());
else {
else if (this.grant.getLabel() != null) {
Grant grant = new Grant();
grant.setId(UUID.randomUUID());
grant.setAbbreviation("");
@ -342,7 +342,7 @@ public class DataManagementPlanEditorModel implements DataModel<DMP, DataManagem
if (this.project != null) {
if (this.project.getExistProject() != null && this.project.getLabel() == null && this.project.getDescription() == null)
dataManagementPlanEntity.setProject(this.project.getExistProject().toDataModel());
else {
else if (this.project.getLabel() != null) {
Project project = new Project();
project.setId(UUID.randomUUID());
project.setAbbreviation("");

View File

@ -196,7 +196,7 @@ public class DataManagementPlanNewVersionModel implements DataModel<DMP, DataMan
if (this.grant != null) {
if (this.grant.getExistGrant() != null && this.grant.getLabel() == null && this.grant.getDescription() == null)
entity.setGrant(this.grant.getExistGrant().toDataModel());
else {
else if (this.grant.getLabel() != null) {
eu.eudat.data.entities.Grant grant = new eu.eudat.data.entities.Grant();
grant.setId(UUID.randomUUID());
grant.setAbbreviation("");
@ -236,7 +236,7 @@ public class DataManagementPlanNewVersionModel implements DataModel<DMP, DataMan
if (this.project != null) {
if (this.project.getExistProject() != null && this.project.getLabel() == null && this.project.getDescription() == null)
entity.setProject(this.project.getExistProject().toDataModel());
else {
else if (this.project.getLabel() != null) {
Project project = new Project();
project.setId(UUID.randomUUID());
project.setAbbreviation("");

View File

@ -223,6 +223,9 @@ export class DmpProfileEditorComponent extends BaseComponent implements AfterVie
removeSection(sectionIndex: number): void {
this.systemFieldListPerSection.splice(sectionIndex, 1);
this.sectionsArray().removeAt(sectionIndex);
this.sectionsArray().controls.forEach((section, index) => {
section.get('ordinal').setValue(index + 1);
});
}
fieldsArray(sectionIndex: number): FormArray {

View File

@ -199,6 +199,7 @@ export class DatasetWizardComponent extends CheckDeactivateBaseComponent impleme
this.lockService.checkLockStatus(data.id).pipe(takeUntil(this._destroyed)).subscribe(lockStatus => {
this.lockStatus = lockStatus;
this.datasetWizardModel = new DatasetWizardEditorModel().fromModel(data);
this.dmpSectionIndex = this.datasetWizardModel.dmpSectionIndex;
this.needsUpdate();
this.breadCrumbs = observableOf([
{
@ -337,6 +338,7 @@ export class DatasetWizardComponent extends CheckDeactivateBaseComponent impleme
this.lockService.checkLockStatus(data.id).pipe(takeUntil(this._destroyed)).subscribe(lockStatus => {
this.lockStatus = lockStatus;
this.datasetWizardModel = new DatasetWizardEditorModel().fromModel(data);
this.dmpSectionIndex = this.datasetWizardModel.dmpSectionIndex;
this.datasetWizardModel.status = 0;
this.formGroup = this.datasetWizardModel.buildForm();
this.formGroup.get('id').setValue(null);

View File

@ -56,6 +56,7 @@ import { PopupNotificationDialogComponent } from '@app/library/notification/popu
import { GrantEditorModel } from '@app/ui/grant/editor/grant-editor.model';
import { CheckDeactivateBaseComponent } from '@app/library/deactivate/deactivate.component';
import { DmpProfileStatus } from '@app/core/common/enum/dmp-profile-status';
import { DatasetService } from '@app/core/services/dataset/dataset.service';
interface Visible {
value: boolean;
@ -132,6 +133,7 @@ export class DmpEditorBlueprintComponent extends CheckDeactivateBaseComponent im
constructor(
private dmpProfileService: DmpProfileService,
private datasetService: DatasetService,
private authService: AuthService,
private route: ActivatedRoute,
private router: Router,
@ -658,6 +660,44 @@ export class DmpEditorBlueprintComponent extends CheckDeactivateBaseComponent im
}
public removeDataset(datasetId: string, index: number) {
const dialogRef = this.dialog.open(ConfirmationDialogComponent, {
maxWidth: '300px',
restoreFocus: false,
data: {
message: this.language.instant('GENERAL.CONFIRMATION-DIALOG.DELETE-ITEM'),
confirmButton: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ACTIONS.DELETE'),
cancelButton: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ACTIONS.CANCEL'),
isDeleteConfirmation: true
}
});
dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => {
if (result) {
if (datasetId) {
this.datasetService.delete(datasetId)
.pipe(takeUntil(this._destroyed))
.subscribe(
complete => {
this.onDeleteCallbackSuccess();
},
error => this.onDeleteCallbackError(error)
);
}
this.formGroup.get('datasets')['controls'].splice(index, 1);
this.step = 0;
}
});
}
onDeleteCallbackSuccess(): void {
this.uiNotificationService.snackBarNotification(this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-DELETE'), SnackBarNotificationLevel.Success);
this.dmp.id != null ? this.router.navigate(['/reload']).then(() => this.router.navigate(['/plans', 'edit', this.dmp.id])) : this.router.navigate(['/plans']);
}
onDeleteCallbackError(error) {
this.uiNotificationService.snackBarNotification(error.error.message ? error.error.message : this.language.instant('GENERAL.SNACK-BAR.UNSUCCESSFUL-DELETE'), SnackBarNotificationLevel.Error);
}
//checks if the dpm is valid not taking into account the datasets validity
private _isDMPDescriptionValid():boolean{
@ -933,6 +973,7 @@ export class DmpEditorBlueprintComponent extends CheckDeactivateBaseComponent im
let fields: Array<string> = new Array();
var request = new DataTableRequest<DmpBlueprintCriteria>(0, 20, { fields: fields });
request.criteria = new DmpBlueprintCriteria();
request.criteria.like = query;
request.criteria.status = DmpProfileStatus.Finalized;
return this.dmpProfileService.getPagedBlueprint(request).pipe(map(x => x.data));
}