forked from BlueBrain/nexus
-
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.
Add reference check on project / add endpoint back (BlueBrain#3859)
* Add reference check on project / add endpoint back --------- Co-authored-by: Simon Dumas <[email protected]>
- Loading branch information
Showing
27 changed files
with
298 additions
and
89 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
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
34 changes: 34 additions & 0 deletions
34
...dk/src/main/scala/ch/epfl/bluebrain/nexus/delta/sdk/projects/ProjectReferenceFinder.scala
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 ch.epfl.bluebrain.nexus.delta.sdk.projects | ||
|
||
import ch.epfl.bluebrain.nexus.delta.kernel.database.Transactors | ||
import ch.epfl.bluebrain.nexus.delta.sdk.projects.model.ProjectRejection.ProjectIsReferenced | ||
import ch.epfl.bluebrain.nexus.delta.sourcing.EntityDependencyStore | ||
import ch.epfl.bluebrain.nexus.delta.sourcing.model.EntityDependency.ReferencedBy | ||
import ch.epfl.bluebrain.nexus.delta.sourcing.model.ProjectRef | ||
import monix.bio.{IO, UIO} | ||
|
||
/** | ||
* Allows to find reference of a project in other projects | ||
*/ | ||
trait ProjectReferenceFinder { | ||
|
||
/** | ||
* Check if a given project is not referenced by another one | ||
* @param project | ||
* the project to check | ||
*/ | ||
def raiseIfAny(project: ProjectRef): IO[ProjectIsReferenced, Unit] | ||
} | ||
|
||
object ProjectReferenceFinder { | ||
|
||
def apply(xas: Transactors): ProjectReferenceFinder = | ||
apply(EntityDependencyStore.directExternalReferences(_, xas)) | ||
|
||
def apply(fetchReferences: ProjectRef => UIO[Set[ReferencedBy]]): ProjectReferenceFinder = | ||
(project: ProjectRef) => | ||
fetchReferences(project).flatMap { references => | ||
IO.raiseWhen(references.nonEmpty)(ProjectIsReferenced(project, references)) | ||
} | ||
|
||
} |
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
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
Oops, something went wrong.