<repo_name>riiswa/orchalang-server<file_sep>/orchalang-orchacompiler/src/main/kotlin/orcha/lang/compiler/DemoApplication.kt
package orcha.lang.compiler

import orcha.lang.compiler.OrchaCompiler
import orcha.lang.compiler.syntax.ReceiveInstruction
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.CommandLineRunner
import org.springframework.boot.autoconfigure.SpringBootApplication
import org.springframework.boot.runApplication
import org.springframework.context.annotation.Bean
import java.io.File

@SpringBootApplication
class DemoApplication{

	@Bean
	fun init(orchaCompiler: OrchaCompiler) = CommandLineRunner {
		orchaCompiler . compile(File("src/main/orcha/source").list()[0])
	}

}

fun main(args: Array<String>) {
	runApplication<DemoApplication>(*args)
}


<file_sep>/orchalang-spring-integration-implementation/src/main/kotlin/orcha/lang/compiler/referenceimpl/springIntegration/OutputGenerationToSpringIntegration.kt
package orcha.lang.compiler.referenceimpl.springIntegration

import orcha.lang.compiler.IntegrationNode
import orcha.lang.compiler.OrchaMetadata
import orcha.lang.compiler.OrchaProgram
import orcha.lang.compiler.OutputGeneration
import orcha.lang.compiler.referenceimpl.springIntegration.xmlgenerator.Aggregator
import orcha.lang.compiler.referenceimpl.springIntegration.xmlgenerator.MessageFilter
import orcha.lang.compiler.referenceimpl.springIntegration.xmlgenerator.ServiceActivator
import orcha.lang.compiler.referenceimpl.springIntegration.xmlgenerator.impl.AggregatorImpl
import orcha.lang.compiler.syntax.ComputeInstruction
import orcha.lang.compiler.syntax.ReceiveInstruction
import orcha.lang.compiler.syntax.WhenInstruction
import org.jdom2.Document
import org.jdom2.Element
import org.jdom2.input.SAXBuilder
import org.jdom2.output.Format
import org.jdom2.output.XMLOutputter
import org.slf4j.LoggerFactory
import java.io.ByteArrayInputStream
import java.io.File
import java.io.FileWriter
import java.io.StringWriter

class OutputGenerationToSpringIntegration : OutputGeneration, MessageFilter(), Aggregator {

    internal var aggregator: AggregatorImpl = AggregatorImpl()

    override fun aggregate(releaseExpression: String): Element {
        return aggregator.aggregate(releaseExpression)
    }

/*    internal lateinit var sourceCodeDirectory: File

    init {

        try {
            val directories = pathToBinaryCode.split("/".toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray()

            var pathToBinCode = "."
            for (directory in directories) {
                pathToBinCode = pathToBinCode + File.separator + directory
            }

            binaryCodeDirectory = File(pathToBinCode)

            val pathToBinary = binaryCodeDirectory.canonicalPath + File.separator + "orcha" + File.separator + "lang" + File.separator + "generated"

            var files = File(pathToBinary).listFiles()
            if (files != null) {
                for (file in files) {
                    log.info("Delete existing generated file: " + file.canonicalPath)
                    file.delete()
                }
            }

            val pathToSouresCode = "." + File.separator + "src" + File.separator + "main"
            sourceCodeDirectory = File(pathToSouresCode)


            var pathToSource = sourceCodeDirectory.canonicalPath + File.separator + "groovy" + File.separator + "orcha" + File.separator + "lang" + File.separator + "generated"

            files = File(pathToSource).listFiles()
            if (files != null) {
                for (file in files) {
                    log.info("Delete existing generated file: " + file.canonicalPath)
                    file.delete()
                }
            }

            pathToSource = sourceCodeDirectory.canonicalPath + File.separator + "java" + File.separator + "orcha" + File.separator + "lang" + File.separator + "generated"

            files = File(pathToSource).listFiles()
            if (files != null) {
                for (file in files) {
                    log.info("Delete existing generated file: " + file.canonicalPath)
                    file.delete()
                }
            }

        } catch (e: IOException) {
            log.error(e.message)
        }


    }*/

    override fun generation(orchaProgram: OrchaProgram) {

        val orchaMetadata = orchaProgram.orchaMetadata

        log.info("Generation of the output (Spring Integration) for the orcha program \"" + orchaMetadata.title + "\" begins.")

        /*val xmlSpringContextFileName = orchaMetadata.title!! + ".xml"
        val xmlSpringContent = sourceCodeDirectory.absolutePath + File.separator + "resources" + File.separator + xmlSpringContextFileName
        val xmlSpringContextFile = File(xmlSpringContent)

        val xmlSpringContextQoSFileName = orchaMetadata.title!! + "QoS.xml"
        val xmlQoSSpringContent = sourceCodeDirectory.absolutePath + File.separator + "resources" + File.separator + xmlSpringContextQoSFileName
        val xmlQoSSpringContextFile = File(xmlQoSSpringContent)*/

        val stringWriter = StringWriter()
        stringWriter.write("<beans xmlns=\"http://www.springframework.org/schema/beans\">")
        stringWriter.write("</beans>")
        stringWriter.flush()

        val s = stringWriter.toString()

        val inputStream = ByteArrayInputStream(s.toByteArray())

        val builder = SAXBuilder()

        val document = builder. build (inputStream)

        val graphOfInstructions = orchaProgram.integrationGraph

        this.transpile(document, orchaMetadata, graphOfInstructions)

        val pathToResources = "." + File.separator + "src" + File.separator + "main" + File.separator + "resources" + File.separator + orchaMetadata.title + ".xml"
        val file = File(pathToResources)
        val xml = XMLOutputter()
        xml.format = Format.getPrettyFormat()
        val xmlProcessor = xml.xmlOutputProcessor
        val fw = FileWriter(file)
        xmlProcessor.process(fw, Format.getPrettyFormat(), document)
        fw.close()

        log.info("XML configuration file for Spring Integration has been generated: " + file.canonicalPath)
        log.info("Generation of the output (Spring Integration) for the orcha program \"" + orchaMetadata.title + "\" complete successfully.")
    }

