Skip to content

marcelobbfonseca/workflow-api

Repository files navigation

forthebadge Build Status Depfu Depfu License: GPL v3 Average time to resolve an issue Percentage of issues still open

semantic workflow-api

This project is a semantic BPMN workflow API for rails 5.1 and a part of this article . The application comes with rails-admin interface and a view for BPMN modeling tool from bpmn-js. The main goal of this app is to assist the diagram modeling with a domain ontology(.owl file extension). The ontology used for this app was made using PRÓTÉGÉ modeling tool and defines a few tasks inside a newsroom. If theres no interest in using semantic tools, you can still use this project as a Workflow API for Ruby on Rails

preview running in

https://semanticworkflow-api.herokuapp.com/

App architecture

Setting up local development environment

You can setup the project locally installing all requirements or by using docker. Running project with docker containers are a much easier setup and bellow is a step-by-step for both.

Setup with Docker

If you dont have docker installed, create a dockerhub account and follow the instructions to download/Install Docker for your current OS.

Running project

Run app and database containers

docker-compose up -d sql_db
docker-compose up web_api

run migration command inside web_api container

docker-compose exec web_api bash
> rails db:migrate

access application running in localhost:3000

Setup with without docker

Requirements

  • Ruby version: 2.5.3

  • Database: MySQL 5.7

  • Rails version: 5.1

Ruby version can be correctly chosen by installing rvm or rbenv. MySQL also needs to be installed and running. After installing ruby and MySQL install rails.

	gem install rails -v 5.1

Dependencies:

  • Ruby 2.3.3 +
  • Ruby on Rails 5.1 +
  • MySQL 5.7
  • Yarn or npm
  • Node 6.4.0 + How to Use:

1. Start localhost server

	$ git clone https://github.com/marcelobbfonseca/workflow-api.git
	$ cd workflow-api
	$ bundle install

You will need to change MySQL username and password config in workflow-api/config/database.yml to your local MySQL credentials in your machine and remove host. The next step is to run database seed and start local server.

		$ rails db:seed # add users admin, reporter and chief-editor
		$ yarn  # run yarn to compile webpacker
		$ rails server

Access server running in http://localhost:3000

Modeling a new BPD with bpmn-js. Access http://localhost:3000/bpmn/modeler Save file and image localy in yor computer

2.Create Business Process

Select Diagrams ("http://localhost:3000/admin/diagram") Create new diagram using the file and image saved, or just use one of the projects diagrams on bpmn folder. For this study case, upload the diagrama_multi.svg and ProducaoNoticiaWebMulti.bpmn located on workflow-api/bpmn directory.

The MySQL database is already setup. Uploading the diagram xml file("ex:ProducaoDaNoticia.bpmn") as paramater to the framework endpoint will create a business process for it on the relational database. Access the route below to create a Business Process for your diagram.bpmn:

GET http://localhost:3000/bpmn/create.json?name="bpmn_file_name"

For our example we will be using ProducaoDaNoticia.bpmn file, so it will be like this:

GET http://localhost:3000/bpmn/create.json?name=ProducaoDaNoticia

After that it should send a "Business Process Created." message. If you checkout your admin dashboard, there should be 1 new Business Process and all it's tasks and SequenceFlows created.

3.Assign user to a task

Still on admin dashboard click on Tasks ("http://localhost:3000/admin/task") Select the userTask pré-apura pauta to edit and assign user Aroldo, a reporter.

4. Upload Ontology

On admin dashboard, go to Ontologies and select create.("http://localhost:3000/admin/ontology/new") Create a new ontologies with:

The framework is now all setup.

5. Automatic role suggestion

Go to http://localhost:3000/ontologies view and select "show" on the ontology recently created. Just like in step 2. type the diagram name on the form to search the most suitable usertasks role for the diagram's task's. It will make a SparQL querie in the ontology for each usertask on the diagram and show the result in an array.

6. Endpoints

Get Busines Process and all lanes and tasks. 1 = BusinessProcess id

		GET http://localhost:3000/business_processes/1.json

Update Business Process current task to a next task with current_task id=22 and BusinessProcess id=1.

   	PUT http://localhost:3000/business_processes/5.json
   	
		{
   		"business_process":{
   			"current_task_id": 22
   		}
   
   	}

Get task information and existing nexts tasks

   	GET localhost:3000/tasks/26.json

Creates a new Business with bpmn file name as params

   	GET http://localhost:3000/bpmn/create.json?name=ProducaoNoticiaWebMulti

Get user with id = 1 data and all his tasks assigned to.

   	GET http://localhost:3000/users/1.json

Database schema

Database tables

If there's any trouble trying to run the project, create a new issue.

About

Building a BPMN workflow API for rails 5.1

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published