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.model.control.core.server.graphql; 018 019import com.echothree.model.control.core.common.EntityAttributeTypes; 020import com.echothree.model.control.core.server.control.CoreControl; 021import com.echothree.model.control.core.server.control.EntityAttributeGroupControl; 022import com.echothree.model.control.graphql.server.graphql.BaseEntityInstanceObject; 023import com.echothree.model.control.graphql.server.graphql.count.Connections; 024import com.echothree.model.control.graphql.server.graphql.count.CountedObjects; 025import com.echothree.model.control.graphql.server.graphql.count.CountingDataConnectionFetcher; 026import com.echothree.model.control.graphql.server.graphql.count.CountingPaginatedData; 027import com.echothree.model.control.graphql.server.util.BaseGraphQl; 028import com.echothree.model.control.graphql.server.util.count.ObjectLimiter; 029import com.echothree.model.control.sequence.server.graphql.SequenceObject; 030import com.echothree.model.control.sequence.server.graphql.SequenceSecurityUtils; 031import com.echothree.model.control.uom.server.graphql.UnitOfMeasureTypeObject; 032import com.echothree.model.control.uom.server.graphql.UomSecurityUtils; 033import com.echothree.model.control.user.server.control.UserControl; 034import com.echothree.model.control.workflow.server.graphql.WorkflowObject; 035import com.echothree.model.control.workflow.server.graphql.WorkflowSecurityUtils; 036import com.echothree.model.data.core.common.EntityAttributeEntityAttributeGroupConstants; 037import com.echothree.model.data.core.common.EntityIntegerRangeConstants; 038import com.echothree.model.data.core.common.EntityListItemConstants; 039import com.echothree.model.data.core.common.EntityLongRangeConstants; 040import com.echothree.model.data.core.server.entity.EntityAttribute; 041import com.echothree.model.data.core.server.entity.EntityAttributeBlob; 042import com.echothree.model.data.core.server.entity.EntityAttributeDetail; 043import com.echothree.model.data.core.server.entity.EntityAttributeInteger; 044import com.echothree.model.data.core.server.entity.EntityAttributeListItem; 045import com.echothree.model.data.core.server.entity.EntityAttributeLong; 046import com.echothree.model.data.core.server.entity.EntityAttributeNumeric; 047import com.echothree.model.data.core.server.entity.EntityAttributeString; 048import com.echothree.model.data.core.server.entity.EntityAttributeWorkflow; 049import com.echothree.model.data.core.server.entity.EntityInstance; 050import com.echothree.util.server.persistence.Session; 051import graphql.annotations.annotationTypes.GraphQLDescription; 052import graphql.annotations.annotationTypes.GraphQLField; 053import graphql.annotations.annotationTypes.GraphQLName; 054import graphql.annotations.annotationTypes.GraphQLNonNull; 055import graphql.annotations.connection.GraphQLConnection; 056import graphql.schema.DataFetchingEnvironment; 057import java.util.ArrayList; 058import java.util.stream.Collectors; 059 060@GraphQLDescription("entity attribute object") 061@GraphQLName("EntityAttribute") 062public class EntityAttributeObject 063 extends BaseEntityInstanceObject { 064 065 private final EntityAttribute entityAttribute; // Always Present 066 private final EntityInstance entityInstance; // Optional 067 068 public EntityAttributeObject(EntityAttribute entityAttribute, EntityInstance entityInstance) { 069 super(entityAttribute.getPrimaryKey()); 070 071 this.entityAttribute = entityAttribute; 072 this.entityInstance = entityInstance; 073 } 074 075 private EntityAttributeDetail entityAttributeDetail; // Optional, use getEntityAttributeDetail() 076 077 private EntityAttributeDetail getEntityAttributeDetail() { 078 if(entityAttributeDetail == null) { 079 entityAttributeDetail = entityAttribute.getLastDetail(); 080 } 081 082 return entityAttributeDetail; 083 } 084 085 private EntityAttributeTypes entityAttributeTypeEnum = null; // Optional, use getEntityAttributeTypeEnum() 086 087 protected EntityAttributeTypes getEntityAttributeTypeEnum() { 088 if(entityAttributeTypeEnum == null) { 089 entityAttributeTypeEnum = EntityAttributeTypes.valueOf(getEntityAttributeDetail().getEntityAttributeType().getEntityAttributeTypeName()); 090 } 091 092 return entityAttributeTypeEnum; 093 } 094 095 private EntityAttributeBlob entityAttributeBlob; // Optional, use getEntityAttributeBlob() 096 097 private EntityAttributeBlob getEntityAttributeBlob() { 098 if(entityAttributeBlob == null && getEntityAttributeTypeEnum() == EntityAttributeTypes.BLOB) { 099 var coreControl = Session.getModelController(CoreControl.class); 100 101 entityAttributeBlob = coreControl.getEntityAttributeBlob(entityAttribute); 102 } 103 104 return entityAttributeBlob; 105 } 106 107 private EntityAttributeString entityAttributeString; // Optional, use getEntityAttributeString() 108 109 private EntityAttributeString getEntityAttributeString() { 110 if(entityAttributeString == null && getEntityAttributeTypeEnum() == EntityAttributeTypes.STRING) { 111 var coreControl = Session.getModelController(CoreControl.class); 112 113 entityAttributeString = coreControl.getEntityAttributeString(entityAttribute); 114 } 115 116 return entityAttributeString; 117 } 118 119 private EntityAttributeInteger entityAttributeInteger; // Optional, use getEntityAttributeInteger() 120 121 private EntityAttributeInteger getEntityAttributeInteger() { 122 if(entityAttributeInteger == null && getEntityAttributeTypeEnum() == EntityAttributeTypes.INTEGER) { 123 var coreControl = Session.getModelController(CoreControl.class); 124 125 entityAttributeInteger = coreControl.getEntityAttributeInteger(entityAttribute); 126 } 127 128 return entityAttributeInteger; 129 } 130 131 private EntityAttributeLong entityAttributeLong; // Optional, use getEntityAttributeLong() 132 133 private EntityAttributeLong getEntityAttributeLong() { 134 if(entityAttributeLong == null && getEntityAttributeTypeEnum() == EntityAttributeTypes.LONG) { 135 var coreControl = Session.getModelController(CoreControl.class); 136 137 entityAttributeLong = coreControl.getEntityAttributeLong(entityAttribute); 138 } 139 140 return entityAttributeLong; 141 } 142 143 private EntityAttributeNumeric entityAttributeNumeric; // Optional, use getEntityAttributeNumeric() 144 145 private EntityAttributeNumeric getEntityAttributeNumeric() { 146 var entityAttributeType = getEntityAttributeTypeEnum(); 147 148 if(entityAttributeNumeric == null 149 && (entityAttributeType == EntityAttributeTypes.INTEGER 150 || entityAttributeType == EntityAttributeTypes.LONG)) { 151 var coreControl = Session.getModelController(CoreControl.class); 152 153 entityAttributeNumeric = coreControl.getEntityAttributeNumeric(entityAttribute); 154 } 155 156 return entityAttributeNumeric; 157 } 158 159 private EntityAttributeListItem entityAttributeListItem; // Optional, use getEntityAttributeListItem() 160 161 private EntityAttributeListItem getEntityAttributeListItem() { 162 var entityAttributeType = getEntityAttributeTypeEnum(); 163 164 if(entityAttributeListItem == null 165 && (entityAttributeType == EntityAttributeTypes.LISTITEM 166 || entityAttributeType == EntityAttributeTypes.MULTIPLELISTITEM)) { 167 var coreControl = Session.getModelController(CoreControl.class); 168 169 entityAttributeListItem = coreControl.getEntityAttributeListItem(entityAttribute); 170 } 171 172 return entityAttributeListItem; 173 } 174 175 private EntityAttributeWorkflow entityAttributeWorkflow; // Optional, use getEntityAttributeWorkflow() 176 177 private EntityAttributeWorkflow getEntityAttributeWorkflow() { 178 var entityAttributeType = getEntityAttributeTypeEnum(); 179 180 if(entityAttributeWorkflow == null && (entityAttributeType == EntityAttributeTypes.WORKFLOW)) { 181 var coreControl = Session.getModelController(CoreControl.class); 182 183 entityAttributeWorkflow = coreControl.getEntityAttributeWorkflow(entityAttribute); 184 } 185 186 return entityAttributeWorkflow; 187 } 188 189 @GraphQLField 190 @GraphQLDescription("entity type") 191 public EntityTypeObject getEntityType(final DataFetchingEnvironment env) { 192 return CoreSecurityUtils.getHasEntityTypeAccess(env) ? new EntityTypeObject(getEntityAttributeDetail().getEntityType()) : null; 193 } 194 195 @GraphQLField 196 @GraphQLDescription("entity attribute name") 197 @GraphQLNonNull 198 public String getEntityAttributeName() { 199 return getEntityAttributeDetail().getEntityAttributeName(); 200 } 201 202 @GraphQLField 203 @GraphQLDescription("entity attribute type") 204 public EntityAttributeTypeObject getEntityAttributeType(final DataFetchingEnvironment env) { 205 return CoreSecurityUtils.getHasEntityAttributeTypeAccess(env) ? new EntityAttributeTypeObject(getEntityAttributeDetail().getEntityAttributeType()) : null; 206 } 207 208 @GraphQLField 209 @GraphQLDescription("track revisions") 210 @GraphQLNonNull 211 public boolean getTrackRevisions() { 212 return getEntityAttributeDetail().getTrackRevisions(); 213 } 214 215 @GraphQLField 216 @GraphQLDescription("check content web address") 217 @GraphQLNonNull 218 public boolean getCheckContentWebAddress() { 219 return getEntityAttributeBlob().getCheckContentWebAddress(); 220 } 221 222 @GraphQLField 223 @GraphQLDescription("validation pattern") 224 public String getValidationPattern() { 225 var entityAttributeString = getEntityAttributeString(); 226 227 return entityAttributeString == null ? null : entityAttributeString.getValidationPattern(); 228 } 229 230 @GraphQLField 231 @GraphQLDescription("unformatted upper range integer value") 232 public Integer getUnformattedUpperRangeIntegerValue() { 233 var entityAttributeInteger = getEntityAttributeInteger(); 234 235 return entityAttributeInteger == null ? null : entityAttributeInteger.getUpperRangeIntegerValue(); 236 } 237 238 @GraphQLField 239 @GraphQLDescription("upper range integer value") 240 public String getUpperRangeIntegerValue() { 241 var entityAttributeInteger = getEntityAttributeInteger(); 242 243 return entityAttributeInteger == null ? null : entityAttributeInteger.getUpperRangeIntegerValue().toString(); // TODO 244 } 245 246 @GraphQLField 247 @GraphQLDescription("unformatted upper limit integer value") 248 public Integer getUnformattedUpperLimitIntegerValue() { 249 var entityAttributeInteger = getEntityAttributeInteger(); 250 251 return entityAttributeInteger == null ? null : entityAttributeInteger.getUpperLimitIntegerValue(); 252 } 253 254 @GraphQLField 255 @GraphQLDescription("upper limit integer value") 256 public String getUpperLimitIntegerValue() { 257 var entityAttributeInteger = getEntityAttributeInteger(); 258 259 return entityAttributeInteger == null ? null : entityAttributeInteger.getUpperLimitIntegerValue().toString(); // TODO 260 } 261 262 @GraphQLField 263 @GraphQLDescription("unformatted lower limit integer value") 264 public Integer getUnformattedLowerLimitIntegerValue() { 265 var entityAttributeInteger = getEntityAttributeInteger(); 266 267 return entityAttributeInteger == null ? null : entityAttributeInteger.getLowerLimitIntegerValue(); 268 } 269 270 @GraphQLField 271 @GraphQLDescription("lower limit integer value") 272 public String getLowerLimitIntegerValue() { 273 var entityAttributeInteger = getEntityAttributeInteger(); 274 275 return entityAttributeInteger == null ? null : entityAttributeInteger.getLowerLimitIntegerValue().toString(); // TODO 276 } 277 278 @GraphQLField 279 @GraphQLDescription("unformatted lower range integer value") 280 public Integer getUnformattedLowerRangeIntegerValue() { 281 var entityAttributeInteger = getEntityAttributeInteger(); 282 283 return entityAttributeInteger == null ? null : entityAttributeInteger.getLowerRangeIntegerValue(); 284 } 285 286 @GraphQLField 287 @GraphQLDescription("lower range integer value") 288 public String getLowerRangeIntegerValue() { 289 var entityAttributeInteger = getEntityAttributeInteger(); 290 291 return entityAttributeInteger == null ? null : entityAttributeInteger.getLowerRangeIntegerValue().toString(); // TODO 292 } 293 294 @GraphQLField 295 @GraphQLDescription("unformatted upper range long value") 296 public Long getUnformattedUpperRangeLongValue() { 297 var entityAttributeLong = getEntityAttributeLong(); 298 299 return entityAttributeLong == null ? null : entityAttributeLong.getUpperRangeLongValue(); 300 } 301 302 @GraphQLField 303 @GraphQLDescription("upper range long value") 304 public String getUpperRangeLongValue() { 305 var entityAttributeLong = getEntityAttributeLong(); 306 307 return entityAttributeLong == null ? null : entityAttributeLong.getUpperRangeLongValue().toString(); // TODO 308 } 309 310 @GraphQLField 311 @GraphQLDescription("unformatted upper limit long value") 312 public Long getUnformattedUpperLimitLongValue() { 313 var entityAttributeLong = getEntityAttributeLong(); 314 315 return entityAttributeLong == null ? null : entityAttributeLong.getUpperLimitLongValue(); 316 } 317 318 @GraphQLField 319 @GraphQLDescription("upper limit long value") 320 public String getUpperLimitLongValue() { 321 var entityAttributeLong = getEntityAttributeLong(); 322 323 return entityAttributeLong == null ? null : entityAttributeLong.getUpperLimitLongValue().toString(); // TODO 324 } 325 326 @GraphQLField 327 @GraphQLDescription("unformatted lower limit long value") 328 public Long getUnformattedLowerLimitLongValue() { 329 var entityAttributeLong = getEntityAttributeLong(); 330 331 return entityAttributeLong == null ? null : entityAttributeLong.getLowerLimitLongValue(); 332 } 333 334 @GraphQLField 335 @GraphQLDescription("lower limit long value") 336 public String getLowerLimitLongValue() { 337 var entityAttributeLong = getEntityAttributeLong(); 338 339 return entityAttributeLong == null ? null : entityAttributeLong.getLowerLimitLongValue().toString(); // TODO 340 } 341 342 @GraphQLField 343 @GraphQLDescription("unformatted lower range long value") 344 public Long getUnformattedLowerRangeLongValue() { 345 var entityAttributeLong = getEntityAttributeLong(); 346 347 return entityAttributeLong == null ? null : entityAttributeLong.getLowerRangeLongValue(); 348 } 349 350 @GraphQLField 351 @GraphQLDescription("lower range long value") 352 public String getLowerRangeLongValue() { 353 var entityAttributeLong = getEntityAttributeLong(); 354 355 return entityAttributeLong == null ? null : entityAttributeLong.getLowerRangeLongValue().toString(); // TODO 356 } 357 358 @GraphQLField 359 @GraphQLDescription("unit of measure type") 360 public UnitOfMeasureTypeObject getUnitOfMeasureType(final DataFetchingEnvironment env) { 361 var entityAttributeNumeric = getEntityAttributeNumeric(); 362 var unitOfMeasureType = entityAttributeNumeric == null ? null : entityAttributeNumeric.getUnitOfMeasureType(); 363 364 return unitOfMeasureType != null && UomSecurityUtils.getHasUnitOfMeasureTypeAccess(env) ? new UnitOfMeasureTypeObject(unitOfMeasureType) : null; 365 } 366 367 @GraphQLField 368 @GraphQLDescription("entity list item sequence") 369 public SequenceObject getEntityListItemSequence(final DataFetchingEnvironment env) { 370 var entityAttributeListItem = getEntityAttributeListItem(); 371 var entityListItemSequence = entityAttributeListItem == null ? null : entityAttributeListItem.getEntityListItemSequence(); 372 373 return entityListItemSequence != null && SequenceSecurityUtils.getHasSequenceAccess(env) ? new SequenceObject(entityListItemSequence) : null; 374 } 375 376 @GraphQLField 377 @GraphQLDescription("workflow") 378 public WorkflowObject getWorkflow(final DataFetchingEnvironment env) { 379 var entityAttributeWorkflow = getEntityAttributeWorkflow(); 380 var workflow = entityAttributeWorkflow == null ? null : entityAttributeWorkflow.getWorkflow(); 381 382 return workflow != null && WorkflowSecurityUtils.getHasWorkflowAccess(env) ? new WorkflowObject(workflow) : null; 383 } 384 385 @GraphQLField 386 @GraphQLDescription("sort order") 387 @GraphQLNonNull 388 public int getSortOrder() { 389 return getEntityAttributeDetail().getSortOrder(); 390 } 391 392 @GraphQLField 393 @GraphQLDescription("description") 394 @GraphQLNonNull 395 public String getDescription(final DataFetchingEnvironment env) { 396 var coreControl = Session.getModelController(CoreControl.class); 397 var userControl = Session.getModelController(UserControl.class); 398 399 return coreControl.getBestEntityAttributeDescription(entityAttribute, userControl.getPreferredLanguageFromUserVisit(BaseGraphQl.getUserVisit(env))); 400 } 401 402 @GraphQLField 403 @GraphQLDescription("attribute") 404 public AttributeInterface getAttribute(final DataFetchingEnvironment env) { 405 AttributeInterface attributeInterface = null; 406 407 if(entityInstance != null) { 408 var coreControl = Session.getModelController(CoreControl.class); 409 410 switch(getEntityAttributeTypeEnum()) { 411 // TODO: BLOB 412 case BOOLEAN -> { 413 var entityBooleanAttribute = coreControl.getEntityBooleanAttribute(entityAttribute, entityInstance); 414 415 attributeInterface = entityBooleanAttribute == null ? null : new EntityBooleanAttributeObject(entityBooleanAttribute); 416 } 417 case CLOB -> { 418 var userControl = Session.getModelController(UserControl.class); 419 var entityClobAttribute = coreControl.getBestEntityClobAttribute(entityAttribute, entityInstance, 420 userControl.getPreferredLanguageFromUserVisit(BaseGraphQl.getUserVisit(env))); 421 422 attributeInterface = entityClobAttribute == null ? null : new EntityClobAttributeObject(entityClobAttribute); 423 } 424 case COLLECTION -> { 425 attributeInterface = new EntityCollectionAttributeObject(entityAttribute, entityInstance); 426 } 427 case DATE -> { 428 var entityDateAttribute = coreControl.getEntityDateAttribute(entityAttribute, entityInstance); 429 430 attributeInterface = entityDateAttribute == null ? null : new EntityDateAttributeObject(entityDateAttribute); 431 } 432 case ENTITY -> { 433 var entityEntityAttribute = coreControl.getEntityEntityAttribute(entityAttribute, entityInstance); 434 435 attributeInterface = entityEntityAttribute == null ? null : new EntityEntityAttributeObject(entityEntityAttribute); 436 } 437 case GEOPOINT -> { 438 var entityGeoPointAttribute = coreControl.getEntityGeoPointAttribute(entityAttribute, entityInstance); 439 440 attributeInterface = entityGeoPointAttribute == null ? null : new EntityGeoPointAttributeObject(entityGeoPointAttribute); 441 } 442 case INTEGER -> { 443 var entityIntegerAttribute = coreControl.getEntityIntegerAttribute(entityAttribute, entityInstance); 444 445 attributeInterface = entityIntegerAttribute == null ? null : new EntityIntegerAttributeObject(entityIntegerAttribute); 446 } 447 case LISTITEM -> { 448 var entityListItemAttribute = coreControl.getEntityListItemAttribute(entityAttribute, entityInstance); 449 450 attributeInterface = entityListItemAttribute == null ? null : new EntityListItemAttributeObject(entityListItemAttribute); 451 } 452 case LONG -> { 453 var entityLongAttribute = coreControl.getEntityLongAttribute(entityAttribute, entityInstance); 454 455 attributeInterface = entityLongAttribute == null ? null : new EntityLongAttributeObject(entityLongAttribute); 456 } 457 case MULTIPLELISTITEM -> { 458 attributeInterface = new EntityMultipleListItemAttributeObject(entityAttribute, entityInstance); 459 } 460 case NAME -> { 461 var entityNameAttribute = coreControl.getEntityNameAttribute(entityAttribute, entityInstance); 462 463 attributeInterface = entityNameAttribute == null ? null : new EntityNameAttributeObject(entityNameAttribute); 464 } 465 case STRING -> { 466 var userControl = Session.getModelController(UserControl.class); 467 var entityStringAttribute = coreControl.getBestEntityStringAttribute(entityAttribute, entityInstance, 468 userControl.getPreferredLanguageFromUserVisit(BaseGraphQl.getUserVisit(env))); 469 470 attributeInterface = entityStringAttribute == null ? null : new EntityStringAttributeObject(entityStringAttribute); 471 } 472 case TIME -> { 473 var entityTimeAttribute = coreControl.getEntityTimeAttribute(entityAttribute, entityInstance); 474 475 attributeInterface = entityTimeAttribute == null ? null : new EntityTimeAttributeObject(entityTimeAttribute); 476 } 477 case WORKFLOW -> { 478 attributeInterface = new EntityWorkflowAttributeObject(entityAttribute, entityInstance); 479 } 480 default -> {} // Leave attributeInterface null 481 } 482 } 483 484 return attributeInterface; 485 } 486 487 @GraphQLField 488 @GraphQLDescription("default") 489 public DefaultInterface getDefault(final DataFetchingEnvironment env) { 490 var coreControl = Session.getModelController(CoreControl.class); 491 DefaultInterface defaultInterface = null; 492 493 switch(getEntityAttributeTypeEnum()) { 494 case BOOLEAN -> { 495 var entityBooleanDefault = coreControl.getEntityBooleanDefault(entityAttribute); 496 497 defaultInterface = entityBooleanDefault == null ? null : new EntityBooleanDefaultObject(entityBooleanDefault); 498 } 499 case DATE -> { 500 var entityDateDefault = coreControl.getEntityDateDefault(entityAttribute); 501 502 defaultInterface = entityDateDefault == null ? null : new EntityDateDefaultObject(entityDateDefault); 503 } 504 case GEOPOINT -> { 505 var entityGeoPointDefault = coreControl.getEntityGeoPointDefault(entityAttribute); 506 507 defaultInterface = entityGeoPointDefault == null ? null : new EntityGeoPointDefaultObject(entityGeoPointDefault); 508 } 509 case INTEGER -> { 510 var entityIntegerDefault = coreControl.getEntityIntegerDefault(entityAttribute); 511 512 defaultInterface = entityIntegerDefault == null ? null : new EntityIntegerDefaultObject(entityIntegerDefault); 513 } 514 case LONG -> { 515 var entityLongDefault = coreControl.getEntityLongDefault(entityAttribute); 516 517 defaultInterface = entityLongDefault == null ? null : new EntityLongDefaultObject(entityLongDefault); 518 } 519 case LISTITEM -> { 520 var entityListItemDefault = coreControl.getEntityListItemDefault(entityAttribute); 521 522 defaultInterface = entityListItemDefault == null ? null : new EntityListItemDefaultObject(entityListItemDefault); 523 } 524 case STRING -> { 525 var userControl = Session.getModelController(UserControl.class); 526 var entityStringDefault = coreControl.getEntityStringDefault(entityAttribute, 527 userControl.getPreferredLanguageFromUserVisit(BaseGraphQl.getUserVisit(env))); 528 529 defaultInterface = entityStringDefault == null ? null : new EntityStringDefaultObject(entityStringDefault); 530 } 531 case TIME -> { 532 var entityTimeDefault = coreControl.getEntityTimeDefault(entityAttribute); 533 534 defaultInterface = entityTimeDefault == null ? null : new EntityTimeDefaultObject(entityTimeDefault); 535 } 536 default -> {} // Leave defaultInterface null 537 } 538 539 return defaultInterface; 540 } 541 542 @GraphQLField 543 @GraphQLDescription("entity list items") 544 @GraphQLConnection(connectionFetcher = CountingDataConnectionFetcher.class) 545 public CountingPaginatedData<EntityListItemObject> getEntityListItems(final DataFetchingEnvironment env) { 546 var entityAttributeType = getEntityAttributeTypeEnum(); 547 CountingPaginatedData<EntityListItemObject> entityListItemObjects = null; 548 549 if((entityAttributeType == EntityAttributeTypes.LISTITEM 550 || entityAttributeType == EntityAttributeTypes.MULTIPLELISTITEM) 551 && CoreSecurityUtils.getHasEntityListItemsAccess(env)) { 552 var coreControl = Session.getModelController(CoreControl.class); 553 var totalCount = coreControl.countEntityListItems(entityAttribute); 554 555 try(var objectLimiter = new ObjectLimiter(env, EntityListItemConstants.COMPONENT_VENDOR_NAME, EntityListItemConstants.ENTITY_TYPE_NAME, totalCount)) { 556 var entities = coreControl.getEntityListItems(entityAttribute); 557 var entityListItems = entities.stream().map(EntityListItemObject::new).collect(Collectors.toCollection(() -> new ArrayList<>(entities.size()))); 558 559 entityListItemObjects = new CountedObjects<>(objectLimiter, entityListItems); 560 } 561 } 562 563 return entityListItemObjects; 564 } 565 566 @GraphQLField 567 @GraphQLDescription("entity long ranges") 568 @GraphQLConnection(connectionFetcher = CountingDataConnectionFetcher.class) 569 public CountingPaginatedData<EntityLongRangeObject> getEntityLongRanges(final DataFetchingEnvironment env) { 570 CountingPaginatedData<EntityLongRangeObject> entityLongRangeObjects = null; 571 572 if(getEntityAttributeTypeEnum() == EntityAttributeTypes.LONG 573 && CoreSecurityUtils.getHasEntityLongRangesAccess(env)) { 574 var coreControl = Session.getModelController(CoreControl.class); 575 var totalCount = coreControl.countEntityLongRanges(entityAttribute); 576 577 try(var objectLimiter = new ObjectLimiter(env, EntityLongRangeConstants.COMPONENT_VENDOR_NAME, EntityLongRangeConstants.ENTITY_TYPE_NAME, totalCount)) { 578 var entities = coreControl.getEntityLongRanges(entityAttribute); 579 var entityLongRanges = entities.stream().map(EntityLongRangeObject::new).collect(Collectors.toCollection(() -> new ArrayList<>(entities.size()))); 580 581 entityLongRangeObjects = new CountedObjects<>(objectLimiter, entityLongRanges); 582 } 583 } 584 585 return entityLongRangeObjects; 586 } 587 588 @GraphQLField 589 @GraphQLDescription("entity integer ranges") 590 @GraphQLConnection(connectionFetcher = CountingDataConnectionFetcher.class) 591 public CountingPaginatedData<EntityIntegerRangeObject> getEntityIntegerRanges(final DataFetchingEnvironment env) { 592 CountingPaginatedData<EntityIntegerRangeObject> entityIntegerRangeObjects = null; 593 594 if(getEntityAttributeTypeEnum() == EntityAttributeTypes.INTEGER 595 && CoreSecurityUtils.getHasEntityIntegerRangesAccess(env)) { 596 var coreControl = Session.getModelController(CoreControl.class); 597 var totalCount = coreControl.countEntityIntegerRanges(entityAttribute); 598 599 try(var objectLimiter = new ObjectLimiter(env, EntityIntegerRangeConstants.COMPONENT_VENDOR_NAME, EntityIntegerRangeConstants.ENTITY_TYPE_NAME, totalCount)) { 600 var entities = coreControl.getEntityIntegerRanges(entityAttribute); 601 var entityIntegerRanges = entities.stream().map(EntityIntegerRangeObject::new).collect(Collectors.toCollection(() -> new ArrayList<>(entities.size()))); 602 603 entityIntegerRangeObjects = new CountedObjects<>(objectLimiter, entityIntegerRanges); 604 } 605 } 606 607 return entityIntegerRangeObjects; 608 } 609 610 @GraphQLField 611 @GraphQLDescription("entity attribute entity attribute groups") 612 @GraphQLNonNull 613 @GraphQLConnection(connectionFetcher = CountingDataConnectionFetcher.class) 614 public CountingPaginatedData<EntityAttributeEntityAttributeGroupObject> getEntityAttributeEntityAttributeGroups(final DataFetchingEnvironment env) { 615 if(CoreSecurityUtils.getHasEntityAttributeEntityAttributeGroupsAccess(env)) { 616 var entityAttributeGroupControl = Session.getModelController(EntityAttributeGroupControl.class); 617 var totalCount = entityAttributeGroupControl.countEntityAttributeEntityAttributeGroupsByEntityAttribute(entityAttribute); 618 619 try(var objectLimiter = new ObjectLimiter(env, EntityAttributeEntityAttributeGroupConstants.COMPONENT_VENDOR_NAME, EntityAttributeEntityAttributeGroupConstants.ENTITY_TYPE_NAME, totalCount)) { 620 var entities = entityAttributeGroupControl.getEntityAttributeEntityAttributeGroupsByEntityAttribute(entityAttribute); 621 var entityAttributeEntityAttributeGroups = entities.stream().map(EntityAttributeEntityAttributeGroupObject::new).collect(Collectors.toCollection(() -> new ArrayList<>(entities.size()))); 622 623 return new CountedObjects<>(objectLimiter, entityAttributeEntityAttributeGroups); 624 } 625 } else { 626 return Connections.emptyConnection(); 627 } 628 } 629 630}