From e53c8a6f95f7c28c95c1f635573e8641525faff4 Mon Sep 17 00:00:00 2001 From: Robert Csakany Date: Wed, 19 Apr 2023 13:12:53 +0200 Subject: [PATCH] JNG-4762 Add checksum regeneration feature to support code formatters (#72) * JNG-4762 Initial feature commit [ci skip] * JNG-4762 [Release] Updating versions * JNG-4762 Fixing multiple generation for unmapped output pages * JNG-4762 Checksum test function added --- .../action_group_test__god/pom.xml | 43 +++++++++++++++++++ .../ui/generator/react/UiActionsHelper.java | 15 ++++--- .../judo/ui/generator/react/UiI18NHelper.java | 4 +- .../judo/ui/generator/react/UiPageHelper.java | 21 ++------- .../output-view/output-view.tsx.hbs | 5 +-- .../src/main/resources/ui-react.yaml | 14 ++---- pom.xml | 4 +- 7 files changed, 63 insertions(+), 43 deletions(-) diff --git a/judo-ui-react-itest/ActionGroupTest/action_group_test__god/pom.xml b/judo-ui-react-itest/ActionGroupTest/action_group_test__god/pom.xml index 3c0e8a25..3a32f58c 100644 --- a/judo-ui-react-itest/ActionGroupTest/action_group_test__god/pom.xml +++ b/judo-ui-react-itest/ActionGroupTest/action_group_test__god/pom.xml @@ -92,6 +92,49 @@ + + + + execute-ui-checksum + process-sources + + checksum + + + + ${actor-fq-name} + + ${ui-model} + ${generation-target} + + + + + + execute-ui-generation-validate-checksum + process-sources + + generate + + + + mvn:hu.blackbelt.judo.generator:judo-ui-react:${revision} + + ui-react + + ${actor-fq-name} + + ${ui-model} + ${generation-target} + + ${model-name} + ${appScope} + ${appVersion} + + 10 + + + diff --git a/judo-ui-react/src/main/java/hu/blackbelt/judo/ui/generator/react/UiActionsHelper.java b/judo-ui-react/src/main/java/hu/blackbelt/judo/ui/generator/react/UiActionsHelper.java index c452e1ec..f0fff82b 100644 --- a/judo-ui-react/src/main/java/hu/blackbelt/judo/ui/generator/react/UiActionsHelper.java +++ b/judo-ui-react/src/main/java/hu/blackbelt/judo/ui/generator/react/UiActionsHelper.java @@ -132,11 +132,10 @@ public static List> getActionsForOutputPages(Ap List> actions = new ArrayList<>(); getUnmappedOutputViewsForPages(application) .forEach(p -> { - CallOperationAction action = (CallOperationAction) p.getKey(); - getUniquePageActions(action.getOutputParameterPage()).forEach(a -> { + getUniquePageActions(p).forEach(a -> { KeyValue kv = new KeyValue<>(); kv.setKey(a); - kv.setValue(action.getOutputParameterPage()); + kv.setValue(p); actions.add(kv); }); }); @@ -149,9 +148,13 @@ public static List> getActionFormsForPages(Appl return actions.stream().filter(kv -> actionHasInputForm(kv.getKey())).collect(Collectors.toList()); } - public static List> getUnmappedOutputViewsForPages(Application application) { - List> actions = getActionsForPages(application); - return actions.stream().filter(kv -> actionHasUnmappedOutputForm(kv.getKey())).collect(Collectors.toList()); + public static List getUnmappedOutputViewsForPages(Application application) { + Set unmappedOutputForms = getActionsForPages(application) + .stream() + .filter(kv -> kv.getKey() instanceof CallOperationAction && + actionHasUnmappedOutputForm(kv.getKey())) + .map(kv -> ((CallOperationAction) kv.getKey()).getOutputParameterPage()).collect(Collectors.toSet()); + return unmappedOutputForms.stream().sorted(Comparator.comparing(NamedElement::getFQName)).collect(Collectors.toList()); } public static String actionsPath(PageDefinition page) { diff --git a/judo-ui-react/src/main/java/hu/blackbelt/judo/ui/generator/react/UiI18NHelper.java b/judo-ui-react/src/main/java/hu/blackbelt/judo/ui/generator/react/UiI18NHelper.java index dd907cff..89e35e7f 100644 --- a/judo-ui-react/src/main/java/hu/blackbelt/judo/ui/generator/react/UiI18NHelper.java +++ b/judo-ui-react/src/main/java/hu/blackbelt/judo/ui/generator/react/UiI18NHelper.java @@ -226,9 +226,7 @@ public static Map getApplicationTranslations(Application applica } // Unmapped Operation Output Views for modals - for (KeyValue def: getUnmappedOutputViewsForPages(application)) { - CallOperationAction action = (CallOperationAction) def.getKey(); - PageDefinition page = action.getOutputParameterPage(); + for (PageDefinition page: getUnmappedOutputViewsForPages(application)) { translations.put(idToTranslationKey(page.getFQName(), application), page.getLabel()); diff --git a/judo-ui-react/src/main/java/hu/blackbelt/judo/ui/generator/react/UiPageHelper.java b/judo-ui-react/src/main/java/hu/blackbelt/judo/ui/generator/react/UiPageHelper.java index 689bd307..17868f95 100644 --- a/judo-ui-react/src/main/java/hu/blackbelt/judo/ui/generator/react/UiPageHelper.java +++ b/judo-ui-react/src/main/java/hu/blackbelt/judo/ui/generator/react/UiPageHelper.java @@ -397,24 +397,9 @@ public static Collection getApiImportsForCallOperationAction(CallOperati return res; } - public static Collection getApiImportsForUnmappedOperationOutputAction(CallOperationAction action, PageDefinition ownerPage) { - PageDefinition outputParameterPage = action.getOutputParameterPage(); - Set res = outputParameterPage != null ? new HashSet<>(getApiImportsForViewPage(outputParameterPage)) : new HashSet<>(); - - res.addAll(getOwnerApiImportsForDataElement(action.getDataElement())); - - if (ownerPage != null) { - if (ownerPage.getDataElement() instanceof ReferenceType) { - res.add(classDataName(((ReferenceType) ownerPage.getDataElement()).getTarget(), "Stored")); - } - } - - if (action.getOperation().getIsMapped()) { - res.add(classDataName((ClassType) action.getDataElement().getOwner(), "Stored")); - } - - res.addAll(getApiImportsForReferenceType((ReferenceType) outputParameterPage.getDataElement())); - + public static Collection getApiImportsForUnmappedOperationOutputAction(PageDefinition page) { + Set res = new HashSet<>(getApiImportsForViewPage(page)); + res.addAll(getApiImportsForReferenceType((ReferenceType) page.getDataElement())); return res; } diff --git a/judo-ui-react/src/main/resources/actor/src/pages/actions/action/call-operation-action/output-view/output-view.tsx.hbs b/judo-ui-react/src/main/resources/actor/src/pages/actions/action/call-operation-action/output-view/output-view.tsx.hbs index 2d12a896..1a5f5ce1 100644 --- a/judo-ui-react/src/main/resources/actor/src/pages/actions/action/call-operation-action/output-view/output-view.tsx.hbs +++ b/judo-ui-react/src/main/resources/actor/src/pages/actions/action/call-operation-action/output-view/output-view.tsx.hbs @@ -1,6 +1,4 @@ {{> fragment.header.hbs }} -// Action name: {{ action.name }} -// Owner Page name: {{ ownerPage.name }} // Page name: {{ page.name }} import { useState, useEffect, useCallback, Dispatch, SetStateAction, FC } from 'react'; @@ -21,13 +19,12 @@ import { useL10N } from '{{ relativePathFromPage page 'l10n' }}/l10n-context'; import { AggregationInput, AssociationButton, BinaryInput, CollectionAssociationButton, TrinaryLogicCombobox } from '{{ relativePathFromPage page 'components/widgets' }}'; import { FilterOption, FilterType } from '{{ relativePathFromPage page 'components-api' }}'; import { - {{# each (getApiImportsForUnmappedOperationOutputAction action page) as |imp| }} + {{# each (getApiImportsForUnmappedOperationOutputAction page) as |imp| }} {{ imp }}, {{/ each }} } from '{{ relativePathFromPage page 'generated/data-api' }}'; import { {{ classServiceName page.dataElement.target }}Impl, - {{ classServiceName action.dataElement.owner }}Impl, } from '{{ relativePathFromPage page 'generated/data-axios'}}'; import { useErrorHandler, diff --git a/judo-ui-react/src/main/resources/ui-react.yaml b/judo-ui-react/src/main/resources/ui-react.yaml index 12f448b4..32e841d9 100644 --- a/judo-ui-react/src/main/resources/ui-react.yaml +++ b/judo-ui-react/src/main/resources/ui-react.yaml @@ -580,25 +580,19 @@ templates: - name: actor/src/pages/actions/action/call-operation-action/output-view/output-view.tsx factoryExpression: "#getUnmappedOutputViewsForPages(#application)" - pathExpression: "#pagePath(#self.key.outputParameterPage) + '/index.tsx'" + pathExpression: "#pagePath(#self) + 'index.tsx'" templateName: actor/src/pages/actions/action/call-operation-action/output-view/output-view.tsx.hbs templateContext: - - name: kv - expression: "#self" - - name: action - expression: "#self.key" - - name: ownerPage - expression: "#self.value" - name: page - expression: "#self.key.outputParameterPage" + expression: "#self" - name: actor/src/pages/actions/index.tsx factoryExpression: "#getUnmappedOutputViewsForPages(#application)" - pathExpression: "#pagePath(#self.key.outputParameterPage) + '/actions/index.tsx'" + pathExpression: "#pagePath(#self) + 'actions/index.tsx'" templateName: actor/src/pages/actions/index.tsx.hbs templateContext: - name: page - expression: "#self.key.outputParameterPage" + expression: "#self" - name: actor/src/pages/actions/action.tsx factoryExpression: "#getActionsForOutputPages(#application)" diff --git a/pom.xml b/pom.xml index 1777e32a..0253a7d3 100644 --- a/pom.xml +++ b/pom.xml @@ -53,8 +53,8 @@ 18.14.2 7.29.1 - 1.1.0.20230416_041747_f8e66293_develop - 1.0.0.20230415_220023_013a5a8d_develop + 1.1.0.20230418_101407_5f1fa81f_feature_JNG_4762_AddChecksumRegeneration + 1.0.0.20230418_091911_cff862f1_feature_JNG_4762_AddChecksumRegeneration 1.0.0.20230417_163750_74636108_bugfix_JNG_4759_fix_mapped_operation_range 3.0.0-M7