Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/1693 api v3 delete recreate #2055

Merged
merged 90 commits into from
May 24, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
90 commits
Select commit Hold shift + click to select a range
f1798b2
#1693 API v3: VersionedModel v3 init - VersionedModelControllerV3 bas…
dk1844 Mar 7, 2022
0f62851
#1693 API v3: some basic VersionedModelControllerV3 integration test
dk1844 Mar 7, 2022
c01cfda
#1693 API v3: VersionedModelControllerV3 integration test cont'd - te…
dk1844 Mar 8, 2022
4fd08e2
#1693 API v3: VersionedModelControllerV3 - post to yield location hea…
dk1844 Mar 21, 2022
5c8e005
#1693 API v3: VersionedModelControllerV3 - put to yield no content ->…
dk1844 Mar 23, 2022
458bfed
#1693 API v3: VersionedModelControllerV3 - IT for /ds/export (latest …
dk1844 Mar 23, 2022
a7a6cf9
#1693 API v3: VersionedModelControllerV3 - location header for put/po…
dk1844 Mar 23, 2022
af489b1
#1693 API v3: VersionedModelControllerV3 - location header for post-i…
dk1844 Mar 24, 2022
21f8008
#1693 API v3: VersionedModelControllerV3 -IT for GET datasets/{name},…
dk1844 Mar 24, 2022
6f63117
#1693 API v3: VersionedModelControllerV3 - IT for GET datasets/{name}…
dk1844 Mar 24, 2022
76e87ce
#1693 API v3: VersionedModelControllerV3 - GET /datasets/{name}/{vers…
dk1844 Mar 24, 2022
d62cd90
#1693 API v3: VersionedModelControllerV3 - common implementation of /…
dk1844 Mar 24, 2022
fc4c359
#1693 API v3: VersionedModelControllerV3 - /{name}/{version}/used-in …
dk1844 Mar 24, 2022
e6c8d8c
#1693 API v3: VersionedModelControllerV3 - GET/PUT /{name}/{version}/…
dk1844 Mar 29, 2022
3566df5
#1693 API v3: VersionedModelControllerV3 - GET/PUT /{name}/{version}/…
dk1844 Mar 30, 2022
219360a
#1693 Fix: (v2) VersionedModelController.getLatestVersionNumber(): Fu…
dk1844 Mar 30, 2022
112ac1e
#1693 VersionedModelControllerV3: `/{name}/{version}/validation` impl…
dk1844 Mar 30, 2022
101b37a
#1693 VersionedModelControllerV3 - IT extended for `POST /{name}/{ver…
dk1844 Mar 31, 2022
b934958
#1693 VersionedModelControllerV3 - conformance rule mgmt GET+POST dat…
dk1844 Apr 1, 2022
51ad013
#1693 PR review update - typos etc
dk1844 Apr 6, 2022
ba5edce
#1693 Validation-warnings as payload to caller in V3
dk1844 Apr 6, 2022
662119b
#1693 Validation-warnings as payload to caller in V3 - IT covered
dk1844 Apr 7, 2022
b0fd955
#1693 API v3 impl for MTs, no tests yet
dk1844 Apr 7, 2022
d480445
#1693 import validation check added to IT.
dk1844 Apr 7, 2022
bffbf55
Merge branch 'feature/1693-api-v3-versioned-model' into feature/1693-…
dk1844 Apr 7, 2022
3542a43
Merge branch 'develop-ver-3.0' into feature/1693-api-v3-versioned-model
dk1844 Apr 7, 2022
51d68a8
Merge branch 'feature/1693-api-v3-versioned-model' into feature/1693-…
dk1844 Apr 7, 2022
e1c904e
#1693 api-v3 mapping table specific - IntegTest for GET/POST/PUT .../…
dk1844 Apr 11, 2022
489ae12
#1693 api-v3 mapping table specific - MT now validates if schema exis…
dk1844 Apr 11, 2022
d6ef401
#1693 schema validation for DSs + IntegTest update
dk1844 Apr 11, 2022
a75ab85
#1693 Mt existence check for DS rules + reflecting in integTest
dk1844 Apr 11, 2022
6a16696
Merge branch 'feature/1693-api-v3-versioned-model' into feature/1693-…
dk1844 Apr 11, 2022
65b9f21
#1693 Mt existence check for DS rules + reflecting in integTest 2
dk1844 Apr 12, 2022
4426ff7
#1693 schema controller v3 - todo IT (original IT v2 works)
dk1844 Apr 14, 2022
fe6246c
#1693 schema controller v3 - partial IT - POST, .../json, .../origina…
dk1844 Apr 14, 2022
9241eb1
Merge branch 'develop-ver-3.0' into feature/1693-api-v3-versioned-model
dk1844 Apr 14, 2022
373bf1d
#1693 PropertyDefinitionControllerV3 - impl + IT for create;
dk1844 Apr 20, 2022
73bb8fd
#1693 admin rights required in VersionedModelControllerV3 -> reflecte…
dk1844 Apr 20, 2022
a2c5f40
#1693 admin rights required in VersionedModelControllerV3 -> ITs with…
dk1844 Apr 20, 2022
4d9f623
#1693 schema api v3: GET ... /json 400 with validation errors on empt…
dk1844 Apr 22, 2022
f410702
#1693 dataset v2 delete IT asserted to make sure there are regression…
dk1844 Apr 25, 2022
27b2e62
#1693 VersionedModelControllerV3 disable (DELETE .../{name}) + enable…
dk1844 Apr 25, 2022
1787692
#1693 Dataset V3 API enable/disable ITs + impl fix
dk1844 Apr 26, 2022
e4559b1
#1693 Schema V3 API enable/disable simple cases - no usedIn checks, yet
dk1844 Apr 26, 2022
cdbe7ae
#1693 VersionedModelControllerV3 - 2 levels of .../used-in exist ( /{…
dk1844 Apr 27, 2022
be02b5d
#1693 usedIn + delete for propertyDefinitions ref'd in Datasets + ITs…
dk1844 Apr 28, 2022
09c326e
#1693 PR review update 1
dk1844 Apr 28, 2022
5df526d
Merge branch 'feature/1693-api-v3-versioned-model' into feature/1693-…
dk1844 Apr 28, 2022
fd87e11
Merge branch 'feature/1693-api-v3-schema-etc' into feature/1693-api-v…
dk1844 Apr 28, 2022
8baf2d3
#1693 PR review update: SchemaService(V3) update/create behavior is e…
dk1844 Apr 29, 2022
0677bef
Merge branch 'feature/1693-api-v3-schema-etc' into feature/1693-api-v…
dk1844 Apr 29, 2022
a474054
#1693 cleanup
dk1844 Apr 29, 2022
c50a024
#1693 MT in MCR check - usedIn fix (originally from JS). IT test-case…
dk1844 Apr 29, 2022
32e48d0
#1693 UsedIn - empty/nonEmpty normalization + UnitTest. V2 alternated…
dk1844 Apr 29, 2022
1c241d1
#1693 DatasetService.updateProperties[V3] -> split between DatasetSer…
dk1844 May 3, 2022
bf15425
Merge branch 'feature/1693-api-v3-versioned-model' into feature/1693-…
dk1844 May 3, 2022
06e5c5f
Merge branch 'feature/1693-api-v3-schema-etc' into feature/1693-api-v…
dk1844 May 3, 2022
7fe2a93
#1693 PR review update: VersionedModelControllerV3 - GET /{name}/expo…
dk1844 May 4, 2022
56a9f0c
#1693 VersionedMongoRepository - unused method `getAllVersionsValues`…
dk1844 May 4, 2022
a4aac70
#1693 for V3 API: VersionedSummary -> NamedLatestVersion: impl + IT
dk1844 May 4, 2022
5d24819
#1693 PR review update: VersionedModelControllerV3 - GET /{name}/expo…
dk1844 May 4, 2022
7040694
#1693 VersionedMongoRepository - unused method `getAllVersionsValues`…
dk1844 May 4, 2022
e0fda73
#1693 for V3 API: VersionedSummary -> NamedLatestVersion: impl + IT
dk1844 May 4, 2022
2bfd751
Merge branch 'feature/1693-api-v3-versioned-model' into feature/1693-…
dk1844 May 4, 2022
a401024
Merge branch 'feature/1693-api-v3-schema-etc' into feature/1693-api-v…
dk1844 May 4, 2022
1da8e8c
#1693 PR review updates: renamings, comments, removed unused, formatt…
dk1844 May 5, 2022
7ae4acb
Merge branch 'feature/1693-api-v3-schema-etc' into feature/1693-api-v…
dk1844 May 5, 2022
9c3f663
#1693 PR review updates: `@PreAuthorize("@authConstants.hasAdminRole(…
dk1844 May 5, 2022
c72e559
Merge branch 'feature/1693-api-v3-schema-etc' into feature/1693-api-v…
dk1844 May 5, 2022
99ee67b
#1693 mergefix: admin-auth for PropDefs only.
dk1844 May 5, 2022
a80d9ac
#1693 Swagger differs in paths based on `spring.profiles.active` bein…
dk1844 May 6, 2022
f851bce
Merge branch 'feature/1693-api-v3-versioned-model' into feature/1693-…
dk1844 May 6, 2022
9679d56
Merge branch 'feature/1693-api-v3-schema-etc' into feature/1693-api-v…
dk1844 May 6, 2022
562da60
#1693 Swagger API: dev-profile: full v2+v3 API, non-dev: full v3 API
dk1844 May 9, 2022
fb0dd93
Merge branch 'feature/1693-api-v3-versioned-model' into feature/1693-…
dk1844 May 9, 2022
1a9c18b
Merge branch 'feature/1693-api-v3-schema-etc' into feature/1693-api-v…
dk1844 May 9, 2022
eac77dd
#1693 unused import cleanup
dk1844 May 9, 2022
db1227b
#1693 `NamedLatestVersion` generalized into a multipurpose `NamedVers…
dk1844 May 9, 2022
56ba9ed
#1693 PRReview `/{name}/{version}/defaults` processing generalization…
dk1844 May 9, 2022
28c7334
Merge branch 'feature/1693-api-v3-schema-etc' into feature/1693-api-v…
dk1844 May 9, 2022
619da37
Merge branch 'develop-ver-3.0' into feature/1693-api-v3-schema-etc
dk1844 May 9, 2022
67f163e
Merge branch 'feature/1693-api-v3-schema-etc' into feature/1693-api-v…
dk1844 May 9, 2022
9769f8d
Merge branch 'develop-ver-3.0' into feature/1693-api-v3-delete-recreate
dk1844 May 10, 2022
0ff6851
#1692 Review update: API v3 summary (NamedVersion) now contains `disa…
dk1844 May 12, 2022
4574b09
#1692 Review update: UsedIn.{isEmpty|nonEmpty} omitted from serializa…
dk1844 May 12, 2022
982e813
Merge branch 'develop-ver-3.0' into feature/1693-api-v3-delete-recreate
dk1844 May 16, 2022
006feb0
#1693 VersionedSummaryV2 Bson support fix
dk1844 May 17, 2022
2905892
#1693 VersionedSummaryV2 support fix - tests & impl
dk1844 May 17, 2022
e593df1
#1693 disable fail due to nonEmpty used in now carries a wrapper with…
dk1844 May 17, 2022
34292c4
#1693 `Future {throw x}` replaced with `Future.failed(x)` in rest_api…
dk1844 May 18, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,10 @@
package za.co.absa.enceladus.model.test.factories

