Skip to content

Commit

Permalink
JNG-4762 Add checksum regeneration feature to support code formatters (
Browse files Browse the repository at this point in the history
…#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
  • Loading branch information
robertcsakany authored Apr 19, 2023
1 parent f948902 commit e53c8a6
Show file tree
Hide file tree
Showing 7 changed files with 63 additions and 43 deletions.
43 changes: 43 additions & 0 deletions judo-ui-react-itest/ActionGroupTest/action_group_test__god/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,49 @@
</templateParameters>
</configuration>
</execution>

<!-- Regenerate checksum -->
<execution>
<id>execute-ui-checksum</id>
<phase>process-sources</phase>
<goals>
<goal>checksum</goal>
</goals>
<configuration>
<applications>
${actor-fq-name}
</applications>
<ui>${ui-model}</ui>
<destination>${generation-target}</destination>
</configuration>
</execution>

<!-- Regenerate source code to check the formatted version will not cause problem -->
<execution>
<id>execute-ui-generation-validate-checksum</id>
<phase>process-sources</phase>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<uris>
<uri>mvn:hu.blackbelt.judo.generator:judo-ui-react:${revision}</uri>
</uris>
<type>ui-react</type>
<applications>
${actor-fq-name}
</applications>
<ui>${ui-model}</ui>
<destination>${generation-target}</destination>
<templateParameters>
<appModelName>${model-name}</appModelName>
<appScope>${appScope}</appScope>
<appVersion>${appVersion}</appVersion>

<tablePageLimit>10</tablePageLimit>
</templateParameters>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,11 +132,10 @@ public static List<KeyValue<Action, PageDefinition>> getActionsForOutputPages(Ap
List<KeyValue<Action, PageDefinition>> actions = new ArrayList<>();
getUnmappedOutputViewsForPages(application)
.forEach(p -> {
CallOperationAction action = (CallOperationAction) p.getKey();
getUniquePageActions(action.getOutputParameterPage()).forEach(a -> {
getUniquePageActions(p).forEach(a -> {
KeyValue<Action, PageDefinition> kv = new KeyValue<>();
kv.setKey(a);
kv.setValue(action.getOutputParameterPage());
kv.setValue(p);
actions.add(kv);
});
});
Expand All @@ -149,9 +148,13 @@ public static List<KeyValue<Action, PageDefinition>> getActionFormsForPages(Appl
return actions.stream().filter(kv -> actionHasInputForm(kv.getKey())).collect(Collectors.toList());
}

public static List<KeyValue<Action, PageDefinition>> getUnmappedOutputViewsForPages(Application application) {
List<KeyValue<Action, PageDefinition>> actions = getActionsForPages(application);
return actions.stream().filter(kv -> actionHasUnmappedOutputForm(kv.getKey())).collect(Collectors.toList());
public static List<PageDefinition> getUnmappedOutputViewsForPages(Application application) {
Set<PageDefinition> 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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,9 +226,7 @@ public static Map<String, String> getApplicationTranslations(Application applica
}

// Unmapped Operation Output Views for modals
for (KeyValue<Action, PageDefinition> 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());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -397,24 +397,9 @@ public static Collection<String> getApiImportsForCallOperationAction(CallOperati
return res;
}

public static Collection<String> getApiImportsForUnmappedOperationOutputAction(CallOperationAction action, PageDefinition ownerPage) {
PageDefinition outputParameterPage = action.getOutputParameterPage();
Set<String> 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<String> getApiImportsForUnmappedOperationOutputAction(PageDefinition page) {
Set<String> res = new HashSet<>(getApiImportsForViewPage(page));
res.addAll(getApiImportsForReferenceType((ReferenceType) page.getDataElement()));
return res;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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,
Expand Down
14 changes: 4 additions & 10 deletions judo-ui-react/src/main/resources/ui-react.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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)"
Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@
<node-version>18.14.2</node-version>
<pnpm-version>7.29.1</pnpm-version>

<judo-meta-ui-version>1.1.0.20230416_041747_f8e66293_develop</judo-meta-ui-version>
<judo-generator-commons-version>1.0.0.20230415_220023_013a5a8d_develop</judo-generator-commons-version>
<judo-meta-ui-version>1.1.0.20230418_101407_5f1fa81f_feature_JNG_4762_AddChecksumRegeneration</judo-meta-ui-version>
<judo-generator-commons-version>1.0.0.20230418_091911_cff862f1_feature_JNG_4762_AddChecksumRegeneration</judo-generator-commons-version>
<judo-ui-typescript-rest-version>1.0.0.20230417_163750_74636108_bugfix_JNG_4759_fix_mapped_operation_range</judo-ui-typescript-rest-version>

<surefire-version>3.0.0-M7</surefire-version>
Expand Down

0 comments on commit e53c8a6

Please sign in to comment.