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