diff --git a/activiti-xml-parser/src/main/kotlin/com/valb3r/bpmn/intellij/plugin/activiti/parser/ActivitiParser.kt b/activiti-xml-parser/src/main/kotlin/com/valb3r/bpmn/intellij/plugin/activiti/parser/ActivitiParser.kt index 3735ccbbf..c4efbf9b8 100644 --- a/activiti-xml-parser/src/main/kotlin/com/valb3r/bpmn/intellij/plugin/activiti/parser/ActivitiParser.kt +++ b/activiti-xml-parser/src/main/kotlin/com/valb3r/bpmn/intellij/plugin/activiti/parser/ActivitiParser.kt @@ -5,7 +5,7 @@ import com.fasterxml.jackson.module.kotlin.readValue import com.valb3r.bpmn.intellij.plugin.activiti.parser.nodes.BpmnFile import com.valb3r.bpmn.intellij.plugin.activiti.parser.nodes.DiagramNode import com.valb3r.bpmn.intellij.plugin.activiti.parser.nodes.ProcessNode -import com.valb3r.bpmn.intellij.plugin.bpmn.api.BpmnProcessObject +import com.valb3r.bpmn.intellij.plugin.bpmn.api.BpmnFileObject import com.valb3r.bpmn.intellij.plugin.bpmn.api.info.PropertyType import com.valb3r.bpmn.intellij.plugin.bpmn.parser.core.BaseBpmnParser import com.valb3r.bpmn.intellij.plugin.bpmn.parser.core.NS @@ -116,18 +116,18 @@ open class ActivitiParser : BaseBpmnParser() { private val mapper: XmlMapper = mapper() - override fun parse(input: String): BpmnProcessObject { + override fun parse(input: String): BpmnFileObject { val dto = mapper.readValue(input) return toProcessObject(dto) } - private fun toProcessObject(dto: BpmnFile): BpmnProcessObject { - // TODO - Multi process support? + private fun toProcessObject(dto: BpmnFile): BpmnFileObject { markSubprocessesAndTransactionsThatHaveExternalDiagramAsCollapsed(dto.processes[0], dto.diagrams!!) - val process = dto.processes[0].toElement() + val processes = dto.processes.map { it.toElement() } + val collaborations = dto.collaborations?.map { it.toElement() } ?: emptyList() val diagrams = dto.diagrams!!.map { it.toElement() } - return BpmnProcessObject(process, diagrams) + return BpmnFileObject(processes, collaborations, diagrams) } override fun modelNs(): NS { diff --git a/activiti-xml-parser/src/main/kotlin/com/valb3r/bpmn/intellij/plugin/activiti/parser/nodes/ActivitiXml.kt b/activiti-xml-parser/src/main/kotlin/com/valb3r/bpmn/intellij/plugin/activiti/parser/nodes/ActivitiXml.kt index bc01ea9f0..84a88e69a 100644 --- a/activiti-xml-parser/src/main/kotlin/com/valb3r/bpmn/intellij/plugin/activiti/parser/nodes/ActivitiXml.kt +++ b/activiti-xml-parser/src/main/kotlin/com/valb3r/bpmn/intellij/plugin/activiti/parser/nodes/ActivitiXml.kt @@ -21,12 +21,12 @@ import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.elements.subprocess.BpmnEve import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.elements.subprocess.BpmnSubProcess import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.elements.tasks.* import com.valb3r.bpmn.intellij.plugin.bpmn.api.diagram.DiagramElement +import com.valb3r.bpmn.intellij.plugin.activiti.parser.nodes.collaboration.Collaboration import org.mapstruct.Mapper import org.mapstruct.Mapping import org.mapstruct.Mappings import org.mapstruct.factory.Mappers import java.util.concurrent.ConcurrentHashMap -import kotlin.reflect.KClass const val EXTENSION_ELEM_STREAM = "java(null == input.getExtensionElements() ? null : input.getExtensionElements().stream()" @@ -38,20 +38,25 @@ const val EXTENSION_BOOLEAN_EXTRACTOR = ".map(it -> Boolean.valueOf(it.getString // https://github.com/FasterXML/jackson-dataformat-xml/issues/363 // unfortunately this has failed with Kotlin 'data' classes class BpmnFile( - @JacksonXmlProperty(localName = "message") - @JsonMerge - @JacksonXmlElementWrapper(useWrapping = false) - var messages: List? = null, - - @JacksonXmlProperty(localName = "process") - @JsonMerge - @JacksonXmlElementWrapper(useWrapping = false) - var processes: List, - - @JacksonXmlProperty(localName = "BPMNDiagram") - @JsonMerge - @JacksonXmlElementWrapper(useWrapping = false) - var diagrams: List? = null + @JacksonXmlProperty(localName = "message") + @JsonMerge + @JacksonXmlElementWrapper(useWrapping = false) + var messages: List? = null, + + @JacksonXmlProperty(localName = "collaboration") + @JsonMerge + @JacksonXmlElementWrapper(useWrapping = false) + var collaborations: List? = null, + + @JacksonXmlProperty(localName = "process") + @JsonMerge + @JacksonXmlElementWrapper(useWrapping = false) + var processes: List, + + @JacksonXmlProperty(localName = "BPMNDiagram") + @JsonMerge + @JacksonXmlElementWrapper(useWrapping = false) + var diagrams: List? = null ) data class MessageNode(val id: String, var name: String?) diff --git a/activiti-xml-parser/src/main/kotlin/com/valb3r/bpmn/intellij/plugin/activiti/parser/nodes/collaboration/Collaboration.kt b/activiti-xml-parser/src/main/kotlin/com/valb3r/bpmn/intellij/plugin/activiti/parser/nodes/collaboration/Collaboration.kt new file mode 100644 index 000000000..60e8b09bd --- /dev/null +++ b/activiti-xml-parser/src/main/kotlin/com/valb3r/bpmn/intellij/plugin/activiti/parser/nodes/collaboration/Collaboration.kt @@ -0,0 +1,43 @@ +package com.valb3r.bpmn.intellij.plugin.activiti.parser.nodes.collaboration + +import com.fasterxml.jackson.annotation.JsonMerge +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty +import com.valb3r.bpmn.intellij.plugin.activiti.parser.nodes.BpmnMappable +import com.valb3r.bpmn.intellij.plugin.activiti.parser.nodes.process.BpmnElementIdMapper +import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.BpmnCollaboration +import org.mapstruct.Mapper +import org.mapstruct.factory.Mappers + +data class Collaboration( + @JacksonXmlProperty(isAttribute = true) val id: String, + @JacksonXmlProperty(isAttribute = true) val name: String?, + @JsonMerge @JacksonXmlElementWrapper(useWrapping = false) val participant: List?, + @JsonMerge @JacksonXmlElementWrapper(useWrapping = false) val messageFlow: List?, +) : BpmnMappable { + + override fun toElement(): BpmnCollaboration { + return Mappers.getMapper(Mapping::class.java).convertToDto(this) + } + + @Mapper(uses = [BpmnElementIdMapper::class]) + interface Mapping { + fun convertToDto(input: Collaboration): BpmnCollaboration + } +} + +data class Participant( + @JacksonXmlProperty(isAttribute = true) val id: String, + @JacksonXmlProperty(isAttribute = true) val name: String?, + @JacksonXmlProperty(isAttribute = true) val processRef: String?, + val documentation: String? +) + +data class MessageFlow( + @JacksonXmlProperty(isAttribute = true) val id: String, + @JacksonXmlProperty(isAttribute = true) val name: String?, + val documentation: String?, + @JacksonXmlProperty(isAttribute = true) val sourceRef: String?, + @JacksonXmlProperty(isAttribute = true) val targetRef: String?, +) + diff --git a/activiti-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/activiti/parser/ActivityParserDumbTest.kt b/activiti-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/activiti/parser/ActivityParserDumbTest.kt index b630c1fc9..d040ab6e4 100644 --- a/activiti-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/activiti/parser/ActivityParserDumbTest.kt +++ b/activiti-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/activiti/parser/ActivityParserDumbTest.kt @@ -1,7 +1,7 @@ package com.valb3r.bpmn.intellij.plugin.activiti.parser import com.valb3r.bpmn.intellij.plugin.activiti.parser.testevents.* -import com.valb3r.bpmn.intellij.plugin.bpmn.api.BpmnProcessObject +import com.valb3r.bpmn.intellij.plugin.bpmn.api.BpmnFileObject import com.valb3r.bpmn.intellij.plugin.bpmn.api.PropertyTable import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.BpmnElementId import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.elements.BpmnSequenceFlow @@ -25,7 +25,7 @@ internal class ActivityParserDumbTest { @Test fun `XML process with all Activiti elements is parseable without error`() { - val processObject: BpmnProcessObject? + val processObject: BpmnFileObject? processObject = ActivitiParser().parse("popurri.bpmn20.xml".asResource()!!) @@ -34,7 +34,7 @@ internal class ActivityParserDumbTest { @Test fun `XML process without name should be parseable without error`() { - val processObject: BpmnProcessObject? + val processObject: BpmnFileObject? processObject = ActivitiParser().parse("empty-process-name.bpmn20.xml".asResource()!!) @@ -44,7 +44,7 @@ internal class ActivityParserDumbTest { @Test fun `XML process with interlaced elements of same type should be parseable without error`() { - val processObject: BpmnProcessObject? + val processObject: BpmnFileObject? processObject = ActivitiParser().parse("duplicates.bpmn20.xml".asResource()!!) @@ -53,7 +53,7 @@ internal class ActivityParserDumbTest { @Test fun `XML process with nested subprocess elements of same type should be parseable without error`() { - val processObject: BpmnProcessObject? + val processObject: BpmnFileObject? processObject = ActivitiParser().parse("nested.bpmn20.xml".asResource()!!) @@ -62,38 +62,38 @@ internal class ActivityParserDumbTest { @Test fun `XML process with nested subprocess elements that have interlaced subelems of same type should be parseable without error`() { - val processObject: BpmnProcessObject? + val processObject: BpmnFileObject? processObject = ActivitiParser().parse("nested-interlaced.bpmn20.xml".asResource()!!) processObject.shouldNotBeNull() - processObject.process.body!!.serviceTask!!.map { it.id.id }.shouldContainAll(arrayOf("parentInterlaceBeginServiceTask", "parentInterlaceEndServiceTask")) - processObject.process.children!![BpmnElementId("sid-9E62AF47-D4DF-4492-BA2F-E531CEB29A03")]!!.serviceTask!!.shouldHaveSize(2) - processObject.process.children!![BpmnElementId("sid-9E62AF47-D4DF-4492-BA2F-E531CEB29A03")]!!.serviceTask!!.map { it.id.id }.shouldContain("nestedServiceTaskInterlaced") + processObject.processes[0].body!!.serviceTask!!.map { it.id.id }.shouldContainAll(arrayOf("parentInterlaceBeginServiceTask", "parentInterlaceEndServiceTask")) + processObject.processes[0].children!![BpmnElementId("sid-9E62AF47-D4DF-4492-BA2F-E531CEB29A03")]!!.serviceTask!!.shouldHaveSize(2) + processObject.processes[0].children!![BpmnElementId("sid-9E62AF47-D4DF-4492-BA2F-E531CEB29A03")]!!.serviceTask!!.map { it.id.id }.shouldContain("nestedServiceTaskInterlaced") } @Test fun `XML process with nested other subprocess elements that have interlaced subelems of same type should be parseable without error`() { - val processObject: BpmnProcessObject? + val processObject: BpmnFileObject? processObject = ActivitiParser().parse("nested-interlaced.bpmn20.xml".asResource()!!) processObject.shouldNotBeNull() - processObject.process.body!!.serviceTask!!.map { it.id.id }.shouldContainAll(arrayOf("parentInterlaceBeginServiceTask", "parentInterlaceEndServiceTask")) - processObject.process.children!![BpmnElementId("sid-0B5D0923-5542-44DA-B86D-C3E4B2883DC2")]!!.serviceTask!!.shouldHaveSize(2) - processObject.process.children!![BpmnElementId("sid-0B5D0923-5542-44DA-B86D-C3E4B2883DC2")]!!.serviceTask!!.map { it.id.id }.shouldContain("nestedServiceTaskInterlacedOther") + processObject.processes[0].body!!.serviceTask!!.map { it.id.id }.shouldContainAll(arrayOf("parentInterlaceBeginServiceTask", "parentInterlaceEndServiceTask")) + processObject.processes[0].children!![BpmnElementId("sid-0B5D0923-5542-44DA-B86D-C3E4B2883DC2")]!!.serviceTask!!.shouldHaveSize(2) + processObject.processes[0].children!![BpmnElementId("sid-0B5D0923-5542-44DA-B86D-C3E4B2883DC2")]!!.serviceTask!!.map { it.id.id }.shouldContain("nestedServiceTaskInterlacedOther") } @Test fun `XML process with nested transactional subprocess elements that have interlaced subelems of same type should be parseable without error`() { - val processObject: BpmnProcessObject? + val processObject: BpmnFileObject? processObject = ActivitiParser().parse("nested-interlaced.bpmn20.xml".asResource()!!) processObject.shouldNotBeNull() - processObject.process.body!!.serviceTask!!.map { it.id.id }.shouldContainAll(arrayOf("parentInterlaceBeginServiceTask", "parentInterlaceEndServiceTask")) - processObject.process.children!![BpmnElementId("sid-77F95F37-ADC3-4EBB-8F21-AEF1C015D5EB")]!!.serviceTask!!.shouldHaveSize(2) - processObject.process.children!![BpmnElementId("sid-77F95F37-ADC3-4EBB-8F21-AEF1C015D5EB")]!!.serviceTask!!.map { it.id.id }.shouldContain("nestedServiceTaskInterlacedYetOther") + processObject.processes[0].body!!.serviceTask!!.map { it.id.id }.shouldContainAll(arrayOf("parentInterlaceBeginServiceTask", "parentInterlaceEndServiceTask")) + processObject.processes[0].children!![BpmnElementId("sid-77F95F37-ADC3-4EBB-8F21-AEF1C015D5EB")]!!.serviceTask!!.shouldHaveSize(2) + processObject.processes[0].children!![BpmnElementId("sid-77F95F37-ADC3-4EBB-8F21-AEF1C015D5EB")]!!.serviceTask!!.map { it.id.id }.shouldContain("nestedServiceTaskInterlacedYetOther") } @Test @@ -223,7 +223,7 @@ internal class ActivityParserDumbTest { updated.shouldNotBeNull() val updatedProcess = ActivitiParser().parse(updated) - updatedProcess.process.children!![BpmnElementId("sid-1334170C-BA4D-4387-99BD-44229D18942C")]!!.sequenceFlow!!.map { it.id }.shouldContain(newId) + updatedProcess.processes[0].children!![BpmnElementId("sid-1334170C-BA4D-4387-99BD-44229D18942C")]!!.sequenceFlow!!.map { it.id }.shouldContain(newId) } @Test @@ -258,7 +258,7 @@ internal class ActivityParserDumbTest { updated.shouldNotBeNull() val processObject = ActivitiParser().parse(updated) - processObject.process.body!!.transaction!!.map { it.id.id }.shouldContain("sid-9DBEBCA6-7BE8-4170-ACC3-4548A2244C40") + processObject.processes[0].body!!.transaction!!.map { it.id.id }.shouldContain("sid-9DBEBCA6-7BE8-4170-ACC3-4548A2244C40") } @Test @@ -280,7 +280,7 @@ internal class ActivityParserDumbTest { updated.shouldNotBeNull() val updatedProcess = ActivitiParser().parse(updated) - val sequenceFlow = updatedProcess.process.body!!.sequenceFlow!!.filter { it.id.id == "sid-2CF229A2-6399-4510-AED6-45B5C553458C"}.shouldHaveSingleItem() + val sequenceFlow = updatedProcess.processes[0].body!!.sequenceFlow!!.filter { it.id.id == "sid-2CF229A2-6399-4510-AED6-45B5C553458C"}.shouldHaveSingleItem() sequenceFlow.conditionExpression!!.text.shouldBeNull() } @@ -293,7 +293,7 @@ internal class ActivityParserDumbTest { updated.shouldNotBeNull() val updatedProcess = ActivitiParser().parse(updated) - val sequenceFlow = updatedProcess.process.body!!.sequenceFlow!!.filter { it.id.id == "sid-BFF510EA-1AD5-4353-AB11-DF8B2090A9FD"}.shouldHaveSingleItem() + val sequenceFlow = updatedProcess.processes[0].body!!.sequenceFlow!!.filter { it.id.id == "sid-BFF510EA-1AD5-4353-AB11-DF8B2090A9FD"}.shouldHaveSingleItem() sequenceFlow.conditionExpression!!.text.shouldBeNull() } } diff --git a/activiti-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/activiti/parser/CommonUtils.kt b/activiti-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/activiti/parser/CommonUtils.kt index f3f2a7932..73deeb95d 100644 --- a/activiti-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/activiti/parser/CommonUtils.kt +++ b/activiti-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/activiti/parser/CommonUtils.kt @@ -1,21 +1,21 @@ package com.valb3r.bpmn.intellij.plugin.activiti.parser -import com.valb3r.bpmn.intellij.plugin.bpmn.api.BpmnProcessObject +import com.valb3r.bpmn.intellij.plugin.bpmn.api.BpmnFileObject import com.valb3r.bpmn.intellij.plugin.bpmn.api.events.EventPropagatableToXml import org.amshove.kluent.shouldNotBeNull import java.nio.charset.StandardCharsets fun String.asResource(): String? = object {}::class.java.classLoader.getResource(this)?.readText(StandardCharsets.UTF_8) -fun readAndUpdateProcess(parser: ActivitiParser, event: EventPropagatableToXml): BpmnProcessObject { +fun readAndUpdateProcess(parser: ActivitiParser, event: EventPropagatableToXml): BpmnFileObject { return readAndUpdateProcess(parser, "simple-nested.bpmn20.xml", event) } -fun readAndUpdateProcess(parser: ActivitiParser, processName: String, event: EventPropagatableToXml): BpmnProcessObject { +fun readAndUpdateProcess(parser: ActivitiParser, processName: String, event: EventPropagatableToXml): BpmnFileObject { return readAndUpdateProcess(parser, processName, listOf(event)) } -fun readAndUpdateProcess(parser: ActivitiParser, processName: String, events: List): BpmnProcessObject { +fun readAndUpdateProcess(parser: ActivitiParser, processName: String, events: List): BpmnFileObject { val updated = updateBpmnFile(parser, processName, events) return parser.parse(updated) } diff --git a/activiti-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/activiti/parser/WindowsEncodingAndCrLfTest.kt b/activiti-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/activiti/parser/WindowsEncodingAndCrLfTest.kt index e5fb4371e..a38252c2f 100644 --- a/activiti-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/activiti/parser/WindowsEncodingAndCrLfTest.kt +++ b/activiti-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/activiti/parser/WindowsEncodingAndCrLfTest.kt @@ -19,7 +19,7 @@ class WindowsEncodingAndCrLfTest { val updateNameTo = "提交请假" val ActivityParser = ActivitiParser() val updated = ActivityParser.update(initial, listOf(StringValueUpdatedEvent(BpmnElementId("empty-process-name"), PropertyType.NAME, updateNameTo))) - ActivityParser.parse(updated).process.name.shouldBeEqualTo(updateNameTo) + ActivityParser.parse(updated).processes[0].name.shouldBeEqualTo(updateNameTo) } private fun setKoi8DefaultEncoding() { diff --git a/activiti-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/activiti/parser/XmlUpdateEventApplyTest.kt b/activiti-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/activiti/parser/XmlUpdateEventApplyTest.kt index 9baac3e0c..417557e3b 100644 --- a/activiti-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/activiti/parser/XmlUpdateEventApplyTest.kt +++ b/activiti-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/activiti/parser/XmlUpdateEventApplyTest.kt @@ -34,7 +34,7 @@ internal class XmlUpdateEventApplyTest { val newValue = "Start task name" val updatedProcess = readAndUpdateProcess(parser, StringValueUpdatedEvent(startEventId, PropertyType.NAME, newValue)) - updatedProcess.process.body!!.startEvent!!.filter { it.id == startEventId }.shouldHaveSingleItem().name.shouldBeEqualTo(newValue) + updatedProcess.processes[0].body!!.startEvent!!.filter { it.id == startEventId }.shouldHaveSingleItem().name.shouldBeEqualTo(newValue) } @Test @@ -42,7 +42,7 @@ internal class XmlUpdateEventApplyTest { val newValue = "Nested service task name" val updatedProcess = readAndUpdateProcess(parser, StringValueUpdatedEvent(nestedServiceTaskFirstId, PropertyType.NAME, newValue)) - updatedProcess.process.children!![subProcessId]!!.serviceTask!!.filter { it.id == nestedServiceTaskFirstId }.shouldHaveSingleItem().name.shouldBeEqualTo(newValue) + updatedProcess.processes[0].children!![subProcessId]!!.serviceTask!!.filter { it.id == nestedServiceTaskFirstId }.shouldHaveSingleItem().name.shouldBeEqualTo(newValue) } @Test @@ -50,8 +50,8 @@ internal class XmlUpdateEventApplyTest { val newValue = "newAwesomeStartEventId" val updatedProcess = readAndUpdateProcess(parser, StringValueUpdatedEvent(startEventId, PropertyType.ID, newValue)) - updatedProcess.process.body!!.startEvent!!.filter { it.id == BpmnElementId(newValue) }.shouldHaveSingleItem() - updatedProcess.process.body!!.startEvent!!.filter { it.id == startEventId }.shouldBeEmpty() + updatedProcess.processes[0].body!!.startEvent!!.filter { it.id == BpmnElementId(newValue) }.shouldHaveSingleItem() + updatedProcess.processes[0].body!!.startEvent!!.filter { it.id == startEventId }.shouldBeEmpty() } @Test @@ -59,8 +59,8 @@ internal class XmlUpdateEventApplyTest { val newValue = "newAwesomeNestedServiceId" val updatedProcess = readAndUpdateProcess(parser, StringValueUpdatedEvent(nestedServiceTaskFirstId, PropertyType.ID, newValue)) - updatedProcess.process.children!![subProcessId]!!.serviceTask!!.filter { it.id == BpmnElementId(newValue) }.shouldHaveSingleItem() - updatedProcess.process.children!![subProcessId]!!.serviceTask!!.filter { it.id == nestedServiceTaskFirstId }.shouldBeEmpty() + updatedProcess.processes[0].children!![subProcessId]!!.serviceTask!!.filter { it.id == BpmnElementId(newValue) }.shouldHaveSingleItem() + updatedProcess.processes[0].children!![subProcessId]!!.serviceTask!!.filter { it.id == nestedServiceTaskFirstId }.shouldBeEmpty() } @Test @@ -68,7 +68,7 @@ internal class XmlUpdateEventApplyTest { val newValue = "Some new docs" val updatedProcess = readAndUpdateProcess(parser, StringValueUpdatedEvent(startEventId, PropertyType.DOCUMENTATION, newValue)) - updatedProcess.process.body!!.startEvent!!.filter { it.id == startEventId }.shouldHaveSingleItem().documentation.shouldBeEqualTo(newValue) + updatedProcess.processes[0].body!!.startEvent!!.filter { it.id == startEventId }.shouldHaveSingleItem().documentation.shouldBeEqualTo(newValue) } @Test @@ -76,31 +76,31 @@ internal class XmlUpdateEventApplyTest { val newValue = "Some new docs" val updatedProcess = readAndUpdateProcess(parser, StringValueUpdatedEvent(nestedServiceTaskFirstId, PropertyType.DOCUMENTATION, newValue)) - updatedProcess.process.children!![subProcessId]!!.serviceTask!!.filter { it.id == nestedServiceTaskFirstId }.shouldHaveSingleItem().documentation.shouldBeEqualTo(newValue) + updatedProcess.processes[0].children!![subProcessId]!!.serviceTask!!.filter { it.id == nestedServiceTaskFirstId }.shouldHaveSingleItem().documentation.shouldBeEqualTo(newValue) } @Test fun `Boolean value update event on flat element works (attribute)`() { val updatedProcess = readAndUpdateProcess(parser, BooleanValueUpdatedEvent(flatServiceTaskId, PropertyType.ASYNC, true)) - updatedProcess.process.body!!.serviceTask!!.filter { it.id == flatServiceTaskId }.shouldHaveSingleItem().async.shouldBeEqualTo(true) + updatedProcess.processes[0].body!!.serviceTask!!.filter { it.id == flatServiceTaskId }.shouldHaveSingleItem().async.shouldBeEqualTo(true) } @Test fun `Boolean value update event on nested element works (attribute)`() { val updatedProcess = readAndUpdateProcess(parser, BooleanValueUpdatedEvent(nestedServiceTaskFirstId, PropertyType.ASYNC, true)) - updatedProcess.process.children!![subProcessId]!!.serviceTask!!.filter { it.id == nestedServiceTaskFirstId }.shouldHaveSingleItem().async.shouldBeEqualTo(true) + updatedProcess.processes[0].children!![subProcessId]!!.serviceTask!!.filter { it.id == nestedServiceTaskFirstId }.shouldHaveSingleItem().async.shouldBeEqualTo(true) } @Test fun `Element type pdate event on flat element works (attribute)`() { val updatedProcess = readAndUpdateProcess(parser, BooleanValueUpdatedEvent(subProcessId, PropertyType.IS_TRANSACTIONAL_SUBPROCESS, true)) - updatedProcess.process.body!!.transaction!!.filter { it.id == subProcessId }.shouldHaveSingleItem() - updatedProcess.process.body!!.subProcess.shouldBeNull() - updatedProcess.process.children!![subProcessId]!!.serviceTask!!.shouldHaveSize(2) - updatedProcess.process.children!![subProcessId]!!.sequenceFlow!!.shouldHaveSize(1) + updatedProcess.processes[0].body!!.transaction!!.filter { it.id == subProcessId }.shouldHaveSingleItem() + updatedProcess.processes[0].body!!.subProcess.shouldBeNull() + updatedProcess.processes[0].children!![subProcessId]!!.serviceTask!!.shouldHaveSize(2) + updatedProcess.processes[0].children!![subProcessId]!!.sequenceFlow!!.shouldHaveSize(1) } @@ -177,14 +177,14 @@ internal class XmlUpdateEventApplyTest { fun `BPMN element removed event on flat element works`() { val updatedProcess = readAndUpdateProcess(parser, BpmnElementRemovedEvent(flatServiceTaskId)) - updatedProcess.process.body!!.serviceTask.shouldBeNull() + updatedProcess.processes[0].body!!.serviceTask.shouldBeNull() } @Test fun `BPMN element removed event on nested element works`() { val updatedProcess = readAndUpdateProcess(parser, BpmnElementRemovedEvent(nestedServiceTaskFirstId)) - updatedProcess.process.body!!.serviceTask!!.filter { it.id == nestedServiceTaskFirstId }.shouldBeEmpty() + updatedProcess.processes[0].body!!.serviceTask!!.filter { it.id == nestedServiceTaskFirstId }.shouldBeEmpty() } // BPMN Object added is tested in XmlUpdateEventBpmnObjectAdded @@ -208,7 +208,7 @@ internal class XmlUpdateEventApplyTest { PropertyTable(mutableMapOf(Pair(PropertyType.ID, mutableListOf(Property(id.id))), Pair(PropertyType.NAME, mutableListOf(Property(nameOnProp))))) )) - updatedProcess.process.body!!.sequenceFlow!!.filter { it.id == id }.shouldHaveSingleItem().name.shouldBeEqualTo(nameOnProp) + updatedProcess.processes[0].body!!.sequenceFlow!!.filter { it.id == id }.shouldHaveSingleItem().name.shouldBeEqualTo(nameOnProp) } @Test @@ -230,7 +230,7 @@ internal class XmlUpdateEventApplyTest { PropertyTable(mutableMapOf(Pair(PropertyType.ID, mutableListOf(Property(id.id))), Pair(PropertyType.NAME, mutableListOf(Property(nameOnProp))))) )) - updatedProcess.process.children!![subProcessId]!!.sequenceFlow!!.filter { it.id == id }.shouldHaveSingleItem().name.shouldBeEqualTo(nameOnProp) + updatedProcess.processes[0].children!![subProcessId]!!.sequenceFlow!!.filter { it.id == id }.shouldHaveSingleItem().name.shouldBeEqualTo(nameOnProp) val addedEdge = updatedProcess.diagram.filter { it.id == parentDiagramElementId }.shouldHaveSingleItem().bpmnPlane.bpmnEdge!!.filter { it.id == diagramId }.shouldHaveSingleItem() addedEdge.waypoint!![0].x.shouldBeNear(100.0f, EPSILON) addedEdge.waypoint!![0].y.shouldBeNear(100.0f, EPSILON) @@ -258,9 +258,9 @@ internal class XmlUpdateEventApplyTest { fun `BPMN parent changed event on flat element works`() { val updatedProcess = readAndUpdateProcess(parser, BpmnParentChangedEvent(flatServiceTaskId, subProcessId)) - updatedProcess.process.body!!.serviceTask.shouldBeNull() - updatedProcess.process.children!![subProcessId]!!.serviceTask!!.filter { it.id == flatServiceTaskId }.shouldHaveSingleItem() - updatedProcess.process.children!![subProcessId]!!.serviceTask!!.map { it.id }.shouldContainSame( + updatedProcess.processes[0].body!!.serviceTask.shouldBeNull() + updatedProcess.processes[0].children!![subProcessId]!!.serviceTask!!.filter { it.id == flatServiceTaskId }.shouldHaveSingleItem() + updatedProcess.processes[0].children!![subProcessId]!!.serviceTask!!.map { it.id }.shouldContainSame( listOf(flatServiceTaskId, nestedServiceTaskFirstId, nestedServiceTaskSecondId) ) } @@ -269,9 +269,9 @@ internal class XmlUpdateEventApplyTest { fun `BPMN parent changed event on nested element works`() { val updatedProcess = readAndUpdateProcess(parser, BpmnParentChangedEvent(nestedServiceTaskFirstId, processId)) - updatedProcess.process.children!![subProcessId]!!.serviceTask!!.filter { it.id == nestedServiceTaskFirstId }.shouldBeEmpty() - updatedProcess.process.body!!.serviceTask!!.filter { it.id == nestedServiceTaskFirstId }.shouldHaveSingleItem() - updatedProcess.process.body!!.serviceTask!!.map { it.id }.shouldContainSame( + updatedProcess.processes[0].children!![subProcessId]!!.serviceTask!!.filter { it.id == nestedServiceTaskFirstId }.shouldBeEmpty() + updatedProcess.processes[0].body!!.serviceTask!!.filter { it.id == nestedServiceTaskFirstId }.shouldHaveSingleItem() + updatedProcess.processes[0].body!!.serviceTask!!.map { it.id }.shouldContainSame( listOf(flatServiceTaskId, nestedServiceTaskFirstId) ) } @@ -280,8 +280,8 @@ internal class XmlUpdateEventApplyTest { fun `BPMN parent changed event without propagation flag on nested element works`() { val updatedProcess = readAndUpdateProcess(parser, BpmnParentChangedEvent(nestedServiceTaskFirstId, processId, false)) - updatedProcess.process.children!![subProcessId]!!.serviceTask!!.filter { it.id == nestedServiceTaskFirstId }.shouldHaveSingleItem() - updatedProcess.process.body!!.serviceTask!!.filter { it.id == nestedServiceTaskFirstId }.shouldBeEmpty() - updatedProcess.process.body!!.serviceTask!!.filter { it.id == flatServiceTaskId }.shouldHaveSingleItem() + updatedProcess.processes[0].children!![subProcessId]!!.serviceTask!!.filter { it.id == nestedServiceTaskFirstId }.shouldHaveSingleItem() + updatedProcess.processes[0].body!!.serviceTask!!.filter { it.id == nestedServiceTaskFirstId }.shouldBeEmpty() + updatedProcess.processes[0].body!!.serviceTask!!.filter { it.id == flatServiceTaskId }.shouldHaveSingleItem() } } \ No newline at end of file diff --git a/activiti-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/activiti/parser/XmlUpdateEventBpmnObjectAddedTest.kt b/activiti-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/activiti/parser/XmlUpdateEventBpmnObjectAddedTest.kt index 8af3e882e..391101f49 100644 --- a/activiti-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/activiti/parser/XmlUpdateEventBpmnObjectAddedTest.kt +++ b/activiti-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/activiti/parser/XmlUpdateEventBpmnObjectAddedTest.kt @@ -1,7 +1,7 @@ package com.valb3r.bpmn.intellij.plugin.activiti.parser import com.valb3r.bpmn.intellij.plugin.activiti.parser.testevents.BpmnShapeObjectAddedEvent -import com.valb3r.bpmn.intellij.plugin.bpmn.api.BpmnProcessObject +import com.valb3r.bpmn.intellij.plugin.bpmn.api.BpmnFileObject import com.valb3r.bpmn.intellij.plugin.bpmn.api.PropertyTable import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.BpmnElementId import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.elements.WithBpmnId @@ -53,322 +53,322 @@ internal class XmlUpdateEventBpmnObjectAddedTest { fun `Added start event works`() { val updatedProcess = readAndUpdateProcess(generateUpdateEvent(BpmnStartEvent::class)) - updatedProcess.process.body!!.startEvent!!.filter { it.id == id }.shouldHaveSingleItem().name.shouldBeEqualTo(nameOnProp) + updatedProcess.processes[0].body!!.startEvent!!.filter { it.id == id }.shouldHaveSingleItem().name.shouldBeEqualTo(nameOnProp) } @Test fun `Added start timer event works`() { val updatedProcess = readAndUpdateProcess(generateUpdateEvent(BpmnStartTimerEvent::class)) - updatedProcess.process.body!!.timerStartEvent!!.filter { it.id == id }.shouldHaveSingleItem().name.shouldBeEqualTo(nameOnProp) + updatedProcess.processes[0].body!!.timerStartEvent!!.filter { it.id == id }.shouldHaveSingleItem().name.shouldBeEqualTo(nameOnProp) } @Test fun `Added start signal event works`() { val updatedProcess = readAndUpdateProcess(generateUpdateEvent(BpmnStartSignalEvent::class)) - updatedProcess.process.body!!.signalStartEvent!!.filter { it.id == id }.shouldHaveSingleItem().name.shouldBeEqualTo(nameOnProp) + updatedProcess.processes[0].body!!.signalStartEvent!!.filter { it.id == id }.shouldHaveSingleItem().name.shouldBeEqualTo(nameOnProp) } @Test fun `Added start message event works`() { val updatedProcess = readAndUpdateProcess(generateUpdateEvent(BpmnStartMessageEvent::class)) - updatedProcess.process.body!!.messageStartEvent!!.filter { it.id == id }.shouldHaveSingleItem().name.shouldBeEqualTo(nameOnProp) + updatedProcess.processes[0].body!!.messageStartEvent!!.filter { it.id == id }.shouldHaveSingleItem().name.shouldBeEqualTo(nameOnProp) } @Test fun `Added start error event works`() { val updatedProcess = readAndUpdateProcess(generateUpdateEvent(BpmnStartErrorEvent::class)) - updatedProcess.process.body!!.errorStartEvent!!.filter { it.id == id }.shouldHaveSingleItem().name.shouldBeEqualTo(nameOnProp) + updatedProcess.processes[0].body!!.errorStartEvent!!.filter { it.id == id }.shouldHaveSingleItem().name.shouldBeEqualTo(nameOnProp) } @Test fun `Added start conditional event works`() { val updatedProcess = readAndUpdateProcess(generateUpdateEvent(BpmnStartConditionalEvent::class)) - updatedProcess.process.body!!.conditionalStartEvent!!.filter { it.id == id }.shouldHaveSingleItem().name.shouldBeEqualTo(nameOnProp) + updatedProcess.processes[0].body!!.conditionalStartEvent!!.filter { it.id == id }.shouldHaveSingleItem().name.shouldBeEqualTo(nameOnProp) } @Test fun `Added start escalation event works`() { val updatedProcess = readAndUpdateProcess(generateUpdateEvent(BpmnStartEscalationEvent::class)) - updatedProcess.process.body!!.escalationStartEvent!!.filter { it.id == id }.shouldHaveSingleItem().name.shouldBeEqualTo(nameOnProp) + updatedProcess.processes[0].body!!.escalationStartEvent!!.filter { it.id == id }.shouldHaveSingleItem().name.shouldBeEqualTo(nameOnProp) } @Test fun `Added end event works`() { val updatedProcess = readAndUpdateProcess(generateUpdateEvent(BpmnEndEvent::class)) - updatedProcess.process.body!!.endEvent!!.filter { it.id == id }.shouldHaveSingleItem().name.shouldBeEqualTo(nameOnProp) + updatedProcess.processes[0].body!!.endEvent!!.filter { it.id == id }.shouldHaveSingleItem().name.shouldBeEqualTo(nameOnProp) } @Test fun `Added end termination event works`() { val updatedProcess = readAndUpdateProcess(generateUpdateEvent(BpmnEndTerminateEvent::class)) - updatedProcess.process.body!!.terminateEndEvent!!.filter { it.id == id }.shouldHaveSingleItem().name.shouldBeEqualTo(nameOnProp) + updatedProcess.processes[0].body!!.terminateEndEvent!!.filter { it.id == id }.shouldHaveSingleItem().name.shouldBeEqualTo(nameOnProp) } @Test fun `Added end escalation event works`() { val updatedProcess = readAndUpdateProcess(generateUpdateEvent(BpmnEndEscalationEvent::class)) - updatedProcess.process.body!!.escalationEndEvent!!.filter { it.id == id }.shouldHaveSingleItem().name.shouldBeEqualTo(nameOnProp) + updatedProcess.processes[0].body!!.escalationEndEvent!!.filter { it.id == id }.shouldHaveSingleItem().name.shouldBeEqualTo(nameOnProp) } @Test fun `Added end cancel event works`() { val updatedProcess = readAndUpdateProcess(generateUpdateEvent(BpmnEndCancelEvent::class)) - updatedProcess.process.body!!.cancelEndEvent!!.filter { it.id == id }.shouldHaveSingleItem().name.shouldBeEqualTo(nameOnProp) + updatedProcess.processes[0].body!!.cancelEndEvent!!.filter { it.id == id }.shouldHaveSingleItem().name.shouldBeEqualTo(nameOnProp) } @Test fun `Added end error event works`() { val updatedProcess = readAndUpdateProcess(generateUpdateEvent(BpmnEndErrorEvent::class)) - updatedProcess.process.body!!.errorEndEvent!!.filter { it.id == id }.shouldHaveSingleItem().name.shouldBeEqualTo(nameOnProp) + updatedProcess.processes[0].body!!.errorEndEvent!!.filter { it.id == id }.shouldHaveSingleItem().name.shouldBeEqualTo(nameOnProp) } @Test fun `Added boundary cancel event works`() { val updatedProcess = readAndUpdateProcess(generateUpdateEvent(BpmnBoundaryCancelEvent::class)) - updatedProcess.process.body!!.boundaryCancelEvent!!.filter { it.id == id }.shouldHaveSingleItem().name.shouldBeEqualTo(nameOnProp) + updatedProcess.processes[0].body!!.boundaryCancelEvent!!.filter { it.id == id }.shouldHaveSingleItem().name.shouldBeEqualTo(nameOnProp) } @Test fun `Added boundary compensation event works`() { val updatedProcess = readAndUpdateProcess(generateUpdateEvent(BpmnBoundaryCompensationEvent::class)) - updatedProcess.process.body!!.boundaryCompensationEvent!!.filter { it.id == id }.shouldHaveSingleItem().name.shouldBeEqualTo(nameOnProp) + updatedProcess.processes[0].body!!.boundaryCompensationEvent!!.filter { it.id == id }.shouldHaveSingleItem().name.shouldBeEqualTo(nameOnProp) } @Test fun `Added boundary condtional event works`() { val updatedProcess = readAndUpdateProcess(generateUpdateEvent(BpmnBoundaryConditionalEvent::class)) - updatedProcess.process.body!!.boundaryConditionalEvent!!.filter { it.id == id }.shouldHaveSingleItem().name.shouldBeEqualTo(nameOnProp) + updatedProcess.processes[0].body!!.boundaryConditionalEvent!!.filter { it.id == id }.shouldHaveSingleItem().name.shouldBeEqualTo(nameOnProp) } @Test fun `Added boundary error event works`() { val updatedProcess = readAndUpdateProcess(generateUpdateEvent(BpmnBoundaryErrorEvent::class)) - updatedProcess.process.body!!.boundaryErrorEvent!!.filter { it.id == id }.shouldHaveSingleItem().name.shouldBeEqualTo(nameOnProp) + updatedProcess.processes[0].body!!.boundaryErrorEvent!!.filter { it.id == id }.shouldHaveSingleItem().name.shouldBeEqualTo(nameOnProp) } @Test fun `Added boundary escalation event works`() { val updatedProcess = readAndUpdateProcess(generateUpdateEvent(BpmnBoundaryEscalationEvent::class)) - updatedProcess.process.body!!.boundaryEscalationEvent!!.filter { it.id == id }.shouldHaveSingleItem().name.shouldBeEqualTo(nameOnProp) + updatedProcess.processes[0].body!!.boundaryEscalationEvent!!.filter { it.id == id }.shouldHaveSingleItem().name.shouldBeEqualTo(nameOnProp) } @Test fun `Added boundary message event works`() { val updatedProcess = readAndUpdateProcess(generateUpdateEvent(BpmnBoundaryMessageEvent::class)) - updatedProcess.process.body!!.boundaryMessageEvent!!.filter { it.id == id }.shouldHaveSingleItem().name.shouldBeEqualTo(nameOnProp) + updatedProcess.processes[0].body!!.boundaryMessageEvent!!.filter { it.id == id }.shouldHaveSingleItem().name.shouldBeEqualTo(nameOnProp) } @Test fun `Added boundary signal event works`() { val updatedProcess = readAndUpdateProcess(generateUpdateEvent(BpmnBoundarySignalEvent::class)) - updatedProcess.process.body!!.boundarySignalEvent!!.filter { it.id == id }.shouldHaveSingleItem().name.shouldBeEqualTo(nameOnProp) + updatedProcess.processes[0].body!!.boundarySignalEvent!!.filter { it.id == id }.shouldHaveSingleItem().name.shouldBeEqualTo(nameOnProp) } @Test fun `Added boundary timer event works`() { val updatedProcess = readAndUpdateProcess(generateUpdateEvent(BpmnBoundaryTimerEvent::class)) - updatedProcess.process.body!!.boundaryTimerEvent!!.filter { it.id == id }.shouldHaveSingleItem().name.shouldBeEqualTo(nameOnProp) + updatedProcess.processes[0].body!!.boundaryTimerEvent!!.filter { it.id == id }.shouldHaveSingleItem().name.shouldBeEqualTo(nameOnProp) } @Test fun `Added intermediate timer catching event works`() { val updatedProcess = readAndUpdateProcess(generateUpdateEvent(BpmnIntermediateTimerCatchingEvent::class)) - updatedProcess.process.body!!.intermediateTimerCatchingEvent!!.filter { it.id == id }.shouldHaveSingleItem().name.shouldBeEqualTo(nameOnProp) + updatedProcess.processes[0].body!!.intermediateTimerCatchingEvent!!.filter { it.id == id }.shouldHaveSingleItem().name.shouldBeEqualTo(nameOnProp) } @Test fun `Added intermediate message catching event works`() { val updatedProcess = readAndUpdateProcess(generateUpdateEvent(BpmnIntermediateMessageCatchingEvent::class)) - updatedProcess.process.body!!.intermediateMessageCatchingEvent!!.filter { it.id == id }.shouldHaveSingleItem().name.shouldBeEqualTo(nameOnProp) + updatedProcess.processes[0].body!!.intermediateMessageCatchingEvent!!.filter { it.id == id }.shouldHaveSingleItem().name.shouldBeEqualTo(nameOnProp) } @Test fun `Added intermediate signal catching event works`() { val updatedProcess = readAndUpdateProcess(generateUpdateEvent(BpmnIntermediateSignalCatchingEvent::class)) - updatedProcess.process.body!!.intermediateSignalCatchingEvent!!.filter { it.id == id }.shouldHaveSingleItem().name.shouldBeEqualTo(nameOnProp) + updatedProcess.processes[0].body!!.intermediateSignalCatchingEvent!!.filter { it.id == id }.shouldHaveSingleItem().name.shouldBeEqualTo(nameOnProp) } @Test fun `Added intermediate conditional catching event works`() { val updatedProcess = readAndUpdateProcess(generateUpdateEvent(BpmnIntermediateConditionalCatchingEvent::class)) - updatedProcess.process.body!!.intermediateConditionalCatchingEvent!!.filter { it.id == id }.shouldHaveSingleItem().name.shouldBeEqualTo(nameOnProp) + updatedProcess.processes[0].body!!.intermediateConditionalCatchingEvent!!.filter { it.id == id }.shouldHaveSingleItem().name.shouldBeEqualTo(nameOnProp) } @Test fun `Added intermediate none throwing event works`() { val updatedProcess = readAndUpdateProcess(generateUpdateEvent(BpmnIntermediateNoneThrowingEvent::class)) - updatedProcess.process.body!!.intermediateNoneThrowingEvent!!.filter { it.id == id }.shouldHaveSingleItem().name.shouldBeEqualTo(nameOnProp) + updatedProcess.processes[0].body!!.intermediateNoneThrowingEvent!!.filter { it.id == id }.shouldHaveSingleItem().name.shouldBeEqualTo(nameOnProp) } @Test fun `Added intermediate signal throwing event works`() { val updatedProcess = readAndUpdateProcess(generateUpdateEvent(BpmnIntermediateSignalThrowingEvent::class)) - updatedProcess.process.body!!.intermediateSignalThrowingEvent!!.filter { it.id == id }.shouldHaveSingleItem().name.shouldBeEqualTo(nameOnProp) + updatedProcess.processes[0].body!!.intermediateSignalThrowingEvent!!.filter { it.id == id }.shouldHaveSingleItem().name.shouldBeEqualTo(nameOnProp) } @Test fun `Added intermediate escalation throwing event works`() { val updatedProcess = readAndUpdateProcess(generateUpdateEvent(BpmnIntermediateEscalationThrowingEvent::class)) - updatedProcess.process.body!!.intermediateEscalationThrowingEvent!!.filter { it.id == id }.shouldHaveSingleItem().name.shouldBeEqualTo(nameOnProp) + updatedProcess.processes[0].body!!.intermediateEscalationThrowingEvent!!.filter { it.id == id }.shouldHaveSingleItem().name.shouldBeEqualTo(nameOnProp) } @Test fun `Added user task event works`() { val updatedProcess = readAndUpdateProcess(generateUpdateEvent(BpmnUserTask::class)) - updatedProcess.process.body!!.userTask!!.filter { it.id == id }.shouldHaveSingleItem().name.shouldBeEqualTo(nameOnProp) + updatedProcess.processes[0].body!!.userTask!!.filter { it.id == id }.shouldHaveSingleItem().name.shouldBeEqualTo(nameOnProp) } @Test fun `Added script task event works`() { val updatedProcess = readAndUpdateProcess(generateUpdateEvent(BpmnScriptTask::class)) - updatedProcess.process.body!!.scriptTask!!.filter { it.id == id }.shouldHaveSingleItem().name.shouldBeEqualTo(nameOnProp) + updatedProcess.processes[0].body!!.scriptTask!!.filter { it.id == id }.shouldHaveSingleItem().name.shouldBeEqualTo(nameOnProp) } @Test fun `Added service task event works`() { val updatedProcess = readAndUpdateProcess(generateUpdateEvent(BpmnServiceTask::class)) - updatedProcess.process.body!!.serviceTask!!.filter { it.id == id }.shouldHaveSingleItem().name.shouldBeEqualTo(nameOnProp) + updatedProcess.processes[0].body!!.serviceTask!!.filter { it.id == id }.shouldHaveSingleItem().name.shouldBeEqualTo(nameOnProp) } @Test fun `Added business rule task event works`() { val updatedProcess = readAndUpdateProcess(generateUpdateEvent(BpmnBusinessRuleTask::class)) - updatedProcess.process.body!!.businessRuleTask!!.filter { it.id == id }.shouldHaveSingleItem().name.shouldBeEqualTo(nameOnProp) + updatedProcess.processes[0].body!!.businessRuleTask!!.filter { it.id == id }.shouldHaveSingleItem().name.shouldBeEqualTo(nameOnProp) } @Test fun `Added receive task event works`() { val updatedProcess = readAndUpdateProcess(generateUpdateEvent(BpmnReceiveTask::class)) - updatedProcess.process.body!!.receiveTask!!.filter { it.id == id }.shouldHaveSingleItem().name.shouldBeEqualTo(nameOnProp) + updatedProcess.processes[0].body!!.receiveTask!!.filter { it.id == id }.shouldHaveSingleItem().name.shouldBeEqualTo(nameOnProp) } @Test fun `Added camel task event works`() { val updatedProcess = readAndUpdateProcess(generateUpdateEvent(BpmnCamelTask::class)) - updatedProcess.process.body!!.camelTask!!.filter { it.id == id }.shouldHaveSingleItem().name.shouldBeEqualTo(nameOnProp) + updatedProcess.processes[0].body!!.camelTask!!.filter { it.id == id }.shouldHaveSingleItem().name.shouldBeEqualTo(nameOnProp) } @Test fun `Added http task event works`() { val updatedProcess = readAndUpdateProcess(generateUpdateEvent(BpmnHttpTask::class)) - updatedProcess.process.body!!.httpTask!!.filter { it.id == id }.shouldHaveSingleItem().name.shouldBeEqualTo(nameOnProp) + updatedProcess.processes[0].body!!.httpTask!!.filter { it.id == id }.shouldHaveSingleItem().name.shouldBeEqualTo(nameOnProp) } @Test fun `Added mule task event works`() { val updatedProcess = readAndUpdateProcess(generateUpdateEvent(BpmnMuleTask::class)) - updatedProcess.process.body!!.muleTask!!.filter { it.id == id }.shouldHaveSingleItem().name.shouldBeEqualTo(nameOnProp) + updatedProcess.processes[0].body!!.muleTask!!.filter { it.id == id }.shouldHaveSingleItem().name.shouldBeEqualTo(nameOnProp) } @Test fun `Added decision task event works`() { val updatedProcess = readAndUpdateProcess(generateUpdateEvent(BpmnDecisionTask::class)) - updatedProcess.process.body!!.decisionTask!!.filter { it.id == id }.shouldHaveSingleItem().name.shouldBeEqualTo(nameOnProp) + updatedProcess.processes[0].body!!.decisionTask!!.filter { it.id == id }.shouldHaveSingleItem().name.shouldBeEqualTo(nameOnProp) } @Test fun `Added shell task event works`() { val updatedProcess = readAndUpdateProcess(generateUpdateEvent(BpmnShellTask::class)) - updatedProcess.process.body!!.shellTask!!.filter { it.id == id }.shouldHaveSingleItem().name.shouldBeEqualTo(nameOnProp) + updatedProcess.processes[0].body!!.shellTask!!.filter { it.id == id }.shouldHaveSingleItem().name.shouldBeEqualTo(nameOnProp) } @Test fun `Added call activity event works`() { val updatedProcess = readAndUpdateProcess(generateUpdateEvent(BpmnCallActivity::class)) - updatedProcess.process.body!!.callActivity!!.filter { it.id == id }.shouldHaveSingleItem().name.shouldBeEqualTo(nameOnProp) + updatedProcess.processes[0].body!!.callActivity!!.filter { it.id == id }.shouldHaveSingleItem().name.shouldBeEqualTo(nameOnProp) } @Test fun `Added sub process event works`() { val updatedProcess = readAndUpdateProcess(generateUpdateEvent(BpmnSubProcess::class)) - updatedProcess.process.body!!.subProcess!!.filter { it.id == id }.shouldHaveSingleItem().name.shouldBeEqualTo(nameOnProp) + updatedProcess.processes[0].body!!.subProcess!!.filter { it.id == id }.shouldHaveSingleItem().name.shouldBeEqualTo(nameOnProp) } @Test fun `Added event sub process event works`() { val updatedProcess = readAndUpdateProcess(generateUpdateEvent(BpmnEventSubprocess::class)) - updatedProcess.process.body!!.eventSubProcess!!.filter { it.id == id }.shouldHaveSingleItem().name.shouldBeEqualTo(nameOnProp) + updatedProcess.processes[0].body!!.eventSubProcess!!.filter { it.id == id }.shouldHaveSingleItem().name.shouldBeEqualTo(nameOnProp) } @Test fun `Added adhoc sub process event works`() { val updatedProcess = readAndUpdateProcess(generateUpdateEvent(BpmnAdHocSubProcess::class)) - updatedProcess.process.body!!.adHocSubProcess!!.filter { it.id == id }.shouldHaveSingleItem().name.shouldBeEqualTo(nameOnProp) + updatedProcess.processes[0].body!!.adHocSubProcess!!.filter { it.id == id }.shouldHaveSingleItem().name.shouldBeEqualTo(nameOnProp) } @Test fun `Added transactional sub process event works`() { val updatedProcess = readAndUpdateProcess(generateUpdateEvent(BpmnTransactionalSubProcess::class)) - updatedProcess.process.body!!.transaction!!.filter { it.id == id }.shouldHaveSingleItem().name.shouldBeEqualTo(nameOnProp) + updatedProcess.processes[0].body!!.transaction!!.filter { it.id == id }.shouldHaveSingleItem().name.shouldBeEqualTo(nameOnProp) } @Test fun `Added exclusive gateway works`() { val updatedProcess = readAndUpdateProcess(generateUpdateEvent(BpmnExclusiveGateway::class)) - updatedProcess.process.body!!.exclusiveGateway!!.filter { it.id == id }.shouldHaveSingleItem().name.shouldBeEqualTo(nameOnProp) + updatedProcess.processes[0].body!!.exclusiveGateway!!.filter { it.id == id }.shouldHaveSingleItem().name.shouldBeEqualTo(nameOnProp) } @Test fun `Added parallel gateway works`() { val updatedProcess = readAndUpdateProcess(generateUpdateEvent(BpmnParallelGateway::class)) - updatedProcess.process.body!!.parallelGateway!!.filter { it.id == id }.shouldHaveSingleItem().name.shouldBeEqualTo(nameOnProp) + updatedProcess.processes[0].body!!.parallelGateway!!.filter { it.id == id }.shouldHaveSingleItem().name.shouldBeEqualTo(nameOnProp) } @Test fun `Added inclusive gateway works`() { val updatedProcess = readAndUpdateProcess(generateUpdateEvent(BpmnInclusiveGateway::class)) - updatedProcess.process.body!!.inclusiveGateway!!.filter { it.id == id }.shouldHaveSingleItem().name.shouldBeEqualTo(nameOnProp) + updatedProcess.processes[0].body!!.inclusiveGateway!!.filter { it.id == id }.shouldHaveSingleItem().name.shouldBeEqualTo(nameOnProp) } @Test fun `Added event gateway works`() { val updatedProcess = readAndUpdateProcess(generateUpdateEvent(BpmnEventGateway::class)) - updatedProcess.process.body!!.eventBasedGateway!!.filter { it.id == id }.shouldHaveSingleItem().name.shouldBeEqualTo(nameOnProp) + updatedProcess.processes[0].body!!.eventBasedGateway!!.filter { it.id == id }.shouldHaveSingleItem().name.shouldBeEqualTo(nameOnProp) } private fun generateUpdateEvent(clazz: KClass): EventPropagatableToXml { @@ -394,7 +394,7 @@ internal class XmlUpdateEventBpmnObjectAddedTest { return ctor.call(*args.toTypedArray()) } - private fun readAndUpdateProcess(event: EventPropagatableToXml): BpmnProcessObject { + private fun readAndUpdateProcess(event: EventPropagatableToXml): BpmnFileObject { val updated = parser.update( "simple-nested.bpmn20.xml".asResource()!!, listOf(event) @@ -404,4 +404,4 @@ internal class XmlUpdateEventBpmnObjectAddedTest { return parser.parse(updated) } -} \ No newline at end of file +} diff --git a/activiti-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/activiti/parser/XmlUpdateEventDocumentationFormatTest.kt b/activiti-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/activiti/parser/XmlUpdateEventDocumentationFormatTest.kt index eba272aa2..81113b0ea 100644 --- a/activiti-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/activiti/parser/XmlUpdateEventDocumentationFormatTest.kt +++ b/activiti-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/activiti/parser/XmlUpdateEventDocumentationFormatTest.kt @@ -2,7 +2,7 @@ package com.valb3r.bpmn.intellij.plugin.activiti.parser import com.valb3r.bpmn.intellij.plugin.activiti.parser.testevents.BpmnElementRemovedEvent import com.valb3r.bpmn.intellij.plugin.activiti.parser.testevents.BpmnShapeObjectAddedEvent -import com.valb3r.bpmn.intellij.plugin.bpmn.api.BpmnProcessObject +import com.valb3r.bpmn.intellij.plugin.bpmn.api.BpmnFileObject import com.valb3r.bpmn.intellij.plugin.bpmn.api.PropertyTable import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.BpmnElementId import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.elements.WithParentId @@ -68,17 +68,17 @@ class XmlUpdateEventDocumentationFormatTest { fun `Removing element does not break 'documentation' element formatting`() { val originalProcess = readProcess() val updatedProcess = readAndUpdateProcess(BpmnElementRemovedEvent(BpmnElementId(startEventId))) - updatedProcess.process.body!!.scriptTask!![0].documentation - .shouldBeEqualTo(originalProcess.process.body!!.scriptTask!![0].documentation) + updatedProcess.processes[0].body!!.scriptTask!![0].documentation + .shouldBeEqualTo(originalProcess.processes[0].body!!.scriptTask!![0].documentation) } - private fun readProcess(): BpmnProcessObject { + private fun readProcess(): BpmnFileObject { val process = parser.parse(documentationProcessName.asResource()!!) process.shouldNotBeNull() return process } - private fun readAndUpdateProcess(event: EventPropagatableToXml): BpmnProcessObject { + private fun readAndUpdateProcess(event: EventPropagatableToXml): BpmnFileObject { val updated = parser.update( documentationProcessName.asResource()!!, listOf(event) @@ -88,4 +88,4 @@ class XmlUpdateEventDocumentationFormatTest { return parser.parse(updated) } -} \ No newline at end of file +} diff --git a/activiti-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/activiti/parser/XmlWithNestedStructureParserTest.kt b/activiti-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/activiti/parser/XmlWithNestedStructureParserTest.kt index 0c9231f5f..53f46c4f4 100644 --- a/activiti-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/activiti/parser/XmlWithNestedStructureParserTest.kt +++ b/activiti-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/activiti/parser/XmlWithNestedStructureParserTest.kt @@ -1,6 +1,6 @@ package com.valb3r.bpmn.intellij.plugin.activiti.parser -import com.valb3r.bpmn.intellij.plugin.bpmn.api.BpmnProcessObject +import com.valb3r.bpmn.intellij.plugin.bpmn.api.BpmnFileObject import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.BpmnElementId import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.BpmnProcessBody import org.amshove.kluent.* @@ -13,21 +13,21 @@ internal class XmlWithNestedStructureParserTest { @Test fun `XML file nested process structure parsing test`() { - val processObject: BpmnProcessObject? + val processObject: BpmnFileObject? processObject = ActivitiParser().parse("nested-interlaced.bpmn20.xml".asResource()!!) // Assert the process structure processObject.shouldNotBeNull() - processObject.process.id.shouldBeEqualTo(BpmnElementId("nested-test")) - processObject.process.body.shouldNotBeNull() - processObject.process.body!!.startEvent!!.shouldHaveSingleItem().id.id.shouldBeEqualTo("startGlobal") - processObject.process.body!!.endEvent!!.shouldHaveSingleItem().id.id.shouldBeEqualTo("endGlobal") - processObject.process.body!!.serviceTask!!.map { it.id.id }.shouldContainSame( + processObject.processes[0].id.shouldBeEqualTo(BpmnElementId("nested-test")) + processObject.processes[0].body.shouldNotBeNull() + processObject.processes[0].body!!.startEvent!!.shouldHaveSingleItem().id.id.shouldBeEqualTo("startGlobal") + processObject.processes[0].body!!.endEvent!!.shouldHaveSingleItem().id.id.shouldBeEqualTo("endGlobal") + processObject.processes[0].body!!.serviceTask!!.map { it.id.id }.shouldContainSame( listOf("parentInterlaceBeginServiceTask", "parentInterlaceEndServiceTask") ) - processObject.process.body!!.exclusiveGateway!!.shouldHaveSingleItem().id.id.shouldBeEqualTo("basicGateway") - processObject.process.body!!.sequenceFlow!!.map { it.id.id }.shouldContainSame( + processObject.processes[0].body!!.exclusiveGateway!!.shouldHaveSingleItem().id.id.shouldBeEqualTo("basicGateway") + processObject.processes[0].body!!.sequenceFlow!!.map { it.id.id }.shouldContainSame( listOf( "sid-96EFCF3C-548C-4556-B36C-2F10C675DD3E", "sid-B87070EE-2490-4FEC-AC02-099A30CFD986", @@ -38,12 +38,12 @@ internal class XmlWithNestedStructureParserTest { ) ) - processObject.process.body!!.subProcess!!.map { it.id.id }.shouldContainAll( + processObject.processes[0].body!!.subProcess!!.map { it.id.id }.shouldContainAll( listOf("sid-9DBEBCA6-7BE8-4170-ACC3-4548A2244C40", "sid-0B5D0923-5542-44DA-B86D-C3E4B2883DC2") ) - processObject.process.body!!.adHocSubProcess.shouldBeNull() // Activity does not support Ad-Hoc subprocess - processObject.process.body!!.transaction!!.shouldHaveSingleItem().id.id.shouldBeEqualTo("sid-77F95F37-ADC3-4EBB-8F21-AEF1C015D5EB") - processObject.process.children!!.keys.map { it.id }.shouldContainSame( + processObject.processes[0].body!!.adHocSubProcess.shouldBeNull() // Activity does not support Ad-Hoc subprocess + processObject.processes[0].body!!.transaction!!.shouldHaveSingleItem().id.id.shouldBeEqualTo("sid-77F95F37-ADC3-4EBB-8F21-AEF1C015D5EB") + processObject.processes[0].children!!.keys.map { it.id }.shouldContainSame( listOf( "sid-9DBEBCA6-7BE8-4170-ACC3-4548A2244C40", "sid-9E62AF47-D4DF-4492-BA2F-E531CEB29A03", @@ -53,13 +53,13 @@ internal class XmlWithNestedStructureParserTest { ) ) - validateDirectChildSubProcess(processObject.process.children!![BpmnElementId("sid-9DBEBCA6-7BE8-4170-ACC3-4548A2244C40")]!!) - validateInSubProcessNestedChildSubProcess(processObject.process.children!![BpmnElementId("sid-9E62AF47-D4DF-4492-BA2F-E531CEB29A03")]!!) - validateAnotherDirectSubProcess(processObject.process.children!![BpmnElementId("sid-0B5D0923-5542-44DA-B86D-C3E4B2883DC2")]!!) - validateAnotherDirectSubProcessNestedChildSubProcess(processObject.process.children!![BpmnElementId("sid-1334170C-BA4D-4387-99BD-44229D18942C")]!!) - validateDirectTransactionSubProcess(processObject.process.children!![BpmnElementId("sid-77F95F37-ADC3-4EBB-8F21-AEF1C015D5EB")]!!) + validateDirectChildSubProcess(processObject.processes[0].children!![BpmnElementId("sid-9DBEBCA6-7BE8-4170-ACC3-4548A2244C40")]!!) + validateInSubProcessNestedChildSubProcess(processObject.processes[0].children!![BpmnElementId("sid-9E62AF47-D4DF-4492-BA2F-E531CEB29A03")]!!) + validateAnotherDirectSubProcess(processObject.processes[0].children!![BpmnElementId("sid-0B5D0923-5542-44DA-B86D-C3E4B2883DC2")]!!) + validateAnotherDirectSubProcessNestedChildSubProcess(processObject.processes[0].children!![BpmnElementId("sid-1334170C-BA4D-4387-99BD-44229D18942C")]!!) + validateDirectTransactionSubProcess(processObject.processes[0].children!![BpmnElementId("sid-77F95F37-ADC3-4EBB-8F21-AEF1C015D5EB")]!!) - othersAreEmpty(processObject.process.body!!) + othersAreEmpty(processObject.processes[0].body!!) } private fun validateDirectChildSubProcess(subProcess: BpmnProcessBody) { @@ -178,4 +178,4 @@ internal class XmlWithNestedStructureParserTest { body.inclusiveGateway.shouldBeNull() body.eventBasedGateway.shouldBeNull() } -} \ No newline at end of file +} diff --git a/activiti-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/activiti/parser/activiti7/Activity7ParserBasicTest.kt b/activiti-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/activiti/parser/activiti7/Activity7ParserBasicTest.kt index 6942d802f..8ce4566ef 100644 --- a/activiti-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/activiti/parser/activiti7/Activity7ParserBasicTest.kt +++ b/activiti-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/activiti/parser/activiti7/Activity7ParserBasicTest.kt @@ -1,10 +1,9 @@ package com.valb3r.bpmn.intellij.plugin.activiti.parser.activiti7 import com.valb3r.bpmn.intellij.plugin.activiti.parser.Activiti7ObjectFactory -import com.valb3r.bpmn.intellij.plugin.activiti.parser.ActivitiObjectFactory import com.valb3r.bpmn.intellij.plugin.activiti.parser.ActivitiParser import com.valb3r.bpmn.intellij.plugin.activiti.parser.asResource -import com.valb3r.bpmn.intellij.plugin.bpmn.api.BpmnProcessObject +import com.valb3r.bpmn.intellij.plugin.bpmn.api.BpmnFileObject import org.amshove.kluent.shouldNotBeNull import org.junit.jupiter.api.Test @@ -12,12 +11,13 @@ internal class Activity7ParserBasicTest { @Test fun `Activiti 7 process should be parseable and its properties readable`() { - val processObject: BpmnProcessObject? + val processObject: BpmnFileObject? processObject = ActivitiParser().parse("activiti7/simple-activiti7-process.bpmn20.xml".asResource()!!) processObject.shouldNotBeNull() - val props = BpmnProcessObject(processObject.process, processObject.diagram).toView(Activiti7ObjectFactory()).elemPropertiesByElementId + val props = BpmnFileObject(processObject.processes, diagram = processObject.diagram, collaborations = listOf()) + .toView(Activiti7ObjectFactory()).processes[0].processElemPropertiesByElementId props.shouldNotBeNull() } } diff --git a/activiti-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/activiti/parser/bugfix/CondExpressionWithoutTypeParseable.kt b/activiti-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/activiti/parser/bugfix/CondExpressionWithoutTypeParseable.kt index 288374a45..d785138a8 100644 --- a/activiti-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/activiti/parser/bugfix/CondExpressionWithoutTypeParseable.kt +++ b/activiti-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/activiti/parser/bugfix/CondExpressionWithoutTypeParseable.kt @@ -1,7 +1,7 @@ package com.valb3r.bpmn.intellij.plugin.activiti.parser.bugfix import com.valb3r.bpmn.intellij.plugin.activiti.parser.* -import com.valb3r.bpmn.intellij.plugin.bpmn.api.BpmnProcessObject +import com.valb3r.bpmn.intellij.plugin.bpmn.api.BpmnFileObject import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.BpmnElementId import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.elements.ConditionExpression import com.valb3r.bpmn.intellij.plugin.bpmn.api.info.PropertyType @@ -20,11 +20,11 @@ internal class CondExpressionWithoutTypeParseable { fun `Sequence flow with empty conditional flow element parseable`() { val processObject = parser.parse(FILE.asResource()!!) - val sequenceFlow = processObject.process.body!!.sequenceFlow!![2] + val sequenceFlow = processObject.processes[0].body!!.sequenceFlow!![2] sequenceFlow.id.shouldBeEqualTo(sequenceFlowElem) sequenceFlow.conditionExpression.shouldBeEqualTo(ConditionExpression(null, "\${evection.num<3} ")) - val props = BpmnProcessObject(processObject.process, processObject.diagram).toView(ActivitiObjectFactory()).elemPropertiesByElementId[sequenceFlow.id]!! + val props = BpmnFileObject(processObject.processes, processObject.diagram).toView(ActivitiObjectFactory()).processes[0].processElemPropertiesByElementId[sequenceFlow.id]!! props[PropertyType.ID]!!.value.shouldBeEqualTo(sequenceFlowElem.id) props[PropertyType.CONDITION_EXPR_TYPE]!!.value.shouldBeNull() props[PropertyType.CONDITION_EXPR_VALUE]!!.value.shouldBeEqualTo("\${evection.num<3} ") @@ -34,13 +34,13 @@ internal class CondExpressionWithoutTypeParseable { fun `Sequence flow with empty conditional flow element parseable (Activiti 7)`() { val processObject = Activiti7Parser().parse(FILE.asResource()!!) - val sequenceFlow = processObject.process.body!!.sequenceFlow!![2] + val sequenceFlow = processObject.processes[0].body!!.sequenceFlow!![2] sequenceFlow.id.shouldBeEqualTo(sequenceFlowElem) sequenceFlow.conditionExpression.shouldBeEqualTo(ConditionExpression(null, "\${evection.num<3} ")) - val props = BpmnProcessObject(processObject.process, processObject.diagram).toView(Activiti7ObjectFactory()).elemPropertiesByElementId[sequenceFlow.id]!! + val props = BpmnFileObject(processObject.processes, processObject.diagram).toView(Activiti7ObjectFactory()).processes[0].processElemPropertiesByElementId[sequenceFlow.id]!! props[PropertyType.ID]!!.value.shouldBeEqualTo(sequenceFlowElem.id) props[PropertyType.CONDITION_EXPR_TYPE]!!.value.shouldBeNull() props[PropertyType.CONDITION_EXPR_VALUE]!!.value.shouldBeEqualTo("\${evection.num<3} ") } -} \ No newline at end of file +} diff --git a/activiti-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/activiti/parser/bugfix/EmptyCondExpressionParseable.kt b/activiti-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/activiti/parser/bugfix/EmptyCondExpressionParseable.kt index 3932b47d5..e900d3261 100644 --- a/activiti-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/activiti/parser/bugfix/EmptyCondExpressionParseable.kt +++ b/activiti-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/activiti/parser/bugfix/EmptyCondExpressionParseable.kt @@ -1,7 +1,7 @@ package com.valb3r.bpmn.intellij.plugin.flowable.parser.bugfix import com.valb3r.bpmn.intellij.plugin.activiti.parser.* -import com.valb3r.bpmn.intellij.plugin.bpmn.api.BpmnProcessObject +import com.valb3r.bpmn.intellij.plugin.bpmn.api.BpmnFileObject import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.BpmnElementId import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.elements.ConditionExpression import com.valb3r.bpmn.intellij.plugin.bpmn.api.info.PropertyType @@ -20,11 +20,11 @@ internal class EmptyCondExpressionParseable { fun `Sequence flow with empty conditional flow element parseable`() { val processObject = parser.parse(FILE.asResource()!!) - val sequenceFlow = processObject.process.body!!.sequenceFlow!![0] + val sequenceFlow = processObject.processes[0].body!!.sequenceFlow!![0] sequenceFlow.id.shouldBeEqualTo(sequenceFlowElem) sequenceFlow.conditionExpression.shouldBeEqualTo(ConditionExpression(null, "")) - val props = BpmnProcessObject(processObject.process, processObject.diagram).toView(ActivitiObjectFactory()).elemPropertiesByElementId[sequenceFlow.id]!! + val props = BpmnFileObject(processObject.processes, processObject.diagram).toView(ActivitiObjectFactory()).processes[0].processElemPropertiesByElementId[sequenceFlow.id]!! props[PropertyType.ID]!!.value.shouldBeEqualTo(sequenceFlowElem.id) props[PropertyType.CONDITION_EXPR_TYPE]!!.value.shouldBeNull() props[PropertyType.CONDITION_EXPR_VALUE]!!.value.shouldBeEqualTo("") @@ -34,13 +34,13 @@ internal class EmptyCondExpressionParseable { fun `Sequence flow with empty conditional flow element parseable (Activiti 7)`() { val processObject = Activiti7Parser().parse(FILE.asResource()!!) - val sequenceFlow = processObject.process.body!!.sequenceFlow!![0] + val sequenceFlow = processObject.processes[0].body!!.sequenceFlow!![0] sequenceFlow.id.shouldBeEqualTo(sequenceFlowElem) sequenceFlow.conditionExpression.shouldBeEqualTo(ConditionExpression(null, "")) - val props = BpmnProcessObject(processObject.process, processObject.diagram).toView(Activiti7ObjectFactory()).elemPropertiesByElementId[sequenceFlow.id]!! + val props = BpmnFileObject(processObject.processes, processObject.diagram).toView(Activiti7ObjectFactory()).processes[0].processElemPropertiesByElementId[sequenceFlow.id]!! props[PropertyType.ID]!!.value.shouldBeEqualTo(sequenceFlowElem.id) props[PropertyType.CONDITION_EXPR_TYPE]!!.value.shouldBeNull() props[PropertyType.CONDITION_EXPR_VALUE]!!.value.shouldBeEqualTo("") } -} \ No newline at end of file +} diff --git a/activiti-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/activiti/parser/custom/ActivitiStartEventWithNestedExtensionTest.kt b/activiti-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/activiti/parser/custom/ActivitiStartEventWithNestedExtensionTest.kt index 78e50e951..23c0a65fe 100644 --- a/activiti-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/activiti/parser/custom/ActivitiStartEventWithNestedExtensionTest.kt +++ b/activiti-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/activiti/parser/custom/ActivitiStartEventWithNestedExtensionTest.kt @@ -5,7 +5,7 @@ import com.valb3r.bpmn.intellij.plugin.activiti.parser.ActivitiParser import com.valb3r.bpmn.intellij.plugin.activiti.parser.asResource import com.valb3r.bpmn.intellij.plugin.activiti.parser.readAndUpdateProcess import com.valb3r.bpmn.intellij.plugin.activiti.parser.testevents.StringValueUpdatedEvent -import com.valb3r.bpmn.intellij.plugin.bpmn.api.BpmnProcessObject +import com.valb3r.bpmn.intellij.plugin.bpmn.api.BpmnFileObject import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.BpmnElementId import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.elements.events.begin.BpmnStartEvent import com.valb3r.bpmn.intellij.plugin.bpmn.api.info.Property @@ -30,7 +30,7 @@ internal class ActivitiUsereventWithNestedExtensionTest { val event = readStartEventWithExtensions(processObject) event.id.shouldBeEqualTo(elementId) - val props = BpmnProcessObject(processObject.process, processObject.diagram).toView(ActivitiObjectFactory()).elemPropertiesByElementId[event.id]!! + val props = BpmnFileObject(processObject.processes, processObject.diagram).toView(ActivitiObjectFactory()).processes[0].processElemPropertiesByElementId[event.id]!! props[PropertyType.ID]!!.value.shouldBeEqualTo(event.id.id) props.getAll(PropertyType.FORM_PROPERTY_ID).shouldContainSame(arrayOf( @@ -81,7 +81,7 @@ internal class ActivitiUsereventWithNestedExtensionTest { return readStartEventWithExtensions(readAndUpdateProcess(parser, FILE, StringValueUpdatedEvent(elementId, property, newValue, propertyIndex = propertyIndex.split(",")))) } - private fun readStartEventWithExtensions(processObject: BpmnProcessObject): BpmnStartEvent { - return processObject.process.body!!.startEvent!!.shouldHaveSize(1)[0] + private fun readStartEventWithExtensions(processObject: BpmnFileObject): BpmnStartEvent { + return processObject.processes[0].body!!.startEvent!!.shouldHaveSize(1)[0] } } diff --git a/activiti-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/activiti/parser/customservicetasks/ActivityBusinessRuleTaskTest.kt b/activiti-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/activiti/parser/customservicetasks/ActivityBusinessRuleTaskTest.kt index aac04bca2..665702635 100644 --- a/activiti-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/activiti/parser/customservicetasks/ActivityBusinessRuleTaskTest.kt +++ b/activiti-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/activiti/parser/customservicetasks/ActivityBusinessRuleTaskTest.kt @@ -6,7 +6,7 @@ import com.valb3r.bpmn.intellij.plugin.activiti.parser.asResource import com.valb3r.bpmn.intellij.plugin.activiti.parser.readAndUpdateProcess import com.valb3r.bpmn.intellij.plugin.activiti.parser.testevents.BooleanValueUpdatedEvent import com.valb3r.bpmn.intellij.plugin.activiti.parser.testevents.StringValueUpdatedEvent -import com.valb3r.bpmn.intellij.plugin.bpmn.api.BpmnProcessObject +import com.valb3r.bpmn.intellij.plugin.bpmn.api.BpmnFileObject import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.BpmnElementId import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.elements.tasks.BpmnBusinessRuleTask import com.valb3r.bpmn.intellij.plugin.bpmn.api.info.PropertyType @@ -36,7 +36,7 @@ internal class ActivityBusinessRuleTaskTest { task.resultVariable.shouldBeEqualTo("RESULT_VAR") task.exclude!!.shouldBeTrue() - val props = BpmnProcessObject(processObject.process, processObject.diagram).toView(ActivitiObjectFactory()).elemPropertiesByElementId[task.id]!! + val props = BpmnFileObject(processObject.processes, processObject.diagram).toView(ActivitiObjectFactory()).processes[0].processElemPropertiesByElementId[task.id]!! props[PropertyType.ID]!!.value.shouldBeEqualTo(task.id.id) props[PropertyType.NAME]!!.value.shouldBeEqualTo(task.name) props[PropertyType.DOCUMENTATION]!!.value.shouldBeEqualTo(task.documentation) @@ -82,7 +82,7 @@ internal class ActivityBusinessRuleTaskTest { return readBusinessRuleTask(readAndUpdateProcess(parser, FILE, BooleanValueUpdatedEvent(elementId, property, newValue))) } - private fun readBusinessRuleTask(processObject: BpmnProcessObject): BpmnBusinessRuleTask { - return processObject.process.body!!.businessRuleTask!!.shouldHaveSingleItem() + private fun readBusinessRuleTask(processObject: BpmnFileObject): BpmnBusinessRuleTask { + return processObject.processes[0].body!!.businessRuleTask!!.shouldHaveSingleItem() } -} \ No newline at end of file +} diff --git a/activiti-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/activiti/parser/customservicetasks/ActivityCamelTaskTest.kt b/activiti-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/activiti/parser/customservicetasks/ActivityCamelTaskTest.kt index 1b0243b87..35bc05c97 100644 --- a/activiti-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/activiti/parser/customservicetasks/ActivityCamelTaskTest.kt +++ b/activiti-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/activiti/parser/customservicetasks/ActivityCamelTaskTest.kt @@ -6,7 +6,7 @@ import com.valb3r.bpmn.intellij.plugin.activiti.parser.asResource import com.valb3r.bpmn.intellij.plugin.activiti.parser.readAndUpdateProcess import com.valb3r.bpmn.intellij.plugin.activiti.parser.testevents.BooleanValueUpdatedEvent import com.valb3r.bpmn.intellij.plugin.activiti.parser.testevents.StringValueUpdatedEvent -import com.valb3r.bpmn.intellij.plugin.bpmn.api.BpmnProcessObject +import com.valb3r.bpmn.intellij.plugin.bpmn.api.BpmnFileObject import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.BpmnElementId import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.elements.tasks.BpmnCamelTask import com.valb3r.bpmn.intellij.plugin.bpmn.api.info.PropertyType @@ -36,7 +36,7 @@ internal class ActivityCamelTaskTest { task.isForCompensation!!.shouldBeTrue() task.camelContext.shouldBeEqualTo("CAMEL_CTX") - val props = BpmnProcessObject(processObject.process, processObject.diagram).toView(ActivitiObjectFactory()).elemPropertiesByElementId[task.id]!! + val props = BpmnFileObject(processObject.processes, processObject.diagram).toView(ActivitiObjectFactory()).processes[0].processElemPropertiesByElementId[task.id]!! props[PropertyType.ID]!!.value.shouldBeEqualTo(task.id.id) props[PropertyType.NAME]!!.value.shouldBeEqualTo(task.name) props[PropertyType.DOCUMENTATION]!!.value.shouldBeEqualTo(task.documentation) @@ -93,7 +93,7 @@ internal class ActivityCamelTaskTest { return readCamelTask(readAndUpdateProcess(parser, FILE, BooleanValueUpdatedEvent(elementId, property, newValue))) } - private fun readCamelTask(processObject: BpmnProcessObject): BpmnCamelTask { - return processObject.process.body!!.camelTask!!.shouldHaveSingleItem() + private fun readCamelTask(processObject: BpmnFileObject): BpmnCamelTask { + return processObject.processes[0].body!!.camelTask!!.shouldHaveSingleItem() } -} \ No newline at end of file +} diff --git a/activiti-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/activiti/parser/customservicetasks/ActivityDecisionTaskTest.kt b/activiti-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/activiti/parser/customservicetasks/ActivityDecisionTaskTest.kt index de491da5d..2e3c2edfc 100644 --- a/activiti-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/activiti/parser/customservicetasks/ActivityDecisionTaskTest.kt +++ b/activiti-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/activiti/parser/customservicetasks/ActivityDecisionTaskTest.kt @@ -6,13 +6,12 @@ import com.valb3r.bpmn.intellij.plugin.activiti.parser.asResource import com.valb3r.bpmn.intellij.plugin.activiti.parser.readAndUpdateProcess import com.valb3r.bpmn.intellij.plugin.activiti.parser.testevents.BooleanValueUpdatedEvent import com.valb3r.bpmn.intellij.plugin.activiti.parser.testevents.StringValueUpdatedEvent -import com.valb3r.bpmn.intellij.plugin.bpmn.api.BpmnProcessObject +import com.valb3r.bpmn.intellij.plugin.bpmn.api.BpmnFileObject import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.BpmnElementId import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.elements.tasks.BpmnDecisionTask import com.valb3r.bpmn.intellij.plugin.bpmn.api.info.PropertyType import org.amshove.kluent.* import org.junit.jupiter.api.Test -import org.junit.jupiter.api.assertThrows private const val FILE = "custom-service-tasks/decision-task.bpmn20.xml" @@ -36,7 +35,7 @@ internal class ActivityDecisionTaskTest { task.decisionTaskThrowErrorOnNoHits.shouldBeNull() // Not supported by activity task.fallbackToDefaultTenantCdata.shouldBeNull() // Not supported by activity - val props = BpmnProcessObject(processObject.process, processObject.diagram).toView(ActivitiObjectFactory()).elemPropertiesByElementId[task.id]!! + val props = BpmnFileObject(processObject.processes, processObject.diagram).toView(ActivitiObjectFactory()).processes[0].processElemPropertiesByElementId[task.id]!! props[PropertyType.ID]!!.value.shouldBeEqualTo(task.id.id) props[PropertyType.NAME]!!.value.shouldBeEqualTo(task.name) props[PropertyType.DOCUMENTATION]!!.value.shouldBeEqualTo(task.documentation) @@ -78,7 +77,7 @@ internal class ActivityDecisionTaskTest { return readDecisionTask(readAndUpdateProcess(parser, FILE, BooleanValueUpdatedEvent(elementId, property, newValue))) } - private fun readDecisionTask(processObject: BpmnProcessObject): BpmnDecisionTask { - return processObject.process.body!!.decisionTask!!.shouldHaveSingleItem() + private fun readDecisionTask(processObject: BpmnFileObject): BpmnDecisionTask { + return processObject.processes[0].body!!.decisionTask!!.shouldHaveSingleItem() } -} \ No newline at end of file +} diff --git a/activiti-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/activiti/parser/customservicetasks/ActivityMailTaskTest.kt b/activiti-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/activiti/parser/customservicetasks/ActivityMailTaskTest.kt index 8b6d61f5b..ae9807544 100644 --- a/activiti-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/activiti/parser/customservicetasks/ActivityMailTaskTest.kt +++ b/activiti-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/activiti/parser/customservicetasks/ActivityMailTaskTest.kt @@ -6,13 +6,12 @@ import com.valb3r.bpmn.intellij.plugin.activiti.parser.asResource import com.valb3r.bpmn.intellij.plugin.activiti.parser.readAndUpdateProcess import com.valb3r.bpmn.intellij.plugin.activiti.parser.testevents.BooleanValueUpdatedEvent import com.valb3r.bpmn.intellij.plugin.activiti.parser.testevents.StringValueUpdatedEvent -import com.valb3r.bpmn.intellij.plugin.bpmn.api.BpmnProcessObject +import com.valb3r.bpmn.intellij.plugin.bpmn.api.BpmnFileObject import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.BpmnElementId import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.elements.tasks.BpmnMailTask import com.valb3r.bpmn.intellij.plugin.bpmn.api.info.PropertyType import org.amshove.kluent.* import org.junit.jupiter.api.Test -import org.junit.jupiter.api.assertThrows private const val FILE = "custom-service-tasks/mail-task.bpmn20.xml" @@ -42,7 +41,7 @@ internal class ActivityMailTaskTest { task.html.shouldBeEqualTo("Hello") task.charset.shouldBeEqualTo("UTF-8") - val props = BpmnProcessObject(processObject.process, processObject.diagram).toView(ActivitiObjectFactory()).elemPropertiesByElementId[task.id]!! + val props = BpmnFileObject(processObject.processes, processObject.diagram).toView(ActivitiObjectFactory()).processes[0].processElemPropertiesByElementId[task.id]!! props[PropertyType.ID]!!.value.shouldBeEqualTo(task.id.id) props[PropertyType.NAME]!!.value.shouldBeEqualTo(task.name) props[PropertyType.DOCUMENTATION]!!.value.shouldBeEqualTo(task.documentation) @@ -104,7 +103,7 @@ internal class ActivityMailTaskTest { return readMailTask(readAndUpdateProcess(parser, FILE, BooleanValueUpdatedEvent(elementId, property, newValue))) } - private fun readMailTask(processObject: BpmnProcessObject): BpmnMailTask { - return processObject.process.body!!.mailTask!!.shouldHaveSingleItem() + private fun readMailTask(processObject: BpmnFileObject): BpmnMailTask { + return processObject.processes[0].body!!.mailTask!!.shouldHaveSingleItem() } -} \ No newline at end of file +} diff --git a/activiti-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/activiti/parser/customservicetasks/ActivityManualTaskTest.kt b/activiti-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/activiti/parser/customservicetasks/ActivityManualTaskTest.kt index 17d80bf97..d5f115669 100644 --- a/activiti-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/activiti/parser/customservicetasks/ActivityManualTaskTest.kt +++ b/activiti-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/activiti/parser/customservicetasks/ActivityManualTaskTest.kt @@ -6,7 +6,7 @@ import com.valb3r.bpmn.intellij.plugin.activiti.parser.asResource import com.valb3r.bpmn.intellij.plugin.activiti.parser.readAndUpdateProcess import com.valb3r.bpmn.intellij.plugin.activiti.parser.testevents.BooleanValueUpdatedEvent import com.valb3r.bpmn.intellij.plugin.activiti.parser.testevents.StringValueUpdatedEvent -import com.valb3r.bpmn.intellij.plugin.bpmn.api.BpmnProcessObject +import com.valb3r.bpmn.intellij.plugin.bpmn.api.BpmnFileObject import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.BpmnElementId import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.elements.tasks.BpmnManualTask import com.valb3r.bpmn.intellij.plugin.bpmn.api.info.PropertyType @@ -35,7 +35,7 @@ internal class ActivityManualTaskTest { // TODO 'exclusive' ? task.isForCompensation!!.shouldBeTrue() - val props = BpmnProcessObject(processObject.process, processObject.diagram).toView(ActivitiObjectFactory()).elemPropertiesByElementId[task.id]!! + val props = BpmnFileObject(processObject.processes, processObject.diagram).toView(ActivitiObjectFactory()).processes[0].processElemPropertiesByElementId[task.id]!! props[PropertyType.ID]!!.value.shouldBeEqualTo(task.id.id) props[PropertyType.NAME]!!.value.shouldBeEqualTo(task.name) props[PropertyType.DOCUMENTATION]!!.value.shouldBeEqualTo(task.documentation) @@ -70,7 +70,7 @@ internal class ActivityManualTaskTest { return readManualTask(readAndUpdateProcess(parser, FILE, BooleanValueUpdatedEvent(elementId, property, newValue))) } - private fun readManualTask(processObject: BpmnProcessObject): BpmnManualTask { - return processObject.process.body!!.manualTask!!.shouldHaveSingleItem() + private fun readManualTask(processObject: BpmnFileObject): BpmnManualTask { + return processObject.processes[0].body!!.manualTask!!.shouldHaveSingleItem() } -} \ No newline at end of file +} diff --git a/activiti-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/activiti/parser/customservicetasks/ActivityMuleTaskTest.kt b/activiti-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/activiti/parser/customservicetasks/ActivityMuleTaskTest.kt index 01a9abbc3..49618969c 100644 --- a/activiti-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/activiti/parser/customservicetasks/ActivityMuleTaskTest.kt +++ b/activiti-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/activiti/parser/customservicetasks/ActivityMuleTaskTest.kt @@ -6,7 +6,7 @@ import com.valb3r.bpmn.intellij.plugin.activiti.parser.asResource import com.valb3r.bpmn.intellij.plugin.activiti.parser.readAndUpdateProcess import com.valb3r.bpmn.intellij.plugin.activiti.parser.testevents.BooleanValueUpdatedEvent import com.valb3r.bpmn.intellij.plugin.activiti.parser.testevents.StringValueUpdatedEvent -import com.valb3r.bpmn.intellij.plugin.bpmn.api.BpmnProcessObject +import com.valb3r.bpmn.intellij.plugin.bpmn.api.BpmnFileObject import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.BpmnElementId import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.elements.tasks.BpmnMuleTask import com.valb3r.bpmn.intellij.plugin.bpmn.api.info.PropertyType @@ -39,7 +39,7 @@ internal class ActivityMuleTaskTest { task.payloadExpression.shouldBeEqualTo("\${foo.bar}") task.resultVariableCdata.shouldBeEqualTo("RESULT") - val props = BpmnProcessObject(processObject.process, processObject.diagram).toView(ActivitiObjectFactory()).elemPropertiesByElementId[task.id]!! + val props = BpmnFileObject(processObject.processes, processObject.diagram).toView(ActivitiObjectFactory()).processes[0].processElemPropertiesByElementId[task.id]!! props[PropertyType.ID]!!.value.shouldBeEqualTo(task.id.id) props[PropertyType.NAME]!!.value.shouldBeEqualTo(task.name) props[PropertyType.DOCUMENTATION]!!.value.shouldBeEqualTo(task.documentation) @@ -86,7 +86,7 @@ internal class ActivityMuleTaskTest { return readMuleTask(readAndUpdateProcess(parser, FILE, BooleanValueUpdatedEvent(elementId, property, newValue))) } - private fun readMuleTask(processObject: BpmnProcessObject): BpmnMuleTask { - return processObject.process.body!!.muleTask!!.shouldHaveSingleItem() + private fun readMuleTask(processObject: BpmnFileObject): BpmnMuleTask { + return processObject.processes[0].body!!.muleTask!!.shouldHaveSingleItem() } -} \ No newline at end of file +} diff --git a/activiti-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/activiti/parser/customservicetasks/ActivityReceiveTaskTest.kt b/activiti-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/activiti/parser/customservicetasks/ActivityReceiveTaskTest.kt index e6d3a52da..4257bd779 100644 --- a/activiti-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/activiti/parser/customservicetasks/ActivityReceiveTaskTest.kt +++ b/activiti-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/activiti/parser/customservicetasks/ActivityReceiveTaskTest.kt @@ -6,7 +6,7 @@ import com.valb3r.bpmn.intellij.plugin.activiti.parser.asResource import com.valb3r.bpmn.intellij.plugin.activiti.parser.readAndUpdateProcess import com.valb3r.bpmn.intellij.plugin.activiti.parser.testevents.BooleanValueUpdatedEvent import com.valb3r.bpmn.intellij.plugin.activiti.parser.testevents.StringValueUpdatedEvent -import com.valb3r.bpmn.intellij.plugin.bpmn.api.BpmnProcessObject +import com.valb3r.bpmn.intellij.plugin.bpmn.api.BpmnFileObject import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.BpmnElementId import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.elements.tasks.BpmnReceiveTask import com.valb3r.bpmn.intellij.plugin.bpmn.api.info.PropertyType @@ -35,7 +35,7 @@ internal class ActivityReceiveTaskTest { // TODO 'exclusive' ? task.isForCompensation!!.shouldBeTrue() - val props = BpmnProcessObject(processObject.process, processObject.diagram).toView(ActivitiObjectFactory()).elemPropertiesByElementId[task.id]!! + val props = BpmnFileObject(processObject.processes, processObject.diagram).toView(ActivitiObjectFactory()).processes[0].processElemPropertiesByElementId[task.id]!! props[PropertyType.ID]!!.value.shouldBeEqualTo(task.id.id) props[PropertyType.NAME]!!.value.shouldBeEqualTo(task.name) props[PropertyType.DOCUMENTATION]!!.value.shouldBeEqualTo(task.documentation) @@ -70,7 +70,7 @@ internal class ActivityReceiveTaskTest { return readReceiveTask(readAndUpdateProcess(parser, FILE, BooleanValueUpdatedEvent(elementId, property, newValue))) } - private fun readReceiveTask(processObject: BpmnProcessObject): BpmnReceiveTask { - return processObject.process.body!!.receiveTask!!.shouldHaveSingleItem() + private fun readReceiveTask(processObject: BpmnFileObject): BpmnReceiveTask { + return processObject.processes[0].body!!.receiveTask!!.shouldHaveSingleItem() } -} \ No newline at end of file +} diff --git a/activiti-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/activiti/parser/customservicetasks/ActivityScriptTaskTest.kt b/activiti-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/activiti/parser/customservicetasks/ActivityScriptTaskTest.kt index 435884dbf..81c780f65 100644 --- a/activiti-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/activiti/parser/customservicetasks/ActivityScriptTaskTest.kt +++ b/activiti-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/activiti/parser/customservicetasks/ActivityScriptTaskTest.kt @@ -6,7 +6,7 @@ import com.valb3r.bpmn.intellij.plugin.activiti.parser.asResource import com.valb3r.bpmn.intellij.plugin.activiti.parser.readAndUpdateProcess import com.valb3r.bpmn.intellij.plugin.activiti.parser.testevents.BooleanValueUpdatedEvent import com.valb3r.bpmn.intellij.plugin.activiti.parser.testevents.StringValueUpdatedEvent -import com.valb3r.bpmn.intellij.plugin.bpmn.api.BpmnProcessObject +import com.valb3r.bpmn.intellij.plugin.bpmn.api.BpmnFileObject import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.BpmnElementId import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.elements.tasks.BpmnScriptTask import com.valb3r.bpmn.intellij.plugin.bpmn.api.info.PropertyType @@ -38,7 +38,7 @@ internal class ActivityScriptTaskTest { task.autoStoreVariables.shouldBeEqualTo(false) task.scriptBody.shouldBeEqualTo("echo \"Foo Bar!\" > /tmp/foo.txt") - val props = BpmnProcessObject(processObject.process, processObject.diagram).toView(ActivitiObjectFactory()).elemPropertiesByElementId[task.id]!! + val props = BpmnFileObject(processObject.processes, processObject.diagram).toView(ActivitiObjectFactory()).processes[0].processElemPropertiesByElementId[task.id]!! props[PropertyType.ID]!!.value.shouldBeEqualTo(task.id.id) props[PropertyType.NAME]!!.value.shouldBeEqualTo(task.name) props[PropertyType.DOCUMENTATION]!!.value.shouldBeEqualTo(task.documentation) @@ -81,7 +81,7 @@ internal class ActivityScriptTaskTest { return readScriptTask(readAndUpdateProcess(parser, FILE, BooleanValueUpdatedEvent(elementId, property, newValue))) } - private fun readScriptTask(processObject: BpmnProcessObject): BpmnScriptTask { - return processObject.process.body!!.scriptTask!!.shouldHaveSingleItem() + private fun readScriptTask(processObject: BpmnFileObject): BpmnScriptTask { + return processObject.processes[0].body!!.scriptTask!!.shouldHaveSingleItem() } -} \ No newline at end of file +} diff --git a/activiti-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/activiti/parser/customservicetasks/ActivityServiceTaskEmptyUpdateWithNestedExtensionTest.kt b/activiti-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/activiti/parser/customservicetasks/ActivityServiceTaskEmptyUpdateWithNestedExtensionTest.kt index 9fe325ef2..1641d4cb0 100644 --- a/activiti-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/activiti/parser/customservicetasks/ActivityServiceTaskEmptyUpdateWithNestedExtensionTest.kt +++ b/activiti-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/activiti/parser/customservicetasks/ActivityServiceTaskEmptyUpdateWithNestedExtensionTest.kt @@ -3,7 +3,7 @@ package com.valb3r.bpmn.intellij.plugin.activiti.parser.customservicetasks import com.valb3r.bpmn.intellij.plugin.activiti.parser.ActivitiObjectFactory import com.valb3r.bpmn.intellij.plugin.activiti.parser.ActivitiParser import com.valb3r.bpmn.intellij.plugin.activiti.parser.asResource -import com.valb3r.bpmn.intellij.plugin.bpmn.api.BpmnProcessObject +import com.valb3r.bpmn.intellij.plugin.bpmn.api.BpmnFileObject import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.BpmnElementId import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.elements.tasks.BpmnServiceTask import com.valb3r.bpmn.intellij.plugin.bpmn.api.info.PropertyType @@ -28,14 +28,14 @@ internal class ActivityServiceTaskEmptyUpdateWithNestedExtensionTest { task.name.shouldBeEqualTo("Service task with extension") task.documentation.shouldBeNull() - val props = BpmnProcessObject(processObject.process, processObject.diagram).toView(ActivitiObjectFactory()).elemPropertiesByElementId[task.id]!! + val props = BpmnFileObject(processObject.processes, processObject.diagram).toView(ActivitiObjectFactory()).processes[0].processElemPropertiesByElementId[task.id]!! props[PropertyType.ID]!!.value.shouldBeEqualTo(task.id.id) props.getAll(PropertyType.FIELD_NAME)[0].value.shouldBeNull() props.getAll(PropertyType.FIELD_EXPRESSION)[0].value.shouldBeNull() props.getAll(PropertyType.FIELD_STRING)[0].value.shouldBeNull() } - private fun readServiceTask(processObject: BpmnProcessObject): BpmnServiceTask { - return processObject.process.body!!.serviceTask!!.shouldHaveSingleItem() + private fun readServiceTask(processObject: BpmnFileObject): BpmnServiceTask { + return processObject.processes[0].body!!.serviceTask!!.shouldHaveSingleItem() } } diff --git a/activiti-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/activiti/parser/customservicetasks/ActivityServiceTaskTest.kt b/activiti-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/activiti/parser/customservicetasks/ActivityServiceTaskTest.kt index bc0f9ec22..7518e6e3b 100644 --- a/activiti-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/activiti/parser/customservicetasks/ActivityServiceTaskTest.kt +++ b/activiti-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/activiti/parser/customservicetasks/ActivityServiceTaskTest.kt @@ -6,13 +6,12 @@ import com.valb3r.bpmn.intellij.plugin.activiti.parser.asResource import com.valb3r.bpmn.intellij.plugin.activiti.parser.readAndUpdateProcess import com.valb3r.bpmn.intellij.plugin.activiti.parser.testevents.BooleanValueUpdatedEvent import com.valb3r.bpmn.intellij.plugin.activiti.parser.testevents.StringValueUpdatedEvent -import com.valb3r.bpmn.intellij.plugin.bpmn.api.BpmnProcessObject +import com.valb3r.bpmn.intellij.plugin.bpmn.api.BpmnFileObject import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.BpmnElementId import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.elements.tasks.BpmnServiceTask import com.valb3r.bpmn.intellij.plugin.bpmn.api.info.PropertyType import org.amshove.kluent.* import org.junit.jupiter.api.Test -import org.junit.jupiter.api.assertThrows private const val FILE = "custom-service-tasks/service-task.bpmn20.xml" @@ -41,7 +40,7 @@ internal class ActivityServiceTaskTest { task.useLocalScopeForResultVariable.shouldBeNull() // TODO handle deep extension elements - field - val props = BpmnProcessObject(processObject.process, processObject.diagram).toView(ActivitiObjectFactory()).elemPropertiesByElementId[task.id]!! + val props = BpmnFileObject(processObject.processes, processObject.diagram).toView(ActivitiObjectFactory()).processes[0].processElemPropertiesByElementId[task.id]!! props[PropertyType.ID]!!.value.shouldBeEqualTo(task.id.id) props[PropertyType.NAME]!!.value.shouldBeEqualTo(task.name) props[PropertyType.DOCUMENTATION]!!.value.shouldBeEqualTo(task.documentation) @@ -95,7 +94,7 @@ internal class ActivityServiceTaskTest { return readServiceTask(readAndUpdateProcess(parser, FILE, BooleanValueUpdatedEvent(elementId, property, newValue))) } - private fun readServiceTask(processObject: BpmnProcessObject): BpmnServiceTask { - return processObject.process.body!!.serviceTask!!.shouldHaveSingleItem() + private fun readServiceTask(processObject: BpmnFileObject): BpmnServiceTask { + return processObject.processes[0].body!!.serviceTask!!.shouldHaveSingleItem() } -} \ No newline at end of file +} diff --git a/activiti-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/activiti/parser/customservicetasks/ActivityServiceTaskWithExtensionElementsTest.kt b/activiti-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/activiti/parser/customservicetasks/ActivityServiceTaskWithExtensionElementsTest.kt index 4a7e0a9e8..d017ede3e 100644 --- a/activiti-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/activiti/parser/customservicetasks/ActivityServiceTaskWithExtensionElementsTest.kt +++ b/activiti-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/activiti/parser/customservicetasks/ActivityServiceTaskWithExtensionElementsTest.kt @@ -5,7 +5,7 @@ import com.valb3r.bpmn.intellij.plugin.activiti.parser.ActivitiParser import com.valb3r.bpmn.intellij.plugin.activiti.parser.asResource import com.valb3r.bpmn.intellij.plugin.activiti.parser.readAndUpdateProcess import com.valb3r.bpmn.intellij.plugin.activiti.parser.testevents.StringValueUpdatedEvent -import com.valb3r.bpmn.intellij.plugin.bpmn.api.BpmnProcessObject +import com.valb3r.bpmn.intellij.plugin.bpmn.api.BpmnFileObject import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.BpmnElementId import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.elements.tasks.BpmnServiceTask import com.valb3r.bpmn.intellij.plugin.bpmn.api.info.PropertyType @@ -23,12 +23,12 @@ internal class ActivityServiceTaskWithExtensionElementsTest { @Test fun `Service task with failedJobRetryTimeCycle is parseable`() { val processObject = parser.parse(FILE.asResource()!!) - val task = processObject.process.body!!.serviceTask!![0] + val task = processObject.processes[0].body!!.serviceTask!![0] task.id.shouldBeEqualTo(elementId) task.failedJobRetryTimeCycle.shouldBeEqualTo("R10/PT5M") - val props = BpmnProcessObject(processObject.process, processObject.diagram).toView(ActivitiObjectFactory()).elemPropertiesByElementId[task.id]!! + val props = BpmnFileObject(processObject.processes, processObject.diagram).toView(ActivitiObjectFactory()).processes[0].processElemPropertiesByElementId[task.id]!! props[PropertyType.FAILED_JOB_RETRY_CYCLE]!!.value.shouldBeEqualTo(task.failedJobRetryTimeCycle) } @@ -41,7 +41,7 @@ internal class ActivityServiceTaskWithExtensionElementsTest { return readServiceTask(readAndUpdateProcess(parser, FILE, StringValueUpdatedEvent(elementId, property, newValue))) } - private fun readServiceTask(processObject: BpmnProcessObject): BpmnServiceTask { - return processObject.process.body!!.serviceTask!!.shouldHaveSingleItem() + private fun readServiceTask(processObject: BpmnFileObject): BpmnServiceTask { + return processObject.processes[0].body!!.serviceTask!!.shouldHaveSingleItem() } -} \ No newline at end of file +} diff --git a/activiti-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/activiti/parser/customservicetasks/ActivityServiceTaskWithNestedExtensionTest.kt b/activiti-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/activiti/parser/customservicetasks/ActivityServiceTaskWithNestedExtensionTest.kt index 28fde1d80..d07ec57ee 100644 --- a/activiti-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/activiti/parser/customservicetasks/ActivityServiceTaskWithNestedExtensionTest.kt +++ b/activiti-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/activiti/parser/customservicetasks/ActivityServiceTaskWithNestedExtensionTest.kt @@ -2,7 +2,7 @@ package com.valb3r.bpmn.intellij.plugin.activiti.parser.customservicetasks import com.valb3r.bpmn.intellij.plugin.activiti.parser.* import com.valb3r.bpmn.intellij.plugin.activiti.parser.testevents.StringValueUpdatedEvent -import com.valb3r.bpmn.intellij.plugin.bpmn.api.BpmnProcessObject +import com.valb3r.bpmn.intellij.plugin.bpmn.api.BpmnFileObject import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.BpmnElementId import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.elements.tasks.BpmnServiceTask import com.valb3r.bpmn.intellij.plugin.bpmn.api.info.Property @@ -28,7 +28,7 @@ internal class ActivityServiceTaskWithNestedExtensionTest { task.documentation.shouldBeNull() task.failedJobRetryTimeCycle?.shouldBeEqualTo("R10/PT5M") - val props = BpmnProcessObject(processObject.process, processObject.diagram).toView(ActivitiObjectFactory()).elemPropertiesByElementId[task.id]!! + val props = BpmnFileObject(processObject.processes, processObject.diagram).toView(ActivitiObjectFactory()).processes[0].processElemPropertiesByElementId[task.id]!! props[PropertyType.ID]!!.value.shouldBeEqualTo(task.id.id) props[PropertyType.NAME]!!.value.shouldBeEqualTo(task.name) props[PropertyType.DOCUMENTATION]!!.value.shouldBeEqualTo(task.documentation) @@ -66,8 +66,8 @@ internal class ActivityServiceTaskWithNestedExtensionTest { @Test fun `Add nested extension element`() { val process = readAndUpdateProcess(parser, FILE, StringValueUpdatedEvent(emptyElementId, PropertyType.FIELD_NAME, "new name", propertyIndex = listOf(""))) - val emptyTask = process.process.body!!.serviceTask!!.firstOrNull {it.id == emptyElementId}.shouldNotBeNull() - val props = BpmnProcessObject(process.process, process.diagram).toView(ActivitiObjectFactory()).elemPropertiesByElementId[emptyTask.id]!! + val emptyTask = process.processes[0].body!!.serviceTask!!.firstOrNull {it.id == emptyElementId}.shouldNotBeNull() + val props = BpmnFileObject(process.processes, process.diagram).toView(ActivitiObjectFactory()).processes[0].processElemPropertiesByElementId[emptyTask.id]!! props[PropertyType.FIELD_NAME]!!.shouldBeEqualTo(Property("new name", listOf("new name"))) } @@ -81,8 +81,8 @@ internal class ActivityServiceTaskWithNestedExtensionTest { StringValueUpdatedEvent(emptyElementId, PropertyType.FIELD_NAME, "", propertyIndex = listOf("new name")) ) ) - val emptyTask = process.process.body!!.serviceTask!!.firstOrNull {it.id == emptyElementId}.shouldNotBeNull() - val props = BpmnProcessObject(process.process, process.diagram).toView(ActivitiObjectFactory()).elemPropertiesByElementId[emptyTask.id]!! + val emptyTask = process.processes[0].body!!.serviceTask!!.firstOrNull {it.id == emptyElementId}.shouldNotBeNull() + val props = BpmnFileObject(process.processes, process.diagram).toView(ActivitiObjectFactory()).processes[0].processElemPropertiesByElementId[emptyTask.id]!! props[PropertyType.FIELD_NAME]?.value.shouldBeNull() } @@ -97,8 +97,8 @@ internal class ActivityServiceTaskWithNestedExtensionTest { StringValueUpdatedEvent(emptyElementId, PropertyType.FIELD_NAME, "other new name", propertyIndex = listOf("")), ) ) - val emptyTask = process.process.body!!.serviceTask!!.firstOrNull {it.id == emptyElementId}.shouldNotBeNull() - val props = BpmnProcessObject(process.process, process.diagram).toView(ActivitiObjectFactory()).elemPropertiesByElementId[emptyTask.id]!! + val emptyTask = process.processes[0].body!!.serviceTask!!.firstOrNull {it.id == emptyElementId}.shouldNotBeNull() + val props = BpmnFileObject(process.processes, process.diagram).toView(ActivitiObjectFactory()).processes[0].processElemPropertiesByElementId[emptyTask.id]!! props[PropertyType.FIELD_NAME]!!.shouldBeEqualTo(Property("other new name", listOf("other new name"))) } @@ -112,8 +112,8 @@ internal class ActivityServiceTaskWithNestedExtensionTest { StringValueUpdatedEvent(emptyElementId, PropertyType.FIELD_NAME, "new name", propertyIndex = listOf("")), ) ) - val emptyTask = process.process.body!!.serviceTask!!.firstOrNull {it.id == emptyElementId}.shouldNotBeNull() - val props = BpmnProcessObject(process.process, process.diagram).toView(ActivitiObjectFactory()).elemPropertiesByElementId[emptyTask.id]!! + val emptyTask = process.processes[0].body!!.serviceTask!!.firstOrNull {it.id == emptyElementId}.shouldNotBeNull() + val props = BpmnFileObject(process.processes, process.diagram).toView(ActivitiObjectFactory()).processes[0].processElemPropertiesByElementId[emptyTask.id]!! props[PropertyType.FIELD_NAME]!!.shouldBeEqualTo(Property("new name", listOf("new name"))) props[PropertyType.FIELD_EXPRESSION]!!.shouldBeEqualTo(Property("expression 1", listOf("new name"))) } @@ -129,7 +129,7 @@ internal class ActivityServiceTaskWithNestedExtensionTest { return readServiceTaskWithExtensions(readAndUpdateProcess(parser, FILE, StringValueUpdatedEvent(elementId, property, newValue, propertyIndex = listOf(propertyIndex)))) } - private fun readServiceTaskWithExtensions(processObject: BpmnProcessObject): BpmnServiceTask { - return processObject.process.body!!.serviceTask!!.shouldHaveSize(3)[0] + private fun readServiceTaskWithExtensions(processObject: BpmnFileObject): BpmnServiceTask { + return processObject.processes[0].body!!.serviceTask!!.shouldHaveSize(3)[0] } } diff --git a/activiti-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/activiti/parser/customservicetasks/ActivityUserTaskTest.kt b/activiti-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/activiti/parser/customservicetasks/ActivityUserTaskTest.kt index bbbc1ae8e..1310104e3 100644 --- a/activiti-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/activiti/parser/customservicetasks/ActivityUserTaskTest.kt +++ b/activiti-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/activiti/parser/customservicetasks/ActivityUserTaskTest.kt @@ -6,13 +6,12 @@ import com.valb3r.bpmn.intellij.plugin.activiti.parser.asResource import com.valb3r.bpmn.intellij.plugin.activiti.parser.readAndUpdateProcess import com.valb3r.bpmn.intellij.plugin.activiti.parser.testevents.BooleanValueUpdatedEvent import com.valb3r.bpmn.intellij.plugin.activiti.parser.testevents.StringValueUpdatedEvent -import com.valb3r.bpmn.intellij.plugin.bpmn.api.BpmnProcessObject +import com.valb3r.bpmn.intellij.plugin.bpmn.api.BpmnFileObject import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.BpmnElementId import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.elements.tasks.BpmnUserTask import com.valb3r.bpmn.intellij.plugin.bpmn.api.info.PropertyType import org.amshove.kluent.* import org.junit.jupiter.api.Test -import org.junit.jupiter.api.assertThrows private const val FILE = "custom-service-tasks/user-task.bpmn20.xml" @@ -42,7 +41,7 @@ internal class ActivityUserTaskTest { task.priority.shouldBeEqualTo("1") task.skipExpression.shouldBeNull() // Unsupported by Activity - val props = BpmnProcessObject(processObject.process, processObject.diagram).toView(ActivitiObjectFactory()).elemPropertiesByElementId[task.id]!! + val props = BpmnFileObject(processObject.processes, processObject.diagram).toView(ActivitiObjectFactory()).processes[0].processElemPropertiesByElementId[task.id]!! props[PropertyType.ID]!!.value.shouldBeEqualTo(task.id.id) props[PropertyType.NAME]!!.value.shouldBeEqualTo(task.name) props[PropertyType.DOCUMENTATION]!!.value.shouldBeEqualTo(task.documentation) @@ -103,7 +102,7 @@ internal class ActivityUserTaskTest { return readUserTask(readAndUpdateProcess(parser, FILE, BooleanValueUpdatedEvent(elementId, property, newValue))) } - private fun readUserTask(processObject: BpmnProcessObject): BpmnUserTask { - return processObject.process.body!!.userTask!!.shouldHaveSingleItem() + private fun readUserTask(processObject: BpmnFileObject): BpmnUserTask { + return processObject.processes[0].body!!.userTask!!.shouldHaveSingleItem() } -} \ No newline at end of file +} diff --git a/activiti-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/activiti/parser/customservicetasks/ActivityUserTaskWithNestedExtensionTest.kt b/activiti-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/activiti/parser/customservicetasks/ActivityUserTaskWithNestedExtensionTest.kt index 50bd09c61..4ee466791 100644 --- a/activiti-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/activiti/parser/customservicetasks/ActivityUserTaskWithNestedExtensionTest.kt +++ b/activiti-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/activiti/parser/customservicetasks/ActivityUserTaskWithNestedExtensionTest.kt @@ -2,13 +2,11 @@ package com.valb3r.bpmn.intellij.plugin.activiti.parser.customservicetasks import com.valb3r.bpmn.intellij.plugin.activiti.parser.* import com.valb3r.bpmn.intellij.plugin.activiti.parser.testevents.StringValueUpdatedEvent -import com.valb3r.bpmn.intellij.plugin.bpmn.api.BpmnProcessObject +import com.valb3r.bpmn.intellij.plugin.bpmn.api.BpmnFileObject import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.BpmnElementId import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.elements.tasks.BpmnUserTask -import com.valb3r.bpmn.intellij.plugin.bpmn.api.info.FunctionalGroupType import com.valb3r.bpmn.intellij.plugin.bpmn.api.info.Property import com.valb3r.bpmn.intellij.plugin.bpmn.api.info.PropertyType -import com.valb3r.bpmn.intellij.plugin.bpmn.api.info.PropertyValueType import org.amshove.kluent.* import org.junit.jupiter.api.Test @@ -28,7 +26,7 @@ internal class ActivityUserTaskWithNestedExtensionTest { task.name.shouldBeEqualTo("A user task") task.documentation.shouldBeEqualTo("A user task to do") - val props = BpmnProcessObject(processObject.process, processObject.diagram).toView(ActivitiObjectFactory()).elemPropertiesByElementId[task.id]!! + val props = BpmnFileObject(processObject.processes, processObject.diagram).toView(ActivitiObjectFactory()).processes[0].processElemPropertiesByElementId[task.id]!! props[PropertyType.ID]!!.value.shouldBeEqualTo(task.id.id) props[PropertyType.NAME]!!.value.shouldBeEqualTo(task.name) props[PropertyType.DOCUMENTATION]!!.value.shouldBeEqualTo(task.documentation) @@ -94,7 +92,7 @@ internal class ActivityUserTaskWithNestedExtensionTest { val task = readEmptyUserTaskWithExtensions(processObject) task.id.shouldBeEqualTo(BpmnElementId("emptyUserTaskId")) - val props = BpmnProcessObject(processObject.process, processObject.diagram).toView(ActivitiObjectFactory()).elemPropertiesByElementId[task.id]!! + val props = BpmnFileObject(processObject.processes, processObject.diagram).toView(ActivitiObjectFactory()).processes[0].processElemPropertiesByElementId[task.id]!! props.getAll(PropertyType.FORM_PROPERTY_ID).shouldHaveSize(1) } @@ -102,11 +100,11 @@ internal class ActivityUserTaskWithNestedExtensionTest { return readUserTaskWithExtensions(readAndUpdateProcess(parser, FILE, StringValueUpdatedEvent(elementId, property, newValue, propertyIndex = propertyIndex.split(",")))) } - private fun readUserTaskWithExtensions(processObject: BpmnProcessObject): BpmnUserTask { - return processObject.process.body!!.userTask!!.shouldHaveSize(3)[0] + private fun readUserTaskWithExtensions(processObject: BpmnFileObject): BpmnUserTask { + return processObject.processes[0].body!!.userTask!!.shouldHaveSize(3)[0] } - private fun readEmptyUserTaskWithExtensions(processObject: BpmnProcessObject): BpmnUserTask { - return processObject.process.body!!.userTask!!.shouldHaveSize(3)[2] + private fun readEmptyUserTaskWithExtensions(processObject: BpmnFileObject): BpmnUserTask { + return processObject.processes[0].body!!.userTask!!.shouldHaveSize(3)[2] } } diff --git a/bpmn-intellij-plugin-common-tests/src/main/kotlin/com/valb3r/bpmn/intellij/plugin/core/tests/BaseUiTest.kt b/bpmn-intellij-plugin-common-tests/src/main/kotlin/com/valb3r/bpmn/intellij/plugin/core/tests/BaseUiTest.kt index 4d259a4f6..ab1fa31ef 100644 --- a/bpmn-intellij-plugin-common-tests/src/main/kotlin/com/valb3r/bpmn/intellij/plugin/core/tests/BaseUiTest.kt +++ b/bpmn-intellij-plugin-common-tests/src/main/kotlin/com/valb3r/bpmn/intellij/plugin/core/tests/BaseUiTest.kt @@ -8,8 +8,8 @@ import com.intellij.openapi.vfs.VirtualFile import com.intellij.util.messages.MessageBus import com.intellij.util.messages.MessageBusConnection import com.nhaarman.mockitokotlin2.* +import com.valb3r.bpmn.intellij.plugin.bpmn.api.BpmnFileObject import com.valb3r.bpmn.intellij.plugin.bpmn.api.BpmnParser -import com.valb3r.bpmn.intellij.plugin.bpmn.api.BpmnProcessObject import com.valb3r.bpmn.intellij.plugin.bpmn.api.PropertyTable import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.BpmnElementId import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.BpmnProcess @@ -146,17 +146,22 @@ abstract class BaseUiTest { protected val uiEventBus = setUiEventBus(project, UiEventBus()) protected var renderResult: RenderResult? = null - protected val basicProcess = BpmnProcessObject( + protected val basicProcess = BpmnFileObject( + listOf( BpmnProcess( - parentProcessBpmnId, - "mainProcess", - null, - null, - null, - null - ), - mutableListOf() + parentProcessBpmnId, + "mainProcess", + null, + null, + null, + null, + null + ) + ), + mutableListOf(), + mutableListOf() ) + protected val mainProcessOfBasicProcess = basicProcess.processes[0] protected val basicProcessBody = BpmnProcessBody(null, null, null, null, null, null, null, null, null, null, @@ -318,7 +323,7 @@ abstract class BaseUiTest { bounds = BoundsElement(intermediateX, intermediateY, taskSize, taskSize) ) updateEventsRegistry(project).addObjectEvent( - BpmnShapeObjectAddedEvent(WithParentId(basicProcess.process.id, task), shape, PropertyTable(mutableMapOf(PropertyType.ID to mutableListOf(Property(task.id))))) + BpmnShapeObjectAddedEvent(WithParentId(mainProcessOfBasicProcess.id, task), shape, PropertyTable(mutableMapOf(PropertyType.ID to mutableListOf(Property(task.id))))) ) return task.id @@ -411,12 +416,12 @@ abstract class BaseUiTest { protected fun prepareOneSubProcessView() { val process = basicProcess.copy( - basicProcess.process.copy( - body = basicProcessBody.copy(subProcess = listOf(bpmnSubProcess)) + listOf( + mainProcessOfBasicProcess.copy(body = basicProcessBody.copy(subProcess = listOf(bpmnSubProcess))) ), - listOf(DiagramElement( + diagram = listOf(DiagramElement( diagramMainElementId, - PlaneElement(diagramMainPlaneElementId, basicProcess.process.id, listOf(diagramSubProcess), listOf())) + PlaneElement(diagramMainPlaneElementId, mainProcessOfBasicProcess.id, listOf(diagramSubProcess), listOf())) ) ) whenever(parser.parse("")).thenReturn(process) @@ -425,18 +430,19 @@ abstract class BaseUiTest { protected fun prepareOneSubProcessWithTwoServiceTasksView() { val process = basicProcess.copy( - basicProcess.process.copy( + listOf( + mainProcessOfBasicProcess.copy( body = basicProcessBody.copy(serviceTask = listOf(bpmnServiceTaskStart, bpmnServiceTaskEnd), subProcess = listOf(bpmnSubProcess)), children = mapOf( subprocessBpmnId to basicProcessBody.copy(serviceTask = listOf(bpmnServiceTaskStart, bpmnServiceTaskEnd)) - ) + )) ), - listOf( + diagram = listOf( DiagramElement( diagramMainElementId, PlaneElement( diagramMainPlaneElementId, - basicProcess.process.id, + mainProcessOfBasicProcess.id, listOf(diagramSubProcess, diagramServiceTaskStart, diagramServiceTaskEnd), listOf() ) @@ -449,18 +455,19 @@ abstract class BaseUiTest { protected fun prepareOneSubProcessWithTwoLinkedServiceTasksView() { val process = basicProcess.copy( - basicProcess.process.copy( + listOf( + mainProcessOfBasicProcess.copy( body = basicProcessBody.copy(subProcess = listOf(bpmnSubProcess)), children = mapOf( subprocessBpmnId to basicProcessBody.copy(serviceTask = listOf(bpmnServiceTaskStart, bpmnServiceTaskEnd)) - ) + )) ), - listOf( + diagram = listOf( DiagramElement( diagramMainElementId, PlaneElement( diagramMainPlaneElementId, - basicProcess.process.id, + mainProcessOfBasicProcess.id, listOf(diagramSubProcess, diagramServiceTaskStart, diagramServiceTaskEnd), listOf() ) @@ -475,19 +482,19 @@ abstract class BaseUiTest { protected fun prepareOneSubProcessThenNestedSubProcessWithOneServiceTaskView() { val process = basicProcess.copy( - basicProcess.process.copy( + listOf(mainProcessOfBasicProcess.copy( body = basicProcessBody.copy(serviceTask = listOf(bpmnServiceTaskStart, bpmnServiceTaskEnd), subProcess = listOf(bpmnSubProcess)), children = mapOf( subprocessBpmnId to basicProcessBody.copy(subProcess = listOf(bpmnNestedSubProcess)), subprocessInSubProcessBpmnId to basicProcessBody.copy(serviceTask = listOf(bpmnServiceTaskStart)) - ) + )) ), - listOf( + diagram = listOf( DiagramElement( diagramMainElementId, PlaneElement( diagramMainPlaneElementId, - basicProcess.process.id, + mainProcessOfBasicProcess.id, listOf(diagramSubProcess, diagramNestedSubProcess, diagramServiceTaskStart), listOf() ) @@ -507,19 +514,20 @@ abstract class BaseUiTest { ) val process = basicProcess.copy( - basicProcess.process.copy( + listOf( + mainProcessOfBasicProcess.copy( body = basicProcessBody.copy(serviceTask = listOf(bpmnServiceTaskStart, bpmnServiceTaskEnd), subProcess = listOf(bpmnSubProcess), boundaryErrorEvent = listOf(boundaryEventOnRoot)), children = mapOf( subprocessBpmnId to basicProcessBody.copy(subProcess = listOf(bpmnNestedSubProcess)), subprocessInSubProcessBpmnId to basicProcessBody.copy(serviceTask = listOf(bpmnServiceTaskStart)) - ) + )) ), - listOf( + diagram = listOf( DiagramElement( diagramMainElementId, PlaneElement( diagramMainPlaneElementId, - basicProcess.process.id, + mainProcessOfBasicProcess.id, listOf(diagramSubProcess, diagramNestedSubProcess, diagramServiceTaskStart, boundaryEventOnRootShape), listOf() ) @@ -532,19 +540,19 @@ abstract class BaseUiTest { protected fun prepareOneSubProcessThenNestedSubProcessWithReversedChildParentOrder() { val process = basicProcess.copy( - basicProcess.process.copy( + listOf(mainProcessOfBasicProcess.copy( body = basicProcessBody.copy(subProcess = listOf(bpmnSubProcess)), children = mapOf( subprocessBpmnId to basicProcessBody.copy(subProcess = listOf(bpmnNestedSubProcess)), subprocessInSubProcessBpmnId to basicProcessBody.copy() - ) + )) ), - listOf( + diagram = listOf( DiagramElement( diagramMainElementId, PlaneElement( diagramMainPlaneElementId, - basicProcess.process.id, + mainProcessOfBasicProcess.id, listOf(diagramNestedSubProcess, diagramSubProcess), listOf() ) @@ -557,12 +565,12 @@ abstract class BaseUiTest { protected fun prepareSendEventTask(){ val process = basicProcess.copy( - basicProcess.process.copy( + listOf(basicProcess.processes[0].copy( body = basicProcessBody.copy(sendEventTask = listOf(bpmnSendEventTask)) - ), - listOf(DiagramElement( + )), + diagram = listOf(DiagramElement( diagramMainElementId, - PlaneElement(diagramMainPlaneElementId, basicProcess.process.id, listOf(diagramSendEventTask), listOf())) + PlaneElement(diagramMainPlaneElementId, basicProcess.processes[0].id, listOf(diagramSendEventTask), listOf())) ) ) whenever(parser.parse("")).thenReturn(process) @@ -591,12 +599,12 @@ abstract class BaseUiTest { protected fun prepareUserTask(task: BpmnUserTask) { val process = basicProcess.copy( - basicProcess.process.copy( + listOf(basicProcess.processes[0].copy( body = basicProcessBody.copy(userTask = listOf(task)) - ), - listOf(DiagramElement( + )), + diagram = listOf(DiagramElement( diagramMainElementId, - PlaneElement(diagramMainPlaneElementId, basicProcess.process.id, listOf(diagramUserTask), listOf())) + PlaneElement(diagramMainPlaneElementId, basicProcess.processes[0].id, listOf(diagramUserTask), listOf())) ) ) whenever(parser.parse("")).thenReturn(process) @@ -609,12 +617,12 @@ abstract class BaseUiTest { protected fun prepareTwoServiceTaskView(one: BpmnServiceTask, two: BpmnServiceTask) { val process = basicProcess.copy( - basicProcess.process.copy( + listOf(mainProcessOfBasicProcess.copy( body = basicProcessBody.copy(serviceTask = listOf(one, two)) - ), - listOf(DiagramElement( + )), + diagram = listOf(DiagramElement( diagramMainElementId, - PlaneElement(diagramMainPlaneElementId, basicProcess.process.id, listOf(diagramServiceTaskStart, diagramServiceTaskEnd), listOf())) + PlaneElement(diagramMainPlaneElementId, mainProcessOfBasicProcess.id, listOf(diagramServiceTaskStart, diagramServiceTaskEnd), listOf())) ) ) whenever(parser.parse("")).thenReturn(process) @@ -630,12 +638,12 @@ abstract class BaseUiTest { ) val process = basicProcess.copy( - basicProcess.process.copy( + listOf(mainProcessOfBasicProcess.copy( body = basicProcessBody.copy(serviceTask = listOf(bpmnServiceTaskStart), boundaryErrorEvent = listOf(boundaryEventOnServiceTask)) - ), - listOf(DiagramElement( + )), + diagram = listOf(DiagramElement( diagramMainElementId, - PlaneElement(diagramMainPlaneElementId, basicProcess.process.id, listOf(diagramServiceTaskStart, boundaryEventOnServiceTaskShape), listOf())) + PlaneElement(diagramMainPlaneElementId, mainProcessOfBasicProcess.id, listOf(diagramServiceTaskStart, boundaryEventOnServiceTaskShape), listOf())) ) ) whenever(parser.parse("")).thenReturn(process) @@ -651,12 +659,12 @@ abstract class BaseUiTest { ) val process = basicProcess.copy( - basicProcess.process.copy( + listOf(mainProcessOfBasicProcess.copy( body = basicProcessBody.copy(serviceTask = listOf(bpmnServiceTaskStart), boundaryErrorEvent = listOf(boundaryEventOnRoot)) - ), - listOf(DiagramElement( + )), + diagram = listOf(DiagramElement( diagramMainElementId, - PlaneElement(diagramMainPlaneElementId, basicProcess.process.id, listOf(diagramServiceTaskStart, boundaryEventOnRootShape), listOf())) + PlaneElement(diagramMainPlaneElementId, mainProcessOfBasicProcess.id, listOf(diagramServiceTaskStart, boundaryEventOnRootShape), listOf())) ) ) whenever(parser.parse("")).thenReturn(process) @@ -672,15 +680,15 @@ abstract class BaseUiTest { ) val process = basicProcess.copy( - basicProcess.process.copy( + listOf(mainProcessOfBasicProcess.copy( body = basicProcessBody.copy(subProcess = listOf(bpmnSubProcess), boundaryErrorEvent = listOf(boundaryEventOnRoot)), children = mapOf( subprocessBpmnId to basicProcessBody.copy(serviceTask = listOf(bpmnServiceTaskStart)) ) - ), - listOf(DiagramElement( + )), + diagram = listOf(DiagramElement( diagramMainElementId, - PlaneElement(diagramMainPlaneElementId, basicProcess.process.id, listOf(diagramSubProcess, diagramServiceTaskStart, boundaryEventOnRootShape), listOf())) + PlaneElement(diagramMainPlaneElementId, mainProcessOfBasicProcess.id, listOf(diagramSubProcess, diagramServiceTaskStart, boundaryEventOnRootShape), listOf())) ) ) whenever(parser.parse("")).thenReturn(process) @@ -696,15 +704,15 @@ abstract class BaseUiTest { ) val process = basicProcess.copy( - basicProcess.process.copy( + listOf(mainProcessOfBasicProcess.copy( body = basicProcessBody.copy(subProcess = listOf(bpmnSubProcess)), children = mapOf( subprocessBpmnId to basicProcessBody.copy(serviceTask = listOf(bpmnServiceTaskStart), boundaryErrorEvent = listOf(boundaryEventOnServiceTask)) ) - ), - listOf(DiagramElement( + )), + diagram = listOf(DiagramElement( diagramMainElementId, - PlaneElement(diagramMainPlaneElementId, basicProcess.process.id, listOf(diagramSubProcess, diagramServiceTaskStart, boundaryEventOnServiceTaskShape), listOf())) + PlaneElement(diagramMainPlaneElementId, mainProcessOfBasicProcess.id, listOf(diagramSubProcess, diagramServiceTaskStart, boundaryEventOnServiceTaskShape), listOf())) ) ) whenever(parser.parse("")).thenReturn(process) @@ -720,13 +728,13 @@ abstract class BaseUiTest { ) val process = basicProcess.copy( - basicProcess.process.copy( + listOf(mainProcessOfBasicProcess.copy( body = basicProcessBody.copy(serviceTask = listOf(bpmnServiceTaskStart), boundaryErrorEvent = listOf(boundaryEventOnServiceTask), subProcess = listOf(bpmnSubProcess)), children = mapOf(subprocessBpmnId to basicProcessBody) - ), - listOf(DiagramElement( + )), + diagram = listOf(DiagramElement( diagramMainElementId, - PlaneElement(diagramMainPlaneElementId, basicProcess.process.id, listOf(diagramSubProcess, diagramServiceTaskStart, boundaryEventOnServiceTaskShape), listOf())) + PlaneElement(diagramMainPlaneElementId, mainProcessOfBasicProcess.id, listOf(diagramSubProcess, diagramServiceTaskStart, boundaryEventOnServiceTaskShape), listOf())) ) ) whenever(parser.parse("")).thenReturn(process) @@ -742,7 +750,7 @@ abstract class BaseUiTest { ) val process = basicProcess.copy( - basicProcess.process.copy( + listOf(mainProcessOfBasicProcess.copy( body = basicProcessBody.copy(subProcess = listOf(bpmnSubProcess)), children = mapOf( subprocessBpmnId to basicProcessBody.copy( @@ -755,13 +763,13 @@ abstract class BaseUiTest { sequenceFlow = listOf(bpmnSequenceFlow) ) ) - ), - listOf( + )), + diagram = listOf( DiagramElement( diagramMainElementId, PlaneElement( diagramMainPlaneElementId, - basicProcess.process.id, + mainProcessOfBasicProcess.id, listOf(diagramNestedSubProcess, diagramSubProcess, diagramServiceTaskStart, diagramServiceTaskEnd, boundaryEventOnServiceTaskShape), listOf(diagramSequenceFlow) ) diff --git a/bpmn-intellij-plugin-core/src/main/kotlin/com/valb3r/bpmn/intellij/plugin/core/CanvasBuilder.kt b/bpmn-intellij-plugin-core/src/main/kotlin/com/valb3r/bpmn/intellij/plugin/core/CanvasBuilder.kt index 89754edd4..717fb1521 100644 --- a/bpmn-intellij-plugin-core/src/main/kotlin/com/valb3r/bpmn/intellij/plugin/core/CanvasBuilder.kt +++ b/bpmn-intellij-plugin-core/src/main/kotlin/com/valb3r/bpmn/intellij/plugin/core/CanvasBuilder.kt @@ -60,9 +60,11 @@ class CanvasBuilder( initializeUpdateEventsRegistry(project, committerFactory.invoke(parser)) val data = readFile(bpmnFile) - val process = parser.parse(data) + val processes = parser.parse(data) + val factory = newElementsFactory(project) + val view = processes.toView(factory) newPropertiesVisualizer(project, properties, dropDownFactory, classEditorFactory, editorFactory, textFieldFactory, multiLineExpandableTextFieldFactory, checkboxFieldFactory, buttonFactory, arrowButtonFactory) - canvas.reset(data, process.toView(newElementsFactory(project)), bpmnProcessRenderer) + canvas.reset(data, view, bpmnProcessRenderer) // FIXME - wrapper class for processes currentVfsConnection?.let { it.disconnect(); it.dispose() } currentPaintConnection?.let { it.disconnect(); it.dispose() } @@ -126,4 +128,4 @@ class CanvasBuilder( } private fun readFile(bpmnFile: VirtualFile) = String(bpmnFile.contentsToByteArray(), UTF_8) -} \ No newline at end of file +} diff --git a/bpmn-intellij-plugin-core/src/main/kotlin/com/valb3r/bpmn/intellij/plugin/core/actions/ElementRemoveActionHandler.kt b/bpmn-intellij-plugin-core/src/main/kotlin/com/valb3r/bpmn/intellij/plugin/core/actions/ElementRemoveActionHandler.kt index bd48851d9..ef9433b62 100644 --- a/bpmn-intellij-plugin-core/src/main/kotlin/com/valb3r/bpmn/intellij/plugin/core/actions/ElementRemoveActionHandler.kt +++ b/bpmn-intellij-plugin-core/src/main/kotlin/com/valb3r/bpmn/intellij/plugin/core/actions/ElementRemoveActionHandler.kt @@ -28,9 +28,9 @@ class ElementRemoveActionHandler(private val project: Project) { updateEventsRegistry(project).addElementRemovedEvent( targetIds.map { DiagramElementRemovedEvent(it) }, - targetIds.mapNotNull { state.currentState.elementByDiagramId[it] }.map { BpmnElementRemovedEvent(it) } + targetIds.mapNotNull { state.currentState.elementsByDiagramId[it] }.map { BpmnElementRemovedEvent(it) } ) currentCanvas(project).repaint() } -} \ No newline at end of file +} diff --git a/bpmn-intellij-plugin-core/src/main/kotlin/com/valb3r/bpmn/intellij/plugin/core/actions/copypaste/CopyPasteActionHandler.kt b/bpmn-intellij-plugin-core/src/main/kotlin/com/valb3r/bpmn/intellij/plugin/core/actions/copypaste/CopyPasteActionHandler.kt index a2d9f7314..795f057c5 100644 --- a/bpmn-intellij-plugin-core/src/main/kotlin/com/valb3r/bpmn/intellij/plugin/core/actions/copypaste/CopyPasteActionHandler.kt +++ b/bpmn-intellij-plugin-core/src/main/kotlin/com/valb3r/bpmn/intellij/plugin/core/actions/copypaste/CopyPasteActionHandler.kt @@ -89,7 +89,7 @@ class CopyPasteActionHandler(private val clipboard: SystemClipboard) { val alreadyRemovedBpmn = mutableSetOf() val elemsToDelete = elementIdsToCopyOrCut(ctx) - .mapNotNull { ctx.currentState.elementByDiagramId[it] } + .mapNotNull { ctx.currentState.elementsByDiagramId[it] } .filter { if (alreadyRemovedBpmn.contains(it)) false else { alreadyRemovedBpmn += it; true } } .mapNotNull { elementsById[it] } @@ -262,7 +262,7 @@ class CopyPasteActionHandler(private val clipboard: SystemClipboard) { private fun ensureRootElementsComeFirst(idsToCopy: MutableList, ctx: RenderState, elementsById: Map): MutableList { return idsToCopy - .sortedByDescending { ctx.currentState.elementByDiagramId[it]?.let {id -> elementsById[id] }?.zIndex() ?: 0 } + .sortedByDescending { ctx.currentState.elementsByDiagramId[it]?.let { id -> elementsById[id] }?.zIndex() ?: 0 } .toMutableList() } @@ -291,7 +291,7 @@ class CopyPasteActionHandler(private val clipboard: SystemClipboard) { idReplacements: MutableMap, processedElementIds: MutableSet ) { - val bpmnId = ctx.currentState.elementByDiagramId[diagramId] ?: return + val bpmnId = ctx.currentState.elementsByDiagramId[diagramId] ?: return val withParentId = ctx.currentState.elementByBpmnId[bpmnId] ?: return val props = ctx.currentState.elemPropertiesByStaticElementId[bpmnId] ?: return if (processedElementIds.contains(bpmnId)) { diff --git a/bpmn-intellij-plugin-core/src/main/kotlin/com/valb3r/bpmn/intellij/plugin/core/events/Events.kt b/bpmn-intellij-plugin-core/src/main/kotlin/com/valb3r/bpmn/intellij/plugin/core/events/Events.kt index bccc43fa4..c19f20de8 100644 --- a/bpmn-intellij-plugin-core/src/main/kotlin/com/valb3r/bpmn/intellij/plugin/core/events/Events.kt +++ b/bpmn-intellij-plugin-core/src/main/kotlin/com/valb3r/bpmn/intellij/plugin/core/events/Events.kt @@ -4,6 +4,7 @@ import com.valb3r.bpmn.intellij.plugin.bpmn.api.PropertyTable import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.BpmnElementId import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.elements.WithBpmnId import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.elements.WithParentId +import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.elements.lanes.BpmnFlowNodeRef import com.valb3r.bpmn.intellij.plugin.bpmn.api.diagram.DiagramElementId import com.valb3r.bpmn.intellij.plugin.bpmn.api.diagram.elements.ShapeElement import com.valb3r.bpmn.intellij.plugin.bpmn.api.events.* @@ -36,6 +37,8 @@ data class BpmnElementRemovedEvent(override val bpmnElementId: BpmnElementId): B data class BpmnShapeObjectAddedEvent(override val bpmnObject: WithParentId, override val shape: ShapeElement, override val props: PropertyTable): BpmnShapeObjectAdded +data class BpmnFlowNodeRefAddedEvent(override val bpmnObject: BpmnFlowNodeRef): BpmnFlowNodeRefAdded + data class BpmnEdgeObjectAddedEvent(override val bpmnObject: WithParentId, override val edge: EdgeWithIdentifiableWaypoints, override val props: PropertyTable): BpmnEdgeObjectAdded data class UiOnlyValueAddedEvent(val bpmnElementId: BpmnElementId, val property: PropertyType, val newValue: Any?, val propertyIndex: List? = null): EventUiOnly diff --git a/bpmn-intellij-plugin-core/src/main/kotlin/com/valb3r/bpmn/intellij/plugin/core/events/ProcessModelUpdateEvents.kt b/bpmn-intellij-plugin-core/src/main/kotlin/com/valb3r/bpmn/intellij/plugin/core/events/ProcessModelUpdateEvents.kt index 8070f7208..e3fd3d455 100644 --- a/bpmn-intellij-plugin-core/src/main/kotlin/com/valb3r/bpmn/intellij/plugin/core/events/ProcessModelUpdateEvents.kt +++ b/bpmn-intellij-plugin-core/src/main/kotlin/com/valb3r/bpmn/intellij/plugin/core/events/ProcessModelUpdateEvents.kt @@ -170,6 +170,7 @@ class ProcessModelUpdateEvents(private val committer: FileCommitter, private val is BpmnEdgeObjectAddedEvent -> addObjectEdgeEvent(toStore as Order) is BpmnElementRemovedEvent -> removeBpmnElement(event.bpmnElementId , toStore as Order ) is BpmnElementTypeChangeEvent -> changeBpmnElement(event.elementId , toStore as Order, toStore as Order) + is BpmnFlowNodeRefAddedEvent -> { /* Nothing here - purely fictitious event handled by XML parser only */ } else -> throw IllegalArgumentException("Can't bulk add: " + event::class.qualifiedName) } } diff --git a/bpmn-intellij-plugin-core/src/main/kotlin/com/valb3r/bpmn/intellij/plugin/core/popupmenu/CommonCanvasPopupMenuProvider.kt b/bpmn-intellij-plugin-core/src/main/kotlin/com/valb3r/bpmn/intellij/plugin/core/popupmenu/CommonCanvasPopupMenuProvider.kt index b2fd817f3..2ffe50172 100644 --- a/bpmn-intellij-plugin-core/src/main/kotlin/com/valb3r/bpmn/intellij/plugin/core/popupmenu/CommonCanvasPopupMenuProvider.kt +++ b/bpmn-intellij-plugin-core/src/main/kotlin/com/valb3r/bpmn/intellij/plugin/core/popupmenu/CommonCanvasPopupMenuProvider.kt @@ -9,6 +9,8 @@ import com.valb3r.bpmn.intellij.plugin.core.events.BpmnElementTypeChangeEvent import com.valb3r.bpmn.intellij.plugin.core.events.BpmnShapeObjectAddedEvent import com.valb3r.bpmn.intellij.plugin.core.events.updateEventsRegistry import com.valb3r.bpmn.intellij.plugin.core.newelements.newElementsFactory +import com.valb3r.bpmn.intellij.plugin.core.render.elements.BaseBpmnRenderElement +import com.valb3r.bpmn.intellij.plugin.core.render.lastRenderedState import com.valb3r.bpmn.intellij.plugin.core.render.snapToGridIfNecessary import com.valb3r.bpmn.intellij.plugin.core.state.currentStateProvider import java.awt.event.ActionEvent @@ -34,11 +36,17 @@ private fun newShapeElement(project: Project, sceneLocation: Poi class ShapeCreator (private val project: Project, private val clazz: KClass, private val sceneLocation: Point2D.Float, private val parent: BpmnElementId): ActionListener { override fun actionPerformed(e: ActionEvent?) { - val newObject = newElementsFactory(project).newBpmnObject(clazz) - val shape = newShapeElement(project, sceneLocation, newObject) + val probablyParentElement = lastRenderedState(project)!!.elementsById[parent]!! + if (probablyParentElement !is BaseBpmnRenderElement) { + // TODO - error here? + return + } - updateEventsRegistry(project).addObjectEvent( - BpmnShapeObjectAddedEvent(WithParentId(parent, newObject), shape, newElementsFactory(project).propertiesOf(newObject)) + updateEventsRegistry(project).addEvents( + probablyParentElement.onElementCreatedOnTopThis( + clazz, + newElementsFactory(project) + ) { newShapeElement(project, sceneLocation, it) } ) } } diff --git a/bpmn-intellij-plugin-core/src/main/kotlin/com/valb3r/bpmn/intellij/plugin/core/render/Canvas.kt b/bpmn-intellij-plugin-core/src/main/kotlin/com/valb3r/bpmn/intellij/plugin/core/render/Canvas.kt index d6d75c3f7..d51367ad1 100644 --- a/bpmn-intellij-plugin-core/src/main/kotlin/com/valb3r/bpmn/intellij/plugin/core/render/Canvas.kt +++ b/bpmn-intellij-plugin-core/src/main/kotlin/com/valb3r/bpmn/intellij/plugin/core/render/Canvas.kt @@ -7,7 +7,7 @@ import com.google.common.collect.EvictingQueue import com.google.common.math.Quantiles.percentiles import com.intellij.openapi.project.Project import com.intellij.util.ui.UIUtil -import com.valb3r.bpmn.intellij.plugin.bpmn.api.BpmnProcessObjectView +import com.valb3r.bpmn.intellij.plugin.bpmn.api.BpmnFileView import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.BpmnElementId import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.elements.BpmnSequenceFlow import com.valb3r.bpmn.intellij.plugin.bpmn.api.diagram.DiagramElementId @@ -25,6 +25,9 @@ import java.awt.Color import java.awt.Graphics import java.awt.Graphics2D import java.awt.RenderingHints +import java.awt.geom.AffineTransform +import java.awt.geom.Area +import java.awt.geom.PathIterator.SEG_CLOSE import java.awt.geom.Point2D import java.awt.geom.Rectangle2D import java.awt.image.BufferedImage @@ -184,14 +187,14 @@ open class Canvas(private val project: Project, private val settings: CanvasCons return renderedImage } - fun reset(fileContent: String, processObject: BpmnProcessObjectView, renderer: BpmnProcessRenderer) { + fun reset(fileContent: String, view: BpmnFileView, renderer: BpmnProcessRenderer) { this.cachedTreeState = null this.renderer = renderer this.latestOnScreenModelDimensions = null this.camera = Camera(settings.defaultCameraOrigin, Point2D.Float(settings.defaultZoomRatio, settings.defaultZoomRatio)) this.propsVisualizer = propertiesVisualizer(project) this.propsVisualizer?.clear() - this.stateProvider.resetStateTo(fileContent, processObject) + this.stateProvider.resetStateTo(fileContent, view) selectedElements = mutableSetOf() repaint() } @@ -425,7 +428,7 @@ open class Canvas(private val project: Project, private val settings: CanvasCons val elementIdForPropertiesTable = propertiesForElement.firstOrNull() val state = stateProvider.currentState() state - .elementByDiagramId[elementIdForPropertiesTable] + .elementsByDiagramId[elementIdForPropertiesTable] ?.let { elemId -> state.elemPropertiesByStaticElementId[elemId]?.let { propsVisualizer?.visualize( @@ -486,7 +489,7 @@ open class Canvas(private val project: Project, private val settings: CanvasCons continue } - val bpmnId = setOf(stateProvider.currentState().elementByDiagramId[elem.first], elem.second.bpmnElementId).filterNotNull().firstOrNull() ?: continue + val bpmnId = setOf(stateProvider.currentState().elementsByDiagramId[elem.first], elem.second.bpmnElementId).filterNotNull().firstOrNull() ?: continue val bpmnElem = stateProvider.currentState().elementByBpmnId[bpmnId] if (bpmnElem?.element is BpmnSequenceFlow) { continue @@ -517,15 +520,30 @@ open class Canvas(private val project: Project, private val settings: CanvasCons val intersection = areaByElement?.filter { it.value.area.intersects(withinRect) } val maxZindex = intersection?.maxBy { it: Map.Entry -> it.value.index } val result = mutableListOf() - val centerRect = Point2D.Float(withinRect.centerX.toFloat(), withinRect.centerY.toFloat()) + val minDistSq = fun (area: Area, pt: Point2D.Float): Float { + var minDist = Float.MAX_VALUE + val pts = FloatArray(6) + val iter = area.getPathIterator(AffineTransform()) + while (!iter.isDone) { + if (SEG_CLOSE == iter.currentSegment(pts)) { + iter.next() + continue + } + val curvePt = Point2D.Float(pts[0], pts[1]) + val dist = curvePt.distanceSq(pt).toFloat() + if (dist < minDist) { + minDist = dist + } + iter.next() + } + return minDist + } + intersection ?.filter { !excludeAreas.contains(it.value.areaType) } - ?.filter { it.value.index == maxZindex?.value?.index } + ?.filter { it.value.index == maxZindex?.value?.index || it.value.areaType == AreaType.EDGE } ?.minBy { it: Map.Entry -> - Point2D.Float( - it.value.area.bounds2D.centerX.toFloat(), - it.value.area.bounds2D.centerY.toFloat() - ).distance(centerRect) + minDistSq(it.value.area, cursorPoint) } ?.let { result += it.key; it.value.parentToSelect?.apply { result += this } } return result diff --git a/bpmn-intellij-plugin-core/src/main/kotlin/com/valb3r/bpmn/intellij/plugin/core/render/DefaultBpmnProcessRenderer.kt b/bpmn-intellij-plugin-core/src/main/kotlin/com/valb3r/bpmn/intellij/plugin/core/render/DefaultBpmnProcessRenderer.kt index f0dac3211..869db9f2e 100644 --- a/bpmn-intellij-plugin-core/src/main/kotlin/com/valb3r/bpmn/intellij/plugin/core/render/DefaultBpmnProcessRenderer.kt +++ b/bpmn-intellij-plugin-core/src/main/kotlin/com/valb3r/bpmn/intellij/plugin/core/render/DefaultBpmnProcessRenderer.kt @@ -1,7 +1,9 @@ package com.valb3r.bpmn.intellij.plugin.core.render import com.intellij.openapi.project.Project +import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.BpmnCollaboration import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.BpmnElementId +import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.BpmnParticipant import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.elements.WithBpmnId import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.elements.activities.BpmnCallActivity import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.elements.events.begin.* @@ -12,6 +14,7 @@ import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.elements.events.throwing.Bp import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.elements.events.throwing.BpmnIntermediateNoneThrowingEvent import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.elements.events.throwing.BpmnIntermediateSignalThrowingEvent import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.elements.gateways.* +import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.elements.lanes.BpmnLane import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.elements.subprocess.* import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.elements.tasks.* import com.valb3r.bpmn.intellij.plugin.bpmn.api.diagram.DiagramElementId @@ -27,9 +30,11 @@ import com.valb3r.bpmn.intellij.plugin.core.render.elements.BaseDiagramRenderEle import com.valb3r.bpmn.intellij.plugin.core.render.elements.RenderState import com.valb3r.bpmn.intellij.plugin.core.render.elements.edges.EdgeRenderElement import com.valb3r.bpmn.intellij.plugin.core.render.elements.elemIdToRemove +import com.valb3r.bpmn.intellij.plugin.core.render.elements.internal.InvisibleShape import com.valb3r.bpmn.intellij.plugin.core.render.elements.planes.PlaneRenderElement import com.valb3r.bpmn.intellij.plugin.core.render.elements.shapes.* import com.valb3r.bpmn.intellij.plugin.core.render.uieventbus.* +import com.valb3r.bpmn.intellij.plugin.core.settings.currentSettings import groovy.lang.Tuple2 import java.awt.BasicStroke import java.awt.geom.Point2D @@ -47,7 +52,7 @@ data class RenderedState(val state: RenderState, val elementsById: Map): Set { val result = mutableSetOf() - result += elem.map { state.currentState.elementByDiagramId[it] } + result += elem.map { state.currentState.elementsByDiagramId[it] } .mapNotNull { elementsById[it] } .flatMap { allChildrenOf(it) } @@ -68,6 +73,8 @@ data class RenderedState(val state: RenderState, val elementsById: Map() val currentState = ctx.stateProvider.currentState() - val history = currentDebugger(project)?.executionSequence(project, currentState.processId.id)?.history ?: emptyList() + val history = currentDebugger(project)?.executionSequence(project, currentState.primaryProcessId.id)?.history ?: emptyList() val state = RenderState( elementsByDiagramId, mutableMapOf(), @@ -156,7 +163,8 @@ class DefaultBpmnProcessRenderer(private val project: Project, val icons: IconPr val result = TreeState(state, elementsById, elementsByDiagramId, version) val root = createRootProcessElem({ result.state }, elements, elementsById) - createShapes({ result.state }, elements, elementsById) + createCollaborationAndCollaborationProcesses({ result.state }, root, elements, elementsById) + createShapes({ result.state }, root, elements, elementsById) createEdges({ result.state }, elements, elementsById) linkChildrenToParent({ result.state }, elementsById) // Not all elements have BpmnElementId, but they have DiagramElementId @@ -167,14 +175,30 @@ class DefaultBpmnProcessRenderer(private val project: Project, val icons: IconPr } private fun createRootProcessElem(state: () -> RenderState, elements: MutableList, elementsById: MutableMap): BaseBpmnRenderElement { - val processElem = PlaneRenderElement(state().currentState.processDiagramId(), state().currentState.processId, state, mutableListOf()) + val processElem = PlaneRenderElement(state().currentState.primaryProcessDiagramId(), state().currentState.primaryProcessId, state, mutableListOf()) elements += processElem - elementsById[state().currentState.processId] = processElem + elementsById[state().currentState.primaryProcessId] = processElem return processElem } - private fun createShapes(state: () -> RenderState, elements: MutableList, elementsById: MutableMap) { - state().currentState.shapes.forEach { + private fun createCollaborationAndCollaborationProcesses(state: () -> RenderState, root: BaseBpmnRenderElement, elements: MutableList, elementsById: MutableMap) { + state().currentState.elementByBpmnId.values.map { it.element }.filterIsInstance().filter { it.id != root.bpmnElementId }.forEach { + val processElem = InvisibleShape(DiagramElementId("__collaboration:_${it.id}"), it.id, state) + elements += processElem + elementsById[it.id] = processElem + } + + val rootProcessId = state().currentState.primaryProcessId + val collaborations = state().currentState.processes.filter { it != rootProcessId } + collaborations.forEach { + val processElem = InvisibleShape(DiagramElementId("__collaboration:_process_${it.id}"), it, state) + elements += processElem + elementsById[it] = processElem + } + } + + private fun createShapes(state: () -> RenderState, root: BaseBpmnRenderElement, elements: MutableList, elementsById: MutableMap) { + state().currentState.shapes.filter { it.bpmnElement != root.bpmnElementId }.forEach { val elem = state().currentState.elementByBpmnId[it.bpmnElement] elem?.let { bpmn -> mapFromShape(state, it.id, it, bpmn.element).let { shape -> @@ -196,7 +220,7 @@ class DefaultBpmnProcessRenderer(private val project: Project, val icons: IconPr private fun linkChildrenToParent(state: () -> RenderState, elementsById: MutableMap) { elementsById.forEach { (id, renderElem) -> val elem = state().currentState.elementByBpmnId[id] - elem?.parent?.let {elementsById[it]}?.let { if (it is BaseBpmnRenderElement) it else null }?.let { parent -> + elem?.parent?.let { elementsById[it] }?.let { if (it is BaseBpmnRenderElement) it else null }?.let { parent -> parent.children.add(renderElem) parent.let { renderElem.parents.add(it) } } @@ -249,6 +273,9 @@ class DefaultBpmnProcessRenderer(private val project: Project, val icons: IconPr is BpmnTransactionCollapsedSubprocess -> ExpandableShapeNoIcon(id, bpmn.id, isCollapsed(bpmn.id, state), icons.plus, icons.minus, shape, state, areaType = AreaType.SHAPE_THAT_NESTS) is BpmnCallActivity -> NoIconShape(id, bpmn.id, shape, state) is BpmnAdHocSubProcess -> BottomMiddleIconShape(id, bpmn.id, icons.tilde, shape, state, areaType = AreaType.SHAPE_THAT_NESTS) + is BpmnLane -> ShapeGroupElement(id, bpmn.id, shape, state, Colors.PROCESS_COLOR, Colors.ELEMENT_BORDER_COLOR, Colors.SUBPROCESS_TEXT_COLOR, areaType = AreaType.SHAPE_THAT_NESTS) + is BpmnParticipant -> ShapeGroupParentElement(id, bpmn.id, shape, state, Colors.PROCESS_COLOR, Colors.ELEMENT_BORDER_COLOR, Colors.SUBPROCESS_TEXT_COLOR, areaType = AreaType.SHAPE_THAT_NESTS) + is BpmnCollaboration -> InvisibleShape(id, bpmn.id, state) is BpmnExclusiveGateway -> IconShape(id, bpmn.id, icons.exclusiveGateway, shape, state) is BpmnParallelGateway -> IconShape(id, bpmn.id, icons.parallelGateway, shape, state) is BpmnInclusiveGateway -> IconShape(id, bpmn.id, icons.inclusiveGateway, shape, state) @@ -342,7 +369,7 @@ class DefaultBpmnProcessRenderer(private val project: Project, val icons: IconPr locationY += drawIconWithAction(state, zoomOutId, locationX, locationY, renderedArea, { currentUiEventBus(project).publish(ZoomOutEvent()) }, icons.zoomOut).second + iconMargin locationX = undoRedoStartMargin locationX += drawIconWithAction(state, zoomResetId, locationX, locationY, renderedArea, { currentUiEventBus(project).publish(ResetAndCenterEvent()) }, icons.zoomReset).first + iconMargin - locationY += drawIconWithAction(state, centerImageId, locationX, locationY, renderedArea, { currentUiEventBus(project).publish(CenterModelEvent()) }, icons.centerImage).first + iconMargin + locationY += drawIconWithAction(state, centerImageId, locationX, locationY, renderedArea, { currentUiEventBus(project).publish(CenterModelEvent()) }, icons.centerImage).second + iconMargin locationX = undoRedoStartMargin val currentGridState = gridState.get() val gridIcon = gridIcons[currentGridState]() @@ -352,7 +379,12 @@ class DefaultBpmnProcessRenderer(private val project: Project, val icons: IconPr } locationX += drawIconWithAction(state, gridStateId, locationX, locationY, renderedArea, nextGridStep, gridIcon).first + iconMargin val verticalAnchors = verticalAnchorsEnabled.get() - drawIconWithAction(state, anchorEnabled, locationX, locationY, renderedArea, { verticalAnchorsEnabled.set(!verticalAnchors)}, if (verticalAnchors) icons.anchorOff else icons.anchorOn).first + iconMargin + locationY += drawIconWithAction(state, anchorEnabled, locationX, locationY, renderedArea, { verticalAnchorsEnabled.set(!verticalAnchors)}, if (verticalAnchors) icons.anchorOff else icons.anchorOn).second + iconMargin + locationX = undoRedoStartMargin + + if (currentSettings().enableDevelopmentFunctions) { + locationX += drawIconWithAction(state, DiagramElementId("__development_tool_render_tree_state"), locationX, locationY, renderedArea, { dumpRenderTree(project) }, icons.dumpRenderTree).first + iconMargin + } } private fun drawIconWithAction( diff --git a/bpmn-intellij-plugin-core/src/main/kotlin/com/valb3r/bpmn/intellij/plugin/core/render/DevHelper.kt b/bpmn-intellij-plugin-core/src/main/kotlin/com/valb3r/bpmn/intellij/plugin/core/render/DevHelper.kt new file mode 100644 index 000000000..cc6e77040 --- /dev/null +++ b/bpmn-intellij-plugin-core/src/main/kotlin/com/valb3r/bpmn/intellij/plugin/core/render/DevHelper.kt @@ -0,0 +1,71 @@ +package com.valb3r.bpmn.intellij.plugin.core.render + +import com.intellij.openapi.project.Project +import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.BpmnElementId +import com.valb3r.bpmn.intellij.plugin.core.render.elements.BaseBpmnRenderElement +import com.valb3r.bpmn.intellij.plugin.core.render.elements.BaseDiagramRenderElement + +fun dumpRenderTree(project: Project) { + val renderState = lastRenderedState(project)!! + println("===== Mapped XML tree: =====") + val parentToElems = renderState.state.currentState.elementByBpmnId.entries + .groupBy { it.value.parent.id } + .mapValues { entry -> LinkedHashSet(entry.value.map { it.key.id }) } + dumpTree(renderState.elementsById, parentToElems) + println("===== End XML tree =====") + + println("===== Render tree: =====") + dumpTree(renderState.elementsById, rootToElemsByParent(renderState, renderState.state.ctx.cachedDom!!.domRoot)) + println("===== End Render tree =====") +} + +private fun rootToElemsByParent(state: RenderedState, root: BaseBpmnRenderElement): Map> { + val elemMap = state.state.elemMap + val front = linkedSetOf(root) + val result = linkedMapOf>() + while (front.isNotEmpty()) { + front.forEach { result.computeIfAbsent(it.parents.firstOrNull()?.bpmnElementId?.id ?: "") { mutableSetOf() }.add(it.bpmnElementId.id) } + val newFront = front.flatMap { it.children }.map { elemMap[it.elementId] }.filterIsInstance() + front.clear() + front.addAll(newFront) + } + + return result +} + +private fun dumpTree(elementsById: Map, elemsByParent: Map>) { + val childElems = LinkedHashSet(elemsByParent.values.flatten()) + val roots = LinkedHashSet(elemsByParent.keys.filter { !childElems.contains(it) }) + if (roots.isEmpty()) { + println("Cyclic structure detected, none of ${elemsByParent.keys} is standalone root") + elemsByParent.keys.forEach { possibleRoot -> + elemsByParent.forEach { (k, v) -> + if (v.contains(possibleRoot)) { + println("Possible root '$possibleRoot' is child of '$k'") + } + } + } + } + println("{") + dumpTree(elementsById, roots, elemsByParent) + println("}") +} + +private fun dumpTree(elementsById: Map, front: Set, elemsByParent: Map>, prefix: Int = 4) { + fun separatorIfNeeded(ind: Int) = if (ind != front.size - 1) "," else "" + val prefixStr = " ".repeat(prefix) + front.forEachIndexed { ind, elem -> + val children = elemsByParent[elem] + val diagramElem = elementsById[BpmnElementId(elem)] + val clazz = if (null != diagramElem) diagramElem::class.simpleName else null + if (null != children) { + println("$prefixStr\"$elem [$clazz] (diagram id: ${diagramElem?.elementId?.id})\":") + println("$prefixStr{") + dumpTree(elementsById, children, elemsByParent, prefix + 4) + println("$prefixStr}${separatorIfNeeded(ind)}") + } else { + println("$prefixStr\"$elem [$clazz] (diagram id: ${diagramElem?.elementId?.id})\"${separatorIfNeeded(ind)}") + } + + } +} diff --git a/bpmn-intellij-plugin-core/src/main/kotlin/com/valb3r/bpmn/intellij/plugin/core/render/IconProvider.kt b/bpmn-intellij-plugin-core/src/main/kotlin/com/valb3r/bpmn/intellij/plugin/core/render/IconProvider.kt index 6de02b664..a53bbb5b1 100644 --- a/bpmn-intellij-plugin-core/src/main/kotlin/com/valb3r/bpmn/intellij/plugin/core/render/IconProvider.kt +++ b/bpmn-intellij-plugin-core/src/main/kotlin/com/valb3r/bpmn/intellij/plugin/core/render/IconProvider.kt @@ -39,6 +39,7 @@ interface IconProvider { val sequence: Icon val anchorOn: Icon val anchorOff: Icon + val dumpRenderTree: Icon val exclusiveGateway: SvgIcon val parallelGateway: SvgIcon val inclusiveGateway: SvgIcon @@ -128,6 +129,7 @@ data class IconProviderImpl( override val sequence: Icon = IconLoader.getIcon("/icons/ui-icons/sequence.png", IconProvider::class.java), override val anchorOn: Icon = IconLoader.getIcon("/icons/actions/anchor.png", IconProvider::class.java), override val anchorOff: Icon = IconLoader.getIcon("/icons/actions/anchor-off.png", IconProvider::class.java), + override val dumpRenderTree: Icon = IconLoader.getIcon("/icons/actions/dump-render-tree.png"), override val plus: Icon = IconLoader.getIcon("/icons/ui-icons/plus.png", IconProvider::class.java), override val minus: Icon = IconLoader.getIcon("/icons/ui-icons/minus.png", IconProvider::class.java), override val exclusiveGateway: SvgIcon = "/icons/ui-icons/svg/exclusive-gateway.svg".asResource()!!, diff --git a/bpmn-intellij-plugin-core/src/main/kotlin/com/valb3r/bpmn/intellij/plugin/core/render/elements/BaseBpmnRenderElement.kt b/bpmn-intellij-plugin-core/src/main/kotlin/com/valb3r/bpmn/intellij/plugin/core/render/elements/BaseBpmnRenderElement.kt index 3443443a0..9c9f5c95e 100644 --- a/bpmn-intellij-plugin-core/src/main/kotlin/com/valb3r/bpmn/intellij/plugin/core/render/elements/BaseBpmnRenderElement.kt +++ b/bpmn-intellij-plugin-core/src/main/kotlin/com/valb3r/bpmn/intellij/plugin/core/render/elements/BaseBpmnRenderElement.kt @@ -1,8 +1,16 @@ package com.valb3r.bpmn.intellij.plugin.core.render.elements +import com.valb3r.bpmn.intellij.plugin.bpmn.api.BpmnObjectFactory +import com.valb3r.bpmn.intellij.plugin.bpmn.api.PropertyTable import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.BpmnElementId +import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.elements.WithBpmnId +import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.elements.WithParentId import com.valb3r.bpmn.intellij.plugin.bpmn.api.diagram.DiagramElementId +import com.valb3r.bpmn.intellij.plugin.bpmn.api.diagram.elements.ShapeElement +import com.valb3r.bpmn.intellij.plugin.bpmn.api.events.Event import com.valb3r.bpmn.intellij.plugin.core.events.BpmnElementRemovedEvent +import com.valb3r.bpmn.intellij.plugin.core.events.BpmnShapeObjectAddedEvent +import kotlin.reflect.KClass abstract class BaseBpmnRenderElement( elementId: DiagramElementId, @@ -16,4 +24,15 @@ abstract class BaseBpmnRenderElement( delete += BpmnElementRemovedEvent(bpmnElementId) return delete } + + override fun toString(): String { + return bpmnElementId.id + } + + open fun onElementCreatedOnTopThis(clazz: KClass, factory: BpmnObjectFactory, newShape: (T) -> ShapeElement): MutableList { + val elem = factory.newBpmnObject(clazz) + val shape = newShape(elem) + val props = factory.propertiesOf(elem) + return mutableListOf(BpmnShapeObjectAddedEvent(WithParentId(this.bpmnElementId, elem), shape, props)) + } } \ No newline at end of file diff --git a/bpmn-intellij-plugin-core/src/main/kotlin/com/valb3r/bpmn/intellij/plugin/core/render/elements/BaseDiagramRenderElement.kt b/bpmn-intellij-plugin-core/src/main/kotlin/com/valb3r/bpmn/intellij/plugin/core/render/elements/BaseDiagramRenderElement.kt index c59cd7bb0..c22dc1d12 100644 --- a/bpmn-intellij-plugin-core/src/main/kotlin/com/valb3r/bpmn/intellij/plugin/core/render/elements/BaseDiagramRenderElement.kt +++ b/bpmn-intellij-plugin-core/src/main/kotlin/com/valb3r/bpmn/intellij/plugin/core/render/elements/BaseDiagramRenderElement.kt @@ -287,4 +287,8 @@ abstract class BaseDiagramRenderElement( currentOnScreenRect(state().ctx.canvas.camera) children.forEach {it.currentOnScreenRect(state().ctx.canvas.camera)} } + + override fun toString(): String { + return "DIAG:${elementId.id}" + } } \ No newline at end of file diff --git a/bpmn-intellij-plugin-core/src/main/kotlin/com/valb3r/bpmn/intellij/plugin/core/render/elements/anchors/PhysicalWaypoint.kt b/bpmn-intellij-plugin-core/src/main/kotlin/com/valb3r/bpmn/intellij/plugin/core/render/elements/anchors/PhysicalWaypoint.kt index baaf7f61b..af9adef2a 100644 --- a/bpmn-intellij-plugin-core/src/main/kotlin/com/valb3r/bpmn/intellij/plugin/core/render/elements/anchors/PhysicalWaypoint.kt +++ b/bpmn-intellij-plugin-core/src/main/kotlin/com/valb3r/bpmn/intellij/plugin/core/render/elements/anchors/PhysicalWaypoint.kt @@ -79,7 +79,7 @@ class PhysicalWaypoint( val state = state().currentState val currentProps = state.propertyWithElementByPropertyType - val rootProcessId = state.processId + val rootProcessId = state.primaryProcessId if (null != droppedOn && !multipleElementsSelected() && !multipleElementsDragged()) { if (edgePhysicalSize - 1 == physicalPos) { events += StringValueUpdatedEvent(parentElementBpmnId, PropertyType.TARGET_REF, droppedOn.id) @@ -183,4 +183,4 @@ class PhysicalWaypoint( result += orthoIconId to AreaWithZindex(rightAngleIcon, areaType, mutableSetOf(), mutableSetOf(), ICON_Z_INDEX, elementId) return bounds } -} \ No newline at end of file +} diff --git a/bpmn-intellij-plugin-core/src/main/kotlin/com/valb3r/bpmn/intellij/plugin/core/render/elements/edges/BaseEdgeRenderElement.kt b/bpmn-intellij-plugin-core/src/main/kotlin/com/valb3r/bpmn/intellij/plugin/core/render/elements/edges/BaseEdgeRenderElement.kt index 8497c381e..56477ef03 100644 --- a/bpmn-intellij-plugin-core/src/main/kotlin/com/valb3r/bpmn/intellij/plugin/core/render/elements/edges/BaseEdgeRenderElement.kt +++ b/bpmn-intellij-plugin-core/src/main/kotlin/com/valb3r/bpmn/intellij/plugin/core/render/elements/edges/BaseEdgeRenderElement.kt @@ -172,4 +172,4 @@ abstract class BaseEdgeRenderElement( else -> null } } -} \ No newline at end of file +} diff --git a/bpmn-intellij-plugin-core/src/main/kotlin/com/valb3r/bpmn/intellij/plugin/core/render/elements/edges/EdgeRenderElement.kt b/bpmn-intellij-plugin-core/src/main/kotlin/com/valb3r/bpmn/intellij/plugin/core/render/elements/edges/EdgeRenderElement.kt index 207e0e13c..34d912b69 100644 --- a/bpmn-intellij-plugin-core/src/main/kotlin/com/valb3r/bpmn/intellij/plugin/core/render/elements/edges/EdgeRenderElement.kt +++ b/bpmn-intellij-plugin-core/src/main/kotlin/com/valb3r/bpmn/intellij/plugin/core/render/elements/edges/EdgeRenderElement.kt @@ -6,8 +6,6 @@ import com.valb3r.bpmn.intellij.plugin.bpmn.api.diagram.elements.BoundsElement import com.valb3r.bpmn.intellij.plugin.bpmn.api.events.EdgeWithIdentifiableWaypoints import com.valb3r.bpmn.intellij.plugin.bpmn.api.info.PropertyType import com.valb3r.bpmn.intellij.plugin.core.Colors -import com.valb3r.bpmn.intellij.plugin.core.events.BpmnElementRemovedEvent -import com.valb3r.bpmn.intellij.plugin.core.events.DiagramElementRemovedEvent import com.valb3r.bpmn.intellij.plugin.core.render.AreaType import com.valb3r.bpmn.intellij.plugin.core.render.AreaWithZindex import com.valb3r.bpmn.intellij.plugin.core.render.ICON_Z_INDEX @@ -37,4 +35,4 @@ class EdgeRenderElement( delId to AreaWithZindex(deleteIconArea, AreaType.POINT, mutableSetOf(), mutableSetOf(), ICON_Z_INDEX, elementId) ) } -} \ No newline at end of file +} diff --git a/bpmn-intellij-plugin-core/src/main/kotlin/com/valb3r/bpmn/intellij/plugin/core/render/elements/internal/InvisibleShape.kt b/bpmn-intellij-plugin-core/src/main/kotlin/com/valb3r/bpmn/intellij/plugin/core/render/elements/internal/InvisibleShape.kt new file mode 100644 index 000000000..3dab70acf --- /dev/null +++ b/bpmn-intellij-plugin-core/src/main/kotlin/com/valb3r/bpmn/intellij/plugin/core/render/elements/internal/InvisibleShape.kt @@ -0,0 +1,63 @@ +package com.valb3r.bpmn.intellij.plugin.core.render.elements.internal + +import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.BpmnElementId +import com.valb3r.bpmn.intellij.plugin.bpmn.api.diagram.DiagramElementId +import com.valb3r.bpmn.intellij.plugin.bpmn.api.events.Event +import com.valb3r.bpmn.intellij.plugin.core.render.AreaType +import com.valb3r.bpmn.intellij.plugin.core.render.AreaWithZindex +import com.valb3r.bpmn.intellij.plugin.core.render.Camera +import com.valb3r.bpmn.intellij.plugin.core.render.RenderContext +import com.valb3r.bpmn.intellij.plugin.core.render.elements.Anchor +import com.valb3r.bpmn.intellij.plugin.core.render.elements.BaseBpmnRenderElement +import com.valb3r.bpmn.intellij.plugin.core.render.elements.RenderState +import java.awt.geom.Rectangle2D + +class InvisibleShape( + elementId: DiagramElementId, + bpmnElementId: BpmnElementId, + state: () -> RenderState +) : BaseBpmnRenderElement(elementId, bpmnElementId, state) { + + override fun doRenderWithoutChildren(ctx: RenderContext): Map { + return emptyMap() + } + + override val areaType: AreaType + get() = AreaType.POINT + + override fun drawActionsRight(x: Float, y: Float): Map { + return emptyMap() + } + + override fun doDragToWithoutChildren(dx: Float, dy: Float) { + // NOP + } + + override fun doOnDragEndWithoutChildren(dx: Float, dy: Float, droppedOn: BpmnElementId?, allDroppedOnAreas: Map): MutableList { + return mutableListOf() + } + + override fun doResizeWithoutChildren(dw: Float, dh: Float) { + // NOP + } + + override fun doResizeEndWithoutChildren(dw: Float, dh: Float): MutableList { + return mutableListOf() + } + + override fun currentRect(): Rectangle2D.Float { + return Rectangle2D.Float(0.0f, 0.0f, 0.0f, 0.0f) + } + + override fun currentOnScreenRect(camera: Camera): Rectangle2D.Float { + return Rectangle2D.Float(0.0f, 0.0f, 0.0f, 0.0f) + } + + override fun waypointAnchors(camera: Camera): MutableSet { + return mutableSetOf() + } + + override fun shapeAnchors(camera: Camera): MutableSet { + return mutableSetOf() + } +} diff --git a/bpmn-intellij-plugin-core/src/main/kotlin/com/valb3r/bpmn/intellij/plugin/core/render/elements/shapes/ShapeGroupElement.kt b/bpmn-intellij-plugin-core/src/main/kotlin/com/valb3r/bpmn/intellij/plugin/core/render/elements/shapes/ShapeGroupElement.kt new file mode 100644 index 000000000..07a3c7b6b --- /dev/null +++ b/bpmn-intellij-plugin-core/src/main/kotlin/com/valb3r/bpmn/intellij/plugin/core/render/elements/shapes/ShapeGroupElement.kt @@ -0,0 +1,67 @@ +package com.valb3r.bpmn.intellij.plugin.core.render.elements.shapes + +import com.valb3r.bpmn.intellij.plugin.bpmn.api.BpmnObjectFactory +import com.valb3r.bpmn.intellij.plugin.bpmn.api.PropertyTable +import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.BpmnElementId +import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.elements.WithBpmnId +import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.elements.WithParentId +import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.elements.lanes.BpmnFlowNodeRef +import com.valb3r.bpmn.intellij.plugin.bpmn.api.diagram.DiagramElementId +import com.valb3r.bpmn.intellij.plugin.bpmn.api.diagram.elements.ShapeElement +import com.valb3r.bpmn.intellij.plugin.bpmn.api.events.Event +import com.valb3r.bpmn.intellij.plugin.core.Colors +import com.valb3r.bpmn.intellij.plugin.core.events.BpmnFlowNodeRefAddedEvent +import com.valb3r.bpmn.intellij.plugin.core.events.BpmnShapeObjectAddedEvent +import com.valb3r.bpmn.intellij.plugin.core.render.AreaType +import com.valb3r.bpmn.intellij.plugin.core.render.AreaWithZindex +import com.valb3r.bpmn.intellij.plugin.core.render.RenderContext +import com.valb3r.bpmn.intellij.plugin.core.render.elements.RenderState +import java.awt.Stroke +import kotlin.reflect.KClass + +class ShapeGroupElement( + elementId: DiagramElementId, + bpmnElementId: BpmnElementId, + shape: ShapeElement, + state: () -> RenderState, + private val backgroundColor: Colors = Colors.CALL_ACTIVITY_COLOR, + private val borderColor: Colors = Colors.ELEMENT_BORDER_COLOR, + private val textColor: Colors = Colors.INNER_TEXT_COLOR, + private val borderStroke: Stroke? = null, + override val areaType: AreaType = AreaType.SHAPE +) : ResizeableShapeRenderElement(elementId, bpmnElementId, shape, state) { + + override fun doRender(ctx: RenderContext, shapeCtx: ShapeCtx): Map { + + val area = ctx.canvas.drawRoundedRect( + shapeCtx.shape, + shapeCtx.name, + color(backgroundColor), + borderColor.color, + textColor.color, + borderStroke + ) + + return mapOf(shapeCtx.diagramId to AreaWithZindex(area, areaType, waypointAnchors(ctx.canvas.camera), shapeAnchors(ctx.canvas.camera), index = zIndex(), bpmnElementId = shape.bpmnElement)) + } + + override fun onDragEnd(dx: Float, dy: Float, droppedOn: BpmnElementId?, allDroppedOnAreas: Map): MutableList { + if (null != droppedOn) { + return mutableListOf() + } + + return super.onDragEnd(dx, dy, droppedOn, allDroppedOnAreas) + } + + override fun onElementCreatedOnTopThis(clazz: KClass, factory: BpmnObjectFactory, newShape: (T) -> ShapeElement + ): MutableList { + val newElems = super.onElementCreatedOnTopThis(clazz, factory, newShape) + val refNode = factory.newFlowRef().copy(ref = (newElems[0] as BpmnShapeObjectAddedEvent).bpmnObject.element.id.id) + newElems += BpmnFlowNodeRefAddedEvent(refNode) + return newElems + } + + override fun zIndex(): Int { + return (parents.firstOrNull()?.zIndex() ?: -1) + 1 + } +} diff --git a/bpmn-intellij-plugin-core/src/main/kotlin/com/valb3r/bpmn/intellij/plugin/core/render/elements/shapes/ShapeGroupParentElement.kt b/bpmn-intellij-plugin-core/src/main/kotlin/com/valb3r/bpmn/intellij/plugin/core/render/elements/shapes/ShapeGroupParentElement.kt new file mode 100644 index 000000000..0edc44c8b --- /dev/null +++ b/bpmn-intellij-plugin-core/src/main/kotlin/com/valb3r/bpmn/intellij/plugin/core/render/elements/shapes/ShapeGroupParentElement.kt @@ -0,0 +1,42 @@ +package com.valb3r.bpmn.intellij.plugin.core.render.elements.shapes + +import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.BpmnElementId +import com.valb3r.bpmn.intellij.plugin.bpmn.api.diagram.DiagramElementId +import com.valb3r.bpmn.intellij.plugin.bpmn.api.diagram.elements.ShapeElement +import com.valb3r.bpmn.intellij.plugin.core.Colors +import com.valb3r.bpmn.intellij.plugin.core.render.AreaType +import com.valb3r.bpmn.intellij.plugin.core.render.AreaWithZindex +import com.valb3r.bpmn.intellij.plugin.core.render.RenderContext +import com.valb3r.bpmn.intellij.plugin.core.render.elements.RenderState +import java.awt.Stroke + +class ShapeGroupParentElement( + elementId: DiagramElementId, + bpmnElementId: BpmnElementId, + shape: ShapeElement, + state: () -> RenderState, + private val backgroundColor: Colors = Colors.CALL_ACTIVITY_COLOR, + private val borderColor: Colors = Colors.ELEMENT_BORDER_COLOR, + private val textColor: Colors = Colors.INNER_TEXT_COLOR, + private val borderStroke: Stroke? = null, + override val areaType: AreaType = AreaType.SHAPE +) : ResizeableShapeRenderElement(elementId, bpmnElementId, shape, state) { + + override fun doRender(ctx: RenderContext, shapeCtx: ShapeCtx): Map { + + val area = ctx.canvas.drawRoundedRect( + shapeCtx.shape, + shapeCtx.name, + color(backgroundColor), + borderColor.color, + textColor.color, + borderStroke + ) + + return mapOf(shapeCtx.diagramId to AreaWithZindex(area, areaType, waypointAnchors(ctx.canvas.camera), shapeAnchors(ctx.canvas.camera), index = zIndex(), bpmnElementId = shape.bpmnElement)) + } + + override fun zIndex(): Int { + return (parents.firstOrNull()?.zIndex() ?: -1) + 1 + } +} diff --git a/bpmn-intellij-plugin-core/src/main/kotlin/com/valb3r/bpmn/intellij/plugin/core/render/elements/shapes/ShapeRenderElement.kt b/bpmn-intellij-plugin-core/src/main/kotlin/com/valb3r/bpmn/intellij/plugin/core/render/elements/shapes/ShapeRenderElement.kt index 26d69f8e1..d6b583df3 100644 --- a/bpmn-intellij-plugin-core/src/main/kotlin/com/valb3r/bpmn/intellij/plugin/core/render/elements/shapes/ShapeRenderElement.kt +++ b/bpmn-intellij-plugin-core/src/main/kotlin/com/valb3r/bpmn/intellij/plugin/core/render/elements/shapes/ShapeRenderElement.kt @@ -54,7 +54,7 @@ abstract class ShapeRenderElement( get() = shape override fun doRenderWithoutChildren(ctx: RenderContext): Map { - val elem = state().currentState.elementByDiagramId[shape.id] + val elem = state().currentState.elementsByDiagramId[shape.id] val props = state().currentState.elemPropertiesByStaticElementId[elem] val name = props?.get(PropertyType.NAME)?.value as String? @@ -239,12 +239,12 @@ abstract class ShapeRenderElement( if (null != nests && nests != currentParent?.bpmnElementId) { newEvents += BpmnParentChangedEvent(shape.bpmnElement, nests) // Cascade parent change to waypoint owning edge - newEvents += cascadeTargets.mapNotNull { state().currentState.elementByDiagramId[it.parentEdgeId] }.map { BpmnParentChangedEvent(it, nests) } + newEvents += cascadeTargets.mapNotNull { state().currentState.elementsByDiagramId[it.parentEdgeId] }.map { BpmnParentChangedEvent(it, nests) } } else if (null != parentProcess && parentProcess != parents.firstOrNull()?.bpmnElementId) { newEvents += BpmnParentChangedEvent(shape.bpmnElement, parentProcess) // Cascade parent change to waypoint owning edge - newEvents += cascadeTargets.mapNotNull { state().currentState.elementByDiagramId[it.parentEdgeId] }.map { BpmnParentChangedEvent(it, parentProcess) } + newEvents += cascadeTargets.mapNotNull { state().currentState.elementsByDiagramId[it.parentEdgeId] }.map { BpmnParentChangedEvent(it, parentProcess) } } return newEvents } @@ -253,7 +253,7 @@ abstract class ShapeRenderElement( val idCascadesTo = setOf(PropertyType.SOURCE_REF, PropertyType.TARGET_REF) val result = mutableSetOf() val elemToDiagramId = mutableMapOf>() - state().currentState.elementByDiagramId.forEach { elemToDiagramId.computeIfAbsent(it.value) { mutableSetOf() }.add(it.key) } + state().currentState.elementsByDiagramId.forEach { elemToDiagramId.computeIfAbsent(it.value) { mutableSetOf() }.add(it.key) } state().currentState.elemPropertiesByStaticElementId.forEach { (owner, props) -> idCascadesTo.intersect(props.keys).filter { props[it]?.value == shape.bpmnElement.id }.forEach { type -> when (state().currentState.elementByBpmnId[owner]?.element) { @@ -425,4 +425,4 @@ abstract class ShapeRenderElement( fun cartesianProduct(first: Collection, second: Collection): Sequence> { return first.asSequence().flatMap { lhsElem -> second.asSequence().map { rhsElem -> lhsElem to rhsElem } } } -} \ No newline at end of file +} diff --git a/bpmn-intellij-plugin-core/src/main/kotlin/com/valb3r/bpmn/intellij/plugin/core/settings/BpmnPluginSettingsComponent.form b/bpmn-intellij-plugin-core/src/main/kotlin/com/valb3r/bpmn/intellij/plugin/core/settings/BpmnPluginSettingsComponent.form index 4f4063400..037725d91 100644 --- a/bpmn-intellij-plugin-core/src/main/kotlin/com/valb3r/bpmn/intellij/plugin/core/settings/BpmnPluginSettingsComponent.form +++ b/bpmn-intellij-plugin-core/src/main/kotlin/com/valb3r/bpmn/intellij/plugin/core/settings/BpmnPluginSettingsComponent.form @@ -1,9 +1,9 @@
- + - + @@ -204,6 +204,14 @@ + + + + + + + + diff --git a/bpmn-intellij-plugin-core/src/main/kotlin/com/valb3r/bpmn/intellij/plugin/core/settings/BpmnPluginSettingsComponent.kt b/bpmn-intellij-plugin-core/src/main/kotlin/com/valb3r/bpmn/intellij/plugin/core/settings/BpmnPluginSettingsComponent.kt index d0b347e60..27c632251 100644 --- a/bpmn-intellij-plugin-core/src/main/kotlin/com/valb3r/bpmn/intellij/plugin/core/settings/BpmnPluginSettingsComponent.kt +++ b/bpmn-intellij-plugin-core/src/main/kotlin/com/valb3r/bpmn/intellij/plugin/core/settings/BpmnPluginSettingsComponent.kt @@ -26,6 +26,7 @@ class BpmnPluginSettingsComponent() { private lateinit var dataFontSize: JSpinner private lateinit var openExtensions: JTextField private lateinit var enableFps: JCheckBox + private lateinit var enableDevelopmentFunctions: JCheckBox init { AutoCompleteDecorator.decorate(uiFontName) @@ -65,6 +66,7 @@ class BpmnPluginSettingsComponent() { dataFontSize.value = state.dataFontSize openExtensions.text = state.openExtensions.joinToString(DELIMITER) enableFps.isSelected = state.enableFps + enableDevelopmentFunctions.isSelected = state.enableDevelopmentFunctions } private fun populateFontComboboxes(actualUiFont: Font, actualDataFont: Font) { @@ -110,10 +112,11 @@ class BpmnPluginSettingsComponent() { } }) enableFps.addChangeListener { state.enableFps = enableFps.isSelected } + enableDevelopmentFunctions.addChangeListener { state.enableDevelopmentFunctions = enableDevelopmentFunctions.isSelected } } private fun extensions() = openExtensions.text.split(DELIMITER).toSet() private fun Float.asSlider(): Int = (this * 100.0f).toInt() private fun Int.fromSlider(): Float = this / 100.0f -} \ No newline at end of file +} diff --git a/bpmn-intellij-plugin-core/src/main/kotlin/com/valb3r/bpmn/intellij/plugin/core/settings/BpmnPluginSettingsState.kt b/bpmn-intellij-plugin-core/src/main/kotlin/com/valb3r/bpmn/intellij/plugin/core/settings/BpmnPluginSettingsState.kt index e316ff168..296da2425 100644 --- a/bpmn-intellij-plugin-core/src/main/kotlin/com/valb3r/bpmn/intellij/plugin/core/settings/BpmnPluginSettingsState.kt +++ b/bpmn-intellij-plugin-core/src/main/kotlin/com/valb3r/bpmn/intellij/plugin/core/settings/BpmnPluginSettingsState.kt @@ -50,6 +50,7 @@ abstract class BaseBpmnPluginSettingsState: PersistentStateComponent, - val edges: List, - val elementByDiagramId: Map, - val elementByBpmnId: Map, - val elemPropertiesByStaticElementId: Map, - val propertyWithElementByPropertyType: Map>, - val elemUiOnlyPropertiesByStaticElementId: Map>, - val undoRedo: Set, - val version: Long, - val diagramByElementId: Map = elementByDiagramId.map { Pair(it.value, it.key) }.toMap(), + val primaryProcessId: BpmnElementId, + val processes: Set, + val shapes: List, + val edges: List, + val elementsByDiagramId: Map, + val elementByBpmnId: Map, + val elemPropertiesByStaticElementId: Map, + val propertyWithElementByPropertyType: Map>, + val elemUiOnlyPropertiesByStaticElementId: Map>, + val undoRedo: Set, + val version: Long, + val diagramByElementId: Map = elementsByDiagramId.map { Pair(it.value, it.key) }.toMap(), ) { - fun processDiagramId(): DiagramElementId { - return processDiagramId(processId) + fun primaryProcessDiagramId(): DiagramElementId { + return primaryProcessDiagramId(primaryProcessId) } companion object { - fun processDiagramId(processId: BpmnElementId): DiagramElementId { + fun primaryProcessDiagramId(processId: BpmnElementId): DiagramElementId { return DiagramElementId(processId.id) } } } +private val ZERO_STATE = CurrentState(BpmnElementId(""), emptySet(), emptyList(), emptyList(), emptyMap(), emptyMap(), emptyMap(), emptyMap(), emptyMap(), emptySet(), 0L) + // Global singleton class CurrentStateProvider(private val project: Project) { private val mapper = Mappers.getMapper(MapTransactionalSubprocessToSubprocess::class.java) - private var fileState = CurrentState(BpmnElementId(""), emptyList(), emptyList(), emptyMap(), emptyMap(), emptyMap(), emptyMap(), emptyMap(), emptySet(), 0L) - private var currentState = CurrentState(BpmnElementId(""), emptyList(), emptyList(), emptyMap(), emptyMap(), emptyMap(), emptyMap(), emptyMap(), emptySet(), 0L) + private var fileState = ZERO_STATE.copy() + private var currentState = ZERO_STATE.copy() private val version = AtomicLong(0L) - fun resetStateTo(fileContent: String, processObject: BpmnProcessObjectView) { + fun resetStateTo(fileContent: String, view: BpmnFileView) { version.set(0L) fileState = CurrentState( - processObject.processId, - processObject.diagram.flatMap { it.bpmnPlane.bpmnShape ?: emptyList() }, - processObject.diagram.flatMap { it.bpmnPlane.bpmnEdge ?: emptyList() }.map { EdgeElementState(it) }, - processObject.elementByDiagramId, - processObject.elementByStaticId, - processObject.elemPropertiesByElementId, + view.primaryProcessId, + view.processes.map { it.processId }.toSet(), + view.processes.flatMap { proc -> proc.diagram.flatMap { it.bpmnPlane.bpmnShape ?: emptyList() } }, + view.processes.flatMap { proc -> proc.diagram.flatMap { it.bpmnPlane.bpmnEdge ?: emptyList() }.map { EdgeElementState(it) } }, + extractDiagramElementToBpmnIds(view), + extractBpmnElements(view), + extractProperties(view), emptyMap(), emptyMap(), emptySet(), @@ -83,15 +87,27 @@ class CurrentStateProvider(private val project: Project) { return handleUpdates(currentState) } + private fun extractProperties(view: BpmnFileView) = + view.processes.flatMap { proc -> proc.processElemPropertiesByElementId.entries }.groupBy { it.key }.mapValues { it.value.first().value } + + view.collaborations.flatMap { coll -> coll.collaborationElemPropertiesByElementId.entries }.groupBy { it.key }.mapValues { it.value.first().value } + + private fun extractBpmnElements(view: BpmnFileView) = + view.processes.flatMap { proc -> proc.processElementByStaticId.entries }.groupBy { it.key }.mapValues { it.value.first().value } + + view.collaborations.flatMap { coll -> coll.collaborationElementByStaticId.entries }.groupBy { it.key }.mapValues { it.value.first().value } + + private fun extractDiagramElementToBpmnIds(view: BpmnFileView) = + view.processes.flatMap { proc -> proc.allElementsByDiagramId.entries }.groupBy { it.key }.mapValues { it.value.first().value } + private fun handleUpdates(state: CurrentState): CurrentState { var updatedShapes = state.shapes.toMutableList() var updatedEdges = state.edges.toMutableList() - val updatedElementByDiagramId = state.elementByDiagramId.toMutableMap() + val updatedElementByDiagramId = state.elementsByDiagramId.toMutableMap() val updatedElementByStaticId = state.elementByBpmnId.toMutableMap() val updatedElemPropertiesByStaticElementId = state.elemPropertiesByStaticElementId.mapValues { it.value.copy() }.toMutableMap() val updatedPropertyWithElementByPropertyType = mutableMapOf>() val updatedElemUiOnlyPropertiesByStaticElementId = state.elemUiOnlyPropertiesByStaticElementId.toMutableMap() - var updatedProcessId = state.processId + var updatedProcessId = state.primaryProcessId + val updatedProcessSet = state.processes.toMutableSet() val updateEventsRegistry: ProcessModelUpdateEvents = updateEventsRegistry(project) val undoRedoStatus = updateEventsRegistry.undoRedoStatus() val updates = updateEventsRegistry.getUpdateEventList() @@ -110,7 +126,7 @@ class CurrentStateProvider(private val project: Project) { updatedEdges = updatedEdges.map { edge -> if (edge.id == event.edgeElementId) updateWaypointLocation(edge, event) else edge }.toMutableList() } is BpmnElementRemoved -> { - handleRemoved(event.bpmnElementId, updatedShapes, updatedEdges, updatedElementByDiagramId, updatedElementByStaticId, updatedElemPropertiesByStaticElementId) + handleRemoved(event.bpmnElementId, updatedProcessSet, updatedShapes, updatedEdges, updatedElementByDiagramId, updatedElementByStaticId, updatedElemPropertiesByStaticElementId) } is BpmnElementChange -> { handleChangeType(event.elementId, event.newBpmnElement, updatedElementByStaticId, event.props, updatedElemPropertiesByStaticElementId) @@ -118,6 +134,11 @@ class CurrentStateProvider(private val project: Project) { is DiagramElementRemoved -> { handleDiagramRemoved(event.elementId, updatedShapes, updatedEdges, updatedElementByDiagramId) } + is BpmnProcessObjectAdded -> { + updatedProcessSet.add(event.bpmnObject.id) + updatedElementByStaticId[event.bpmnObject.id] = event.bpmnObject + updatedElemPropertiesByStaticElementId[event.bpmnObject.id] = event.props.copy() + } is BpmnShapeObjectAdded -> { updatedShapes.add(event.shape) updatedElementByDiagramId[event.shape.id] = event.bpmnObject.id @@ -150,6 +171,7 @@ class CurrentStateProvider(private val project: Project) { is IndexUiOnlyValueUpdatedEvent -> updateIndexProperty(event, updatedElemPropertiesByStaticElementId) is UiOnlyValueAddedEvent -> addUiOnlyProperty(event, updatedElemPropertiesByStaticElementId) is UiOnlyValueRemovedEvent -> removeUiOnlyProperty(event, updatedElemPropertiesByStaticElementId) + is BpmnFlowNodeRefAddedEvent -> { /* Nothing here - purely fictitious event handled by XML parser only */ } else -> throw IllegalStateException("Can't handle event ${event.javaClass}") } } @@ -162,6 +184,7 @@ class CurrentStateProvider(private val project: Project) { return CurrentState( updatedProcessId, + updatedProcessSet, updatedShapes, updatedEdges, updatedElementByDiagramId, @@ -289,12 +312,14 @@ class CurrentStateProvider(private val project: Project) { private fun handleRemoved( elementId: BpmnElementId, + processes: MutableSet, updatedShapes: MutableList, updatedEdges: MutableList, updatedElementByDiagramId: MutableMap, updatedElementByStaticId: MutableMap, updatedElemPropertiesByStaticElementId: MutableMap ) { + processes.remove(elementId) val shape = updatedShapes.find { it.bpmnElement == elementId } val edge = updatedEdges.find { it.bpmnElement == elementId } shape?.let { updatedElementByDiagramId.remove(it.id); updatedShapes.remove(it) } @@ -351,7 +376,7 @@ class CurrentStateProvider(private val project: Project) { updatedElemPropertiesByStaticElementId[newElementId] = elemPropUpdated if (elementId == processId) { - updatedElementByDiagramId[CurrentState.processDiagramId(newElementId)] = newElementId + updatedElementByDiagramId[CurrentState.primaryProcessDiagramId(newElementId)] = newElementId return newElementId } diff --git a/bpmn-intellij-plugin-core/src/main/resources/icons/actions/dump-render-tree.png b/bpmn-intellij-plugin-core/src/main/resources/icons/actions/dump-render-tree.png new file mode 100644 index 000000000..48db3db13 Binary files /dev/null and b/bpmn-intellij-plugin-core/src/main/resources/icons/actions/dump-render-tree.png differ diff --git a/bpmn-intellij-plugin-core/src/main/resources/icons/actions/dump-render-tree_dark.png b/bpmn-intellij-plugin-core/src/main/resources/icons/actions/dump-render-tree_dark.png new file mode 100644 index 000000000..9209d78dd Binary files /dev/null and b/bpmn-intellij-plugin-core/src/main/resources/icons/actions/dump-render-tree_dark.png differ diff --git a/bpmn-intellij-plugin-core/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/BoundaryEventAttachTest.kt b/bpmn-intellij-plugin-core/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/BoundaryEventAttachTest.kt index c10053597..ed89eb9b3 100644 --- a/bpmn-intellij-plugin-core/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/BoundaryEventAttachTest.kt +++ b/bpmn-intellij-plugin-core/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/BoundaryEventAttachTest.kt @@ -293,7 +293,7 @@ internal class BoundaryEventAttachTest: BaseUiTest() { lastValue.shouldContainSame(listOf(edgeBpmn, *propUpdate)) val sequence = edgeBpmn.bpmnObject.element.shouldBeInstanceOf() - edgeBpmn.bpmnObject.parent.shouldBe(basicProcess.process.id) + edgeBpmn.bpmnObject.parent.shouldBe(basicProcess.processes[0].id) sequence.sourceRef.shouldBe(optionalBoundaryErrorEventBpmnId.id) sequence.targetRef.shouldBe("") @@ -323,7 +323,7 @@ internal class BoundaryEventAttachTest: BaseUiTest() { lastValue.shouldContainSame(listOf(edgeBpmn, *propUpdate)) val sequence = edgeBpmn.bpmnObject.element.shouldBeInstanceOf() - edgeBpmn.bpmnObject.parent.shouldBe(basicProcess.process.id) + edgeBpmn.bpmnObject.parent.shouldBe(basicProcess.processes[0].id) sequence.sourceRef.shouldBe(optionalBoundaryErrorEventBpmnId.id) sequence.targetRef.shouldBe("") diff --git a/bpmn-intellij-plugin-core/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/UiEditorLightE2ETest.kt b/bpmn-intellij-plugin-core/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/UiEditorLightE2ETest.kt index 3124412fe..2d4afaa45 100644 --- a/bpmn-intellij-plugin-core/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/UiEditorLightE2ETest.kt +++ b/bpmn-intellij-plugin-core/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/UiEditorLightE2ETest.kt @@ -116,10 +116,10 @@ internal class UiEditorLightE2ETest: BaseUiTest() { lastValue.shouldContainSame(listOf(edgeBpmn, shapeBpmn, draggedTo, *propUpdate)) shapeBpmn.bpmnObject.element.shouldBeInstanceOf() - shapeBpmn.bpmnObject.parent.shouldBe(basicProcess.process.id) + shapeBpmn.bpmnObject.parent.shouldBe(basicProcess.processes[0].id) val sequence = edgeBpmn.bpmnObject.element.shouldBeInstanceOf() - edgeBpmn.bpmnObject.parent.shouldBe(basicProcess.process.id) + edgeBpmn.bpmnObject.parent.shouldBe(basicProcess.processes[0].id) sequence.sourceRef.shouldBe(serviceTaskStartBpmnId.id) sequence.targetRef.shouldBe("") @@ -164,7 +164,7 @@ internal class UiEditorLightE2ETest: BaseUiTest() { lastValue.shouldContainSame(listOf(edgeBpmn, draggedTo, *propUpdate)) val sequence = edgeBpmn.bpmnObject.element.shouldBeInstanceOf() - edgeBpmn.bpmnObject.parent.shouldBe(basicProcess.process.id) + edgeBpmn.bpmnObject.parent.shouldBe(basicProcess.processes[0].id) sequence.sourceRef.shouldBe(serviceTaskStartBpmnId.id) sequence.targetRef.shouldBe("") @@ -207,7 +207,7 @@ internal class UiEditorLightE2ETest: BaseUiTest() { lastValue.shouldContainSame(listOf(edgeBpmn, draggedTo, *propUpdate)) val sequence = edgeBpmn.bpmnObject.element.shouldBeInstanceOf() - edgeBpmn.bpmnObject.parent.shouldBe(basicProcess.process.id) + edgeBpmn.bpmnObject.parent.shouldBe(basicProcess.processes[0].id) sequence.sourceRef.shouldBe(serviceTaskStartBpmnId.id) sequence.targetRef.shouldBe("") @@ -257,7 +257,7 @@ internal class UiEditorLightE2ETest: BaseUiTest() { lastValue.shouldContainSame(listOf(edgeBpmn, draggedToMid, draggedToTarget, *propUpdate)) val sequence = edgeBpmn.bpmnObject.element.shouldBeInstanceOf() - edgeBpmn.bpmnObject.parent.shouldBe(basicProcess.process.id) + edgeBpmn.bpmnObject.parent.shouldBe(basicProcess.processes[0].id) sequence.sourceRef.shouldBe(serviceTaskStartBpmnId.id) sequence.targetRef.shouldBe("") @@ -267,7 +267,7 @@ internal class UiEditorLightE2ETest: BaseUiTest() { intermediateTargetChangeToParentPropUpd.bpmnElementId.shouldBe(edgeBpmn.bpmnObject.id) intermediateTargetChangeToParentPropUpd.property.shouldBe(PropertyType.TARGET_REF) - intermediateTargetChangeToParentPropUpd.newValue.shouldBe(basicProcess.process.id.id) + intermediateTargetChangeToParentPropUpd.newValue.shouldBe(basicProcess.processes[0].id.id) draggedToTarget.diagramElementId.shouldBeEqualTo(lastEndpointId) draggedToTarget.dx.shouldBeNear(endElemX - point.x - draggedToMid.dx, 0.1f) @@ -301,7 +301,7 @@ internal class UiEditorLightE2ETest: BaseUiTest() { lastValue.shouldContainSame(listOf(edgeBpmn, *propUpdate, newWaypoint)) val sequence = edgeBpmn.bpmnObject.element.shouldBeInstanceOf() - edgeBpmn.bpmnObject.parent.shouldBe(basicProcess.process.id) + edgeBpmn.bpmnObject.parent.shouldBe(basicProcess.processes[0].id) sequence.sourceRef.shouldBe(serviceTaskStartBpmnId.id) sequence.targetRef.shouldBe("") @@ -369,7 +369,7 @@ internal class UiEditorLightE2ETest: BaseUiTest() { lastValue.shouldContainSame(listOf(edgeBpmn, newMidWaypoint, newQuarterWaypoint, *propUpdate)) val sequence = edgeBpmn.bpmnObject.element.shouldBeInstanceOf() - edgeBpmn.bpmnObject.parent.shouldBe(basicProcess.process.id) + edgeBpmn.bpmnObject.parent.shouldBe(basicProcess.processes[0].id) sequence.sourceRef.shouldBe(serviceTaskStartBpmnId.id) sequence.targetRef.shouldBe("") @@ -444,7 +444,7 @@ internal class UiEditorLightE2ETest: BaseUiTest() { lastValue.shouldContainSame(listOf(edgeBpmn, dragTask, dragEdge, *propUpdate)) val sequence = edgeBpmn.bpmnObject.element.shouldBeInstanceOf() - edgeBpmn.bpmnObject.parent.shouldBe(basicProcess.process.id) + edgeBpmn.bpmnObject.parent.shouldBe(basicProcess.processes[0].id) sequence.sourceRef.shouldBe(serviceTaskStartBpmnId.id) sequence.targetRef.shouldBe("") @@ -486,7 +486,7 @@ internal class UiEditorLightE2ETest: BaseUiTest() { lastValue.shouldContainSame(listOf(edgeBpmn, *propUpdate)) val sequence = edgeBpmn.bpmnObject.element.shouldBeInstanceOf() - edgeBpmn.bpmnObject.parent.shouldBe(basicProcess.process.id) + edgeBpmn.bpmnObject.parent.shouldBe(basicProcess.processes[0].id) sequence.sourceRef.shouldBe(serviceTaskStartBpmnId.id) sequence.targetRef.shouldBe("") @@ -544,7 +544,7 @@ internal class UiEditorLightE2ETest: BaseUiTest() { lastValue.shouldContainSame(listOf(edgeBpmn, *propUpdate, dragTask, dragEdge)) val sequence = edgeBpmn.bpmnObject.element.shouldBeInstanceOf() - edgeBpmn.bpmnObject.parent.shouldBe(basicProcess.process.id) + edgeBpmn.bpmnObject.parent.shouldBe(basicProcess.processes[0].id) sequence.sourceRef.shouldBe(serviceTaskStartBpmnId.id) sequence.targetRef.shouldBe("") @@ -555,7 +555,7 @@ internal class UiEditorLightE2ETest: BaseUiTest() { cascadeIdUpdate.first().bpmnElementId.id.shouldBeEqualTo(newId) cascadeIdUpdate.first().property.shouldBeEqualTo(PropertyType.SOURCE_REF) - cascadeIdUpdate.first().newValue.shouldBeEqualTo(basicProcess.process.id.id) + cascadeIdUpdate.first().newValue.shouldBeEqualTo(basicProcess.processes[0].id.id) cascadeIdUpdate.last().bpmnElementId.id.shouldBeEqualTo(newId) cascadeIdUpdate.last().property.shouldBeEqualTo(PropertyType.SOURCE_REF) @@ -605,7 +605,7 @@ internal class UiEditorLightE2ETest: BaseUiTest() { lastValue.shouldContainSame(listOf(edgeBpmn, *propUpdate, dragTask, dragEdge)) val sequence = edgeBpmn.bpmnObject.element.shouldBeInstanceOf() - edgeBpmn.bpmnObject.parent.shouldBe(basicProcess.process.id) + edgeBpmn.bpmnObject.parent.shouldBe(basicProcess.processes[0].id) sequence.sourceRef.shouldBe(serviceTaskStartBpmnId.id) sequence.targetRef.shouldBe("") @@ -709,7 +709,7 @@ internal class UiEditorLightE2ETest: BaseUiTest() { lastValue.shouldContainSame(listOf(edgeBpmn, dragStart, dragEdge, *propUpdate)) val sequence = edgeBpmn.bpmnObject.element.shouldBeInstanceOf() - edgeBpmn.bpmnObject.parent.shouldBe(basicProcess.process.id) + edgeBpmn.bpmnObject.parent.shouldBe(basicProcess.processes[0].id) sequence.sourceRef.shouldBe(serviceTaskStartBpmnId.id) sequence.targetRef.shouldBe("") @@ -796,7 +796,7 @@ internal class UiEditorLightE2ETest: BaseUiTest() { lastValue.shouldContainSame(listOf(edgeBpmn, removeEdgeDiagram, removeEdgeBpmn, *propUpdate)) val sequence = edgeBpmn.bpmnObject.element.shouldBeInstanceOf() - edgeBpmn.bpmnObject.parent.shouldBe(basicProcess.process.id) + edgeBpmn.bpmnObject.parent.shouldBe(basicProcess.processes[0].id) sequence.sourceRef.shouldBe(serviceTaskStartBpmnId.id) sequence.targetRef.shouldBe("") @@ -840,7 +840,7 @@ internal class UiEditorLightE2ETest: BaseUiTest() { lastValue.shouldContainSame(listOf(edgeBpmn, newWaypoint, removeWaypoint, *propUpdate)) val sequence = edgeBpmn.bpmnObject.element.shouldBeInstanceOf() - edgeBpmn.bpmnObject.parent.shouldBe(basicProcess.process.id) + edgeBpmn.bpmnObject.parent.shouldBe(basicProcess.processes[0].id) sequence.sourceRef.shouldBe(serviceTaskStartBpmnId.id) sequence.targetRef.shouldBe("") @@ -898,7 +898,7 @@ internal class UiEditorLightE2ETest: BaseUiTest() { lastValue.shouldContainSame(listOf(edgeBpmn) + diagramRemoved + bpmnRemoved + propUpdate) val sequence = edgeBpmn.bpmnObject.element.shouldBeInstanceOf() - edgeBpmn.bpmnObject.parent.shouldBe(basicProcess.process.id) + edgeBpmn.bpmnObject.parent.shouldBe(basicProcess.processes[0].id) sequence.sourceRef.shouldBe(serviceTaskStartBpmnId.id) sequence.targetRef.shouldBe("") @@ -1135,7 +1135,7 @@ internal class UiEditorLightE2ETest: BaseUiTest() { lastValue.shouldContainSame(listOf(edgeBpmn, shapeBpmn, draggedTo, *propUpdate)) shapeBpmn.bpmnObject.element.shouldBeInstanceOf() - shapeBpmn.bpmnObject.parent.shouldBe(basicProcess.process.id) + shapeBpmn.bpmnObject.parent.shouldBe(basicProcess.processes[0].id) val sequence = edgeBpmn.bpmnObject.element.shouldBeInstanceOf() edgeBpmn.bpmnObject.parent.shouldBe(subprocessBpmnId) @@ -1619,7 +1619,7 @@ internal class UiEditorLightE2ETest: BaseUiTest() { canvas.click(onlyRootProcessPoint) lastRenderedState(project)!!.state.ctx.selectedIds.shouldBeEmpty() lastRenderedState(project)!!.state.ctx.stateProvider.currentState() - .elementByDiagramId[CurrentState.processDiagramId(BpmnElementId(newRootProcessId))].shouldNotBeNull() + .elementsByDiagramId[CurrentState.primaryProcessDiagramId(BpmnElementId(newRootProcessId))].shouldNotBeNull() val anotherNewRootProcessId = "another-new-root-process-id" @@ -1631,7 +1631,7 @@ internal class UiEditorLightE2ETest: BaseUiTest() { canvas.click(onlyRootProcessPoint) lastRenderedState(project)!!.state.ctx.selectedIds.shouldBeEmpty() lastRenderedState(project)!!.state.ctx.stateProvider.currentState() - .elementByDiagramId[CurrentState.processDiagramId(BpmnElementId(anotherNewRootProcessId))].shouldNotBeNull() + .elementsByDiagramId[CurrentState.primaryProcessDiagramId(BpmnElementId(anotherNewRootProcessId))].shouldNotBeNull() } @Test diff --git a/camunda-xml-parser/src/main/kotlin/com/valb3r/bpmn/intellij/plugin/camunda/parser/CamundaParser.kt b/camunda-xml-parser/src/main/kotlin/com/valb3r/bpmn/intellij/plugin/camunda/parser/CamundaParser.kt index 14d35f95a..6181390ba 100644 --- a/camunda-xml-parser/src/main/kotlin/com/valb3r/bpmn/intellij/plugin/camunda/parser/CamundaParser.kt +++ b/camunda-xml-parser/src/main/kotlin/com/valb3r/bpmn/intellij/plugin/camunda/parser/CamundaParser.kt @@ -2,7 +2,7 @@ package com.valb3r.bpmn.intellij.plugin.camunda.parser import com.fasterxml.jackson.dataformat.xml.XmlMapper import com.fasterxml.jackson.module.kotlin.readValue -import com.valb3r.bpmn.intellij.plugin.bpmn.api.BpmnProcessObject +import com.valb3r.bpmn.intellij.plugin.bpmn.api.BpmnFileObject import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.elements.WithBpmnId import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.elements.events.catching.BpmnIntermediateLinkCatchingEvent import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.elements.gateways.BpmnComplexGateway @@ -134,18 +134,18 @@ class CamundaParser : BaseBpmnParser() { private val mapper: XmlMapper = mapper() - override fun parse(input: String): BpmnProcessObject { + override fun parse(input: String): BpmnFileObject { val dto = mapper.readValue(input) return toProcessObject(dto) } - private fun toProcessObject(dto: BpmnFile): BpmnProcessObject { - // TODO - Multi process support? + private fun toProcessObject(dto: BpmnFile): BpmnFileObject { markSubprocessesAndTransactionsThatHaveExternalDiagramAsCollapsed(dto.processes[0], dto.diagrams!!) - val process = dto.processes[0].toElement() + val processes = dto.processes.map { it.toElement() } + val collaborations = dto.collaborations?.map { it.toElement() } ?: emptyList() val diagrams = dto.diagrams!!.map { it.toElement() } - return BpmnProcessObject(process, diagrams) + return BpmnFileObject(processes, collaborations, diagrams) } override fun modelNs(): NS { diff --git a/camunda-xml-parser/src/main/kotlin/com/valb3r/bpmn/intellij/plugin/camunda/parser/nodes/CamundaXml.kt b/camunda-xml-parser/src/main/kotlin/com/valb3r/bpmn/intellij/plugin/camunda/parser/nodes/CamundaXml.kt index 17b2950e0..2b53ef8e4 100644 --- a/camunda-xml-parser/src/main/kotlin/com/valb3r/bpmn/intellij/plugin/camunda/parser/nodes/CamundaXml.kt +++ b/camunda-xml-parser/src/main/kotlin/com/valb3r/bpmn/intellij/plugin/camunda/parser/nodes/CamundaXml.kt @@ -14,13 +14,15 @@ import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.elements.events.throwing.Bp import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.elements.events.throwing.BpmnIntermediateNoneThrowingEvent import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.elements.events.throwing.BpmnIntermediateSignalThrowingEvent import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.elements.events.throwing.BpmnIntermediateThrowingEvent +import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.elements.lanes.BpmnLaneSet import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.elements.subprocess.BpmnEventSubprocess import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.elements.subprocess.BpmnSubProcess import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.elements.tasks.* import com.valb3r.bpmn.intellij.plugin.bpmn.api.diagram.DiagramElement -import com.valb3r.bpmn.intellij.plugin.camunda.parser.nodes.process.* +import com.valb3r.bpmn.intellij.plugin.camunda.parser.nodes.collaboration.Collaboration import com.valb3r.bpmn.intellij.plugin.camunda.parser.nodes.diagram.DiagramElementIdMapper import com.valb3r.bpmn.intellij.plugin.camunda.parser.nodes.diagram.Plane +import com.valb3r.bpmn.intellij.plugin.camunda.parser.nodes.process.* import org.mapstruct.Mapper import org.mapstruct.Mapping import org.mapstruct.Mappings @@ -40,101 +42,156 @@ const val EXTENSION_BOOLEAN_EXTRACTOR = ".map(it -> Boolean.valueOf(it.getString // unfortunately this has failed with Kotlin 'data' classes class BpmnFile( @JacksonXmlProperty(localName = "message") - @JsonMerge - @JacksonXmlElementWrapper(useWrapping = false) - var messages: List? = null, + @JsonMerge + @JacksonXmlElementWrapper(useWrapping = false) + var messages: List? = null, + + @JacksonXmlProperty(localName = "collaboration") + @JsonMerge + @JacksonXmlElementWrapper(useWrapping = false) + var collaborations: List? = null, @JacksonXmlProperty(localName = "process") - @JsonMerge - @JacksonXmlElementWrapper(useWrapping = false) - var processes: List, + @JsonMerge + @JacksonXmlElementWrapper(useWrapping = false) + var processes: List, @JacksonXmlProperty(localName = "BPMNDiagram") - @JsonMerge - @JacksonXmlElementWrapper(useWrapping = false) - var diagrams: List? = null + @JsonMerge + @JacksonXmlElementWrapper(useWrapping = false) + var diagrams: List? = null ) data class MessageNode(val id: String, var name: String?) open class ProcessBody { - + + // Collaboration related + @JsonMerge + @JacksonXmlElementWrapper(useWrapping = false) + var laneSet: List? = null + // Events - @JsonMerge @JacksonXmlElementWrapper(useWrapping = false) + @JsonMerge + @JacksonXmlElementWrapper(useWrapping = false) var startEvent: List? = null - @JsonMerge @JacksonXmlElementWrapper(useWrapping = false) + + @JsonMerge + @JacksonXmlElementWrapper(useWrapping = false) var endEvent: List? = null - @JsonMerge @JacksonXmlElementWrapper(useWrapping = false) + + @JsonMerge + @JacksonXmlElementWrapper(useWrapping = false) var boundaryEvent: List? = null + // Events-intermediate - @JsonMerge @JacksonXmlElementWrapper(useWrapping = false) + @JsonMerge + @JacksonXmlElementWrapper(useWrapping = false) var intermediateCatchEvent: List? = null - @JsonMerge @JacksonXmlElementWrapper(useWrapping = false) + + @JsonMerge + @JacksonXmlElementWrapper(useWrapping = false) var intermediateThrowEvent: List? = null // Service task alike: - @JsonMerge @JacksonXmlElementWrapper(useWrapping = false) + @JsonMerge + @JacksonXmlElementWrapper(useWrapping = false) var task: List? = null - @JsonMerge @JacksonXmlElementWrapper(useWrapping = false) + + @JsonMerge + @JacksonXmlElementWrapper(useWrapping = false) var userTask: List? = null - @JsonMerge @JacksonXmlElementWrapper(useWrapping = false) + + @JsonMerge + @JacksonXmlElementWrapper(useWrapping = false) var scriptTask: List? = null - @JsonMerge @JacksonXmlElementWrapper(useWrapping = false) + + @JsonMerge + @JacksonXmlElementWrapper(useWrapping = false) var serviceTask: List? = null - @JsonMerge @JacksonXmlElementWrapper(useWrapping = false) + + @JsonMerge + @JacksonXmlElementWrapper(useWrapping = false) var businessRuleTask: List? = null - @JsonMerge @JacksonXmlElementWrapper(useWrapping = false) + + @JsonMerge + @JacksonXmlElementWrapper(useWrapping = false) var manualTask: List? = null - @JsonMerge @JacksonXmlElementWrapper(useWrapping = false) + + @JsonMerge + @JacksonXmlElementWrapper(useWrapping = false) var sendTask: List? = null - @JsonMerge @JacksonXmlElementWrapper(useWrapping = false) + + @JsonMerge + @JacksonXmlElementWrapper(useWrapping = false) var receiveTask: List? = null // Sub process alike - @JsonMerge @JacksonXmlElementWrapper(useWrapping = false) + @JsonMerge + @JacksonXmlElementWrapper(useWrapping = false) var callActivity: List? = null - @JsonMerge @JacksonXmlElementWrapper(useWrapping = false) + + @JsonMerge + @JacksonXmlElementWrapper(useWrapping = false) var subProcess: List? = null - @JsonMerge @JacksonXmlElementWrapper(useWrapping = false) + + @JsonMerge + @JacksonXmlElementWrapper(useWrapping = false) var transaction: List? = null - @JsonMerge @JacksonXmlElementWrapper(useWrapping = false) + + @JsonMerge + @JacksonXmlElementWrapper(useWrapping = false) var adHocSubProcess: List? = null // Gateways - @JsonMerge @JacksonXmlElementWrapper(useWrapping = false) + @JsonMerge + @JacksonXmlElementWrapper(useWrapping = false) var exclusiveGateway: List? = null - @JsonMerge @JacksonXmlElementWrapper(useWrapping = false) + + @JsonMerge + @JacksonXmlElementWrapper(useWrapping = false) var parallelGateway: List? = null - @JsonMerge @JacksonXmlElementWrapper(useWrapping = false) + + @JsonMerge + @JacksonXmlElementWrapper(useWrapping = false) var inclusiveGateway: List? = null - @JsonMerge @JacksonXmlElementWrapper(useWrapping = false) + + @JsonMerge + @JacksonXmlElementWrapper(useWrapping = false) var eventBasedGateway: List? = null - @JsonMerge @JacksonXmlElementWrapper(useWrapping = false) + + @JsonMerge + @JacksonXmlElementWrapper(useWrapping = false) var complexGateway: List? = null // Linking elements - @JsonMerge @JacksonXmlElementWrapper(useWrapping = false) + @JsonMerge + @JacksonXmlElementWrapper(useWrapping = false) var sequenceFlow: List? = null } // For mixed lists in XML we need to have JsonSetter/JsonMerge on field // https://github.com/FasterXML/jackson-dataformat-xml/issues/363 // unfortunately this has failed with Kotlin 'data' classes -class ProcessNode: BpmnMappable, ProcessBody() { +class ProcessNode : BpmnMappable, ProcessBody() { private val mappers = ConcurrentHashMap, Any>() - @JacksonXmlProperty(isAttribute = true) var id: String? = null // it is false - it is non-null - @JacksonXmlProperty(isAttribute = true) var name: String? = null + @JacksonXmlProperty(isAttribute = true) + var id: String? = null // it is false - it is non-null + @JacksonXmlProperty(isAttribute = true) + var name: String? = null var documentation: String? = null - @JacksonXmlProperty(isAttribute = true) var isExecutable: Boolean? = null + @JacksonXmlProperty(isAttribute = true) + var isExecutable: Boolean? = null override fun toElement(): BpmnProcess { val result = cachedMapper(ProcessNodeMapping::class.java).convertToDto(this) val mappedBody = mapBody(this) return result.copy( - body = mappedBody, - children = extractNestedProcesses(this) + body = mappedBody, + children = extractNestedProcesses(this), + laneSets = laneSet?.map { mapLaneSet(it) } ?: emptyList() ) } @@ -163,6 +220,11 @@ class ProcessNode: BpmnMappable, ProcessBody() { return fillBodyWithDedicatedElements(bodyMapper.convertToDto(body)) } + private fun mapLaneSet(laneSet: LaneSet): BpmnLaneSet { + val laneMapper = cachedMapper(LaneSetMapping::class.java) + return laneMapper.convertToDto(laneSet) + } + private fun fillBodyWithDedicatedElements(processBody: BpmnProcessBody): BpmnProcessBody { var body = processBody body = applySubprocessCustomizationByEventTrigger(body) @@ -176,13 +238,13 @@ class ProcessNode: BpmnMappable, ProcessBody() { private fun applyServiceTaskCustomizationByType(process: BpmnProcessBody): BpmnProcessBody { var result = process - result = extractTasksBasedOnType(result, "camel", cachedMapper(CamelMapper::class.java)) { updates, target -> target.copy(camelTask = updates) } + result = extractTasksBasedOnType(result, "camel", cachedMapper(CamelMapper::class.java)) { updates, target -> target.copy(camelTask = updates) } result = extractTasksBasedOnType(result, "external", cachedMapper(ExternalTaskMapper::class.java)) { updates, target -> target.copy(externalTask = updates) } - result = extractTasksBasedOnType(result, "http", cachedMapper(HttpMapper::class.java)) { updates, target -> target.copy(httpTask = updates) } - result = extractTasksBasedOnType(result, "mail", cachedMapper(MailMapper::class.java)) { updates, target -> target.copy(mailTask = updates) } - result = extractTasksBasedOnType(result, "mule", cachedMapper(MuleMapper::class.java)) { updates, target -> target.copy(muleTask = updates) } - result = extractTasksBasedOnType(result, "dmn", cachedMapper(DecisionMapper::class.java)) { updates, target -> target.copy(decisionTask = updates) } - result = extractTasksBasedOnType(result, "shell", cachedMapper(ShellMapper::class.java)) { updates, target -> target.copy(shellTask = updates) } + result = extractTasksBasedOnType(result, "http", cachedMapper(HttpMapper::class.java)) { updates, target -> target.copy(httpTask = updates) } + result = extractTasksBasedOnType(result, "mail", cachedMapper(MailMapper::class.java)) { updates, target -> target.copy(mailTask = updates) } + result = extractTasksBasedOnType(result, "mule", cachedMapper(MuleMapper::class.java)) { updates, target -> target.copy(muleTask = updates) } + result = extractTasksBasedOnType(result, "dmn", cachedMapper(DecisionMapper::class.java)) { updates, target -> target.copy(decisionTask = updates) } + result = extractTasksBasedOnType(result, "shell", cachedMapper(ShellMapper::class.java)) { updates, target -> target.copy(shellTask = updates) } return result } @@ -197,52 +259,110 @@ class ProcessNode: BpmnMappable, ProcessBody() { private fun applyIntermediateCatchEventCustomizationByType(process: BpmnProcessBody): BpmnProcessBody { var result = process - result = extractIntermediateCatchEventsBasedOnType(result, { null != it.timerEventDefinition }, cachedMapper(TimerCatchingMapper::class.java)) { updates, target -> target.copy(intermediateTimerCatchingEvent = updates) } - result = extractIntermediateCatchEventsBasedOnType(result, { null != it.signalEventDefinition }, cachedMapper(SignalCatchingMapper::class.java)) { updates, target -> target.copy(intermediateSignalCatchingEvent = updates) } - result = extractIntermediateCatchEventsBasedOnType(result, { null != it.messageEventDefinition }, cachedMapper(MessageCatchingMapper::class.java)) { updates, target -> target.copy(intermediateMessageCatchingEvent = updates) } - result = extractIntermediateCatchEventsBasedOnType(result, { null != it.conditionalEventDefinition }, cachedMapper(ConditionalCatchingMapper::class.java)) { updates, target -> target.copy(intermediateConditionalCatchingEvent = updates) } - result = extractIntermediateCatchEventsBasedOnType(result, { null != it.linkEventDefinition }, cachedMapper(LinkIntermediateCatchMapper::class.java)) { updates, target -> target.copy(intermediateLinkCatchingEvent = updates) } + result = extractIntermediateCatchEventsBasedOnType(result, { null != it.timerEventDefinition }, cachedMapper(TimerCatchingMapper::class.java)) { updates, target -> + target.copy(intermediateTimerCatchingEvent = updates) + } + result = extractIntermediateCatchEventsBasedOnType(result, { null != it.signalEventDefinition }, cachedMapper(SignalCatchingMapper::class.java)) { updates, target -> + target.copy(intermediateSignalCatchingEvent = updates) + } + result = extractIntermediateCatchEventsBasedOnType(result, { null != it.messageEventDefinition }, cachedMapper(MessageCatchingMapper::class.java)) { updates, target -> + target.copy(intermediateMessageCatchingEvent = updates) + } + result = extractIntermediateCatchEventsBasedOnType(result, { null != it.conditionalEventDefinition }, cachedMapper(ConditionalCatchingMapper::class.java)) { updates, target -> + target.copy(intermediateConditionalCatchingEvent = updates) + } + result = extractIntermediateCatchEventsBasedOnType(result, { null != it.linkEventDefinition }, cachedMapper(LinkIntermediateCatchMapper::class.java)) { updates, target -> + target.copy(intermediateLinkCatchingEvent = updates) + } return result } private fun applyIntermediateThrowingEventCustomizationByType(process: BpmnProcessBody): BpmnProcessBody { var result = process - result = extractIntermediateThrowingEventsBasedOnType(result, { null == it.escalationEventDefinition && null == it.signalEventDefinition }, cachedMapper(NoneThrowMapper::class.java)) { updates, target -> target.copy(intermediateNoneThrowingEvent = updates) } - result = extractIntermediateThrowingEventsBasedOnType(result, { null != it.signalEventDefinition }, cachedMapper(SignalThrowMapper::class.java)) { updates, target -> target.copy(intermediateSignalThrowingEvent = updates) } - result = extractIntermediateThrowingEventsBasedOnType(result, { null != it.escalationEventDefinition }, cachedMapper(EscalationThrowMapper::class.java)) { updates, target -> target.copy(intermediateEscalationThrowingEvent = updates) } + result = extractIntermediateThrowingEventsBasedOnType( + result, + { null == it.escalationEventDefinition && null == it.signalEventDefinition }, + cachedMapper(NoneThrowMapper::class.java) + ) { updates, target -> target.copy(intermediateNoneThrowingEvent = updates) } + result = extractIntermediateThrowingEventsBasedOnType(result, { null != it.signalEventDefinition }, cachedMapper(SignalThrowMapper::class.java)) { updates, target -> + target.copy(intermediateSignalThrowingEvent = updates) + } + result = extractIntermediateThrowingEventsBasedOnType(result, { null != it.escalationEventDefinition }, cachedMapper(EscalationThrowMapper::class.java)) { updates, target -> + target.copy(intermediateEscalationThrowingEvent = updates) + } return result } private fun applyEndEventCustomizationByType(process: BpmnProcessBody): BpmnProcessBody { var result = process - result = extractEndEventsBasedOnType(result, { null != it.errorEventDefinition }, cachedMapper(EndErrorMapper::class.java)) { updates, target -> target.copy(errorEndEvent = updates) } - result = extractEndEventsBasedOnType(result, { null != it.escalationEventDefinition }, cachedMapper(EndEscalationMapper::class.java)) { updates, target -> target.copy(escalationEndEvent = updates) } - result = extractEndEventsBasedOnType(result, { null != it.cancelEventDefinition }, cachedMapper(EndCancelMapper::class.java)) { updates, target -> target.copy(cancelEndEvent = updates) } - result = extractEndEventsBasedOnType(result, { null != it.terminateEventDefinition }, cachedMapper(EndTerminationMapper::class.java)) { updates, target -> target.copy(terminateEndEvent = updates) } + result = extractEndEventsBasedOnType(result, { null != it.errorEventDefinition }, cachedMapper(EndErrorMapper::class.java)) { updates, target -> target.copy(errorEndEvent = updates) } + result = extractEndEventsBasedOnType( + result, + { null != it.escalationEventDefinition }, + cachedMapper(EndEscalationMapper::class.java) + ) { updates, target -> target.copy(escalationEndEvent = updates) } + result = extractEndEventsBasedOnType(result, { null != it.cancelEventDefinition }, cachedMapper(EndCancelMapper::class.java)) { updates, target -> target.copy(cancelEndEvent = updates) } + result = + extractEndEventsBasedOnType(result, { null != it.terminateEventDefinition }, cachedMapper(EndTerminationMapper::class.java)) { updates, target -> target.copy(terminateEndEvent = updates) } return result } private fun applyStartEventCustomizationByType(process: BpmnProcessBody): BpmnProcessBody { var result = process - result = extractStartEventsBasedOnType(result, { null != it.conditionalEventDefinition }, cachedMapper(StartConditionalMapper::class.java)) { updates, target -> target.copy(conditionalStartEvent = updates) } - result = extractStartEventsBasedOnType(result, { null != it.errorEventDefinition }, cachedMapper(StartErrorMapper::class.java)) { updates, target -> target.copy(errorStartEvent = updates) } - result = extractStartEventsBasedOnType(result, { null != it.escalationEventDefinition }, cachedMapper(StartEscalationMapper::class.java)) { updates, target -> target.copy(escalationStartEvent = updates) } - result = extractStartEventsBasedOnType(result, { null != it.messageEventDefinition }, cachedMapper(StartMessageMapper::class.java)) { updates, target -> target.copy(messageStartEvent = updates) } - result = extractStartEventsBasedOnType(result, { null != it.signalEventDefinition }, cachedMapper(StartSignalMapper::class.java)) { updates, target -> target.copy(signalStartEvent = updates) } - result = extractStartEventsBasedOnType(result, { null != it.timerEventDefinition }, cachedMapper(StartTimerMapper::class.java)) { updates, target -> target.copy(timerStartEvent = updates) } + result = extractStartEventsBasedOnType( + result, + { null != it.conditionalEventDefinition }, + cachedMapper(StartConditionalMapper::class.java) + ) { updates, target -> target.copy(conditionalStartEvent = updates) } + result = extractStartEventsBasedOnType(result, { null != it.errorEventDefinition }, cachedMapper(StartErrorMapper::class.java)) { updates, target -> target.copy(errorStartEvent = updates) } + result = extractStartEventsBasedOnType( + result, + { null != it.escalationEventDefinition }, + cachedMapper(StartEscalationMapper::class.java) + ) { updates, target -> target.copy(escalationStartEvent = updates) } + result = + extractStartEventsBasedOnType(result, { null != it.messageEventDefinition }, cachedMapper(StartMessageMapper::class.java)) { updates, target -> target.copy(messageStartEvent = updates) } + result = extractStartEventsBasedOnType(result, { null != it.signalEventDefinition }, cachedMapper(StartSignalMapper::class.java)) { updates, target -> target.copy(signalStartEvent = updates) } + result = extractStartEventsBasedOnType(result, { null != it.timerEventDefinition }, cachedMapper(StartTimerMapper::class.java)) { updates, target -> target.copy(timerStartEvent = updates) } return result } private fun applyBoundaryEventCustomizationByType(process: BpmnProcessBody): BpmnProcessBody { var result = process - result = extractBoundaryEventsBasedOnType(result, { null != it.cancelEventDefinition }, cachedMapper(BoundaryCancelMapper::class.java)) { updates, target -> target.copy(boundaryCancelEvent = updates) } - result = extractBoundaryEventsBasedOnType(result, { null != it.compensateEventDefinition }, cachedMapper(BoundaryCompensationMapper::class.java)) { updates, target -> target.copy(boundaryCompensationEvent = updates) } - result = extractBoundaryEventsBasedOnType(result, { null != it.conditionalEventDefinition }, cachedMapper(BoundaryConditionalMapper::class.java)) { updates, target -> target.copy(boundaryConditionalEvent = updates) } - result = extractBoundaryEventsBasedOnType(result, { null != it.errorEventDefinition }, cachedMapper(BoundaryErrorMapper::class.java)) { updates, target -> target.copy(boundaryErrorEvent = updates) } - result = extractBoundaryEventsBasedOnType(result, { null != it.escalationEventDefinition }, cachedMapper(BoundaryEscalationMapper::class.java)) { updates, target -> target.copy(boundaryEscalationEvent = updates) } - result = extractBoundaryEventsBasedOnType(result, { null != it.messageEventDefinition }, cachedMapper(BoundaryMessageMapper::class.java)) { updates, target -> target.copy(boundaryMessageEvent = updates) } - result = extractBoundaryEventsBasedOnType(result, { null != it.signalEventDefinition }, cachedMapper(BoundarySignalMapper::class.java)) { updates, target -> target.copy(boundarySignalEvent = updates) } - result = extractBoundaryEventsBasedOnType(result, { null != it.timerEventDefinition }, cachedMapper(BoundaryTimerMapper::class.java)) { updates, target -> target.copy(boundaryTimerEvent = updates) } + result = extractBoundaryEventsBasedOnType( + result, + { null != it.cancelEventDefinition }, + cachedMapper(BoundaryCancelMapper::class.java) + ) { updates, target -> target.copy(boundaryCancelEvent = updates) } + result = extractBoundaryEventsBasedOnType(result, { null != it.compensateEventDefinition }, cachedMapper(BoundaryCompensationMapper::class.java)) { updates, target -> + target.copy(boundaryCompensationEvent = updates) + } + result = extractBoundaryEventsBasedOnType(result, { null != it.conditionalEventDefinition }, cachedMapper(BoundaryConditionalMapper::class.java)) { updates, target -> + target.copy(boundaryConditionalEvent = updates) + } + result = extractBoundaryEventsBasedOnType( + result, + { null != it.errorEventDefinition }, + cachedMapper(BoundaryErrorMapper::class.java) + ) { updates, target -> target.copy(boundaryErrorEvent = updates) } + result = extractBoundaryEventsBasedOnType(result, { null != it.escalationEventDefinition }, cachedMapper(BoundaryEscalationMapper::class.java)) { updates, target -> + target.copy(boundaryEscalationEvent = updates) + } + result = extractBoundaryEventsBasedOnType( + result, + { null != it.messageEventDefinition }, + cachedMapper(BoundaryMessageMapper::class.java) + ) { updates, target -> target.copy(boundaryMessageEvent = updates) } + result = extractBoundaryEventsBasedOnType( + result, + { null != it.signalEventDefinition }, + cachedMapper(BoundarySignalMapper::class.java) + ) { updates, target -> target.copy(boundarySignalEvent = updates) } + result = extractBoundaryEventsBasedOnType( + result, + { null != it.timerEventDefinition }, + cachedMapper(BoundaryTimerMapper::class.java) + ) { updates, target -> target.copy(boundaryTimerEvent = updates) } return result } @@ -256,7 +376,12 @@ class ProcessNode: BpmnMappable, ProcessBody() { return process } - private fun extractIntermediateCatchEventsBasedOnType(process: BpmnProcessBody, filter: (BpmnIntermediateCatchingEvent) -> Boolean, mapper: IntermediateCatchEventMapper, update: (List?, BpmnProcessBody) -> BpmnProcessBody): BpmnProcessBody { + private fun extractIntermediateCatchEventsBasedOnType( + process: BpmnProcessBody, + filter: (BpmnIntermediateCatchingEvent) -> Boolean, + mapper: IntermediateCatchEventMapper, + update: (List?, BpmnProcessBody) -> BpmnProcessBody + ): BpmnProcessBody { process.intermediateCatchEvent?.apply { val byTypeGroup = this.groupBy { filter(it) } val newProcess = process.copy(intermediateCatchEvent = byTypeGroup[false]) @@ -266,7 +391,12 @@ class ProcessNode: BpmnMappable, ProcessBody() { return process } - private fun extractIntermediateThrowingEventsBasedOnType(process: BpmnProcessBody, filter: (BpmnIntermediateThrowingEvent) -> Boolean, mapper: IntermediateThrowEventMapper, update: (List?, BpmnProcessBody) -> BpmnProcessBody): BpmnProcessBody { + private fun extractIntermediateThrowingEventsBasedOnType( + process: BpmnProcessBody, + filter: (BpmnIntermediateThrowingEvent) -> Boolean, + mapper: IntermediateThrowEventMapper, + update: (List?, BpmnProcessBody) -> BpmnProcessBody + ): BpmnProcessBody { process.intermediateThrowEvent?.apply { val byTypeGroup = this.groupBy { filter(it) } val newProcess = process.copy(intermediateThrowEvent = byTypeGroup[false]) @@ -276,7 +406,12 @@ class ProcessNode: BpmnMappable, ProcessBody() { return process } - private fun extractEndEventsBasedOnType(process: BpmnProcessBody, filter: (BpmnEndEvent) -> Boolean, mapper: EndEventMapper, update: (List?, BpmnProcessBody) -> BpmnProcessBody): BpmnProcessBody { + private fun extractEndEventsBasedOnType( + process: BpmnProcessBody, + filter: (BpmnEndEvent) -> Boolean, + mapper: EndEventMapper, + update: (List?, BpmnProcessBody) -> BpmnProcessBody + ): BpmnProcessBody { process.endEvent?.apply { val byTypeGroup = this.groupBy { filter(it) } val newProcess = process.copy(endEvent = byTypeGroup[false]) @@ -286,7 +421,12 @@ class ProcessNode: BpmnMappable, ProcessBody() { return process } - private fun extractStartEventsBasedOnType(process: BpmnProcessBody, filter: (BpmnStartEvent) -> Boolean, mapper: StartEventMapper, update: (List?, BpmnProcessBody) -> BpmnProcessBody): BpmnProcessBody { + private fun extractStartEventsBasedOnType( + process: BpmnProcessBody, + filter: (BpmnStartEvent) -> Boolean, + mapper: StartEventMapper, + update: (List?, BpmnProcessBody) -> BpmnProcessBody + ): BpmnProcessBody { process.startEvent?.apply { val byTypeGroup = this.groupBy { filter(it) } val newProcess = process.copy(startEvent = byTypeGroup[false]) @@ -296,7 +436,12 @@ class ProcessNode: BpmnMappable, ProcessBody() { return process } - private fun extractBoundaryEventsBasedOnType(process: BpmnProcessBody, filter: (BpmnBoundaryEvent) -> Boolean, mapper: BoundaryEventMapper, update: (List?, BpmnProcessBody) -> BpmnProcessBody): BpmnProcessBody { + private fun extractBoundaryEventsBasedOnType( + process: BpmnProcessBody, + filter: (BpmnBoundaryEvent) -> Boolean, + mapper: BoundaryEventMapper, + update: (List?, BpmnProcessBody) -> BpmnProcessBody + ): BpmnProcessBody { process.boundaryEvent?.apply { val byTypeGroup = this.groupBy { filter(it) } val newProcess = process.copy(boundaryEvent = byTypeGroup[false]) @@ -315,42 +460,52 @@ class ProcessNode: BpmnMappable, ProcessBody() { fun convertToDto(input: ProcessNode): BpmnProcess } - @Mapper(uses = [ - BpmnElementIdMapper::class, - SubProcess.SubProcessMapping::class, - Transaction.TransactionMapping::class, - BusinessRuleTask.BusinessRuleTaskMapping::class, - ServiceTask.ServiceTaskMapping::class, - ManualTask.ManualTaskMapping::class, - Task.TaskMapping::class, - SendTask.SendTaskMapping::class, - ReceiveTask.ReceiveTaskMapping::class, - ScriptTask.ScriptTaskMapping::class, - UserTask.UserTaskMapping::class, - StartEventNode.StartEventNodeMapping::class, - IntermediateCatchEvent.Mapping::class - ]) + @Mapper( + uses = [ + BpmnElementIdMapper::class, + SubProcess.SubProcessMapping::class, + Transaction.TransactionMapping::class, + BusinessRuleTask.BusinessRuleTaskMapping::class, + ServiceTask.ServiceTaskMapping::class, + ManualTask.ManualTaskMapping::class, + Task.TaskMapping::class, + SendTask.SendTaskMapping::class,ReceiveTask.ReceiveTaskMapping::class, + ScriptTask.ScriptTaskMapping::class, + UserTask.UserTaskMapping::class, + StartEventNode.StartEventNodeMapping::class, + IntermediateCatchEvent.Mapping::class + ] + ) interface BodyMapping { @Mappings( - Mapping(source = "subProcess", target = "subProcess"), - Mapping(source = "subProcess", target = "collapsedSubProcess"), // will be post-filtered - Mapping(source = "transaction", target = "transaction"), - Mapping(source = "transaction", target = "collapsedTransaction") // will be post-filtered + Mapping(source = "subProcess", target = "subProcess"), + Mapping(source = "subProcess", target = "collapsedSubProcess"), // will be post-filtered + Mapping(source = "transaction", target = "transaction"), + Mapping(source = "transaction", target = "collapsedTransaction") // will be post-filtered ) fun convertToDto(input: ProcessBody): BpmnProcessBody } + @Mapper(uses = [BpmnElementIdMapper::class]) + interface LaneSetMapping { + + @Mapping(source = "lane", target = "lanes") + fun convertToDto(input: LaneSet): BpmnLaneSet + } + @Mapper - interface EventSubProcessMapper: SubProcessMapper + interface EventSubProcessMapper : SubProcessMapper @Mapper - interface CamelMapper: ServiceTaskMapper { + interface CamelMapper : ServiceTaskMapper { @Mappings( Mapping(source = "forCompensation", target = "isForCompensation"), - Mapping(expression = "$EXTENSION_ELEM_STREAM.filter(it -> \"camelContext\".equals(it.getName()))$EXTENSION_STRING_EXTRACTOR", - target = "camelContext") + Mapping( + expression = "$EXTENSION_ELEM_STREAM.filter(it -> \"camelContext\".equals(it.getName()))$EXTENSION_STRING_EXTRACTOR", + target = "camelContext" + ) ) override fun convertToDto(input: BpmnServiceTask): BpmnCamelTask } @@ -367,131 +522,217 @@ class ProcessNode: BpmnMappable, ProcessBody() { } @Mapper - interface HttpMapper: ServiceTaskMapper { + interface HttpMapper : ServiceTaskMapper { @Mappings( - Mapping(source = "forCompensation", target = "isForCompensation"), - Mapping(expression = "$EXTENSION_ELEM_STREAM.filter(it -> \"requestMethod\".equals(it.getName()))$EXTENSION_STRING_EXTRACTOR", - target = "requestMethod"), - Mapping(expression = "$EXTENSION_ELEM_STREAM.filter(it -> \"requestUrl\".equals(it.getName()))$EXTENSION_STRING_EXTRACTOR", - target = "requestUrl"), - Mapping(expression = "$EXTENSION_ELEM_STREAM.filter(it -> \"requestHeaders\".equals(it.getName()))$EXTENSION_STRING_EXTRACTOR", - target = "requestHeaders"), - Mapping(expression = "$EXTENSION_ELEM_STREAM.filter(it -> \"requestBody\".equals(it.getName()))$EXTENSION_STRING_EXTRACTOR", - target = "requestBody"), - Mapping(expression = "$EXTENSION_ELEM_STREAM.filter(it -> \"requestBodyEncoding\".equals(it.getName()))$EXTENSION_STRING_EXTRACTOR", - target = "requestBodyEncoding"), - Mapping(expression = "$EXTENSION_ELEM_STREAM.filter(it -> \"requestTimeout\".equals(it.getName()))$EXTENSION_STRING_EXTRACTOR", - target = "requestTimeout"), - Mapping(expression = "$EXTENSION_ELEM_STREAM.filter(it -> \"disallowRedirects\".equals(it.getName()))$EXTENSION_BOOLEAN_EXTRACTOR", - target = "disallowRedirects"), - Mapping(expression = "$EXTENSION_ELEM_STREAM.filter(it -> \"failStatusCodes\".equals(it.getName()))$EXTENSION_STRING_EXTRACTOR", - target = "failStatusCodes"), - Mapping(expression = "$EXTENSION_ELEM_STREAM.filter(it -> \"handleStatusCodes\".equals(it.getName()))$EXTENSION_STRING_EXTRACTOR", - target = "handleStatusCodes"), - Mapping(expression = "$EXTENSION_ELEM_STREAM.filter(it -> \"responseVariableName\".equals(it.getName()))$EXTENSION_STRING_EXTRACTOR", - target = "responseVariableName"), - Mapping(expression = "$EXTENSION_ELEM_STREAM.filter(it -> \"ignoreException\".equals(it.getName()))$EXTENSION_STRING_EXTRACTOR", - target = "ignoreException"), - Mapping(expression = "$EXTENSION_ELEM_STREAM.filter(it -> \"saveRequestVariables\".equals(it.getName()))$EXTENSION_STRING_EXTRACTOR", - target = "saveRequestVariables"), - Mapping(expression = "$EXTENSION_ELEM_STREAM.filter(it -> \"saveResponseParameters\".equals(it.getName()))$EXTENSION_STRING_EXTRACTOR", - target = "saveResponseParameters"), - Mapping(expression = "$EXTENSION_ELEM_STREAM.filter(it -> \"resultVariablePrefix\".equals(it.getName()))$EXTENSION_STRING_EXTRACTOR", - target = "resultVariablePrefix"), - Mapping(expression = "$EXTENSION_ELEM_STREAM.filter(it -> \"saveResponseParametersTransient\".equals(it.getName()))$EXTENSION_STRING_EXTRACTOR", - target = "saveResponseParametersTransient"), - Mapping(expression = "$EXTENSION_ELEM_STREAM.filter(it -> \"saveResponseVariableAsJson\".equals(it.getName()))$EXTENSION_STRING_EXTRACTOR", - target = "saveResponseVariableAsJson") + Mapping(source = "forCompensation", target = "isForCompensation"), + Mapping( + expression = "$EXTENSION_ELEM_STREAM.filter(it -> \"requestMethod\".equals(it.getName()))$EXTENSION_STRING_EXTRACTOR", + target = "requestMethod" + ), + Mapping( + expression = "$EXTENSION_ELEM_STREAM.filter(it -> \"requestUrl\".equals(it.getName()))$EXTENSION_STRING_EXTRACTOR", + target = "requestUrl" + ), + Mapping( + expression = "$EXTENSION_ELEM_STREAM.filter(it -> \"requestHeaders\".equals(it.getName()))$EXTENSION_STRING_EXTRACTOR", + target = "requestHeaders" + ), + Mapping( + expression = "$EXTENSION_ELEM_STREAM.filter(it -> \"requestBody\".equals(it.getName()))$EXTENSION_STRING_EXTRACTOR", + target = "requestBody" + ), + Mapping( + expression = "$EXTENSION_ELEM_STREAM.filter(it -> \"requestBodyEncoding\".equals(it.getName()))$EXTENSION_STRING_EXTRACTOR", + target = "requestBodyEncoding" + ), + Mapping( + expression = "$EXTENSION_ELEM_STREAM.filter(it -> \"requestTimeout\".equals(it.getName()))$EXTENSION_STRING_EXTRACTOR", + target = "requestTimeout" + ), + Mapping( + expression = "$EXTENSION_ELEM_STREAM.filter(it -> \"disallowRedirects\".equals(it.getName()))$EXTENSION_BOOLEAN_EXTRACTOR", + target = "disallowRedirects" + ), + Mapping( + expression = "$EXTENSION_ELEM_STREAM.filter(it -> \"failStatusCodes\".equals(it.getName()))$EXTENSION_STRING_EXTRACTOR", + target = "failStatusCodes" + ), + Mapping( + expression = "$EXTENSION_ELEM_STREAM.filter(it -> \"handleStatusCodes\".equals(it.getName()))$EXTENSION_STRING_EXTRACTOR", + target = "handleStatusCodes" + ), + Mapping( + expression = "$EXTENSION_ELEM_STREAM.filter(it -> \"responseVariableName\".equals(it.getName()))$EXTENSION_STRING_EXTRACTOR", + target = "responseVariableName" + ), + Mapping( + expression = "$EXTENSION_ELEM_STREAM.filter(it -> \"ignoreException\".equals(it.getName()))$EXTENSION_STRING_EXTRACTOR", + target = "ignoreException" + ), + Mapping( + expression = "$EXTENSION_ELEM_STREAM.filter(it -> \"saveRequestVariables\".equals(it.getName()))$EXTENSION_STRING_EXTRACTOR", + target = "saveRequestVariables" + ), + Mapping( + expression = "$EXTENSION_ELEM_STREAM.filter(it -> \"saveResponseParameters\".equals(it.getName()))$EXTENSION_STRING_EXTRACTOR", + target = "saveResponseParameters" + ), + Mapping( + expression = "$EXTENSION_ELEM_STREAM.filter(it -> \"resultVariablePrefix\".equals(it.getName()))$EXTENSION_STRING_EXTRACTOR", + target = "resultVariablePrefix" + ), + Mapping( + expression = "$EXTENSION_ELEM_STREAM.filter(it -> \"saveResponseParametersTransient\".equals(it.getName()))$EXTENSION_STRING_EXTRACTOR", + target = "saveResponseParametersTransient" + ), + Mapping( + expression = "$EXTENSION_ELEM_STREAM.filter(it -> \"saveResponseVariableAsJson\".equals(it.getName()))$EXTENSION_STRING_EXTRACTOR", + target = "saveResponseVariableAsJson" + ) ) override fun convertToDto(input: BpmnServiceTask): BpmnHttpTask } @Mapper - interface MailMapper: ServiceTaskMapper { + interface MailMapper : ServiceTaskMapper { @Mappings( - Mapping(source = "forCompensation", target = "isForCompensation"), - Mapping(expression = "$EXTENSION_ELEM_STREAM.filter(it -> \"headers\".equals(it.getName()))$EXTENSION_STRING_EXTRACTOR", - target = "headers"), - Mapping(expression = "$EXTENSION_ELEM_STREAM.filter(it -> \"to\".equals(it.getName()))$EXTENSION_STRING_EXTRACTOR", - target = "to"), - Mapping(expression = "$EXTENSION_ELEM_STREAM.filter(it -> \"from\".equals(it.getName()))$EXTENSION_STRING_EXTRACTOR", - target = "from"), - Mapping(expression = "$EXTENSION_ELEM_STREAM.filter(it -> \"subject\".equals(it.getName()))$EXTENSION_STRING_EXTRACTOR", - target = "subject"), - Mapping(expression = "$EXTENSION_ELEM_STREAM.filter(it -> \"cc\".equals(it.getName()))$EXTENSION_STRING_EXTRACTOR", - target = "cc"), - Mapping(expression = "$EXTENSION_ELEM_STREAM.filter(it -> \"bcc\".equals(it.getName()))$EXTENSION_STRING_EXTRACTOR", - target = "bcc"), - Mapping(expression = "$EXTENSION_ELEM_STREAM.filter(it -> \"text\".equals(it.getName()))$EXTENSION_STRING_EXTRACTOR", - target = "text"), - Mapping(expression = "$EXTENSION_ELEM_STREAM.filter(it -> \"html\".equals(it.getName()))$EXTENSION_STRING_EXTRACTOR", - target = "html"), - Mapping(expression = "$EXTENSION_ELEM_STREAM.filter(it -> \"charset\".equals(it.getName()))$EXTENSION_STRING_EXTRACTOR", - target = "charset") + Mapping(source = "forCompensation", target = "isForCompensation"), + Mapping( + expression = "$EXTENSION_ELEM_STREAM.filter(it -> \"headers\".equals(it.getName()))$EXTENSION_STRING_EXTRACTOR", + target = "headers" + ), + Mapping( + expression = "$EXTENSION_ELEM_STREAM.filter(it -> \"to\".equals(it.getName()))$EXTENSION_STRING_EXTRACTOR", + target = "to" + ), + Mapping( + expression = "$EXTENSION_ELEM_STREAM.filter(it -> \"from\".equals(it.getName()))$EXTENSION_STRING_EXTRACTOR", + target = "from" + ), + Mapping( + expression = "$EXTENSION_ELEM_STREAM.filter(it -> \"subject\".equals(it.getName()))$EXTENSION_STRING_EXTRACTOR", + target = "subject" + ), + Mapping( + expression = "$EXTENSION_ELEM_STREAM.filter(it -> \"cc\".equals(it.getName()))$EXTENSION_STRING_EXTRACTOR", + target = "cc" + ), + Mapping( + expression = "$EXTENSION_ELEM_STREAM.filter(it -> \"bcc\".equals(it.getName()))$EXTENSION_STRING_EXTRACTOR", + target = "bcc" + ), + Mapping( + expression = "$EXTENSION_ELEM_STREAM.filter(it -> \"text\".equals(it.getName()))$EXTENSION_STRING_EXTRACTOR", + target = "text" + ), + Mapping( + expression = "$EXTENSION_ELEM_STREAM.filter(it -> \"html\".equals(it.getName()))$EXTENSION_STRING_EXTRACTOR", + target = "html" + ), + Mapping( + expression = "$EXTENSION_ELEM_STREAM.filter(it -> \"charset\".equals(it.getName()))$EXTENSION_STRING_EXTRACTOR", + target = "charset" + ) ) override fun convertToDto(input: BpmnServiceTask): BpmnMailTask } @Mapper - interface MuleMapper: ServiceTaskMapper { + interface MuleMapper : ServiceTaskMapper { @Mappings( - Mapping(source = "forCompensation", target = "isForCompensation"), - Mapping(expression = "$EXTENSION_ELEM_STREAM.filter(it -> \"endpointUrl\".equals(it.getName()))$EXTENSION_STRING_EXTRACTOR", - target = "endpointUrl"), - Mapping(expression = "$EXTENSION_ELEM_STREAM.filter(it -> \"language\".equals(it.getName()))$EXTENSION_STRING_EXTRACTOR", - target = "language"), - Mapping(expression = "$EXTENSION_ELEM_STREAM.filter(it -> \"payloadExpression\".equals(it.getName()))$EXTENSION_EXPRESSION_EXTRACTOR", - target = "payloadExpression"), - Mapping(expression = "$EXTENSION_ELEM_STREAM.filter(it -> \"resultVariable\".equals(it.getName()))$EXTENSION_STRING_EXTRACTOR", - target = "resultVariableCdata") + Mapping(source = "forCompensation", target = "isForCompensation"), + Mapping( + expression = "$EXTENSION_ELEM_STREAM.filter(it -> \"endpointUrl\".equals(it.getName()))$EXTENSION_STRING_EXTRACTOR", + target = "endpointUrl" + ), + Mapping( + expression = "$EXTENSION_ELEM_STREAM.filter(it -> \"language\".equals(it.getName()))$EXTENSION_STRING_EXTRACTOR", + target = "language" + ), + Mapping( + expression = "$EXTENSION_ELEM_STREAM.filter(it -> \"payloadExpression\".equals(it.getName()))$EXTENSION_EXPRESSION_EXTRACTOR", + target = "payloadExpression" + ), + Mapping( + expression = "$EXTENSION_ELEM_STREAM.filter(it -> \"resultVariable\".equals(it.getName()))$EXTENSION_STRING_EXTRACTOR", + target = "resultVariableCdata" + ) ) override fun convertToDto(input: BpmnServiceTask): BpmnMuleTask } @Mapper - interface DecisionMapper: ServiceTaskMapper { + interface DecisionMapper : ServiceTaskMapper { @Mappings( - Mapping(source = "forCompensation", target = "isForCompensation"), - Mapping(expression = "$EXTENSION_ELEM_STREAM.filter(it -> \"decisionTableReferenceKey\".equals(it.getName()))$EXTENSION_STRING_EXTRACTOR", - target = "decisionTableReferenceKey"), - Mapping(expression = "$EXTENSION_ELEM_STREAM.filter(it -> \"decisionTaskThrowErrorOnNoHits\".equals(it.getName()))$EXTENSION_BOOLEAN_EXTRACTOR", - target = "decisionTaskThrowErrorOnNoHits"), - Mapping(expression = "$EXTENSION_ELEM_STREAM.filter(it -> \"fallbackToDefaultTenant\".equals(it.getName()))$EXTENSION_BOOLEAN_EXTRACTOR", - target = "fallbackToDefaultTenantCdata") + Mapping(source = "forCompensation", target = "isForCompensation"), + Mapping( + expression = "$EXTENSION_ELEM_STREAM.filter(it -> \"decisionTableReferenceKey\".equals(it.getName()))$EXTENSION_STRING_EXTRACTOR", + target = "decisionTableReferenceKey" + ), + Mapping( + expression = "$EXTENSION_ELEM_STREAM.filter(it -> \"decisionTaskThrowErrorOnNoHits\".equals(it.getName()))$EXTENSION_BOOLEAN_EXTRACTOR", + target = "decisionTaskThrowErrorOnNoHits" + ), + Mapping( + expression = "$EXTENSION_ELEM_STREAM.filter(it -> \"fallbackToDefaultTenant\".equals(it.getName()))$EXTENSION_BOOLEAN_EXTRACTOR", + target = "fallbackToDefaultTenantCdata" + ) ) override fun convertToDto(input: BpmnServiceTask): BpmnDecisionTask } @Mapper - interface ShellMapper: ServiceTaskMapper { + interface ShellMapper : ServiceTaskMapper { @Mappings( - Mapping(source = "forCompensation", target = "isForCompensation"), - Mapping(expression = "$EXTENSION_ELEM_STREAM.filter(it -> \"command\".equals(it.getName()))$EXTENSION_STRING_EXTRACTOR", - target = "command"), - Mapping(expression = "$EXTENSION_ELEM_STREAM.filter(it -> \"arg1\".equals(it.getName()))$EXTENSION_STRING_EXTRACTOR", - target = "arg1"), - Mapping(expression = "$EXTENSION_ELEM_STREAM.filter(it -> \"arg2\".equals(it.getName()))$EXTENSION_STRING_EXTRACTOR", - target = "arg2"), - Mapping(expression = "$EXTENSION_ELEM_STREAM.filter(it -> \"arg3\".equals(it.getName()))$EXTENSION_STRING_EXTRACTOR", - target = "arg3"), - Mapping(expression = "$EXTENSION_ELEM_STREAM.filter(it -> \"arg4\".equals(it.getName()))$EXTENSION_STRING_EXTRACTOR", - target = "arg4"), - Mapping(expression = "$EXTENSION_ELEM_STREAM.filter(it -> \"arg5\".equals(it.getName()))$EXTENSION_STRING_EXTRACTOR", - target = "arg5"), - Mapping(expression = "$EXTENSION_ELEM_STREAM.filter(it -> \"wait\".equals(it.getName()))$EXTENSION_STRING_EXTRACTOR", - target = "wait"), - Mapping(expression = "$EXTENSION_ELEM_STREAM.filter(it -> \"cleanEnv\".equals(it.getName()))$EXTENSION_STRING_EXTRACTOR", - target = "cleanEnv"), - Mapping(expression = "$EXTENSION_ELEM_STREAM.filter(it -> \"errorCodeVariable\".equals(it.getName()))$EXTENSION_STRING_EXTRACTOR", - target = "errorCodeVariable"), - Mapping(expression = "$EXTENSION_ELEM_STREAM.filter(it -> \"outputVariable\".equals(it.getName()))$EXTENSION_STRING_EXTRACTOR", - target = "outputVariable"), - Mapping(expression = "$EXTENSION_ELEM_STREAM.filter(it -> \"directory\".equals(it.getName()))$EXTENSION_STRING_EXTRACTOR", - target = "directory") + Mapping(source = "forCompensation", target = "isForCompensation"), + Mapping( + expression = "$EXTENSION_ELEM_STREAM.filter(it -> \"command\".equals(it.getName()))$EXTENSION_STRING_EXTRACTOR", + target = "command" + ), + Mapping( + expression = "$EXTENSION_ELEM_STREAM.filter(it -> \"arg1\".equals(it.getName()))$EXTENSION_STRING_EXTRACTOR", + target = "arg1" + ), + Mapping( + expression = "$EXTENSION_ELEM_STREAM.filter(it -> \"arg2\".equals(it.getName()))$EXTENSION_STRING_EXTRACTOR", + target = "arg2" + ), + Mapping( + expression = "$EXTENSION_ELEM_STREAM.filter(it -> \"arg3\".equals(it.getName()))$EXTENSION_STRING_EXTRACTOR", + target = "arg3" + ), + Mapping( + expression = "$EXTENSION_ELEM_STREAM.filter(it -> \"arg4\".equals(it.getName()))$EXTENSION_STRING_EXTRACTOR", + target = "arg4" + ), + Mapping( + expression = "$EXTENSION_ELEM_STREAM.filter(it -> \"arg5\".equals(it.getName()))$EXTENSION_STRING_EXTRACTOR", + target = "arg5" + ), + Mapping( + expression = "$EXTENSION_ELEM_STREAM.filter(it -> \"wait\".equals(it.getName()))$EXTENSION_STRING_EXTRACTOR", + target = "wait" + ), + Mapping( + expression = "$EXTENSION_ELEM_STREAM.filter(it -> \"cleanEnv\".equals(it.getName()))$EXTENSION_STRING_EXTRACTOR", + target = "cleanEnv" + ), + Mapping( + expression = "$EXTENSION_ELEM_STREAM.filter(it -> \"errorCodeVariable\".equals(it.getName()))$EXTENSION_STRING_EXTRACTOR", + target = "errorCodeVariable" + ), + Mapping( + expression = "$EXTENSION_ELEM_STREAM.filter(it -> \"outputVariable\".equals(it.getName()))$EXTENSION_STRING_EXTRACTOR", + target = "outputVariable" + ), + Mapping( + expression = "$EXTENSION_ELEM_STREAM.filter(it -> \"directory\".equals(it.getName()))$EXTENSION_STRING_EXTRACTOR", + target = "directory" + ) ) override fun convertToDto(input: BpmnServiceTask): BpmnShellTask } @@ -502,98 +743,98 @@ class ProcessNode: BpmnMappable, ProcessBody() { } @Mapper - interface TimerCatchingMapper: IntermediateCatchEventMapper + interface TimerCatchingMapper : IntermediateCatchEventMapper @Mapper - interface SignalCatchingMapper: IntermediateCatchEventMapper + interface SignalCatchingMapper : IntermediateCatchEventMapper @Mapper - interface MessageCatchingMapper: IntermediateCatchEventMapper + interface MessageCatchingMapper : IntermediateCatchEventMapper @Mapper - interface ConditionalCatchingMapper: IntermediateCatchEventMapper + interface ConditionalCatchingMapper : IntermediateCatchEventMapper @Mapper - interface LinkIntermediateCatchMapper: IntermediateCatchEventMapper + interface LinkIntermediateCatchMapper : IntermediateCatchEventMapper interface IntermediateCatchEventMapper { fun convertToDto(input: BpmnIntermediateCatchingEvent): T } @Mapper - interface NoneThrowMapper: IntermediateThrowEventMapper + interface NoneThrowMapper : IntermediateThrowEventMapper @Mapper - interface SignalThrowMapper: IntermediateThrowEventMapper + interface SignalThrowMapper : IntermediateThrowEventMapper @Mapper - interface EscalationThrowMapper: IntermediateThrowEventMapper + interface EscalationThrowMapper : IntermediateThrowEventMapper interface IntermediateThrowEventMapper { fun convertToDto(input: BpmnIntermediateThrowingEvent): T } @Mapper - interface EndCancelMapper: EndEventMapper + interface EndCancelMapper : EndEventMapper @Mapper - interface EndErrorMapper: EndEventMapper + interface EndErrorMapper : EndEventMapper @Mapper - interface EndEscalationMapper: EndEventMapper + interface EndEscalationMapper : EndEventMapper @Mapper - interface EndTerminationMapper: EndEventMapper + interface EndTerminationMapper : EndEventMapper interface EndEventMapper { fun convertToDto(input: BpmnEndEvent): T } @Mapper - interface StartTimerMapper: StartEventMapper + interface StartTimerMapper : StartEventMapper @Mapper - interface StartSignalMapper: StartEventMapper + interface StartSignalMapper : StartEventMapper @Mapper - interface StartMessageMapper: StartEventMapper + interface StartMessageMapper : StartEventMapper @Mapper - interface StartErrorMapper: StartEventMapper + interface StartErrorMapper : StartEventMapper @Mapper - interface StartEscalationMapper: StartEventMapper + interface StartEscalationMapper : StartEventMapper @Mapper - interface StartConditionalMapper: StartEventMapper + interface StartConditionalMapper : StartEventMapper interface StartEventMapper { fun convertToDto(input: BpmnStartEvent): T } @Mapper - interface BoundaryCancelMapper: BoundaryEventMapper + interface BoundaryCancelMapper : BoundaryEventMapper @Mapper - interface BoundaryCompensationMapper: BoundaryEventMapper + interface BoundaryCompensationMapper : BoundaryEventMapper @Mapper - interface BoundaryConditionalMapper: BoundaryEventMapper + interface BoundaryConditionalMapper : BoundaryEventMapper @Mapper - interface BoundaryErrorMapper: BoundaryEventMapper + interface BoundaryErrorMapper : BoundaryEventMapper @Mapper - interface BoundaryEscalationMapper: BoundaryEventMapper + interface BoundaryEscalationMapper : BoundaryEventMapper @Mapper - interface BoundaryMessageMapper: BoundaryEventMapper + interface BoundaryMessageMapper : BoundaryEventMapper @Mapper - interface BoundarySignalMapper: BoundaryEventMapper + interface BoundarySignalMapper : BoundaryEventMapper @Mapper - interface BoundaryTimerMapper: BoundaryEventMapper + interface BoundaryTimerMapper : BoundaryEventMapper interface BoundaryEventMapper { fun convertToDto(input: BpmnBoundaryEvent): T @@ -605,8 +846,8 @@ class ProcessNode: BpmnMappable, ProcessBody() { } data class DiagramNode( - @JacksonXmlProperty(isAttribute = true) val id: String, - @JacksonXmlProperty(localName = "BPMNPlane") val bpmnPlane: Plane + @JacksonXmlProperty(isAttribute = true) val id: String, + @JacksonXmlProperty(localName = "BPMNPlane") val bpmnPlane: Plane ) : BpmnMappable { override fun toElement(): DiagramElement { @@ -617,4 +858,4 @@ data class DiagramNode( interface Mapping { fun convertToDto(input: DiagramNode): DiagramElement } -} \ No newline at end of file +} diff --git a/camunda-xml-parser/src/main/kotlin/com/valb3r/bpmn/intellij/plugin/camunda/parser/nodes/collaboration/Collaboration.kt b/camunda-xml-parser/src/main/kotlin/com/valb3r/bpmn/intellij/plugin/camunda/parser/nodes/collaboration/Collaboration.kt new file mode 100644 index 000000000..469f11e56 --- /dev/null +++ b/camunda-xml-parser/src/main/kotlin/com/valb3r/bpmn/intellij/plugin/camunda/parser/nodes/collaboration/Collaboration.kt @@ -0,0 +1,43 @@ +package com.valb3r.bpmn.intellij.plugin.camunda.parser.nodes.collaboration + +import com.fasterxml.jackson.annotation.JsonMerge +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty +import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.BpmnCollaboration +import com.valb3r.bpmn.intellij.plugin.camunda.parser.nodes.BpmnMappable +import com.valb3r.bpmn.intellij.plugin.camunda.parser.nodes.process.BpmnElementIdMapper +import org.mapstruct.Mapper +import org.mapstruct.factory.Mappers + +data class Collaboration( + @JacksonXmlProperty(isAttribute = true) val id: String, + @JacksonXmlProperty(isAttribute = true) val name: String?, + @JsonMerge @JacksonXmlElementWrapper(useWrapping = false) val participant: List?, + @JsonMerge @JacksonXmlElementWrapper(useWrapping = false) val messageFlow: List?, +) : BpmnMappable { + + override fun toElement(): BpmnCollaboration { + return Mappers.getMapper(Mapping::class.java).convertToDto(this) + } + + @Mapper(uses = [BpmnElementIdMapper::class]) + interface Mapping { + fun convertToDto(input: Collaboration): BpmnCollaboration + } +} + +data class Participant( + @JacksonXmlProperty(isAttribute = true) val id: String, + @JacksonXmlProperty(isAttribute = true) val name: String?, + @JacksonXmlProperty(isAttribute = true) val processRef: String?, + val documentation: String? +) + +data class MessageFlow( + @JacksonXmlProperty(isAttribute = true) val id: String, + @JacksonXmlProperty(isAttribute = true) val name: String?, + val documentation: String?, + @JacksonXmlProperty(isAttribute = true) val sourceRef: String?, + @JacksonXmlProperty(isAttribute = true) val targetRef: String?, +) + diff --git a/camunda-xml-parser/src/main/kotlin/com/valb3r/bpmn/intellij/plugin/camunda/parser/nodes/process/LaneSet.kt b/camunda-xml-parser/src/main/kotlin/com/valb3r/bpmn/intellij/plugin/camunda/parser/nodes/process/LaneSet.kt new file mode 100644 index 000000000..ac5a92269 --- /dev/null +++ b/camunda-xml-parser/src/main/kotlin/com/valb3r/bpmn/intellij/plugin/camunda/parser/nodes/process/LaneSet.kt @@ -0,0 +1,24 @@ +package com.valb3r.bpmn.intellij.plugin.camunda.parser.nodes.process + +import com.fasterxml.jackson.annotation.JsonMerge +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlCData +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlText +import com.valb3r.bpmn.intellij.plugin.bpmn.parser.core.CDATA_FIELD + + +data class LaneSet( + @JacksonXmlProperty(isAttribute = true) val id: String, + @JsonMerge @JacksonXmlElementWrapper(useWrapping = false) val lane: List?, +) + +data class Lane( + @JacksonXmlProperty(isAttribute = true) val id: String, + @JacksonXmlProperty(isAttribute = true) val name: String?, + val documentation: String?, + @JsonMerge @JacksonXmlElementWrapper(useWrapping = false) val flowNodeRef: List?, +) + +data class FlowNodeRef(@JsonProperty(CDATA_FIELD) @JacksonXmlText @JacksonXmlCData val ref: String? = null) diff --git a/camunda-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/camunda/parser/CamundaParserPopurriTest.kt b/camunda-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/camunda/parser/CamundaParserPopurriTest.kt index 8c4d0201c..8e20e9f68 100644 --- a/camunda-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/camunda/parser/CamundaParserPopurriTest.kt +++ b/camunda-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/camunda/parser/CamundaParserPopurriTest.kt @@ -1,18 +1,15 @@ package com.valb3r.bpmn.intellij.plugin.camunda.parser -import com.valb3r.bpmn.intellij.plugin.bpmn.api.BpmnProcessObject -import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.BpmnElementId -import com.valb3r.bpmn.intellij.plugin.bpmn.api.diagram.DiagramElementId +import com.valb3r.bpmn.intellij.plugin.bpmn.api.BpmnFileObject import org.amshove.kluent.shouldNotBeNull import org.junit.jupiter.api.Test -import java.util.* internal class CamundaParserPopurriTest { @Test fun `XML process with all Camunda elements is parseable without error`() { - val processObject: BpmnProcessObject? + val processObject: BpmnFileObject? processObject = CamundaParser().parse("popurri.bpmn".asResource()!!) diff --git a/camunda-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/camunda/parser/CommonUtils.kt b/camunda-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/camunda/parser/CommonUtils.kt index aeea54be1..8a7a2eace 100644 --- a/camunda-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/camunda/parser/CommonUtils.kt +++ b/camunda-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/camunda/parser/CommonUtils.kt @@ -1,22 +1,21 @@ package com.valb3r.bpmn.intellij.plugin.camunda.parser -import com.valb3r.bpmn.intellij.plugin.bpmn.api.BpmnProcessObject +import com.valb3r.bpmn.intellij.plugin.bpmn.api.BpmnFileObject import com.valb3r.bpmn.intellij.plugin.bpmn.api.events.EventPropagatableToXml -import com.valb3r.bpmn.intellij.plugin.camunda.parser.CamundaParser import org.amshove.kluent.shouldNotBeNull import java.nio.charset.StandardCharsets fun String.asResource(): String? = object {}::class.java.classLoader.getResource(this)?.readText(StandardCharsets.UTF_8) -fun readAndUpdateProcess(parser: CamundaParser, event: EventPropagatableToXml): BpmnProcessObject { +fun readAndUpdateProcess(parser: CamundaParser, event: EventPropagatableToXml): BpmnFileObject { return readAndUpdateProcess(parser, "simple-nested.bpmn20.xml", event) } -fun readAndUpdateProcess(parser: CamundaParser, processName: String, event: EventPropagatableToXml): BpmnProcessObject { +fun readAndUpdateProcess(parser: CamundaParser, processName: String, event: EventPropagatableToXml): BpmnFileObject { return readAndUpdateProcess(parser, processName, listOf(event)) } -fun readAndUpdateProcess(parser: CamundaParser, processName: String, events: List): BpmnProcessObject { +fun readAndUpdateProcess(parser: CamundaParser, processName: String, events: List): BpmnFileObject { val updated = updateBpmnFile(parser, processName, events) return parser.parse(updated) } @@ -29,4 +28,4 @@ fun updateBpmnFile(parser: CamundaParser, processName: String, events: List + + + + + Some docs + + + + Docs + + + Some docs + + + + + + + + + Lane 1 docs + + + + + + startEvent + endEvent + + + Lane 2 docs + + + + + + task1 + task2 + + + Lane 3 docs + exclusiveGateway + + + + Flow_0azr5ii + + + Flow_0d674ph + Flow_0o7uq2i + + + Flow_0azr5ii + Flow_11nikih + + + Flow_11nikih + Flow_0xg9put + Flow_0o7uq2i + + + Flow_0xg9put + Flow_0d674ph + + + + + + + + + + + task1Participant2 + task2Participant2 + + + task3Participant2 + + + + Flow_0io2j9n + Flow_1gv7f66 + + + Flow_0io2j9n + Flow_0on2aiy + + + + Flow_1gv7f66 + Flow_0on2aiy + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/flowable-xml-parser/src/main/kotlin/com/valb3r/bpmn/intellij/plugin/flowable/parser/FlowableParser.kt b/flowable-xml-parser/src/main/kotlin/com/valb3r/bpmn/intellij/plugin/flowable/parser/FlowableParser.kt index 8e6757ef0..b81407aa4 100644 --- a/flowable-xml-parser/src/main/kotlin/com/valb3r/bpmn/intellij/plugin/flowable/parser/FlowableParser.kt +++ b/flowable-xml-parser/src/main/kotlin/com/valb3r/bpmn/intellij/plugin/flowable/parser/FlowableParser.kt @@ -2,7 +2,7 @@ package com.valb3r.bpmn.intellij.plugin.flowable.parser import com.fasterxml.jackson.dataformat.xml.XmlMapper import com.fasterxml.jackson.module.kotlin.readValue -import com.valb3r.bpmn.intellij.plugin.bpmn.api.BpmnProcessObject +import com.valb3r.bpmn.intellij.plugin.bpmn.api.BpmnFileObject import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.elements.WithBpmnId import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.elements.tasks.BpmnExternalTask import com.valb3r.bpmn.intellij.plugin.bpmn.api.info.PropertyType @@ -145,18 +145,18 @@ class FlowableParser : BaseBpmnParser() { private val mapper: XmlMapper = mapper() - override fun parse(input: String): BpmnProcessObject { + override fun parse(input: String): BpmnFileObject { val dto = mapper.readValue(input) return toProcessObject(dto) } - private fun toProcessObject(dto: BpmnFile): BpmnProcessObject { - // TODO - Multi process support? + private fun toProcessObject(dto: BpmnFile): BpmnFileObject { markSubprocessesAndTransactionsThatHaveExternalDiagramAsCollapsed(dto.processes[0], dto.diagrams!!) - val process = dto.processes[0].toElement() + val processes = dto.processes.map { it.toElement() } + val collaborations = dto.collaborations?.map { it.toElement() } ?: emptyList() val diagrams = dto.diagrams!!.map { it.toElement() } - return BpmnProcessObject(process, diagrams) + return BpmnFileObject(processes, collaborations, diagrams) } override fun modelNs(): NS { diff --git a/flowable-xml-parser/src/main/kotlin/com/valb3r/bpmn/intellij/plugin/flowable/parser/nodes/FlowableXml.kt b/flowable-xml-parser/src/main/kotlin/com/valb3r/bpmn/intellij/plugin/flowable/parser/nodes/FlowableXml.kt index 6a90668b9..683a25384 100644 --- a/flowable-xml-parser/src/main/kotlin/com/valb3r/bpmn/intellij/plugin/flowable/parser/nodes/FlowableXml.kt +++ b/flowable-xml-parser/src/main/kotlin/com/valb3r/bpmn/intellij/plugin/flowable/parser/nodes/FlowableXml.kt @@ -19,6 +19,7 @@ import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.elements.subprocess.BpmnEve import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.elements.subprocess.BpmnSubProcess import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.elements.tasks.* import com.valb3r.bpmn.intellij.plugin.bpmn.api.diagram.DiagramElement +import com.valb3r.bpmn.intellij.plugin.flowable.parser.nodes.collaboration.Collaboration import com.valb3r.bpmn.intellij.plugin.flowable.parser.nodes.diagram.DiagramElementIdMapper import com.valb3r.bpmn.intellij.plugin.flowable.parser.nodes.diagram.Plane import com.valb3r.bpmn.intellij.plugin.flowable.parser.nodes.process.* @@ -48,6 +49,11 @@ class BpmnFile( @JacksonXmlElementWrapper(useWrapping = false) var messages: List? = null, + @JacksonXmlProperty(localName = "collaboration") + @JsonMerge + @JacksonXmlElementWrapper(useWrapping = false) + var collaborations: List? = null, + @JacksonXmlProperty(localName = "process") @JsonMerge @JacksonXmlElementWrapper(useWrapping = false) diff --git a/flowable-xml-parser/src/main/kotlin/com/valb3r/bpmn/intellij/plugin/flowable/parser/nodes/collaboration/Collaboration.kt b/flowable-xml-parser/src/main/kotlin/com/valb3r/bpmn/intellij/plugin/flowable/parser/nodes/collaboration/Collaboration.kt new file mode 100644 index 000000000..37a70d606 --- /dev/null +++ b/flowable-xml-parser/src/main/kotlin/com/valb3r/bpmn/intellij/plugin/flowable/parser/nodes/collaboration/Collaboration.kt @@ -0,0 +1,43 @@ +package com.valb3r.bpmn.intellij.plugin.flowable.parser.nodes.collaboration + +import com.fasterxml.jackson.annotation.JsonMerge +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty +import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.BpmnCollaboration +import com.valb3r.bpmn.intellij.plugin.flowable.parser.nodes.BpmnMappable +import com.valb3r.bpmn.intellij.plugin.flowable.parser.nodes.process.BpmnElementIdMapper +import org.mapstruct.Mapper +import org.mapstruct.factory.Mappers + +data class Collaboration( + @JacksonXmlProperty(isAttribute = true) val id: String, + @JacksonXmlProperty(isAttribute = true) val name: String?, + @JsonMerge @JacksonXmlElementWrapper(useWrapping = false) val participant: List?, + @JsonMerge @JacksonXmlElementWrapper(useWrapping = false) val messageFlow: List?, +) : BpmnMappable { + + override fun toElement(): BpmnCollaboration { + return Mappers.getMapper(Mapping::class.java).convertToDto(this) + } + + @Mapper(uses = [BpmnElementIdMapper::class]) + interface Mapping { + fun convertToDto(input: Collaboration): BpmnCollaboration + } +} + +data class Participant( + @JacksonXmlProperty(isAttribute = true) val id: String, + @JacksonXmlProperty(isAttribute = true) val name: String?, + @JacksonXmlProperty(isAttribute = true) val processRef: String?, + val documentation: String? +) + +data class MessageFlow( + @JacksonXmlProperty(isAttribute = true) val id: String, + @JacksonXmlProperty(isAttribute = true) val name: String?, + val documentation: String?, + @JacksonXmlProperty(isAttribute = true) val sourceRef: String?, + @JacksonXmlProperty(isAttribute = true) val targetRef: String?, +) + diff --git a/flowable-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/flowable/parser/CollapsedSubprocessTest.kt b/flowable-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/flowable/parser/CollapsedSubprocessTest.kt index a0f9c347f..3a7cf8b54 100644 --- a/flowable-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/flowable/parser/CollapsedSubprocessTest.kt +++ b/flowable-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/flowable/parser/CollapsedSubprocessTest.kt @@ -1,6 +1,6 @@ package com.valb3r.bpmn.intellij.plugin.flowable.parser -import com.valb3r.bpmn.intellij.plugin.bpmn.api.BpmnProcessObject +import com.valb3r.bpmn.intellij.plugin.bpmn.api.BpmnFileObject import org.amshove.kluent.shouldBeEqualTo import org.amshove.kluent.shouldHaveSingleItem import org.amshove.kluent.shouldNotBeNull @@ -10,23 +10,23 @@ internal class CollapsedSubprocessTest { @Test fun `Collapsed subprocess is readable and mapped`() { - val processObject: BpmnProcessObject? + val processObject: BpmnFileObject? processObject = FlowableParser().parse("simple-collapsed-subprocess.bpmn20.xml".asResource()!!) processObject.shouldNotBeNull() - processObject.process.body!!.subProcess!!.shouldHaveSingleItem().id.id.shouldBeEqualTo("subProcess") - processObject.process.body!!.collapsedSubProcess!!.shouldHaveSingleItem().id.id.shouldBeEqualTo("collapsedSubProcess") + processObject.processes[0].body!!.subProcess!!.shouldHaveSingleItem().id.id.shouldBeEqualTo("subProcess") + processObject.processes[0].body!!.collapsedSubProcess!!.shouldHaveSingleItem().id.id.shouldBeEqualTo("collapsedSubProcess") } @Test fun `Collapsed transactional subprocess is readable and mapped`() { - val processObject: BpmnProcessObject? + val processObject: BpmnFileObject? processObject = FlowableParser().parse("transactional-collapsed-subprocess.bpmn20.xml".asResource()!!) processObject.shouldNotBeNull() - processObject.process.body!!.transaction!!.shouldHaveSingleItem().id.id.shouldBeEqualTo("transactionalSubprocess") - processObject.process.body!!.collapsedTransaction!!.shouldHaveSingleItem().id.id.shouldBeEqualTo("transactionalCollapsedSubprocess") + processObject.processes[0].body!!.transaction!!.shouldHaveSingleItem().id.id.shouldBeEqualTo("transactionalSubprocess") + processObject.processes[0].body!!.collapsedTransaction!!.shouldHaveSingleItem().id.id.shouldBeEqualTo("transactionalCollapsedSubprocess") } -} \ No newline at end of file +} diff --git a/flowable-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/flowable/parser/CommonUtils.kt b/flowable-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/flowable/parser/CommonUtils.kt index 9a55c2c27..5a3f21159 100644 --- a/flowable-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/flowable/parser/CommonUtils.kt +++ b/flowable-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/flowable/parser/CommonUtils.kt @@ -1,21 +1,21 @@ package com.valb3r.bpmn.intellij.plugin.flowable.parser -import com.valb3r.bpmn.intellij.plugin.bpmn.api.BpmnProcessObject +import com.valb3r.bpmn.intellij.plugin.bpmn.api.BpmnFileObject import com.valb3r.bpmn.intellij.plugin.bpmn.api.events.EventPropagatableToXml import org.amshove.kluent.shouldNotBeNull import java.nio.charset.StandardCharsets fun String.asResource(): String? = object {}::class.java.classLoader.getResource(this)?.readText(StandardCharsets.UTF_8) -fun readAndUpdateProcess(parser: FlowableParser, event: EventPropagatableToXml): BpmnProcessObject { +fun readAndUpdateProcess(parser: FlowableParser, event: EventPropagatableToXml): BpmnFileObject { return readAndUpdateProcess(parser, "simple-nested.bpmn20.xml", event) } -fun readAndUpdateProcess(parser: FlowableParser, processName: String, event: EventPropagatableToXml): BpmnProcessObject { +fun readAndUpdateProcess(parser: FlowableParser, processName: String, event: EventPropagatableToXml): BpmnFileObject { return readAndUpdateProcess(parser, processName, listOf(event)) } -fun readAndUpdateProcess(parser: FlowableParser, processName: String, events: List): BpmnProcessObject { +fun readAndUpdateProcess(parser: FlowableParser, processName: String, events: List): BpmnFileObject { val updated = updateBpmnFile(parser, processName, events) return parser.parse(updated) } @@ -28,4 +28,4 @@ fun updateBpmnFile(parser: FlowableParser, processName: String, events: List generateUpdateEvent(clazz: KClass): EventPropagatableToXml { @@ -394,7 +394,7 @@ internal class XmlUpdateEventBpmnObjectAddedTest { return ctor.call(*args.toTypedArray()) } - private fun readAndUpdateProcess(event: EventPropagatableToXml): BpmnProcessObject { + private fun readAndUpdateProcess(event: EventPropagatableToXml): BpmnFileObject { val updated = parser.update( "simple-nested.bpmn20.xml".asResource()!!, listOf(event) @@ -404,4 +404,4 @@ internal class XmlUpdateEventBpmnObjectAddedTest { return parser.parse(updated) } -} \ No newline at end of file +} diff --git a/flowable-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/flowable/parser/XmlUpdateEventDocumentationFormatTest.kt b/flowable-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/flowable/parser/XmlUpdateEventDocumentationFormatTest.kt index 79a344bca..74001b09f 100644 --- a/flowable-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/flowable/parser/XmlUpdateEventDocumentationFormatTest.kt +++ b/flowable-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/flowable/parser/XmlUpdateEventDocumentationFormatTest.kt @@ -1,6 +1,6 @@ package com.valb3r.bpmn.intellij.plugin.flowable.parser -import com.valb3r.bpmn.intellij.plugin.bpmn.api.BpmnProcessObject +import com.valb3r.bpmn.intellij.plugin.bpmn.api.BpmnFileObject import com.valb3r.bpmn.intellij.plugin.bpmn.api.PropertyTable import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.BpmnElementId import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.elements.WithParentId @@ -68,17 +68,17 @@ class XmlUpdateEventDocumentationFormatTest { fun `Removing element does not break 'documentation' element formatting`() { val originalProcess = readProcess() val updatedProcess = readAndUpdateProcess(BpmnElementRemovedEvent(BpmnElementId(startEventId))) - updatedProcess.process.body!!.scriptTask!![0].documentation - .shouldBeEqualTo(originalProcess.process.body!!.scriptTask!![0].documentation) + updatedProcess.processes[0].body!!.scriptTask!![0].documentation!! + .shouldBeEqualTo(originalProcess.processes[0].body!!.scriptTask!![0].documentation) } - private fun readProcess(): BpmnProcessObject { + private fun readProcess(): BpmnFileObject { val process = parser.parse(documentationProcessName.asResource()!!) process.shouldNotBeNull() return process } - private fun readAndUpdateProcess(event: EventPropagatableToXml): BpmnProcessObject { + private fun readAndUpdateProcess(event: EventPropagatableToXml): BpmnFileObject { val updated = parser.update( documentationProcessName.asResource()!!, listOf(event) @@ -88,4 +88,4 @@ class XmlUpdateEventDocumentationFormatTest { return parser.parse(updated) } -} \ No newline at end of file +} diff --git a/flowable-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/flowable/parser/XmlWithNestedStructureParserTest.kt b/flowable-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/flowable/parser/XmlWithNestedStructureParserTest.kt index 7f6ee1227..757a0d1f4 100644 --- a/flowable-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/flowable/parser/XmlWithNestedStructureParserTest.kt +++ b/flowable-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/flowable/parser/XmlWithNestedStructureParserTest.kt @@ -1,6 +1,6 @@ package com.valb3r.bpmn.intellij.plugin.flowable.parser -import com.valb3r.bpmn.intellij.plugin.bpmn.api.BpmnProcessObject +import com.valb3r.bpmn.intellij.plugin.bpmn.api.BpmnFileObject import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.BpmnElementId import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.BpmnProcessBody import org.amshove.kluent.* @@ -13,21 +13,21 @@ internal class XmlWithNestedStructureParserTest { @Test fun `XML file nested process structure parsing test`() { - val processObject: BpmnProcessObject? + val processObject: BpmnFileObject? processObject = FlowableParser().parse("nested-interlaced.bpmn20.xml".asResource()!!) // Assert the process structure processObject.shouldNotBeNull() - processObject.process.id.shouldBeEqualTo(BpmnElementId("nested-test")) - processObject.process.body.shouldNotBeNull() - processObject.process.body!!.startEvent!!.shouldHaveSingleItem().id.id.shouldBeEqualTo("startGlobal") - processObject.process.body!!.endEvent!!.shouldHaveSingleItem().id.id.shouldBeEqualTo("endGlobal") - processObject.process.body!!.serviceTask!!.map { it.id.id }.shouldContainSame( + processObject.processes[0].id.shouldBeEqualTo(BpmnElementId("nested-test")) + processObject.processes[0].body.shouldNotBeNull() + processObject.processes[0].body!!.startEvent!!.shouldHaveSingleItem().id.id.shouldBeEqualTo("startGlobal") + processObject.processes[0].body!!.endEvent!!.shouldHaveSingleItem().id.id.shouldBeEqualTo("endGlobal") + processObject.processes[0].body!!.serviceTask!!.map { it.id.id }.shouldContainSame( listOf("parentInterlaceBeginServiceTask", "parentInterlaceEndServiceTask") ) - processObject.process.body!!.exclusiveGateway!!.shouldHaveSingleItem().id.id.shouldBeEqualTo("basicGateway") - processObject.process.body!!.sequenceFlow!!.map { it.id.id }.shouldContainSame( + processObject.processes[0].body!!.exclusiveGateway!!.shouldHaveSingleItem().id.id.shouldBeEqualTo("basicGateway") + processObject.processes[0].body!!.sequenceFlow!!.map { it.id.id }.shouldContainSame( listOf( "sid-E256FA9F-E663-49B5-B15A-6C1BA641C61A", "sid-4F47ED8C-967A-4774-AC42-0DD33A0F5FA7", @@ -38,10 +38,10 @@ internal class XmlWithNestedStructureParserTest { ) ) - processObject.process.body!!.subProcess!!.shouldHaveSingleItem().id.id.shouldBeEqualTo("sid-C4389D7E-1083-47D2-BECC-99479E63D18B") - processObject.process.body!!.adHocSubProcess!!.shouldHaveSingleItem().id.id.shouldBeEqualTo("sid-5EEB495F-ACAC-4C04-99E1-691D906B3A30") - processObject.process.body!!.transaction!!.shouldHaveSingleItem().id.id.shouldBeEqualTo("sid-1BB4FA80-C87F-4A05-95DF-753D06EE7424") - processObject.process.children!!.keys.map { it.id }.shouldContainSame( + processObject.processes[0].body!!.subProcess!!.shouldHaveSingleItem().id.id.shouldBeEqualTo("sid-C4389D7E-1083-47D2-BECC-99479E63D18B") + processObject.processes[0].body!!.adHocSubProcess!!.shouldHaveSingleItem().id.id.shouldBeEqualTo("sid-5EEB495F-ACAC-4C04-99E1-691D906B3A30") + processObject.processes[0].body!!.transaction!!.shouldHaveSingleItem().id.id.shouldBeEqualTo("sid-1BB4FA80-C87F-4A05-95DF-753D06EE7424") + processObject.processes[0].children!!.keys.map { it.id }.shouldContainSame( listOf( "sid-C4389D7E-1083-47D2-BECC-99479E63D18B", "sid-5EEB495F-ACAC-4C04-99E1-691D906B3A30", @@ -51,13 +51,13 @@ internal class XmlWithNestedStructureParserTest { ) ) - validateDirectChildSubProcess(processObject.process.children!![BpmnElementId("sid-C4389D7E-1083-47D2-BECC-99479E63D18B")]!!) - validateInSubProcessNestedChildSubProcess(processObject.process.children!![BpmnElementId("sid-775FFB07-8CFB-4F82-A6EA-AB0E9BBB79A6")]!!) - validateDirectAdhocSubProcess(processObject.process.children!![BpmnElementId("sid-5EEB495F-ACAC-4C04-99E1-691D906B3A30")]!!) - validateInAdHocNestedChildSubProcess(processObject.process.children!![BpmnElementId("sid-3AD3FAD5-389C-4066-8CB0-C4090CA91F6D")]!!) - validateDirectTransactionSubProcess(processObject.process.children!![BpmnElementId("sid-1BB4FA80-C87F-4A05-95DF-753D06EE7424")]!!) + validateDirectChildSubProcess(processObject.processes[0].children!![BpmnElementId("sid-C4389D7E-1083-47D2-BECC-99479E63D18B")]!!) + validateInSubProcessNestedChildSubProcess(processObject.processes[0].children!![BpmnElementId("sid-775FFB07-8CFB-4F82-A6EA-AB0E9BBB79A6")]!!) + validateDirectAdhocSubProcess(processObject.processes[0].children!![BpmnElementId("sid-5EEB495F-ACAC-4C04-99E1-691D906B3A30")]!!) + validateInAdHocNestedChildSubProcess(processObject.processes[0].children!![BpmnElementId("sid-3AD3FAD5-389C-4066-8CB0-C4090CA91F6D")]!!) + validateDirectTransactionSubProcess(processObject.processes[0].children!![BpmnElementId("sid-1BB4FA80-C87F-4A05-95DF-753D06EE7424")]!!) - othersAreEmpty(processObject.process.body!!) + othersAreEmpty(processObject.processes[0].body!!) } private fun validateDirectChildSubProcess(subProcess: BpmnProcessBody) { @@ -176,4 +176,4 @@ internal class XmlWithNestedStructureParserTest { body.inclusiveGateway.shouldBeNull() body.eventBasedGateway.shouldBeNull() } -} \ No newline at end of file +} diff --git a/flowable-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/flowable/parser/bugfix/CondExpressionWithoutTypeParseable.kt b/flowable-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/flowable/parser/bugfix/CondExpressionWithoutTypeParseable.kt index 51b4cfa46..94ecb0f9e 100644 --- a/flowable-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/flowable/parser/bugfix/CondExpressionWithoutTypeParseable.kt +++ b/flowable-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/flowable/parser/bugfix/CondExpressionWithoutTypeParseable.kt @@ -1,6 +1,6 @@ package com.valb3r.bpmn.intellij.plugin.flowable.parser.bugfix -import com.valb3r.bpmn.intellij.plugin.bpmn.api.BpmnProcessObject +import com.valb3r.bpmn.intellij.plugin.bpmn.api.BpmnFileObject import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.BpmnElementId import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.elements.ConditionExpression import com.valb3r.bpmn.intellij.plugin.bpmn.api.info.PropertyType @@ -22,13 +22,13 @@ internal class CondExpressionWithoutTypeParseable { fun `Sequence flow with empty conditional flow element parseable`() { val processObject = parser.parse(FILE.asResource()!!) - val sequenceFlow = processObject.process.body!!.sequenceFlow!![2] + val sequenceFlow = processObject.processes[0].body!!.sequenceFlow!![2] sequenceFlow.id.shouldBeEqualTo(sequenceFlowElem) sequenceFlow.conditionExpression.shouldBeEqualTo(ConditionExpression(null, "\${evection.num<3} ")) - val props = BpmnProcessObject(processObject.process, processObject.diagram).toView(FlowableObjectFactory()).elemPropertiesByElementId[sequenceFlow.id]!! + val props = BpmnFileObject(processObject.processes, processObject.diagram).toView(FlowableObjectFactory()).processes[0].processElemPropertiesByElementId[sequenceFlow.id]!! props[PropertyType.ID]!!.value.shouldBeEqualTo(sequenceFlowElem.id) props[PropertyType.CONDITION_EXPR_TYPE]!!.value.shouldBeNull() props[PropertyType.CONDITION_EXPR_VALUE]!!.value.shouldBeEqualTo("\${evection.num<3} ") } -} \ No newline at end of file +} diff --git a/flowable-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/flowable/parser/bugfix/EmptyCondExpressionParseable.kt b/flowable-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/flowable/parser/bugfix/EmptyCondExpressionParseable.kt index 0a76d1294..904bf0d8b 100644 --- a/flowable-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/flowable/parser/bugfix/EmptyCondExpressionParseable.kt +++ b/flowable-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/flowable/parser/bugfix/EmptyCondExpressionParseable.kt @@ -1,6 +1,6 @@ package com.valb3r.bpmn.intellij.plugin.flowable.parser.bugfix -import com.valb3r.bpmn.intellij.plugin.bpmn.api.BpmnProcessObject +import com.valb3r.bpmn.intellij.plugin.bpmn.api.BpmnFileObject import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.BpmnElementId import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.elements.ConditionExpression import com.valb3r.bpmn.intellij.plugin.bpmn.api.info.PropertyType @@ -22,13 +22,13 @@ internal class EmptyCondExpressionParseable { fun `Sequence flow with empty conditional flow element parseable`() { val processObject = parser.parse(FILE.asResource()!!) - val sequenceFlow = processObject.process.body!!.sequenceFlow!![0] + val sequenceFlow = processObject.processes[0].body!!.sequenceFlow!![0] sequenceFlow.id.shouldBeEqualTo(sequenceFlowElem) sequenceFlow.conditionExpression.shouldBeEqualTo(ConditionExpression(null, "")) - val props = BpmnProcessObject(processObject.process, processObject.diagram).toView(FlowableObjectFactory()).elemPropertiesByElementId[sequenceFlow.id]!! + val props = BpmnFileObject(processObject.processes, processObject.diagram).toView(FlowableObjectFactory()).processes[0].processElemPropertiesByElementId[sequenceFlow.id]!! props[PropertyType.ID]!!.value.shouldBeEqualTo(sequenceFlowElem.id) props[PropertyType.CONDITION_EXPR_TYPE]!!.value.shouldBeNull() props[PropertyType.CONDITION_EXPR_VALUE]!!.value.shouldBeEqualTo("") } -} \ No newline at end of file +} diff --git a/flowable-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/flowable/parser/customevents/FlowableStartEventWithNestedExtensionTest.kt b/flowable-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/flowable/parser/customevents/FlowableStartEventWithNestedExtensionTest.kt index 1ddf10860..9fdc03d1f 100644 --- a/flowable-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/flowable/parser/customevents/FlowableStartEventWithNestedExtensionTest.kt +++ b/flowable-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/flowable/parser/customevents/FlowableStartEventWithNestedExtensionTest.kt @@ -1,6 +1,6 @@ package com.valb3r.bpmn.intellij.plugin.flowable.parser.customevents -import com.valb3r.bpmn.intellij.plugin.bpmn.api.BpmnProcessObject +import com.valb3r.bpmn.intellij.plugin.bpmn.api.BpmnFileObject import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.BpmnElementId import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.elements.events.begin.BpmnStartEvent import com.valb3r.bpmn.intellij.plugin.bpmn.api.info.Property @@ -30,7 +30,7 @@ internal class FlowableUsereventWithNestedExtensionTest { val event = readStartEventWithExtensions(processObject) event.id.shouldBeEqualTo(elementId) - val props = BpmnProcessObject(processObject.process, processObject.diagram).toView(FlowableObjectFactory()).elemPropertiesByElementId[event.id]!! + val props = BpmnFileObject(processObject.processes, processObject.diagram).toView(FlowableObjectFactory()).processes[0].processElemPropertiesByElementId[event.id]!! props[PropertyType.ID]!!.value.shouldBeEqualTo(event.id.id) props.getAll(PropertyType.FORM_PROPERTY_ID).shouldContainSame(arrayOf( @@ -81,7 +81,7 @@ internal class FlowableUsereventWithNestedExtensionTest { return readStartEventWithExtensions(readAndUpdateProcess(parser, FILE, StringValueUpdatedEvent(elementId, property, newValue, propertyIndex = propertyIndex.split(",")))) } - private fun readStartEventWithExtensions(processObject: BpmnProcessObject): BpmnStartEvent { - return processObject.process.body!!.startEvent!!.shouldHaveSize(1)[0] + private fun readStartEventWithExtensions(processObject: BpmnFileObject): BpmnStartEvent { + return processObject.processes[0].body!!.startEvent!!.shouldHaveSize(1)[0] } } diff --git a/flowable-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/flowable/parser/customservicetasks/FlowableBusinessRuleTaskTest.kt b/flowable-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/flowable/parser/customservicetasks/FlowableBusinessRuleTaskTest.kt index 2d9111743..b8c33aa5e 100644 --- a/flowable-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/flowable/parser/customservicetasks/FlowableBusinessRuleTaskTest.kt +++ b/flowable-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/flowable/parser/customservicetasks/FlowableBusinessRuleTaskTest.kt @@ -1,6 +1,6 @@ package com.valb3r.bpmn.intellij.plugin.flowable.parser.customservicetasks -import com.valb3r.bpmn.intellij.plugin.bpmn.api.BpmnProcessObject +import com.valb3r.bpmn.intellij.plugin.bpmn.api.BpmnFileObject import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.BpmnElementId import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.elements.tasks.BpmnBusinessRuleTask import com.valb3r.bpmn.intellij.plugin.bpmn.api.info.PropertyType @@ -36,7 +36,7 @@ internal class FlowableBusinessRuleTaskTest { task.resultVariable.shouldBeEqualTo("RESULT_VAR") task.exclude!!.shouldBeTrue() - val props = BpmnProcessObject(processObject.process, processObject.diagram).toView(FlowableObjectFactory()).elemPropertiesByElementId[task.id]!! + val props = BpmnFileObject(processObject.processes, processObject.diagram).toView(FlowableObjectFactory()).processes[0].processElemPropertiesByElementId[task.id]!! props[PropertyType.ID]!!.value.shouldBeEqualTo(task.id.id) props[PropertyType.NAME]!!.value.shouldBeEqualTo(task.name) props[PropertyType.DOCUMENTATION]!!.value.shouldBeEqualTo(task.documentation) @@ -82,7 +82,7 @@ internal class FlowableBusinessRuleTaskTest { return readBusinessRuleTask(readAndUpdateProcess(parser, FILE, BooleanValueUpdatedEvent(elementId, property, newValue))) } - private fun readBusinessRuleTask(processObject: BpmnProcessObject): BpmnBusinessRuleTask { - return processObject.process.body!!.businessRuleTask!!.shouldHaveSingleItem() + private fun readBusinessRuleTask(processObject: BpmnFileObject): BpmnBusinessRuleTask { + return processObject.processes[0].body!!.businessRuleTask!!.shouldHaveSingleItem() } -} \ No newline at end of file +} diff --git a/flowable-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/flowable/parser/customservicetasks/FlowableCamelTaskTest.kt b/flowable-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/flowable/parser/customservicetasks/FlowableCamelTaskTest.kt index 167272e8b..e33b1ce20 100644 --- a/flowable-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/flowable/parser/customservicetasks/FlowableCamelTaskTest.kt +++ b/flowable-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/flowable/parser/customservicetasks/FlowableCamelTaskTest.kt @@ -1,6 +1,6 @@ package com.valb3r.bpmn.intellij.plugin.flowable.parser.customservicetasks -import com.valb3r.bpmn.intellij.plugin.bpmn.api.BpmnProcessObject +import com.valb3r.bpmn.intellij.plugin.bpmn.api.BpmnFileObject import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.BpmnElementId import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.elements.tasks.BpmnCamelTask import com.valb3r.bpmn.intellij.plugin.bpmn.api.info.PropertyType @@ -36,7 +36,7 @@ internal class FlowableCamelTaskTest { task.isForCompensation!!.shouldBeTrue() task.camelContext.shouldBeEqualTo("CAMEL_CTX") - val props = BpmnProcessObject(processObject.process, processObject.diagram).toView(FlowableObjectFactory()).elemPropertiesByElementId[task.id]!! + val props = BpmnFileObject(processObject.processes, processObject.diagram).toView(FlowableObjectFactory()).processes[0].processElemPropertiesByElementId[task.id]!! props[PropertyType.ID]!!.value.shouldBeEqualTo(task.id.id) props[PropertyType.NAME]!!.value.shouldBeEqualTo(task.name) props[PropertyType.DOCUMENTATION]!!.value.shouldBeEqualTo(task.documentation) @@ -93,7 +93,7 @@ internal class FlowableCamelTaskTest { return readCamelTask(readAndUpdateProcess(parser, FILE, BooleanValueUpdatedEvent(elementId, property, newValue))) } - private fun readCamelTask(processObject: BpmnProcessObject): BpmnCamelTask { - return processObject.process.body!!.camelTask!!.shouldHaveSingleItem() + private fun readCamelTask(processObject: BpmnFileObject): BpmnCamelTask { + return processObject.processes[0].body!!.camelTask!!.shouldHaveSingleItem() } -} \ No newline at end of file +} diff --git a/flowable-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/flowable/parser/customservicetasks/FlowableDecisionTaskTest.kt b/flowable-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/flowable/parser/customservicetasks/FlowableDecisionTaskTest.kt index b97aadaeb..f3f581cf3 100644 --- a/flowable-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/flowable/parser/customservicetasks/FlowableDecisionTaskTest.kt +++ b/flowable-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/flowable/parser/customservicetasks/FlowableDecisionTaskTest.kt @@ -1,6 +1,6 @@ package com.valb3r.bpmn.intellij.plugin.flowable.parser.customservicetasks -import com.valb3r.bpmn.intellij.plugin.bpmn.api.BpmnProcessObject +import com.valb3r.bpmn.intellij.plugin.bpmn.api.BpmnFileObject import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.BpmnElementId import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.elements.tasks.BpmnDecisionTask import com.valb3r.bpmn.intellij.plugin.bpmn.api.info.PropertyType @@ -38,7 +38,7 @@ internal class FlowableDecisionTaskTest { task.decisionTaskThrowErrorOnNoHits.shouldBeEqualTo(true) task.fallbackToDefaultTenantCdata.shouldBeEqualTo(true) - val props = BpmnProcessObject(processObject.process, processObject.diagram).toView(FlowableObjectFactory()).elemPropertiesByElementId[task.id]!! + val props = BpmnFileObject(processObject.processes, processObject.diagram).toView(FlowableObjectFactory()).processes[0].processElemPropertiesByElementId[task.id]!! props[PropertyType.ID]!!.value.shouldBeEqualTo(task.id.id) props[PropertyType.NAME]!!.value.shouldBeEqualTo(task.name) props[PropertyType.DOCUMENTATION]!!.value.shouldBeEqualTo(task.documentation) @@ -80,7 +80,7 @@ internal class FlowableDecisionTaskTest { return readDecisionTask(readAndUpdateProcess(parser, FILE, BooleanValueUpdatedEvent(elementId, property, newValue))) } - private fun readDecisionTask(processObject: BpmnProcessObject): BpmnDecisionTask { - return processObject.process.body!!.decisionTask!!.shouldHaveSingleItem() + private fun readDecisionTask(processObject: BpmnFileObject): BpmnDecisionTask { + return processObject.processes[0].body!!.decisionTask!!.shouldHaveSingleItem() } -} \ No newline at end of file +} diff --git a/flowable-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/flowable/parser/customservicetasks/FlowableExternalTaskTest.kt b/flowable-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/flowable/parser/customservicetasks/FlowableExternalTaskTest.kt index 2f211c452..6f80cf9d8 100644 --- a/flowable-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/flowable/parser/customservicetasks/FlowableExternalTaskTest.kt +++ b/flowable-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/flowable/parser/customservicetasks/FlowableExternalTaskTest.kt @@ -1,9 +1,8 @@ package com.valb3r.bpmn.intellij.plugin.flowable.parser.customservicetasks -import com.valb3r.bpmn.intellij.plugin.bpmn.api.BpmnProcessObject +import com.valb3r.bpmn.intellij.plugin.bpmn.api.BpmnFileObject import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.BpmnElementId import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.elements.tasks.BpmnExternalTask -import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.elements.tasks.BpmnHttpTask import com.valb3r.bpmn.intellij.plugin.bpmn.api.info.PropertyType import com.valb3r.bpmn.intellij.plugin.flowable.parser.FlowableObjectFactory import com.valb3r.bpmn.intellij.plugin.flowable.parser.FlowableParser @@ -36,7 +35,7 @@ class FlowableExternalTaskTest { // TODO 'exclusive' ? task.isForCompensation!!.shouldBeTrue() - val props = BpmnProcessObject(processObject.process, processObject.diagram).toView(FlowableObjectFactory()).elemPropertiesByElementId[task.id]!! + val props = BpmnFileObject(processObject.processes, processObject.diagram).toView(FlowableObjectFactory()).processes[0].processElemPropertiesByElementId[task.id]!! props[PropertyType.ID]!!.value.shouldBeEqualTo(task.id.id) props[PropertyType.NAME]!!.value.shouldBeEqualTo(task.name) props[PropertyType.DOCUMENTATION]!!.value.shouldBeEqualTo(task.documentation) @@ -74,7 +73,7 @@ class FlowableExternalTaskTest { return readExternalTask(readAndUpdateProcess(parser, FILE, BooleanValueUpdatedEvent(elementId, property, newValue))) } - private fun readExternalTask(processObject: BpmnProcessObject): BpmnExternalTask { - return processObject.process.body!!.externalTask!!.shouldHaveSingleItem() + private fun readExternalTask(processObject: BpmnFileObject): BpmnExternalTask { + return processObject.processes[0].body!!.externalTask!!.shouldHaveSingleItem() } } diff --git a/flowable-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/flowable/parser/customservicetasks/FlowableHttpTaskTest.kt b/flowable-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/flowable/parser/customservicetasks/FlowableHttpTaskTest.kt index 15779e303..f835cdddb 100644 --- a/flowable-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/flowable/parser/customservicetasks/FlowableHttpTaskTest.kt +++ b/flowable-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/flowable/parser/customservicetasks/FlowableHttpTaskTest.kt @@ -1,6 +1,6 @@ package com.valb3r.bpmn.intellij.plugin.flowable.parser.customservicetasks -import com.valb3r.bpmn.intellij.plugin.bpmn.api.BpmnProcessObject +import com.valb3r.bpmn.intellij.plugin.bpmn.api.BpmnFileObject import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.BpmnElementId import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.elements.tasks.BpmnHttpTask import com.valb3r.bpmn.intellij.plugin.bpmn.api.info.PropertyType @@ -56,7 +56,7 @@ internal class FlowableHttpTaskTest { task.saveResponseParametersTransient.shouldBeEqualTo("TRANSIENT_RESPONSE") task.saveResponseVariableAsJson.shouldBeEqualTo("AS_JSON") - val props = BpmnProcessObject(processObject.process, processObject.diagram).toView(FlowableObjectFactory()).elemPropertiesByElementId[task.id]!! + val props = BpmnFileObject(processObject.processes, processObject.diagram).toView(FlowableObjectFactory()).processes[0].processElemPropertiesByElementId[task.id]!! props[PropertyType.ID]!!.value.shouldBeEqualTo(task.id.id) props[PropertyType.NAME]!!.value.shouldBeEqualTo(task.name) props[PropertyType.DOCUMENTATION]!!.value.shouldBeEqualTo(task.documentation) @@ -140,7 +140,7 @@ internal class FlowableHttpTaskTest { return readHttpTask(readAndUpdateProcess(parser, FILE, BooleanValueUpdatedEvent(elementId, property, newValue))) } - private fun readHttpTask(processObject: BpmnProcessObject): BpmnHttpTask { - return processObject.process.body!!.httpTask!!.shouldHaveSingleItem() + private fun readHttpTask(processObject: BpmnFileObject): BpmnHttpTask { + return processObject.processes[0].body!!.httpTask!!.shouldHaveSingleItem() } -} \ No newline at end of file +} diff --git a/flowable-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/flowable/parser/customservicetasks/FlowableMailTaskTest.kt b/flowable-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/flowable/parser/customservicetasks/FlowableMailTaskTest.kt index 33c0dd09b..d5802491f 100644 --- a/flowable-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/flowable/parser/customservicetasks/FlowableMailTaskTest.kt +++ b/flowable-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/flowable/parser/customservicetasks/FlowableMailTaskTest.kt @@ -1,6 +1,6 @@ package com.valb3r.bpmn.intellij.plugin.flowable.parser.customservicetasks -import com.valb3r.bpmn.intellij.plugin.bpmn.api.BpmnProcessObject +import com.valb3r.bpmn.intellij.plugin.bpmn.api.BpmnFileObject import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.BpmnElementId import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.elements.tasks.BpmnMailTask import com.valb3r.bpmn.intellij.plugin.bpmn.api.info.PropertyType @@ -44,7 +44,7 @@ internal class FlowableMailTaskTest { task.html.shouldBeEqualTo("Hello") task.charset.shouldBeEqualTo("UTF-8") - val props = BpmnProcessObject(processObject.process, processObject.diagram).toView(FlowableObjectFactory()).elemPropertiesByElementId[task.id]!! + val props = BpmnFileObject(processObject.processes, processObject.diagram).toView(FlowableObjectFactory()).processes[0].processElemPropertiesByElementId[task.id]!! props[PropertyType.ID]!!.value.shouldBeEqualTo(task.id.id) props[PropertyType.NAME]!!.value.shouldBeEqualTo(task.name) props[PropertyType.DOCUMENTATION]!!.value.shouldBeEqualTo(task.documentation) @@ -106,7 +106,7 @@ internal class FlowableMailTaskTest { return readMailTask(readAndUpdateProcess(parser, FILE, BooleanValueUpdatedEvent(elementId, property, newValue))) } - private fun readMailTask(processObject: BpmnProcessObject): BpmnMailTask { - return processObject.process.body!!.mailTask!!.shouldHaveSingleItem() + private fun readMailTask(processObject: BpmnFileObject): BpmnMailTask { + return processObject.processes[0].body!!.mailTask!!.shouldHaveSingleItem() } -} \ No newline at end of file +} diff --git a/flowable-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/flowable/parser/customservicetasks/FlowableManualTaskTest.kt b/flowable-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/flowable/parser/customservicetasks/FlowableManualTaskTest.kt index c840738c3..f0517fb92 100644 --- a/flowable-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/flowable/parser/customservicetasks/FlowableManualTaskTest.kt +++ b/flowable-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/flowable/parser/customservicetasks/FlowableManualTaskTest.kt @@ -1,6 +1,6 @@ package com.valb3r.bpmn.intellij.plugin.flowable.parser.customservicetasks -import com.valb3r.bpmn.intellij.plugin.bpmn.api.BpmnProcessObject +import com.valb3r.bpmn.intellij.plugin.bpmn.api.BpmnFileObject import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.BpmnElementId import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.elements.tasks.BpmnManualTask import com.valb3r.bpmn.intellij.plugin.bpmn.api.info.PropertyType @@ -35,7 +35,7 @@ internal class FlowableManualTaskTest { // TODO 'exclusive' ? task.isForCompensation!!.shouldBeTrue() - val props = BpmnProcessObject(processObject.process, processObject.diagram).toView(FlowableObjectFactory()).elemPropertiesByElementId[task.id]!! + val props = BpmnFileObject(processObject.processes, processObject.diagram).toView(FlowableObjectFactory()).processes[0].processElemPropertiesByElementId[task.id]!! props[PropertyType.ID]!!.value.shouldBeEqualTo(task.id.id) props[PropertyType.NAME]!!.value.shouldBeEqualTo(task.name) props[PropertyType.DOCUMENTATION]!!.value.shouldBeEqualTo(task.documentation) @@ -70,7 +70,7 @@ internal class FlowableManualTaskTest { return readManualTask(readAndUpdateProcess(parser, FILE, BooleanValueUpdatedEvent(elementId, property, newValue))) } - private fun readManualTask(processObject: BpmnProcessObject): BpmnManualTask { - return processObject.process.body!!.manualTask!!.shouldHaveSingleItem() + private fun readManualTask(processObject: BpmnFileObject): BpmnManualTask { + return processObject.processes[0].body!!.manualTask!!.shouldHaveSingleItem() } -} \ No newline at end of file +} diff --git a/flowable-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/flowable/parser/customservicetasks/FlowableMuleTaskTest.kt b/flowable-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/flowable/parser/customservicetasks/FlowableMuleTaskTest.kt index 2b866836b..9f5542a0e 100644 --- a/flowable-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/flowable/parser/customservicetasks/FlowableMuleTaskTest.kt +++ b/flowable-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/flowable/parser/customservicetasks/FlowableMuleTaskTest.kt @@ -1,6 +1,6 @@ package com.valb3r.bpmn.intellij.plugin.flowable.parser.customservicetasks -import com.valb3r.bpmn.intellij.plugin.bpmn.api.BpmnProcessObject +import com.valb3r.bpmn.intellij.plugin.bpmn.api.BpmnFileObject import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.BpmnElementId import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.elements.tasks.BpmnMuleTask import com.valb3r.bpmn.intellij.plugin.bpmn.api.info.PropertyType @@ -39,7 +39,7 @@ internal class FlowableMuleTaskTest { task.payloadExpression.shouldBeEqualTo("\${foo.bar}") task.resultVariableCdata.shouldBeEqualTo("RESULT") - val props = BpmnProcessObject(processObject.process, processObject.diagram).toView(FlowableObjectFactory()).elemPropertiesByElementId[task.id]!! + val props = BpmnFileObject(processObject.processes, processObject.diagram).toView(FlowableObjectFactory()).processes[0].processElemPropertiesByElementId[task.id]!! props[PropertyType.ID]!!.value.shouldBeEqualTo(task.id.id) props[PropertyType.NAME]!!.value.shouldBeEqualTo(task.name) props[PropertyType.DOCUMENTATION]!!.value.shouldBeEqualTo(task.documentation) @@ -86,7 +86,7 @@ internal class FlowableMuleTaskTest { return readMuleTask(readAndUpdateProcess(parser, FILE, BooleanValueUpdatedEvent(elementId, property, newValue))) } - private fun readMuleTask(processObject: BpmnProcessObject): BpmnMuleTask { - return processObject.process.body!!.muleTask!!.shouldHaveSingleItem() + private fun readMuleTask(processObject: BpmnFileObject): BpmnMuleTask { + return processObject.processes[0].body!!.muleTask!!.shouldHaveSingleItem() } -} \ No newline at end of file +} diff --git a/flowable-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/flowable/parser/customservicetasks/FlowableReceiveTaskTest.kt b/flowable-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/flowable/parser/customservicetasks/FlowableReceiveTaskTest.kt index 6578644e4..8ca9e3744 100644 --- a/flowable-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/flowable/parser/customservicetasks/FlowableReceiveTaskTest.kt +++ b/flowable-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/flowable/parser/customservicetasks/FlowableReceiveTaskTest.kt @@ -1,6 +1,6 @@ package com.valb3r.bpmn.intellij.plugin.flowable.parser.customservicetasks -import com.valb3r.bpmn.intellij.plugin.bpmn.api.BpmnProcessObject +import com.valb3r.bpmn.intellij.plugin.bpmn.api.BpmnFileObject import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.BpmnElementId import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.elements.tasks.BpmnReceiveTask import com.valb3r.bpmn.intellij.plugin.bpmn.api.info.PropertyType @@ -35,7 +35,7 @@ internal class FlowableReceiveTaskTest { // TODO 'exclusive' ? task.isForCompensation!!.shouldBeTrue() - val props = BpmnProcessObject(processObject.process, processObject.diagram).toView(FlowableObjectFactory()).elemPropertiesByElementId[task.id]!! + val props = BpmnFileObject(processObject.processes, processObject.diagram).toView(FlowableObjectFactory()).processes[0].processElemPropertiesByElementId[task.id]!! props[PropertyType.ID]!!.value.shouldBeEqualTo(task.id.id) props[PropertyType.NAME]!!.value.shouldBeEqualTo(task.name) props[PropertyType.DOCUMENTATION]!!.value.shouldBeEqualTo(task.documentation) @@ -70,7 +70,7 @@ internal class FlowableReceiveTaskTest { return readReceiveTask(readAndUpdateProcess(parser, FILE, BooleanValueUpdatedEvent(elementId, property, newValue))) } - private fun readReceiveTask(processObject: BpmnProcessObject): BpmnReceiveTask { - return processObject.process.body!!.receiveTask!!.shouldHaveSingleItem() + private fun readReceiveTask(processObject: BpmnFileObject): BpmnReceiveTask { + return processObject.processes[0].body!!.receiveTask!!.shouldHaveSingleItem() } -} \ No newline at end of file +} diff --git a/flowable-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/flowable/parser/customservicetasks/FlowableScriptTaskTest.kt b/flowable-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/flowable/parser/customservicetasks/FlowableScriptTaskTest.kt index 042cb3543..3db07d1a0 100644 --- a/flowable-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/flowable/parser/customservicetasks/FlowableScriptTaskTest.kt +++ b/flowable-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/flowable/parser/customservicetasks/FlowableScriptTaskTest.kt @@ -1,6 +1,6 @@ package com.valb3r.bpmn.intellij.plugin.flowable.parser.customservicetasks -import com.valb3r.bpmn.intellij.plugin.bpmn.api.BpmnProcessObject +import com.valb3r.bpmn.intellij.plugin.bpmn.api.BpmnFileObject import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.BpmnElementId import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.elements.tasks.BpmnScriptTask import com.valb3r.bpmn.intellij.plugin.bpmn.api.info.PropertyType @@ -38,7 +38,7 @@ internal class FlowableScriptTaskTest { task.autoStoreVariables.shouldBeEqualTo(true) task.scriptBody.shouldBeEqualTo("echo \"Foo Bar!\" > /tmp/foo.txt") - val props = BpmnProcessObject(processObject.process, processObject.diagram).toView(FlowableObjectFactory()).elemPropertiesByElementId[task.id]!! + val props = BpmnFileObject(processObject.processes, processObject.diagram).toView(FlowableObjectFactory()).processes[0].processElemPropertiesByElementId[task.id]!! props[PropertyType.ID]!!.value.shouldBeEqualTo(task.id.id) props[PropertyType.NAME]!!.value.shouldBeEqualTo(task.name) props[PropertyType.DOCUMENTATION]!!.value.shouldBeEqualTo(task.documentation) @@ -81,7 +81,7 @@ internal class FlowableScriptTaskTest { return readScriptTask(readAndUpdateProcess(parser, FILE, BooleanValueUpdatedEvent(elementId, property, newValue))) } - private fun readScriptTask(processObject: BpmnProcessObject): BpmnScriptTask { - return processObject.process.body!!.scriptTask!!.shouldHaveSingleItem() + private fun readScriptTask(processObject: BpmnFileObject): BpmnScriptTask { + return processObject.processes[0].body!!.scriptTask!!.shouldHaveSingleItem() } -} \ No newline at end of file +} diff --git a/flowable-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/flowable/parser/customservicetasks/FlowableServiceTaskTest.kt b/flowable-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/flowable/parser/customservicetasks/FlowableServiceTaskTest.kt index 914d16565..d01693fa1 100644 --- a/flowable-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/flowable/parser/customservicetasks/FlowableServiceTaskTest.kt +++ b/flowable-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/flowable/parser/customservicetasks/FlowableServiceTaskTest.kt @@ -1,6 +1,6 @@ package com.valb3r.bpmn.intellij.plugin.flowable.parser.customservicetasks -import com.valb3r.bpmn.intellij.plugin.bpmn.api.BpmnProcessObject +import com.valb3r.bpmn.intellij.plugin.bpmn.api.BpmnFileObject import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.BpmnElementId import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.elements.tasks.BpmnServiceTask import com.valb3r.bpmn.intellij.plugin.bpmn.api.info.PropertyType @@ -43,7 +43,7 @@ internal class FlowableServiceTaskTest { task.useLocalScopeForResultVariable!!.shouldBeTrue() // TODO handle deep extension elements - field - val props = BpmnProcessObject(processObject.process, processObject.diagram).toView(FlowableObjectFactory()).elemPropertiesByElementId[task.id]!! + val props = BpmnFileObject(processObject.processes, processObject.diagram).toView(FlowableObjectFactory()).processes[0].processElemPropertiesByElementId[task.id]!! props[PropertyType.ID]!!.value.shouldBeEqualTo(task.id.id) props[PropertyType.NAME]!!.value.shouldBeEqualTo(task.name) props[PropertyType.DOCUMENTATION]!!.value.shouldBeEqualTo(task.documentation) @@ -97,7 +97,7 @@ internal class FlowableServiceTaskTest { return readServiceTask(readAndUpdateProcess(parser, FILE, BooleanValueUpdatedEvent(elementId, property, newValue))) } - private fun readServiceTask(processObject: BpmnProcessObject): BpmnServiceTask { - return processObject.process.body!!.serviceTask!!.shouldHaveSingleItem() + private fun readServiceTask(processObject: BpmnFileObject): BpmnServiceTask { + return processObject.processes[0].body!!.serviceTask!!.shouldHaveSingleItem() } -} \ No newline at end of file +} diff --git a/flowable-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/flowable/parser/customservicetasks/FlowableServiceTaskWithExtensionElementsTest.kt b/flowable-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/flowable/parser/customservicetasks/FlowableServiceTaskWithExtensionElementsTest.kt index 40947c4b3..ef8903fdb 100644 --- a/flowable-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/flowable/parser/customservicetasks/FlowableServiceTaskWithExtensionElementsTest.kt +++ b/flowable-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/flowable/parser/customservicetasks/FlowableServiceTaskWithExtensionElementsTest.kt @@ -1,6 +1,6 @@ package com.valb3r.bpmn.intellij.plugin.flowable.parser.customservicetasks -import com.valb3r.bpmn.intellij.plugin.bpmn.api.BpmnProcessObject +import com.valb3r.bpmn.intellij.plugin.bpmn.api.BpmnFileObject import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.BpmnElementId import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.elements.tasks.BpmnServiceTask import com.valb3r.bpmn.intellij.plugin.bpmn.api.info.PropertyType @@ -23,12 +23,12 @@ internal class FlowableServiceTaskWithExtensionElementsTest { @Test fun `Service task with failedJobRetryTimeCycle is parseable`() { val processObject = parser.parse(FILE.asResource()!!) - val task = processObject.process.body!!.serviceTask!![0] + val task = processObject.processes[0].body!!.serviceTask!![0] task.id.shouldBeEqualTo(elementId) task.failedJobRetryTimeCycle.shouldBeEqualTo("R10/PT5M") - val props = BpmnProcessObject(processObject.process, processObject.diagram).toView(FlowableObjectFactory()).elemPropertiesByElementId[task.id]!! + val props = BpmnFileObject(processObject.processes, processObject.diagram).toView(FlowableObjectFactory()).processes[0].processElemPropertiesByElementId[task.id]!! props[PropertyType.FAILED_JOB_RETRY_CYCLE]!!.value.shouldBeEqualTo(task.failedJobRetryTimeCycle) } @@ -41,7 +41,7 @@ internal class FlowableServiceTaskWithExtensionElementsTest { return readServiceTask(readAndUpdateProcess(parser, FILE, StringValueUpdatedEvent(elementId, property, newValue))) } - private fun readServiceTask(processObject: BpmnProcessObject): BpmnServiceTask { - return processObject.process.body!!.serviceTask!!.shouldHaveSingleItem() + private fun readServiceTask(processObject: BpmnFileObject): BpmnServiceTask { + return processObject.processes[0].body!!.serviceTask!!.shouldHaveSingleItem() } -} \ No newline at end of file +} diff --git a/flowable-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/flowable/parser/customservicetasks/FlowableServiceTaskWithNestedExtensionTest.kt b/flowable-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/flowable/parser/customservicetasks/FlowableServiceTaskWithNestedExtensionTest.kt index 73d5604dc..c6f777aff 100644 --- a/flowable-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/flowable/parser/customservicetasks/FlowableServiceTaskWithNestedExtensionTest.kt +++ b/flowable-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/flowable/parser/customservicetasks/FlowableServiceTaskWithNestedExtensionTest.kt @@ -1,6 +1,6 @@ package com.valb3r.bpmn.intellij.plugin.flowable.parser.customservicetasks -import com.valb3r.bpmn.intellij.plugin.bpmn.api.BpmnProcessObject +import com.valb3r.bpmn.intellij.plugin.bpmn.api.BpmnFileObject import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.BpmnElementId import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.elements.tasks.BpmnServiceTask import com.valb3r.bpmn.intellij.plugin.bpmn.api.info.Property @@ -29,7 +29,7 @@ internal class FlowableServiceTaskWithNestedExtensionTest { task.documentation.shouldBeNull() task.failedJobRetryTimeCycle?.shouldBeEqualTo("R10/PT5M") - val props = BpmnProcessObject(processObject.process, processObject.diagram).toView(FlowableObjectFactory()).elemPropertiesByElementId[task.id]!! + val props = BpmnFileObject(processObject.processes, processObject.diagram).toView(FlowableObjectFactory()).processes[0].processElemPropertiesByElementId[task.id]!! props[PropertyType.ID]!!.value.shouldBeEqualTo(task.id.id) props[PropertyType.NAME]!!.value.shouldBeEqualTo(task.name) props[PropertyType.DOCUMENTATION]!!.value.shouldBeEqualTo(task.documentation) @@ -67,8 +67,8 @@ internal class FlowableServiceTaskWithNestedExtensionTest { @Test fun `Add nested extension element`() { val process = readAndUpdateProcess(parser, FILE, StringValueUpdatedEvent(emptyElementId, PropertyType.FIELD_NAME, "new name", propertyIndex = listOf(""))) - val emptyTask = process.process.body!!.serviceTask!!.firstOrNull {it.id == emptyElementId}.shouldNotBeNull() - val props = BpmnProcessObject(process.process, process.diagram).toView(FlowableObjectFactory()).elemPropertiesByElementId[emptyTask.id]!! + val emptyTask = process.processes[0].body!!.serviceTask!!.firstOrNull {it.id == emptyElementId}.shouldNotBeNull() + val props = BpmnFileObject(process.processes, process.diagram).toView(FlowableObjectFactory()).processes[0].processElemPropertiesByElementId[emptyTask.id]!! props[PropertyType.FIELD_NAME]!!.shouldBeEqualTo(Property("new name", listOf("new name"))) } @@ -82,8 +82,8 @@ internal class FlowableServiceTaskWithNestedExtensionTest { StringValueUpdatedEvent(emptyElementId, PropertyType.FIELD_NAME, "", propertyIndex = listOf("new name")) ) ) - val emptyTask = process.process.body!!.serviceTask!!.firstOrNull {it.id == emptyElementId}.shouldNotBeNull() - val props = BpmnProcessObject(process.process, process.diagram).toView(FlowableObjectFactory()).elemPropertiesByElementId[emptyTask.id]!! + val emptyTask = process.processes[0].body!!.serviceTask!!.firstOrNull {it.id == emptyElementId}.shouldNotBeNull() + val props = BpmnFileObject(process.processes, process.diagram).toView(FlowableObjectFactory()).processes[0].processElemPropertiesByElementId[emptyTask.id]!! props[PropertyType.FIELD_NAME]?.value.shouldBeNull() } @@ -98,8 +98,8 @@ internal class FlowableServiceTaskWithNestedExtensionTest { StringValueUpdatedEvent(emptyElementId, PropertyType.FIELD_NAME, "other new name", propertyIndex = listOf("")), ) ) - val emptyTask = process.process.body!!.serviceTask!!.firstOrNull {it.id == emptyElementId}.shouldNotBeNull() - val props = BpmnProcessObject(process.process, process.diagram).toView(FlowableObjectFactory()).elemPropertiesByElementId[emptyTask.id]!! + val emptyTask = process.processes[0].body!!.serviceTask!!.firstOrNull {it.id == emptyElementId}.shouldNotBeNull() + val props = BpmnFileObject(process.processes, process.diagram).toView(FlowableObjectFactory()).processes[0].processElemPropertiesByElementId[emptyTask.id]!! props[PropertyType.FIELD_NAME]!!.shouldBeEqualTo(Property("other new name", listOf("other new name"))) } @@ -113,8 +113,8 @@ internal class FlowableServiceTaskWithNestedExtensionTest { StringValueUpdatedEvent(emptyElementId, PropertyType.FIELD_NAME, "new name", propertyIndex = listOf("")), ) ) - val emptyTask = process.process.body!!.serviceTask!!.firstOrNull {it.id == emptyElementId}.shouldNotBeNull() - val props = BpmnProcessObject(process.process, process.diagram).toView(FlowableObjectFactory()).elemPropertiesByElementId[emptyTask.id]!! + val emptyTask = process.processes[0].body!!.serviceTask!!.firstOrNull {it.id == emptyElementId}.shouldNotBeNull() + val props = BpmnFileObject(process.processes, process.diagram).toView(FlowableObjectFactory()).processes[0].processElemPropertiesByElementId[emptyTask.id]!! props[PropertyType.FIELD_NAME]!!.shouldBeEqualTo(Property("new name", listOf("new name"))) props[PropertyType.FIELD_EXPRESSION]!!.shouldBeEqualTo(Property("expression 1", listOf("new name"))) } @@ -130,7 +130,7 @@ internal class FlowableServiceTaskWithNestedExtensionTest { return readServiceTaskWithExtensions(readAndUpdateProcess(parser, FILE, StringValueUpdatedEvent(elementId, property, newValue, propertyIndex = propertyIndex.split(",")))) } - private fun readServiceTaskWithExtensions(processObject: BpmnProcessObject): BpmnServiceTask { - return processObject.process.body!!.serviceTask!!.shouldHaveSize(2)[0] + private fun readServiceTaskWithExtensions(processObject: BpmnFileObject): BpmnServiceTask { + return processObject.processes[0].body!!.serviceTask!!.shouldHaveSize(2)[0] } } diff --git a/flowable-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/flowable/parser/customservicetasks/FlowableShellTaskTest.kt b/flowable-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/flowable/parser/customservicetasks/FlowableShellTaskTest.kt index 6a55191a7..6f0bd5c46 100644 --- a/flowable-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/flowable/parser/customservicetasks/FlowableShellTaskTest.kt +++ b/flowable-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/flowable/parser/customservicetasks/FlowableShellTaskTest.kt @@ -1,6 +1,6 @@ package com.valb3r.bpmn.intellij.plugin.flowable.parser.customservicetasks -import com.valb3r.bpmn.intellij.plugin.bpmn.api.BpmnProcessObject +import com.valb3r.bpmn.intellij.plugin.bpmn.api.BpmnFileObject import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.BpmnElementId import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.elements.tasks.BpmnShellTask import com.valb3r.bpmn.intellij.plugin.bpmn.api.info.PropertyType @@ -46,7 +46,7 @@ internal class FlowableShellTaskTest { task.outputVariable.shouldBeEqualTo("OUTPUT_VAR") task.directory.shouldBeEqualTo("/tmp") - val props = BpmnProcessObject(processObject.process, processObject.diagram).toView(FlowableObjectFactory()).elemPropertiesByElementId[task.id]!! + val props = BpmnFileObject(processObject.processes, processObject.diagram).toView(FlowableObjectFactory()).processes[0].processElemPropertiesByElementId[task.id]!! props[PropertyType.ID]!!.value.shouldBeEqualTo(task.id.id) props[PropertyType.NAME]!!.value.shouldBeEqualTo(task.name) props[PropertyType.DOCUMENTATION]!!.value.shouldBeEqualTo(task.documentation) @@ -114,7 +114,7 @@ internal class FlowableShellTaskTest { return readShellTask(readAndUpdateProcess(parser, FILE, BooleanValueUpdatedEvent(elementId, property, newValue))) } - private fun readShellTask(processObject: BpmnProcessObject): BpmnShellTask { - return processObject.process.body!!.shellTask!!.shouldHaveSingleItem() + private fun readShellTask(processObject: BpmnFileObject): BpmnShellTask { + return processObject.processes[0].body!!.shellTask!!.shouldHaveSingleItem() } -} \ No newline at end of file +} diff --git a/flowable-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/flowable/parser/customservicetasks/FlowableUserTaskTest.kt b/flowable-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/flowable/parser/customservicetasks/FlowableUserTaskTest.kt index bdfaaf69a..726d57ddd 100644 --- a/flowable-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/flowable/parser/customservicetasks/FlowableUserTaskTest.kt +++ b/flowable-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/flowable/parser/customservicetasks/FlowableUserTaskTest.kt @@ -1,6 +1,6 @@ package com.valb3r.bpmn.intellij.plugin.flowable.parser.customservicetasks -import com.valb3r.bpmn.intellij.plugin.bpmn.api.BpmnProcessObject +import com.valb3r.bpmn.intellij.plugin.bpmn.api.BpmnFileObject import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.BpmnElementId import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.elements.tasks.BpmnUserTask import com.valb3r.bpmn.intellij.plugin.bpmn.api.info.PropertyType @@ -44,7 +44,7 @@ internal class FlowableUserTaskTest { task.priority.shouldBeEqualTo("1") task.skipExpression.shouldBeEqualTo("#{do.skip}") - val props = BpmnProcessObject(processObject.process, processObject.diagram).toView(FlowableObjectFactory()).elemPropertiesByElementId[task.id]!! + val props = BpmnFileObject(processObject.processes, processObject.diagram).toView(FlowableObjectFactory()).processes[0].processElemPropertiesByElementId[task.id]!! props[PropertyType.ID]!!.value.shouldBeEqualTo(task.id.id) props[PropertyType.NAME]!!.value.shouldBeEqualTo(task.name) props[PropertyType.DOCUMENTATION]!!.value.shouldBeEqualTo(task.documentation) @@ -105,7 +105,7 @@ internal class FlowableUserTaskTest { return readUserTask(readAndUpdateProcess(parser, FILE, BooleanValueUpdatedEvent(elementId, property, newValue))) } - private fun readUserTask(processObject: BpmnProcessObject): BpmnUserTask { - return processObject.process.body!!.userTask!!.shouldHaveSingleItem() + private fun readUserTask(processObject: BpmnFileObject): BpmnUserTask { + return processObject.processes[0].body!!.userTask!!.shouldHaveSingleItem() } -} \ No newline at end of file +} diff --git a/flowable-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/flowable/parser/customservicetasks/FlowableUserTaskWithNestedExtensionTest.kt b/flowable-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/flowable/parser/customservicetasks/FlowableUserTaskWithNestedExtensionTest.kt index cb9394800..1078e5524 100644 --- a/flowable-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/flowable/parser/customservicetasks/FlowableUserTaskWithNestedExtensionTest.kt +++ b/flowable-xml-parser/src/test/kotlin/com/valb3r/bpmn/intellij/plugin/flowable/parser/customservicetasks/FlowableUserTaskWithNestedExtensionTest.kt @@ -1,6 +1,6 @@ package com.valb3r.bpmn.intellij.plugin.flowable.parser.customservicetasks -import com.valb3r.bpmn.intellij.plugin.bpmn.api.BpmnProcessObject +import com.valb3r.bpmn.intellij.plugin.bpmn.api.BpmnFileObject import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.BpmnElementId import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.elements.tasks.BpmnUserTask import com.valb3r.bpmn.intellij.plugin.bpmn.api.info.Property @@ -32,7 +32,7 @@ internal class FlowableUserTaskWithNestedExtensionTest { task.name.shouldBeEqualTo("A user task") task.documentation.shouldBeEqualTo("A user task to do") - val props = BpmnProcessObject(processObject.process, processObject.diagram).toView(FlowableObjectFactory()).elemPropertiesByElementId[task.id]!! + val props = BpmnFileObject(processObject.processes, processObject.diagram).toView(FlowableObjectFactory()).processes[0].processElemPropertiesByElementId[task.id]!! props[PropertyType.ID]!!.value.shouldBeEqualTo(task.id.id) props[PropertyType.NAME]!!.value.shouldBeEqualTo(task.name) props[PropertyType.DOCUMENTATION]!!.value.shouldBeEqualTo(task.documentation) @@ -98,7 +98,7 @@ internal class FlowableUserTaskWithNestedExtensionTest { val task = readEmptyUserTaskWithExtensions(processObject) task.id.shouldBeEqualTo(BpmnElementId("emptyUserTaskId")) - val props = BpmnProcessObject(processObject.process, processObject.diagram).toView(FlowableObjectFactory()).elemPropertiesByElementId[task.id]!! + val props = BpmnFileObject(processObject.processes, processObject.diagram).toView(FlowableObjectFactory()).processes[0].processElemPropertiesByElementId[task.id]!! props.getAll(PropertyType.FORM_PROPERTY_ID).shouldHaveSize(1) } @@ -106,11 +106,11 @@ internal class FlowableUserTaskWithNestedExtensionTest { return readUserTaskWithExtensions(readAndUpdateProcess(parser, FILE, StringValueUpdatedEvent(elementId, property, newValue, propertyIndex = propertyIndex.split(",")))) } - private fun readUserTaskWithExtensions(processObject: BpmnProcessObject): BpmnUserTask { - return processObject.process.body!!.userTask!!.shouldHaveSize(3)[0] + private fun readUserTaskWithExtensions(processObject: BpmnFileObject): BpmnUserTask { + return processObject.processes[0].body!!.userTask!!.shouldHaveSize(3)[0] } - private fun readEmptyUserTaskWithExtensions(processObject: BpmnProcessObject): BpmnUserTask { - return processObject.process.body!!.userTask!!.shouldHaveSize(3)[2] + private fun readEmptyUserTaskWithExtensions(processObject: BpmnFileObject): BpmnUserTask { + return processObject.processes[0].body!!.userTask!!.shouldHaveSize(3)[2] } } diff --git a/flowable-xml-parser/src/test/resources/swimlanes.bpmn20.xml b/flowable-xml-parser/src/test/resources/swimlanes.bpmn20.xml new file mode 100644 index 000000000..416b213d6 --- /dev/null +++ b/flowable-xml-parser/src/test/resources/swimlanes.bpmn20.xml @@ -0,0 +1,164 @@ + + + + + + + + + + + sid-EA3DB0F5-2D74-4B20-A4FE-5B5F80CC7906 + sid-44502611-0CAD-4020-9FF7-4E807DF23B91 + sid-9035BBFD-279C-40C3-A677-B95FEEA51FC8 + sid-1E9FF4A4-7101-474F-989C-1B1AFDDB49CC + + + + + + + + + + + sid-7079C677-5228-47E6-A6FB-CD612D977DE4 + sid-D62875C4-5D78-4A09-BDA8-375C7379460A + sid-0D8FDC6C-4718-4790-B91E-2C79478BB8AC + sid-59D0BC66-482C-4DC6-95D8-4A5B568F6DBE + sid-9DF8CA19-AC71-40D5-855A-929F6434184A + sid-8DE5712B-13BC-45A1-907E-CAC736EF51D6 + + + + + + + + + + + + + sid-B568CF5B-C8F5-472C-8E46-FF7D32675CEE + sid-E06ADE70-0BA1-45FB-AE4A-EE1C14E816C8 + sid-470B217F-723D-4099-8F3F-47E5BD8D7553 + sid-C8FCAD61-0A63-4A28-8C16-633EC5058EE6 + sid-E707356E-1F46-4C15-ACD4-F8B727B0FD6D + sid-5EFA0E75-9CE6-4CF1-9FD8-13F13385FADE + sid-D73CA041-029A-4A70-96B1-3DAD593E377E + sid-2471135F-B873-458B-85A2-D58D7DA1A0B8 + + + sid-61C9C6F3-E51E-4C1B-B33C-9AA190A211B6 + sid-D2F4E732-BCAE-415C-8383-0B97E076A328 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/gradle.properties b/gradle.properties index 7f3680244..6a9d21fb2 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1 +1,2 @@ +org.gradle.jvmargs=--illegal-access=permit intellijPublishToken= diff --git a/xml-parser-api/src/main/kotlin/com/valb3r/bpmn/intellij/plugin/bpmn/api/BpmnProcessObject.kt b/xml-parser-api/src/main/kotlin/com/valb3r/bpmn/intellij/plugin/bpmn/api/BpmnFileObject.kt similarity index 67% rename from xml-parser-api/src/main/kotlin/com/valb3r/bpmn/intellij/plugin/bpmn/api/BpmnProcessObject.kt rename to xml-parser-api/src/main/kotlin/com/valb3r/bpmn/intellij/plugin/bpmn/api/BpmnFileObject.kt index f391ddd95..6af5957c8 100644 --- a/xml-parser-api/src/main/kotlin/com/valb3r/bpmn/intellij/plugin/bpmn/api/BpmnProcessObject.kt +++ b/xml-parser-api/src/main/kotlin/com/valb3r/bpmn/intellij/plugin/bpmn/api/BpmnFileObject.kt @@ -1,47 +1,104 @@ package com.valb3r.bpmn.intellij.plugin.bpmn.api +import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.BpmnCollaboration import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.BpmnElementId import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.BpmnProcess import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.BpmnProcessBody import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.elements.WithBpmnId import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.elements.WithParentId +import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.elements.lanes.BpmnLane +import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.elements.lanes.BpmnLaneSet import com.valb3r.bpmn.intellij.plugin.bpmn.api.diagram.DiagramElement import com.valb3r.bpmn.intellij.plugin.bpmn.api.diagram.DiagramElementId import com.valb3r.bpmn.intellij.plugin.bpmn.api.info.Property import com.valb3r.bpmn.intellij.plugin.bpmn.api.info.PropertyType // TODO - move to some implementation module -data class BpmnProcessObject(val process: BpmnProcess, val diagram: List) { +data class BpmnFileObject(val processes: List, val collaborations: List, val diagram: List) { - fun toView(factory: BpmnObjectFactory) : BpmnProcessObjectView { - val elementByDiagramId = mutableMapOf() - val elementByStaticId = mutableMapOf() - val propertiesById = mutableMapOf() + constructor(processes: List, diagram: List) : this(processes, listOf(), diagram) - fillFor(BpmnElementId(""), factory, process, elementByStaticId, propertiesById) - elementByDiagramId[DiagramElementId(process.id.id)] = process.id + fun toView(factory: BpmnObjectFactory) : BpmnFileView { + val mappedCollaborations = mapCollaborations(factory) + val rootProcessOrCollaborationId = mappedCollaborations.firstOrNull()?.collaborationId ?: this.processes[0].id + val collaborationProcessRoots = collaborations.flatMap { it.participant ?: emptyList() } + .filter { null != it.processRef } + .groupBy { it.processRef!! } + .mapValues { entry -> entry.value.first().id } + val mappedProcesses = mapProcesses(factory, rootProcessOrCollaborationId, collaborationProcessRoots) - // 1st pass - process.body?.let { extractElementsFromBody(process.id, it, factory, elementByStaticId, propertiesById) } - process.children?.forEach { (id, body) -> extractElementsFromBody(id, body, factory, elementByStaticId, propertiesById)} - // 2nd pass - process.body?.let { reassignParentsBasedOnTargetRef(process.id, it, factory, elementByStaticId, propertiesById) } - process.children?.forEach { (id, body) -> reassignParentsBasedOnTargetRef(id, body, factory, elementByStaticId, propertiesById)} + return BpmnFileView(rootProcessOrCollaborationId, mappedProcesses, mappedCollaborations) + } + + private fun mapCollaborations(factory: BpmnObjectFactory): List { + val mappedCollaborations = mutableListOf() + for (collaboration in collaborations) { + val elementByStaticId = mutableMapOf() + val propertiesById = mutableMapOf() + + fillFor(BpmnElementId(""), factory, collaboration, elementByStaticId, propertiesById) + + collaboration.participant?.forEach { fillFor(collaboration.id, factory, it, elementByStaticId, propertiesById)} + collaboration.messageFlow?.forEach { fillFor(collaboration.id, factory, it, elementByStaticId, propertiesById)} + + mappedCollaborations += BpmnCollaborationView( + collaboration.id, + elementByStaticId, + propertiesById + ) + } - diagram.flatMap { it.bpmnPlane.bpmnEdge ?: emptyList()} + return mappedCollaborations + } + + private fun mapProcesses(factory: BpmnObjectFactory, rootId: BpmnElementId, collaborationByProcess: Map): List { + val mappedProcesses = mutableListOf() + val allElementsByDiagramId = mutableMapOf() + for (process in processes) { + val elementByStaticId = mutableMapOf() + val propertiesById = mutableMapOf() + + fillFor(collaborationByProcess.getOrDefault(process.id.id, rootId), factory, process, elementByStaticId, propertiesById) + allElementsByDiagramId[DiagramElementId(process.id.id)] = process.id + + // 1st pass + process.body?.let { extractElementsFromBody(process.id, it, factory, elementByStaticId, propertiesById) } + process.children?.forEach { (id, body) -> extractElementsFromBody(id, body, factory, elementByStaticId, propertiesById) } + process.laneSets?.forEach { extractElementsFromLanes(process.id, it, factory, elementByStaticId, propertiesById) } + // 2nd pass + process.body?.let { reassignParentsBasedOnTargetRef(process.id, it, factory, elementByStaticId, propertiesById) } + process.children?.forEach { (id, body) -> reassignParentsBasedOnTargetRef(id, body, factory, elementByStaticId, propertiesById) } + diagram.flatMap { it.bpmnPlane.bpmnEdge ?: emptyList() } .filter { null != it.bpmnElement } - .forEach { elementByDiagramId[it.id] = it.bpmnElement!! } + .forEach { allElementsByDiagramId[it.id] = it.bpmnElement!! } + + diagram.flatMap { it.bpmnPlane.bpmnShape ?: emptyList() } + .forEach { allElementsByDiagramId[it.id] = it.bpmnElement } - diagram.flatMap { it.bpmnPlane.bpmnShape ?: emptyList() } - .forEach { elementByDiagramId[it.id] = it.bpmnElement } + remapElementsToLanes(elementByStaticId) - return BpmnProcessObjectView( + mappedProcesses += BpmnProcessObjectView( process.id, - elementByDiagramId, + allElementsByDiagramId, elementByStaticId, propertiesById, diagram - ) + ) + } + + return mappedProcesses + } + + private fun remapElementsToLanes(elems: MutableMap) { + val lanes = elems.values.map { it.element }.filterIsInstance() + val elementByParentLane = lanes.flatMap { lane -> lane.flowNodeRef?.map { it to lane.id } ?: emptyList() } + .groupBy { it.first.ref } + .mapValues { it.value.first().second.id } + + elems.replaceAll { k, v -> + val laneId = elementByParentLane[k.id]?.let { BpmnElementId(it) } + return@replaceAll v.copy(parent = laneId ?: v.parent) + } } private fun extractElementsFromBody( @@ -124,6 +181,15 @@ data class BpmnProcessObject(val process: BpmnProcess, val diagram: List, + propertiesById: MutableMap) { + laneSet.lanes?.forEach { fillFor(parentId, factory, it, elementByStaticId, propertiesById) } + } + private fun reassignParentsBasedOnTargetRef( parentId: BpmnElementId, body: BpmnProcessBody, @@ -148,7 +214,9 @@ data class BpmnProcessObject(val process: BpmnProcess, val diagram: List, propertiesByElemType: MutableMap) { - elementById[activity.id] = WithParentId(parentId, activity) + if (activity.id != parentId) { // Handle the case of plain processes (without collaboration) + elementById[activity.id] = WithParentId(parentId, activity) + } propertiesByElemType[activity.id] = factory.propertiesOf(activity) } @@ -170,12 +238,24 @@ data class BpmnProcessObject(val process: BpmnProcess, val diagram: List, + val collaborations: List +) + +data class BpmnCollaborationView( + val collaborationId: BpmnElementId, + val collaborationElementByStaticId: Map, + val collaborationElemPropertiesByElementId: Map +) + data class BpmnProcessObjectView( - val processId: BpmnElementId, - val elementByDiagramId: Map, - val elementByStaticId: Map, - val elemPropertiesByElementId: Map, - val diagram: List + val processId: BpmnElementId, + val allElementsByDiagramId: Map, + val processElementByStaticId: Map, + val processElemPropertiesByElementId: Map, + val diagram: List ) data class PropertyTable(private val properties: MutableMap>) { diff --git a/xml-parser-api/src/main/kotlin/com/valb3r/bpmn/intellij/plugin/bpmn/api/BpmnObjectFactory.kt b/xml-parser-api/src/main/kotlin/com/valb3r/bpmn/intellij/plugin/bpmn/api/BpmnObjectFactory.kt index ede9f87bd..910b11d7d 100644 --- a/xml-parser-api/src/main/kotlin/com/valb3r/bpmn/intellij/plugin/bpmn/api/BpmnObjectFactory.kt +++ b/xml-parser-api/src/main/kotlin/com/valb3r/bpmn/intellij/plugin/bpmn/api/BpmnObjectFactory.kt @@ -2,6 +2,7 @@ package com.valb3r.bpmn.intellij.plugin.bpmn.api import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.elements.BpmnSequenceFlow import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.elements.WithBpmnId +import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.elements.lanes.BpmnFlowNodeRef import com.valb3r.bpmn.intellij.plugin.bpmn.api.diagram.elements.WithDiagramId import com.valb3r.bpmn.intellij.plugin.bpmn.api.info.Property import com.valb3r.bpmn.intellij.plugin.bpmn.api.info.PropertyType @@ -10,8 +11,9 @@ import kotlin.reflect.KClass interface BpmnObjectFactory { fun newBpmnObject(clazz: KClass): T + fun newFlowRef(): BpmnFlowNodeRef fun newOutgoingSequence(sourceRef: T): BpmnSequenceFlow - fun propertiesOf(obj: T): PropertyTable + fun propertiesOf(obj: T): PropertyTable fun newDiagramObject(clazz: KClass, forBpmnObject: WithBpmnId): T fun propertyTypes(): List } \ No newline at end of file diff --git a/xml-parser-api/src/main/kotlin/com/valb3r/bpmn/intellij/plugin/bpmn/api/BpmnParser.kt b/xml-parser-api/src/main/kotlin/com/valb3r/bpmn/intellij/plugin/bpmn/api/BpmnParser.kt index c73e606b9..2f0e99632 100644 --- a/xml-parser-api/src/main/kotlin/com/valb3r/bpmn/intellij/plugin/bpmn/api/BpmnParser.kt +++ b/xml-parser-api/src/main/kotlin/com/valb3r/bpmn/intellij/plugin/bpmn/api/BpmnParser.kt @@ -4,11 +4,11 @@ import com.valb3r.bpmn.intellij.plugin.bpmn.api.events.EventPropagatableToXml interface BpmnParser { - fun parse(input: String): BpmnProcessObject + fun parse(input: String): BpmnFileObject fun validateForErrors(input: String): String? fun validateForWarnings(input: String): String? // Keeping update model simple by following: // https://www.jetbrains.org/intellij/sdk/docs/tutorials/editor_basics/working_with_text.html#safely-replacing-selected-text-in-the-document fun update(input: String, events: List): String -} \ No newline at end of file +} diff --git a/xml-parser-api/src/main/kotlin/com/valb3r/bpmn/intellij/plugin/bpmn/api/bpmn/BpmnCollaboration.kt b/xml-parser-api/src/main/kotlin/com/valb3r/bpmn/intellij/plugin/bpmn/api/bpmn/BpmnCollaboration.kt new file mode 100644 index 000000000..15f2c4965 --- /dev/null +++ b/xml-parser-api/src/main/kotlin/com/valb3r/bpmn/intellij/plugin/bpmn/api/bpmn/BpmnCollaboration.kt @@ -0,0 +1,40 @@ +package com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn + +import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.elements.WithBpmnId + +data class BpmnCollaboration( + override val id: BpmnElementId, + val name: String?, + val participant: List?, + val messageFlow: List?, +): WithBpmnId { + + override fun updateBpmnElemId(newId: BpmnElementId): WithBpmnId { + return copy(id = newId) + } +} + +data class BpmnParticipant( + override val id: BpmnElementId, + val name: String?, + val processRef: String?, + val documentation: String? +): WithBpmnId { + + override fun updateBpmnElemId(newId: BpmnElementId): WithBpmnId { + return copy(id = newId) + } +} + +data class BpmnMessageFlow( + override val id: BpmnElementId, + val name: String?, + val documentation: String?, + val sourceRef: String?, + val targetRef: String?, +): WithBpmnId { + + override fun updateBpmnElemId(newId: BpmnElementId): WithBpmnId { + return copy(id = newId) + } +} diff --git a/xml-parser-api/src/main/kotlin/com/valb3r/bpmn/intellij/plugin/bpmn/api/bpmn/BpmnProcess.kt b/xml-parser-api/src/main/kotlin/com/valb3r/bpmn/intellij/plugin/bpmn/api/bpmn/BpmnProcess.kt index a08f489d3..6dfa0c373 100644 --- a/xml-parser-api/src/main/kotlin/com/valb3r/bpmn/intellij/plugin/bpmn/api/bpmn/BpmnProcess.kt +++ b/xml-parser-api/src/main/kotlin/com/valb3r/bpmn/intellij/plugin/bpmn/api/bpmn/BpmnProcess.kt @@ -12,6 +12,7 @@ import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.elements.events.throwing.Bp import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.elements.events.throwing.BpmnIntermediateSignalThrowingEvent import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.elements.events.throwing.BpmnIntermediateThrowingEvent import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.elements.gateways.* +import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.elements.lanes.BpmnLaneSet import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.elements.subprocess.* import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.elements.tasks.* @@ -110,10 +111,11 @@ data class BpmnProcess( // Using flat data approach as CycleAvoidingMappingContext seem to be an issue with @KotlinBuilder // Child BPMN processes in rendering order, flattened, so that i.e. subProcess is flat simple object (id, docs, ...) // and not recursion object - val children: Map? + val children: Map?, + val laneSets: List? ): WithBpmnId { override fun updateBpmnElemId(newId: BpmnElementId): WithBpmnId { return copy(id = newId) } -} \ No newline at end of file +} diff --git a/xml-parser-api/src/main/kotlin/com/valb3r/bpmn/intellij/plugin/bpmn/api/bpmn/elements/lanes/Lane.kt b/xml-parser-api/src/main/kotlin/com/valb3r/bpmn/intellij/plugin/bpmn/api/bpmn/elements/lanes/Lane.kt new file mode 100644 index 000000000..80d5d78b4 --- /dev/null +++ b/xml-parser-api/src/main/kotlin/com/valb3r/bpmn/intellij/plugin/bpmn/api/bpmn/elements/lanes/Lane.kt @@ -0,0 +1,28 @@ +package com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.elements.lanes + +import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.BpmnElementId +import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.elements.WithBpmnId + +data class BpmnLaneSet( + override val id: BpmnElementId, + val lanes: List?, +): WithBpmnId { + + override fun updateBpmnElemId(newId: BpmnElementId): WithBpmnId { + return copy(id = newId) + } +} + +data class BpmnLane( + override val id: BpmnElementId, + val name: String?, + val documentation: String?, + val flowNodeRef: List?, +): WithBpmnId { + + override fun updateBpmnElemId(newId: BpmnElementId): WithBpmnId { + return copy(id = newId) + } +} + +data class BpmnFlowNodeRef(val ref: String) diff --git a/xml-parser-api/src/main/kotlin/com/valb3r/bpmn/intellij/plugin/bpmn/api/events/EventInterfaces.kt b/xml-parser-api/src/main/kotlin/com/valb3r/bpmn/intellij/plugin/bpmn/api/events/EventInterfaces.kt index 03b3ded3a..69a910f13 100644 --- a/xml-parser-api/src/main/kotlin/com/valb3r/bpmn/intellij/plugin/bpmn/api/events/EventInterfaces.kt +++ b/xml-parser-api/src/main/kotlin/com/valb3r/bpmn/intellij/plugin/bpmn/api/events/EventInterfaces.kt @@ -5,6 +5,7 @@ import com.valb3r.bpmn.intellij.plugin.bpmn.api.PropertyTable import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.BpmnElementId import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.elements.WithBpmnId import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.elements.WithParentId +import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.elements.lanes.BpmnFlowNodeRef import com.valb3r.bpmn.intellij.plugin.bpmn.api.diagram.DiagramElementId import com.valb3r.bpmn.intellij.plugin.bpmn.api.diagram.elements.ShapeElement import com.valb3r.bpmn.intellij.plugin.bpmn.api.diagram.elements.Translatable @@ -60,6 +61,15 @@ interface BpmnShapeObjectAdded: EventPropagatableToXml { val props: PropertyTable } +interface BpmnFlowNodeRefAdded: EventPropagatableToXml { + val bpmnObject: BpmnFlowNodeRef +} + +interface BpmnProcessObjectAdded: EventPropagatableToXml { + val bpmnObject: WithParentId + val props: PropertyTable +} + interface BpmnShapeResizedAndMoved: EventPropagatableToXml { val diagramElementId: DiagramElementId val cx: Float diff --git a/xml-parser-core/src/main/kotlin/com/valb3r/bpmn/intellij/plugin/bpmn/parser/core/BaseBpmnObjectFactory.kt b/xml-parser-core/src/main/kotlin/com/valb3r/bpmn/intellij/plugin/bpmn/parser/core/BaseBpmnObjectFactory.kt index b1811bc0c..44858c401 100644 --- a/xml-parser-core/src/main/kotlin/com/valb3r/bpmn/intellij/plugin/bpmn/parser/core/BaseBpmnObjectFactory.kt +++ b/xml-parser-core/src/main/kotlin/com/valb3r/bpmn/intellij/plugin/bpmn/parser/core/BaseBpmnObjectFactory.kt @@ -5,8 +5,7 @@ import com.fasterxml.jackson.databind.ObjectMapper import com.fasterxml.jackson.databind.node.NullNode import com.valb3r.bpmn.intellij.plugin.bpmn.api.BpmnObjectFactory import com.valb3r.bpmn.intellij.plugin.bpmn.api.PropertyTable -import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.BpmnElementId -import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.BpmnProcess +import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.* import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.elements.BpmnSequenceFlow import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.elements.ConditionExpression import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.elements.WithBpmnId @@ -19,6 +18,9 @@ import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.elements.events.throwing.Bp import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.elements.events.throwing.BpmnIntermediateNoneThrowingEvent import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.elements.events.throwing.BpmnIntermediateSignalThrowingEvent import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.elements.gateways.* +import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.elements.lanes.BpmnFlowNodeRef +import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.elements.lanes.BpmnLane +import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.elements.lanes.BpmnLaneSet import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.elements.subprocess.* import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.elements.tasks.* import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.elements.types.* @@ -27,7 +29,9 @@ import com.valb3r.bpmn.intellij.plugin.bpmn.api.diagram.elements.BoundsElement import com.valb3r.bpmn.intellij.plugin.bpmn.api.diagram.elements.EdgeElement import com.valb3r.bpmn.intellij.plugin.bpmn.api.diagram.elements.ShapeElement import com.valb3r.bpmn.intellij.plugin.bpmn.api.diagram.elements.WithDiagramId -import com.valb3r.bpmn.intellij.plugin.bpmn.api.info.* +import com.valb3r.bpmn.intellij.plugin.bpmn.api.info.Property +import com.valb3r.bpmn.intellij.plugin.bpmn.api.info.PropertyType +import com.valb3r.bpmn.intellij.plugin.bpmn.api.info.PropertyValueType import java.util.* import kotlin.reflect.KClass @@ -124,15 +128,20 @@ abstract class BaseBpmnObjectFactory : BpmnObjectFactory { } } - override fun propertiesOf(obj: T): PropertyTable { + override fun newFlowRef(): BpmnFlowNodeRef { + return BpmnFlowNodeRef(""); + } + + override fun propertiesOf(obj: T): PropertyTable { val table = when (obj) { is BpmnStartEventAlike, is EndEventAlike, is BpmnBoundaryEventAlike, is BpmnTaskAlike, is BpmnGatewayAlike, - is IntermediateCatchingEventAlike, is IntermediateThrowingEventAlike, is BpmnProcess + is IntermediateCatchingEventAlike, is IntermediateThrowingEventAlike, is BpmnProcess, + is BpmnCollaboration, is BpmnParticipant, is BpmnMessageFlow, is BpmnLaneSet, is BpmnLane -> processDtoToPropertyMap(obj) is BpmnStructuralElementAlike -> fillForCallActivity(obj) is BpmnSequenceFlow -> fillForSequenceFlow(obj) - else -> throw IllegalArgumentException("Can't parse properties of: ${obj.javaClass}") + else -> throw IllegalArgumentException("Can't parse properties of: ${obj!!::class.java}") } return PropertyTable(table) diff --git a/xml-parser-core/src/main/kotlin/com/valb3r/bpmn/intellij/plugin/bpmn/parser/core/BaseBpmnParser.kt b/xml-parser-core/src/main/kotlin/com/valb3r/bpmn/intellij/plugin/bpmn/parser/core/BaseBpmnParser.kt index 5d1c6e584..192c37d86 100644 --- a/xml-parser-core/src/main/kotlin/com/valb3r/bpmn/intellij/plugin/bpmn/parser/core/BaseBpmnParser.kt +++ b/xml-parser-core/src/main/kotlin/com/valb3r/bpmn/intellij/plugin/bpmn/parser/core/BaseBpmnParser.kt @@ -8,7 +8,7 @@ import com.fasterxml.jackson.dataformat.xml.JacksonXmlModule import com.fasterxml.jackson.dataformat.xml.XmlMapper import com.fasterxml.jackson.module.kotlin.KotlinModule import com.valb3r.bpmn.intellij.plugin.bpmn.api.BpmnParser -import com.valb3r.bpmn.intellij.plugin.bpmn.api.BpmnProcessObject +import com.valb3r.bpmn.intellij.plugin.bpmn.api.BpmnFileObject import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.BpmnElementId import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.elements.BpmnSequenceFlow import com.valb3r.bpmn.intellij.plugin.bpmn.api.bpmn.elements.WithBpmnId @@ -56,7 +56,7 @@ data class PropertyTypeDetails( abstract class BaseBpmnParser: BpmnParser { - abstract override fun parse(input: String): BpmnProcessObject + abstract override fun parse(input: String): BpmnFileObject override fun validateForErrors(input: String): String? { if (!input.contains("BPMNDiagram")) { @@ -174,6 +174,7 @@ abstract class BaseBpmnParser: BpmnParser { is BpmnEdgeObjectAdded -> applyBpmnEdgeObjectAdded(doc, event) is PropertyUpdateWithId -> applyPropertyUpdateWithId(doc, event) is BpmnParentChanged -> applyParentChange(doc, event) + is BpmnFlowNodeRefAdded -> TODO() } } }