zf

zenflows testing
git clone https://s.sonu.ch/~srfsh/zf.git
Log | Files | Refs | Submodules | README | LICENSE

type.ex (8801B)


      1 # Zenflows is designed to implement the Valueflows vocabulary,
      2 # written and maintained by srfsh <info@dyne.org>.
      3 # Copyright (C) 2021-2023 Dyne.org foundation <foundation@dyne.org>.
      4 #
      5 # This program is free software: you can redistribute it and/or modify
      6 # it under the terms of the GNU Affero General Public License as published by
      7 # the Free Software Foundation, either version 3 of the License, or
      8 # (at your option) any later version.
      9 #
     10 # This program is distributed in the hope that it will be useful,
     11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
     12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     13 # GNU Affero General Public License for more details.
     14 #
     15 # You should have received a copy of the GNU Affero General Public License
     16 # along with this program.  If not, see <https://www.gnu.org/licenses/>.
     17 
     18 defmodule Zenflows.VF.EconomicResource.Type do
     19 @moduledoc false
     20 
     21 use Absinthe.Schema.Notation
     22 
     23 alias Zenflows.VF.EconomicResource.Resolv
     24 
     25 @name """
     26 An informal or formal textual identifier for an item.  Does not imply
     27 uniqueness.
     28 """
     29 @note "A textual description or comment."
     30 @images """
     31 The image files relevant to the entity, such as a photo, diagram, etc.
     32 """
     33 @tracking_identifier """
     34 Sometimes called serial number, used when each item must have a traceable
     35 identifier (like a computer).  Could also be used for other unique
     36 tracking identifiers needed for resources.
     37 """
     38 @classified_as """
     39 References one or more concepts in a common taxonomy or other
     40 classification scheme for purposes of categorization or grouping.
     41 """
     42 @conforms_to """
     43 The primary resource specification or definition of an existing or
     44 potential economic resource.  A resource will have only one, as this
     45 specifies exactly what the resource is.
     46 """
     47 @accounting_quantity """
     48 The current amount and unit of the economic resource for which the
     49 agent has primary rights and responsibilities, sometimes thought of as
     50 ownership.  This can be either stored or derived from economic events
     51 affecting the resource.
     52 """
     53 @onhand_quantity """
     54 The current amount and unit of the economic resource which is under
     55 direct control of the agent.  It may be more or less than the accounting
     56 quantity.  This can be either stored or derived from economic events
     57 affecting the resource.
     58 """
     59 @primary_accountable """
     60 The agent currently with primary rights and responsibilites for
     61 the economic resource.  It is the agent that is associated with the
     62 accountingQuantity of the economic resource.
     63 """
     64 @custodian """
     65 The agent who holds the physical custody of this resource.  It is the
     66 agent that is associated with the onhandQuantity of the economic resource.
     67 """
     68 @stage """
     69 References the ProcessSpecification of the last process the desired
     70 economic resource went through.  Stage is used when the last process
     71 is important for finding proper resources, such as where the publishing
     72 process wants only documents that have gone through the editing process.
     73 """
     74 @state """
     75 The state of the desired economic resource (pass or fail), after coming
     76 out of a test or review process.  Can be derived from the last event if
     77 a pass or fail event.
     78 """
     79 @current_location """
     80 The current place an economic resource is located.  Could be at any
     81 level of granularity, from a town to an address to a warehouse location.
     82 Usually mappable.
     83 """
     84 @lot """
     85 Lot or batch of an economic resource, used to track forward or backwards
     86 to all occurrences of resources of that lot.  Note more than one resource
     87 can be of the same lot.
     88 """
     89 @lot_id "(`ProductBatch`) #{@lot}"
     90 @contained_in """
     91 Used when a stock economic resource contains items also defined as
     92 economic resources.
     93 """
     94 @unit_of_effort """
     95 The unit used for use or work or cite actions for this resource.
     96 """
     97 @okhv "The okh version of the standard of the manifest."
     98 @licensor "States who is licensing the project."
     99 @license "States the licenses under which the project is made available."
    100 @repo "A URL to the repository of the project."
    101 @version "The version of the project."
    102 @metadata "Metadata of the project."
    103 
    104 @desc "A resource which is useful to people or the ecosystem."
    105 object :economic_resource do
    106 	field :id, non_null(:id)
    107 
    108 	@desc @name
    109 	field :name, non_null(:string)
    110 
    111 	@desc @note
    112 	field :note, :string
    113 
    114 	@desc @images
    115 	field :images, list_of(non_null(:file)), resolve: &Resolv.images/3
    116 
    117 	@desc @tracking_identifier
    118 	field :tracking_identifier, :string
    119 
    120 	@desc @classified_as
    121 	field :classified_as, list_of(non_null(:uri))
    122 
    123 	@desc @conforms_to
    124 	field :conforms_to, non_null(:resource_specification),
    125 		resolve: &Resolv.conforms_to/3
    126 
    127 	@desc @accounting_quantity
    128 	field :accounting_quantity, non_null(:measure),
    129 		resolve: &Resolv.accounting_quantity/3
    130 
    131 	@desc @onhand_quantity
    132 	field :onhand_quantity, non_null(:measure),
    133 		resolve: &Resolv.onhand_quantity/3
    134 
    135 	@desc @primary_accountable
    136 	field :primary_accountable, non_null(:agent),
    137 		resolve: &Resolv.primary_accountable/3
    138 
    139 	@desc @custodian
    140 	field :custodian, non_null(:agent),
    141 		resolve: &Resolv.custodian/3
    142 
    143 	@desc @stage
    144 	field :stage, :process_specification, resolve: &Resolv.stage/3
    145 
    146 	@desc @state
    147 	field :state, :action, resolve: &Resolv.state/3
    148 
    149 	@desc @current_location
    150 	field :current_location, :spatial_thing,
    151 		resolve: &Resolv.current_location/3
    152 
    153 	@desc @lot
    154 	field :lot, :product_batch, resolve: &Resolv.lot/3
    155 
    156 	@desc @contained_in
    157 	field :contained_in, :economic_resource,
    158 		resolve: &Resolv.contained_in/3
    159 
    160 	@desc @unit_of_effort
    161 	field :unit_of_effort, :unit, resolve: &Resolv.unit_of_effort/3
    162 
    163 	@desc @okhv
    164 	field :okhv, :string
    165 
    166 	@desc @repo
    167 	field :repo, :string
    168 
    169 	@desc @version
    170 	field :version, :string
    171 
    172 	@desc @licensor
    173 	field :licensor, :string
    174 
    175 	@desc @license
    176 	field :license, :string
    177 
    178 	@desc @metadata
    179 	field :metadata, :json
    180 
    181 	field :previous, list_of(non_null(:economic_event)),
    182 		resolve: &Resolv.previous/3
    183 
    184 	field :trace, list_of(non_null(:track_trace_item)),
    185 		resolve: &Resolv.trace/3
    186 
    187 	field :trace_dpp, non_null(:json), resolve: &Resolv.trace_dpp/3
    188 end
    189 
    190 input_object :economic_resource_create_params do
    191 	@desc @name
    192 	field :name, :string
    193 
    194 	@desc @note
    195 	field :note, :string
    196 
    197 	@desc @images
    198 	field :images, list_of(non_null(:ifile))
    199 
    200 	@desc @tracking_identifier
    201 	field :tracking_identifier, :string
    202 
    203 	@desc @lot_id
    204 	field :lot_id, :id, name: "lot"
    205 
    206 	@desc @okhv
    207 	field :okhv, :string
    208 
    209 	@desc @repo
    210 	field :repo, :string
    211 
    212 	@desc @version
    213 	field :version, :string
    214 
    215 	@desc @licensor
    216 	field :licensor, :string
    217 
    218 	@desc @license
    219 	field :license, :string
    220 
    221 	@desc @metadata
    222 	field :metadata, :json
    223 end
    224 
    225 input_object :economic_resource_update_params do
    226 	field :id, non_null(:id)
    227 
    228 	@desc @note
    229 	field :note, :string
    230 
    231 	@desc @metadata
    232 	field :metadata, :json
    233 end
    234 
    235 object :economic_resource_response do
    236 	field :economic_resource, non_null(:economic_resource)
    237 end
    238 
    239 object :economic_resource_edge do
    240 	field :cursor, non_null(:id)
    241 	field :node, non_null(:economic_resource)
    242 end
    243 
    244 object :economic_resource_connection do
    245 	field :page_info, non_null(:page_info)
    246 	field :edges, non_null(list_of(non_null(:economic_resource_edge)))
    247 end
    248 
    249 input_object :economic_resource_filter_params do
    250 	field :id, list_of(non_null(:id))
    251 	field :or_id, list_of(non_null(:id))
    252 	field :classified_as, list_of(non_null(:uri))
    253 	field :or_classified_as, list_of(non_null(:uri))
    254 	field :conforms_to, list_of(non_null(:id))
    255 	field :or_conforms_to, list_of(non_null(:id))
    256 	field :primary_accountable, list_of(non_null(:id))
    257 	field :or_primary_accountable, list_of(non_null(:id))
    258 	field :not_primary_accountable, list_of(non_null(:id))
    259 	field :custodian, list_of(non_null(:id))
    260 	field :or_custodian, list_of(non_null(:id))
    261 	field :not_custodian, list_of(non_null(:id))
    262 	field :gt_onhand_quantity_has_numerical_value, :decimal
    263 	field :or_gt_onhand_quantity_has_numerical_value, :decimal
    264 	field :name, :string
    265 	field :or_name, :string
    266 	field :note, :string
    267 	field :or_note, :string
    268 end
    269 
    270 object :query_economic_resource do
    271 	field :economic_resource, :economic_resource do
    272 		meta only_guest?: true
    273 		arg :id, non_null(:id)
    274 		resolve &Resolv.economic_resource/2
    275 	end
    276 
    277 	field :economic_resources, :economic_resource_connection do
    278 		meta only_guest?: true
    279 		arg :first, :integer
    280 		arg :after, :id
    281 		arg :last, :integer
    282 		arg :before, :id
    283 		arg :filter, :economic_resource_filter_params
    284 		resolve &Resolv.economic_resources/2
    285 	end
    286 
    287 	field :economic_resource_classifications, list_of(non_null(:uri)) do
    288 		resolve &Resolv.economic_resource_classifications/2
    289 	end
    290 end
    291 
    292 object :mutation_economic_resource do
    293 	field :update_economic_resource, non_null(:economic_resource_response) do
    294 		arg :resource, non_null(:economic_resource_update_params)
    295 		resolve &Resolv.update_economic_resource/2
    296 	end
    297 
    298 	field :delete_economic_resource, non_null(:boolean) do
    299 		arg :id, non_null(:id)
    300 		resolve &Resolv.delete_economic_resource/2
    301 	end
    302 end
    303 end