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

db.migration.V1_013__GroupNodesChange.scala Maven / Gradle / Ivy

There is a newer version: 1.17.0
Show newest version
package db.migration

import io.circe.Json._
import io.circe._
import pl.touk.nussknacker.ui.db.migration.ProcessJsonMigration

trait V1_013__GroupNodesChange extends ProcessJsonMigration {

  override def updateProcessJson(jsonProcess: Json): Option[Json] =
    jsonProcess.hcursor
      .downField("metaData")
      .downField("additionalFields")
      .downField("groups")
      .withFocus(updateGroups)
      .top

  private def updateGroups(groups: Json): Json = fromValues(groups.asArray.getOrElse(List()).map { group =>
    group.arrayOrObject(group, transformGroupArray, _ => group)
  })

  private def transformGroupArray(array: Vector[Json]) =
    obj("id" -> fromString(array.map(_.asString.getOrElse("")).mkString("-")), "nodes" -> fromValues(array))

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy