builder

package
v0.9.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 17, 2024 License: Apache-2.0 Imports: 16 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddElementToProcess added in v0.9.0

func AddElementToProcess(process *Process, xe any, elementType, elementId string) error

AddElementToProcess creates a new element based on the XML element, type, and id and adds it to the current process and lookup for all elements in the process

func AddElementToSubProcess added in v0.9.0

func AddElementToSubProcess(process *Process, subprocess *SubProcess, xe any, elementType, elementId string) error

AddElementToSubProcess creates a new element based on the XML element, type, and id and adds it to the current subprocess and lookup for all elements in the process

func CreateElements added in v0.9.0

func CreateElements(process *Process, subprocess *SubProcess, spElements *XMLSubProcess, elements *XMLBPMNElements, ps *ProcessorSet) error

CreateElements executes the element processors to create elements based on the XML BPMN elements. The elements are used for code generattion.

func GenerateCode added in v0.9.0

func GenerateCode(process *Process, defs *XMLBPMNElements, ps *ProcessorSet)

GenerateCode generates the code for a process by sequentially calling the element processors in order. Order can matter in some cases such as subprocesses.

func GenerateCodeForSingleOutgoingElement added in v0.9.0

func GenerateCodeForSingleOutgoingElement(currentElement *Element, outgoingElements []*Element, process *Process, ps *ProcessorSet) string

GenerateCodeForSingleOutgoingElement generates the code for the current element assuming there is only one outgoing element.

func GenerateNextStateCode added in v0.9.0

func GenerateNextStateCode(element any, process *Process, processor ElementProcessor, ps *ProcessorSet)

GenerateNextStateCode generates the code for the next state that comes after the current BPMN element

func GetModuleName added in v0.9.0

func GetModuleName(fileName string) (string, error)

GetModuleName gets the name of a module given a fileName for the go.mod

func IsBPMN

func IsBPMN(input string) bool

IsBPMN determines if an input is a bpmn file based on the extension

func IsDir

func IsDir(input string) bool

IsDir checks if an input is a directory

Types

type Element

type Element struct {
	Id            string
	Name          string
	BpmnType      string
	XMLElement    any
	NextStateCode string
}

func GetProcessElement added in v0.9.0

func GetProcessElement(element any, process *Process) *Element

GetProcessElement looks up an element in a process by element id

func GetProcessOutgoingElements added in v0.9.0

func GetProcessOutgoingElements(element any, process *Process) []*Element

GetProcessOutgoingElements returns the outgoing elements for an element. If there are no outgoing elements it returns nil

func NewElement

func NewElement(elementType string, src any) (*Element, error)

NewElement creates a new element of a given BPMN type and xml src object

type ElementProcessor added in v0.9.0

type ElementProcessor interface {
	// CreateElements creates new elements and adds them to the process and/or subprocess for the given element BPMN processor type
	CreateElements(process *Process, subprocess *SubProcess, spElements *XMLSubProcess, elements *XMLBPMNElements, ps *ProcessorSet) error
	// GenerateElementNextStateCodes generates the code for the next state for each element of the element BPMN processor type
	GenerateElementNextStateCodes(process *Process, defs *XMLBPMNElements, ps *ProcessorSet)
	// GenerateNextStateCode generates the code of the next elements for the current element
	GenerateNextStateCode(currentElement *Element, nextElements []*Element, process *Process, ps *ProcessorSet) string
	// GenerateCodeForNewElement generates code for a new instance of this BPMN element
	GenerateCodeForNewElement(currentElement, newElement *Element, process *Process, ps *ProcessorSet) string
}

ElementProcessor generates code for a specific BPMN element type

type EndEventProcessor added in v0.9.0

type EndEventProcessor struct {
}

func (EndEventProcessor) CreateElements added in v0.9.0

func (ep EndEventProcessor) CreateElements(p *Process, subprocess *SubProcess, spElements *XMLSubProcess, elements *XMLBPMNElements, ps *ProcessorSet) error

func (EndEventProcessor) GenerateCodeForNewElement added in v0.9.0

func (ep EndEventProcessor) GenerateCodeForNewElement(currentElement, newElement *Element, process *Process, ps *ProcessorSet) string

