001// -------------------------------------------------------------------------------- 002// Copyright 2002-2024 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.workflow.server.graphql; 018 019import com.echothree.model.control.core.server.graphql.CoreSecurityUtils; 020import com.echothree.model.control.core.server.graphql.EntityInstanceObject; 021import com.echothree.model.control.graphql.server.graphql.TimeObject; 022import com.echothree.model.control.graphql.server.util.BaseGraphQl; 023import com.echothree.model.data.workflow.server.entity.WorkflowEntityStatus; 024import graphql.annotations.annotationTypes.GraphQLDescription; 025import graphql.annotations.annotationTypes.GraphQLField; 026import graphql.annotations.annotationTypes.GraphQLName; 027import graphql.annotations.annotationTypes.GraphQLNonNull; 028import graphql.schema.DataFetchingEnvironment; 029 030@GraphQLDescription("workflow entity status object") 031@GraphQLName("WorkflowEntityStatus") 032public class WorkflowEntityStatusObject 033 implements BaseGraphQl { 034 035 private final WorkflowEntityStatus workflowEntityStatus; // Always Present 036 037 public WorkflowEntityStatusObject(WorkflowEntityStatus workflowEntityStatus) { 038 this.workflowEntityStatus = workflowEntityStatus; 039 } 040 041 @GraphQLField 042 @GraphQLDescription("entity instance") 043 public EntityInstanceObject getEntityInstance(final DataFetchingEnvironment env) { 044 if(CoreSecurityUtils.getHasEntityInstanceAccess(env)) { 045 return new EntityInstanceObject(workflowEntityStatus.getEntityInstance()); 046 } else { 047 return null; 048 } 049 } 050 051 @GraphQLField 052 @GraphQLDescription("workflow step") 053 public WorkflowStepObject getWorkflowStep(final DataFetchingEnvironment env) { 054 if(WorkflowSecurityUtils.getHasWorkflowStepAccess(env)) { 055 return new WorkflowStepObject(workflowEntityStatus.getWorkflowStep()); 056 } else { 057 return null; 058 } 059 } 060 061 // TODO: WorkEffortScope 062 063 @GraphQLField 064 @GraphQLDescription("from time") 065 @GraphQLNonNull 066 public TimeObject getFromTime(final DataFetchingEnvironment env) { 067 return new TimeObject(workflowEntityStatus.getFromTime()); 068 } 069 070 @GraphQLField 071 @GraphQLDescription("thru time") 072 @GraphQLNonNull 073 public TimeObject getThruTime(final DataFetchingEnvironment env) { 074 return new TimeObject(workflowEntityStatus.getThruTime()); 075 } 076 077}