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.inventory.server.graphql; 018 019import com.echothree.model.control.graphql.server.graphql.BaseObject; 020import com.echothree.model.control.item.server.graphql.ItemObject; 021import com.echothree.model.control.item.server.graphql.ItemSecurityUtils; 022import com.echothree.model.control.party.server.graphql.PartyObject; 023import com.echothree.model.control.party.server.graphql.PartySecurityUtils; 024import com.echothree.model.control.uom.server.graphql.UnitOfMeasureTypeObject; 025import com.echothree.model.control.uom.server.graphql.UomSecurityUtils; 026import com.echothree.model.data.inventory.server.entity.PartyBucket; 027import graphql.annotations.annotationTypes.GraphQLDescription; 028import graphql.annotations.annotationTypes.GraphQLField; 029import graphql.annotations.annotationTypes.GraphQLName; 030import graphql.annotations.annotationTypes.GraphQLNonNull; 031import graphql.schema.DataFetchingEnvironment; 032 033@GraphQLDescription("party bucket object") 034@GraphQLName("PartyBucket") 035public class PartyBucketObject 036 extends BaseObject { 037 038 private final PartyBucket partyBucket; 039 040 public PartyBucketObject(final PartyBucket partyBucket) { 041 this.partyBucket = partyBucket; 042 } 043 044 @GraphQLField 045 @GraphQLDescription("party") 046 public PartyObject getParty(final DataFetchingEnvironment env) { 047 var party = partyBucket.getParty(); 048 049 return PartySecurityUtils.getHasPartyAccess(env, party) ? new PartyObject(party) : null; 050 } 051 052 @GraphQLField 053 @GraphQLDescription("item") 054 public ItemObject getItem(final DataFetchingEnvironment env) { 055 return ItemSecurityUtils.getHasItemAccess(env) ? new ItemObject(partyBucket.getItem()) : null; 056 } 057 058 @GraphQLField 059 @GraphQLDescription("unit of measure type") 060 public UnitOfMeasureTypeObject getUnitOfMeasureType(final DataFetchingEnvironment env) { 061 return UomSecurityUtils.getHasUnitOfMeasureTypeAccess(env) 062 ? new UnitOfMeasureTypeObject(partyBucket.getUnitOfMeasureType()) : null; 063 } 064 065 @GraphQLField 066 @GraphQLDescription("inventory condition") 067 public InventoryConditionObject getInventoryCondition(final DataFetchingEnvironment env) { 068 return InventorySecurityUtils.getHasInventoryConditionAccess(env) 069 ? new InventoryConditionObject(partyBucket.getInventoryCondition()) : null; 070 } 071 072 @GraphQLField 073 @GraphQLDescription("inventory bucket type") 074 public InventoryBucketTypeObject getInventoryBucketType(final DataFetchingEnvironment env) { 075 return InventorySecurityUtils.getHasInventoryBucketTypeAccess(env) 076 ? new InventoryBucketTypeObject(partyBucket.getInventoryBucketType()) : null; 077 } 078 079 @GraphQLField 080 @GraphQLDescription("quantity") 081 @GraphQLNonNull 082 public Long getQuantity() { 083 return partyBucket.getQuantity(); 084 } 085 086}