Fixes bug on not creating new "External Datasets" and "Data Repositories". (Issue #212)

This commit is contained in:
gkolokythas 2019-12-13 13:05:58 +02:00
parent d4db0e204e
commit 52334aec6a
7 changed files with 32 additions and 33 deletions

View File

@ -1,6 +1,5 @@
package eu.eudat.models.data.datarepository;
import com.fasterxml.jackson.annotation.JsonProperty;
import eu.eudat.data.entities.DataRepository;
import eu.eudat.data.entities.UserInfo;
import eu.eudat.models.DataModel;
@ -8,13 +7,9 @@ import eu.eudat.models.DataModel;
import java.util.Date;
import java.util.UUID;
/**
* Created by ikalyvas on 9/3/2018.
*/
public class DataRepositoryModel implements DataModel<DataRepository, DataRepositoryModel> {
private UUID id;
@JsonProperty("name")
private String label;
private String name;
private String pid;
private String abbreviation;
private String uri;
@ -30,11 +25,11 @@ public class DataRepositoryModel implements DataModel<DataRepository, DataReposi
this.id = id;
}
public String getLabel() {
return label;
public String getName() {
return name;
}
public void setLabel(String label) {
this.label = label;
public void setName(String name) {
this.name = name;
}
public String getPid() {
@ -89,7 +84,7 @@ public class DataRepositoryModel implements DataModel<DataRepository, DataReposi
@Override
public DataRepositoryModel fromDataModel(DataRepository entity) {
this.setAbbreviation(entity.getAbbreviation());
this.setLabel(entity.getLabel());
this.setName(entity.getLabel());
this.setUri(entity.getUri());
this.setId(entity.getId());
String source1 = entity.getReference().substring(0, entity.getReference().indexOf(":"));
@ -108,11 +103,15 @@ public class DataRepositoryModel implements DataModel<DataRepository, DataReposi
dataRepository.setAbbreviation(this.abbreviation);
dataRepository.setCreated(this.created != null ? this.created : new Date());
dataRepository.setModified(new Date());
dataRepository.setLabel(this.label);
if (this.source.equals("Internal") || this.source.equals(this.id.toString().substring(0, this.source.length()))) {
dataRepository.setReference(this.id.toString());
dataRepository.setLabel(this.name);
if (this.source != null) {
if (this.source.equals("Internal") || this.source.equals(this.id.toString().substring(0, this.source.length()))) {
dataRepository.setReference(this.id.toString());
} else {
dataRepository.setReference(this.source + ":" + dataRepository.getId());
}
} else {
dataRepository.setReference(this.source + ":" + this.id);
dataRepository.setReference("dmp:" + dataRepository.getId());
}
dataRepository.setUri(this.uri);
dataRepository.setStatus((short) 0);

View File

@ -7,7 +7,7 @@ import java.util.Date;
public class DataRepository implements DataModel<eu.eudat.data.entities.DataRepository, DataRepository>, LabelGenerator {
private String pid;
private String label;
private String name;
private String uri;
private String info;
private String reference;
@ -21,11 +21,11 @@ public class DataRepository implements DataModel<eu.eudat.data.entities.DataRepo
this.pid = pid;
}
public String getLabel() {
return label;
public String getName() {
return name;
}
public void setLabel(String label) {
this.label = label;
public void setName(String name) {
this.name = name;
}
public String getUri() {
@ -65,7 +65,7 @@ public class DataRepository implements DataModel<eu.eudat.data.entities.DataRepo
public DataRepository fromDataModel(eu.eudat.data.entities.DataRepository entity) {
this.pid = entity.getReference();
this.label = entity.getLabel();
this.name = entity.getLabel();
this.uri = entity.getUri();
this.reference = entity.getReference();
String source1 = entity.getReference().substring(0, entity.getReference().indexOf(":"));
@ -80,7 +80,7 @@ public class DataRepository implements DataModel<eu.eudat.data.entities.DataRepo
public eu.eudat.data.entities.DataRepository toDataModel() {
eu.eudat.data.entities.DataRepository entity = new eu.eudat.data.entities.DataRepository();
entity.setReference(this.pid);
entity.setLabel(this.label);
entity.setLabel(this.name);
entity.setUri(this.uri);
entity.setCreated(new Date());
entity.setModified(new Date());
@ -99,7 +99,7 @@ public class DataRepository implements DataModel<eu.eudat.data.entities.DataRepo
@Override
public String generateLabel() {
return this.getLabel();
return this.getName();
}
@Override

View File

@ -1,6 +1,6 @@
export interface DataRepositoryModel {
id: string;
label: string;
name: string;
abbreviation: string;
uri: string;
pid: string;

View File

@ -303,7 +303,7 @@ export class ExternalDatasetEditorModel {
export class ExternalDataRepositoryEditorModel {
public id: string;
public label: string;
public name: string;
public abbreviation: string;
public uri: string;
public reference: string;
@ -312,9 +312,9 @@ export class ExternalDataRepositoryEditorModel {
public modified: Date;
public source: string;
constructor(id?: string, label?: string, abbreviation?: string, uri?: string, reference?: string, source?: string) {
constructor(id?: string, name?: string, abbreviation?: string, uri?: string, reference?: string, source?: string) {
this.id = id;
this.label = label;
this.name = name;
this.abbreviation = abbreviation;
this.uri = uri;
this.reference = reference;
@ -323,7 +323,7 @@ export class ExternalDataRepositoryEditorModel {
fromModel(item: DataRepositoryModel): ExternalDataRepositoryEditorModel {
this.id = item.id;
this.label = item.label;
this.name = item.name;
this.abbreviation = item.abbreviation;
this.uri = item.uri;
this.info = item.info;
@ -335,7 +335,7 @@ export class ExternalDataRepositoryEditorModel {
buildForm(context: ValidationContext = null, disabled: boolean = false): FormGroup {
return new FormBuilder().group({
id: [this.id],
label: [this.label],
name: [this.name],
abbreviation: [this.abbreviation],
uri: [this.uri],
info: [this.info],

View File

@ -16,7 +16,7 @@
<ng-template #dataRepositoriesTemplate let-suggestion let-i="index" let-callback="function">
<div class="col-12 row align-items-center">
<span class="col">
{{i+1}}) {{suggestion.get('label').value}}
{{i+1}}) {{suggestion.get('name').value}}
</span>
<div class="col-auto">
<mat-form-field>

View File

@ -139,7 +139,7 @@ export class DatasetExternalReferencesEditorComponent extends BaseComponent impl
.pipe(takeUntil(this._destroyed))
.subscribe(result => {
if (!result) { return; }
const dataRepositoryModel = new ExternalDataRepositoryEditorModel(result.id, result.label, result.pid, result.uri, result.reference);
const dataRepositoryModel = new ExternalDataRepositoryEditorModel(result.id, result.name, result.pid, result.uri, result.reference);
(<FormArray>this.formGroup.get('dataRepositories')).push(dataRepositoryModel.buildForm());
});
}

View File

@ -9,8 +9,8 @@
</div>
<div mat-dialog-content class="row">
<mat-form-field class="col-auto">
<input matInput formControlName="label" placeholder="{{'DATASET-REFERENCED-MODELS.DATA-REPOSITORY.LABEL' | translate}}" required>
<mat-error *ngIf="formGroup.get('label').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
<input matInput formControlName="name" placeholder="{{'DATASET-REFERENCED-MODELS.DATA-REPOSITORY.LABEL' | translate}}" required>
<mat-error *ngIf="formGroup.get('name').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>
<mat-form-field class="col-auto">
<input matInput formControlName="abbreviation" placeholder="{{'DATASET-REFERENCED-MODELS.DATA-REPOSITORY.ABBREVIATION' | translate}}" required>