All Downloads are FREE. Search and download functionalities are using the official Maven repository.

camundala.helper.openApi.BpmnSuperClassGenerator.scala Maven / Gradle / Ivy

There is a newer version: 1.30.23
Show newest version
package camundala.helper.openApi

case class BpmnSuperClassGenerator()(using
    val apiDefinition: ApiDefinition,
    val config: OpenApiConfig
) extends GeneratorHelper:

  val allSchemas = Map.empty[String, Schema[?]]
  val name = config.superClassName(superClass.versionTag).getOrElse(superClass.name)

  def generate =
    os.remove.all(bpmnPath)
    os.makeDir.all(bpmnPath)
    os.write.over(bpmnPath / s"$name.scala", content)
    // println(content)
    name
  end generate

  private lazy val content =
    s"""package $bpmnPackage
       |
       |object $name:
       |
       |  final val serviceLabel = "${superClass.title} ${superClass.versionTag}"
       |  val description = ${optionalText(superClass.descr)}
       |  val externalDoc = ${optionalText(superClass.externalDescr)}
       |  val externalUrl = ${optionalText(superClass.externalUrl)}
       |
       |trait $name
       |  extends ${config.superBpmnClass}:
       |  final val serviceLabel = $name.serviceLabel
       |  val serviceVersion = "${superClass.version.getOrElse("-")}"
       |end $name
       |""".stripMargin

  private def optionalText(text: Option[String]): String =
    text.map(d => s"""Some("$d")""").getOrElse("None")
end BpmnSuperClassGenerator




© 2015 - 2024 Weber Informatics LLC | Privacy Policy