From 435d2bf75b34bf884d75eb4c519adad97cfe2996 Mon Sep 17 00:00:00 2001 From: Norbert Csaba Herczeg Date: Mon, 17 Apr 2023 21:42:58 +0200 Subject: [PATCH] JNG-4759 fix mapped operation range (#28) --- .../ui/generator/typescript/rest/axios/UiAxiosHelper.java | 8 ++------ .../src/main/resources/data-axios/classServiceImpl.ts.hbs | 4 ++-- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/judo-ui-typescript-rest-axios/src/main/java/hu/blackbelt/judo/ui/generator/typescript/rest/axios/UiAxiosHelper.java b/judo-ui-typescript-rest-axios/src/main/java/hu/blackbelt/judo/ui/generator/typescript/rest/axios/UiAxiosHelper.java index f57d6cd..d87a0c9 100644 --- a/judo-ui-typescript-rest-axios/src/main/java/hu/blackbelt/judo/ui/generator/typescript/rest/axios/UiAxiosHelper.java +++ b/judo-ui-typescript-rest-axios/src/main/java/hu/blackbelt/judo/ui/generator/typescript/rest/axios/UiAxiosHelper.java @@ -76,13 +76,9 @@ public static String classTypeRestPath(ClassType classType, String suffix) { .collect(Collectors.joining("/")) + effectiveSuffix; } - public static String classTypeRestPathThreeParams(ClassType classType, String first, String second) { - String suffix = first + second; + public static String operationRestPath(ClassType classType, OperationType operation, String suffix) { String effectiveSuffix = suffix == null ? "" : suffix; - return "/" + stream(classType.getName().split("::")) - .skip(1) - .filter(i -> i != "_default_transferobjecttypes") - .collect(Collectors.joining("/")) + effectiveSuffix; + return classTypeRestPath(classType, "") + "/" + operation.getName() + effectiveSuffix; } public static String stringConcat(String... strings) { diff --git a/judo-ui-typescript-rest-axios/src/main/resources/data-axios/classServiceImpl.ts.hbs b/judo-ui-typescript-rest-axios/src/main/resources/data-axios/classServiceImpl.ts.hbs index 84fcd3d..5d1ec51 100644 --- a/judo-ui-typescript-rest-axios/src/main/resources/data-axios/classServiceImpl.ts.hbs +++ b/judo-ui-typescript-rest-axios/src/main/resources/data-axios/classServiceImpl.ts.hbs @@ -155,7 +155,7 @@ export class {{ classType.serviceClassName }}Impl extends JudoAxiosService imple * @throws {AxiosError} With data containing {@link Array} for status codes: 400, 401, 403. */ async {{ operation.name }}({{# if operation.isMapped }}owner: JudoIdentifiable<{{ getClassName classType }}>{{/ if }}{{# if operation.input }}{{# if operation.isMapped }},{{/ if }}target:{{ getClassName operation.input.target }}{{/ if }}): Promise<{{# if operation.output }}{{ classDataName operation.output.target "Stored" }}{{ else }}void{{/ if }}> { - const path = '{{ classTypeRestPathThreeParams classType "/" operation.name }}'; + const path = '{{ operationRestPath classType operation '' }}'; const response = await this.axios.post(this.getPathForActor(path){{# if operation.input }}, target{{ else }}, undefined{{/ if }}{{# if operation.isMapped }}, { headers: { 'X-Judo-SignedIdentifier': owner.__signedIdentifier!, @@ -172,7 +172,7 @@ export class {{ classType.serviceClassName }}Impl extends JudoAxiosService imple * @throws {AxiosError} With data containing {@link Array} for status codes: 401, 403. */ async getRangeFor{{ firstToUpper operation.name }}(owner?: {{ classDataName classType "Stored" }}, queryCustomizer?:{{ classDataName operation.input.target "QueryCustomizer" }}): Promise> { - const path = '{{ classTypeRestPath classType "/" operation.name "/~range" }}'; + const path = '{{ operationRestPath classType operation '/~range' }}'; const response = await this.axios.post(this.getPathForActor(path), { owner: owner ?? {}, queryCustomizer: queryCustomizer ?? {} }); return response.data;