Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
4
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Switch to GitLab Next
Sign in / Register
Toggle navigation
C
CommonsPub Federated Server
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
10
Issues
10
List
Boards
Labels
Service Desk
Milestones
Iterations
Merge Requests
1
Merge Requests
1
Requirements
Requirements
List
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Test Cases
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Package Registry
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issue
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Bonfire
CommonsPub Federated Server
Commits
3ed3b6e1
Commit
3ed3b6e1
authored
Nov 12, 2020
by
Mayel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
missing fields
parent
96d605cc
Pipeline
#215169732
failed with stage
in 1 minute and 11 seconds
Changes
13
Pipelines
2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
416 additions
and
182 deletions
+416
-182
lib/extensions/value_flows/claim/graphql.ex
lib/extensions/value_flows/claim/graphql.ex
+0
-9
lib/extensions/value_flows/hydration.ex
lib/extensions/value_flows/hydration.ex
+26
-2
lib/extensions/value_flows/knowledge/action/actions.ex
lib/extensions/value_flows/knowledge/action/actions.ex
+3
-3
lib/extensions/value_flows/knowledge/process_specification/graphql.ex
...ns/value_flows/knowledge/process_specification/graphql.ex
+1
-0
lib/extensions/value_flows/observation/event/event_side_effects.ex
...sions/value_flows/observation/event/event_side_effects.ex
+13
-0
lib/extensions/value_flows/observation/process/graphql.ex
lib/extensions/value_flows/observation/process/graphql.ex
+12
-3
lib/extensions/value_flows/observation/resource/graphql.ex
lib/extensions/value_flows/observation/resource/graphql.ex
+6
-0
lib/extensions/value_flows/observation/resource/resource.ex
lib/extensions/value_flows/observation/resource/resource.ex
+1
-1
lib/extensions/value_flows/planning/intent/intent_graphql.ex
lib/extensions/value_flows/planning/intent/intent_graphql.ex
+0
-10
lib/extensions/value_flows/simulate.ex
lib/extensions/value_flows/simulate.ex
+24
-5
lib/extensions/value_flows/util/graphql.ex
lib/extensions/value_flows/util/graphql.ex
+20
-0
test/value_flows/agent/person/person_graphql_test.exs
test/value_flows/agent/person/person_graphql_test.exs
+41
-19
test/value_flows/observation/event/events_resources_test.exs
test/value_flows/observation/event/events_resources_test.exs
+269
-130
No files found.
lib/extensions/value_flows/claim/graphql.ex
View file @
3ed3b6e1
...
...
@@ -42,15 +42,6 @@ defmodule ValueFlows.Claim.GraphQL do
})
end
def
fetch_resource_conforms_to_edge
(%{
resource_conforms_to_id:
id
}
=
thing
,
_
,
_
)
when
is_binary
(
id
)
do
thing
=
Repo
.
preload
(
thing
,
:resource_conforms_to
)
{
:ok
,
Map
.
get
(
thing
,
:resource_conforms_to
)}
end
def
fetch_resource_conforms_to_edge
(
_
,
_
,
_
)
do
{
:ok
,
nil
}
end
def
fetch_triggered_by_edge
(%{
triggered_by_id:
id
}
=
thing
,
_
,
_
)
when
is_binary
(
id
)
do
thing
=
Repo
.
preload
(
thing
,
:triggered_by
)
...
...
lib/extensions/value_flows/hydration.ex
View file @
3ed3b6e1
...
...
@@ -121,11 +121,17 @@ defmodule ValueFlows.Hydration do
resolve:
&
ValueFlows
.
Proposal
.
ProposedIntentGraphQL
.
published_in_edge
/
3
],
resource_conforms_to:
[
resolve:
&
ValueFlows
.
Planning
.
Intent
.
GraphQL
.
fetch_resource_conforms_to_edge
/
3
resolve:
&
ValueFlows
.
Util
.
GraphQL
.
fetch_resource_conforms_to_edge
/
3
],
resource_inventoried_as:
[
resolve:
&
ValueFlows
.
Planning
.
Intent
.
GraphQL
.
fetch_resource_inventoried_as_edge
/
3
],
resource_quantity:
[
resolve:
&
ValueFlows
.
Util
.
GraphQL
.
resource_quantity_edge
/
3
],
effort_quantity:
[
resolve:
&
ValueFlows
.
Util
.
GraphQL
.
effort_quantity_edge
/
3
],
input_of:
[
resolve:
&
ValueFlows
.
Planning
.
Intent
.
GraphQL
.
fetch_input_of_edge
/
3
],
...
...
@@ -150,7 +156,7 @@ defmodule ValueFlows.Hydration do
resolve:
&
ValueFlows
.
Util
.
GraphQL
.
effort_quantity_edge
/
3
],
resource_conforms_to:
[
resolve:
&
ValueFlows
.
Claim
.
GraphQL
.
fetch_resource_conforms_to_edge
/
3
,
resolve:
&
ValueFlows
.
Util
.
GraphQL
.
fetch_resource_conforms_to_edge
/
3
,
],
triggered_by:
[
resolve:
&
ValueFlows
.
Claim
.
GraphQL
.
fetch_triggered_by_edge
/
3
,
...
...
@@ -175,6 +181,15 @@ defmodule ValueFlows.Hydration do
action:
[
resolve:
&
ValueFlows
.
Knowledge
.
Action
.
GraphQL
.
action_edge
/
3
],
resource_conforms_to:
[
resolve:
&
ValueFlows
.
Util
.
GraphQL
.
fetch_resource_conforms_to_edge
/
3
,
],
resource_quantity:
[
resolve:
&
ValueFlows
.
Util
.
GraphQL
.
resource_quantity_edge
/
3
],
effort_quantity:
[
resolve:
&
ValueFlows
.
Util
.
GraphQL
.
effort_quantity_edge
/
3
],
in_scope_of:
[
resolve:
&
CommonResolver
.
context_edge
/
3
],
...
...
@@ -215,6 +230,9 @@ defmodule ValueFlows.Hydration do
canonical_url:
[
resolve:
&
ValueFlows
.
Util
.
GraphQL
.
canonical_url_edge
/
3
],
state:
[
resolve:
&
ValueFlows
.
Observation
.
EconomicResource
.
GraphQL
.
fetch_state_edge
/
3
],
in_scope_of:
[
resolve:
&
CommonResolver
.
context_edge
/
3
],
...
...
@@ -227,6 +245,9 @@ defmodule ValueFlows.Hydration do
image:
[
resolve:
&
UploadResolver
.
image_content_edge
/
3
],
available_quantity:
[
resolve:
&
ValueFlows
.
Util
.
GraphQL
.
available_quantity_edge
/
3
],
accounting_quantity:
[
resolve:
&
ValueFlows
.
Util
.
GraphQL
.
accounting_quantity_edge
/
3
],
...
...
@@ -279,6 +300,9 @@ defmodule ValueFlows.Hydration do
],
outputs:
[
resolve:
&
ValueFlows
.
Observation
.
Process
.
GraphQL
.
outputs
/
3
],
based_on:
[
resolve:
&
ValueFlows
.
Observation
.
Process
.
GraphQL
.
fetch_based_on_edge
/
3
]
},
...
...
lib/extensions/value_flows/knowledge/action/actions.ex
View file @
3ed3b6e1
defmodule
ValueFlows
.
Knowledge
.
Action
.
Actions
do
# @on_load :load_actions
def
action!
(
label
)
do
def
action!
(
label
)
do
with
{
:ok
,
action
}
<-
action
(
label
)
do
action
else
_
->
nil
else
_
->
nil
end
end
...
...
@@ -12,7 +13,6 @@ defmodule ValueFlows.Knowledge.Action.Actions do
action
(
Atom
.
to_string
(
label
))
end
def
action
(
label
)
do
case
load_actions
()[
label
]
do
nil
->
...
...
lib/extensions/value_flows/knowledge/process_specification/graphql.ex
View file @
3ed3b6e1
...
...
@@ -193,6 +193,7 @@ defmodule ValueFlows.Knowledge.ProcessSpecification.GraphQL do
end
end
# defp validate_agent(pointer) do
# if Pointers.table!(pointer).schema in valid_contexts() do
# :ok
...
...
lib/extensions/value_flows/observation/event/event_side_effects.ex
View file @
3ed3b6e1
...
...
@@ -157,6 +157,7 @@ defmodule ValueFlows.Observation.EconomicEvent.EventSideEffects do
EconomicResources
.
update
(
resource
,
%{
onhand_quantity:
by_quantity
})
do
resource
end
resource
end
...
...
@@ -191,10 +192,22 @@ defmodule ValueFlows.Observation.EconomicEvent.EventSideEffects do
measurement
end
def
return_updated_event
(
event
,
{
:error
,
e
})
do
{
:error
,
e
}
end
def
return_updated_event
(
event
,
resource
)
do
{
:ok
,
%{
event
|
resource_inventoried_as:
resource
}}
end
def
return_updated_event
(
event
,
{
:error
,
e
},
_
)
do
{
:error
,
e
}
end
def
return_updated_event
(
event
,
_
,
{
:error
,
e
})
do
{
:error
,
e
}
end
def
return_updated_event
(
event
,
resource
,
to_resource
)
do
{
:ok
,
%{
event
|
resource_inventoried_as:
resource
,
to_resource_inventoried_as:
to_resource
}}
end
...
...
lib/extensions/value_flows/observation/process/graphql.ex
View file @
3ed3b6e1
...
...
@@ -2,7 +2,6 @@
defmodule
ValueFlows
.
Observation
.
Process
.
GraphQL
do
require
Logger
alias
CommonsPub
.
{
# Activities,
# Communities,
...
...
@@ -181,7 +180,7 @@ defmodule ValueFlows.Observation.Process.GraphQL do
processes_filtered
(%{
agent:
creator
})
end
def
creator_processes
(
_
,
_page_opts
,
_info
)
do
def
creator_processes
(
_
,
_page_opts
,
_info
)
do
{
:ok
,
nil
}
end
...
...
@@ -208,6 +207,16 @@ defmodule ValueFlows.Observation.Process.GraphQL do
)
end
def
fetch_based_on_edge
(%{
based_on_id:
id
}
=
thing
,
_
,
_
)
when
is_binary
(
id
)
do
thing
=
Repo
.
preload
(
thing
,
:based_on
)
{
:ok
,
Map
.
get
(
thing
,
:based_on
)}
end
def
fetch_based_on_edge
(
_
,
_
,
_
)
do
{
:ok
,
nil
}
end
def
list_processes
(
page_opts
,
base_filters
,
_data_filters
,
_cursor_type
)
do
FetchPage
.
run
(%
FetchPage
{
queries:
Queries
,
...
...
@@ -226,7 +235,7 @@ defmodule ValueFlows.Observation.Process.GraphQL do
# preload: [:provider, :receiver, :tags],
# cursor_fn: Processes.cursor(:followers),
page_opts:
page_opts
,
cursor_fn:
&
&1
.
id
,
cursor_fn:
&
&1
.
id
,
base_filters:
[
:default
,
# preload: [:provider, :receiver, :tags],
...
...
lib/extensions/value_flows/observation/resource/graphql.ex
View file @
3ed3b6e1
...
...
@@ -365,6 +365,12 @@ defmodule ValueFlows.Observation.EconomicResource.GraphQL do
EconomicResources
.
trace
(
id
)
end
def
fetch_state_edge
(%{
state_id:
id
}
=
thing
,
_
,
_
)
when
is_binary
(
id
)
do
thing
=
EconomicResources
.
preload_state
(
thing
)
{
:ok
,
Map
.
get
(
thing
,
:conforms_to
)}
end
def
create_resource
(%{
new_inventoried_resource:
resource_attrs
},
info
)
do
with
{
:ok
,
resource
}
<-
create_resource
(%{
economic_resource:
resource_attrs
},
info
)
do
{
:ok
,
Map
.
get
(
resource
,
:economic_resource
)}
...
...
lib/extensions/value_flows/observation/resource/resource.ex
View file @
3ed3b6e1
...
...
@@ -71,7 +71,7 @@ defmodule ValueFlows.Observation.EconomicResource do
@required
~w(name is_public)a
@cast
@required
++
~w(note tracking_identifier current_location_id is_disabled image_id)a
++
~w(primary_accountable_id contained_in_id unit_of_effort_id conforms_to_id current_location_id)a
~w(primary_accountable_id
state_id
contained_in_id unit_of_effort_id conforms_to_id current_location_id)a
def
create_changeset
(
%
User
{}
=
creator
,
...
...
lib/extensions/value_flows/planning/intent/intent_graphql.ex
View file @
3ed3b6e1
...
...
@@ -273,16 +273,6 @@ defmodule ValueFlows.Planning.Intent.GraphQL do
)
end
def
fetch_resource_conforms_to_edge
(%{
resource_conforms_to_id:
id
}
=
thing
,
_
,
_
)
when
is_binary
(
id
)
do
thing
=
Repo
.
preload
(
thing
,
:resource_conforms_to
)
{
:ok
,
Map
.
get
(
thing
,
:resource_conforms_to
)}
end
def
fetch_resource_conforms_to_edge
(
_
,
_
,
_
)
do
{
:ok
,
nil
}
end
def
fetch_resource_inventoried_as_edge
(%{
resource_inventoried_as_id:
id
}
=
thing
,
_
,
_
)
when
is_binary
(
id
)
do
thing
=
Repo
.
preload
(
thing
,
:resource_inventoried_as
)
...
...
lib/extensions/value_flows/simulate.ex
View file @
3ed3b6e1
...
...
@@ -41,6 +41,7 @@ defmodule ValueFlows.Simulate do
|>
Map
.
put_new_lazy
(
"created"
,
&
past_datetime_iso
/
0
)
|>
Map
.
put_new_lazy
(
"due"
,
&
future_datetime_iso
/
0
)
|>
Map
.
put_new_lazy
(
"action"
,
&
action_id
/
0
)
# |> Map.put_new_lazy("resourceClassifiedAs", fn -> some(1..5, &url/0) end)
end
...
...
@@ -57,7 +58,9 @@ defmodule ValueFlows.Simulate do
end
def
fake_agent!
(
overrides
\\
%{},
opts
\\
[])
when
is_map
(
overrides
)
and
is_list
(
opts
)
do
ValueFlows
.
Agent
.
Agents
.
character_to_agent
(
a_fake_user!
(
ValueFlows
.
Agent
.
Agents
.
agent_to_character
(
agent
(
overrides
))))
ValueFlows
.
Agent
.
Agents
.
character_to_agent
(
a_fake_user!
(
ValueFlows
.
Agent
.
Agents
.
agent_to_character
(
agent
(
overrides
)))
)
end
def
resource_specification
(
base
\\
%{})
do
...
...
@@ -118,7 +121,7 @@ defmodule ValueFlows.Simulate do
|>
Map
.
put_new_lazy
(
:name
,
&
name
/
0
)
|>
Map
.
put_new_lazy
(
:note
,
&
summary
/
0
)
|>
Map
.
put_new_lazy
(
:tracking_identifier
,
&
uuid
/
0
)
#
|> Map.put_new_lazy(:state, &action_id/0)
|>
Map
.
put_new_lazy
(
:state
,
&
action_id
/
0
)
# |> Map.put_new_lazy(:accounting_quantity, &measure/0)
# |> Map.put_new_lazy(:onhand_quantity, &measure/0)
# |> Map.put_new_lazy(:unit_of_effort, &unit/0)
...
...
@@ -217,7 +220,7 @@ defmodule ValueFlows.Simulate do
|>
Map
.
put_new_lazy
(
:has_end
,
&
future_datetime
/
0
)
|>
Map
.
put_new_lazy
(
:has_point_in_time
,
&
future_datetime
/
0
)
|>
Map
.
put_new_lazy
(
:due
,
&
future_datetime
/
0
)
# TODO: list of URIs
# TODO: list of URIs
?
|>
Map
.
put_new_lazy
(
:resource_classified_as
,
fn
->
some
(
1
..
5
,
&
url
/
0
)
end
)
|>
Map
.
put_new_lazy
(
:finished
,
&
bool
/
0
)
|>
Map
.
put_new_lazy
(
:is_public
,
&
truth
/
0
)
...
...
@@ -249,6 +252,21 @@ defmodule ValueFlows.Simulate do
end
def
fake_intent!
(
user
,
overrides
\\
%{})
do
unit
=
fake_unit!
(
user
)
fake_intent!
(
user
,
overrides
,
unit
)
end
def
fake_intent!
(
user
,
overrides
,
unit
)
do
measure_attrs
=
%{
unit_id:
unit
.
id
}
measures
=
%{
available_quantity:
measure
(
measure_attrs
),
resource_quantity:
measure
(
measure_attrs
),
effort_quantity:
measure
(
measure_attrs
)
}
overrides
=
Map
.
merge
(
overrides
,
measures
)
{
:ok
,
intent
}
=
Intents
.
create
(
user
,
intent
(
overrides
))
intent
end
...
...
@@ -288,7 +306,8 @@ defmodule ValueFlows.Simulate do
measure_attrs
=
%{
unit_id:
unit
.
id
}
measures
=
%{
resource_quantity:
measure
(
measure_attrs
)
resource_quantity:
measure
(
measure_attrs
),
effort_quantity:
measure
(
measure_attrs
)
}
overrides
=
Map
.
merge
(
overrides
,
measures
)
...
...
@@ -317,7 +336,7 @@ defmodule ValueFlows.Simulate do
measures
=
%{
accounting_quantity:
measure
(
measure_attrs
),
onhand_quantity:
measure
(
measure_attrs
)
,
onhand_quantity:
measure
(
measure_attrs
)
}
overrides
=
Map
.
merge
(
overrides
,
measures
)
...
...
lib/extensions/value_flows/util/graphql.ex
View file @
3ed3b6e1
...
...
@@ -71,6 +71,26 @@ defmodule ValueFlows.Util.GraphQL do
{
:ok
,
nil
}
end
def
fetch_resource_conforms_to_edge
(%{
resource_conforms_to_id:
id
}
=
thing
,
_
,
_
)
when
is_binary
(
id
)
do
thing
=
Repo
.
preload
(
thing
,
:resource_conforms_to
)
{
:ok
,
Map
.
get
(
thing
,
:resource_conforms_to
)}
end
def
fetch_resource_conforms_to_edge
(
_
,
_
,
_
)
do
{
:ok
,
nil
}
end
def
available_quantity_edge
(%{
available_quantity_id:
id
}
=
thing
,
_
,
_
)
when
not
is_nil
(
id
)
do
thing
=
Repo
.
preload
(
thing
,
available_quantity:
[
:unit
])
{
:ok
,
Map
.
get
(
thing
,
:available_quantity
)}
end
def
available_quantity_edge
(
_
,
_
,
_
)
do
{
:ok
,
nil
}
end
def
resource_quantity_edge
(%{
resource_quantity_id:
id
}
=
thing
,
_
,
_
)
when
not
is_nil
(
id
)
do
thing
=
Repo
.
preload
(
thing
,
resource_quantity:
[
:unit
])
{
:ok
,
Map
.
get
(
thing
,
:resource_quantity
)}
...
...
test/value_flows/agent/person/person_graphql_test.exs
View file @
3ed3b6e1
...
...
@@ -6,6 +6,7 @@ defmodule Valueflows.Agent.Person.GraphQLTest do
import
CommonsPub
.
Web
.
Test
.
GraphQLAssertions
import
Geolocation
.
Test
.
Faking
import
Measurement
.
Simulate
import
ValueFlows
.
Simulate
import
ValueFlows
.
Test
.
Faking
...
...
@@ -28,28 +29,50 @@ defmodule Valueflows.Agent.Person.GraphQLTest do
# attach some data to the person...
intent
=
fake_intent!
(
user
,
%{
provider:
user
.
id
})
unit
=
fake_unit!
(
user
)
resource
=
fake_economic_resource!
(
user
,
%{
primary_accountable:
user
.
id
})
intent
=
fake_intent!
(
user
,
%{
provider:
user
.
id
})
rspec
=
fake_resource_specification!
(
user
)
process
=
fake_process!
(
user
)
from_resource
=
fake_economic_resource!
(
user2
,
%{
name:
"Previous Resource"
,
conforms_to:
rspec
.
id
},
unit
)
resource
=
fake_economic_resource!
(
user
,
%{
primary_accountable:
user
.
id
,
name:
"Resulting Resource"
,
conforms_to:
rspec
.
id
},
unit
)
pspec
=
fake_process_specification!
(
user
)
process
=
fake_process!
(
user
,
%{
based_on:
pspec
.
id
})
event
=
fake_economic_event!
(
user
,
%{
provider:
user2
.
id
,
receiver:
user
.
id
,
action:
"transfer"
,
input_of:
fake_process!
(
user
)
.
id
,
output_of:
fake_process!
(
user2
)
.
id
,
resource_conforms_to:
fake_resource_specification!
(
user2
)
.
id
,
resource_inventoried_as:
fake_economic_resource!
(
user2
,
%{
name:
"Previous Resourec"
})
.
id
,
to_resource_inventoried_as:
fake_economic_resource!
(
user
,
%{
name:
"Resulting Resource"
})
.
id
})
IO
.
inspect
(
ress:
ValueFlows
.
Observation
.
EconomicResource
.
EconomicResources
.
many
(
agent_id:
user
.
id
))
fake_economic_event!
(
user
,
%{
provider:
user2
.
id
,
receiver:
user
.
id
,
action:
"transfer"
,
input_of:
fake_process!
(
user
)
.
id
,
output_of:
fake_process!
(
user2
)
.
id
,
resource_conforms_to:
fake_resource_specification!
(
user
)
.
id
,
resource_inventoried_as:
from_resource
.
id
,
to_resource_inventoried_as:
resource
.
id
},
unit
)
IO
.
inspect
(
event:
event
)
# IO.inspect(
# resource: ValueFlows.Observation.EconomicResource.EconomicResources.many(agent_id: user.id)
# )
assert
queried
=
CommonsPub
.
Web
.
GraphQL
.
QueryHelper
.
run_query_id
(
...
...
@@ -61,7 +84,6 @@ defmodule Valueflows.Agent.Person.GraphQLTest do
@debug
)
assert_agent
(
queried
)
# assert_optional(assert_url(queried["image"]))
assert_intent
(
List
.
first
(
queried
[
"intents"
]))
...
...
test/value_flows/observation/event/events_resources_test.exs
View file @
3ed3b6e1
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment