Implemented Simple Locking Mechanism for Editing/Viewing Datasets - (Ticket #45 - Dataset editing / viewing modes)
This commit is contained in:
parent
17391120ff
commit
1d4eb0128e
|
@ -1,19 +1,26 @@
|
|||
package eu.eudat.logic.services.utilities;
|
||||
|
||||
import eu.eudat.core.logger.Logger;
|
||||
import eu.eudat.core.models.exception.ApiExceptionLoggingModel;
|
||||
import eu.eudat.data.dao.entities.DMPDao;
|
||||
import eu.eudat.data.dao.entities.InvitationDao;
|
||||
import eu.eudat.data.entities.DMP;
|
||||
import eu.eudat.data.entities.Invitation;
|
||||
import eu.eudat.data.entities.UserInfo;
|
||||
import eu.eudat.models.data.mail.SimpleMail;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.stereotype.Service;
|
||||
import types.LoggingType;
|
||||
|
||||
import javax.mail.MessagingException;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
@Service("invitationService")
|
||||
|
@ -38,8 +45,10 @@ public class InvitationServiceImpl implements InvitationService {
|
|||
|
||||
@Override
|
||||
public void assignToDmp(DMPDao dmpDao, eu.eudat.data.entities.UserInfo user, DMP dmp) {
|
||||
dmp.getUsers().add(user);
|
||||
dmpDao.createOrUpdate(dmp);
|
||||
if (!dmp.getUsers().stream().map(x -> x.getId()).collect(Collectors.toList()).contains(user.getId())) {
|
||||
dmp.getUsers().add(user);
|
||||
dmpDao.createOrUpdate(dmp);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -65,8 +74,17 @@ public class InvitationServiceImpl implements InvitationService {
|
|||
mail.setTo(invitation.getInvitationEmail());
|
||||
try {
|
||||
mailService.sendSimpleMail(mail);
|
||||
} catch (MessagingException e) {
|
||||
this.logger.error(e, e.getMessage());
|
||||
} catch (Exception ex) {
|
||||
ApiExceptionLoggingModel<Exception, UserInfo> apiExceptionLoggingModel = new ApiExceptionLoggingModel<>();
|
||||
apiExceptionLoggingModel.setCode(HttpStatus.BAD_REQUEST);
|
||||
apiExceptionLoggingModel.setUser(invitation.getUser());
|
||||
Map<String, Exception> exceptionMap = new HashMap<>();
|
||||
exceptionMap.put("exception", ex);
|
||||
apiExceptionLoggingModel.setData(exceptionMap);
|
||||
apiExceptionLoggingModel.setMessage(ex.getMessage());
|
||||
apiExceptionLoggingModel.setType(LoggingType.ERROR);
|
||||
ex.printStackTrace();
|
||||
this.logger.error(apiExceptionLoggingModel);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
dmp.domain = http://localhost:4200
|
||||
|
||||
####################PERSISTENCE OVERRIDES CONFIGURATIONS##########
|
||||
database.url=jdbc:postgresql://localhost:32768/dmptool
|
||||
database.username=postgres
|
||||
database.password=
|
||||
|
||||
database.url=jdbc:postgresql://dbserver02.local.cite.gr:5432/dmptool
|
||||
database.username=dmtadm
|
||||
database.password=t00L4DM@18!
|
||||
spring.datasource.maxIdle: 2
|
||||
spring.datasource.max-active: 4
|
||||
spring.datasource.max-wait: 10000
|
||||
####################ELASTIIC SEARCH TAGS OVERRIDES CONFIGURATIONS##########
|
||||
elasticsearch.host = localhost
|
||||
elasticsearch.port = 9200
|
||||
|
|
|
@ -5,6 +5,12 @@
|
|||
<h3 *ngIf="!isNew">{{datasetWizardModel?.label}} {{ 'GENERAL.NAMES.DATASET' | translate }}</h3>
|
||||
<h3 *ngIf="this.formGroup && this.formGroup.dirty"> - {{ 'GENERAL.STATUSES.EDIT' | translate }}</h3>
|
||||
<h3 *ngIf="this.formGroup && viewOnly"> - {{ 'GENERAL.STATUSES.FINALISED' | translate }}</h3>
|
||||
<button *ngIf="!editMode " mat-icon-button (click)="enableForm()">
|
||||
<mat-icon class="mat-24">edit</mat-icon>
|
||||
</button>
|
||||
<button *ngIf="editMode" mat-icon-button (click)="disableForm()">
|
||||
<mat-icon class="mat-24">lock</mat-icon>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex-container" *ngIf="this.datasetProfileDefinitionModel">
|
||||
|
|
|
@ -9,7 +9,7 @@ import { DatasetService } from '../../services/dataset/dataset.service';
|
|||
import { ExternalSourcesItemModel } from '../../models/external-sources/ExternalSourcesItemModel';
|
||||
import { DatasetProfileModel } from '../../models/datasetprofile/DatasetProfileModel';
|
||||
import { DatasetProfileDefinitionModel } from '../../models/DatasetProfileDefinitionModel';
|
||||
import { DatasetWizardModel } from '../../models/datasets/DatasetWizardModel';
|
||||
import { DatasetWizardModel, DatasetStatus } from '../../models/datasets/DatasetWizardModel';
|
||||
import { DataManagementPlanService } from '../../services/data-management-plan/data-management-plan.service';
|
||||
import { ExternalSourcesService } from '../../services/external-sources/external-sources.service';
|
||||
import { DatasetWizardService } from '../../services/dataset-wizard/dataset-wizard.service';
|
||||
|
@ -52,6 +52,8 @@ export class DatasetWizardComponent implements OnInit, AfterViewInit, IBreadCrum
|
|||
breadCrumbs: Observable<BreadcrumbItem[]>;
|
||||
viewOnly = false;
|
||||
@ViewChild('stepper') stepper: MatStepper;
|
||||
editMode = false;
|
||||
|
||||
//autocomplete Display Functions;
|
||||
//autocomplete Configurations;
|
||||
externalDatasetAutoCompleteConfiguration: AutoCompleteConfiguration;
|
||||
|
@ -144,7 +146,6 @@ export class DatasetWizardComponent implements OnInit, AfterViewInit, IBreadCrum
|
|||
items: this.searchDmp(''),
|
||||
displayFn: (item) => item['label'],
|
||||
titleFn: (item) => item['label'],
|
||||
//mapFn: (item) => new JsonSerializer<ProjectReference>().fromJSONArray(item, ProjectReference).map(item => item.toDropdownList()),
|
||||
loadDataOnStart: true
|
||||
};
|
||||
|
||||
|
@ -175,6 +176,7 @@ export class DatasetWizardComponent implements OnInit, AfterViewInit, IBreadCrum
|
|||
]
|
||||
}]);
|
||||
this.formGroup = this.datasetWizardModel.buildForm();
|
||||
this.editMode = this.datasetWizardModel.status === DatasetStatus.Draft;
|
||||
if (this.datasetWizardModel.status === 1) {
|
||||
this.formGroup.disable();
|
||||
this.viewOnly = true;
|
||||
|
@ -190,12 +192,12 @@ export class DatasetWizardComponent implements OnInit, AfterViewInit, IBreadCrum
|
|||
setTimeout(() => {
|
||||
this.datasetWizardModel.dmp = data;
|
||||
this.formGroup = this.datasetWizardModel.buildForm();
|
||||
this.editMode = this.datasetWizardModel.status === DatasetStatus.Draft;
|
||||
if (this.datasetWizardModel.status === 1) {
|
||||
this.formGroup.disable();
|
||||
this.viewOnly = true;
|
||||
}
|
||||
this.loadDatasetProfiles();
|
||||
|
||||
this.breadCrumbs = Observable.of([
|
||||
{
|
||||
parentComponentName: null,
|
||||
|
@ -218,13 +220,12 @@ export class DatasetWizardComponent implements OnInit, AfterViewInit, IBreadCrum
|
|||
} else {
|
||||
this.datasetWizardModel = new DatasetWizardModel();
|
||||
this.formGroup = this.datasetWizardModel.buildForm();
|
||||
this.editMode = this.datasetWizardModel.status === DatasetStatus.Draft;
|
||||
if (this.datasetWizardModel.status === 1) {
|
||||
this.formGroup.disable();
|
||||
this.viewOnly = true;
|
||||
}
|
||||
|
||||
if (this.viewOnly) { this.formGroup.disable(); }
|
||||
|
||||
this.formGroup.get('dmp').valueChanges.subscribe(x => {
|
||||
this.loadDatasetProfiles();
|
||||
});
|
||||
|
@ -461,4 +462,15 @@ export class DatasetWizardComponent implements OnInit, AfterViewInit, IBreadCrum
|
|||
(<FormArray>this.formGroup.get('services')).push(serviceModel.buildForm());
|
||||
});
|
||||
}
|
||||
|
||||
public enableForm() {
|
||||
this.editMode = true;
|
||||
this.formGroup.enable();
|
||||
|
||||
}
|
||||
|
||||
public disableForm() {
|
||||
this.editMode = false;
|
||||
this.formGroup.disable();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,8 +15,6 @@ import { TdDialogService } from '@covalent/core';
|
|||
import { ProjectFileUploaderService } from '../../services/files/project-file-uploader.service';
|
||||
import { HostConfiguration } from '../../app.constants';
|
||||
import { LanguageResolverService } from '../../services/language-resolver/language-resolver.service';
|
||||
import { THIS_EXPR } from '@angular/compiler/src/output/output_ast';
|
||||
import { BaseHttpService } from '../../utilities/cite-http-service-module/base-http.service';
|
||||
import { IBreadCrumbComponent } from '../../shared/components/breadcrumb/definition/IBreadCrumbComponent';
|
||||
import { BreadcrumbItem } from '../../shared/components/breadcrumb/definition/breadcrumb-item';
|
||||
|
||||
|
|
Loading…
Reference in New Issue