import java.time.ZonedDateTime

import za.co.absa.enceladus.model.Dataset
import za.co.absa.enceladus.model.conformanceRule._
import za.co.absa.enceladus.model.menas.MenasReference
import za.co.absa.enceladus.model.versionedModel.VersionedSummary
import za.co.absa.enceladus.model.versionedModel.VersionedSummaryV2

object DatasetFactory extends EntityFactory[Dataset] {

Expand Down Expand Up @@ -127,8 +126,8 @@ object DatasetFactory extends EntityFactory[Dataset] {
MenasReference(collection, name, version)
}

def toSummary(dataset: Dataset): VersionedSummary = {
VersionedSummary(dataset.name, dataset.version)
def toSummaryV2(dataset: Dataset): VersionedSummaryV2 = {
VersionedSummaryV2(dataset.name, dataset.version)
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,7 @@

package za.co.absa.enceladus.model.versionedModel

case class NamedVersion(name: String, version: Int)
/**
* V3 Wrapper for [[za.co.absa.enceladus.model.versionedModel.VersionedSummary]]
*/
case class NamedVersion(name: String, version: Int, disabled: Boolean)
Zejnilovic marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,18 @@

package za.co.absa.enceladus.model.versionedModel

case class VersionedSummary(_id: String, latestVersion: Int) {
def toNamedVersion: NamedVersion = NamedVersion(_id, latestVersion)
/**
* V2 Representation of `VersionedSummary` - V2 does not carry disabled information
*/
case class VersionedSummaryV2(_id: String, latestVersion: Int)

case class VersionedSummary(_id: String, latestVersion: Int, disabledSet: Set[Boolean]) {
def toV2: VersionedSummaryV2 = VersionedSummaryV2(_id, latestVersion)

def toNamedVersion: NamedVersion = {
val disabled = disabledSet.contains(true) // legacy mixed state reported as disabled for V3 summary
NamedVersion(_id, latestVersion, disabled)
}
}


Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import za.co.absa.enceladus.rest_api.services.DatasetService
import za.co.absa.enceladus.utils.validation.ValidationLevel.ValidationLevel
import za.co.absa.enceladus.model.conformanceRule.ConformanceRule
import za.co.absa.enceladus.model.properties.PropertyDefinition
import za.co.absa.enceladus.model.versionedModel.VersionedSummary
import za.co.absa.enceladus.model.versionedModel.VersionedSummaryV2
import za.co.absa.enceladus.model.{Dataset, Validation}
import za.co.absa.enceladus.utils.validation.ValidationLevel.Constants.DefaultValidationLevelName

Expand All @@ -49,9 +49,9 @@ class DatasetController @Autowired()(datasetService: DatasetService)
@GetMapping(Array("/latest"))
@ResponseStatus(HttpStatus.OK)
def getLatestVersions(@RequestParam(value = "missing_property", required = false)
missingProperty: Optional[String]): CompletableFuture[Seq[VersionedSummary]] = {
missingProperty: Optional[String]): CompletableFuture[Seq[VersionedSummaryV2]] = {
datasetService.getLatestVersions(missingProperty.toScalaOption)
.map(datasets => datasets.map(dataset => VersionedSummary(dataset.name, dataset.version)))
.map(datasets => datasets.map(dataset => VersionedSummaryV2(dataset.name, dataset.version)))
}

@PostMapping(Array("/{datasetName}/rule/create"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import org.springframework.security.core.annotation.AuthenticationPrincipal
import org.springframework.security.core.userdetails.UserDetails
import org.springframework.web.bind.annotation._
import za.co.absa.enceladus.model.{ExportableObject, UsedIn}
import za.co.absa.enceladus.model.versionedModel._
import za.co.absa.enceladus.model.versionedModel.{VersionedModel, VersionedSummaryV2}
import za.co.absa.enceladus.rest_api.exceptions.NotFoundException
import za.co.absa.enceladus.rest_api.services.VersionedModelService
import za.co.absa.enceladus.model.menas.audit._
Expand All @@ -38,8 +38,9 @@ abstract class VersionedModelController[C <: VersionedModel with Product with Au

@GetMapping(Array("/list", "/list/{searchQuery}"))
@ResponseStatus(HttpStatus.OK)
def getList(@PathVariable searchQuery: Optional[String]): CompletableFuture[Seq[VersionedSummary]] = {
def getList(@PathVariable searchQuery: Optional[String]): CompletableFuture[Seq[VersionedSummaryV2]] = {
versionedModelService.getLatestVersionsSummarySearch(searchQuery.toScalaOption)
.map(_.map(_.toV2))
}

@GetMapping(Array("/searchSuggestions"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import org.mongodb.scala.model.Updates._
import org.mongodb.scala.model._
import org.mongodb.scala.result.UpdateResult
import za.co.absa.enceladus.model.menas._
import za.co.absa.enceladus.model.versionedModel.{VersionedModel, VersionedSummary}
import za.co.absa.enceladus.model.versionedModel.{VersionedModel, VersionedSummary, VersionedSummaryV2}

import scala.concurrent.Future
import scala.reflect.ClassTag
Expand Down Expand Up @@ -68,10 +68,13 @@ abstract class VersionedMongoRepository[C <: VersionedModel](mongoDb: MongoDatab
}
val pipeline = Seq(
filter(Filters.and(searchFilter, getNotDisabledFilter)),
Aggregates.group("$name", Accumulators.max("latestVersion", "$version")),
Aggregates.group("$name",
Accumulators.max("latestVersion", "$version")
),
sort(Sorts.ascending("_id"))
)
collection.aggregate[VersionedSummary](pipeline).toFuture()
collection.aggregate[VersionedSummaryV2](pipeline).toFuture()
.map(_.map(summaryV2 => VersionedSummary(summaryV2._id, summaryV2.latestVersion, Set(true)))) // because of the notDisabled filter
}

def getLatestVersions(missingProperty: Option[String]): Future[Seq[C]] = {
Expand All @@ -90,7 +93,10 @@ abstract class VersionedMongoRepository[C <: VersionedModel](mongoDb: MongoDatab
def getLatestVersionSummary(name: String): Future[Option[VersionedSummary]] = {
val pipeline = Seq(
filter(getNameFilter(name)),
Aggregates.group("$name", Accumulators.max("latestVersion", "$version"))
Aggregates.group("$name",
Accumulators.max("latestVersion", "$version"),
Accumulators.addToSet("disabledSet", "$disabled")
)
)
collection.aggregate[VersionedSummary](pipeline).headOption()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,29 @@ class DatasetControllerV3IntegrationSuite extends BaseRestApiTestV3 with BeforeA

val response = sendGet[NamedVersion](s"$apiUrl/datasetA")
assertOk(response)
assert(response.getBody == NamedVersion("datasetA", 2))
assert(response.getBody == NamedVersion("datasetA", 2, disabled = false))
}

"a Dataset with the given name exists - all disabled" in {
schemaFixture.add(SchemaFactory.getDummySchema("dummySchema"))
val datasetV1 = DatasetFactory.getDummyDataset(name = "datasetA", version = 1, disabled = true)
val datasetV2 = DatasetFactory.getDummyDataset(name = "datasetA", version = 2, disabled = true)
datasetFixture.add(datasetV1, datasetV2)

val response = sendGet[NamedVersion](s"$apiUrl/datasetA")
assertOk(response)
assert(response.getBody == NamedVersion("datasetA", 2, disabled = true))
}

"a Dataset with with mixed disabled states" in {
schemaFixture.add(SchemaFactory.getDummySchema("dummySchema"))
val datasetV1 = DatasetFactory.getDummyDataset(name = "datasetA", version = 1)
val datasetV2 = DatasetFactory.getDummyDataset(name = "datasetA", version = 2, disabled = true)
datasetFixture.add(datasetV1, datasetV2)

val response = sendGet[NamedVersion](s"$apiUrl/datasetA")
assertOk(response)
assert(response.getBody == NamedVersion("datasetA", 2, disabled = true)) // mixed state -> disabled
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ class PropertyDefinitionControllerV3IntegrationSuite extends BaseRestApiTestV3 w

val response = sendGet[NamedVersion](s"$apiUrl/pdA")
assertOk(response)
assert(response.getBody == NamedVersion("pdA", 2))
assert(response.getBody == NamedVersion("pdA", 2, disabled = false))
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,7 @@ class DatasetRepositoryIntegrationSuite extends BaseRepositoryTest with Matchers
datasetFixture.add(dataset2, dataset3, dataset4, dataset5)
val actual = await(datasetMongoRepository.getLatestVersionsSummarySearch(Some("dataset2")))

val expected = Seq(dataset3).map(DatasetFactory.toSummary)
val expected = Seq(dataset3).map(DatasetFactory.toSummaryV2)
assert(actual == expected)
}
"search query is a partial match" in {
Expand All @@ -512,7 +512,7 @@ class DatasetRepositoryIntegrationSuite extends BaseRepositoryTest with Matchers
datasetFixture.add(dataset2, dataset3, dataset4, dataset5)
val actual = await(datasetMongoRepository.getLatestVersionsSummarySearch(Some("tas")))

val expected = Seq(dataset3, dataset4).map(DatasetFactory.toSummary)
val expected = Seq(dataset3, dataset4).map(DatasetFactory.toSummaryV2)
assert(actual == expected)
}

Expand Down Expand Up @@ -548,7 +548,7 @@ class DatasetRepositoryIntegrationSuite extends BaseRepositoryTest with Matchers
datasetFixture.add(dataset1ver1, dataset1ver2, dataset2ver1, abc1)
val actual = await(datasetMongoRepository.getLatestVersionsSummarySearch(Some("")))

val expected = Seq(abc1, dataset1ver2, dataset2ver1).map(DatasetFactory.toSummary)
val expected = Seq(abc1, dataset1ver2, dataset2ver1).map(DatasetFactory.toSummaryV2)
assert(actual == expected)
}
}
Expand All @@ -565,7 +565,7 @@ class DatasetRepositoryIntegrationSuite extends BaseRepositoryTest with Matchers

val actual = await(datasetMongoRepository.getLatestVersionsSummarySearch(None))

val expected = Seq(dataset1ver2, dataset2ver2).map(DatasetFactory.toSummary)
val expected = Seq(dataset1ver2, dataset2ver2).map(DatasetFactory.toSummaryV2)
assert(actual == expected)
}
}
Expand All @@ -579,11 +579,11 @@ class DatasetRepositoryIntegrationSuite extends BaseRepositoryTest with Matchers
}
"returns even the disabled dataset" when {
"only disabled dataset exists" in {
val dataset1 = DatasetFactory.getDummyDataset(name = "datasetA", disabled = true)
val dataset1 = DatasetFactory.getDummyDataset(name = "datasetA", disabled = false)
val dataset2 = DatasetFactory.getDummyDataset(name = "datasetA", disabled = true, version = 2)
datasetFixture.add(dataset1, dataset2)
val actual = await(datasetMongoRepository.getLatestVersionSummary("datasetA"))
actual shouldBe Some(VersionedSummary("datasetA", 2)) // warning: currently, this method reports the disabled, too
actual shouldBe Some(VersionedSummary("datasetA", 2, Set(true, false)))
}
}

Expand All @@ -595,7 +595,7 @@ class DatasetRepositoryIntegrationSuite extends BaseRepositoryTest with Matchers
datasetFixture.add(dataset1, dataset2, dataset3)

val actual = await(datasetMongoRepository.getLatestVersionSummary("datasetA"))
actual shouldBe Some(VersionedSummary("datasetA", 3))
actual shouldBe Some(VersionedSummary("datasetA", 3, Set(false)))
}
}
}
Expand Down