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.CoreEditFactory; 020import com.echothree.control.user.core.common.edit.EntityAttributeEdit; 021import com.echothree.control.user.core.common.form.EditEntityAttributeForm; 022import com.echothree.control.user.core.common.result.CoreResultFactory; 023import com.echothree.control.user.core.common.result.EditEntityAttributeResult; 024import com.echothree.control.user.core.common.spec.EntityAttributeUniversalSpec; 025import com.echothree.model.control.core.common.EntityAttributeTypes; 026import com.echothree.model.control.core.server.logic.EntityAttributeLogic; 027import com.echothree.model.control.party.common.PartyTypes; 028import com.echothree.model.control.security.common.SecurityRoleGroups; 029import com.echothree.model.control.security.common.SecurityRoles; 030import com.echothree.model.control.sequence.common.SequenceTypes; 031import com.echothree.model.control.sequence.server.control.SequenceControl; 032import com.echothree.model.control.sequence.server.logic.SequenceTypeLogic; 033import com.echothree.model.control.uom.server.logic.UnitOfMeasureTypeLogic; 034import com.echothree.model.control.workflow.server.logic.WorkflowLogic; 035import com.echothree.model.data.core.server.entity.EntityAttribute; 036import com.echothree.model.data.sequence.server.entity.Sequence; 037import com.echothree.model.data.uom.server.entity.UnitOfMeasureType; 038import com.echothree.model.data.user.common.pk.UserVisitPK; 039import com.echothree.model.data.workflow.server.entity.Workflow; 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.BaseAbstractEditCommand; 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 EditEntityAttributeCommand 055 extends BaseAbstractEditCommand<EntityAttributeUniversalSpec, EntityAttributeEdit, EditEntityAttributeResult, EntityAttribute, EntityAttribute> { 056 057 private final static CommandSecurityDefinition COMMAND_SECURITY_DEFINITION; 058 private final static List<FieldDefinition> SPEC_FIELD_DEFINITIONS; 059 private final static List<FieldDefinition> EDIT_FIELD_DEFINITIONS; 060 061 static { 062 COMMAND_SECURITY_DEFINITION = new CommandSecurityDefinition(List.of( 063 new PartyTypeDefinition(PartyTypes.UTILITY.name(), null), 064 new PartyTypeDefinition(PartyTypes.EMPLOYEE.name(), List.of( 065 new SecurityRoleDefinition(SecurityRoleGroups.EntityAttribute.name(), SecurityRoles.Edit.name()) 066 )) 067 )); 068 069 SPEC_FIELD_DEFINITIONS = List.of( 070 new FieldDefinition("EntityRef", FieldType.ENTITY_REF, false, null, null), 071 new FieldDefinition("Uuid", FieldType.UUID, false, null, null), 072 new FieldDefinition("ComponentVendorName", FieldType.ENTITY_NAME, false, null, null), 073 new FieldDefinition("EntityTypeName", FieldType.ENTITY_TYPE_NAME, false, null, null), 074 new FieldDefinition("EntityAttributeName", FieldType.ENTITY_NAME, false, null, null) 075 ); 076 077 EDIT_FIELD_DEFINITIONS = List.of( 078 new FieldDefinition("EntityAttributeName", FieldType.ENTITY_NAME, true, null, null), 079 new FieldDefinition("TrackRevisions", FieldType.BOOLEAN, true, null, null), 080 new FieldDefinition("SortOrder", FieldType.SIGNED_INTEGER, true, null, null), 081 new FieldDefinition("Description", FieldType.STRING, false, 1L, 132L) 082 ); 083 } 084 085 @Inject 086 SequenceControl sequenceControl; 087 088 @Inject 089 EntityAttributeLogic entityAttributeLogic; 090 091 @Inject 092 SequenceTypeLogic sequenceTypeLogic; 093 094 @Inject 095 UnitOfMeasureTypeLogic unitOfMeasureTypeLogic; 096 097 @Inject 098 WorkflowLogic workflowLogic; 099 100 /** Creates a new instance of EditEntityAttributeCommand */ 101 public EditEntityAttributeCommand() { 102 super(COMMAND_SECURITY_DEFINITION, SPEC_FIELD_DEFINITIONS, EDIT_FIELD_DEFINITIONS); 103 } 104 105 @Override 106 protected ValidationResult validateEdit(Validator validator) { 107 var validationResult = validator.validate(edit, getEditFieldDefinitions()); 108 109 if(!validationResult.getHasErrors()) { 110 entityAttribute = entityAttributeLogic.getEntityAttributeByUniversalSpec(this, 111 spec); 112 113 if(!hasExecutionErrors()) { 114 var entityAttributeType = entityAttribute.getLastDetail().getEntityAttributeType(); 115 116 validationResult = CreateEntityAttributeCommand.AdditionalEntityAttributeValidation(edit, validator, entityAttributeType); 117 } 118 } 119 120 return validationResult; 121 } 122 123 @Override 124 public EditEntityAttributeResult getResult() { 125 return CoreResultFactory.getEditEntityAttributeResult(); 126 } 127 128 @Override 129 public EntityAttributeEdit getEdit() { 130 return CoreEditFactory.getEntityAttributeEdit(); 131 } 132 133 EntityAttribute entityAttribute = null; 134 135 @Override 136 public EntityAttribute getEntity(EditEntityAttributeResult result) { 137 entityAttribute = entityAttributeLogic.getEntityAttributeByUniversalSpec(this, 138 spec, editModeToEntityPermission(editMode)); 139 140 return entityAttribute; 141 } 142 143 @Override 144 public EntityAttribute getLockEntity(EntityAttribute entityAttribute) { 145 return entityAttribute; 146 } 147 148 @Override 149 public void fillInResult(EditEntityAttributeResult result, EntityAttribute entityAttribute) { 150 151 result.setEntityAttribute(coreControl.getEntityAttributeTransfer(getUserVisit(), entityAttribute, null)); 152 } 153 154 Sequence entityListItemSequence = null; 155 UnitOfMeasureType unitOfMeasureType = null; 156 Workflow workflow = null; 157 158 @Override 159 public void doLock(EntityAttributeEdit edit, EntityAttribute entityAttribute) { 160 var entityAttributeDescription = coreControl.getEntityAttributeDescription(entityAttribute, getPreferredLanguage()); 161 var entityAttributeDetail = entityAttribute.getLastDetail(); 162 var entityAttributeTypeName = entityAttribute.getLastDetail().getEntityAttributeType().getEntityAttributeTypeName(); 163 var entityAttributeType = EntityAttributeTypes.valueOf(entityAttributeTypeName); 164 165 edit.setEntityAttributeName(entityAttributeDetail.getEntityAttributeName()); 166 edit.setTrackRevisions(entityAttributeDetail.getTrackRevisions().toString()); 167 edit.setSortOrder(entityAttributeDetail.getSortOrder().toString()); 168 169 switch(entityAttributeType) { 170 case BLOB -> { 171 var entityAttributeBlob = coreControl.getEntityAttributeBlobForUpdate(entityAttribute); 172 173 edit.setCheckContentWebAddress(entityAttributeBlob.getCheckContentWebAddress().toString()); 174 } 175 case STRING -> { 176 var entityAttributeString = coreControl.getEntityAttributeStringForUpdate(entityAttribute); 177 178 if(entityAttributeString != null) { 179 edit.setValidationPattern(entityAttributeString.getValidationPattern()); 180 } 181 } 182 case INTEGER -> { 183 var entityAttributeInteger = coreControl.getEntityAttributeIntegerForUpdate(entityAttribute); 184 var entityAttributeNumeric = coreControl.getEntityAttributeNumericForUpdate(entityAttribute); 185 186 if(entityAttributeInteger != null) { 187 var upperLimitIntegerValue = entityAttributeInteger.getUpperLimitIntegerValue(); 188 var upperRangeIntegerValue = entityAttributeInteger.getUpperRangeIntegerValue(); 189 var lowerRangeIntegerValue = entityAttributeInteger.getLowerRangeIntegerValue(); 190 var lowerLimitIntegerValue = entityAttributeInteger.getLowerLimitIntegerValue(); 191 192 edit.setUpperLimitIntegerValue(upperLimitIntegerValue == null ? null : upperLimitIntegerValue.toString()); 193 edit.setUpperRangeIntegerValue(upperRangeIntegerValue == null ? null : upperRangeIntegerValue.toString()); 194 edit.setLowerRangeIntegerValue(lowerRangeIntegerValue == null ? null : lowerRangeIntegerValue.toString()); 195 edit.setLowerLimitIntegerValue(lowerLimitIntegerValue == null ? null : lowerLimitIntegerValue.toString()); 196 } 197 198 if(entityAttributeNumeric != null) { 199 unitOfMeasureType = entityAttributeNumeric.getUnitOfMeasureType(); 200 201 if(unitOfMeasureType != null) { 202 var unitOfMeasureTypeDetail = unitOfMeasureType.getLastDetail(); 203 204 edit.setUnitOfMeasureKindName(unitOfMeasureTypeDetail.getUnitOfMeasureKind().getLastDetail().getUnitOfMeasureKindName()); 205 edit.setUnitOfMeasureTypeName(unitOfMeasureTypeDetail.getUnitOfMeasureTypeName()); 206 } 207 } 208 } 209 case LONG -> { 210 var entityAttributeLong = coreControl.getEntityAttributeLongForUpdate(entityAttribute); 211 var entityAttributeNumeric = coreControl.getEntityAttributeNumericForUpdate(entityAttribute); 212 213 if(entityAttributeLong != null) { 214 var upperLimitLongValue = entityAttributeLong.getUpperLimitLongValue(); 215 var upperRangeLongValue = entityAttributeLong.getUpperRangeLongValue(); 216 var lowerRangeLongValue = entityAttributeLong.getLowerRangeLongValue(); 217 var lowerLimitLongValue = entityAttributeLong.getLowerLimitLongValue(); 218 219 edit.setUpperLimitLongValue(upperLimitLongValue == null ? null : upperLimitLongValue.toString()); 220 edit.setUpperRangeLongValue(upperRangeLongValue == null ? null : upperRangeLongValue.toString()); 221 edit.setLowerRangeLongValue(lowerRangeLongValue == null ? null : lowerRangeLongValue.toString()); 222 edit.setLowerLimitLongValue(lowerLimitLongValue == null ? null : lowerLimitLongValue.toString()); 223 } 224 225 if(entityAttributeNumeric != null) { 226 unitOfMeasureType = entityAttributeNumeric.getUnitOfMeasureType(); 227 228 if(unitOfMeasureType != null) { 229 var unitOfMeasureTypeDetail = unitOfMeasureType.getLastDetail(); 230 231 edit.setUnitOfMeasureKindName(unitOfMeasureTypeDetail.getUnitOfMeasureKind().getLastDetail().getUnitOfMeasureKindName()); 232 edit.setUnitOfMeasureTypeName(unitOfMeasureTypeDetail.getUnitOfMeasureTypeName()); 233 } 234 } 235 } 236 case WORKFLOW -> { 237 var entityAttributeWorkflow = coreControl.getEntityAttributeWorkflowForUpdate(entityAttribute); 238 239 if(entityAttributeWorkflow != null) { 240 edit.setWorkflowName(entityAttributeWorkflow.getWorkflow().getLastDetail().getWorkflowName()); 241 } 242 } 243 case LISTITEM, MULTIPLELISTITEM -> { 244 var entityAttributeListItem = coreControl.getEntityAttributeListItemForUpdate(entityAttribute); 245 246 if(entityAttributeListItem != null) { 247 entityListItemSequence = entityAttributeListItem.getEntityListItemSequence(); 248 249 edit.setEntityListItemSequenceName(entityListItemSequence == null ? null : entityListItemSequence.getLastDetail().getSequenceName()); 250 } 251 } 252 default -> { 253 } 254 } 255 256 if(entityAttributeDescription != null) { 257 edit.setDescription(entityAttributeDescription.getDescription()); 258 } 259 } 260 261 @Override 262 public void canUpdate(EntityAttribute entityAttribute) { 263 var entityAttributeName = edit.getEntityAttributeName(); 264 var duplicateEntityAttribute = coreControl.getEntityAttributeByName(entityAttribute.getLastDetail().getEntityType(), 265 entityAttributeName); 266 267 if(duplicateEntityAttribute == null || entityAttribute.equals(duplicateEntityAttribute)) { 268 var entityAttributeTypeName = entityAttribute.getLastDetail().getEntityAttributeType().getEntityAttributeTypeName(); 269 var entityListItemSequenceName = entityAttributeTypeName.equals(EntityAttributeTypes.LISTITEM.name()) 270 || entityAttributeTypeName.equals(EntityAttributeTypes.MULTIPLELISTITEM.name()) ? 271 edit.getEntityListItemSequenceName() : null; 272 273 if(entityListItemSequenceName != null) { 274 var sequenceType = sequenceTypeLogic.getSequenceTypeByName(this, SequenceTypes.ENTITY_LIST_ITEM.name()); 275 276 if(!hasExecutionErrors()) { 277 entityListItemSequence = sequenceControl.getSequenceByName(sequenceType, entityListItemSequenceName); 278 279 if(entityListItemSequence == null) { 280 addExecutionError(ExecutionErrors.UnknownEntityListItemSequenceName.name(), entityListItemSequenceName); 281 } 282 } 283 } 284 285 if(!hasExecutionErrors()) { 286 var unitOfMeasureKindName = edit.getUnitOfMeasureKindName(); 287 var unitOfMeasureTypeName = edit.getUnitOfMeasureTypeName(); 288 var parameterCount = (unitOfMeasureKindName == null ? 0 : 1) + (unitOfMeasureTypeName == null ? 0 : 1); 289 290 if(parameterCount == 0 || parameterCount == 2) { 291 if(parameterCount == 2) { 292 unitOfMeasureType = unitOfMeasureTypeLogic.getUnitOfMeasureTypeByName(this, unitOfMeasureKindName, unitOfMeasureTypeName); 293 } 294 } else { 295 addExecutionError(ExecutionErrors.InvalidParameterCount.name()); 296 } 297 } 298 299 if(!hasExecutionErrors() && entityAttributeTypeName.equals(EntityAttributeTypes.WORKFLOW.name())) { 300 workflow = workflowLogic.getWorkflowByName(this, edit.getWorkflowName()); 301 } 302 } else { 303 addExecutionError(ExecutionErrors.DuplicateEntityAttributeName.name(), entityAttributeName); 304 } 305 } 306 307 @Override 308 public void doUpdate(EntityAttribute entityAttribute) { 309 var partyPK = getPartyPK(); 310 var entityAttributeDetailValue = coreControl.getEntityAttributeDetailValueForUpdate(entityAttribute); 311 var entityAttributeDescription = coreControl.getEntityAttributeDescriptionForUpdate(entityAttribute, getPreferredLanguage()); 312 var strCheckContentWebAddress = edit.getCheckContentWebAddress(); 313 var checkContentWebAddress = strCheckContentWebAddress == null ? null : Boolean.valueOf(strCheckContentWebAddress); 314 var validationPattern = edit.getValidationPattern(); 315 var strUpperRangeIntegerValue = edit.getUpperRangeIntegerValue(); 316 var upperRangeIntegerValue = strUpperRangeIntegerValue == null ? null : Integer.valueOf(strUpperRangeIntegerValue); 317 var strUpperLimitIntegerValue = edit.getUpperLimitIntegerValue(); 318 var upperLimitIntegerValue = strUpperLimitIntegerValue == null ? null : Integer.valueOf(strUpperLimitIntegerValue); 319 var strLowerLimitIntegerValue = edit.getLowerLimitIntegerValue(); 320 var lowerLimitIntegerValue = strLowerLimitIntegerValue == null ? null : Integer.valueOf(strLowerLimitIntegerValue); 321 var strLowerRangeIntegerValue = edit.getLowerRangeIntegerValue(); 322 var lowerRangeIntegerValue = strLowerRangeIntegerValue == null ? null : Integer.valueOf(strLowerRangeIntegerValue); 323 var strUpperRangeLongValue = edit.getUpperRangeLongValue(); 324 var upperRangeLongValue = strUpperRangeLongValue == null ? null : Long.valueOf(strUpperRangeLongValue); 325 var strUpperLimitLongValue = edit.getUpperLimitLongValue(); 326 var upperLimitLongValue = strUpperLimitLongValue == null ? null : Long.valueOf(strUpperLimitLongValue); 327 var strLowerLimitLongValue = edit.getLowerLimitLongValue(); 328 var lowerLimitLongValue = strLowerLimitLongValue == null ? null : Long.valueOf(strLowerLimitLongValue); 329 var strLowerRangeLongValue = edit.getLowerRangeLongValue(); 330 var lowerRangeLongValue = strLowerRangeLongValue == null ? null : Long.valueOf(strLowerRangeLongValue); 331 var description = edit.getDescription(); 332 333 entityAttributeDetailValue.setEntityAttributeName(edit.getEntityAttributeName()); 334 entityAttributeDetailValue.setTrackRevisions(Boolean.valueOf(edit.getTrackRevisions())); 335 entityAttributeDetailValue.setSortOrder(Integer.valueOf(edit.getSortOrder())); 336 337 entityAttributeLogic.updateEntityAttributeFromValue(session, entityAttributeDetailValue, partyPK); 338 339 var entityAttributeTypeName = entityAttribute.getLastDetail().getEntityAttributeType().getEntityAttributeTypeName(); 340 var entityAttributeType = EntityAttributeTypes.valueOf(entityAttributeTypeName); 341 342 switch(entityAttributeType) { 343 case BLOB -> { 344 var entityAttributeBlobValue = coreControl.getEntityAttributeBlobValueForUpdate(entityAttribute); 345 346 entityAttributeBlobValue.setCheckContentWebAddress(checkContentWebAddress); 347 coreControl.updateEntityAttributeBlobFromValue(entityAttributeBlobValue, partyPK); 348 } 349 case STRING -> { 350 var entityAttributeString = coreControl.getEntityAttributeStringForUpdate(entityAttribute); 351 352 if(entityAttributeString == null && validationPattern != null) { 353 coreControl.createEntityAttributeString(entityAttribute, validationPattern, partyPK); 354 } else if(entityAttributeString != null) { 355 if(validationPattern == null) { 356 coreControl.deleteEntityAttributeString(entityAttributeString, partyPK); 357 } else { 358 var entityAttributeStringValue = coreControl.getEntityAttributeStringValue(entityAttributeString); 359 360 entityAttributeStringValue.setValidationPattern(validationPattern); 361 coreControl.updateEntityAttributeStringFromValue(entityAttributeStringValue, partyPK); 362 } 363 } 364 } 365 case INTEGER -> { 366 var entityAttributeInteger = coreControl.getEntityAttributeIntegerForUpdate(entityAttribute); 367 var entityAttributeNumeric = coreControl.getEntityAttributeNumericForUpdate(entityAttribute); 368 369 if(entityAttributeInteger == null && (upperRangeIntegerValue != null || upperLimitIntegerValue != null || lowerLimitIntegerValue != null || lowerRangeIntegerValue != null)) { 370 coreControl.createEntityAttributeInteger(entityAttribute, upperRangeIntegerValue, upperLimitIntegerValue, lowerLimitIntegerValue, lowerRangeIntegerValue, partyPK); 371 } else if(entityAttributeInteger != null) { 372 if(upperRangeIntegerValue == null && upperLimitIntegerValue == null && lowerLimitIntegerValue == null && lowerRangeIntegerValue == null) { 373 coreControl.deleteEntityAttributeInteger(entityAttributeInteger, partyPK); 374 } else { 375 var entityAttributeIntegerValue = coreControl.getEntityAttributeIntegerValue(entityAttributeInteger); 376 377 entityAttributeIntegerValue.setUpperRangeIntegerValue(upperRangeIntegerValue); 378 entityAttributeIntegerValue.setUpperLimitIntegerValue(upperLimitIntegerValue); 379 entityAttributeIntegerValue.setLowerLimitIntegerValue(lowerLimitIntegerValue); 380 entityAttributeIntegerValue.setLowerRangeIntegerValue(lowerRangeIntegerValue); 381 coreControl.updateEntityAttributeIntegerFromValue(entityAttributeIntegerValue, partyPK); 382 } 383 } 384 385 if(entityAttributeNumeric == null && unitOfMeasureType != null) { 386 coreControl.createEntityAttributeNumeric(entityAttribute, unitOfMeasureType, partyPK); 387 } else if(entityAttributeNumeric != null) { 388 if(unitOfMeasureType == null) { 389 coreControl.deleteEntityAttributeNumeric(entityAttributeNumeric, partyPK); 390 } else { 391 var entityAttributeNumericValue = coreControl.getEntityAttributeNumericValue(entityAttributeNumeric); 392 393 entityAttributeNumericValue.setUnitOfMeasureTypePK(unitOfMeasureType.getPrimaryKey()); 394 coreControl.updateEntityAttributeNumericFromValue(entityAttributeNumericValue, partyPK); 395 } 396 } 397 } 398 case LONG -> { 399 var entityAttributeLong = coreControl.getEntityAttributeLongForUpdate(entityAttribute); 400 var entityAttributeNumeric = coreControl.getEntityAttributeNumericForUpdate(entityAttribute); 401 402 if(entityAttributeLong == null && (upperRangeLongValue != null || upperLimitLongValue != null || lowerLimitLongValue != null || lowerRangeLongValue != null)) { 403 coreControl.createEntityAttributeLong(entityAttribute, upperRangeLongValue, upperLimitLongValue, lowerLimitLongValue, lowerRangeLongValue, partyPK); 404 } else if(entityAttributeLong != null) { 405 if(upperRangeLongValue == null && upperLimitLongValue == null && lowerLimitLongValue == null && lowerRangeLongValue == null) { 406 coreControl.deleteEntityAttributeLong(entityAttributeLong, partyPK); 407 } else { 408 var entityAttributeLongValue = coreControl.getEntityAttributeLongValue(entityAttributeLong); 409 410 entityAttributeLongValue.setUpperRangeLongValue(upperRangeLongValue); 411 entityAttributeLongValue.setUpperLimitLongValue(upperLimitLongValue); 412 entityAttributeLongValue.setLowerLimitLongValue(lowerLimitLongValue); 413 entityAttributeLongValue.setLowerRangeLongValue(lowerRangeLongValue); 414 coreControl.updateEntityAttributeLongFromValue(entityAttributeLongValue, partyPK); 415 } 416 } 417 418 if(entityAttributeNumeric == null && unitOfMeasureType != null) { 419 coreControl.createEntityAttributeNumeric(entityAttribute, unitOfMeasureType, partyPK); 420 } else if(entityAttributeNumeric != null) { 421 if(unitOfMeasureType == null) { 422 coreControl.deleteEntityAttributeNumeric(entityAttributeNumeric, partyPK); 423 } else { 424 var entityAttributeNumericValue = coreControl.getEntityAttributeNumericValue(entityAttributeNumeric); 425 426 entityAttributeNumericValue.setUnitOfMeasureTypePK(unitOfMeasureType.getPrimaryKey()); 427 coreControl.updateEntityAttributeNumericFromValue(entityAttributeNumericValue, partyPK); 428 } 429 } 430 } 431 case LISTITEM, MULTIPLELISTITEM -> { 432 var entityAttributeListItem = coreControl.getEntityAttributeListItemForUpdate(entityAttribute); 433 434 if(entityAttributeListItem == null && entityListItemSequence != null) { 435 coreControl.createEntityAttributeListItem(entityAttribute, entityListItemSequence, partyPK); 436 } else if(entityAttributeListItem != null) { 437 if(entityListItemSequence == null) { 438 coreControl.deleteEntityAttributeListItem(entityAttributeListItem, partyPK); 439 } else { 440 var entityAttributeListItemValue = coreControl.getEntityAttributeListItemValue(entityAttributeListItem); 441 442 entityAttributeListItemValue.setEntityListItemSequencePK(entityListItemSequence.getPrimaryKey()); 443 coreControl.updateEntityAttributeListItemFromValue(entityAttributeListItemValue, partyPK); 444 } 445 } 446 } 447 case WORKFLOW -> { 448 var entityAttributeWorkflow = coreControl.getEntityAttributeWorkflowForUpdate(entityAttribute); 449 450 if(entityAttributeWorkflow == null) { 451 coreControl.createEntityAttributeWorkflow(entityAttribute, workflow, partyPK); 452 } else { 453 var entityAttributeWorkflowValue = coreControl.getEntityAttributeWorkflowValue(entityAttributeWorkflow); 454 455 entityAttributeWorkflowValue.setWorkflowPK(workflow.getPrimaryKey()); 456 coreControl.updateEntityAttributeWorkflowFromValue(entityAttributeWorkflowValue, partyPK); 457 } 458 } 459 default -> { 460 } 461 } 462 463 if(entityAttributeDescription == null && description != null) { 464 coreControl.createEntityAttributeDescription(entityAttribute, getPreferredLanguage(), description, partyPK); 465 } else if(entityAttributeDescription != null) { 466 if(description == null) { 467 coreControl.deleteEntityAttributeDescription(entityAttributeDescription, partyPK); 468 } else { 469 var entityAttributeDescriptionValue = coreControl.getEntityAttributeDescriptionValue(entityAttributeDescription); 470 471 entityAttributeDescriptionValue.setDescription(description); 472 coreControl.updateEntityAttributeDescriptionFromValue(entityAttributeDescriptionValue, partyPK); 473 } 474 } 475 } 476 477}