Skip to content

Commit

Permalink
[netcdf] Validate both kinds of NetCdf
Browse files Browse the repository at this point in the history
  • Loading branch information
mirzov committed Apr 24, 2024
1 parent a71a77a commit 7e0c4ae
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/main/scala/se/lu/nateko/cp/data/api/MetaVocab.scala
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ object CpMetaVocab extends MetaVocab(new URI("http://meta.icos-cp.eu/ontologies/
val excel = getRelative("excel")

def isNonIngestedZip(objFormat: URI): Boolean = objFormat == arbitraryZip || objFormat == excel
def isNetCdfSpatial(objFormat: URI): Boolean = objFormat == netCdfSpatial
def isNetCdf(objFormat: URI): Boolean = objFormat == netCdfSpatial || objFormat == netCdfTimeSer
}

def getDataObject(hash: Sha256Sum)(using envri: EnvriConfig) =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import akka.stream.scaladsl.FileIO
import akka.stream.scaladsl.Sink
import akka.stream.scaladsl.Source
import akka.util.ByteString
import eu.icoscp.envri.Envri
import se.lu.nateko.cp.cpauth.core.UserId
import se.lu.nateko.cp.data.NetCdfConfig
import se.lu.nateko.cp.data.UploadConfig
Expand All @@ -30,13 +31,11 @@ import scala.concurrent.ExecutionContext
import scala.concurrent.Future
import scala.util.Failure
import scala.util.Success
import eu.icoscp.envri.Envri
import se.lu.nateko.cp.data.api.CpMetaVocab.ObjectFormats.isNetCdfSpatial

class UploadService(config: UploadConfig, netcdfConf: NetCdfConfig, val meta: MetaClient)(using Materializer) {

import UploadService.*
import ObjectFormats.{isNonIngestedZip, netCdfTimeSer}
import ObjectFormats.{isNonIngestedZip, isNetCdf, netCdfTimeSer}
import meta.{ dispatcher, system }

val log = system.log
Expand Down Expand Up @@ -220,7 +219,7 @@ class UploadService(config: UploadConfig, netcdfConf: NetCdfConfig, val meta: Me
if spec.datasetSpec.isEmpty then
if isNonIngestedZip(spec.format.self.uri) then
Future.successful(new ZipValidatingUploadTask)
else if isNetCdfSpatial(spec.format.self.uri) then
else if isNetCdf(spec.format.self.uri) then
Future.successful(new NetCdfValidatingUploadTask)
else
if isTryIngest then
Expand Down

0 comments on commit 7e0c4ae

Please sign in to comment.