Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
fix(cardinality): Check cardinality with multiple inherited classes (D…
…EV-1189) (#2164) * check that always the stricter cardinality is taken * add unit tests * remove replaced method * add comments * introduce value objects for cardinalities * check cardinality compatibility in case of multiple super classes * fix error message * clean up docstrings * fix broken docs link * remove unused project * fix error in docs * add testdata and tests * fix build.sbt * simplify test data * improve comments * cleanup imports * fix bad references for coverage * improve comments * reintroduce return * wrap case objects * simplify test * fix missing import * implement feedback from review * run scalafmt Co-authored-by: Ivan Subotic <400790+subotic@users.noreply.github.com>
- Loading branch information
Showing
46 changed files
with
672 additions
and
426 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
68 changes: 68 additions & 0 deletions
68
dsp-schema/core/src/main/scala/dsp/schema/domain/SchemaDomain.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,68 @@ | ||
/* | ||
* Copyright © 2021 - 2022 Data and Service Center for the Humanities and/or DaSCH Service Platform contributors. | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package dsp.schema.domain | ||
|
||
import Cardinality._ | ||
|
||
/** | ||
* Represents a cardinality value object. | ||
*/ | ||
sealed trait Cardinality { self => | ||
|
||
/** | ||
* The string representation of the cardinality | ||
*/ | ||
val value: String | ||
|
||
/** | ||
* Checks whether a cardinality is stricter than another one. | ||
* | ||
* @param that the cardinality to be compared against | ||
* @return `true` if the present cardinality is stricter than `that`, `false` otherwise | ||
*/ | ||
def isStricterThan(that: Cardinality): Boolean = | ||
if (self == that) { | ||
false | ||
} else { | ||
self match { | ||
case MustHaveOne => true | ||
case MustHaveSome => that == MayHaveMany | ||
case MayHaveOne => that == MayHaveMany | ||
case MayHaveMany => false | ||
} | ||
} | ||
} | ||
|
||
object Cardinality { | ||
|
||
/** | ||
* The cardinality of a property that must have one value. | ||
*/ | ||
final case object MustHaveOne extends Cardinality { | ||
override val value: String = "1" | ||
} | ||
|
||
/** | ||
* The cardinality of a property that must have at least one value. | ||
*/ | ||
final case object MustHaveSome extends Cardinality { | ||
override val value: String = "1-n" | ||
} | ||
|
||
/** | ||
* The cardinality of a property that may have one value. | ||
*/ | ||
final case object MayHaveOne extends Cardinality { | ||
override val value: String = "0-1" | ||
} | ||
|
||
/** | ||
* The cardinality of a property that may have one or more values. | ||
*/ | ||
final case object MayHaveMany extends Cardinality { | ||
override val value: String = "0-n" | ||
} | ||
} |
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: 1 addition & 3 deletions
4
dsp-schema/core/src/main/scala/dsp/schema/handler/CreateSchema.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 |
---|---|---|
@@ -1,5 +1,3 @@ | ||
package dsp.schema.handler | ||
|
||
object CreateSchema { | ||
|
||
} | ||
object CreateSchema {} |
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.