Skip to content

Commit

Permalink
Merge pull request #557 from SciCatProject/swap-3349
Browse files Browse the repository at this point in the history
Swap 3349 - Issue 450
  • Loading branch information
nitrosx authored Jun 15, 2023
2 parents b9aa0d3 + f067c63 commit e64f9d6
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 8 deletions.
39 changes: 39 additions & 0 deletions src/datablocks/dto/create-datablock.dto.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { ApiProperty } from "@nestjs/swagger";
import { Type } from "class-transformer";
import {
ArrayNotEmpty,
IsArray,
IsInt,
IsNotEmpty,
IsOptional,
IsString,
ValidateNested,
Expand All @@ -12,22 +14,59 @@ import { OwnableDto } from "src/common/dto/ownable.dto";
import { DataFile } from "src/common/schemas/datafile.schema";

export class CreateDatablockDto extends OwnableDto {
@ApiProperty({
type: String,
required: true,
description:
"Persistent identifier of the dataset this orig datablock belongs to.",
})
@IsString()
readonly datasetId: string;

@ApiProperty({
type: String,
required: true,
description:
"Unique identifier given by the archive system to the stored datablock. This id is used when data is retrieved back.",
})
@IsString()
readonly archiveId: string;

@ApiProperty({
type: Number,
required: true,
description:
"Total size in bytes of all files in the datablock when on accessible.",
})
@IsInt()
readonly size: number;

@ApiProperty({
type: Number,
required: true,
description:
"Total size in bytes of all files in the datablock when on archived.",
})
@IsInt()
readonly packedSize: number;

@ApiProperty({
type: String,
required: false,
description:
"Name of the hasing algorithm used to compute the hash for each file.",
})
@IsOptional()
@IsString()
@IsNotEmpty()
readonly chkAlg: string;

@ApiProperty({
type: String,
required: true,
description:
"Version string defining the format of how data is packed and stored in archive.",
})
@IsString()
readonly version: string;

Expand Down
21 changes: 15 additions & 6 deletions src/datablocks/schemas/datablock.schema.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Prop, Schema, SchemaFactory } from "@nestjs/mongoose";
import { ApiProperty } from "@nestjs/swagger";
import { ApiProperty, getSchemaPath } from "@nestjs/swagger";
import { DataFile, DataFileSchema } from "src/common/schemas/datafile.schema";
import { OwnableClass } from "src/common/schemas/ownable.schema";
import { v4 as uuidv4 } from "uuid";
Expand Down Expand Up @@ -35,6 +35,7 @@ export class Datablock extends OwnableClass {

@ApiProperty({
type: String,
required: true,
description:
"Unique identifier given by the archive system to the stored datablock. This id is used when data is retrieved back.",
})
Expand All @@ -50,7 +51,7 @@ export class Datablock extends OwnableClass {
type: Number,
required: true,
description:
"Total size in bytes of all files in the datablock when unpacked.",
"Total size in bytes of all files in the datablock when on accessible.",
})
@Prop({
type: Number,
Expand All @@ -61,7 +62,8 @@ export class Datablock extends OwnableClass {
@ApiProperty({
type: Number,
required: true,
description: "Size of the datablock package file.",
description:
"Total size in bytes of all files in the datablock when on archived.",
})
@Prop({
type: Number,
Expand All @@ -71,6 +73,7 @@ export class Datablock extends OwnableClass {

@ApiProperty({
type: String,
required: false,
description:
"Algorithm used for calculation of file checksums. Should be lowercase, e.g., sha2 or blake2b.",
})
Expand All @@ -82,6 +85,7 @@ export class Datablock extends OwnableClass {

@ApiProperty({
type: String,
required: true,
description:
"Version string defining the format of how data is packed and stored in archive.",
})
Expand All @@ -92,10 +96,15 @@ export class Datablock extends OwnableClass {
version: string;

@ApiProperty({
description:
"Embedded schema definition for which fields are required for each file.",
type: "array",
items: { $ref: getSchemaPath(DataFile) },
required: true,
description: "Embedded schema definition for each file.",
})
@Prop({
type: [DataFileSchema],
required: true,
})
@Prop([DataFileSchema])
dataFileList: DataFile[];
}

Expand Down
10 changes: 8 additions & 2 deletions src/origdatablocks/schemas/origdatablock.schema.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Prop, Schema, SchemaFactory } from "@nestjs/mongoose";
import { ApiProperty } from "@nestjs/swagger";
import { ApiProperty, getSchemaPath } from "@nestjs/swagger";
import { OwnableClass } from "src/common/schemas/ownable.schema";
import { v4 as uuidv4 } from "uuid";
import { DataFile, DataFileSchema } from "../../common/schemas/datafile.schema";
Expand Down Expand Up @@ -59,9 +59,15 @@ export class OrigDatablock extends OwnableClass {
chkAlg: string;

@ApiProperty({
type: "array",
items: { $ref: getSchemaPath(DataFile) },
required: true,
description: "Embedded schema definitions for each file.",
})
@Prop([DataFileSchema])
@Prop({
type: [DataFileSchema],
required: true,
})
dataFileList: DataFile[];
}

Expand Down

0 comments on commit e64f9d6

Please sign in to comment.