func (EndEventProcessor) GenerateElementNextStateCodes added in v0.9.0

func (ep EndEventProcessor) GenerateElementNextStateCodes(process *Process, defs *XMLBPMNElements, ps *ProcessorSet)

func (EndEventProcessor) GenerateNextStateCode added in v0.9.0

func (ep EndEventProcessor) GenerateNextStateCode(currentElement *Element, nextElements []*Element, process *Process, ps *ProcessorSet) string

type ExclusiveGatewayProcessor added in v0.9.0

type ExclusiveGatewayProcessor struct {
}

func (ExclusiveGatewayProcessor) CreateElements added in v0.9.0

func (ep ExclusiveGatewayProcessor) CreateElements(p *Process, subprocess *SubProcess, spElements *XMLSubProcess, elements *XMLBPMNElements, ps *ProcessorSet) error

func (ExclusiveGatewayProcessor) GenerateCodeForNewElement added in v0.9.0

func (ep ExclusiveGatewayProcessor) GenerateCodeForNewElement(currentElement, newElement *Element, process *Process, ps *ProcessorSet) string

func (ExclusiveGatewayProcessor) GenerateElementNextStateCodes added in v0.9.0

func (ep ExclusiveGatewayProcessor) GenerateElementNextStateCodes(process *Process, defs *XMLBPMNElements, ps *ProcessorSet)

func (ExclusiveGatewayProcessor) GenerateNextStateCode added in v0.9.0

func (ep ExclusiveGatewayProcessor) GenerateNextStateCode(currentElement *Element, nextElements []*Element, process *Process, ps *ProcessorSet) string

type IDName

type IDName interface {
	GetId() string
	GetName() string
}

type Incoming

type Incoming interface {
	GetIncoming() []string
}

type Outgoing

type Outgoing interface {
	GetOutgoing() []string
}

type OutputDefProcessCode

type OutputDefProcessCode struct {
	InputFile  string // Input BPMN file path including file name
	OutputFile string // Output go code path including file name
	Defs       *XMLBPMNDefinitions
	OutputCode *ProcessCode // Output code
	PkgName    string
}

type ParallelGatewayProcessor added in v0.9.0

type ParallelGatewayProcessor struct {
}

func (ParallelGatewayProcessor) CreateElements added in v0.9.0

func (pp ParallelGatewayProcessor) CreateElements(p *Process, subprocess *SubProcess, spElements *XMLSubProcess, elements *XMLBPMNElements, ps *ProcessorSet) error

func (ParallelGatewayProcessor) GenerateCodeForNewElement added in v0.9.0

func (pp ParallelGatewayProcessor) GenerateCodeForNewElement(currentElement, newElement *Element, process *Process, ps *ProcessorSet) string

func (ParallelGatewayProcessor) GenerateElementNextStateCodes added in v0.9.0

func (pp ParallelGatewayProcessor) GenerateElementNextStateCodes(process *Process, defs *XMLBPMNElements, ps *ProcessorSet)

func (ParallelGatewayProcessor) GenerateNextStateCode added in v0.9.0

func (pp ParallelGatewayProcessor) GenerateNextStateCode(currentElement *Element, nextElements []*Element, process *Process, ps *ProcessorSet) string

type Process

type Process struct {
	Id           string
	Name         string
	StartEvent   *Element
	Elements     []*Element
	AllElements  []*Element
	SubProcesses []*SubProcess
	UserTasks    []*Element

	GoModule            string
	GoPackage           string
	GoStartVariableName string
	GoStartVariableType string
	// contains filtered or unexported fields
}

type ProcessCode

type ProcessCode struct {
	Process *Process
	Code    *string
}

type ProcessGenerator

type ProcessGenerator struct {
	// Input BPMN file or path to process BPMN files
	Input string

	// Output BPMN file or path for generated code
	Output string

	// Generates the output file path/name for a given input file, and the input/output args.
	OutputFileNameGenerator func(inputFile string, process *XMLBPMNProcess, input, output string, isOutputDir bool) string

	// Stores output definitions and code given input file path and name
	OutputGen map[string]*OutputDefProcessCode

	ProcessTemplate string
	ProcessorSet    *ProcessorSet
	PackageName     string
}

