001// --------------------------------------------------------------------------------
002// Copyright 2002-2026 Echo Three, LLC
003//
004// Licensed under the Apache License, Version 2.0 (the "License");
005// you may not use this file except in compliance with the License.
006// You may obtain a copy of the License at
007//
008//     http://www.apache.org/licenses/LICENSE-2.0
009//
010// Unless required by applicable law or agreed to in writing, software
011// distributed under the License is distributed on an "AS IS" BASIS,
012// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013// See the License for the specific language governing permissions and
014// limitations under the License.
015// --------------------------------------------------------------------------------
016
017package com.echothree.control.user.core.server.command;
018
019import com.echothree.control.user.core.common.edit.EntityAttributeEdit;
020import com.echothree.control.user.core.common.form.CreateEntityAttributeForm;
021import com.echothree.control.user.core.common.result.CoreResultFactory;
022import com.echothree.model.control.core.common.EntityAttributeTypes;
023import com.echothree.model.control.core.server.logic.EntityAttributeLogic;
024import com.echothree.model.control.core.server.logic.EntityTypeLogic;
025import com.echothree.model.control.party.common.PartyTypes;
026import com.echothree.model.control.security.common.SecurityRoleGroups;
027import com.echothree.model.control.security.common.SecurityRoles;
028import com.echothree.model.control.sequence.common.SequenceTypes;
029import com.echothree.model.control.sequence.server.control.SequenceControl;
030import com.echothree.model.control.sequence.server.logic.SequenceTypeLogic;
031import com.echothree.model.control.uom.server.logic.UnitOfMeasureTypeLogic;
032import com.echothree.model.control.workflow.server.logic.WorkflowLogic;
033import com.echothree.model.data.core.server.entity.EntityAttribute;
034import com.echothree.model.data.core.server.entity.EntityAttributeType;
035import com.echothree.model.data.sequence.server.entity.Sequence;
036import com.echothree.model.data.uom.server.entity.UnitOfMeasureType;
037import com.echothree.model.data.user.common.pk.UserVisitPK;
038import com.echothree.model.data.workflow.server.entity.Workflow;
039import com.echothree.util.common.command.BaseResult;
040import com.echothree.util.common.form.ValidationResult;
041import com.echothree.util.common.message.ExecutionErrors;
042import com.echothree.util.common.validation.FieldDefinition;
043import com.echothree.util.common.validation.FieldType;
044import com.echothree.util.server.control.BaseSimpleCommand;
045import com.echothree.util.server.control.CommandSecurityDefinition;
046import com.echothree.util.server.control.PartyTypeDefinition;
047import com.echothree.util.server.control.SecurityRoleDefinition;
048import com.echothree.util.server.validation.Validator;
049import java.util.List;
050import javax.enterprise.context.Dependent;
051import javax.inject.Inject;
052
053@Dependent
054public class CreateEntityAttributeCommand
055        extends BaseSimpleCommand<CreateEntityAttributeForm> {
056    
057    private final static CommandSecurityDefinition COMMAND_SECURITY_DEFINITION;
058    private final static List<FieldDefinition> FORM_FIELD_DEFINITIONS;
059    
060    private final static List<FieldDefinition> BLOB_FORM_FIELD_DEFINITIONS;
061    private final static List<FieldDefinition> STRING_FORM_FIELD_DEFINITIONS;
062    private final static List<FieldDefinition> INTEGER_FORM_FIELD_DEFINITIONS;
063    private final static List<FieldDefinition> LONG_FORM_FIELD_DEFINITIONS;
064    private final static List<FieldDefinition> LISTITEM_FORM_FIELD_DEFINITIONS;
065    private final static List<FieldDefinition> MULTIPLELISTITEM_FORM_FIELD_DEFINITIONS;
066    private final static List<FieldDefinition> WORKFLOW_FORM_FIELD_DEFINITIONS;
067    private final static List<FieldDefinition> OTHER_FORM_FIELD_DEFINITIONS;
068    
069    static {
070        COMMAND_SECURITY_DEFINITION = new CommandSecurityDefinition(List.of(
071                new PartyTypeDefinition(PartyTypes.UTILITY.name(), null),
072                new PartyTypeDefinition(PartyTypes.EMPLOYEE.name(), List.of(
073                        new SecurityRoleDefinition(SecurityRoleGroups.EntityAttribute.name(), SecurityRoles.Create.name())
074                ))
075        ));
076        
077        FORM_FIELD_DEFINITIONS = List.of(
078                new FieldDefinition("EntityRef", FieldType.ENTITY_REF, false, null, null),
079                new FieldDefinition("Uuid", FieldType.UUID, false, null, null),
080                new FieldDefinition("ComponentVendorName", FieldType.ENTITY_NAME, false, null, null),
081                new FieldDefinition("EntityTypeName", FieldType.ENTITY_TYPE_NAME, false, null, null),
082                new FieldDefinition("EntityAttributeName", FieldType.ENTITY_NAME, false, null, null),
083                new FieldDefinition("EntityAttributeTypeName", FieldType.ENTITY_NAME, true, null, null),
084                new FieldDefinition("TrackRevisions", FieldType.BOOLEAN, true, null, null),
085                new FieldDefinition("SortOrder", FieldType.SIGNED_INTEGER, true, null, null),
086                new FieldDefinition("Description", FieldType.STRING, false, 1L, 132L)
087        );
088        
089        BLOB_FORM_FIELD_DEFINITIONS = List.of(
090                new FieldDefinition("CheckContentWebAddress", FieldType.BOOLEAN, true, null, null),
091                new FieldDefinition("ValidationPattern", FieldType.NULL, false, null, null),
092                new FieldDefinition("UpperRangeIntegerValue", FieldType.SIGNED_INTEGER, false, null, null),
093                new FieldDefinition("UpperLimitIntegerValue", FieldType.SIGNED_INTEGER, false, null, null),
094                new FieldDefinition("LowerLimitIntegerValue", FieldType.SIGNED_INTEGER, false, null, null),
095                new FieldDefinition("LowerRangeIntegerValue", FieldType.SIGNED_INTEGER, false, null, null),
096                new FieldDefinition("UpperRangeLongValue", FieldType.SIGNED_LONG, false, null, null),
097                new FieldDefinition("UpperLimitLongValue", FieldType.SIGNED_LONG, false, null, null),
098                new FieldDefinition("LowerLimitLongValue", FieldType.SIGNED_LONG, false, null, null),
099                new FieldDefinition("LowerRangeLongValue", FieldType.SIGNED_LONG, false, null, null),
100                new FieldDefinition("UnitOfMeasureKindName", FieldType.ENTITY_NAME, false, null, null),
101                new FieldDefinition("UnitOfMeasureTypeName", FieldType.ENTITY_NAME, false, null, null),
102                new FieldDefinition("EntityListItemSequenceName", FieldType.ENTITY_NAME, false, null, null),
103                new FieldDefinition("WorkflowName", FieldType.ENTITY_NAME, false, null, null)
104        );
105        
106        STRING_FORM_FIELD_DEFINITIONS = List.of(
107                new FieldDefinition("CheckContentWebAddress", FieldType.NULL, false, null, null),
108                new FieldDefinition("ValidationPattern", FieldType.REGULAR_EXPRESSION, false, null, null),
109                new FieldDefinition("UpperRangeIntegerValue", FieldType.NULL, false, null, null),
110                new FieldDefinition("UpperLimitIntegerValue", FieldType.NULL, false, null, null),
111                new FieldDefinition("LowerLimitIntegerValue", FieldType.NULL, false, null, null),
112                new FieldDefinition("LowerRangeIntegerValue", FieldType.NULL, false, null, null),
113                new FieldDefinition("UpperRangeLongValue", FieldType.NULL, false, null, null),
114                new FieldDefinition("UpperLimitLongValue", FieldType.NULL, false, null, null),
115                new FieldDefinition("LowerLimitLongValue", FieldType.NULL, false, null, null),
116                new FieldDefinition("LowerRangeLongValue", FieldType.NULL, false, null, null),
117                new FieldDefinition("UnitOfMeasureKindName", FieldType.NULL, false, null, null),
118                new FieldDefinition("UnitOfMeasureTypeName", FieldType.NULL, false, null, null),
119                new FieldDefinition("EntityListItemSequenceName", FieldType.NULL, false, null, null),
120                new FieldDefinition("WorkflowName", FieldType.ENTITY_NAME, false, null, null)
121        );
122        
123        INTEGER_FORM_FIELD_DEFINITIONS = List.of(
124                new FieldDefinition("CheckContentWebAddress", FieldType.NULL, false, null, null),
125                new FieldDefinition("ValidationPattern", FieldType.NULL, false, null, null),
126                new FieldDefinition("UpperRangeIntegerValue", FieldType.SIGNED_INTEGER, false, null, null),
127                new FieldDefinition("UpperLimitIntegerValue", FieldType.SIGNED_INTEGER, false, null, null),
128                new FieldDefinition("LowerLimitIntegerValue", FieldType.SIGNED_INTEGER, false, null, null),
129                new FieldDefinition("LowerRangeIntegerValue", FieldType.SIGNED_INTEGER, false, null, null),
130                new FieldDefinition("UpperRangeLongValue", FieldType.NULL, false, null, null),
131                new FieldDefinition("UpperLimitLongValue", FieldType.NULL, false, null, null),
132                new FieldDefinition("LowerLimitLongValue", FieldType.NULL, false, null, null),
133                new FieldDefinition("LowerRangeLongValue", FieldType.NULL, false, null, null),
134                new FieldDefinition("UnitOfMeasureKindName", FieldType.ENTITY_NAME, false, null, null),
135                new FieldDefinition("UnitOfMeasureTypeName", FieldType.ENTITY_NAME, false, null, null),
136                new FieldDefinition("EntityListItemSequenceName", FieldType.NULL, false, null, null),
137                new FieldDefinition("WorkflowName", FieldType.ENTITY_NAME, false, null, null)
138        );
139        
140        LONG_FORM_FIELD_DEFINITIONS = List.of(
141                new FieldDefinition("CheckContentWebAddress", FieldType.NULL, false, null, null),
142                new FieldDefinition("ValidationPattern", FieldType.NULL, false, null, null),
143                new FieldDefinition("UpperRangeIntegerValue", FieldType.NULL, false, null, null),
144                new FieldDefinition("UpperLimitIntegerValue", FieldType.NULL, false, null, null),
145                new FieldDefinition("LowerLimitIntegerValue", FieldType.NULL, false, null, null),
146                new FieldDefinition("LowerRangeIntegerValue", FieldType.NULL, false, null, null),
147                new FieldDefinition("UpperRangeLongValue", FieldType.SIGNED_LONG, false, null, null),
148                new FieldDefinition("UpperLimitLongValue", FieldType.SIGNED_LONG, false, null, null),
149                new FieldDefinition("LowerLimitLongValue", FieldType.SIGNED_LONG, false, null, null),
150                new FieldDefinition("LowerRangeLongValue", FieldType.SIGNED_LONG, false, null, null),
151                new FieldDefinition("UnitOfMeasureKindName", FieldType.ENTITY_NAME, false, null, null),
152                new FieldDefinition("UnitOfMeasureTypeName", FieldType.ENTITY_NAME, false, null, null),
153                new FieldDefinition("EntityListItemSequenceName", FieldType.NULL, false, null, null),
154                new FieldDefinition("WorkflowName", FieldType.ENTITY_NAME, false, null, null)
155        );
156        
157        LISTITEM_FORM_FIELD_DEFINITIONS = List.of(
158                new FieldDefinition("CheckContentWebAddress", FieldType.NULL, false, null, null),
159                new FieldDefinition("ValidationPattern", FieldType.NULL, false, null, null),
160                new FieldDefinition("UpperRangeIntegerValue", FieldType.NULL, false, null, null),
161                new FieldDefinition("UpperLimitIntegerValue", FieldType.NULL, false, null, null),
162                new FieldDefinition("LowerLimitIntegerValue", FieldType.NULL, false, null, null),
163                new FieldDefinition("LowerRangeIntegerValue", FieldType.NULL, false, null, null),
164                new FieldDefinition("UpperRangeLongValue", FieldType.NULL, false, null, null),
165                new FieldDefinition("UpperLimitLongValue", FieldType.NULL, false, null, null),
166                new FieldDefinition("LowerLimitLongValue", FieldType.NULL, false, null, null),
167                new FieldDefinition("LowerRangeLongValue", FieldType.NULL, false, null, null),
168                new FieldDefinition("UnitOfMeasureKindName", FieldType.NULL, false, null, null),
169                new FieldDefinition("UnitOfMeasureTypeName", FieldType.NULL, false, null, null),
170                new FieldDefinition("EntityListItemSequenceName", FieldType.ENTITY_NAME, false, null, null),
171                new FieldDefinition("WorkflowName", FieldType.ENTITY_NAME, false, null, null)
172        );
173        
174        MULTIPLELISTITEM_FORM_FIELD_DEFINITIONS = List.of(
175                new FieldDefinition("CheckContentWebAddress", FieldType.NULL, false, null, null),
176                new FieldDefinition("ValidationPattern", FieldType.NULL, false, null, null),
177                new FieldDefinition("UpperRangeIntegerValue", FieldType.NULL, false, null, null),
178                new FieldDefinition("UpperLimitIntegerValue", FieldType.NULL, false, null, null),
179                new FieldDefinition("LowerLimitIntegerValue", FieldType.NULL, false, null, null),
180                new FieldDefinition("LowerRangeIntegerValue", FieldType.NULL, false, null, null),
181                new FieldDefinition("UpperRangeLongValue", FieldType.NULL, false, null, null),
182                new FieldDefinition("UpperLimitLongValue", FieldType.NULL, false, null, null),
183                new FieldDefinition("LowerLimitLongValue", FieldType.NULL, false, null, null),
184                new FieldDefinition("LowerRangeLongValue", FieldType.NULL, false, null, null),
185                new FieldDefinition("UnitOfMeasureKindName", FieldType.NULL, false, null, null),
186                new FieldDefinition("UnitOfMeasureTypeName", FieldType.NULL, false, null, null),
187                new FieldDefinition("EntityListItemSequenceName", FieldType.ENTITY_NAME, false, null, null),
188                new FieldDefinition("WorkflowName", FieldType.ENTITY_NAME, false, null, null)
189        );
190
191        WORKFLOW_FORM_FIELD_DEFINITIONS = List.of(
192                new FieldDefinition("CheckContentWebAddress", FieldType.NULL, false, null, null),
193                new FieldDefinition("ValidationPattern", FieldType.NULL, false, null, null),
194                new FieldDefinition("UpperRangeIntegerValue", FieldType.NULL, false, null, null),
195                new FieldDefinition("UpperLimitIntegerValue", FieldType.NULL, false, null, null),
196                new FieldDefinition("LowerLimitIntegerValue", FieldType.NULL, false, null, null),
197                new FieldDefinition("LowerRangeIntegerValue", FieldType.NULL, false, null, null),
198                new FieldDefinition("UpperRangeLongValue", FieldType.NULL, false, null, null),
199                new FieldDefinition("UpperLimitLongValue", FieldType.NULL, false, null, null),
200                new FieldDefinition("LowerLimitLongValue", FieldType.NULL, false, null, null),
201                new FieldDefinition("LowerRangeLongValue", FieldType.NULL, false, null, null),
202                new FieldDefinition("UnitOfMeasureKindName", FieldType.NULL, false, null, null),
203                new FieldDefinition("UnitOfMeasureTypeName", FieldType.NULL, false, null, null),
204                new FieldDefinition("EntityListItemSequenceName", FieldType.NULL, false, null, null),
205                new FieldDefinition("WorkflowName", FieldType.ENTITY_NAME, true, null, null)
206        );
207
208        OTHER_FORM_FIELD_DEFINITIONS = List.of(
209                new FieldDefinition("CheckContentWebAddress", FieldType.NULL, false, null, null),
210                new FieldDefinition("ValidationPattern", FieldType.NULL, false, null, null),
211                new FieldDefinition("UpperRangeIntegerValue", FieldType.NULL, false, null, null),
212                new FieldDefinition("UpperLimitIntegerValue", FieldType.NULL, false, null, null),
213                new FieldDefinition("LowerLimitIntegerValue", FieldType.NULL, false, null, null),
214                new FieldDefinition("LowerRangeIntegerValue", FieldType.NULL, false, null, null),
215                new FieldDefinition("UpperRangeLongValue", FieldType.NULL, false, null, null),
216                new FieldDefinition("UpperLimitLongValue", FieldType.NULL, false, null, null),
217                new FieldDefinition("LowerLimitLongValue", FieldType.NULL, false, null, null),
218                new FieldDefinition("LowerRangeLongValue", FieldType.NULL, false, null, null),
219                new FieldDefinition("UnitOfMeasureKindName", FieldType.NULL, false, null, null),
220                new FieldDefinition("UnitOfMeasureTypeName", FieldType.NULL, false, null, null),
221                new FieldDefinition("EntityListItemSequenceName", FieldType.NULL, false, null, null),
222                new FieldDefinition("WorkflowName", FieldType.ENTITY_NAME, false, null, null)
223        );
224    }
225
226    @Inject
227    SequenceControl sequenceControl;
228
229    @Inject
230    EntityAttributeLogic entityAttributeLogic;
231
232    @Inject
233    EntityTypeLogic entityTypeLogic;
234
235    @Inject
236    SequenceTypeLogic sequenceTypeLogic;
237
238    @Inject
239    UnitOfMeasureTypeLogic unitOfMeasureTypeLogic;
240
241    @Inject
242    WorkflowLogic workflowLogic;
243
244    
245    /** Creates a new instance of CreateEntityAttributeCommand */
246    public CreateEntityAttributeCommand() {
247        super(COMMAND_SECURITY_DEFINITION, FORM_FIELD_DEFINITIONS, false);
248    }
249    
250    public static ValidationResult AdditionalEntityAttributeValidation(EntityAttributeEdit edit, Validator validator,
251            EntityAttributeType entityAttributeType) {
252        return switch(EntityAttributeTypes.valueOf(entityAttributeType.getEntityAttributeTypeName())) {
253            case BLOB -> validator.validate(edit, BLOB_FORM_FIELD_DEFINITIONS);
254            case STRING -> validator.validate(edit, STRING_FORM_FIELD_DEFINITIONS);
255            case INTEGER -> validator.validate(edit, INTEGER_FORM_FIELD_DEFINITIONS);
256            case LONG -> validator.validate(edit, LONG_FORM_FIELD_DEFINITIONS);
257            case LISTITEM -> validator.validate(edit, LISTITEM_FORM_FIELD_DEFINITIONS);
258            case MULTIPLELISTITEM -> validator.validate(edit, MULTIPLELISTITEM_FORM_FIELD_DEFINITIONS);
259            case WORKFLOW -> validator.validate(edit, WORKFLOW_FORM_FIELD_DEFINITIONS);
260            default -> validator.validate(edit, OTHER_FORM_FIELD_DEFINITIONS);
261        };
262    }
263    
264    @Override
265    protected ValidationResult validate() {
266        var validator = new Validator(this);
267        var validationResult = validator.validate(form, FORM_FIELD_DEFINITIONS);
268        
269        if(!validationResult.getHasErrors()) {
270            var entityAttributeType = entityAttributeLogic.getEntityAttributeTypeByName(this, form.getEntityAttributeTypeName());
271            
272            if(!hasExecutionErrors()) {
273                validationResult = AdditionalEntityAttributeValidation(form, validator, entityAttributeType);
274            }
275        }
276        
277        return validationResult;
278    }
279    
280    @Override
281    protected BaseResult execute() {
282        var result = CoreResultFactory.getCreateEntityAttributeResult();
283        EntityAttribute entityAttribute = null;
284        
285        if(!hasExecutionErrors()) {
286            var unitOfMeasureKindName = form.getUnitOfMeasureKindName();
287            var unitOfMeasureTypeName = form.getUnitOfMeasureTypeName();
288            var parameterCount = (unitOfMeasureKindName == null ? 0 : 1) + (unitOfMeasureTypeName == null ? 0 : 1);
289
290            if(parameterCount == 0 || parameterCount == 2) {
291                var entityType = entityTypeLogic.getEntityTypeByUniversalSpec(this, form);
292                var entityAttributeTypeName = form.getEntityAttributeTypeName();
293                var entityAttributeType = entityAttributeLogic.getEntityAttributeTypeByName(this, entityAttributeTypeName);
294
295                if(!hasExecutionErrors()) {
296                    var entityListItemSequenceName = entityAttributeTypeName.equals(EntityAttributeTypes.LISTITEM.name())
297                            || entityAttributeTypeName.equals(EntityAttributeTypes.MULTIPLELISTITEM.name()) ?
298                            form.getEntityListItemSequenceName() : null;
299                    Sequence entityListItemSequence = null;
300
301                    if(entityListItemSequenceName != null) {
302                        var sequenceType = sequenceTypeLogic.getSequenceTypeByName(this, SequenceTypes.ENTITY_LIST_ITEM.name());
303
304                        if(!hasExecutionErrors()) {
305                            entityListItemSequence = sequenceControl.getSequenceByName(sequenceType, entityListItemSequenceName);
306
307                            if(entityListItemSequence == null) {
308                                addExecutionError(ExecutionErrors.UnknownEntityListItemSequenceName.name(), entityListItemSequenceName);
309                            }
310                        }
311                    }
312
313                    if(!hasExecutionErrors()) {
314                        UnitOfMeasureType unitOfMeasureType = null;
315
316                        if(parameterCount == 2) {
317                            unitOfMeasureType = unitOfMeasureTypeLogic.getUnitOfMeasureTypeByName(this, unitOfMeasureKindName, unitOfMeasureTypeName);
318                        }
319
320                        if(!hasExecutionErrors()) {
321                            var workflowName = form.getWorkflowName();
322                            Workflow workflow = null;
323
324                            if(workflowName != null) {
325                                workflow = workflowLogic.getWorkflowByName(this, workflowName);
326                            }
327
328                            if(!hasExecutionErrors()) {
329                                var partyPK = getPartyPK();
330                                var entityAttributeName = form.getEntityAttributeName();
331                                var trackRevisions = Boolean.valueOf(form.getTrackRevisions());
332                                var strCheckContentWebAddress = form.getCheckContentWebAddress();
333                                var checkContentWebAddress = strCheckContentWebAddress == null ? null : Boolean.valueOf(strCheckContentWebAddress);
334                                var validationPattern = form.getValidationPattern();
335                                var strUpperRangeIntegerValue = form.getUpperRangeIntegerValue();
336                                var upperRangeIntegerValue = strUpperRangeIntegerValue == null ? null : Integer.valueOf(strUpperRangeIntegerValue);
337                                var strUpperLimitIntegerValue = form.getUpperLimitIntegerValue();
338                                var upperLimitIntegerValue = strUpperLimitIntegerValue == null ? null : Integer.valueOf(strUpperLimitIntegerValue);
339                                var strLowerLimitIntegerValue = form.getLowerLimitIntegerValue();
340                                var lowerLimitIntegerValue = strLowerLimitIntegerValue == null ? null : Integer.valueOf(strLowerLimitIntegerValue);
341                                var strLowerRangeIntegerValue = form.getLowerRangeIntegerValue();
342                                var lowerRangeIntegerValue = strLowerRangeIntegerValue == null ? null : Integer.valueOf(strLowerRangeIntegerValue);
343                                var strUpperRangeLongValue = form.getUpperRangeLongValue();
344                                var upperRangeLongValue = strUpperRangeLongValue == null ? null : Long.valueOf(strUpperRangeLongValue);
345                                var strUpperLimitLongValue = form.getUpperLimitLongValue();
346                                var upperLimitLongValue = strUpperLimitLongValue == null ? null : Long.valueOf(strUpperLimitLongValue);
347                                var strLowerLimitLongValue = form.getLowerLimitLongValue();
348                                var lowerLimitLongValue = strLowerLimitLongValue == null ? null : Long.valueOf(strLowerLimitLongValue);
349                                var strLowerRangeLongValue = form.getLowerRangeLongValue();
350                                var lowerRangeLongValue = strLowerRangeLongValue == null ? null : Long.valueOf(strLowerRangeLongValue);
351                                var sortOrder = Integer.valueOf(form.getSortOrder());
352                                var description = form.getDescription();
353
354                                entityAttribute = entityAttributeLogic.createEntityAttribute(this, entityType,
355                                        entityAttributeName, entityAttributeType, trackRevisions, checkContentWebAddress,
356                                        validationPattern, upperRangeIntegerValue, upperLimitIntegerValue, lowerLimitIntegerValue,
357                                        lowerRangeIntegerValue, upperRangeLongValue, upperLimitLongValue, lowerLimitLongValue,
358                                        lowerRangeLongValue, entityListItemSequence, unitOfMeasureType, workflow, sortOrder,
359                                        partyPK, getPreferredLanguage(), description);
360                            }
361                        }
362                    }
363                }
364            } else {
365                addExecutionError(ExecutionErrors.InvalidParameterCount.name());
366            }
367        }
368        
369        if(entityAttribute != null) {
370            var basePK = entityAttribute.getPrimaryKey();
371
372            result.setEntityAttributeName(entityAttribute.getLastDetail().getEntityAttributeName());
373            result.setEntityRef(basePK.getEntityRef());
374        }
375        
376        return result;
377    }
378
379}