-
Notifications
You must be signed in to change notification settings - Fork 7
[NAE-2119] Fix menuItem #315
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
70406c8
a5cccb5
a1418a1
d3584fb
9796d46
891b24b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -79,6 +79,10 @@ protected Optional<DataField> transformDataField(String fieldId, Case useCase) { | |||||||||||||||||||||||||||||||||||||||||
| return this.transformUserListField(caseField); | ||||||||||||||||||||||||||||||||||||||||||
| } else if (netField instanceof com.netgrif.application.engine.objects.petrinet.domain.dataset.I18nField) { | ||||||||||||||||||||||||||||||||||||||||||
| return this.transformI18nField(caseField, (com.netgrif.application.engine.objects.petrinet.domain.dataset.I18nField) netField); | ||||||||||||||||||||||||||||||||||||||||||
| } else if (netField instanceof com.netgrif.application.engine.objects.petrinet.domain.dataset.CaseField) { | ||||||||||||||||||||||||||||||||||||||||||
| return this.transformCaseFieldField(caseField, (com.netgrif.application.engine.objects.petrinet.domain.dataset.CaseField) netField); | ||||||||||||||||||||||||||||||||||||||||||
| } else if (netField instanceof com.netgrif.application.engine.objects.petrinet.domain.dataset.FilterField) { | ||||||||||||||||||||||||||||||||||||||||||
| return this.transformFilterFieldField(caseField, (com.netgrif.application.engine.objects.petrinet.domain.dataset.FilterField) netField); | ||||||||||||||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||||||||||||||
| String string = caseField.getValue().toString(); | ||||||||||||||||||||||||||||||||||||||||||
| if (string == null) | ||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -87,7 +91,8 @@ protected Optional<DataField> transformDataField(String fieldId, Case useCase) { | |||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| protected Optional<DataField> transformMultichoiceMapField(com.netgrif.application.engine.objects.workflow.domain.DataField multichoiceMap, MultichoiceMapField netField) { | ||||||||||||||||||||||||||||||||||||||||||
| protected Optional<DataField> transformMultichoiceMapField | ||||||||||||||||||||||||||||||||||||||||||
| (com.netgrif.application.engine.objects.workflow.domain.DataField multichoiceMap, MultichoiceMapField netField) { | ||||||||||||||||||||||||||||||||||||||||||
| Optional<Set> optValues = this.getMultichoiceValue(multichoiceMap, netField); | ||||||||||||||||||||||||||||||||||||||||||
| if (!optValues.isPresent()) { | ||||||||||||||||||||||||||||||||||||||||||
| return Optional.empty(); | ||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -101,27 +106,44 @@ protected Optional<DataField> transformMultichoiceMapField(com.netgrif.applicati | |||||||||||||||||||||||||||||||||||||||||
| return Optional.of(new com.netgrif.application.engine.adapter.spring.elastic.domain.MapField(values)); | ||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| protected Optional<DataField> transformI18nField(com.netgrif.application.engine.objects.workflow.domain.DataField dataField, com.netgrif.application.engine.objects.petrinet.domain.dataset.I18nField netField) { | ||||||||||||||||||||||||||||||||||||||||||
| protected Optional<DataField> transformI18nField | ||||||||||||||||||||||||||||||||||||||||||
| (com.netgrif.application.engine.objects.workflow.domain.DataField | ||||||||||||||||||||||||||||||||||||||||||
| dataField, com.netgrif.application.engine.objects.petrinet.domain.dataset.I18nField netField) { | ||||||||||||||||||||||||||||||||||||||||||
| Set<String> keys = ((I18nString) dataField.getValue()).getTranslations().keySet(); | ||||||||||||||||||||||||||||||||||||||||||
| Set<String> values = new HashSet<>(((I18nString) dataField.getValue()).getTranslations().values()); | ||||||||||||||||||||||||||||||||||||||||||
| values.add(((I18nString) dataField.getValue()).getDefaultValue()); | ||||||||||||||||||||||||||||||||||||||||||
| return Optional.of(new com.netgrif.application.engine.adapter.spring.elastic.domain.I18nField(keys, values)); | ||||||||||||||||||||||||||||||||||||||||||
| return Optional.of(new com.netgrif.application.engine.adapter.spring.elastic.domain.I18nField(keys, values, ((I18nString) dataField.getValue()).getTranslations())); | ||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| protected Optional<DataField> transformEnumerationMapField(com.netgrif.application.engine.objects.workflow.domain.DataField enumMap, EnumerationMapField netField) { | ||||||||||||||||||||||||||||||||||||||||||
| protected Optional<DataField> transformCaseFieldField(com.netgrif.application.engine.objects.workflow.domain.DataField dataField, com.netgrif.application.engine.objects.petrinet.domain.dataset.CaseField netField) { | ||||||||||||||||||||||||||||||||||||||||||
| String[] allowedNets = dataField.getAllowedNets().toArray(new String[0]); | ||||||||||||||||||||||||||||||||||||||||||
| String[] referencedCases = ((List<String>) dataField.getValue()).toArray(new String[0]); | ||||||||||||||||||||||||||||||||||||||||||
| return Optional.of(new com.netgrif.application.engine.adapter.spring.elastic.domain.CaseField(referencedCases,allowedNets)); | ||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| protected Optional<DataField> transformFilterFieldField(com.netgrif.application.engine.objects.workflow.domain.DataField dataField, com.netgrif.application.engine.objects.petrinet.domain.dataset.FilterField netField) { | ||||||||||||||||||||||||||||||||||||||||||
| String[] allowedNets = dataField.getAllowedNets().toArray(new String[0]); | ||||||||||||||||||||||||||||||||||||||||||
| Map<String, Object> filterMetadata = dataField.getFilterMetadata(); | ||||||||||||||||||||||||||||||||||||||||||
| return Optional.of(new com.netgrif.application.engine.adapter.spring.elastic.domain.FilterField(dataField.getValue().toString(),allowedNets, filterMetadata)); | ||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+124
to
+128
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Add error handling for FilterField transformation. The method assumes protected Optional<DataField> transformFilterFieldField(com.netgrif.application.engine.objects.workflow.domain.DataField dataField, com.netgrif.application.engine.objects.petrinet.domain.dataset.FilterField netField) {
+ if (dataField.getValue() == null || dataField.getAllowedNets() == null) {
+ return Optional.empty();
+ }
String[] allowedNets = dataField.getAllowedNets().toArray(new String[0]);
Map<String, Object> filterMetadata = dataField.getFilterMetadata();
+ if (filterMetadata == null) {
+ filterMetadata = new HashMap<>();
+ }
return Optional.of(new com.netgrif.application.engine.adapter.spring.elastic.domain.FilterField(dataField.getValue().toString(),allowedNets, filterMetadata));
}📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents
renczesstefan marked this conversation as resolved.
|
||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| protected Optional<DataField> transformEnumerationMapField | ||||||||||||||||||||||||||||||||||||||||||
| (com.netgrif.application.engine.objects.workflow.domain.DataField enumMap, EnumerationMapField netField) { | ||||||||||||||||||||||||||||||||||||||||||
| Map<String, I18nString> options = this.getFieldOptions(enumMap, netField); | ||||||||||||||||||||||||||||||||||||||||||
| String selectedKey = (String) enumMap.getValue(); | ||||||||||||||||||||||||||||||||||||||||||
| return Optional.of(new com.netgrif.application.engine.adapter.spring.elastic.domain.MapField(new AbstractMap.SimpleEntry<>(selectedKey, collectTranslations(options.get(selectedKey))))); | ||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| private Map<String, I18nString> getFieldOptions(com.netgrif.application.engine.objects.workflow.domain.DataField map, MapOptionsField<I18nString, ?> netField) { | ||||||||||||||||||||||||||||||||||||||||||
| private Map<String, I18nString> getFieldOptions | ||||||||||||||||||||||||||||||||||||||||||
| (com.netgrif.application.engine.objects.workflow.domain.DataField map, MapOptionsField<I18nString, ?> netField) { | ||||||||||||||||||||||||||||||||||||||||||
| if (map.getOptions() != null) { | ||||||||||||||||||||||||||||||||||||||||||
| return map.getOptions(); | ||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||
| return netField.getOptions(); | ||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| protected Optional<DataField> transformMultichoiceField(com.netgrif.application.engine.objects.workflow.domain.DataField multichoiceField, MultichoiceField netField) { | ||||||||||||||||||||||||||||||||||||||||||
| protected Optional<DataField> transformMultichoiceField | ||||||||||||||||||||||||||||||||||||||||||
| (com.netgrif.application.engine.objects.workflow.domain.DataField multichoiceField, MultichoiceField netField) { | ||||||||||||||||||||||||||||||||||||||||||
| Optional<Set> optValues = this.getMultichoiceValue(multichoiceField, netField); | ||||||||||||||||||||||||||||||||||||||||||
| if (!optValues.isPresent()) { | ||||||||||||||||||||||||||||||||||||||||||
| return Optional.empty(); | ||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -142,7 +164,8 @@ protected Optional<DataField> transformMultichoiceField(com.netgrif.application. | |||||||||||||||||||||||||||||||||||||||||
| return Optional.of(new com.netgrif.application.engine.adapter.spring.elastic.domain.TextField(translations.toArray(new String[0]))); | ||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| private Optional<Set> getMultichoiceValue(com.netgrif.application.engine.objects.workflow.domain.DataField multichoice, Field netField) { | ||||||||||||||||||||||||||||||||||||||||||
| private Optional<Set> getMultichoiceValue(com.netgrif.application.engine.objects.workflow.domain.DataField | ||||||||||||||||||||||||||||||||||||||||||
| multichoice, Field netField) { | ||||||||||||||||||||||||||||||||||||||||||
| if (multichoice.getValue() instanceof Set) { | ||||||||||||||||||||||||||||||||||||||||||
| return Optional.of((Set) multichoice.getValue()); | ||||||||||||||||||||||||||||||||||||||||||
| } else if (multichoice.getValue() instanceof Collection) { | ||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -157,7 +180,8 @@ private Optional<Set> getMultichoiceValue(com.netgrif.application.engine.objects | |||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| protected Optional<DataField> transformEnumerationField(com.netgrif.application.engine.objects.workflow.domain.DataField enumField) { | ||||||||||||||||||||||||||||||||||||||||||
| protected Optional<DataField> transformEnumerationField | ||||||||||||||||||||||||||||||||||||||||||
| (com.netgrif.application.engine.objects.workflow.domain.DataField enumField) { | ||||||||||||||||||||||||||||||||||||||||||
| Object value = enumField.getValue(); | ||||||||||||||||||||||||||||||||||||||||||
| if (value instanceof I18nString) { | ||||||||||||||||||||||||||||||||||||||||||
| return Optional.of(new com.netgrif.application.engine.adapter.spring.elastic.domain.TextField(this.collectTranslations((I18nString) value).toArray(new String[0]))); | ||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -180,25 +204,29 @@ protected List<String> collectTranslations(I18nString i18nString) { | |||||||||||||||||||||||||||||||||||||||||
| return translations; | ||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| protected Optional<DataField> transformNumberField(com.netgrif.application.engine.objects.workflow.domain.DataField numberField) { | ||||||||||||||||||||||||||||||||||||||||||
| protected Optional<DataField> transformNumberField | ||||||||||||||||||||||||||||||||||||||||||
| (com.netgrif.application.engine.objects.workflow.domain.DataField numberField) { | ||||||||||||||||||||||||||||||||||||||||||
| if (numberField.getValue() instanceof Integer) { //TODO: Refactor | ||||||||||||||||||||||||||||||||||||||||||
| return Optional.of(new com.netgrif.application.engine.adapter.spring.elastic.domain.NumberField(Double.parseDouble(numberField.getValue().toString()))); | ||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||
| return Optional.of(new com.netgrif.application.engine.adapter.spring.elastic.domain.NumberField((Double) numberField.getValue())); | ||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| protected Optional<DataField> transformButtonField(com.netgrif.application.engine.objects.workflow.domain.DataField buttonField) { | ||||||||||||||||||||||||||||||||||||||||||
| protected Optional<DataField> transformButtonField | ||||||||||||||||||||||||||||||||||||||||||
| (com.netgrif.application.engine.objects.workflow.domain.DataField buttonField) { | ||||||||||||||||||||||||||||||||||||||||||
| return Optional.of(new com.netgrif.application.engine.adapter.spring.elastic.domain.ButtonField((Integer) buttonField.getValue())); | ||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| protected Optional<DataField> transformUserField(com.netgrif.application.engine.objects.workflow.domain.DataField userField) { | ||||||||||||||||||||||||||||||||||||||||||
| protected Optional<DataField> transformUserField | ||||||||||||||||||||||||||||||||||||||||||
| (com.netgrif.application.engine.objects.workflow.domain.DataField userField) { | ||||||||||||||||||||||||||||||||||||||||||
| UserFieldValue user = (UserFieldValue) userField.getValue(); | ||||||||||||||||||||||||||||||||||||||||||
| if (user == null) | ||||||||||||||||||||||||||||||||||||||||||
| return Optional.empty(); | ||||||||||||||||||||||||||||||||||||||||||
| return Optional.of(new com.netgrif.application.engine.adapter.spring.elastic.domain.UserField(this.transformUserValue(user))); | ||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| protected Optional<DataField> transformUserListField(com.netgrif.application.engine.objects.workflow.domain.DataField userListField) { | ||||||||||||||||||||||||||||||||||||||||||
| protected Optional<DataField> transformUserListField | ||||||||||||||||||||||||||||||||||||||||||
| (com.netgrif.application.engine.objects.workflow.domain.DataField userListField) { | ||||||||||||||||||||||||||||||||||||||||||
| UserListFieldValue userListValue = (UserListFieldValue) userListField.getValue(); | ||||||||||||||||||||||||||||||||||||||||||
| UserField.UserMappingData[] userMappingData = userListValue.getUserValues().stream().map(this::transformUserListValue).toArray(UserField.UserMappingData[]::new); | ||||||||||||||||||||||||||||||||||||||||||
| return Optional.of(new com.netgrif.application.engine.adapter.spring.elastic.domain.UserListField(userMappingData)); | ||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -224,7 +252,9 @@ private StringBuilder buildFullName(String name, String surname) { | |||||||||||||||||||||||||||||||||||||||||
| return fullName; | ||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| protected Optional<DataField> transformDateField(com.netgrif.application.engine.objects.workflow.domain.DataField dateField, com.netgrif.application.engine.objects.petrinet.domain.dataset.DateField netField) { | ||||||||||||||||||||||||||||||||||||||||||
| protected Optional<DataField> transformDateField | ||||||||||||||||||||||||||||||||||||||||||
| (com.netgrif.application.engine.objects.workflow.domain.DataField | ||||||||||||||||||||||||||||||||||||||||||
| dateField, com.netgrif.application.engine.objects.petrinet.domain.dataset.DateField netField) { | ||||||||||||||||||||||||||||||||||||||||||
| if (dateField.getValue() instanceof LocalDate) { | ||||||||||||||||||||||||||||||||||||||||||
| LocalDate date = (LocalDate) dateField.getValue(); | ||||||||||||||||||||||||||||||||||||||||||
| return formatDateField(LocalDateTime.of(date, LocalTime.NOON)); | ||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -239,7 +269,8 @@ protected Optional<DataField> transformDateField(com.netgrif.application.engine. | |||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| protected Optional<DataField> transformDateTimeField(com.netgrif.application.engine.objects.workflow.domain.DataField dateTimeField, DateTimeField netField) { | ||||||||||||||||||||||||||||||||||||||||||
| protected Optional<DataField> transformDateTimeField | ||||||||||||||||||||||||||||||||||||||||||
| (com.netgrif.application.engine.objects.workflow.domain.DataField dateTimeField, DateTimeField netField) { | ||||||||||||||||||||||||||||||||||||||||||
| if (dateTimeField.getValue() instanceof LocalDateTime) { | ||||||||||||||||||||||||||||||||||||||||||
| return formatDateField((LocalDateTime) dateTimeField.getValue()); | ||||||||||||||||||||||||||||||||||||||||||
| } else if (dateTimeField.getValue() instanceof Date) { | ||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -252,7 +283,8 @@ protected Optional<DataField> transformDateTimeField(com.netgrif.application.eng | |||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| private LocalDateTime transformDateValueField(com.netgrif.application.engine.objects.workflow.domain.DataField dateValueField) { | ||||||||||||||||||||||||||||||||||||||||||
| private LocalDateTime transformDateValueField(com.netgrif.application.engine.objects.workflow.domain.DataField | ||||||||||||||||||||||||||||||||||||||||||
| dateValueField) { | ||||||||||||||||||||||||||||||||||||||||||
| return ((Date) dateValueField.getValue()).toInstant() | ||||||||||||||||||||||||||||||||||||||||||
| .atZone(ZoneId.systemDefault()) | ||||||||||||||||||||||||||||||||||||||||||
| .toLocalDateTime(); | ||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -264,26 +296,31 @@ private Optional<DataField> formatDateField(LocalDateTime date) { | |||||||||||||||||||||||||||||||||||||||||
| return Optional.of(new com.netgrif.application.engine.adapter.spring.elastic.domain.DateField(date.format(DateTimeFormatter.BASIC_ISO_DATE), date)); | ||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| protected Optional<DataField> transformBooleanField(com.netgrif.application.engine.objects.workflow.domain.DataField booleanField) { | ||||||||||||||||||||||||||||||||||||||||||
| protected Optional<DataField> transformBooleanField | ||||||||||||||||||||||||||||||||||||||||||
| (com.netgrif.application.engine.objects.workflow.domain.DataField booleanField) { | ||||||||||||||||||||||||||||||||||||||||||
| return Optional.of(new com.netgrif.application.engine.adapter.spring.elastic.domain.BooleanField((Boolean) booleanField.getValue())); | ||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| protected Optional<DataField> transformTextField(com.netgrif.application.engine.objects.workflow.domain.DataField textField) { | ||||||||||||||||||||||||||||||||||||||||||
| protected Optional<DataField> transformTextField | ||||||||||||||||||||||||||||||||||||||||||
| (com.netgrif.application.engine.objects.workflow.domain.DataField textField) { | ||||||||||||||||||||||||||||||||||||||||||
| if (textField.getValue() == null) { | ||||||||||||||||||||||||||||||||||||||||||
| return Optional.empty(); | ||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||
| return Optional.of(new com.netgrif.application.engine.adapter.spring.elastic.domain.TextField((String) textField.getValue())); | ||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| protected Optional<DataField> transformFileField(com.netgrif.application.engine.objects.workflow.domain.DataField fileField) { | ||||||||||||||||||||||||||||||||||||||||||
| protected Optional<DataField> transformFileField | ||||||||||||||||||||||||||||||||||||||||||
| (com.netgrif.application.engine.objects.workflow.domain.DataField fileField) { | ||||||||||||||||||||||||||||||||||||||||||
| return Optional.of(new com.netgrif.application.engine.adapter.spring.elastic.domain.FileField((FileFieldValue) fileField.getValue())); | ||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| protected Optional<DataField> transformFileListField(com.netgrif.application.engine.objects.workflow.domain.DataField fileListField) { | ||||||||||||||||||||||||||||||||||||||||||
| protected Optional<DataField> transformFileListField | ||||||||||||||||||||||||||||||||||||||||||
| (com.netgrif.application.engine.objects.workflow.domain.DataField fileListField) { | ||||||||||||||||||||||||||||||||||||||||||
| return Optional.of(new com.netgrif.application.engine.adapter.spring.elastic.domain.FileField(((FileListFieldValue) fileListField.getValue()).getNamesPaths().toArray(new FileFieldValue[0]))); | ||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| protected Optional<DataField> transformOtherFields(com.netgrif.application.engine.objects.workflow.domain.DataField otherField, Field netField) { | ||||||||||||||||||||||||||||||||||||||||||
| protected Optional<DataField> transformOtherFields | ||||||||||||||||||||||||||||||||||||||||||
| (com.netgrif.application.engine.objects.workflow.domain.DataField otherField, Field netField) { | ||||||||||||||||||||||||||||||||||||||||||
| log.warn("Field of type " + netField.getClass().getCanonicalName() + " is not supported for indexation by default. Indexing the toString() representation of its value..."); | ||||||||||||||||||||||||||||||||||||||||||
| return Optional.of(new com.netgrif.application.engine.adapter.spring.elastic.domain.TextField(otherField.getValue().toString())); | ||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| package com.netgrif.application.engine.objects.elastic.domain; | ||
|
|
||
| import lombok.Data; | ||
| import lombok.EqualsAndHashCode; | ||
| import lombok.NoArgsConstructor; | ||
|
|
||
| import java.util.ArrayList; | ||
| import java.util.List; | ||
|
|
||
| @Data | ||
| @NoArgsConstructor | ||
| @EqualsAndHashCode(callSuper = true) | ||
| public abstract class CaseField extends FieldWithAllowedNetsField { | ||
|
|
||
| public CaseField(String[] fullTextValue, String[] allowedNets) { | ||
| super(fullTextValue, allowedNets); | ||
| } | ||
|
|
||
| @Override | ||
| public Object getValue() { | ||
| return new ArrayList<>(List.of(fulltextValue)); | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Add type safety checks for CaseField transformation.
The method assumes
dataField.getValue()returnsList<String>and thatgetAllowedNets()exists on the workflow DataField. Add null checks and type verification to prevent runtime exceptions.protected Optional<DataField> transformCaseFieldField(com.netgrif.application.engine.objects.workflow.domain.DataField dataField, com.netgrif.application.engine.objects.petrinet.domain.dataset.CaseField netField) { + if (dataField.getValue() == null || dataField.getAllowedNets() == null) { + return Optional.empty(); + } + if (!(dataField.getValue() instanceof List)) { + log.error("CaseField value is not a List. Found: " + dataField.getValue().getClass().getCanonicalName()); + return Optional.empty(); + } String[] allowedNets = dataField.getAllowedNets().toArray(new String[0]); - String[] referencedCases = ((List<String>) dataField.getValue()).toArray(new String[0]); + List<?> valueList = (List<?>) dataField.getValue(); + String[] referencedCases = valueList.stream() + .filter(Objects::nonNull) + .map(Object::toString) + .toArray(String[]::new); return Optional.of(new com.netgrif.application.engine.adapter.spring.elastic.domain.CaseField(referencedCases,allowedNets)); }🤖 Prompt for AI Agents