Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ public abstract class BooleanField extends DataField {

public Boolean booleanValue;

public BooleanField(BooleanField field) {
super(field);
this.booleanValue = field.booleanValue;
}

public BooleanField(Boolean value) {
super(value.toString());
this.booleanValue = value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ public abstract class ButtonField extends DataField {

public Integer buttonValue;

public ButtonField(ButtonField field) {
super(field);
this.buttonValue = field.buttonValue;
}

public ButtonField(Integer value) {
super(value.toString());
this.buttonValue = value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ public abstract class CaseField extends FieldWithAllowedNetsField {

private List<String> caseValue;

public CaseField(CaseField field) {
super(field);
this.caseValue = field.caseValue == null ? null : new ArrayList<>(field.caseValue);
}

public CaseField(String[] fullTextValue, String[] allowedNets) {
super(fullTextValue, allowedNets);
this.caseValue = Arrays.asList(fullTextValue);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import lombok.NoArgsConstructor;
import java.io.Serial;
import java.io.Serializable;
import java.util.Arrays;

@Data
@NoArgsConstructor
Expand All @@ -18,6 +19,10 @@ public abstract class DataField implements Serializable {

public String[] fulltextValue;

DataField(DataField dataField) {
this.fulltextValue = dataField.fulltextValue == null ? null : Arrays.copyOf(dataField.fulltextValue, dataField.fulltextValue.length);
}

DataField(String fulltextValue) {
this.fulltextValue = new String[1];
this.fulltextValue[0] = fulltextValue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ public abstract class DateField extends DataField {

public Long timestampValue;

public DateField(DateField field) {
super(field);
this.dateValue = field.dateValue;
this.timestampValue = field.timestampValue;
}

public DateField(String value, LocalDateTime dateTime) {
super(value);
this.dateValue = dateTime;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.netgrif.application.engine.objects.elastic.domain;

import com.netgrif.application.engine.objects.petrinet.domain.I18nString;
import com.netgrif.application.engine.objects.utils.CopyConstructorUtil;
import com.netgrif.application.engine.objects.workflow.domain.Case;
import com.netgrif.application.engine.objects.workflow.domain.TaskPair;
import lombok.AllArgsConstructor;
Expand Down Expand Up @@ -102,27 +104,44 @@ public ElasticCase(Case useCase) {
viewUsers = new HashSet<>(useCase.getViewUsers());
negativeViewUsers = new HashSet<>(useCase.getNegativeViewUsers());
tags = new HashMap<>(useCase.getTags());

permissions = deepCopy(useCase.getPermissions());
users = deepCopy(useCase.getUsers());
userRefs = deepCopy(useCase.getUserRefs());
dataSet = new HashMap<>();
immediateData = useCase.getImmediateData().stream().map(ImmediateField::new).collect(Collectors.toList());
immediateData = useCase.getImmediateData() == null ? Collections.emptyList() : useCase.getImmediateData().stream().map(ImmediateField::new).collect(Collectors.toList());
}

public void update(ElasticCase useCase) {
version++;
lastModified = useCase.getLastModified();
title = useCase.getTitle();
taskIds = useCase.getTaskIds();
taskMongoIds = useCase.getTaskMongoIds();
tasks = useCase.getTasks();
enabledRoles = useCase.getEnabledRoles();
viewRoles = useCase.getViewRoles();
viewUserRefs = useCase.getViewUserRefs();
negativeViewRoles = useCase.getNegativeViewRoles();
viewUsers = useCase.getViewUsers();
negativeViewUsers = useCase.getNegativeViewUsers();
tags = useCase.getTags();

dataSet = useCase.getDataSet();
immediateData = useCase.getImmediateData();
taskIds = useCase.getTaskIds() == null ? new HashSet<>() : new HashSet<>(useCase.getTaskIds());
taskMongoIds = useCase.getTaskMongoIds() == null ? new HashSet<>() : new HashSet<>(useCase.getTaskMongoIds());
tasks = useCase.getTasks() == null ? new HashSet<>() : useCase.getTasks().stream()
.map(tp -> new ElasticTaskPair(tp.getTask(), tp.getTransition()))
.collect(Collectors.toSet());
enabledRoles = useCase.getEnabledRoles() == null ? new HashSet<>() : new HashSet<>(useCase.getEnabledRoles());
viewRoles = useCase.getViewRoles() == null ? new HashSet<>() : new HashSet<>(useCase.getViewRoles());
viewUserRefs = useCase.getViewUserRefs() == null ? new HashSet<>() : new HashSet<>(useCase.getViewUserRefs());
negativeViewRoles = useCase.getNegativeViewRoles() == null ? new HashSet<>() : new HashSet<>(useCase.getNegativeViewRoles());
viewUsers = useCase.getViewUsers() == null ? new HashSet<>() : new HashSet<>(useCase.getViewUsers());
negativeViewUsers = useCase.getNegativeViewUsers() == null ? new HashSet<>() : new HashSet<>(useCase.getNegativeViewUsers());
tags = useCase.getTags() == null ? new HashMap<>() : new HashMap<>(useCase.getTags());
permissions = deepCopy(useCase.getPermissions());
users = deepCopy(useCase.getUsers());
userRefs = deepCopy(useCase.getUserRefs());
dataSet = useCase.getDataSet() == null ? new HashMap<>() : useCase.getDataSet().entrySet().stream()
.filter(entry -> entry.getValue() != null)
.collect(Collectors.toMap(Map.Entry::getKey, entry -> CopyConstructorUtil.copy(entry.getValue().getClass(), entry.getValue())));
Comment thread
coderabbitai[bot] marked this conversation as resolved.
immediateData = useCase.getImmediateData() == null ? new ArrayList<>() : useCase.getImmediateData().stream()
.map(field -> new ImmediateField(field.getStringId(), new I18nString(field.getName()), field.getType()))
.collect(Collectors.toList());
}

private static Map<String, Map<String, Boolean>> deepCopy(Map<String, Map<String, Boolean>> map) {
if (map == null || map.isEmpty()) {
return new HashMap<>();
}
return map.entrySet().stream().collect(Collectors.toMap(Map.Entry::getKey, e -> e.getValue() == null ? new HashMap<>() : new HashMap<>(e.getValue())));
}
Comment thread
coderabbitai[bot] marked this conversation as resolved.
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;

import java.util.Arrays;
import java.util.List;


Expand All @@ -14,6 +15,11 @@ public abstract class FieldWithAllowedNetsField extends DataField {

public String[] allowedNets;

public FieldWithAllowedNetsField(FieldWithAllowedNetsField field) {
super(field);
this.allowedNets = field.allowedNets == null ? null : Arrays.copyOf(field.allowedNets, field.allowedNets.length);
}

public FieldWithAllowedNetsField(String fullTextValue, String[] allowedNets) {
super(fullTextValue);
this.allowedNets = allowedNets;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@ public abstract class FileField extends DataField {

public String[] fileExtensionValue;

public FileField(FileField fileField) {
super(fileField);
this.filePath = fileField.getFilePath() == null ? null : Arrays.copyOf(fileField.filePath, fileField.filePath.length);
this.fileNameValue = fileField.getFileNameValue() == null ? null : Arrays.copyOf(fileField.fileNameValue, fileField.fileNameValue.length);
this.fileExtensionValue = fileField.getFileExtensionValue() == null ? null : Arrays.copyOf(fileField.fileExtensionValue, fileField.fileExtensionValue.length);
}

public FileField(FileFieldValue value) {
super(value.getName());
this.filePath = new String[1];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ public abstract class FilterField extends FieldWithAllowedNetsField {

public Map<String, Object> filterMetadata;

public FilterField(FilterField field) {
super(field);
this.filterMetadata = field.filterMetadata == null ? null : new HashMap<>(field.filterMetadata);
}

public FilterField(String fullTextValue, String[] allowedNets, Map<String, Object> filterMetadata) {
super(fullTextValue, allowedNets);
this.filterMetadata = filterMetadata != null ? filterMetadata : new HashMap<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;

import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;

Expand All @@ -17,6 +19,12 @@ public abstract class I18nField extends TextField {

public Map<String, String> translations;

public I18nField(I18nField field) {
super(field);
this.keyValue = field.keyValue == null ? null : Arrays.copyOf(field.keyValue, field.keyValue.length);
this.translations = field.translations == null ? null : new HashMap<>(field.translations);
}

public I18nField(Set<String> keys, Set<String> values, Map<String, String> translations) {
super(new String[0]);
this.keyValue = keys.toArray(new String[0]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,12 @@ public ImmediateField() {
}

public ImmediateField(Field<?> field) {
this.stringId = field.getStringId();
this.name = field.getName();
this.type = field.getType().getName();
this(field.getStringId(), field.getName(), field.getType().getName());
}

public ImmediateField(String stringId, I18nString name, String type) {
this.stringId = stringId;
this.name = name;
this.type = type;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import lombok.NoArgsConstructor;

import java.util.*;
import java.util.stream.Collectors;

@Data
@NoArgsConstructor
Expand All @@ -15,6 +16,14 @@ public abstract class MapField extends TextField {
public String[] keyValue;
public Map<String, I18nString> keyValueTranslations;

public MapField(MapField field) {
super(field);
this.keyValue = field.keyValue == null ? null : Arrays.copyOf(field.keyValue, field.keyValue.length);
this.keyValueTranslations = field.keyValueTranslations == null ? null
: field.keyValueTranslations.entrySet().stream()
.collect(Collectors.toMap(Map.Entry::getKey, entry -> new I18nString(entry.getValue())));
}

public MapField(Map.Entry<String, I18nString> valueTranslationPair) {
this(List.of(valueTranslationPair));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ public abstract class NumberField extends DataField {

public Double numberValue;

public NumberField(NumberField field) {
super(field);
this.numberValue = field.numberValue;
}

public NumberField(Double value) {
super(value.toString());
this.numberValue = value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,20 @@
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;

import java.util.Arrays;

@Data
@NoArgsConstructor
@EqualsAndHashCode(callSuper = true)
public abstract class StringCollectionField extends TextField {

public String[] collectionValue;

public StringCollectionField(StringCollectionField field) {
super(field);
this.collectionValue = field.collectionValue == null ? null : Arrays.copyOf(field.collectionValue, field.collectionValue.length);
}

public StringCollectionField(String[] values) {
super(values);
this.collectionValue = values;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ public abstract class TextField extends DataField {

public String[] textValue;

public TextField(TextField field) {
super(field);
this.textValue = field.textValue == null ? null : field.textValue.clone();
}

public TextField(String value) {
super(value);
this.textValue = new String[1];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;

import java.util.Arrays;
import java.util.stream.IntStream;

@Data
Expand All @@ -23,6 +24,14 @@ public abstract class UserField extends DataField {

private String[] userRealmIdValue;

public UserField(UserField field) {
super(field);
this.usernameValue = field.usernameValue == null ? null : Arrays.copyOf(field.usernameValue, field.usernameValue.length);
this.fullNameValue = field.fullNameValue == null ? null : Arrays.copyOf(field.fullNameValue, field.fullNameValue.length);
this.userIdValue = field.userIdValue == null ? null : Arrays.copyOf(field.userIdValue, field.userIdValue.length);
this.userRealmIdValue = field.userRealmIdValue == null ? null : Arrays.copyOf(field.userRealmIdValue, field.userRealmIdValue.length);
}

public UserField(UserMappingData value) {
super(String.format("%s %s", value.fullName, value.username));
this.usernameValue = new String[1];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;

import java.util.Arrays;

@Data
@NoArgsConstructor
@AllArgsConstructor
Expand All @@ -19,6 +21,14 @@ public abstract class UserListField extends UserField {

private String[] userRealmIdValue;

public UserListField(UserListField field) {
super(field);
this.usernameValue = field.usernameValue == null ? null : Arrays.copyOf(field.usernameValue, field.usernameValue.length);
this.fullNameValue = field.fullNameValue == null ? null : Arrays.copyOf(field.fullNameValue, field.fullNameValue.length);
this.userIdValue = field.userIdValue == null ? null : Arrays.copyOf(field.userIdValue, field.userIdValue.length);
this.userRealmIdValue = field.userRealmIdValue == null ? null : Arrays.copyOf(field.userRealmIdValue, field.userRealmIdValue.length);
}

public UserListField(UserMappingData[] values) {
super(values);
this.usernameValue = new String[values.length];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ public class BooleanField extends com.netgrif.application.engine.objects.elastic
@Field(type = Boolean)
public Boolean booleanValue;

public BooleanField(BooleanField field) {
super(field);
this.booleanValue = field.booleanValue;
}

public BooleanField(Boolean value) {
super(value);
this.booleanValue = value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
@EqualsAndHashCode(callSuper = true)
public class ButtonField extends com.netgrif.application.engine.objects.elastic.domain.ButtonField {

public ButtonField(ButtonField field) {
super(field);
}

public ButtonField(Integer value) {
super(value);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
@NoArgsConstructor
public class CaseField extends com.netgrif.application.engine.objects.elastic.domain.CaseField {

public CaseField(CaseField field) {
super(field);
}

public CaseField(String[] values, String[] allowedNets) {
super(values, allowedNets);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
@NoArgsConstructor
public class DateField extends com.netgrif.application.engine.objects.elastic.domain.DateField {

public DateField(DateField field) {
super(field);
}

public DateField(String value, LocalDateTime dateTime) {
super(value, dateTime);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
@EqualsAndHashCode(callSuper = true)
public class FileField extends com.netgrif.application.engine.objects.elastic.domain.FileField {

public FileField(FileField field) {
super(field);
}

public FileField(FileFieldValue value) {
super(value);
}
Expand Down
Loading
Loading