zf

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

action.ex (5322B)


      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.Action do
     19 @moduledoc """
     20 An action verb defining the kind of event, commitment, or intent.
     21 """
     22 use Ecto.Schema
     23 
     24 alias Zenflows.VF.Action.ID
     25 
     26 @type t() :: %__MODULE__{
     27 	id: ID.t(),
     28 	label: String.t(),
     29 	resource_effect: String.t(),
     30 	onhand_effect: String.t(),
     31 	input_output: String.t(),
     32 	pairs_with: String.t(),
     33 }
     34 
     35 @primary_key {:id, ID, []}
     36 embedded_schema do
     37 	field :label, :string
     38 	field :resource_effect, :string
     39 	field :onhand_effect, :string
     40 	field :input_output, :string
     41 	field :pairs_with, :string
     42 end
     43 
     44 @doc "Preloads the Action struct by the given `key`."
     45 @spec preload(Ecto.Schema.t(), atom()) :: nil | Ecto.Schema.t()
     46 def preload(schema, key) do
     47 	%{schema | key => Map.get(map(), Map.fetch!(schema, :"#{key}_id"))}
     48 end
     49 
     50 @doc """
     51 Returns a map, where each string ID key points to its corresponding
     52 Action struct.
     53 """
     54 @spec map() :: %{ID.t() => t()}
     55 def map() do
     56 	%{
     57 		"produce" => %__MODULE__{
     58 			id: "produce",
     59 			label: "produce",
     60 			resource_effect: "increment",
     61 			onhand_effect: "increment",
     62 			input_output: "output",
     63 			pairs_with: "notApplicable",
     64 		},
     65 		"use" => %__MODULE__{
     66 			id: "use",
     67 			label: "use",
     68 			resource_effect: "noEffect",
     69 			onhand_effect: "noEffect",
     70 			input_output: "input",
     71 			pairs_with: "notApplicable",
     72 		},
     73 		"consume" => %__MODULE__{
     74 			id: "consume",
     75 			label: "consume",
     76 			resource_effect: "decrement",
     77 			onhand_effect: "decrement",
     78 			input_output: "input",
     79 			pairs_with: "notApplicable",
     80 		},
     81 		"cite" => %__MODULE__{
     82 			id: "cite",
     83 			label: "cite",
     84 			resource_effect: "noEffect",
     85 			onhand_effect: "noEffect",
     86 			input_output: "input",
     87 			pairs_with: "notApplicable",
     88 		},
     89 		"deliverService" => %__MODULE__{
     90 			id: "deliverService",
     91 			label: "deliver-service",
     92 			resource_effect: "noEffect",
     93 			onhand_effect: "noEffect",
     94 			input_output: "inputOutput",
     95 			pairs_with: "notApplicable",
     96 		},
     97 		"work" => %__MODULE__{
     98 			id: "work",
     99 			label: "work",
    100 			resource_effect: "noEffect",
    101 			onhand_effect: "noEffect",
    102 			input_output: "input",
    103 			pairs_with: "notApplicable",
    104 		},
    105 		"pickup" => %__MODULE__{
    106 			id: "pickup",
    107 			label: "pickup",
    108 			resource_effect: "noEffect",
    109 			onhand_effect: "noEffect",
    110 			input_output: "input",
    111 			pairs_with: "dropoff",
    112 		},
    113 		"dropoff" => %__MODULE__{
    114 			id: "dropoff",
    115 			label: "dropoff",
    116 			resource_effect: "noEffect",
    117 			onhand_effect: "noEffect",
    118 			input_output: "output",
    119 			pairs_with: "pickup",
    120 		},
    121 		"accept" => %__MODULE__{
    122 			id: "accept",
    123 			label: "accept",
    124 			resource_effect: "noEffect",
    125 			onhand_effect: "input",
    126 			input_output: "notApplicable",
    127 			pairs_with: "modify",
    128 		},
    129 		"modify" => %__MODULE__{
    130 			id: "modify",
    131 			label: "modify",
    132 			resource_effect: "noEffect",
    133 			onhand_effect: "noEffect",
    134 			input_output: "output",
    135 			pairs_with: "modify",
    136 		},
    137 		"combine" => %__MODULE__{
    138 			id: "combine",
    139 			label: "combine",
    140 			resource_effect: "noEffect",
    141 			onhand_effect: "decrement",
    142 			input_output: "input",
    143 			pairs_with: "modify",
    144 		},
    145 		"separate" => %__MODULE__{
    146 			id: "separate",
    147 			label: "separate",
    148 			resource_effect: "noEffect",
    149 			onhand_effect: "increment",
    150 			input_output: "output",
    151 			pairs_with: "accept",
    152 		},
    153 		"transferAllRights" => %__MODULE__{
    154 			id: "transferAllRights",
    155 			label: "transfer-all-rights",
    156 			resource_effect: "decrementIncrement",
    157 			onhand_effect: "noEffect",
    158 			input_output: "notApplicable",
    159 			pairs_with: "notApplicable",
    160 		},
    161 		"transferCustody" => %__MODULE__{
    162 			id: "transferCustody",
    163 			label: "transfer-custody",
    164 			resource_effect: "noEffect",
    165 			onhand_effect: "decrementIncrement",
    166 			input_output: "notApplicable",
    167 			pairs_with: "notApplicable",
    168 		},
    169 		"transfer" => %__MODULE__{
    170 			id: "transfer",
    171 			label: "transfer",
    172 			resource_effect: "decrementIncrement",
    173 			onhand_effect: "decrementIncrement",
    174 			input_output: "notApplicable",
    175 			pairs_with: "notApplicable",
    176 		},
    177 		"move" => %__MODULE__{
    178 			id: "move",
    179 			label: "move",
    180 			resource_effect: "decrementIncrement",
    181 			onhand_effect: "decrementIncrement",
    182 			input_output: "notApplicable",
    183 			pairs_with: "notApplicable",
    184 		},
    185 		"raise" => %__MODULE__{
    186 			id: "raise",
    187 			label: "raise",
    188 			resource_effect: "increment",
    189 			onhand_effect: "increment",
    190 			input_output: "notApplicable",
    191 			pairs_with: "notApplicable",
    192 		},
    193 		"lower" => %__MODULE__{
    194 			id: "lower",
    195 			label: "lower",
    196 			resource_effect: "decrement",
    197 			onhand_effect: "decrement",
    198 			input_output: "notApplicable",
    199 			pairs_with: "notApplicable",
    200 		},
    201 	}
    202 end
    203 end