Fixes bug on not creating new "External Datasets" and "Data Repositories". (Issue #212)
This commit is contained in:
parent
d4db0e204e
commit
52334aec6a
|
@ -1,6 +1,5 @@
|
||||||
package eu.eudat.models.data.datarepository;
|
package eu.eudat.models.data.datarepository;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
|
||||||
import eu.eudat.data.entities.DataRepository;
|
import eu.eudat.data.entities.DataRepository;
|
||||||
import eu.eudat.data.entities.UserInfo;
|
import eu.eudat.data.entities.UserInfo;
|
||||||
import eu.eudat.models.DataModel;
|
import eu.eudat.models.DataModel;
|
||||||
|
@ -8,13 +7,9 @@ import eu.eudat.models.DataModel;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by ikalyvas on 9/3/2018.
|
|
||||||
*/
|
|
||||||
public class DataRepositoryModel implements DataModel<DataRepository, DataRepositoryModel> {
|
public class DataRepositoryModel implements DataModel<DataRepository, DataRepositoryModel> {
|
||||||
private UUID id;
|
private UUID id;
|
||||||
@JsonProperty("name")
|
private String name;
|
||||||
private String label;
|
|
||||||
private String pid;
|
private String pid;
|
||||||
private String abbreviation;
|
private String abbreviation;
|
||||||
private String uri;
|
private String uri;
|
||||||
|
@ -30,11 +25,11 @@ public class DataRepositoryModel implements DataModel<DataRepository, DataReposi
|
||||||
this.id = id;
|
this.id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getLabel() {
|
public String getName() {
|
||||||
return label;
|
return name;
|
||||||
}
|
}
|
||||||
public void setLabel(String label) {
|
public void setName(String name) {
|
||||||
this.label = label;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getPid() {
|
public String getPid() {
|
||||||
|
@ -89,7 +84,7 @@ public class DataRepositoryModel implements DataModel<DataRepository, DataReposi
|
||||||
@Override
|
@Override
|
||||||
public DataRepositoryModel fromDataModel(DataRepository entity) {
|
public DataRepositoryModel fromDataModel(DataRepository entity) {
|
||||||
this.setAbbreviation(entity.getAbbreviation());
|
this.setAbbreviation(entity.getAbbreviation());
|
||||||
this.setLabel(entity.getLabel());
|
this.setName(entity.getLabel());
|
||||||
this.setUri(entity.getUri());
|
this.setUri(entity.getUri());
|
||||||
this.setId(entity.getId());
|
this.setId(entity.getId());
|
||||||
String source1 = entity.getReference().substring(0, entity.getReference().indexOf(":"));
|
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.setAbbreviation(this.abbreviation);
|
||||||
dataRepository.setCreated(this.created != null ? this.created : new Date());
|
dataRepository.setCreated(this.created != null ? this.created : new Date());
|
||||||
dataRepository.setModified(new Date());
|
dataRepository.setModified(new Date());
|
||||||
dataRepository.setLabel(this.label);
|
dataRepository.setLabel(this.name);
|
||||||
if (this.source.equals("Internal") || this.source.equals(this.id.toString().substring(0, this.source.length()))) {
|
if (this.source != null) {
|
||||||
dataRepository.setReference(this.id.toString());
|
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 {
|
} else {
|
||||||
dataRepository.setReference(this.source + ":" + this.id);
|
dataRepository.setReference("dmp:" + dataRepository.getId());
|
||||||
}
|
}
|
||||||
dataRepository.setUri(this.uri);
|
dataRepository.setUri(this.uri);
|
||||||
dataRepository.setStatus((short) 0);
|
dataRepository.setStatus((short) 0);
|
||||||
|
|
|
@ -7,7 +7,7 @@ import java.util.Date;
|
||||||
|
|
||||||
public class DataRepository implements DataModel<eu.eudat.data.entities.DataRepository, DataRepository>, LabelGenerator {
|
public class DataRepository implements DataModel<eu.eudat.data.entities.DataRepository, DataRepository>, LabelGenerator {
|
||||||
private String pid;
|
private String pid;
|
||||||
private String label;
|
private String name;
|
||||||
private String uri;
|
private String uri;
|
||||||
private String info;
|
private String info;
|
||||||
private String reference;
|
private String reference;
|
||||||
|
@ -21,11 +21,11 @@ public class DataRepository implements DataModel<eu.eudat.data.entities.DataRepo
|
||||||
this.pid = pid;
|
this.pid = pid;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getLabel() {
|
public String getName() {
|
||||||
return label;
|
return name;
|
||||||
}
|
}
|
||||||
public void setLabel(String label) {
|
public void setName(String name) {
|
||||||
this.label = label;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getUri() {
|
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) {
|
public DataRepository fromDataModel(eu.eudat.data.entities.DataRepository entity) {
|
||||||
this.pid = entity.getReference();
|
this.pid = entity.getReference();
|
||||||
this.label = entity.getLabel();
|
this.name = entity.getLabel();
|
||||||
this.uri = entity.getUri();
|
this.uri = entity.getUri();
|
||||||
this.reference = entity.getReference();
|
this.reference = entity.getReference();
|
||||||
String source1 = entity.getReference().substring(0, entity.getReference().indexOf(":"));
|
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() {
|
public eu.eudat.data.entities.DataRepository toDataModel() {
|
||||||
eu.eudat.data.entities.DataRepository entity = new eu.eudat.data.entities.DataRepository();
|
eu.eudat.data.entities.DataRepository entity = new eu.eudat.data.entities.DataRepository();
|
||||||
entity.setReference(this.pid);
|
entity.setReference(this.pid);
|
||||||
entity.setLabel(this.label);
|
entity.setLabel(this.name);
|
||||||
entity.setUri(this.uri);
|
entity.setUri(this.uri);
|
||||||
entity.setCreated(new Date());
|
entity.setCreated(new Date());
|
||||||
entity.setModified(new Date());
|
entity.setModified(new Date());
|
||||||
|
@ -99,7 +99,7 @@ public class DataRepository implements DataModel<eu.eudat.data.entities.DataRepo
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String generateLabel() {
|
public String generateLabel() {
|
||||||
return this.getLabel();
|
return this.getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
export interface DataRepositoryModel {
|
export interface DataRepositoryModel {
|
||||||
id: string;
|
id: string;
|
||||||
label: string;
|
name: string;
|
||||||
abbreviation: string;
|
abbreviation: string;
|
||||||
uri: string;
|
uri: string;
|
||||||
pid: string;
|
pid: string;
|
||||||
|
|
|
@ -303,7 +303,7 @@ export class ExternalDatasetEditorModel {
|
||||||
|
|
||||||
export class ExternalDataRepositoryEditorModel {
|
export class ExternalDataRepositoryEditorModel {
|
||||||
public id: string;
|
public id: string;
|
||||||
public label: string;
|
public name: string;
|
||||||
public abbreviation: string;
|
public abbreviation: string;
|
||||||
public uri: string;
|
public uri: string;
|
||||||
public reference: string;
|
public reference: string;
|
||||||
|
@ -312,9 +312,9 @@ export class ExternalDataRepositoryEditorModel {
|
||||||
public modified: Date;
|
public modified: Date;
|
||||||
public source: string;
|
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.id = id;
|
||||||
this.label = label;
|
this.name = name;
|
||||||
this.abbreviation = abbreviation;
|
this.abbreviation = abbreviation;
|
||||||
this.uri = uri;
|
this.uri = uri;
|
||||||
this.reference = reference;
|
this.reference = reference;
|
||||||
|
@ -323,7 +323,7 @@ export class ExternalDataRepositoryEditorModel {
|
||||||
|
|
||||||
fromModel(item: DataRepositoryModel): ExternalDataRepositoryEditorModel {
|
fromModel(item: DataRepositoryModel): ExternalDataRepositoryEditorModel {
|
||||||
this.id = item.id;
|
this.id = item.id;
|
||||||
this.label = item.label;
|
this.name = item.name;
|
||||||
this.abbreviation = item.abbreviation;
|
this.abbreviation = item.abbreviation;
|
||||||
this.uri = item.uri;
|
this.uri = item.uri;
|
||||||
this.info = item.info;
|
this.info = item.info;
|
||||||
|
@ -335,7 +335,7 @@ export class ExternalDataRepositoryEditorModel {
|
||||||
buildForm(context: ValidationContext = null, disabled: boolean = false): FormGroup {
|
buildForm(context: ValidationContext = null, disabled: boolean = false): FormGroup {
|
||||||
return new FormBuilder().group({
|
return new FormBuilder().group({
|
||||||
id: [this.id],
|
id: [this.id],
|
||||||
label: [this.label],
|
name: [this.name],
|
||||||
abbreviation: [this.abbreviation],
|
abbreviation: [this.abbreviation],
|
||||||
uri: [this.uri],
|
uri: [this.uri],
|
||||||
info: [this.info],
|
info: [this.info],
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
<ng-template #dataRepositoriesTemplate let-suggestion let-i="index" let-callback="function">
|
<ng-template #dataRepositoriesTemplate let-suggestion let-i="index" let-callback="function">
|
||||||
<div class="col-12 row align-items-center">
|
<div class="col-12 row align-items-center">
|
||||||
<span class="col">
|
<span class="col">
|
||||||
{{i+1}}) {{suggestion.get('label').value}}
|
{{i+1}}) {{suggestion.get('name').value}}
|
||||||
</span>
|
</span>
|
||||||
<div class="col-auto">
|
<div class="col-auto">
|
||||||
<mat-form-field>
|
<mat-form-field>
|
||||||
|
|
|
@ -139,7 +139,7 @@ export class DatasetExternalReferencesEditorComponent extends BaseComponent impl
|
||||||
.pipe(takeUntil(this._destroyed))
|
.pipe(takeUntil(this._destroyed))
|
||||||
.subscribe(result => {
|
.subscribe(result => {
|
||||||
if (!result) { return; }
|
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());
|
(<FormArray>this.formGroup.get('dataRepositories')).push(dataRepositoryModel.buildForm());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,8 +9,8 @@
|
||||||
</div>
|
</div>
|
||||||
<div mat-dialog-content class="row">
|
<div mat-dialog-content class="row">
|
||||||
<mat-form-field class="col-auto">
|
<mat-form-field class="col-auto">
|
||||||
<input matInput formControlName="label" placeholder="{{'DATASET-REFERENCED-MODELS.DATA-REPOSITORY.LABEL' | translate}}" required>
|
<input matInput formControlName="name" placeholder="{{'DATASET-REFERENCED-MODELS.DATA-REPOSITORY.LABEL' | translate}}" required>
|
||||||
<mat-error *ngIf="formGroup.get('label').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
<mat-error *ngIf="formGroup.get('name').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
<mat-form-field class="col-auto">
|
<mat-form-field class="col-auto">
|
||||||
<input matInput formControlName="abbreviation" placeholder="{{'DATASET-REFERENCED-MODELS.DATA-REPOSITORY.ABBREVIATION' | translate}}" required>
|
<input matInput formControlName="abbreviation" placeholder="{{'DATASET-REFERENCED-MODELS.DATA-REPOSITORY.ABBREVIATION' | translate}}" required>
|
||||||
|
|
Loading…
Reference in New Issue