handle json import for ignore descriptions

This commit is contained in:
CITE\amentis 2024-08-02 10:06:49 +03:00
parent 6bc85abbbf
commit e843a2487f
1 changed files with 12 additions and 1 deletions

View File

@ -2216,15 +2216,26 @@ public class PlanServiceImpl implements PlanService {
persist.setDescriptionTemplates(this.commonModelPlanDescriptionTemplatesToPersist(model)); //TODO maybe we should create templates if not exists persist.setDescriptionTemplates(this.commonModelPlanDescriptionTemplatesToPersist(model)); //TODO maybe we should create templates if not exists
persist.setProperties(this.commonModelPlanPropertiesToPersist(model)); persist.setProperties(this.commonModelPlanPropertiesToPersist(model));
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));
if (plan == null) throw new MyApplicationException("Error creating plan"); if (plan == null) throw new MyApplicationException("Error creating plan");
if (!this.conventionService.isListNullOrEmpty(model.getDescriptions())){ if (!this.conventionService.isListNullOrEmpty(model.getDescriptions())){
for (DescriptionModel description: model.getDescriptions()){ for (DescriptionModel description: model.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.importCommonModel(description, plan.getId(), fields != null ? fields.extractPrefixed(this.conventionService.asPrefix(Plan._description)) : null); this.descriptionService.importCommonModel(description, plan.getId(), fields != null ? fields.extractPrefixed(this.conventionService.asPrefix(Plan._description)) : null);
} }
} }
}
}
return plan; return plan;