ProcessGenerator generates go code for a process

func NewProcessGenerator

func NewProcessGenerator(input, output string) *ProcessGenerator

func (*ProcessGenerator) GenerateAndWriteCodeFromBPMN

func (p *ProcessGenerator) GenerateAndWriteCodeFromBPMN() error

type ProcessorSet added in v0.9.0

type ProcessorSet struct {
	ElementProcessors   []ElementProcessor          // Ordered sequence of element processors
	ElementProcessorMap map[string]ElementProcessor // Look up processors by key
}

ProcessorSet contains a set of processors

func NewDefaultProcessorSet added in v0.9.0

func NewDefaultProcessorSet() *ProcessorSet

NewDefaultProcessorSet creates the default processor set

func NewProcessorSet added in v0.9.0

func NewProcessorSet() *ProcessorSet

NewProcessorSet creates an empty processor set. A custom set of element processors may be created by calling AddElementProcessor

func (*ProcessorSet) AddElementProcessor added in v0.9.0

func (p *ProcessorSet) AddElementProcessor(elementType string, e ElementProcessor)

AddElementProcessor adds an element processor to be executed by the code generator in the order they are added. Order may matter for some processors such as subprocesses.

func (*ProcessorSet) SetElementProcessor added in v0.9.0

func (p *ProcessorSet) SetElementProcessor(elementType string, e ElementProcessor)

SetElementProcessor sets the processor for a specific element type. If a processor already exists, it is replaced with the processor passed in

type Script

type Script interface {
	GetScript() string
}

type ScriptProcessor added in v0.9.0

type ScriptProcessor struct {
}

func (ScriptProcessor) CreateElements added in v0.9.0

func (sp ScriptProcessor) CreateElements(p *Process, subprocess *SubProcess, spElements *XMLSubProcess, elements *XMLBPMNElements, ps *ProcessorSet) error

func (ScriptProcessor) GenerateCodeForNewElement added in v0.9.0

func (sp ScriptProcessor) GenerateCodeForNewElement(currentElement, newElement *Element, process *Process, ps *ProcessorSet) string

func (ScriptProcessor) GenerateElementNextStateCodes added in v0.9.0

func (sp ScriptProcessor) GenerateElementNextStateCodes(process *Process, defs *XMLBPMNElements, ps *ProcessorSet)

func (ScriptProcessor) GenerateNextStateCode added in v0.9.0

func (sp ScriptProcessor) GenerateNextStateCode(currentElement *Element, nextElements []*Element, process *Process, ps *ProcessorSet) string

type SequenceFlowProcessor added in v0.9.0

type SequenceFlowProcessor struct {
}

func (SequenceFlowProcessor) CreateElements added in v0.9.0

func (sf SequenceFlowProcessor) CreateElements(p *Process, subprocess *SubProcess, spElements *XMLSubProcess, elements *XMLBPMNElements, ps *ProcessorSet) error

func (SequenceFlowProcessor) GenerateCodeForNewElement added in v0.9.0

func (sf SequenceFlowProcessor) GenerateCodeForNewElement(currentElement, newElement *Element, process *Process, ps *ProcessorSet) string

func (SequenceFlowProcessor) GenerateElementNextStateCodes added in v0.9.0

func (sf SequenceFlowProcessor) GenerateElementNextStateCodes(process *Process, defs *XMLBPMNElements, ps *ProcessorSet)

func (SequenceFlowProcessor) GenerateNextStateCode added in v0.9.0

func (sf SequenceFlowProcessor) GenerateNextStateCode(currentElement *Element, nextElements []*Element, process *Process, ps *ProcessorSet) string

type StartEventProcessor added in v0.9.0

type StartEventProcessor struct {
}

func (StartEventProcessor) CreateElements added in v0.9.0

func (sp StartEventProcessor) CreateElements(p *Process, subprocess *SubProcess, spElements *XMLSubProcess, elements *XMLBPMNElements, ps *ProcessorSet) error

func (StartEventProcessor) GenerateCodeForNewElement added in v0.9.0