    private fun transpile(document: Document, orchaMetadata: OrchaMetadata, graphOfInstructions: List<IntegrationNode>) {

        val rootElement = document.rootElement

        var channelName: String = "input"
        var channelNumber: Int = 1

        for (node in graphOfInstructions) {

            log.info("Generation of XML code for the node: " + node)
            log.info("Generation of XML code for the instruction: " + node.instruction!!.instruction)

            when(node.integrationPattern) {
                IntegrationNode.IntegrationPattern.CHANNEL_ADAPTER -> {

                }
                IntegrationNode.IntegrationPattern.MESSAGE_FILTER -> {
                    when(node.instruction){
                        is ReceiveInstruction -> {
                            val receive: ReceiveInstruction = node.instruction as ReceiveInstruction
                            val element = filter(receive.condition)
                            element.setAttribute("input-channel", channelName)
                            channelName = "OutputFilter" + channelNumber
                            channelNumber++
                            element.setAttribute("output-channel", channelName)
                            rootElement.addContent(element)
                        }
                    }
                }
                IntegrationNode.IntegrationPattern.SERVICE_ACTIVATOR -> {
                    when(node.instruction){
                        is ComputeInstruction -> {

                        }
                    }
                }
                IntegrationNode.IntegrationPattern.AGGREGATOR -> {
                    when(node.instruction){
                        is WhenInstruction -> {
                            val whenInstruction: WhenInstruction = node.instruction as WhenInstruction
                            val element = aggregate(whenInstruction.aggregationExpression)
                            element.setAttribute("input-channel", channelName)
                            channelName = "OutputFilter" + channelNumber
                            channelNumber++
                            element.setAttribute("output-channel", channelName)
                            rootElement.addContent(element)
                        }
                    }
                }
                else -> {

                }
            }


            val adjacentNodes = node.nextIntegrationNodes

            this.transpile(document, orchaMetadata, adjacentNodes)
        }

    }

    companion object {
        private val log = LoggerFactory.getLogger(OutputGenerationToSpringIntegration::class.java)
    }

}
<file_sep>/orchalang-spring-boot-autoconfigure/settings.gradle
includeFlat 'orchalang'
// includeFlat 'orchalang-spring-integration-eventhandler'
includeFlat 'orchalang-spring-integration-implementation'<file_sep>/orchalang/src/main/kotlin/orcha/lang/compiler/OrchaCompiler.kt
package orcha.lang.compiler

import org.slf4j.Logger
import org.slf4j.LoggerFactory
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.beans.factory.annotation.Qualifier
import org.springframework.boot.CommandLineRunner
import org.springframework.boot.SpringApplication
import org.springframework.boot.WebApplicationType
import org.springframework.context.annotation.ComponentScan
import org.springframework.context.annotation.Configuration

class OrchaCompiler {

    @Autowired
    internal var preprocessing: Preprocessing? = null

    @Autowired
    @Qualifier("lexicalAnalysisForOrchaCompiler")
    internal var lexicalAnalysis: LexicalAnalysis? = null

    @Autowired
    internal var syntaxAnalysis: SyntaxAnalysis? = null

    @Autowired
    internal var semanticAnalysis: SemanticAnalysis? = null

    @Autowired
    internal var postprocessing: Postprocessing? = null

    @Autowired
    internal var linkEditor: LinkEditor? = null

    @Autowired
    internal var outputGeneration: OutputGeneration? = null

    @Throws(OrchaCompilationException::class)
    fun compile(orchaFileName: String) {

        val linesOfCode = preprocessing!!.process(orchaFileName)

        var orchaProgram = lexicalAnalysis!!.analysis(linesOfCode)

        orchaProgram = syntaxAnalysis!!.analysis(orchaProgram)

        orchaProgram = semanticAnalysis!!.analysis(orchaProgram)

        orchaProgram = postprocessing!!.process(orchaProgram)

        orchaProgram = linkEditor!!.link(orchaProgram)

        outputGeneration!!.generation(orchaProgram)

    }

    companion object {
        private val log = LoggerFactory.getLogger(OrchaCompiler::class.java)
    }

}
<file_sep>/orchalang-spring-integration-implementation/src/main/kotlin/orcha/lang/compiler/referenceimpl/springIntegration/xmlgenerator/ServiceActivator.kt
package orcha.lang.compiler.referenceimpl.springIntegration.xmlgenerator

import org.jdom2.Element
import org.jdom2.Namespace

open class ServiceActivator {

    fun serviceActivator(expression: String): Element {

        val namespace = Namespace.getNamespace("int", "http://www.springframework.org/schema/integration")

        val element = Element("service-activator", namespace)
        element.setAttribute("expression", expression)

        return element
    }

}<file_sep>/orchalang-spring-boot-sample-app/src/main/orcha/service/transport/Bill.java
package service.transport;

public class Bill {
}
<file_sep>/orchalang/src/main/java/orcha/lang/compiler/OrchaProgram.java
package orcha.lang.compiler;

import java.util.List;

public class OrchaProgram {

    List<IntegrationNode> integrationGraph;
    OrchaMetadata orchaMetadata;

    public OrchaProgram(){
    }

    public OrchaProgram(List<IntegrationNode> integrationGraph, OrchaMetadata orchaMetadata) {
        this.integrationGraph = integrationGraph;
        this.orchaMetadata = orchaMetadata;
    }

    public List<IntegrationNode> getIntegrationGraph() {
        return integrationGraph;
    }

    public void setIntegrationGraph(List<IntegrationNode> integrationGraph) {
        this.integrationGraph = integrationGraph;
    }

    public OrchaMetadata getOrchaMetadata() {
        return orchaMetadata;
    }

    public void setOrchaMetadata(OrchaMetadata orchaMetadata) {
        this.orchaMetadata = orchaMetadata;
    }
}
<file_sep>/orchalang-spring-integration-implementation/src/main/kotlin/orcha/lang/compiler/referenceimpl/springIntegration/OutputGenerationToSpringIntegrationJavaDSL.kt
package orcha.lang.compiler.referenceimpl.springIntegration

import com.fasterxml.jackson.databind.ObjectMapper
import orcha.lang.compiler.IntegrationNode
import orcha.lang.compiler.OrchaMetadata
import orcha.lang.compiler.OrchaProgram
import orcha.lang.compiler.OutputGeneration
import orcha.lang.compiler.syntax.ComputeInstruction
import orcha.lang.compiler.syntax.ReceiveInstruction
import orcha.lang.compiler.syntax.WhenInstruction
import org.slf4j.LoggerFactory
import java.io.File

class OutputGenerationToSpringIntegrationJavaDSL : OutputGeneration {

