import fixes

This commit is contained in:
CITE\amentis 2024-08-01 17:35:17 +03:00
parent 8ef9a344ef
commit 6bc85abbbf
3 changed files with 19 additions and 4 deletions

View File

@ -1931,6 +1931,13 @@ public class PlanServiceImpl implements PlanService {
persist.setDescriptionTemplates(this.xmlPlanDescriptionTemplatesToPersist(planXml)); //TODO maybe we should create templates if not exists persist.setDescriptionTemplates(this.xmlPlanDescriptionTemplatesToPersist(planXml)); //TODO maybe we should create templates if not exists
persist.setBlueprint(this.xmlPlanBlueprintToPersist(planXml)); persist.setBlueprint(this.xmlPlanBlueprintToPersist(planXml));
org.opencdmp.commons.types.planblueprint.DefinitionEntity definition = null;
if (persist.getBlueprint() != null) {
PlanBlueprintEntity planBlueprintEntity = this.queryFactory.query(PlanBlueprintQuery.class).disableTracking().ids(persist.getBlueprint()).first();
definition = this.xmlHandlingService.fromXmlSafe(org.opencdmp.commons.types.planblueprint.DefinitionEntity.class, planBlueprintEntity.getDefinition());
if (definition == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{persist.getBlueprint(), org.opencdmp.commons.types.planblueprint.DefinitionEntity.class.getSimpleName()}, LocaleContextHolder.getLocale()));
}
this.validatorFactory.validator(PlanPersist.PlanPersistValidator.class).validateForce(persist); this.validatorFactory.validator(PlanPersist.PlanPersistValidator.class).validateForce(persist);
Plan plan = this.persist(persist, BaseFieldSet.build(fields, Plan._id, Plan._hash)); Plan plan = this.persist(persist, BaseFieldSet.build(fields, Plan._id, Plan._hash));
@ -1938,9 +1945,13 @@ public class PlanServiceImpl implements PlanService {
if (!this.conventionService.isListNullOrEmpty(planXml.getDescriptions())){ if (!this.conventionService.isListNullOrEmpty(planXml.getDescriptions())){
for (DescriptionImportExport description: planXml.getDescriptions()){ for (DescriptionImportExport description: planXml.getDescriptions()){
if (definition != null && description.getSectionId() != null && !this.conventionService.isListNullOrEmpty(definition.getSections())) {
if (definition.getSections().stream().filter(x -> x.getId().equals(description.getSectionId()) && x.getHasTemplates()).findFirst().orElse(null) != null){
this.descriptionService.importXml(description, plan.getId(), fields != null ? fields.extractPrefixed(this.conventionService.asPrefix(Plan._description)) : null); this.descriptionService.importXml(description, plan.getId(), fields != null ? fields.extractPrefixed(this.conventionService.asPrefix(Plan._description)) : null);
} }
} }
}
}
this.accountingService.increase(UsageLimitTargetMetric.IMPORT_PLAN_XML_EXECUTION_COUNT.getValue()); this.accountingService.increase(UsageLimitTargetMetric.IMPORT_PLAN_XML_EXECUTION_COUNT.getValue());

View File

@ -220,7 +220,7 @@ export class DescriptionEditorComponent extends BaseEditor<DescriptionEditorMode
this.initialTemplateId = data?.descriptionTemplate?.id?.toString(); this.initialTemplateId = data?.descriptionTemplate?.id?.toString();
if (data && data.planDescriptionTemplate?.sectionId && data.plan?.blueprint?.definition?.sections?.length > 0 && data.plan?.descriptions?.length > 0) { if (data && data.planDescriptionTemplate?.sectionId && data.plan?.blueprint?.definition?.sections?.length > 0 && data.plan?.descriptions?.length > 0) {
const section = data.plan?.blueprint?.definition?.sections.find(x => x.id == data.planDescriptionTemplate?.sectionId); const section = data.plan?.blueprint?.definition?.sections.find(x => x.id == data.planDescriptionTemplate?.sectionId);
if (section.hasTemplates) { if (section?.hasTemplates) {
const notAvailableDescriptionTemplates = this.calculateMultiplicityRejectedPlanDescriptionTemplates(section, data.plan.descriptions.filter(x => x.isActive == IsActive.Active)); const notAvailableDescriptionTemplates = this.calculateMultiplicityRejectedPlanDescriptionTemplates(section, data.plan.descriptions.filter(x => x.isActive == IsActive.Active));
this.item.plan.planDescriptionTemplates = data.plan.planDescriptionTemplates.filter(x => !notAvailableDescriptionTemplates.map(y => y.id).includes(x.id)) this.item.plan.planDescriptionTemplates = data.plan.planDescriptionTemplates.filter(x => !notAvailableDescriptionTemplates.map(y => y.id).includes(x.id))
} }

View File

@ -380,7 +380,11 @@ export class DescriptionPropertyDefinitionFieldSetItemEditorModel implements Des
if (item.fields instanceof Map) if (item.fields instanceof Map)
new Map(item.fields)?.forEach((value, key) => this.fields.set(key, new DescriptionFieldEditorModel(this.validationErrorModel).fromModel(value, item.ordinal, definitionFieldSet?.fields?.find(x => x.id == key), descriptionReferences))); new Map(item.fields)?.forEach((value, key) => this.fields.set(key, new DescriptionFieldEditorModel(this.validationErrorModel).fromModel(value, item.ordinal, definitionFieldSet?.fields?.find(x => x.id == key), descriptionReferences)));
else else
Object.keys(item.fields)?.forEach((key) => this.fields.set(key, new DescriptionFieldEditorModel(this.validationErrorModel).fromModel(item.fields[key], item.ordinal, definitionFieldSet?.fields?.find(x => x.id == key), descriptionReferences))); Object.keys(item.fields)?.forEach((key) => {
if ( definitionFieldSet?.fields?.find(x => x.id == key) != null){
this.fields.set(key, new DescriptionFieldEditorModel(this.validationErrorModel).fromModel(item.fields[key], item.ordinal, definitionFieldSet?.fields?.find(x => x.id == key), descriptionReferences))
}
});
} }
} }
return this; return this;
@ -509,7 +513,7 @@ export class DescriptionFieldEditorModel implements DescriptionFieldPersist {
sourceType: x.reference.sourceType sourceType: x.reference.sourceType
} }
}); });
if (descriptionTemplateField.data.multipleSelect == true) { if (descriptionTemplateField?.data?.multipleSelect == true) {
this.references = references; this.references = references;
} else { } else {
if (references?.length == 1) this.reference = references[0]; if (references?.length == 1) this.reference = references[0];