- add references, collections and identifiers to dataset model
All checks were successful
CI Pipeline / japa-tests (push) Successful in 52s

- npm updates
This commit is contained in:
Kaimbacher 2023-08-23 17:07:26 +02:00
parent f6d735d0fd
commit 5f8fe1c16d
9 changed files with 459 additions and 346 deletions

View file

@ -7,6 +7,7 @@ import Title from 'App/Models/Title';
import Description from 'App/Models/Description';
import Language from 'App/Models/Language';
import Coverage from 'App/Models/Coverage';
import Collection from 'App/Models/Collection';
// import CreateUserValidator from 'App/Validators/CreateUserValidator';
// import UpdateUserValidator from 'App/Validators/UpdateUserValidator';
import { schema, CustomMessages, rules } from '@ioc:Adonis/Core/Validator';
@ -48,6 +49,14 @@ export default class DatasetController {
datasets.orderBy('id', 'asc');
}
// const results = await Database
// .query()
// .select(Database.raw("CONCAT('https://doi.org/', b.value) AS concatenated_value"))
// .from('documents as doc')
// .innerJoin('dataset_identifiers as b', 'doc.id', 'b.dataset_id')
// .groupBy('a.id').toQuery();
// const users = await User.query().orderBy('login').paginate(page, limit);
const myDatasets = await datasets
.whereIn('server_state', [
@ -117,10 +126,8 @@ export default class DatasetController {
.map(([key, value]) => ({ value: key, label: value })),
// descriptiontypes: DescriptionTypes
projects: projects,
referenceIdentifierTypes: Object.entries(ReferenceIdentifierTypes)
.map(([key, value]) => ({ value: key, label: value })),
relationTypes: Object.entries(RelationTypes)
.map(([key, value]) => ({ value: key, label: value })),
referenceIdentifierTypes: Object.entries(ReferenceIdentifierTypes).map(([key, value]) => ({ value: key, label: value })),
relationTypes: Object.entries(RelationTypes).map(([key, value]) => ({ value: key, label: value })),
});
}
@ -245,15 +252,12 @@ export default class DatasetController {
depth_min: schema.number.optional([rules.requiredIfExists('depth_max')]),
depth_max: schema.number.optional([rules.requiredIfExists('depth_min')]),
}),
references: schema.array([rules.uniqueArray('value')]).members(
references: schema.array.optional([rules.uniqueArray('value')]).members(
schema.object().members({
value: schema.string({ trim: true }, [
rules.minLength(3),
rules.maxLength(255),
]),
value: schema.string({ trim: true }, [rules.minLength(3), rules.maxLength(255)]),
type: schema.enum(Object.values(ReferenceIdentifierTypes)),
relation: schema.enum(Object.values(RelationTypes)),
// language: schema.string({ trim: true }, [rules.minLength(2), rules.maxLength(255)]),
label: schema.string({ trim: true }, [rules.minLength(2), rules.maxLength(255)]),
}),
),
subjects: schema.array([rules.minLength(3), rules.uniqueArray('value')]).members(
@ -404,6 +408,10 @@ export default class DatasetController {
}
}
// save collection
const collection: Collection | null = await Collection.query().where('id', 21).first();
collection && (await dataset.useTransaction(trx).related('collections').attach([collection.id]));
// save coverage
const coverageData = request.input('coverage');
if (coverageData) {
@ -481,6 +489,12 @@ export default class DatasetController {
'subjects.*.type.required': 'keyword type is required',
'subjects.*.language.required': 'language of keyword is required',
'references.*.value.required': 'Additional reference value is required, if defined',
'references.*.type.required': 'Additional reference identifier type is required',
'references.*.relation.required': 'Additional reference relation type is required',
'references.*.label.required': 'Additional reference label is required',
'files.minLength': 'At least {{ options.minLength }} file upload is required.',
'files.*.size': 'file size is to big',
'files.extnames': 'file extension is not supported',
};