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