    override fun generation(orchaProgram: OrchaProgram) {

        val orchaMetadata = orchaProgram.orchaMetadata

        log.info("Generation of the output (Spring Integration Java DSL) for the orcha program \"" + orchaMetadata.title + "\" begins.")

        val graphOfInstructions = orchaProgram.integrationGraph

        this.export(orchaMetadata, graphOfInstructions)

        val pathToResources = "." + File.separator + "src" + File.separator + "main" + File.separator + "resources" + File.separator + orchaMetadata.title + ".json"
        val file = File(pathToResources)


        val objectMapper = ObjectMapper()
        val jsonInString = objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(graphOfInstructions);
        file.writeText(jsonInString)

        log.info("XML configuration file for Spring Integration has been generated: " + file.canonicalPath)
        log.info("Generation of the output (Spring Integration Java DSL) for the orcha program \"" + orchaMetadata.title + "\" complete successfully.")
    }

    private fun export(orchaMetadata: OrchaMetadata, graphOfInstructions: List<IntegrationNode>) {

        for (node in graphOfInstructions) {

            log.info("Generation of Java DSL code for the node: " + node)
            log.info("Generation of Java DSL code for the instruction: " + node.instruction!!.instruction)

            when(node.integrationPattern) {
                IntegrationNode.IntegrationPattern.CHANNEL_ADAPTER -> {

                }
                IntegrationNode.IntegrationPattern.MESSAGE_FILTER -> {
                    when(node.instruction){
                        is ReceiveInstruction -> {
                            val receive: ReceiveInstruction = node.instruction as ReceiveInstruction
                        }
                    }
                }
                IntegrationNode.IntegrationPattern.SERVICE_ACTIVATOR -> {
                    when(node.instruction){
                        is ComputeInstruction -> {

                        }
                    }
                }
                IntegrationNode.IntegrationPattern.AGGREGATOR -> {
                    when(node.instruction){
                        is WhenInstruction -> {
                            val whenInstruction: WhenInstruction = node.instruction as WhenInstruction
                        }
                    }
                }
                else -> {

                }
            }


            val adjacentNodes = node.nextIntegrationNodes

            this.export(orchaMetadata, adjacentNodes)
        }

    }

    companion object {
        private val log = LoggerFactory.getLogger(OutputGenerationToSpringIntegrationJavaDSL::class.java)
    }

}
<file_sep>/orchalang-spring-integration-implementation/src/test/kotlin/orcha/lang/compiler/referenceimpl/LexicalAnalysisTest.kt
package orcha.lang.compiler.referenceimpl

import orcha.lang.compiler.LexicalAnalysis
import orcha.lang.compiler.OrchaCompilationException
import orcha.lang.compiler.referenceimpl.springIntegration.SendInstructionForSpringIntegration
import orcha.lang.compiler.referenceimpl.springIntegration.WhenInstructionForSpringIntegration
import orcha.lang.compiler.syntax.TitleInstruction
import org.junit.Assert
import org.junit.Test
import org.junit.runner.RunWith
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.test.context.SpringBootTest
import org.springframework.test.context.junit4.SpringRunner
import java.util.*

@RunWith(SpringRunner::class)
@SpringBootTest
class LexicalAnalysisTest {

    @Autowired
    internal var lexicalAnalysisForTest: LexicalAnalysis? = null

    @Test
    fun test() {

        try {
            Assert.assertTrue(lexicalAnalysisForTest != null)

            val linesOfCode = ArrayList(
                    Arrays.asList(
                            "title: title",
                            "",
                            "receive order from customer",
                            "when \"order terminates\"",
                            "send order.number to customer"))

            val orchaProgram = lexicalAnalysisForTest!!.analysis(linesOfCode)

            Assert.assertNotNull(orchaProgram)
            Assert.assertNotNull(orchaProgram.integrationGraph)
            Assert.assertNotNull(orchaProgram.orchaMetadata)

            val orchaMetadata = orchaProgram.orchaMetadata
            val metadata = orchaMetadata.metadata
            Assert.assertNotNull(metadata)
            Assert.assertEquals(metadata.size.toLong(), 1)
            val instruction = metadata[0]
            Assert.assertTrue(instruction is TitleInstruction)


            val graphOfInstructions = orchaProgram.integrationGraph

            Assert.assertTrue(graphOfInstructions.size == 3)

            var integrationNode = graphOfInstructions[1]
            Assert.assertNotNull(integrationNode)
            var inst = integrationNode.instruction
            inst.analysis()
            Assert.assertNotNull(inst)
            Assert.assertTrue(inst is WhenInstructionForSpringIntegration)
            val whenInstruction = inst as WhenInstructionForSpringIntegration
            Assert.assertEquals(whenInstruction.getLineNumber(), 4)
            Assert.assertTrue(whenInstruction.getCommand().equals("when"))

            integrationNode = graphOfInstructions[2]
            Assert.assertNotNull(integrationNode)
            inst = integrationNode.instruction
            Assert.assertNotNull(inst)
            inst.analysis()
            Assert.assertTrue(inst is SendInstructionForSpringIntegration)
            val sendInstruction = inst as SendInstructionForSpringIntegration
            Assert.assertEquals(sendInstruction.getLineNumber(), 5)
            Assert.assertTrue(sendInstruction.getCommand().equals("send"))
            Assert.assertEquals(sendInstruction.getVariables(), "payload.number")

        } catch (e: OrchaCompilationException) {
            Assert.fail(e.message)
        }

    }

}
<file_sep>/README.md
# orchalang

## orcha language

