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

pl.touk.nussknacker.ui.process.deployment.ScenarioResolver.scala Maven / Gradle / Ivy

There is a newer version: 1.17.0
Show newest version
package pl.touk.nussknacker.ui.process.deployment

import cats.data.ValidatedNel
import pl.touk.nussknacker.engine.api.process.ProcessingType
import pl.touk.nussknacker.engine.canonicalgraph.CanonicalProcess
import pl.touk.nussknacker.ui.process.fragment.FragmentResolver
import pl.touk.nussknacker.ui.security.api.LoggedUser

import scala.util.{Failure, Success, Try}

// The purpose of this class is to do the whole preprocessing of a scenario. The preprocessing is currently based on the two steps:
// - disabled nodes removal
// - fragments resolution
class ScenarioResolver(fragmentResolver: FragmentResolver, processingType: ProcessingType) {

  def resolveScenario(canonical: CanonicalProcess)(
      implicit user: LoggedUser
  ): Try[CanonicalProcess] =
    toTry(fragmentResolver.resolveFragments(canonical.withoutDisabledNodes, processingType))

  private def toTry[E, A](validated: ValidatedNel[E, A]) =
    validated.map(Success(_)).valueOr(e => Failure(new RuntimeException(e.head.toString)))

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy