-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: wrapped id cc into Wrapper with companion objects
Ioann Kurchin
committed
Feb 21, 2022
1 parent
ac85bbc
commit 447c854
Showing
44 changed files
with
225 additions
and
133 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
32 changes: 32 additions & 0 deletions
32
model/src/main/scala/cromwell/pipeline/model/wrapper/ProjectConfigurationId.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,32 @@ | ||
package cromwell.pipeline.model.wrapper | ||
|
||
import cats.data.{ NonEmptyChain, Validated } | ||
import cromwell.pipeline.model.validator.Wrapped | ||
import slick.lifted.MappedTo | ||
|
||
import java.util.UUID | ||
|
||
final class ProjectConfigurationId private (override val unwrap: String) | ||
extends AnyVal | ||
with Wrapped[String] | ||
with MappedTo[String] { | ||
override def value: String = unwrap | ||
} | ||
|
||
object ProjectConfigurationId extends Wrapped.Companion { | ||
override type Type = String | ||
override type Wrapper = ProjectConfigurationId | ||
override type Error = String | ||
|
||
val pattern: String = "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$" | ||
|
||
def randomId: ProjectConfigurationId = new ProjectConfigurationId(UUID.randomUUID().toString) | ||
|
||
override protected def create(value: String): ProjectConfigurationId = new ProjectConfigurationId(value) | ||
|
||
override protected def validate(value: String): ValidationResult[String] = Validated.cond( | ||
value.matches(pattern), | ||
value, | ||
NonEmptyChain.one("Invalid ProjectConfigurationId") | ||
) | ||
} |
31 changes: 31 additions & 0 deletions
31
model/src/main/scala/cromwell/pipeline/model/wrapper/ProjectId.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,31 @@ | ||
package cromwell.pipeline.model.wrapper | ||
|
||
import cats.data.{ NonEmptyChain, Validated } | ||
import cromwell.pipeline.model.validator.Wrapped | ||
import play.api.libs.json.Format | ||
import slick.lifted.MappedTo | ||
|
||
import java.util.UUID.randomUUID | ||
|
||
final class ProjectId private (override val unwrap: String) extends AnyVal with Wrapped[String] with MappedTo[String] { | ||
override def value: String = unwrap | ||
} | ||
|
||
object ProjectId extends Wrapped.Companion { | ||
type Type = String | ||
type Wrapper = ProjectId | ||
type Error = String | ||
|
||
implicit lazy val projectIdFormat: Format[ProjectId] = wrapperFormat | ||
|
||
val pattern: String = "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$" | ||
|
||
override protected def create(value: String): ProjectId = new ProjectId(value) | ||
override protected def validate(value: String): ValidationResult[String] = Validated.cond( | ||
value.matches(pattern), | ||
value, | ||
NonEmptyChain.one("Invalid ProjectId") | ||
) | ||
|
||
def random: ProjectId = new ProjectId(randomUUID().toString) | ||
} |
27 changes: 27 additions & 0 deletions
27
model/src/main/scala/cromwell/pipeline/model/wrapper/RepositoryId.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,27 @@ | ||
package cromwell.pipeline.model.wrapper | ||
|
||
import cats.data.{ NonEmptyChain, Validated } | ||
import cromwell.pipeline.model.validator.Wrapped | ||
import play.api.libs.json.Format | ||
import slick.lifted.MappedTo | ||
|
||
final case class RepositoryId(override val unwrap: Int) extends AnyVal with MappedTo[Int] with Wrapped[Int] { | ||
override def value: Int = unwrap | ||
} | ||
|
||
object RepositoryId extends Wrapped.Companion { | ||
type Type = Int | ||
type Wrapper = RepositoryId | ||
type Error = String | ||
|
||
implicit lazy val repositoryIdFormat: Format[RepositoryId] = wrapperFormat | ||
|
||
val pattern = "^[0-9]+$" | ||
|
||
override protected def create(value: Int): RepositoryId = new RepositoryId(value) | ||
override protected def validate(value: Int): ValidationResult[Int] = Validated.cond( | ||
value >= 0, | ||
value, | ||
NonEmptyChain.one("Value should be not negative integer") | ||
) | ||
} |
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
6 changes: 3 additions & 3 deletions
6
repositories/src/main/scala/cromwell/pipeline/datastorage/dao/entry/RunEntry.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
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
2 changes: 1 addition & 1 deletion
2
repositories/src/main/scala/cromwell/pipeline/datastorage/dto/CromwellInput.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
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
1 change: 1 addition & 0 deletions
1
repositories/src/main/scala/cromwell/pipeline/datastorage/dto/ProjectResponse.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
2 changes: 1 addition & 1 deletion
2
repositories/src/main/scala/cromwell/pipeline/datastorage/dto/Run.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
2 changes: 1 addition & 1 deletion
2
...ala/cromwell/pipeline/datastorage/dao/repository/ProjectConfigurationRepositoryTest.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
3 changes: 2 additions & 1 deletion
3
...ll/pipeline/datastorage/dao/repository/impls/ProjectConfigurationRepositoryTestImpl.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
4 changes: 2 additions & 2 deletions
4
.../scala/cromwell/pipeline/datastorage/dao/repository/impls/ProjectRepositoryTestImpl.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
4 changes: 2 additions & 2 deletions
4
...test/scala/cromwell/pipeline/datastorage/dao/repository/impls/RunRepositoryTestImpl.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
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
2 changes: 1 addition & 1 deletion
2
services/src/main/scala/cromwell/pipeline/service/ProjectFileService.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
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
2 changes: 1 addition & 1 deletion
2
.../src/test/scala/cromwell/pipeline/service/impls/ProjectConfigurationServiceTestImpl.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
2 changes: 1 addition & 1 deletion
2
services/src/test/scala/cromwell/pipeline/service/impls/ProjectFileServiceTestImpl.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
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
4 changes: 2 additions & 2 deletions
4
services/src/test/scala/cromwell/pipeline/service/impls/RunServiceTestImpl.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