various fixes
This commit is contained in:
parent
d60ecc4f1c
commit
ef02fa806e
|
@ -1,5 +1,6 @@
|
|||
package eu.eudat.model;
|
||||
|
||||
import eu.eudat.commons.enums.IsActive;
|
||||
import eu.eudat.model.dmpreference.DmpReferenceData;
|
||||
|
||||
import java.time.Instant;
|
||||
|
@ -16,6 +17,9 @@ public class DmpReference {
|
|||
private Reference reference;
|
||||
public static final String _reference = "reference";
|
||||
|
||||
private IsActive isActive;
|
||||
public static final String _isActive = "isActive";
|
||||
|
||||
private Instant createdAt;
|
||||
|
||||
public static final String _createdAt = "createdAt";
|
||||
|
@ -53,6 +57,14 @@ public class DmpReference {
|
|||
this.reference = reference;
|
||||
}
|
||||
|
||||
public IsActive getIsActive() {
|
||||
return isActive;
|
||||
}
|
||||
|
||||
public void setIsActive(IsActive isActive) {
|
||||
this.isActive = isActive;
|
||||
}
|
||||
|
||||
public Instant getCreatedAt() { return createdAt;}
|
||||
|
||||
public void setCreatedAt(Instant createdAt) {this.createdAt = createdAt;}
|
||||
|
|
|
@ -74,6 +74,7 @@ public class DmpReferenceBuilder extends BaseBuilder<DmpReference, DmpReferenceE
|
|||
for (DmpReferenceEntity d : data) {
|
||||
DmpReference m = new DmpReference();
|
||||
if (fields.hasField(this.asIndexer(DmpReference._id))) m.setId(d.getId());
|
||||
if (fields.hasField(this.asIndexer(DmpReference._isActive))) m.setIsActive(d.getIsActive());
|
||||
if (fields.hasField(this.asIndexer(DmpReference._createdAt))) m.setCreatedAt(d.getCreatedAt());
|
||||
if (fields.hasField(this.asIndexer(DmpReference._updatedAt))) m.setUpdatedAt(d.getUpdatedAt());
|
||||
if (fields.hasField(this.asIndexer(DmpReference._hash))) m.setHash(this.hashValue(d.getUpdatedAt()));
|
||||
|
|
|
@ -211,6 +211,7 @@ public class DmpReferenceQuery extends QueryBase<DmpReferenceEntity> {
|
|||
item.setDmpId(QueryBase.convertSafe(tuple, columns, DmpReferenceEntity._dmpId, UUID.class));
|
||||
item.setReferenceId(QueryBase.convertSafe(tuple, columns, DmpReferenceEntity._referenceId, UUID.class));
|
||||
item.setData(QueryBase.convertSafe(tuple, columns, DmpReferenceEntity._data, String.class));
|
||||
item.setIsActive(QueryBase.convertSafe(tuple, columns, DmpReferenceEntity._isActive, IsActive.class));
|
||||
item.setCreatedAt(QueryBase.convertSafe(tuple, columns, DmpReferenceEntity._createdAt, Instant.class));
|
||||
item.setUpdatedAt(QueryBase.convertSafe(tuple, columns, DmpReferenceEntity._updatedAt, Instant.class));
|
||||
return item;
|
||||
|
@ -224,6 +225,7 @@ public class DmpReferenceQuery extends QueryBase<DmpReferenceEntity> {
|
|||
else if (item.match(DmpReference._dmp) || item.match(PublicDmpReference._dmp)) return DmpReferenceEntity._dmpId;
|
||||
else if (item.match(DmpReference._reference) || item.match(PublicDmpReference._reference)) return DmpReferenceEntity._referenceId;
|
||||
else if (item.prefix(DmpReference._data)) return DmpReferenceEntity._data;
|
||||
else if (item.match(DmpReference._isActive)) return DmpReferenceEntity._isActive;
|
||||
else if (item.match(DmpReference._createdAt)) return DmpReferenceEntity._createdAt;
|
||||
else if (item.match(DmpReference._updatedAt)) return DmpReferenceEntity._updatedAt;
|
||||
else if (item.match(DmpReference._hash)) return DmpReferenceEntity._updatedAt;
|
||||
|
|
|
@ -5,16 +5,40 @@ import gr.cite.tools.data.query.Lookup;
|
|||
import gr.cite.tools.data.query.QueryFactory;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public class DmpReferenceLookup extends Lookup {
|
||||
|
||||
private Collection<UUID> ids;
|
||||
private List<UUID> ids;
|
||||
|
||||
private Collection<UUID> dmpIds;
|
||||
private List<UUID> dmpIds;
|
||||
|
||||
private Collection<UUID> referenceIds;
|
||||
private List<UUID> referenceIds;
|
||||
|
||||
public List<UUID> getIds() {
|
||||
return ids;
|
||||
}
|
||||
|
||||
public void setIds(List<UUID> ids) {
|
||||
this.ids = ids;
|
||||
}
|
||||
|
||||
public List<UUID> getDmpIds() {
|
||||
return dmpIds;
|
||||
}
|
||||
|
||||
public void setDmpIds(List<UUID> dmpIds) {
|
||||
this.dmpIds = dmpIds;
|
||||
}
|
||||
|
||||
public List<UUID> getReferenceIds() {
|
||||
return referenceIds;
|
||||
}
|
||||
|
||||
public void setReferenceIds(List<UUID> referenceIds) {
|
||||
this.referenceIds = referenceIds;
|
||||
}
|
||||
|
||||
public DmpReferenceQuery enrich(QueryFactory queryFactory) {
|
||||
DmpReferenceQuery query = queryFactory.query(DmpReferenceQuery.class);
|
||||
|
|
|
@ -569,7 +569,7 @@ public class DmpServiceImpl implements DmpService {
|
|||
data.getContacts().add(this.buildDmpContactEntity(contactPersist));
|
||||
}
|
||||
}
|
||||
if (persist.getDmpBlueprintValues() == null && !persist.getDmpBlueprintValues().isEmpty()){
|
||||
if (persist.getDmpBlueprintValues() != null && !persist.getDmpBlueprintValues().isEmpty()){
|
||||
data.setDmpBlueprintValues(new ArrayList<>());
|
||||
for (DmpBlueprintValuePersist fieldValuePersist: persist.getDmpBlueprintValues().values()) {
|
||||
if (!this.conventionService.isNullOrEmpty(fieldValuePersist.getFieldValue())) data.getDmpBlueprintValues().add(this.buildDmpBlueprintValueEntity(fieldValuePersist));
|
||||
|
@ -604,7 +604,7 @@ public class DmpServiceImpl implements DmpService {
|
|||
|
||||
private @NotNull List<DmpReferencePersist> buildDmpReferencePersists(DmpPropertiesPersist persist){
|
||||
List<DmpReferencePersist> dmpReferencePersists = new ArrayList<>();
|
||||
if (persist.getDmpBlueprintValues() == null && !persist.getDmpBlueprintValues().isEmpty()){
|
||||
if (persist.getDmpBlueprintValues() != null && !persist.getDmpBlueprintValues().isEmpty()){
|
||||
for (DmpBlueprintValuePersist fieldValuePersist: persist.getDmpBlueprintValues().values()) {
|
||||
if (this.conventionService.isNullOrEmpty(fieldValuePersist.getFieldValue()) && !this.conventionService.isListNullOrEmpty( fieldValuePersist.getReferences())) {
|
||||
for (ReferencePersist referencePersist : fieldValuePersist.getReferences()) {
|
||||
|
@ -636,7 +636,7 @@ public class DmpServiceImpl implements DmpService {
|
|||
|
||||
Map<UUID, DmpReferenceDataEntity> dmpReferenceDataEntityMap = new HashMap<>();
|
||||
for (DmpReferenceEntity dmpReferenceEntity : dmpReferences){
|
||||
dmpReferenceDataEntityMap.put(dmpReferenceEntity.getDmpId(), this.jsonHandlingService.fromJsonSafe(DmpReferenceDataEntity.class, dmpReferenceEntity.getData()));
|
||||
dmpReferenceDataEntityMap.put(dmpReferenceEntity.getId(), this.jsonHandlingService.fromJsonSafe(DmpReferenceDataEntity.class, dmpReferenceEntity.getData()));
|
||||
}
|
||||
|
||||
List<UUID> updatedCreatedIds = new ArrayList<>();
|
||||
|
@ -708,6 +708,7 @@ public class DmpServiceImpl implements DmpService {
|
|||
data.setId(UUID.randomUUID());
|
||||
data.setIsActive(IsActive.Active);
|
||||
data.setCreatedAt(Instant.now());
|
||||
data.setUpdatedAt(Instant.now());
|
||||
data.setDmpId(id);
|
||||
data.setSectionId(model.getSectionId());
|
||||
data.setDescriptionTemplateGroupId(model.getDescriptionTemplateGroupId());
|
||||
|
|
|
@ -9,7 +9,7 @@ storage:
|
|||
- type: Transformer
|
||||
basePath: ${TRANSFORMER_BASE_PATH}
|
||||
static-files:
|
||||
externalUrls: externalUrls/ExternalUrls.xml
|
||||
externalUrls: dmp-backend/web/src/main/resources/externalUrls/ExternalUrls.xml
|
||||
semantics: Semantics.json
|
||||
h2020Template: documents/h2020.docx
|
||||
h2020DescriptionTemplate: documents/h2020_dataset.docx
|
||||
|
|
|
@ -81,7 +81,7 @@ export interface DmpPersist extends BaseEntityPersist {
|
|||
}
|
||||
|
||||
export interface DmpPropertiesPersist {
|
||||
dmpBlueprintValues: DmpBlueprintValuePersist[];
|
||||
dmpBlueprintValues: Map<Guid, DmpBlueprintValuePersist>;
|
||||
contacts: DmpContactPersist[];
|
||||
}
|
||||
|
||||
|
|
|
@ -103,7 +103,7 @@ export class ReferenceService {
|
|||
lookup.project = {
|
||||
fields: [
|
||||
nameof<Reference>(x => x.id),
|
||||
nameof<Reference>(x => x.label)
|
||||
nameof<Reference>(x => x.label),
|
||||
]
|
||||
};
|
||||
if (types && types.length > 0) { lookup.types = types; }
|
||||
|
@ -120,7 +120,7 @@ export class ReferenceService {
|
|||
return {
|
||||
initialItems: (data?: any) => this.search(this.buildAutocompleteSearchLookup(type)).pipe(map(x => x)),
|
||||
filterFn: (searchQuery: string, data?: any) => this.search(this.buildAutocompleteSearchLookup(type, searchQuery)).pipe(map(x => x)),
|
||||
getSelectedItem: (selectedItem: any) => this.search(this.buildAutocompleteSearchLookup(type)).pipe(map(x => x[0])),
|
||||
getSelectedItem: (selectedItem: any) => this.query(this.buildAutocompleteSearchSelectedItemsLookup([type], null, null, null, [selectedItem])).pipe(map(x => x.items[0])),
|
||||
displayFn: (item: Reference) => item.label,
|
||||
titleFn: (item: Reference) => item.label,
|
||||
valueAssign: (item: Reference) => item.id,
|
||||
|
@ -131,7 +131,7 @@ export class ReferenceService {
|
|||
return {
|
||||
initialItems: (excludedItems: any[], data?: any) => this.search(this.buildAutocompleteSearchLookup(type, null)).pipe(map(x => x)),
|
||||
filterFn: (searchQuery: string, excludedItems: any[]) => this.search(this.buildAutocompleteSearchLookup(type, searchQuery)).pipe(map(x => x)),
|
||||
getSelectedItems: (selectedItems: any[]) => this.search(this.buildAutocompleteSearchLookup(type, null)).pipe(map(x => x)),
|
||||
getSelectedItems: (selectedItems: any[]) => this.query(this.buildAutocompleteSearchSelectedItemsLookup([type], null, null, null, selectedItems?.map(x => x.id))).pipe(map(x => x.items)),
|
||||
displayFn: (item: Reference) => item.label,
|
||||
titleFn: (item: Reference) => item.label,
|
||||
valueAssign: (item: Reference) => item,
|
||||
|
@ -162,6 +162,34 @@ export class ReferenceService {
|
|||
return lookup;
|
||||
}
|
||||
|
||||
private buildAutocompleteSearchSelectedItemsLookup(types?: ReferenceType[], sourceTypes?: ReferenceSourceType[], like?: string, excludedIds?: Guid[], ids?: Guid[]): ReferenceLookup {
|
||||
const lookup: ReferenceLookup = new ReferenceLookup();
|
||||
lookup.page = { size: 100, offset: 0 };
|
||||
if (excludedIds && excludedIds.length > 0) { lookup.excludedIds = excludedIds; }
|
||||
if (ids && ids.length > 0) { lookup.ids = ids; }
|
||||
lookup.isActive = [IsActive.Active];
|
||||
lookup.project = {
|
||||
fields: [
|
||||
nameof<Reference>(x => x.id),
|
||||
nameof<Reference>(x => x.label),
|
||||
nameof<Reference>(x => x.type),
|
||||
nameof<Reference>(x => x.description),
|
||||
[nameof<Reference>(x => x.definition), nameof<Definition>(x => x.fields), nameof<Field>(x => x.code)].join('.'),
|
||||
[nameof<Reference>(x => x.definition), nameof<Definition>(x => x.fields), nameof<Field>(x => x.dataType)].join('.'),
|
||||
[nameof<Reference>(x => x.definition), nameof<Definition>(x => x.fields), nameof<Field>(x => x.value)].join('.'),
|
||||
nameof<Reference>(x => x.reference),
|
||||
nameof<Reference>(x => x.abbreviation),
|
||||
nameof<Reference>(x => x.source),
|
||||
nameof<Reference>(x => x.sourceType),
|
||||
]
|
||||
};
|
||||
if (types && types.length > 0) { lookup.types = types; }
|
||||
if (sourceTypes && sourceTypes.length > 0) { lookup.sourceTypes = sourceTypes; }
|
||||
lookup.order = { items: [nameof<Reference>(x => x.label)] };
|
||||
if (like) { lookup.like = this.filterService.transformLike(like); }
|
||||
return lookup;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
//
|
||||
|
|
|
@ -212,15 +212,17 @@ export class DmpEditorComponent extends BaseEditor<DmpEditorModel, Dmp> implemen
|
|||
//Transform to persist
|
||||
//Transform descriptionTemplates
|
||||
formData.descriptionTemplates = [];
|
||||
for (const fieldId in (this.formGroup.get('descriptionTemplates') as UntypedFormGroup).controls) {
|
||||
formData.descriptionTemplates.push(this.formGroup.get('descriptionTemplates').get(fieldId).value);
|
||||
for (const sectionId in (this.formGroup.get('descriptionTemplates') as UntypedFormGroup).controls) {
|
||||
formData.descriptionTemplates.push(
|
||||
...(this.formGroup.get('descriptionTemplates').get(sectionId).value as Guid[]).map(x => { return { sectionId: Guid.parse(sectionId), descriptionTemplateGroupId: x } })
|
||||
);
|
||||
}
|
||||
|
||||
//Transform properties
|
||||
formData.properties.dmpBlueprintValues = [];
|
||||
for (const fieldId in (this.formGroup.get('properties').get('dmpBlueprintValues') as UntypedFormGroup).controls) {
|
||||
formData.properties.dmpBlueprintValues.push(this.formGroup.get('properties').get('dmpBlueprintValues').get(fieldId).value);
|
||||
}
|
||||
// formData.properties.dmpBlueprintValues = [];
|
||||
// for (const fieldId in (this.formGroup.get('properties').get('dmpBlueprintValues') as UntypedFormGroup).controls) {
|
||||
// formData.properties.dmpBlueprintValues.push(this.formGroup.get('properties').get('dmpBlueprintValues').get(fieldId).value);
|
||||
// }
|
||||
|
||||
|
||||
this.dmpService.persist(formData)
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import { FormControl, UntypedFormBuilder, UntypedFormGroup, Validators } from "@angular/forms";
|
||||
import { DmpAccessType } from "@app/core/common/enum/dmp-access-type";
|
||||
import { DmpStatus } from "@app/core/common/enum/dmp-status";
|
||||
import { IsActive } from "@app/core/common/enum/is-active.enum";
|
||||
import { DmpBlueprint } from "@app/core/model/dmp-blueprint/dmp-blueprint";
|
||||
import { Dmp, DmpBlueprintValue, DmpBlueprintValuePersist, DmpContact, DmpContactPersist, DmpDescriptionTemplate, DmpDescriptionTemplatePersist, DmpPersist, DmpProperties, DmpPropertiesPersist, DmpReferenceDataPersist, DmpReferencePersist } from "@app/core/model/dmp/dmp";
|
||||
import { DmpReference } from "@app/core/model/dmp/dmp-reference";
|
||||
|
@ -32,7 +33,7 @@ export class DmpEditorModel extends BaseEditorModel implements DmpPersist {
|
|||
super.fromModel(item);
|
||||
this.label = item.label;
|
||||
this.status = item.status;
|
||||
this.properties = new DmpPropertiesEditorModel().fromModel(item.properties, item.dmpReferences, item.blueprint);
|
||||
this.properties = new DmpPropertiesEditorModel().fromModel(item.properties, item.dmpReferences.filter(x => x.isActive === IsActive.Active), item.blueprint);
|
||||
this.description = item.description;
|
||||
this.language = item.language;
|
||||
this.blueprint = item.blueprint?.id;
|
||||
|
@ -122,7 +123,7 @@ export class DmpEditorModel extends BaseEditorModel implements DmpPersist {
|
|||
}
|
||||
|
||||
export class DmpPropertiesEditorModel implements DmpPropertiesPersist {
|
||||
dmpBlueprintValues: DmpBlueprintValueEditorModel[] = [];
|
||||
dmpBlueprintValues: Map<Guid, DmpBlueprintValueEditorModel> = new Map<Guid, DmpBlueprintValueEditorModel>;
|
||||
contacts: DmpContactEditorModel[] = [];
|
||||
|
||||
protected formBuilder: UntypedFormBuilder = new UntypedFormBuilder();
|
||||
|
@ -133,9 +134,10 @@ export class DmpPropertiesEditorModel implements DmpPropertiesPersist {
|
|||
|
||||
fromModel(item: DmpProperties, dmpReferences: DmpReference[], dmpBlueprint: DmpBlueprint): DmpPropertiesEditorModel {
|
||||
|
||||
|
||||
dmpBlueprint.definition.sections.forEach(section => {
|
||||
section.fields.forEach(field => {
|
||||
this.dmpBlueprintValues.push(new DmpBlueprintValueEditorModel().fromModel(
|
||||
this.dmpBlueprintValues.set(field.id, new DmpBlueprintValueEditorModel().fromModel(
|
||||
{
|
||||
fieldId: field.id,
|
||||
fieldValue: item?.dmpBlueprintValues?.find(x => x.fieldId == field.id)?.fieldValue,
|
||||
|
@ -151,7 +153,7 @@ export class DmpPropertiesEditorModel implements DmpPropertiesPersist {
|
|||
context?: ValidationContext,
|
||||
disabled?: boolean,
|
||||
rootPath?: string
|
||||
}): UntypedFormGroup {
|
||||
}, dmpReferences?: DmpReference[], dmpBlueprint?: DmpBlueprint): UntypedFormGroup {
|
||||
let { context = null, disabled = false, rootPath } = params ?? {}
|
||||
if (context == null) {
|
||||
context = DmpPropertiesEditorModel.createValidationContext({
|
||||
|
@ -175,9 +177,8 @@ export class DmpPropertiesEditorModel implements DmpPropertiesPersist {
|
|||
|
||||
|
||||
const dmpBlueprintValuesFormGroup = this.formBuilder.group({});
|
||||
(this.dmpBlueprintValues ?? []).filter(x => x?.fieldId).map(
|
||||
(item, index) => dmpBlueprintValuesFormGroup.addControl(item.fieldId.toString(), item.buildForm({
|
||||
rootPath: `dmpBlueprintValues[${index}].`
|
||||
this.dmpBlueprintValues.forEach((value, key) => dmpBlueprintValuesFormGroup.addControl(key.toString(), value.buildForm({
|
||||
rootPath: `dmpBlueprintValues[${key}].`
|
||||
})), context.getValidation('dmpBlueprintValues')
|
||||
)
|
||||
formGroup.addControl('dmpBlueprintValues', dmpBlueprintValuesFormGroup);
|
||||
|
|
|
@ -57,6 +57,7 @@ export class DmpEditorResolver extends BaseEditorResolver {
|
|||
// [nameof<Dmp>(x => x.dmpUsers), nameof<DmpUser>(x => x.user.name)].join('.'),
|
||||
// [nameof<Dmp>(x => x.dmpUsers), nameof<DmpUser>(x => x.role)].join('.'),
|
||||
[nameof<Dmp>(x => x.dmpReferences), nameof<DmpReference>(x => x.id)].join('.'),
|
||||
[nameof<Dmp>(x => x.dmpReferences), nameof<DmpReference>(x => x.isActive)].join('.'),
|
||||
[nameof<Dmp>(x => x.dmpReferences), nameof<DmpReference>(x => x.data), nameof<DmpReferenceData>(x => x.blueprintFieldId)].join('.'),
|
||||
[nameof<Dmp>(x => x.dmpReferences), nameof<DmpReference>(x => x.reference), nameof<Reference>(x => x.id)].join('.'),
|
||||
[nameof<Dmp>(x => x.dmpReferences), nameof<DmpReference>(x => x.reference), nameof<Reference>(x => x.label)].join('.'),
|
||||
|
|
Loading…
Reference in New Issue