agentbellnorm / dativity Goto Github PK
View Code? Open in Web Editor NEWdata driven, stateless, process engine
License: MIT License
data driven, stateless, process engine
License: MIT License
Great work!
Idea, to make the creation of the graph less verbose, a little "data dsl" would work great.
Given:
(def case-model-dsl
'[
;; roles
applicant is-a role
system is-a role
officer is-a role
;; actions
create-case is-a action
enter-loan-details is-a action
produce-credit-application-document is-a action
sign-credit-application-document is-a action
payout-loan is-a action
;; data
case-id is-a data
customer-id is-a data
loan-details is-a data
credit-application-document is-a data
applicant-signature is-a data
officer-signature is-a data
loan-number is-a data
;; actions relationships
create-case produces customer-id
create-case produces case-id
enter-loan-details produces loan-details
enter-loan-details requires case-id
produce-credit-application-document produces credit-application-document
produce-credit-application-document requires loan-details
produce-credit-application-document requires customer-id
sign-credit-application-document produces applicant-signature
sign-credit-application-document produces officer-signature
sign-credit-application-document requires credit-application-document
payout-loan produces loan-number
payout-loan requires applicant-signature
payout-loan requires officer-signature
;; role-action edges
applicant performs create-case
applicant performs enter-loan-details
applicant performs sign-credit-application-document
officer performs sign-credit-application-document
system performs payout-loan
system performs produce-credit-application-document])
we can transform it into code easily. Here is an example using core.match,
but maybe a little parser based on spec could be a better option ( will play with that when i have time ).
disclaimer: first time using core.match ;)
(defn from-dsl
[model dsl]
(reduce
(fn [acc [from _ to :as i]]
(m/match i
[_ :is-a :action] (dativity.define/add-entity-to-model acc (dativity.define/action from))
[_ :is-a :data] (dativity.define/add-entity-to-model acc (dativity.define/data from))
[_ :is-a :role] (dativity.define/add-entity-to-model acc (dativity.define/role from))
[_ :requires _] (dativity.define/add-relationship-to-model acc (dativity.define/action-requires from to))
[_ :produces _] (dativity.define/add-relationship-to-model acc (dativity.define/action-produces from to))
[_ :performs _] (dativity.define/add-relationship-to-model acc (dativity.define/role-performs from to))
:else "todo/look into errors"
))
model (map vec (partition 3 (map keyword dsl)))))
and used
(from-dsl (dativity.define/empty-case-model) case-model-dsl)
Here is a pic of this approach working in my live editor and visualising it using cytoscape so you can interactively create the graphs.
I will play also with adding visualization of process progress and adding a UI on top to perform actions etc...
Lovely work and very clean and understandable code.
May I suggest renaming actions-performed-by-role
. I immediately assumed that it would return the actions actually performed by a certain role, as opposed to the actions allowed by a specific role. This especially because of actions-performed
which returns all performed actions.
I'm considering removing the dependency from cljc-code.
There should be an edge type that describes a relation between data and action that makes an action possible/allowed if a given data is present, and a predicate function is true.
An example where this would be useful is for example in a model of a legal process. The two actions 'release' and 'serve-punishment' would never both be relevant. Only one of them would be applicable depending on the result of a predicate function that takes the data 'verdict'
I think this is an important feature that the library has been missing that really allows you to model logic gateways.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.