handle json import for ignore descriptions
This commit is contained in:
parent
6bc85abbbf
commit
e843a2487f
|
@ -2216,15 +2216,26 @@ public class PlanServiceImpl implements PlanService {
|
|||
persist.setDescriptionTemplates(this.commonModelPlanDescriptionTemplatesToPersist(model)); //TODO maybe we should create templates if not exists
|
||||
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);
|
||||
Plan plan = this.persist(persist, BaseFieldSet.build(fields, Plan._id, Plan._hash));
|
||||
if (plan == null) throw new MyApplicationException("Error creating plan");
|
||||
|
||||
if (!this.conventionService.isListNullOrEmpty(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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return plan;
|
||||
|
|
Loading…
Reference in New Issue