func (sp StartEventProcessor) GenerateCodeForNewElement(currentElement, newElement *Element, process *Process, ps *ProcessorSet) string

func (StartEventProcessor) GenerateElementNextStateCodes added in v0.9.0

func (sp StartEventProcessor) GenerateElementNextStateCodes(process *Process, defs *XMLBPMNElements, ps *ProcessorSet)

func (StartEventProcessor) GenerateNextStateCode added in v0.9.0

func (sp StartEventProcessor) GenerateNextStateCode(currentElement *Element, nextElements []*Element, process *Process, ps *ProcessorSet) string

type SubProcess added in v0.7.0

type SubProcess struct {
	Id           string
	Name         string
	Elements     []*Element
	SubProcesses []*SubProcess
	// contains filtered or unexported fields
}

type SubProcessProcessor added in v0.9.0

type SubProcessProcessor struct {
}

func (SubProcessProcessor) CreateElements added in v0.9.0

func (s SubProcessProcessor) CreateElements(process *Process, subprocess *SubProcess, spElements *XMLSubProcess, elements *XMLBPMNElements, ps *ProcessorSet) error

func (SubProcessProcessor) GenerateCodeForNewElement added in v0.9.0

func (s SubProcessProcessor) GenerateCodeForNewElement(currentElement, newElement *Element, process *Process, ps *ProcessorSet) string

func (SubProcessProcessor) GenerateElementNextStateCodes added in v0.9.0

func (s SubProcessProcessor) GenerateElementNextStateCodes(process *Process, defs *XMLBPMNElements, ps *ProcessorSet)

func (SubProcessProcessor) GenerateNextStateCode added in v0.9.0

func (s SubProcessProcessor) GenerateNextStateCode(currentElement *Element, nextElements []*Element, process *Process, ps *ProcessorSet) string

type UserTaskProcessor added in v0.9.0

type UserTaskProcessor struct {
}

func (UserTaskProcessor) CreateElements added in v0.9.0

func (up UserTaskProcessor) CreateElements(p *Process, subprocess *SubProcess, spElements *XMLSubProcess, elements *XMLBPMNElements, ps *ProcessorSet) error

func (UserTaskProcessor) GenerateCodeForNewElement added in v0.9.0

func (up UserTaskProcessor) GenerateCodeForNewElement(currentElement, newElement *Element, process *Process, ps *ProcessorSet) string

func (UserTaskProcessor) GenerateElementNextStateCodes added in v0.9.0

func (up UserTaskProcessor) GenerateElementNextStateCodes(process *Process, defs *XMLBPMNElements, ps *ProcessorSet)

func (UserTaskProcessor) GenerateNextStateCode added in v0.9.0

func (up UserTaskProcessor) GenerateNextStateCode(currentElement *Element, nextElements []*Element, process *Process, ps *ProcessorSet) string

type XMLBPMNDefinitions

type XMLBPMNDefinitions struct {
	XMLName xml.Name       `xml:"definitions"`
	Process XMLBPMNProcess `xml:"process"`
}

type XMLBPMNElements added in v0.7.0

type XMLBPMNElements struct {
	StartEvents       []XMLBPMNStartEvent   `xml:"startEvent"`
	ExclusiveGateways []XMLExclusiveGateway `xml:"exclusiveGateway"`
	ParallelGateways  []XMLParallelGateway  `xml:"parallelGateway"`
	SequenceFlows     []XMLSequenceFlow     `xml:"sequenceFlow"`
	UserTasks         []XMLUserTask         `xml:"userTask"`
	EndEvents         []XMLEndEvent         `xml:"endEvent"`
	ScriptTasks       []XMLScriptTask       `xml:"scriptTask"`
	SubProcesses      []XMLSubProcess       `xml:"subProcess"`
}

type XMLBPMNProcess

type XMLBPMNProcess struct {
	XMLIDName
	XMLBPMNElements
	XMLName             xml.Name `xml:"process"`
	GoModule            string   `xml:"module,attr"`
	GoPackage           string   `xml:"package,attr"`
	GoStartVariableName string   `xml:"startVariableName,attr"`
	GoStartVariableType string   `xml:"startVariableType,attr"`
}

