-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
23 changed files
with
359 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
...n/io/holunda/camunda/platform/adminprocess/config/CamundaAdminProcessAutoConfiguration.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package io.holunda.camunda.platform.adminprocess.config | ||
|
||
import io.holunda.camunda.platform.adminprocess.AdminProcess | ||
import io.holunda.camunda.platform.adminprocess.AdminProcessRegistry | ||
import mu.KLogging | ||
import org.springframework.context.annotation.Bean | ||
import org.springframework.context.annotation.Configuration | ||
|
||
@Configuration | ||
class CamundaAdminProcessAutoConfiguration { | ||
companion object : KLogging() | ||
|
||
/** | ||
* Collects all beans of type [AdminProcess] in context and registers them in a map. | ||
*/ | ||
@Bean(AdminProcessRegistry.NAME) | ||
fun adminProcessRegistry( | ||
processes: List<AdminProcess>? | ||
) = AdminProcessRegistry((processes ?: emptyList()).associateBy { it.activityId }) | ||
|
||
} |
38 changes: 0 additions & 38 deletions
38
src/main/kotlin/io/holunda/camunda/platform/adminprocess/form-fields.kt
This file was deleted.
Oops, something went wrong.
10 changes: 10 additions & 0 deletions
10
src/main/kotlin/io/holunda/camunda/platform/adminprocess/form/BooleanField.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package io.holunda.camunda.platform.adminprocess.form | ||
|
||
import io.holunda.camunda.bpm.data.CamundaBpmData | ||
|
||
data class BooleanField( | ||
override val id: String, | ||
override val label: String | ||
) : FormField<Boolean>(id, label, null, "boolean", CamundaBpmData.booleanVariable(id)) { | ||
|
||
} |
9 changes: 9 additions & 0 deletions
9
src/main/kotlin/io/holunda/camunda/platform/adminprocess/form/DateField.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package io.holunda.camunda.platform.adminprocess.form | ||
|
||
import io.holunda.camunda.bpm.data.CamundaBpmData | ||
import java.util.* | ||
|
||
data class DateField( | ||
override val id: String, | ||
override val label: String | ||
) : FormField<Date>(id, label, null, "date", CamundaBpmData.dateVariable(id)) |
34 changes: 34 additions & 0 deletions
34
src/main/kotlin/io/holunda/camunda/platform/adminprocess/form/FormField.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package io.holunda.camunda.platform.adminprocess.form | ||
|
||
import io.holunda.camunda.bpm.data.factory.VariableFactory | ||
import org.camunda.bpm.model.bpmn.builder.StartEventBuilder | ||
|
||
sealed class FormField<T>( | ||
/** | ||
* id of the formField, name of the variable | ||
*/ | ||
open val id: String, | ||
/** | ||
* label of the variable | ||
*/ | ||
open val label: String = id, | ||
/** | ||
* optional default value | ||
*/ | ||
open val defaultValue: T? = null, | ||
|
||
val type: String, | ||
/** | ||
* variable factory for simplified access. | ||
*/ | ||
private val variable: VariableFactory<T> | ||
) : VariableFactory<T> by variable { | ||
|
||
fun addToStartEvent(startEventBuilder: StartEventBuilder): StartEventBuilder = startEventBuilder.camundaFormField() | ||
.camundaLabel(label) | ||
.camundaType(type) | ||
.camundaId(id) | ||
//.camundaDefaultValue(defaultValue?.toString()) | ||
.camundaFormFieldDone() | ||
|
||
} |
8 changes: 8 additions & 0 deletions
8
src/main/kotlin/io/holunda/camunda/platform/adminprocess/form/LongField.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package io.holunda.camunda.platform.adminprocess.form | ||
|
||
import io.holunda.camunda.bpm.data.CamundaBpmData | ||
|
||
data class LongField( | ||
override val id: String, | ||
override val label: String | ||
) : FormField<Long>(id, label, null, "long", CamundaBpmData.longVariable(id)) |
8 changes: 8 additions & 0 deletions
8
src/main/kotlin/io/holunda/camunda/platform/adminprocess/form/StringField.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package io.holunda.camunda.platform.adminprocess.form | ||
|
||
import io.holunda.camunda.bpm.data.CamundaBpmData | ||
|
||
data class StringField( | ||
override val id: String, | ||
override val label: String | ||
) : FormField<String>(id, label, null, "string", CamundaBpmData.stringVariable(id)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ | ||
io.holunda.camunda.platform.adminprocess.CamundaAdminProcessAutoConfiguration | ||
io.holunda.camunda.platform.adminprocess.config.CamundaAdminProcessAutoConfiguration |
Empty file.
27 changes: 27 additions & 0 deletions
27
src/test/kotlin/io/holunda/camunda/platform/adminprocess/TestFixtures.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package io.holunda.camunda.platform.adminprocess | ||
|
||
import io.holunda.camunda.platform.adminprocess.form.FormField | ||
import org.camunda.bpm.model.bpmn.Bpmn | ||
import org.camunda.bpm.model.bpmn.BpmnModelInstance | ||
|
||
|
||
object TestFixtures { | ||
|
||
fun createProcess(field: FormField<*>) = Bpmn.createExecutableProcess() | ||
.startEvent() | ||
.apply { field.addToStartEvent(this) } | ||
.endEvent() | ||
.done() | ||
|
||
|
||
fun BpmnModelInstance.xml() = Bpmn.convertToString(this) | ||
|
||
fun String.extensionElements() = this | ||
.substringAfter("<extensionElements>") | ||
.substringBefore("</extensionElements>") | ||
.flatten() | ||
.trim().trimIndent() | ||
|
||
fun String.flatten() = this.lines().map { it.trim() } | ||
.joinToString("\n") | ||
} |
47 changes: 40 additions & 7 deletions
47
...holunda/camunda/platform/adminprocess/_test/CamundaAdminProcessRegistryTestApplication.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,72 @@ | ||
package io.holunda.camunda.platform.adminprocess._test | ||
|
||
import com.github.javafaker.Faker | ||
import io.holunda.camunda.bpm.data.CamundaBpmData | ||
import io.holunda.camunda.platform.adminprocess.AdminProcess | ||
import io.holunda.camunda.platform.adminprocess.AdminProcessRegistry.Companion.logger | ||
import io.holunda.camunda.platform.adminprocess.CamundaAdminProcessRegistryLib.adminProcess | ||
import io.holunda.camunda.platform.adminprocess.DateField | ||
import io.holunda.camunda.platform.adminprocess.StringField | ||
import io.holunda.camunda.platform.adminprocess.form.BooleanField | ||
import io.holunda.camunda.platform.adminprocess.form.DateField | ||
import io.holunda.camunda.platform.adminprocess.form.LongField | ||
import io.holunda.camunda.platform.adminprocess.form.StringField | ||
import org.camunda.bpm.spring.boot.starter.annotation.EnableProcessApplication | ||
import org.springframework.boot.autoconfigure.SpringBootApplication | ||
import org.springframework.boot.runApplication | ||
import org.springframework.context.annotation.Bean | ||
import java.time.Instant | ||
import java.time.temporal.ChronoUnit | ||
import java.util.* | ||
|
||
fun main(args: Array<String>) = runApplication<CamundaAdminProcessRegistryTestApplication>(*args).let { } | ||
|
||
data class SomeData( | ||
val id: String, | ||
val name: String, | ||
val age: Int | ||
) | ||
|
||
enum class SomeEnum(val id:String) { | ||
FOO("foo"), | ||
BAR("bar"), | ||
; | ||
} | ||
|
||
@SpringBootApplication | ||
@EnableProcessApplication | ||
class CamundaAdminProcessRegistryTestApplication { | ||
|
||
@Bean | ||
fun helloWorldAdminProcess(): AdminProcess { | ||
val foo = StringField("foo", "Foo - enter your name") | ||
val date = DateField("date", "Date - select some magic") | ||
val stringField = StringField("fooId", "Foo - enter your name") | ||
val dateField = DateField("dateId", "Date - select some magic") | ||
val numberField = LongField("longId", "A number") | ||
val booleanField = BooleanField("booleanId", "Yes or no?") | ||
|
||
return adminProcess( | ||
activityId = "helloWorld", | ||
label = "Hello World 2", | ||
formFields = listOf(foo, date) | ||
formFields = listOf(stringField, dateField, numberField, booleanField) | ||
) { | ||
val variables = CamundaBpmData.reader(it) | ||
|
||
logger.info { """ Hi, I am the process running with: | ||
* foo: ${variables.get(foo)} | ||
* date: ${variables.get(date)} | ||
* foo: ${variables.get(stringField)} | ||
* date: ${variables.get(dateField)} | ||
* number: ${variables.get(numberField)} | ||
* yes?: ${variables.get(booleanField)} | ||
""".trimIndent() | ||
} | ||
} | ||
} | ||
|
||
@Bean | ||
fun fake() = JFakerProvider() | ||
|
||
class JFakerProvider { | ||
private val faker = Faker(Locale.GERMAN) | ||
|
||
fun randomName(): String = faker.name().fullName() | ||
|
||
fun randomDate() : Date = Date.from(Instant.now().plus(10, ChronoUnit.DAYS)) | ||
} | ||
} |
Oops, something went wrong.