This commit is contained in:
parent
f828ca4491
commit
cb51a4136f
167 changed files with 21485 additions and 21212 deletions
|
@ -1,22 +1,23 @@
|
|||
import type { HttpContextContract } from '@ioc:Adonis/Core/HttpContext';
|
||||
import type { HttpContext } from '@adonisjs/core/http';
|
||||
import { Client } from '@opensearch-project/opensearch';
|
||||
import User from 'App/Models/User';
|
||||
import Dataset from 'App/Models/Dataset';
|
||||
import DatasetIdentifier from 'App/Models/DatasetIdentifier';
|
||||
import XmlModel from 'App/Library/XmlModel';
|
||||
import { XMLBuilder } from 'xmlbuilder2/lib/interfaces';
|
||||
import User from '#app/Models/User';
|
||||
import Dataset from '#app/Models/Dataset';
|
||||
import DatasetIdentifier from '#app/Models/DatasetIdentifier';
|
||||
import XmlModel from '#app/Library/XmlModel';
|
||||
import { XMLBuilder } from 'xmlbuilder2/lib/interfaces.js';
|
||||
import { create } from 'xmlbuilder2';
|
||||
import { readFileSync } from 'fs';
|
||||
import { transform } from 'saxon-js';
|
||||
import type { ModelQueryBuilderContract } from '@ioc:Adonis/Lucid/Orm';
|
||||
import { schema, CustomMessages } from '@ioc:Adonis/Core/Validator';
|
||||
import SaxonJS from 'saxon-js';
|
||||
import { schema } from '@adonisjs/validator';
|
||||
import { DateTime } from 'luxon';
|
||||
import Index from 'App/Library/Utils/Index';
|
||||
import { getDomain } from 'App/Utils/utility-functions';
|
||||
import { DoiClient } from 'App/Library/Doi/DoiClient';
|
||||
import DoiClientException from 'App/Exceptions/DoiClientException';
|
||||
import Logger from '@ioc:Adonis/Core/Logger';
|
||||
import Index from '#app/Library/Utils/Index';
|
||||
import { getDomain } from '#app/Utils/utility-functions';
|
||||
import { DoiClient } from '#app/Library/Doi/DoiClient';
|
||||
import DoiClientException from '#app/Exceptions/DoiClientException';
|
||||
import logger from '@adonisjs/core/services/logger';
|
||||
import { HttpException } from 'node-exceptions';
|
||||
import { ModelQueryBuilderContract } from "@adonisjs/lucid/types/model";
|
||||
import { CustomMessages } from "@adonisjs/validator/types";
|
||||
|
||||
// Create a new instance of the client
|
||||
const client = new Client({ node: 'http://localhost:9200' }); // replace with your OpenSearch endpoint
|
||||
|
@ -37,7 +38,7 @@ export default class DatasetsController {
|
|||
}
|
||||
|
||||
// public async index({}: HttpContextContract) {}
|
||||
public async index({ auth, request, inertia }: HttpContextContract) {
|
||||
public async index({ auth, request, inertia }: HttpContext) {
|
||||
const user = (await User.find(auth.user?.id)) as User;
|
||||
const page = request.input('page', 1);
|
||||
let datasets: ModelQueryBuilderContract<typeof Dataset, Dataset> = Dataset.query();
|
||||
|
@ -92,7 +93,7 @@ export default class DatasetsController {
|
|||
});
|
||||
}
|
||||
|
||||
public async receive({ request, inertia, response }: HttpContextContract) {
|
||||
public async receive({ request, inertia, response }: HttpContext) {
|
||||
const id = request.param('id');
|
||||
const dataset = await Dataset.query()
|
||||
.where('id', id)
|
||||
|
@ -121,7 +122,7 @@ export default class DatasetsController {
|
|||
});
|
||||
}
|
||||
|
||||
public async receiveUpdate({ auth, request, response }) {
|
||||
public async receiveUpdate({ auth, request, response }: HttpContext) {
|
||||
const id = request.param('id');
|
||||
// const { id } = params;
|
||||
const dataset = await Dataset.findOrFail(id);
|
||||
|
@ -153,7 +154,7 @@ export default class DatasetsController {
|
|||
}
|
||||
}
|
||||
|
||||
public async approve({ request, inertia, response }) {
|
||||
public async approve({ request, inertia, response }: HttpContext) {
|
||||
const id = request.param('id');
|
||||
// $dataset = Dataset::with('user:id,login')->findOrFail($id);
|
||||
const dataset = await Dataset.findOrFail(id);
|
||||
|
@ -182,7 +183,7 @@ export default class DatasetsController {
|
|||
});
|
||||
}
|
||||
|
||||
public async approveUpdate({ request, response }) {
|
||||
public async approveUpdate({ request, response }: HttpContext) {
|
||||
const approveDatasetSchema = schema.create({
|
||||
reviewer_id: schema.number(),
|
||||
});
|
||||
|
@ -221,7 +222,7 @@ export default class DatasetsController {
|
|||
}
|
||||
}
|
||||
|
||||
public async publish({ request, inertia, response }) {
|
||||
public async publish({ request, inertia, response }: HttpContext) {
|
||||
const id = request.param('id');
|
||||
|
||||
const dataset = await Dataset.query()
|
||||
|
@ -250,7 +251,7 @@ export default class DatasetsController {
|
|||
});
|
||||
}
|
||||
|
||||
public async publishUpdate({ request, response }) {
|
||||
public async publishUpdate({ request, response }: HttpContext) {
|
||||
const publishDatasetSchema = schema.create({
|
||||
publisher_name: schema.string({ trim: true }),
|
||||
});
|
||||
|
@ -287,7 +288,7 @@ export default class DatasetsController {
|
|||
}
|
||||
}
|
||||
|
||||
public async doiCreate({ request, inertia }: HttpContextContract) {
|
||||
public async doiCreate({ request, inertia }: HttpContext) {
|
||||
const id = request.param('id');
|
||||
const dataset = await Dataset.query()
|
||||
.where('id', id)
|
||||
|
@ -301,7 +302,7 @@ export default class DatasetsController {
|
|||
});
|
||||
}
|
||||
|
||||
public async doiStore({ request, response }: HttpContextContract) {
|
||||
public async doiStore({ request, response }: HttpContext) {
|
||||
const dataId = request.param('publish_id');
|
||||
const dataset = await Dataset.query()
|
||||
// .preload('xmlCache')
|
||||
|
@ -338,7 +339,7 @@ export default class DatasetsController {
|
|||
const index_name = 'tethys-records';
|
||||
await Index.indexDocument(dataset, index_name);
|
||||
} catch (error) {
|
||||
Logger.error(`${__filename}: Indexing document ${dataset.id} failed: ${error.message}`);
|
||||
logger.error(`${__filename}: Indexing document ${dataset.id} failed: ${error.message}`);
|
||||
// Log the error or handle it as needed
|
||||
throw new HttpException(error.message);
|
||||
}
|
||||
|
@ -351,12 +352,12 @@ export default class DatasetsController {
|
|||
// return response.toRoute('editor.dataset.list').flash('message', xmlMeta);
|
||||
}
|
||||
|
||||
public async show({}: HttpContextContract) {}
|
||||
public async show({}: HttpContext) {}
|
||||
|
||||
public async edit({}: HttpContextContract) {}
|
||||
public async edit({}: HttpContext) {}
|
||||
|
||||
// public async update({}: HttpContextContract) {}
|
||||
public async update({ response }) {
|
||||
public async update({ response }: HttpContext) {
|
||||
const id = 273; //request.param('id');
|
||||
const dataset = await Dataset.query().preload('xmlCache').where('id', id).firstOrFail();
|
||||
// add xml elements
|
||||
|
@ -374,7 +375,7 @@ export default class DatasetsController {
|
|||
const xmlString = xml.end({ prettyPrint: false });
|
||||
let doc = '';
|
||||
try {
|
||||
const result = await transform({
|
||||
const result = await SaxonJS.transform({
|
||||
// stylesheetFileName: `${config.TMP_BASE_DIR}/data-quality/rules/iati.sef.json`,
|
||||
stylesheetText: this.proc,
|
||||
destination: 'serialized',
|
||||
|
@ -472,7 +473,7 @@ export default class DatasetsController {
|
|||
}
|
||||
}
|
||||
|
||||
public async destroy({}: HttpContextContract) {}
|
||||
public async destroy({}: HttpContext) {}
|
||||
|
||||
private async createXmlRecord(dataset: Dataset, datasetNode: XMLBuilder) {
|
||||
const domNode = await this.getDatasetXmlDomNode(dataset);
|
||||
|
|
Loading…
Add table
editor.link_modal.header
Reference in a new issue