From 3702e21d53f09fc2a26920778164707eb926ea22 Mon Sep 17 00:00:00 2001 From: Salvatore Gonda Date: Mon, 11 Mar 2024 10:31:16 +0100 Subject: [PATCH] Minor changes --- README.md | 8 ++-- pkg/collaboration/Structs.go | 58 ++++++++++++++-------------- pkg/core/Definitions.go | 53 ++++++------------------- pkg/core/Definitions_test.go | 28 ++++++++++++++ pkg/core/Interfaces.go | 5 --- pkg/core/Structs.go | 75 +++++++++++++++++++----------------- pkg/pool/Types.go | 2 + pkg/process/Process.go | 45 +++++++++++----------- 8 files changed, 137 insertions(+), 137 deletions(-) create mode 100644 pkg/core/Definitions_test.go diff --git a/README.md b/README.md index d239164..87c7ab0 100644 --- a/README.md +++ b/README.md @@ -6,9 +6,7 @@ A library of elements and attributes for processes in Business Process Model Not ## Wiki -The documentation is now written in the wiki of the respective module - -[Wiki](https://github.com/deemount/gobpmnModels/wiki) +The [documentation](https://github.com/deemount/gobpmnModels/wiki) is now written in the wiki of the respective module **Start here** [gobpmn](https://github.com/deemount/gobpmn) @@ -20,8 +18,10 @@ You can also test the idea behind it directly. Simply follow the link to the lab ## Modules ++ [gobpmnTypes](https://github.com/deemount/gobpmnTypes) + [gobpmnCamunda](https://github.com/deemount/gobpmnCamunda) + [gobpmnDiagram](https://github.com/deemount/gobpmnDiagram) + [gobpmnBuilder](https://github.com/deemount/gobpmnBuilder) ++ [gobpmnCounter](https://github.com/deemount/gobpmnCounter) ++ [gobpmnHash](https://github.com/deemount/gobpmnHash) + [gobpmnReflection](https://github.com/deemount/gobpmnReflection) -+ [gobpmnTypes](https://github.com/deemount/gobpmnTypes) diff --git a/pkg/collaboration/Structs.go b/pkg/collaboration/Structs.go index 6d5934c..8eb4c87 100644 --- a/pkg/collaboration/Structs.go +++ b/pkg/collaboration/Structs.go @@ -11,34 +11,36 @@ import ( * @Elementary */ -// Collaboration ... -type Collaboration struct { - impl.CoreID - attributes.Attributes - Participant PARTICIPANT_SLC `xml:"bpmn:participant" json:"participant,omitempty"` - MessageFlow flow.MESSAGE_FLOW_SLC `xml:"bpmn:messageFlow,omitempty" json:"messageFlow,omitempty"` -} +type ( + // Collaboration ... + Collaboration struct { + impl.CoreID + attributes.Attributes + Participant PARTICIPANT_SLC `xml:"bpmn:participant" json:"participant,omitempty"` + MessageFlow flow.MESSAGE_FLOW_SLC `xml:"bpmn:messageFlow,omitempty" json:"messageFlow,omitempty"` + } -// TCollaboration ... -type TCollaboration struct { - impl.CoreID - attributes.TAttributes - Participant TPARTICIPANT_SLC `xml:"participant" json:"participant,omitempty"` - MessageFlow flow.TMESSAGE_FLOW_SLC `xml:"messageFlow,omitempty" json:"messageFlow,omitempty"` -} + // TCollaboration ... + TCollaboration struct { + impl.CoreID + attributes.TAttributes + Participant TPARTICIPANT_SLC `xml:"participant" json:"participant,omitempty"` + MessageFlow flow.TMESSAGE_FLOW_SLC `xml:"messageFlow,omitempty" json:"messageFlow,omitempty"` + } -// Participant ... -type Participant struct { - impl.BaseAttributes - ProcessRef string `xml:"processRef,attr,omitempty" json:"processRef,omitempty" csv:"PROCESS_REF"` - Documentation attributes.DOCUMENTATION_SLC `xml:"bpmn:documentation,omitempty" json:"documentation,omitempty" csv:"DOCUMENTATION"` - ParticipantMultiplicity []loop.ParticipantMultiplicity `xml:"bpmn:participantMultiplicity,omitempty" json:"participantMultiplicity,omitempty" csv:"PARTICIPANT_MULTIPLICITY"` -} + // Participant ... + Participant struct { + impl.BaseAttributes + ProcessRef string `xml:"processRef,attr,omitempty" json:"processRef,omitempty" csv:"PROCESS_REF"` + Documentation attributes.DOCUMENTATION_SLC `xml:"bpmn:documentation,omitempty" json:"documentation,omitempty" csv:"DOCUMENTATION"` + ParticipantMultiplicity []loop.ParticipantMultiplicity `xml:"bpmn:participantMultiplicity,omitempty" json:"participantMultiplicity,omitempty" csv:"PARTICIPANT_MULTIPLICITY"` + } -// TParticipant ... -type TParticipant struct { - impl.BaseAttributes - ProcessRef string `xml:"processRef,attr" json:"processRef,omitempty"` - Documentation attributes.DOCUMENTATION_SLC `xml:"documentation,omitempty" json:"documentation,omitempty"` - ParticipantMultiplicity []loop.TParticipantMultiplicity `xml:"participantMultiplicity,omitempty" json:"participantMultiplicity,omitempty"` -} + // TParticipant ... + TParticipant struct { + impl.BaseAttributes + ProcessRef string `xml:"processRef,attr" json:"processRef,omitempty"` + Documentation attributes.DOCUMENTATION_SLC `xml:"documentation,omitempty" json:"documentation,omitempty"` + ParticipantMultiplicity []loop.TParticipantMultiplicity `xml:"participantMultiplicity,omitempty" json:"participantMultiplicity,omitempty"` + } +) diff --git a/pkg/core/Definitions.go b/pkg/core/Definitions.go index 5eae4cc..0192f5e 100644 --- a/pkg/core/Definitions.go +++ b/pkg/core/Definitions.go @@ -8,17 +8,13 @@ import ( "github.com/deemount/gobpmnModels/pkg/events" "github.com/deemount/gobpmnModels/pkg/marker" "github.com/deemount/gobpmnModels/pkg/process" - impl "github.com/deemount/gobpmnTypes" + gobpmnTypes "github.com/deemount/gobpmnTypes" ) var ( - schemaBpmnModel = "http://www.omg.org/spec/BPMN/20100524/MODEL" - schemaBpmn20 = "http://www.omg.org/spec/BPMN/2.0/20100501/BPMN20.xsd" - schemaBpmn20_HTTPS = "https://www.omg.org/spec/BPMN/20100501/BPMN20.xsd" - schemaOMGDC = "http://www.omg.org/spec/DD/20100524/DC" - schemaBpmnIOSchema = "http://bpmn.io/schema/bpmn" - schemaW3XmlSchema = "http://www.w3.org/2001/XMLSchema" - schemaW3XmlSchemaInstance = "http://www.w3.org/2001/XMLSchema-instance" + schemaOMGBpmnModel = "http://www.omg.org/spec/BPMN/20100524/MODEL" + schemaOMGDC = "http://www.omg.org/spec/DD/20100524/DC" + schemaBpmnIOSchema = "http://bpmn.io/schema/bpmn" ) // NewDefinitions ... @@ -34,9 +30,14 @@ func NewDefinitions() DefinitionsRepository { /** BPMN **/ +// SetID ... +func (definitions *Definitions) SetID(typ string, suffix interface{}) { + definitions.ID = SetID(typ, suffix) +} + // SetBpmn ... func (definitions *Definitions) SetBpmn() { - definitions.Bpmn = schemaBpmnModel + definitions.Bpmn = schemaOMGBpmnModel } // SetDC ... @@ -44,36 +45,6 @@ func (definitions *Definitions) SetDC() { definitions.DC = schemaOMGDC } -// SetOmgDC ... -func (definitions *Definitions) SetOmgDC() { - definitions.OmgDC = schemaOMGDC -} - -// SetXSD ... -func (definitions *Definitions) SetXSD() { - definitions.Xsd = schemaW3XmlSchema -} - -// SetXSI ... -func (definitions *Definitions) SetXSI() { - definitions.Xsi = schemaW3XmlSchemaInstance -} - -// SetXsiSchemaLocation ... -func (definitions *Definitions) SetXsiSchemaLocation() { - definitions.XsiSchemaLocation = fmt.Sprintf("%s %s", schemaBpmnModel, schemaBpmn20) -} - -// SetXsiSchemaLocation ... -func (definitions *Definitions) SetXsiSchemaLocationHTTPS() { - definitions.XsiSchemaLocation = fmt.Sprintf("%s %s", schemaBpmnModel, schemaBpmn20_HTTPS) -} - -// SetID ... -func (definitions *Definitions) SetID(typ string, suffix interface{}) { - definitions.ID = SetID(typ, suffix) -} - // SetTargetNamespace ... func (definitions *Definitions) SetTargetNamespace() { definitions.TargetNamespace = schemaBpmnIOSchema @@ -117,7 +88,7 @@ func (definitions *Definitions) SetSignal(num int) { * @Settings */ -// SetDefinitionsAttributes ... +// SetDefaultAttributes ... func (definitions *Definitions) SetDefaultAttributes() { definitionsHash := utils.GenerateHash() definitions.SetBpmn() @@ -141,7 +112,7 @@ func (definitions *Definitions) SetMainElements(num int) { /** BPMN **/ // GetID ... -func (definitions Definitions) GetID() impl.STR_PTR { +func (definitions Definitions) GetID() gobpmnTypes.STR_PTR { return &definitions.ID } diff --git a/pkg/core/Definitions_test.go b/pkg/core/Definitions_test.go new file mode 100644 index 0000000..b09491d --- /dev/null +++ b/pkg/core/Definitions_test.go @@ -0,0 +1,28 @@ +package core + +import ( + "testing" +) + +func TestDefinitionsRepository(t *testing.T) { + // create a new repository + repo := NewDefinitions() + t.Logf("result of repo is %v", repo) + // check if the repository is not nil + if repo == nil { + t.Errorf("expected a repository, got nil") + } +} + +func TestDefinitionsRepositoryID(t *testing.T) { + // create a new repository + repo := NewDefinitions() + repo.SetID("definitions", "1234") + repo.SetCollaboration() + repo.SetProcess(0) + t.Logf("result of repo is %v", repo) + // check if the repository has the correct id + if *repo.GetID() != "Definitions_1234" { + t.Errorf("expected a correct id, got something else") + } +} diff --git a/pkg/core/Interfaces.go b/pkg/core/Interfaces.go index e46bcd7..4b36753 100644 --- a/pkg/core/Interfaces.go +++ b/pkg/core/Interfaces.go @@ -33,11 +33,6 @@ type DefinitionsRepository interface { DefinitionsElements SetBpmn() SetDC() - SetOmgDC() - SetXSD() - SetXSI() - SetXsiSchemaLocation() - SetXsiSchemaLocationHTTPS() SetTargetNamespace() SetMainElements(num int) SetDefaultAttributes() diff --git a/pkg/core/Structs.go b/pkg/core/Structs.go index 295d265..65b1823 100644 --- a/pkg/core/Structs.go +++ b/pkg/core/Structs.go @@ -9,39 +9,42 @@ import ( "github.com/deemount/gobpmnModels/pkg/process" ) -// DefinitionsBaseElements ... -type DefinitionsBaseElements struct { - Collaboration collaboration.COLLABORATION_SLC `xml:"bpmn:collaboration,omitempty" json:"collaboration"` - Process process.PROCESS_SLC `xml:"bpmn:process,omitempty" json:"process"` - Category marker.CATEGORY_SLC `xml:"bpmn:category,omitempty" json:"category,omitempty"` - events.CoreEvents -} - -// TDefinitionsBaseElements ... -type TDefinitionsBaseElements struct { - Collaboration collaboration.TCOLLABORATION_SLC `xml:"collaboration,omitempty" json:"collaboration"` - Process process.TPROCESS_SLC `xml:"process,omitempty" json:"process"` - Category marker.TCATEGORY_SLC `xml:"category,omitempty" json:"category,omitempty"` - events.TCoreEvents -} - -// Definitions represents the root element -type Definitions struct { - XMLName xml.Name `xml:"bpmn:definitions" json:"-"` - Bpmn string `xml:"xmlns:bpmn,attr" json:"-"` - Xsd string `xml:"xmlns:xsd,attr,omitempty" json:"-"` - Xsi string `xml:"xmlns:xsi,omitempty" json:"-"` - XsiSchemaLocation string `xml:"xsi:schemaLocation,attr,omitempty" json:"-"` - DC string `xml:"xmlns:dc,attr,omitempty" json:"-"` - OmgDC string `xml:"xmlns:omgdc,attr,omitempty" json:"-"` - ID string `xml:"id,attr" json:"id"` - TargetNamespace string `xml:"targetNamespace,attr" json:"-"` - DefinitionsBaseElements -} - -// TDefinitions ... -type TDefinitions struct { - XMLName xml.Name `xml:"definitions" json:"-"` - ID string `xml:"id,attr" json:"id"` - TDefinitionsBaseElements -} +type ( + + // DefinitionsBaseElements ... + DefinitionsBaseElements struct { + Collaboration collaboration.COLLABORATION_SLC `xml:"bpmn:collaboration,omitempty" json:"collaboration"` + Process process.PROCESS_SLC `xml:"bpmn:process,omitempty" json:"process"` + Category marker.CATEGORY_SLC `xml:"bpmn:category,omitempty" json:"category,omitempty"` + events.CoreEvents + } + + // TDefinitionsBaseElements ... + TDefinitionsBaseElements struct { + Collaboration collaboration.TCOLLABORATION_SLC `xml:"collaboration,omitempty" json:"collaboration"` + Process process.TPROCESS_SLC `xml:"process,omitempty" json:"process"` + Category marker.TCATEGORY_SLC `xml:"category,omitempty" json:"category,omitempty"` + events.TCoreEvents + } + + /* + * @Elementary + */ + + // Definitions represents the root element + Definitions struct { + XMLName xml.Name `xml:"bpmn:definitions" json:"-"` + Bpmn string `xml:"xmlns:bpmn,attr" json:"-"` + DC string `xml:"xmlns:dc,attr,omitempty" json:"-"` + ID string `xml:"id,attr" json:"id"` + TargetNamespace string `xml:"targetNamespace,attr" json:"-"` + DefinitionsBaseElements + } + + // TDefinitions ... + TDefinitions struct { + XMLName xml.Name `xml:"definitions" json:"-"` + ID string `xml:"id,attr" json:"id"` + TDefinitionsBaseElements + } +) diff --git a/pkg/pool/Types.go b/pkg/pool/Types.go index 0eb29f1..da98eb4 100644 --- a/pkg/pool/Types.go +++ b/pkg/pool/Types.go @@ -6,8 +6,10 @@ package pool type FLOWNODEREF_SLC []FlowNodeRef type LANE_SLC []Lane +type LANE_SET_SLC []LaneSet type TLANE_SLC []TLane +type TLANE_SET_SLC []TLaneSet /* * @Pointers diff --git a/pkg/process/Process.go b/pkg/process/Process.go index cbae8e5..00d361d 100644 --- a/pkg/process/Process.go +++ b/pkg/process/Process.go @@ -4,7 +4,6 @@ import ( "github.com/deemount/gobpmnModels/pkg/attributes" "github.com/deemount/gobpmnModels/pkg/data" "github.com/deemount/gobpmnModels/pkg/events" - "github.com/deemount/gobpmnModels/pkg/events/elements" "github.com/deemount/gobpmnModels/pkg/flow" "github.com/deemount/gobpmnModels/pkg/gateways" "github.com/deemount/gobpmnModels/pkg/pool" @@ -56,19 +55,19 @@ func (process *Process) SetDocumentation() { // SetLaneSet ... func (process *Process) SetLaneSet() { - process.LaneSet = make([]pool.LaneSet, 1) + process.LaneSet = make(pool.LANE_SET_SLC, 1) } /*** Events ***/ // SetStartEvent ... func (process *Process) SetStartEvent(num int) { - process.StartEvent = make([]elements.StartEvent, num) + process.StartEvent = make(events.START_EVENT_SLC, num) } // SetBoundaryEvent ... func (process *Process) SetBoundaryEvent(num int) { - process.BoundaryEvent = make([]elements.BoundaryEvent, num) + process.BoundaryEvent = make(events.BOUNDARY_EVENT_SLC, num) } // SetEndEvent ... @@ -78,103 +77,103 @@ func (process *Process) SetEndEvent(num int) { // SetIntermedCatchEvent ... func (process *Process) SetIntermediateCatchEvent(num int) { - process.IntermediateCatchEvent = make([]elements.IntermediateCatchEvent, num) + process.IntermediateCatchEvent = make(events.INTERMEDIATE_CATCH_EVENT_SLC, num) } // SetIntermedThrowEvent ... func (process *Process) SetIntermediateThrowEvent(num int) { - process.IntermediateThrowEvent = make([]elements.IntermediateThrowEvent, num) + process.IntermediateThrowEvent = make(events.INTERMEDIATE_THROW_EVENT_SLC, num) } /*** Tasks ***/ // SetBusinessRuleTask ... func (process *Process) SetBusinessRuleTask(num int) { - process.BusinessRuleTask = make([]tasks.BusinessRuleTask, num) + process.BusinessRuleTask = make(tasks.BUSINESS_RULE_TASK_SLC, num) } // SetTask ... func (process *Process) SetTask(num int) { - process.Task = make([]tasks.Task, num) + process.Task = make(tasks.TASK_SLC, num) } // SetUserTask ... func (process *Process) SetUserTask(num int) { - process.UserTask = make([]tasks.UserTask, num) + process.UserTask = make(tasks.USER_TASK_SLC, num) } // SetManualTask ... func (process *Process) SetManualTask(num int) { - process.ManualTask = make([]tasks.ManualTask, num) + process.ManualTask = make(tasks.MANUAL_TASK_SLC, num) } // SetReceiveTask ... func (process *Process) SetReceiveTask(num int) { - process.ReceiveTask = make([]tasks.ReceiveTask, num) + process.ReceiveTask = make(tasks.RECEIVE_TASK_SLC, num) } // SetScriptTask ... func (process *Process) SetScriptTask(num int) { - process.ScriptTask = make([]tasks.ScriptTask, num) + process.ScriptTask = make(tasks.SCRIPT_TASK_SLC, num) } // SetSendTask ... func (process *Process) SetSendTask(num int) { - process.SendTask = make([]tasks.SendTask, num) + process.SendTask = make(tasks.SEND_TASK_SLC, num) } // SetServiceTask ... func (process *Process) SetServiceTask(num int) { - process.ServiceTask = make([]tasks.ServiceTask, num) + process.ServiceTask = make(tasks.SERVICE_TASK_SLC, num) } /*** Subprocesses ***/ // SetCallActivity ... func (process *Process) SetCallActivity(num int) { - process.CallActivity = make([]subprocesses.CallActivity, num) + process.CallActivity = make(subprocesses.CALL_ACTIVITY_SLC, num) } // SetSubProcess ... func (process *Process) SetSubProcess(num int) { - process.SubProcess = make([]subprocesses.SubProcess, num) + process.SubProcess = make(subprocesses.SUBPROCESS_SLC, num) } // SetTransaction ... func (process *Process) SetTransaction(num int) { - process.Transaction = make([]subprocesses.Transaction, num) + process.Transaction = make(subprocesses.TRANSACTION_SLC, num) } // SetAdHocSubProcess ... func (process *Process) SetAdHocSubProcess(num int) { - process.AdHocSubProcess = make([]subprocesses.AdHocSubProcess, num) + process.AdHocSubProcess = make(subprocesses.ADHOC_SUBPROCESS_SLC, num) } /*** Gateways ***/ // SetExclusiveGateway func (process *Process) SetExclusiveGateway(num int) { - process.ExclusiveGateway = make([]gateways.ExclusiveGateway, num) + process.ExclusiveGateway = make(gateways.EXCLUSIVE_GATEWAY_SLC, num) } // SetInclsuiveGateway func (process *Process) SetInclusiveGateway(num int) { - process.InclusiveGateway = make([]gateways.InclusiveGateway, num) + process.InclusiveGateway = make(gateways.INCLUSIVE_GATEWAY_SLC, num) } // SetParallelGateway func (process *Process) SetParallelGateway(num int) { - process.ParallelGateway = make([]gateways.ParallelGateway, num) + process.ParallelGateway = make(gateways.PARALLEL_GATEWAY_SLC, num) } // SetComplexGateway func (process *Process) SetComplexGateway(num int) { - process.ComplexGateway = make([]gateways.ComplexGateway, num) + process.ComplexGateway = make(gateways.COMPLEX_GATEWAY_SLC, num) } // SetEventBasedGateway func (process *Process) SetEventBasedGateway(num int) { - process.EventBasedGateway = make([]gateways.EventBasedGateway, num) + process.EventBasedGateway = make(gateways.EVENT_BASED_GATEWAYS_SLC, num) } /*** Marker ***/