-
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.
Pass configuration for metadata back to client
Provide calling client with configuration for metadata for the transfer Configuration driven by the relevant schema
- Loading branch information
Showing
9 changed files
with
62 additions
and
9 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
18 changes: 18 additions & 0 deletions
18
.../uk/gov/nationalarchives/tdr/transfer/service/services/schema/MetadataConfiguration.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,18 @@ | ||
package uk.gov.nationalarchives.tdr.transfer.service.services.schema | ||
|
||
import uk.gov.nationalarchives.tdr.transfer.service.api.model.LoadModel.MetadataPropertyDetails | ||
|
||
import scala.jdk.CollectionConverters._ | ||
|
||
object MetadataConfiguration { | ||
def metadataConfiguration(): Set[MetadataPropertyDetails] = { | ||
val schema = SchemaHandler.schema().get("allOf") | ||
val properties = schema.get(0).get("properties").properties().asScala | ||
val requiredProperties = schema.get(0).get("required").asScala.map(_.asText()).toSet | ||
properties | ||
.map(p => { | ||
MetadataPropertyDetails(p.getKey, requiredProperties.contains(p.getKey)) | ||
}) | ||
.toSet | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
...in/scala/uk/gov/nationalarchives/tdr/transfer/service/services/schema/SchemaHandler.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,16 @@ | ||
package uk.gov.nationalarchives.tdr.transfer.service.services.schema | ||
|
||
import com.fasterxml.jackson.databind.{JsonNode, ObjectMapper} | ||
|
||
import java.io.InputStream | ||
|
||
object SchemaHandler { | ||
private def getJsonNodeFromStreamContent(content: InputStream): JsonNode = { | ||
val mapper = new ObjectMapper() | ||
mapper.readTree(content) | ||
} | ||
|
||
def schema(schemaLocation: String = "/metadata-schema/dataLoadSharePointSchema.schema.json"): JsonNode = { | ||
getJsonNodeFromStreamContent(getClass.getResourceAsStream(schemaLocation)) | ||
} | ||
} |
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