Skip to content

Commit

Permalink
Initial upload
Browse files Browse the repository at this point in the history
  • Loading branch information
deemount committed Mar 10, 2024
1 parent fd2265d commit 1ef2f1f
Show file tree
Hide file tree
Showing 8 changed files with 233 additions and 1 deletion.
14 changes: 14 additions & 0 deletions .github/workflows/gotest.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: Go Test
on:
push:
branches: ["main", "dev"]
pull_request:
branches: ["main"]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.21
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.DS_Store
*.code-workspace
69 changes: 69 additions & 0 deletions .golangci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
linters-settings:
govet:
check-shadowing: true
settings:
printf:
funcs:
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Infof
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Warnf
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Errorf
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Fatalf
gocyclo:
min-complexity: 50
maligned:
suggest-new: true
dupl:
threshold: 100
goconst:
min-len: 2
min-occurrences: 2
misspell:
locale: US
revive:
confidence: 0.8
lll:
line-length: 160
# tab width in spaces. Default to 1.
tab-width: 1
funlen:
lines: 150
statements: 80

linters:
# please, do not use `enable-all`: it's deprecated and will be removed soon.
# inverted configuration with `enable-all` and `disable` is not scalable during updates of golangci-lint
disable-all: true
enable:
- errcheck
- funlen
- goconst
- gocyclo
- gosec
- gosimple
- govet
- ineffassign
- lll
- misspell
- revive
- staticcheck
- typecheck
- unconvert
- unparam
- unused

# don't enable:
# - gochecknoglobals
# - gocognit
# - godox
# - maligned
# - prealloc

run:
skip-dirs: []
# - test/testdata_etc
skip-files:
- ".*_test\\.go$"

issues:
exclude-rules: []
#
25 changes: 24 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,24 @@
# gobpmnCounter
# gobpmnCounter

gobpmnCounter is a tool for counting the elements, shapes and egdes present in a process

## Wiki

The [documentation](https://github.com/deemount/gobpmnCounter/wiki) is now written in the wiki of the respective module

**Start here** [gobpmn](https://github.com/deemount/gobpmn)

## Testing

You can also test the idea behind it directly. Simply follow the link to the lab

+ [gobpmnLab](https://github.com/deemount/gobpmnLab)

## Further Links

+ [gobpmnTypes](https://github.com/deemount/gobpmnTypes)
+ [gobpmnModels](https://github.com/deemount/gobpmnModels)
+ [gobpmnCamunda](https://github.com/deemount/gobpmnCamunda)
+ [gobpmnDiagram](https://github.com/deemount/gobpmnDiagram)
+ [gobpmnBuilder](https://github.com/deemount/gobpmnBuilder)
+ [gobpmnReflection](https://github.com/deemount/gobpmnReflection)
101 changes: 101 additions & 0 deletions counter.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
package gobpmn_counter

import (
"strings"

"github.com/deemount/gobpmnCounter/internals/utils"
)

// Count ...
type Count struct {
Process int
Participant int
Message int
StartEvent int
EndEvent int
BusinessRuleTask int
ManualTask int
ReceiveTask int
ScriptTask int
SendTask int
ServiceTask int
Task int
UserTask int
Flow int
Shape int
Edge int
}

/*
* @Base
*/

// countPool ...
func (c *Count) countPool(field, reflectionField string) {
if strings.ToLower(field) == "pool" {
if strings.Contains(reflectionField, "Process") {
c.Process++
}
if strings.Contains(reflectionField, "ID") {
c.Participant++
c.Shape++
}
}
}

// countMessage ...
func (c *Count) countMessage(field, reflectionField string) {
if strings.ToLower(field) == "message" {
if strings.Contains(reflectionField, "Message") {
c.Message++
c.Edge++
}
}
}

/*
* @Processes
*/

// countProcess ...
func (c *Count) countProcess(field string) {
if strings.Contains(field, "Process") {
c.Process++
}
}

/*
* @Elements
*/

func (c *Count) countElements(field string) {

if utils.After(field, "From") == "" {

switch true {
case strings.Contains(field, "StartEvent"):
c.StartEvent++
case strings.Contains(field, "EndEvent"):
c.EndEvent++
case strings.Contains(field, "BusinessRuleTask"):
c.BusinessRuleTask++
case strings.Contains(field, "ManualTask"):
c.ManualTask++
case strings.Contains(field, "ReceiveTask"):
c.ReceiveTask++
case strings.Contains(field, "ScriptTask"):
c.ScriptTask++
case strings.Contains(field, "SendTask"):
c.SendTask++
case strings.Contains(field, "ServiceTask"):
c.ServiceTask++
case strings.Contains(field, "Task"):
c.Task++
case strings.Contains(field, "UserTask"):
c.UserTask++
}

c.Shape++

}
}
5 changes: 5 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module github.com/deemount/gobpmnCounter

go 1.21.7

require github.com/deemount/gobpmnReflection v0.0.0-20240309120253-66d26591856d
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
github.com/deemount/gobpmnReflection v0.0.0-20240309120253-66d26591856d h1:IW2e4maQjHymwLuETWMtbWH/ndSj1tZaceZAJrF60G8=
github.com/deemount/gobpmnReflection v0.0.0-20240309120253-66d26591856d/go.mod h1:NhbSOQE5lfqYvNkZXsm6xWTq3Wpy5xBPaERNqM/0OgI=
16 changes: 16 additions & 0 deletions internals/utils/strings.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package utils

import "strings"

// After get substring after a string
func After(value string, a string) string {
pos := strings.LastIndex(value, a)
if pos == -1 {
return ""
}
adjustedPos := pos + len(a)
if adjustedPos >= len(value) {
return ""
}
return value[adjustedPos:] //len(value)
}

0 comments on commit 1ef2f1f

Please sign in to comment.