type XMLBPMNStartEvent

type XMLBPMNStartEvent struct {
	XMLName xml.Name `xml:"startEvent"`
	XMLIDName
	XMLOutgoingElements
	TimerEventDefinition XMLTimerEventDefinition `xml:"timerEventDefinition"`
}

type XMLConditionExpression

type XMLConditionExpression struct {
	XMLName             xml.Name `xml:"conditionExpression"`
	Type                string   `xml:"type,attr"`
	ConditionExpression string   `xml:"conditionExpression"`
}

type XMLEndEvent

type XMLEndEvent struct {
	XMLIDName
	XMLIncomingElements
	XMLName xml.Name `xml:"endEvent"`
}

type XMLExclusiveGateway

type XMLExclusiveGateway struct {
	XMLIDName
	XMLIncomingElements
	XMLOutgoingElements
	XMLName xml.Name `xml:"exclusiveGateway"`
	Default string   `xml:"default,attr"`
}

type XMLIDName

type XMLIDName struct {
	Id   string `xml:"id,attr"`
	Name string `xml:"name,attr"`
}

func (*XMLIDName) GetId

func (x *XMLIDName) GetId() string

func (*XMLIDName) GetName

func (x *XMLIDName) GetName() string

type XMLIncomingElements

type XMLIncomingElements struct {
	Incoming []string `xml:"incoming"`
}

func (*XMLIncomingElements) GetIncoming

func (e *XMLIncomingElements) GetIncoming() []string

type XMLMultiInstanceLoopCharacteristics added in v0.7.0

type XMLMultiInstanceLoopCharacteristics struct {
	IsSequentialAtt    string `xml:"isSequential,attr"`
	LoopCardinalityAtt string `xml:"loopCardinality"`
}

type XMLOutgoingElements

type XMLOutgoingElements struct {
	Outgoing []string `xml:"outgoing"`
}

func (*XMLOutgoingElements) GetOutgoing

func (e *XMLOutgoingElements) GetOutgoing() []string

type XMLParallelGateway

type XMLParallelGateway struct {
	XMLIDName
	XMLIncomingElements
	XMLOutgoingElements
	XMLName xml.Name `xml:"parallelGateway"`
}

type XMLScript

type XMLScript struct {
	Script string `xml:"script"`
}

func (*XMLScript) GetScript

func (s *XMLScript) GetScript() string

type XMLScriptTask

type XMLScriptTask struct {
	XMLIDName
	XMLIncomingElements
	XMLOutgoingElements
	XMLScript
	XMLName xml.Name `xml:"scriptTask"`
}

type XMLSequenceFlow

type XMLSequenceFlow struct {
	XMLIDName
	XMLConditionExpression
	XMLName   xml.Name `xml:"sequenceFlow"`
	SourceRef string   `xml:"sourceRef,attr"`
	TargetRef string   `xml:"targetRef,attr"`
}

func (*XMLSequenceFlow) GetOutgoing

func (x *XMLSequenceFlow) GetOutgoing() []string

type XMLSubProcess added in v0.7.0

type XMLSubProcess struct {
	XMLIDName
	XMLBPMNElements
	XMLIncomingElements
	XMLOutgoingElements
	XMLName                          xml.Name                            `xml:"subProcess"`
	MultiInstanceLoopCharacteristics XMLMultiInstanceLoopCharacteristics `xml:"multiInstanceLoopCharacteristics"`
}

type XMLTimeCycle

type XMLTimeCycle struct {
	XMLName       xml.Name `xml:"timeCycle"`
	Type          string   `xml:"type,attr"`
	TimeCycle     string   `xml:"timeCycle"`
	ISO8601       dynamap.ISO8601DateTime
	DurationMicro int64
}

type XMLTimerEventDefinition

type XMLTimerEventDefinition struct {
	XMLName xml.Name `xml:"timerEventDefinition"`
	XMLTimeCycle
}

type XMLUserTask

type XMLUserTask struct {
	XMLIDName
	XMLIncomingElements
	XMLOutgoingElements
	XMLName    xml.Name `xml:"userTask"`
	GoDataType string   `xml:"dataType,attr"`
}

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL