solis 0.64.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +18 -0
  3. data/.travis.yml +6 -0
  4. data/CODE_OF_CONDUCT.md +74 -0
  5. data/Gemfile +4 -0
  6. data/LICENSE.txt +21 -0
  7. data/README.md +287 -0
  8. data/Rakefile +10 -0
  9. data/bin/console +14 -0
  10. data/bin/setup +8 -0
  11. data/examples/after_hooks.rb +24 -0
  12. data/examples/config.yml.template +15 -0
  13. data/examples/read_from_shacl.rb +22 -0
  14. data/examples/read_from_shacl_abv.rb +84 -0
  15. data/examples/read_from_sheet.rb +22 -0
  16. data/lib/solis/config_file.rb +91 -0
  17. data/lib/solis/error/cursor_error.rb +6 -0
  18. data/lib/solis/error/general_error.rb +6 -0
  19. data/lib/solis/error/invalid_attribute_error.rb +6 -0
  20. data/lib/solis/error/invalid_datatype_error.rb +6 -0
  21. data/lib/solis/error/not_found_error.rb +6 -0
  22. data/lib/solis/error/query_error.rb +6 -0
  23. data/lib/solis/error.rb +3 -0
  24. data/lib/solis/graph.rb +360 -0
  25. data/lib/solis/model.rb +565 -0
  26. data/lib/solis/options.rb +19 -0
  27. data/lib/solis/query/construct.rb +93 -0
  28. data/lib/solis/query/filter.rb +133 -0
  29. data/lib/solis/query/run.rb +97 -0
  30. data/lib/solis/query.rb +347 -0
  31. data/lib/solis/resource.rb +37 -0
  32. data/lib/solis/shape/data_types.rb +280 -0
  33. data/lib/solis/shape/reader/csv.rb +12 -0
  34. data/lib/solis/shape/reader/file.rb +16 -0
  35. data/lib/solis/shape/reader/sheet.rb +777 -0
  36. data/lib/solis/shape/reader/simple_sheets/sheet.rb +59 -0
  37. data/lib/solis/shape/reader/simple_sheets/worksheet.rb +173 -0
  38. data/lib/solis/shape/reader/simple_sheets.rb +40 -0
  39. data/lib/solis/shape.rb +189 -0
  40. data/lib/solis/sparql_adaptor.rb +318 -0
  41. data/lib/solis/store/sparql/client/query.rb +35 -0
  42. data/lib/solis/store/sparql/client.rb +41 -0
  43. data/lib/solis/version.rb +3 -0
  44. data/lib/solis.rb +13 -0
  45. data/solis.gemspec +50 -0
  46. metadata +304 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: '0965263268b064dee557568f16f61570d571a32c236c7d6f53e675713d30289a'
4
+ data.tar.gz: e2cd0b29580a4031c1d22988dd7131055dec9b6e07fbe4128806aa0709b65b4e
5
+ SHA512:
6
+ metadata.gz: 71e19db05ebbb97b64fdf9b36883d003cb5e5a46ab6a1f2233938790371e94b80ba6cc1f574903c34cc959ddcf279bdb36c67506b44b0cc12378920b4da72d66
7
+ data.tar.gz: 70bbd782872f2d8cf0f771d43e3f5e0074ba5af2821d5d927b99b1a24a4638f88bfe43811818b1d6755a8460b764b571633dd6c3289f0c604bbc39147144fcaa
data/.gitignore ADDED
@@ -0,0 +1,18 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+ .idea
10
+ .DS_Store
11
+ examples/data/cache
12
+ config.yml
13
+ examples/data
14
+ .vscode
15
+ *.gem
16
+ lib/solis/entity
17
+ cache
18
+ Gemfile.lock
data/.travis.yml ADDED
@@ -0,0 +1,6 @@
1
+ ---
2
+ language: ruby
3
+ cache: bundler
4
+ rvm:
5
+ - 2.7.2
6
+ before_install: gem install bundler -v 2.1.4
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at mehmet@celik.be. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [https://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: https://contributor-covenant.org
74
+ [version]: https://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in solis.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2021 Mehmet Celik
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,287 @@
1
+ # Solis
2
+
3
+ Solis means 'the sun' in Latin or just Silos spelled backwards.
4
+ A simple idea to use SHACL to describe models and API on top of a data store.
5
+
6
+ # Status
7
+ Although I'm using it in production I must shamefully acknowledge that it actually needs refactoring. Solis is currently still grown organically driven by my needs and understanding of problem domain(RDF, triples, ...).
8
+ When my current project is live I'll start to refactor the code and release it as 1.0.
9
+
10
+ # From Google Sheets to RDF, Shacl, ... to API
11
+ The biggest hurdle when developing a model is the communication between the people who know the problem domain and the developers.
12
+ Next to this every change in the model has a direct impact on everything that uses the model. From migrations to documentation and eventually the API.
13
+ This is an effort to streamline and minimalize this impact.
14
+
15
+ ## config.yml
16
+ Config file contains all the options needed to run Solis.
17
+
18
+ ```yaml
19
+ :debug: false
20
+ :key: your_Google_API_key
21
+ :solis:
22
+ :cache: tmp/cache
23
+ :query_cache_expire: 300
24
+ :shacl: /path/to/t_shacl.ttl
25
+ :env:
26
+ :graph_name: https://t.example.com/
27
+ :graph_prefix: t
28
+ :sparql_endpoint: http://127.0.0.1:8890/sparql
29
+ :inflections: /path/to/t.json
30
+ :language: nl
31
+ :sheets:
32
+ :t: 1vi2U9Gpgu9mA6OpvrDBWRg8oVKs6Es63VyLDIKFNWYM
33
+
34
+ ```
35
+
36
+ - debug: extra logging like generated queries etc.
37
+ - key: Google API key used to read a Google Sheet
38
+ - solis: runtime configuration
39
+ - cache: Google Sheets can be cached to minimize Google API calls
40
+ - query_cache_expire: time construct queries should expire. 0 is never expire
41
+ - shacl: location of the shacl file to use
42
+ - env: shacl info
43
+ - graph_name: uri of the graph
44
+ - graph_prefix: uri prefix of the graph
45
+ - sparql_endpoint: uri to connect to the data store. Currently focus is on triple stores
46
+ - inflections: singular, plural mapping file for multi lingual data models
47
+ - language: default language strings are stored in.
48
+ - sheets: list of models
49
+ - t: an example sheet
50
+
51
+ ## Solis Model Template
52
+
53
+ ![Template model](./test/resources/data/t.png)
54
+
55
+ This is simple template exclusively used for testing.
56
+ ### Google Sheet [model](https://docs.google.com/spreadsheets/d/1vi2U9Gpgu9mA6OpvrDBWRg8oVKs6Es63VyLDIKFNWYM/edit#gid=577648221)
57
+
58
+ #### Tabs
59
+ - _PREFIXES: a list of ontologies and prefixes used
60
+ - Base: All entities defined under this URI. Selected by '*'
61
+ - Prefix: prefix of ontology
62
+ - URI: URI of ontology
63
+ - _METADATA: description fields for metadata
64
+ - key: identifier of metadata
65
+ - value: metadata value
66
+ - _ENTITIES: a list of entities(classes) used in the model
67
+ - Name: name of entity
68
+ - NamePlural: plural name of entity. The generated API has RESTful endpoints. Non english entities are incorrectly pluralized
69
+ - Description: purpose of entity
70
+ - subClassOf: internal entity reference. Entity you want to inherit from
71
+ - sameAs: External entity reference (not activily used, yet)
72
+ - Any number of tabs describing properties of an entity. See below
73
+
74
+ #### Entity tabs
75
+ Not every entity described in _ENTITIES needs a tab.
76
+ ##### CodeTable
77
+ This is a base entity were other entities that fit a code table are inherited from
78
+
79
+ | Name | Description | Min | Max | sameAs | datatype |
80
+ |---|---|---|---|---|---|
81
+ | id | unique record identifier | 1 | 1 | schema:identifier | xsd:string |
82
+ |short_label|lookup key, short label|0|1|xsd:string|
83
+ |label|prefered display label|1|1|xsd:string|
84
+
85
+ ##### Skill
86
+ Inherits from CodeTable no tab is needed. Skills a teacher can teach
87
+ ```json
88
+ [
89
+ { "id": 1, "short_label": "problemsolv", "label": "Applying and problem-solving"},
90
+ { "id": 2, "short_label": "commexp", "label": "Communicating and expressing"},
91
+ { "id": 3, "short_label": "intcon", "label": "Integrating and connecting"},
92
+ { "id": 4, "label": "Reasoning"}
93
+ ]
94
+ ```
95
+
96
+ ##### Person
97
+ Base class for a person
98
+
99
+ | Name | Description | Min | Max | sameAs | datatype |
100
+ |---|---|---|---|---|---|
101
+ | id | unique record identifier | 1 | 1 | schema:identifier | xsd:string |
102
+ |first_name|Person's first name|1|1|schema:givenName|xsd:string|
103
+ |first_name|Person's last name|1|1|schema:familyName|xsd:string|
104
+
105
+ ##### Teacher
106
+ Inherits all fields from Person and adds extra property "skill" an extra tab with the extra properties must exist
107
+
108
+ | Name | Description | Min | Max | sameAs | datatype |
109
+ |---|---|---|---|---|---|
110
+ | id | unique record identifier | 1 | 1 | schema:identifier | xsd:string |
111
+ |skill|field teacher is skilled in|1| | |t:Skill|
112
+
113
+ ##### Student
114
+ Inherits all fields from Person and adds extra property "age" an extra tab with the extra properties must exist
115
+
116
+ | Name | Description | Min | Max | sameAs | datatype |
117
+ |---|---|---|---|---|---|
118
+ | id | unique record identifier | 1 | 1 | schema:identifier | xsd:string |
119
+ |age|age of student|1|1| |xsd:integer|
120
+
121
+ ```json
122
+ [
123
+ {"id": "s1", "first_name": "Jane", "last_name": "Smith", "age": 22},
124
+ {"id": "s1", "first_name": "Gino", "last_name": "Santi", "age": 25}
125
+ ]
126
+ ```
127
+
128
+ ##### Course
129
+ | Name | Description | Min | Max | sameAs | datatype |
130
+ |---|---|---|---|---|---|
131
+ | id | unique record identifier | 1 | 1 | schema:identifier | xsd:string |
132
+ |name|name of a course|1|1| |xsd:string|
133
+
134
+ ##### Schedule
135
+ | Name | Description | Min | Max | sameAs | datatype |
136
+ |---|---|---|---|---|---|
137
+ | id | unique record identifier | 1 | 1 | schema:identifier | xsd:string |
138
+ |teacher|schedule belongs to|1| 1| |t:Teacher|
139
+ |course|course within schedule| |1 | |t:Course|
140
+ |start_date| |1|1| |xsd:date|
141
+ |end_date| |1| 1| |xsd:date|
142
+
143
+ ##### Example data
144
+
145
+ When __no__ id is supplied records will be created and an id will be assigned
146
+ This example will create a schedule, teacher and course record. The skill and student records are referenced by id and must exist.
147
+ ```json
148
+ {
149
+ "type": "schedules",
150
+ "attributes": {
151
+ "teacher": {
152
+ "first_name": "John",
153
+ "last_mame": "Doe",
154
+ "skill": [{"id": "1"}, {"id": "2"}]
155
+ },
156
+ "students": [{"id": "s1"}, {"id": "s2"}],
157
+ "course": {
158
+ "name": "Something 101"
159
+ },
160
+ "start_date": "2021-10-01",
161
+ "end_date": "2022-01-01"
162
+ }
163
+ }
164
+ ```
165
+
166
+ Create schedule with existing teacher and course records
167
+ ```json
168
+ {
169
+ "type": "schedules",
170
+ "attributes": {
171
+ "teacher": {
172
+ "id": "1"
173
+ },
174
+ "course": {
175
+ "id": "A23B-101"
176
+ },
177
+ "start_date": "2021-10-01",
178
+ "end_date": "2022-01-01"
179
+ }
180
+ }
181
+ ```
182
+
183
+ ## Solis API
184
+ ### Solis::ConfigFile
185
+ Static class to read and manipulate config.yml file
186
+ - name=: name of config file defaults to config.yml
187
+ - path=: location of config file defaults to ./config.yml or ./config/config.yml
188
+ - [key]=: lookup or set a key in your config file
189
+ - include?(key): is key available in config file
190
+
191
+ ```ruby
192
+ Solis::ConfigFile.path='/path/to/config/file'
193
+ raise ':key not found' unless Solis::ConfigFile.include?(:key)
194
+
195
+ key = Solis::Configfile[:key]
196
+ ```
197
+
198
+ ### Solis::LOGGER
199
+ Logger class defaults to STDOUT for now
200
+
201
+ TODO: check if this needs to be configurable
202
+
203
+ ### Solis::VERSION
204
+ Returns Solis version number
205
+
206
+ ### Solis::Error
207
+ List of Solis errors
208
+
209
+ ##### Solis::Error::GeneralError
210
+ An unknown error
211
+ ##### Solis::Error::InvalidAttributeError
212
+ Attribute error. Happens when data does not match model
213
+ ##### Solis::Error::NotFoundError
214
+ When query returns not found
215
+
216
+ ### Solis::Graph
217
+ ### Solis::Model
218
+ ### Solis::Resource
219
+ ### Solis::Query
220
+ ### Solis::Shape
221
+
222
+ ### Solis::Shape::Reader
223
+ #### Solis::Shape::Reader::File
224
+ #### Solis::Shape::Reader::Sheet
225
+
226
+ ### Setup Solis
227
+ ``` ruby
228
+ Solis::ConfigFile.path = './'
229
+ solis = Solis::Graph.new(Solis::Shape::Reader::File.read(Solis::ConfigFile[:solis][:shacl]), Solis::ConfigFile[:solis][:env])
230
+ ```
231
+
232
+
233
+ TODO:
234
+ - extract sparql layer into its own gem
235
+
236
+ ## Installation
237
+
238
+ Add this line to your application's Gemfile:
239
+
240
+ ```ruby
241
+ gem 'solis'
242
+ ```
243
+
244
+ And then execute:
245
+
246
+ $ bundle install
247
+
248
+ Or install it yourself as:
249
+
250
+ $ gem install solis
251
+
252
+ ## Usage
253
+
254
+ Transforming a Google Sheet into a SHACL file and Entity model.
255
+
256
+ [Google sheet template](https://docs.google.com/spreadsheets/d/1vi2U9Gpgu9mA6OpvrDBWRg8oVKs6Es63VyLDIKFNWYM/edit?usp=drive_web&ouid=105856802847127219255) example
257
+
258
+ Tabs starting with an underscore define general metadata
259
+ - _PREFIXES: ontologies to include in SHACL file
260
+ - _METADATA: key/value pairs describing the ontology
261
+ - _ENTITIES: a list of entities describing if it is a sub class of or same as an external entity
262
+
263
+ Every entity that is referenced in _ENTITIES can be further described in its own tab.
264
+
265
+
266
+
267
+
268
+ TODO: Write usage instructions here
269
+
270
+ ## Development
271
+
272
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
273
+
274
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
275
+
276
+ ## Contributing
277
+
278
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/solis. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/solis/blob/master/CODE_OF_CONDUCT.md).
279
+
280
+
281
+ ## License
282
+
283
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
284
+
285
+ ## Code of Conduct
286
+
287
+ Everyone interacting in the Solis project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/solis/blob/master/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << "test"
6
+ t.libs << "lib"
7
+ t.test_files = FileList["test/**/*_test.rb"]
8
+ end
9
+
10
+ task :default => :test
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "solis"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,24 @@
1
+ # $LOAD_PATH << '.' << './lib'
2
+ require 'bundler'
3
+ Bundler.require
4
+
5
+ require 'solis'
6
+ require 'pp'
7
+ require 'json'
8
+
9
+ Solis::ConfigFile.path = './'
10
+ g = Solis::Graph.new(Solis::Shape::Reader::File.read(Solis::ConfigFile[:solis][:shacl]),
11
+ Solis::ConfigFile[:solis][:env].merge(
12
+ hooks: {
13
+ create: { before: lambda { |m, d| puts "before-=-=-=-=-=->"},
14
+ after: lambda { |m, d| puts "after-=-=-=-=->" } }
15
+ })
16
+ )
17
+
18
+ # Skill.model_before_create do |model, graph|
19
+ # puts "---------BEFORE"
20
+ # end
21
+
22
+ s = Skill.new({ id: 5, short_label: 'a short label', label: 'a label' })
23
+
24
+ s.save
@@ -0,0 +1,15 @@
1
+ :debug: false
2
+ :key: your_Google_API_key
3
+ :solis:
4
+ :cache: tmp/cache
5
+ :query_cache_expire: 300
6
+ :shacl: /path/to/t_shacl.ttl
7
+ :env:
8
+ :graph_name: https://t.example.com/
9
+ :graph_prefix: t
10
+ :sparql_endpoint: http://127.0.0.1:8890/sparql
11
+ :inflections: /path/to/t.json
12
+ :language: nl
13
+ :sheets:
14
+ :t: 1vi2U9Gpgu9mA6OpvrDBWRg8oVKs6Es63VyLDIKFNWYM
15
+
@@ -0,0 +1,22 @@
1
+ # $LOAD_PATH << '.' << './lib'
2
+ require 'bundler'
3
+ Bundler.require
4
+
5
+ require 'solis'
6
+ require 'pp'
7
+ require 'json'
8
+
9
+ Solis::ConfigFile.path = './'
10
+ g = Solis::Graph.new(Solis::Shape::Reader::File.read(Solis::ConfigFile[:solis][:shacl]), Solis::ConfigFile[:solis][:env])
11
+
12
+ schedule = g.shape_as_model('Schedule')
13
+ schedule_resource = g.shape_as_resource('Schedule')
14
+ puts schedule.model_template.to_json
15
+ begin
16
+ s = schedule_resource.find({id: 123})
17
+ pp s.to_jsonapi
18
+ rescue Graphiti::Errors::RecordNotFound
19
+ puts "record not found"
20
+ end
21
+
22
+
@@ -0,0 +1,84 @@
1
+ # $LOAD_PATH << '.' << './lib'
2
+ require 'bundler'
3
+ Bundler.require
4
+
5
+ require 'solis'
6
+ require 'pp'
7
+ require 'json'
8
+
9
+ Solis::ConfigFile.path = './'
10
+ g = Solis::Graph.new(Solis::Shape::Reader::File.read(Solis::ConfigFile[:solis][:shacl]), Solis::ConfigFile[:solis][:env])
11
+
12
+ model = g.shape_as_model('Codetabel')
13
+ resource = g.shape_as_resource('Codetabel')
14
+ # model.model_template.to_json
15
+ #
16
+ data = %( {
17
+ "type": "agenten",
18
+ "id": 1776,
19
+ "attributes": {
20
+ "identificatie": [
21
+ {
22
+ "id": 1776,
23
+ "waarde": 1776
24
+ }
25
+ ],
26
+ "type": {
27
+ "id": "292r3yzt3rv7owo7"
28
+ },
29
+ "naam": [
30
+ {
31
+ "waarde": "Bond Moyson-gewest Tielt",
32
+ "type_naam": {
33
+ "id": "p9qirbgec6a0j8ri7qst"
34
+ }
35
+ }
36
+ ],
37
+ "datering": "1970-01-01",
38
+ "geschiedenis_agent": [
39
+ ""
40
+ ],
41
+ "functie_beroep_activiteit": {},
42
+ "erkenning": {
43
+ "id": "4cvras56mmdqmay715kns7"
44
+ },
45
+ "adres": {},
46
+ "telefoon": "",
47
+ "email": "",
48
+ "website": "",
49
+ "gebouw": "",
50
+ "zoektoegang": {},
51
+ "openingsuren": "",
52
+ "toegang_gebruiksvoorwaarden": "",
53
+ "bereikbaarheid": {},
54
+ "taal": {},
55
+ "associaties": {},
56
+ "bron_beschrijving_agent": {},
57
+ "bibliografie_agent": {},
58
+ "opmerking": ""
59
+ }
60
+ }
61
+ )
62
+
63
+ begin
64
+ s = resource.find({label: 'persoon'})
65
+ j = JSON.parse(s.to_jsonapi)
66
+ puts JSON.pretty_generate(j)
67
+
68
+ #Agent = g.shape_as_model('Agent')
69
+ agent_data = JSON.parse(data)['attributes']
70
+ pp agent_data
71
+ agent = Agent.new(agent_data)
72
+
73
+ begin
74
+ agent.save
75
+ rescue StandardError => e
76
+ puts e.message
77
+ end
78
+
79
+
80
+ rescue Graphiti::Errors::RecordNotFound
81
+ puts "record not found"
82
+ end
83
+
84
+
@@ -0,0 +1,22 @@
1
+ # $LOAD_PATH << '.' << './lib'
2
+ require 'bundler'
3
+ Bundler.require
4
+
5
+ require 'solis'
6
+ Solis::ConfigFile.path = Dir.pwd
7
+ sheet_key = Solis::ConfigFile[:solis][:env][:graph_prefix].to_sym
8
+ key = Solis::ConfigFile[:key]
9
+ s = Solis::Shape::Reader::Sheet.read(key, Solis::ConfigFile[:sheets][sheet_key], from_cache: false)
10
+
11
+ File.open("./data/#{sheet_key}.sql", 'wb') { |f| f.puts s[:sql] }
12
+ File.open("./data/#{sheet_key}.json", 'wb') { |f| f.puts s[:inflections] }
13
+ File.open("./data/#{sheet_key}_shacl.ttl", 'wb') { |f| f.puts s[:shacl] }
14
+ File.open("./data/#{sheet_key}_schema.ttl", 'wb') { |f| f.puts s[:schema] }
15
+ File.open("./data/#{sheet_key}.puml", 'wb') { |f| f.puts s[:plantuml] }
16
+ File.open("./data/#{sheet_key}_erd.puml", 'wb') { |f| f.puts s[:plantuml_erd] }
17
+
18
+ #https://plantuml.com/elk
19
+ `plantuml -tsvg ./data/#{sheet_key}.puml`
20
+ `gm convert ./data/#{sheet_key}.svg ./data/#{sheet_key}.png`
21
+ `plantuml -tsvg ./data/#{sheet_key}_erd.puml`
22
+ `gm convert ./data/#{sheet_key}_erd.svg ./data/#{sheet_key}_erd.png`