* [documentation](http://www.orchalang.com/)
* [reference implementation](https://github.com/orchaland/orchalang/tree/master/orchalang)

## Spring integration implementation

* [reference implementation](https://github.com/orchaland/orchalang/tree/master/orchalang-spring-integration-implementation)
<file_sep>/orchalang-orchacompiler/src/main/kotlin/orcha/lang/compiler/OrchaCompilerConfiguration.kt
package orcha.lang.compiler

import orcha.lang.configuration.*
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration

@Configuration
class OrchaCompilerConfiguration {

    @Bean
    fun orchaProgramSource(): EventHandler {
        val eventHandler = EventHandler("orchaProgramSource")
        return eventHandler;
    }

    @Bean
    fun preprocessing(): Application {
        val application = Application("preprocessing", "Kotlin")
        val javaAdapter = JavaServiceAdapter("orcha.lang.compiler.referenceimpl.PreprocessingImpl", "process")
        application.input = Input(javaAdapter, "java.lang.String")
        application.output = Output(javaAdapter, "java.util.List<java.lang.String>")
        return application
    }

    @Bean
    fun lexicalAnalysis(): Application {
        val application = Application("lexicalAnalysis", "Kotlin")
        val javaAdapter = JavaServiceAdapter("orcha.lang.compiler.referenceimpl.LexicalAnalysisImpl", "analysis")
        application.input = Input(javaAdapter, "java.util.List<java.lang.String>")
        application.output = Output(javaAdapter, "orcha.lang.compiler.OrchaProgram")
        return application
    }

    @Bean
    fun syntaxAnalysis(): Application {
        val application = Application("syntaxAnalysis", "Kotlin")
        val javaAdapter = JavaServiceAdapter("orcha.lang.compiler.referenceimpl.SyntaxAnalysisImpl", "analysis")
        application.input = Input(javaAdapter,"orcha.lang.compiler.OrchaProgram")
        application.output = Output(javaAdapter, "orcha.lang.compiler.OrchaProgram")
        return application
    }

    @Bean
    fun semanticAnalysis(): Application {
        val application = Application("semanticAnalysis", "Kotlin")
        val javaAdapter = JavaServiceAdapter("orcha.lang.compiler.referenceimpl.SemanticAnalysisImpl", "analysis")
        application.input = Input(javaAdapter,"orcha.lang.compiler.OrchaProgram")
        application.output = Output(javaAdapter,"orcha.lang.compiler.OrchaProgram")
        return application
    }

    @Bean
    fun postprocessing(): Application {
        val application = Application("postprocessing", "Kotlin")
        val javaAdapter = JavaServiceAdapter("orcha.lang.compiler.referenceimpl.PostprocessingImpl", "process")
        application.input = Input(javaAdapter,"orcha.lang.compiler.OrchaProgram")
        application.output = Output(javaAdapter, "orcha.lang.compiler.OrchaProgram")
        return application
    }

    @Bean
    fun linkEditor(): Application {
        val application = Application("linkEditor", "Kotlin")
        val javaAdapter = JavaServiceAdapter("orcha.lang.compiler.referenceimpl.springIntegration.LinkEditorImpl", "link")
        application.input = Input(javaAdapter,"orcha.lang.compiler.OrchaProgram")
        application.output = Output(javaAdapter, "orcha.lang.compiler.OrchaProgram")
        return application
    }

    @Bean
    fun outputGeneration(): Application {
        val application = Application("outputGeneration", "Kotlin")
        val javaAdapter = JavaServiceAdapter("orcha.lang.compiler.referenceimpl.springIntegration.OutputGenerationToSpringIntegration", "generation")
        application.input = Input(javaAdapter, "orcha.lang.compiler.OrchaProgram")
        return application
    }

    @Bean
    fun orchaProgramDestination(): EventHandler {
        val eventHandler = EventHandler("orchaProgramDestination")
        val fileAdapter = OutputFileAdapter("data/output", "orchaCompiler.xml")
        eventHandler.output = Output(fileAdapter, "application/xml")
        return eventHandler
    }
}<file_sep>/orchalang-orchacompiler/src/main/kotlin/orcha/lang/compiler/OrchaCompilerConfig.kt
package orcha.lang.compiler

import orcha.lang.compiler.referenceimpl.LexicalAnalysisImpl
import orcha.lang.compiler.referenceimpl.PreprocessingImpl
import orcha.lang.compiler.referenceimpl.SemanticAnalysisImpl
import orcha.lang.compiler.referenceimpl.SyntaxAnalysisImpl
import orcha.lang.compiler.referenceimpl.springIntegration.LinkEditorImpl
import orcha.lang.compiler.referenceimpl.springIntegration.OutputGenerationToSpringIntegration
import orcha.lang.compiler.referenceimpl.springIntegration.OutputGenerationToSpringIntegrationJavaDSL
import org.springframework.beans.factory.annotation.Qualifier
import org.springframework.beans.factory.annotation.Value
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
import org.springframework.context.annotation.DependsOn

@Configuration
class OrchaCompilerConfig{

    @Bean
    fun orchaCompiler(): OrchaCompiler{
        return OrchaCompiler()
    }

    /*@Bean(name = ["whenInstruction"])
    fun whenInstructionFactory(): WhenInstructionFactory {
        return WhenInstructionFactory()
    }

    @Bean
    @Throws(Exception::class)
    fun whenInstruction(): WhenInstruction? {
        return whenInstructionFactory().getObject()
    }*/

    @Value("\${orcha.pathToBinaryCode:build/resources/main}")
    internal var pathToBinaryCode: String? = null

    @Bean
    internal fun preprocessing(): Preprocessing {
        return PreprocessingImpl()
    }

    @Bean
    @DependsOn("whenInstruction", "sendInstruction")
    @Qualifier("lexicalAnalysisForOrchaCompiler")
    internal fun lexicalAnalysis(): LexicalAnalysis {
        return LexicalAnalysisImpl()
    }

    @Bean
    internal fun syntaxAnalysis(): SyntaxAnalysis {
        return SyntaxAnalysisImpl()
    }

    @Bean
    internal fun semanticAnalysis(): SemanticAnalysis {
        return SemanticAnalysisImpl()
    }

    @Bean
    internal fun linkEditor(): LinkEditor {
        return LinkEditorImpl()
    }

    /*@Bean
    internal fun outputGeneration(): OutputGeneration {
        return OutputGenerationToSpringIntegration()
    }*/

    @Bean
    internal fun outputGeneration(): OutputGeneration {
        return OutputGenerationToSpringIntegrationJavaDSL()
    }

}<file_sep>/orchalang-spring-boot-sample-app/src/main/orcha/service/transport/ProductDesignation.java
package service.transport;

public class ProductDesignation {

    CategoryOfProduct categoryOfProduct;
    String brand;
    String model;
    int quantity;

}
<file_sep>/orchalang-spring-integration-implementation/src/main/kotlin/orcha/lang/compiler/referenceimpl/springIntegration/xmlgenerator/MessageTranslator.kt
package orcha.lang.compiler.referenceimpl.springIntegration.xmlgenerator

import org.jdom2.Element
import org.jdom2.Namespace
import java.util.HashMap


open class MessageTranslator : Bean() {

    fun translate(translationExpression: String): Element {

        val namespace = Namespace.getNamespace("int", "http://www.springframework.org/schema/integration")
        val transformer = Element("transformer", namespace)
        //transformer.setAttribute("id", "transformer-"+instructionNode.inputName+"-id")
        //transformer.setAttribute("input-channel", instructionNode.inputName + "Transformer")
        //transformer.setAttribute("output-channel", outputChannel)
        transformer.setAttribute("expression", translationExpression)
        return transformer

    }

    fun objectToString(): Element {
        val namespace = Namespace.getNamespace("int", "http://www.springframework.org/schema/integration")
        return Element("object-to-string-transformer", namespace)
    }

    fun objectToJson(): Element {

        val namespace = Namespace.getNamespace("int", "http://www.springframework.org/schema/integration")
        return Element("object-to-json-transformer", namespace)
    }

    fun jsonToObject(type: String): Element {

        val namespace = Namespace.getNamespace("int", "http://www.springframework.org/schema/integration")

        val element = Element("json-to-object-transformer", namespace)
        element.setAttribute("type", type)

        return element
    }

    /*fun objectToApplicationTransformer(integrationNode: IntegrationNode): Element {

        val instruction = integrationNode.instruction

        //val applicationName = instruction.springBean.name
        //val outputServiceChannel = applicationName + "ServiceAcivatorOutput"

        val namespace = Namespace.getNamespace("int", "http://www.springframework.org/schema/integration")

        val transformer = Element("transformer", namespace)
        //transformer.setAttribute("id", "transformer-$outputServiceChannel-id")
        //transformer.setAttribute("input-channel", outputServiceChannel)
        //transformer.setAttribute("output-channel", integrationNode.outputName)
        transformer.setAttribute("method", "transform")

        val properties = object : HashMap<String, String>() {
            init {
                put("application", "applicationName")
            }
        }

        val beanElement = beanWithRef("orcha.lang.compiler.referenceimpl.xmlgenerator.impl.ObjectToApplicationTransformer", properties)

        transformer.addContent(beanElement)

        /*if (integrationNode.options != null && integrationNode.options.eventSourcing != null) {
            if (integrationNode.options.eventSourcing.joinPoint === JoinPoint.after || integrationNode.options.eventSourcing.joinPoint === JoinPoint.beforeAndAfter) {
                val adviceChain = Element("request-handler-advice-chain", namespace)
                transformer.addContent(adviceChain)
                val eventSourcingElement = eventSourcing(integrationNode.options.eventSourcing)
                adviceChain.addContent(eventSourcingElement)
            }
        }*/

        return transformer

    }

    fun applicationsListToObjectsListTransformer(integrationNode: IntegrationNode): Element {

        val namespace = Namespace.getNamespace("int", "http://www.springframework.org/schema/integration")

        //val outputChannel = integrationNode.inputName + "AggregatorOutput"

        val transformer = Element("transformer", namespace)
        //transformer.setAttribute("id", "transformer-$outputChannel-id")
        //transformer.setAttribute("input-channel", outputChannel)
        //transformer.setAttribute("output-channel", integrationNode.outputName)
        transformer.setAttribute("method", "transform")

        val properties = HashMap<String, String>()

        val beanElement = beanWithValue("orcha.lang.compiler.referenceimpl.xmlgenerator.impl.ApplicationsListToObjectsListTransformer", properties)

        transformer.addContent(beanElement)

        return transformer

    }

    fun applicationToObjectTransformer(integrationNode: IntegrationNode): Element {

        val namespace = Namespace.getNamespace("int", "http://www.springframework.org/schema/integration")

        //val outputChannel = integrationNode.inputName + "AggregatorOutput"

        val transformer = Element("transformer", namespace)
        //transformer.setAttribute("id", "transformer-$outputChannel-id")
        //transformer.setAttribute("input-channel", outputChannel)
        //transformer.setAttribute("output-channel", integrationNode.outputName)
        transformer.setAttribute("method", "transform")

        val properties = HashMap<String, String>()

        val beanElement = beanWithValue("orcha.lang.compiler.referenceimpl.xmlgenerator.impl.ApplicationToObjectTransformer", properties)

        transformer.addContent(beanElement)

        return transformer

    }*/

}
<file_sep>/orchalang-spring-integration-implementation/src/main/kotlin/orcha/lang/compiler/referenceimpl/springIntegration/SpringIntegrationAutoConfiguration.kt
package orcha.lang.compiler.referenceimpl.springIntegration

import orcha.lang.compiler.Postprocessing
import orcha.lang.compiler.referenceimpl.PostprocessingImpl
import orcha.lang.compiler.syntax.SendInstruction
import orcha.lang.compiler.syntax.WhenInstruction
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration

@Configuration
@ConditionalOnClass(WhenInstructionForSpringIntegration::class, SendInstructionForSpringIntegration::class)
class SpringIntegrationAutoConfiguration {

    @Bean(name = ["whenInstruction"])
    fun whenInstructionFactory(): WhenInstructionFactory {
        return WhenInstructionFactory()
    }

    @Bean
    @Throws(Exception::class)
    fun whenInstruction(): WhenInstruction? {
        return whenInstructionFactory().getObject()
    }

    @Bean(name = ["sendInstruction"])
    fun sendInstructionFactory(): SendInstructionFactory {
        return SendInstructionFactory()
    }

    @Bean
    @Throws(Exception::class)
    fun sendInstruction(): SendInstruction? {
        return sendInstructionFactory().getObject()
    }

    @Bean
    internal fun postprocessing(): Postprocessing {
        return PostprocessingImpl()
    }

}
<file_sep>/orchalang-spring-integration-implementation/src/main/kotlin/orcha/lang/compiler/referenceimpl/springIntegration/xmlgenerator/impl/AggregatorImpl.kt
package orcha.lang.compiler.referenceimpl.springIntegration.xmlgenerator.impl

import orcha.lang.compiler.referenceimpl.springIntegration.xmlgenerator.Aggregator
import orcha.lang.compiler.referenceimpl.springIntegration.xmlgenerator.MessageTranslator
import org.jdom2.Element
import org.jdom2.Namespace

class AggregatorImpl : MessageTranslator(), Aggregator{

    override fun aggregate(releaseExpression: String): Element {

        //val rootElement = document!!.getRootElement()

        val namespace = Namespace.getNamespace("int", "http://www.springframework.org/schema/integration")


        //val sameEvent = integrationNode.options.sameEvent
        val sameEvent = false

        //val instruction = integrationNode.instruction

        //val outputChannel = integrationNode.inputName + "AggregatorOutput"

        /*if (integrationNode.options == null) {
            integrationNode.options = QualityOfServicesOptions(false)
        }*/

        val aggregatorElement = Element("aggregator", namespace)
        //aggregatorElement.setAttribute("id", "aggregator-" + integrationNode.inputName + "-id")

        //aggregatorElement.setAttribute("input-channel", integrationNode.inputName)

        //aggregatorElement.setAttribute("output-channel", integrationNode.inputName + "Transformer")
        aggregatorElement.setAttribute("release-strategy-expression", releaseExpression)

        if (sameEvent == true) {

            aggregatorElement.setAttribute("correlation-strategy-expression", "headers['messageID']")

        } else {

            aggregatorElement.setAttribute("correlation-strategy-expression", "0")

        }

        //rootElement.addContent(aggregatorElement)


        /*val transformer = Element("transformer", namespace)
        transformer.setAttribute("id", "transformer-" + integrationNode.inputName + "-id")
        transformer.setAttribute("input-channel", integrationNode.inputName + "Transformer")
        transformer.setAttribute("output-channel", outputChannel)
        transformer.setAttribute("expression", transformerExpression)

        rootElement.addContent(transformer)*/

        /*if (isMultipleArgumentsInExpression == true) {

            val applicationsListToObjectsListElement = applicationsListToObjectsListTransformer(integrationNode)
            rootElement.addContent(applicationsListToObjectsListElement)

        } else {

            val applicationToObjectElement = applicationToObjectTransformer(integrationNode)
            rootElement.addContent(applicationToObjectElement)

        }*/

        /*if (integrationNode.options != null && integrationNode.options.queue != null) {

            val queueElement = queue(integrationNode.outputName, integrationNode.options.queue)
            rootElement.addContent(queueElement)

        }*/

        return aggregatorElement


    }
}
<file_sep>/orchalang-spring-boot-autoconfigure/build.gradle
apply plugin: 'org.springframework.boot'

sourceSets {
	main {
		java {
			srcDirs = [ 'src/main/java' ]
			srcDir 'src/main/orcha'
		}
	}
	test {
		java {
			srcDirs = [ 'src/test/java' ]
			srcDir 'src/test/orcha'
		}
		resources {
			srcDirs = ["src/test/resources"]
		}
	}
}

springBoot {
	mainClassName = "orcha.lang.compiler.OrchaCompiler"
}


dependencies {
	compile project(':orchalang')
	compile "org.springframework.boot:spring-boot-autoconfigure"
	annotationProcessor "org.springframework.boot:spring-boot-autoconfigure-processor"
}
<file_sep>/orchalang-spring-integration-implementation/src/test/kotlin/orcha/lang/compiler/referenceimpl/CompilerReferenceImplTestConfiguration.kt
package orcha.lang.compiler.referenceimpl

import orcha.lang.compiler.LexicalAnalysis
import orcha.lang.compiler.SyntaxAnalysis
import orcha.lang.compiler.referenceimpl.springIntegration.SendInstructionFactory
import orcha.lang.compiler.referenceimpl.springIntegration.WhenInstructionFactory
import orcha.lang.compiler.syntax.SendInstruction
import orcha.lang.compiler.syntax.WhenInstruction
import org.springframework.beans.factory.annotation.Value
import org.springframework.boot.SpringBootConfiguration
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
import org.springframework.context.annotation.DependsOn

@SpringBootConfiguration
@Configuration
class CompilerReferenceImplTestConfiguration {

    @Value("\${orcha.pathToBinaryCode:build/resources/main}")
    internal var pathToBinaryCode: String? = null

    @Bean
    @DependsOn("whenInstruction", "sendInstruction")
    internal fun lexicalAnalysisForTest(): LexicalAnalysis {
        return LexicalAnalysisImpl()
    }

    @Bean(name = ["whenInstruction"])
    fun whenInstructionFactory(): WhenInstructionFactory {
        return WhenInstructionFactory()
    }

    @Bean
    @Throws(Exception::class)
    fun whenInstruction(): WhenInstruction? {
        return whenInstructionFactory().getObject()
    }

    @Bean(name = ["sendInstruction"])
    fun sendInstructionFactory(): SendInstructionFactory {
        return SendInstructionFactory()
    }

    @Bean
    @Throws(Exception::class)
    fun sendInstruction(): SendInstruction? {
        return sendInstructionFactory().getObject()
    }

    @Bean
    internal fun syntaxAnalysisForTest(): SyntaxAnalysis {
        return SyntaxAnalysisImpl()
    }


}
<file_sep>/orchalang-spring-integration-implementation/build.gradle
plugins {
	id 'org.jetbrains.kotlin.jvm' version '1.2.71'
	id 'org.jetbrains.kotlin.plugin.spring' version '1.2.71'
}

dependencies {
	compile project(':orchalang')
	implementation 'org.springframework.boot:spring-boot-starter'
	testImplementation 'org.springframework.boot:spring-boot-starter-test'
	compile group: 'org.jdom', name: 'jdom2', version: '2.0.6'
	// https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-core
	compile 'com.fasterxml.jackson.core:jackson-core:2.10.0'
	// https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-databind
	compile 'com.fasterxml.jackson.core:jackson-databind:2.10.0'


	implementation 'org.jetbrains.kotlin:kotlin-reflect'
	implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk8'
}

compileKotlin {
	kotlinOptions {
		freeCompilerArgs = ['-Xjsr305=strict']
		jvmTarget = '1.8'
	}
}

compileTestKotlin {
	kotlinOptions {
		freeCompilerArgs = ['-Xjsr305=strict']
		jvmTarget = '1.8'
	}
}
<file_sep>/orchalang-spring-boot-sample-app/src/main/orcha/service/transport/ProfileUser.kt
package service.transport

import java.util.Calendar

class ProfileUser {

    internal fun check(request: Request): Request {
        request.date = Calendar.getInstance().time
        request.identifier = 123
        request.customer = Customer()
        return request
    }
}
<file_sep>/orchalang-spring-boot-sample-app/src/main/orcha/service/transport/Request.kt
package service.transport


import java.util.ArrayList
import java.util.Date

class Request {

    var identifier: Int = 0
    val products = ArrayList<ProductDesignation>()
    val deliveryTime: DeliveryTime? = null
    var date: Date? = null
    val placeOfDelivery: PlaceOfDelivery? = null
    var customer: Customer? = null
    val bill: Bill? = null

    enum class DeliveryTime private constructor(val numberOfDays: Int) {

        URGENT(1),
        FAST(3),
        NORMAL(5)

    }

    enum class PlaceOfDelivery {
        AT_HOME,
        DELIVERY_CENTER
    }

}
<file_sep>/orchalang-spring-boot-sample-app/src/main/orcha/configuration/transport/ProductOrderConfiguration.kt
package configuration.transport

import orcha.lang.configuration.*
import org.springframework.context.annotation.Bean
import service.transport.ProfileUser

class ProductOrderConfiguration {

    @Bean
    fun user(): EventHandler {
        val eventHandler = EventHandler("user")
        val inputFileAdapter = InputFileAdapter("data/input", "request.json")
        eventHandler.input = Input("application/json", "service.transport.Request", inputFileAdapter)
        val outputFileAdapter = OutputFileAdapter("data/output", true, "securityAlert.json", true, OutputFileAdapter.WritingMode.REPLACE)
        eventHandler.output = Output("application/json", "service.airport.SecurityAlert", outputFileAdapter)
        return eventHandler
    }

    @Bean
    fun profileUser(): ProfileUser {
        return ProfileUser()
    }

    @Bean
    fun authenticateUsersRequest(): Application {
        val application = Application("authenticateUsersRequest", "Java")
        val javaAdapter = JavaServiceAdapter("service.transport.ProfileUser", "check")
        application.input = Input("service.transport.Request", javaAdapter)
        application.output = Output("service.transport.Request", javaAdapter)
        return application
    }

}
<file_sep>/orchalang-spring-integration-implementation/src/main/kotlin/orcha/lang/compiler/referenceimpl/springIntegration/xmlgenerator/MessageRouting.kt
package orcha.lang.compiler.referenceimpl.springIntegration.xmlgenerator

<file_sep>/orchalang-spring-boot-sample-app/src/main/orcha/service/transport/Customer.java
package service.transport;

public class Customer {



}
<file_sep>/orchalang-orchacompiler/src/main/kotlin/orcha/lang/compiler/Server.kt
package orcha.lang.compiler

import com.sun.net.httpserver.HttpServer
import org.springframework.boot.runApplication
import java.io.*
import java.net.InetSocketAddress
import java.nio.charset.StandardCharsets
import java.util.*
import java.util.stream.Collectors

fun inputStreamToString(inputStream: InputStream): String {
    val isReader = InputStreamReader(inputStream)
    val reader = BufferedReader(isReader)
    return reader.lines().collect(Collectors.joining())
}

fun decodeURL(url: String): String {
    return java.net.URLDecoder.decode(url, StandardCharsets.UTF_8.name())
}

fun getQueryMap(query: String): Map<String, String> {
    val params = query.split("&".toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray()
    val map = HashMap<String, String>()
    for (param in params) {
        val name = param.split("=".toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray()[0]
        val value = param.split("=".toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray()[1]
        map[name] = value
    }
    return map
}

fun cleanDirectory(dir: File) {
    for (file in dir.listFiles()) file.delete()
}

fun main(args: Array<String>) {
    HttpServer.create(InetSocketAddress(8080), 0).apply {
        createContext("/api/orcha") { http ->
            http.responseHeaders.add("Access-Control-Allow-Origin", "*")
            http.responseHeaders.add("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept, Authorization, reponseType");
            http.responseHeaders.add("Access-Control-Allow-Credentials", "true")
            http.responseHeaders.add("Access-Control-Allow-Methods", "GET,POST,PUT,DELETE,OPTIONS,HEAD")
            val directory = "src/main/orcha/source/"
            val decodedRequest = decodeURL(inputStreamToString(http.requestBody))
            val params = getQueryMap(decodedRequest)
            if (params.containsKey("fileName") && params.containsKey("fileContent")) {
                cleanDirectory(File(directory))
                val out = PrintWriter(directory + params["fileName"])
                out.println(params["fileContent"])
                out.close()
                val baos = ByteArrayOutputStream()
                val ps = PrintStream(baos)
                val old = System.out
                System.setOut(ps)
                try {
                    runApplication<DemoApplication>(*args)
                } catch (e: Exception) {
                    println(e.message)
                } finally {
                    System.out.flush()
                    System.setOut(old)
                }
                http.sendResponseHeaders(200, 0)

                PrintWriter(http.responseBody).use { out ->
                    out.println(baos.toString())
                }
            } else {
                http.responseHeaders.add("Content-type", "text/plain")
                http.sendResponseHeaders(420, 0)
            }
        }
        start()
    }
}<file_sep>/orchalang/build.gradle
plugins {
	id 'org.jetbrains.kotlin.jvm' version '1.2.71'
	id 'org.jetbrains.kotlin.plugin.spring' version '1.2.71'
}

dependencies {
	implementation 'org.springframework.boot:spring-boot-starter'
	testImplementation 'org.springframework.boot:spring-boot-starter-test'
	//compile group: 'org.jdom', name: 'jdom2', version: '2.0.6'
	implementation 'org.jetbrains.kotlin:kotlin-reflect'
	implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk8'
}

compileKotlin {
	kotlinOptions {
		freeCompilerArgs = ['-Xjsr305=strict']
		jvmTarget = '1.8'
	}
}

compileTestKotlin {
	kotlinOptions {
		freeCompilerArgs = ['-Xjsr305=strict']
		jvmTarget = '1.8'
	}
}


/*sourceSets {
	main {
		java {
			srcDirs = [ 'src/main/java' ]
			srcDir 'src/main/orcha'
		}
	}
	test {
		java {
			srcDirs = [ 'src/test/java' ]
			srcDir 'src/test/orcha'
		}
		resources {
			srcDirs = ["src/test/resources"]
		}
	}
}*/

/*task fatJar(type: Jar) {
	manifest {
		attributes 'Main-Class': 'orcha.lang.compiler.OrchaCompiler'
	}
	baseName = 'orchalanguage'
	from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } }
	with jar
}

springBoot {
	mainClassName = "orcha.lang.compiler.OrchaCompiler"
}*/

/*dependencies {
	implementation 'org.springframework.boot:spring-boot-starter'
	testImplementation 'org.springframework.boot:spring-boot-starter-test'
	compile 'org.codehaus.groovy:groovy-all:2.4.5'
	compile group: 'org.jdom', name: 'jdom2', version: '2.0.6'
}*/
<file_sep>/orchalang-spring-integration-implementation/README.md
# Spring integration implementation

<file_sep>/orchalang-spring-integration-implementation/src/test/kotlin/orcha/lang/compiler/referenceimpl/OutputGenerationTest.kt
package orcha.lang.compiler.referenceimpl

import orcha.lang.compiler.OrchaProgram
import orcha.lang.compiler.OutputGeneration
import org.junit.Test
import org.junit.runner.RunWith
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.test.context.SpringBootTest
import org.springframework.test.context.junit4.SpringRunner

@RunWith(SpringRunner::class)
@SpringBootTest
class OutputGenerationTest {

    @Autowired
    internal var outputGeneration: OutputGeneration? = null

    @Test
    fun test() {
        val orchaProgram = OrchaProgram()
        //transpiler.transpile(orchaProgram);
    }

}
<file_sep>/orchalang-orchacompiler/build.gradle
plugins {
	id 'org.jetbrains.kotlin.jvm' version '1.2.71'
	id 'org.jetbrains.kotlin.plugin.spring' version '1.2.71'
}


/*sourceSets {
	main {
		java {
			srcDirs = [ 'src/main/kotlin' ]
			srcDir 'src/main/orcha'
		}
	}
	test {
		java {
			srcDirs = [ 'src/test/kotlin' ]
			srcDir 'src/test/orcha'
		}
		resources {
			srcDirs = ["src/test/resources"]
		}
	}
}*/


dependencies {
	compile project(':orchalang')
	compile project(':orchalang-spring-integration-implementation')
	implementation 'org.springframework.boot:spring-boot-starter'
	testImplementation 'org.springframework.boot:spring-boot-starter-test'
	implementation 'org.jetbrains.kotlin:kotlin-reflect'
	implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk8'
}

compileKotlin {
	kotlinOptions {
		freeCompilerArgs = ['-Xjsr305=strict']
		jvmTarget = '1.8'
	}
}

compileTestKotlin {
	kotlinOptions {
		freeCompilerArgs = ['-Xjsr305=strict']
		jvmTarget = '1.8'
	}
}
<file_sep>/orchalang-spring-integration-implementation/src/main/kotlin/orcha/lang/compiler/referenceimpl/springIntegration/LinkEditorImpl.kt
package orcha.lang.compiler.referenceimpl.springIntegration

import orcha.lang.compiler.IntegrationNode
import orcha.lang.compiler.LinkEditor
import orcha.lang.compiler.OrchaCompilationException
import orcha.lang.compiler.OrchaProgram
import orcha.lang.compiler.syntax.ComputeInstruction
import orcha.lang.configuration.Application
import org.slf4j.Logger
import org.slf4j.LoggerFactory
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.beans.factory.getBean
import org.springframework.context.ApplicationContext

class LinkEditorImpl : LinkEditor {

    @Autowired
    internal var springApplicationContext: ApplicationContext? = null

    @Throws(OrchaCompilationException::class)
    override fun link(orchaProgram: OrchaProgram): OrchaProgram {

        log.info("Link edition of the orcha program \"" + orchaProgram.orchaMetadata.title + "\" begins. ")

        for (node in orchaProgram.integrationGraph) {

            log.info("Link edition for the node: " + node)
            log.info("Link edition for the instruction: " + node.instruction!!.instruction)

            when (node.integrationPattern) {
                IntegrationNode.IntegrationPattern.SERVICE_ACTIVATOR -> {
                    when(node.instruction){
                        is ComputeInstruction -> {
                            val compute: ComputeInstruction = node.instruction as ComputeInstruction
                            val configuration = springApplicationContext!!.getBean(compute.application)
                            val application: Application = configuration as Application
                            compute.configuration = application
                        }
                    }
                }
            }
        }

        log.info("Linf edition of the orcha program \"" + orchaProgram.orchaMetadata.title + "\" complete successfuly.")
        return orchaProgram
    }

    companion object {

        private val log = LoggerFactory.getLogger(LinkEditorImpl::class.java)
    }
}
<file_sep>/orchalang-spring-integration-implementation/src/main/kotlin/orcha/lang/compiler/referenceimpl/springIntegration/xmlgenerator/Bean.kt
package orcha.lang.compiler.referenceimpl.springIntegration.xmlgenerator

import org.jdom2.Element
import org.jdom2.Namespace
import java.util.HashMap

open class Bean {

    fun bean(fullClassName: String): Element {

        val properties = HashMap<String, String>()
        return beanWithValue(fullClassName, properties)

    }

    fun bean(id: String, fullClassName: String): Element {

        val properties = HashMap<String, String>()
        return beanWithValue(id, fullClassName, properties)

    }

    fun beanWithValue(fullClassName: String, properties: Map<String, String>): Element {

        val namespace = Namespace.getNamespace("", "http://www.springframework.org/schema/beans")

        val bean = Element("bean", namespace)
        bean.setAttribute("class", fullClassName)

        properties.forEach { (k, v) ->
            val property = Element("property", namespace)
            property.setAttribute("name", k)
            property.setAttribute("value", v)
            bean.addContent(property)
        }

        return bean

    }

    fun beanWithValue(id: String, fullClassName: String, properties: Map<String, String>): Element {

        val namespace = Namespace.getNamespace("", "http://www.springframework.org/schema/beans")

        val bean = this.beanWithValue(fullClassName, properties)
        bean.setAttribute("id", id)

        return bean

    }

    fun beanWithRef(fullClassName: String, properties: Map<String, String>): Element {

        val namespace = Namespace.getNamespace("", "http://www.springframework.org/schema/beans")

        val bean = Element("bean", namespace)
        bean.setAttribute("class", fullClassName)

        properties.forEach { (k, v) ->
            val property = Element("property", namespace)
            property.setAttribute("name", k)
            property.setAttribute("ref", v)
            bean.addContent(property)
        }


        return bean

    }

}
<file_sep>/orchalang-spring-integration-implementation/src/main/kotlin/orcha/lang/compiler/referenceimpl/springIntegration/xmlgenerator/Aggregator.kt
package orcha.lang.compiler.referenceimpl.springIntegration.xmlgenerator


import org.jdom2.Document;
import org.jdom2.Element;
import org.jdom2.Namespace;

interface Aggregator {

    fun aggregate(releaseExpression: String): Element

}
