From 69443317615655ea073ee5e28f750c65ddf80707 Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Wed, 13 Mar 2024 00:38:28 +0100 Subject: [PATCH] [DEV] add capability to copy the tool file --- .classpath | 2 +- pom.xml | 5 +++++ .../archidata/dataAccess/DataFactoryTsApi.java | 15 +++++++++++++++ .../resources}/rest-tools.ts | 18 ++++++++++++------ 4 files changed, 33 insertions(+), 7 deletions(-) rename {typescript_model => src/resources}/rest-tools.ts (95%) diff --git a/.classpath b/.classpath index dd85e60..948a0ab 100644 --- a/.classpath +++ b/.classpath @@ -37,8 +37,8 @@ - + diff --git a/pom.xml b/pom.xml index 2d5f3e0..70ceddc 100644 --- a/pom.xml +++ b/pom.xml @@ -185,6 +185,11 @@ src + + + ${basedir}/src/resources + + test/src diff --git a/src/org/kar/archidata/dataAccess/DataFactoryTsApi.java b/src/org/kar/archidata/dataAccess/DataFactoryTsApi.java index 47ac4da..ed0f8a5 100644 --- a/src/org/kar/archidata/dataAccess/DataFactoryTsApi.java +++ b/src/org/kar/archidata/dataAccess/DataFactoryTsApi.java @@ -496,6 +496,21 @@ public class DataFactoryTsApi { myWriter = new FileWriter(pathPackage + File.separator + "index.ts"); myWriter.write(index.toString()); myWriter.close(); + final InputStream ioStream = DataFactoryTsApi.class + .getClassLoader() + .getResourceAsStream("rest-tools.ts"); + if (ioStream == null) { + throw new IllegalArgumentException("rest-tools.ts is not found"); + } + final BufferedReader buffer = new BufferedReader(new InputStreamReader(ioStream)); + myWriter = new FileWriter(pathPackage + File.separator + "rest-tools.ts"); + String line; + while( (line = buffer.readLine()) != null) { + myWriter.write(line); + myWriter.write("\n"); + } + ioStream.close(); + myWriter.close(); return; } diff --git a/typescript_model/rest-tools.ts b/src/resources/rest-tools.ts similarity index 95% rename from typescript_model/rest-tools.ts rename to src/resources/rest-tools.ts index 8497b47..ca9f0d1 100644 --- a/typescript_model/rest-tools.ts +++ b/src/resources/rest-tools.ts @@ -1,7 +1,7 @@ /** @file * @author Edouard DUPIN * @copyright 2024, Edouard DUPIN, all right reserved - * @license MPL-2 (Generate file) + * @license MPL-2 */ import { RestErrorResponse } from "./model" @@ -21,6 +21,7 @@ export enum HTTPMimeType { JSON = 'application/json', OCTET_STREAM = 'application/octet-stream', MULTIPART = 'multipart/form-data', + CSV = 'text/csv', } export interface RESTConfig { @@ -43,11 +44,6 @@ export interface RESTModel { tokenInUrl?: boolean; } -export interface RESTRequest { - params?: object; - body?: any; -} - export interface ModelResponseHttp { status: number; data: any; @@ -222,3 +218,13 @@ export function RESTRequestJsonArray(request: RESTRequestType, checker: (d }); }); } + +export function RESTRequestVoid(request: RESTRequestType): Promise { + return new Promise((resolve, reject) => { + RESTRequest(request).then((value: ModelResponseHttp) => { + resolve(); + }).catch((reason: RestErrorResponse) => { + reject(reason); + }); + }); +}