Skip to content
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

Issue #2271 - Entity Centre: insertion points to support non-default selection criteria for embedded centres upon run #2276

Open
wants to merge 27 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
d73a754
#2271 Added option NO_CRITERIA_CLEARING to runAutomatically() in Cent…
jhou-pro Jun 14, 2024
ef89815
Merge branch 'develop' into Issue-#2271
01es Jun 21, 2024
334facb
#2271 Preserve save-as (named) configurations locally for embedded ce…
jhou-pro Jun 26, 2024
f5fba6a
#2271 Preserve save-as (named) configurations in the server-side for …
jhou-pro Jun 26, 2024
4cff9be
#2271 Added centreChanged calculations to any logic where centre stat…
jhou-pro Jul 11, 2024
7915e23
#2271 Propagated named config names / descs to parent insertion point…
jhou-pro Jul 11, 2024
9927e93
Revert "#2271 Added centreChanged calculations to any logic where cen…
jhou-pro Jul 11, 2024
1450ee5
#2271 Introduced criteriaChanged param instead of centreChanged param…
jhou-pro Jul 11, 2024
b2fe6de
#2271 Renamed staleCriteriaMessage to criteriaIndication. Preliminary…
jhou-pro Jul 17, 2024
67297c3
#2271 Added CriteriaIndication enum with its serialiser. Read seriali…
jhou-pro Jul 17, 2024
5059ae9
#2271 Removed usages of non-existent 'standart-action' css class.
jhou-pro Jul 17, 2024
732ea73
#2271 Added links to CriteriaIndication in javadoc.
jhou-pro Jul 17, 2024
22cdbe4
#2271 Enhanced docs.
jhou-pro Jul 18, 2024
0a68ea9
#2271 Adjusted / tightened web test.
jhou-pro Jul 18, 2024
2435f38
Merge branch 'refs/heads/develop' into Issue-#2271
jhou-pro Jul 18, 2024
07f19e7
#2271 Removed unnecessary observer with logging.
jhou-pro Jul 18, 2024
3e17693
#2271 Improved selectionCriteriaEquals API and implementation.
jhou-pro Jul 19, 2024
d62d95b
#2271 Removed 'improv' that actually breaks method due to full eq check.
jhou-pro Jul 19, 2024
21c5246
#2271 Removed unused parameter.
jhou-pro Jul 19, 2024
4acfa2d
#2271 Removed unused parameters.
jhou-pro Jul 19, 2024
1e00c61
#2271 First steps to efficiently update Show Selection Criteria butto…
jhou-pro Jul 20, 2024
e14e67c
#2271 Enhanced post-SAVE criteria indication to avoid false stale cri…
jhou-pro Jul 20, 2024
334dfbe
#2271 Corrected the problem where SAVE action fails in case where no …
jhou-pro Aug 1, 2024
0e8255f
#2271 Made saving action debounced in 50 ms as in Entity Masters. Mad…
jhou-pro Aug 1, 2024
5929ae4
#2271 Avoided unnecessary updateCentre operation during Run for non-d…
jhou-pro Aug 1, 2024
38d7f0f
Merge branch 'refs/heads/develop' into Issue-#2271
jhou-pro Aug 2, 2024
0a12fc0
Merge branch 'refs/heads/develop' into Issue-#2271
jhou-pro Aug 20, 2024
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
@@ -1,88 +1,5 @@
package ua.com.fielden.platform.web.resources.webui;

import static java.lang.String.format;
import static java.util.Optional.empty;
import static java.util.Optional.of;
import static java.util.Optional.ofNullable;
import static java.util.UUID.randomUUID;
import static java.util.concurrent.TimeUnit.SECONDS;
import static ua.com.fielden.platform.data.generator.IGenerator.FORCE_REGENERATION_KEY;
import static ua.com.fielden.platform.data.generator.IGenerator.shouldForceRegeneration;
import static ua.com.fielden.platform.error.Result.failure;
import static ua.com.fielden.platform.security.tokens.Template.READ;
import static ua.com.fielden.platform.security.tokens.TokenUtils.authoriseReading;
import static ua.com.fielden.platform.streaming.ValueCollectors.toLinkedHashMap;
import static ua.com.fielden.platform.types.either.Either.left;
import static ua.com.fielden.platform.types.either.Either.right;
import static ua.com.fielden.platform.types.tuples.T2.t2;
import static ua.com.fielden.platform.utils.CollectionUtil.linkedMapOf;
import static ua.com.fielden.platform.utils.EntityUtils.areEqual;
import static ua.com.fielden.platform.utils.EntityUtils.equalsEx;
import static ua.com.fielden.platform.web.centre.CentreConfigUtils.isDefault;
import static ua.com.fielden.platform.web.centre.CentreConfigUtils.isDefaultOrLink;
import static ua.com.fielden.platform.web.centre.CentreConfigUtils.isInherited;
import static ua.com.fielden.platform.web.centre.CentreUpdater.FRESH_CENTRE_NAME;
import static ua.com.fielden.platform.web.centre.CentreUpdater.NAME_OF;
import static ua.com.fielden.platform.web.centre.CentreUpdater.PREVIOUSLY_RUN_CENTRE_NAME;
import static ua.com.fielden.platform.web.centre.CentreUpdater.SAVED_CENTRE_NAME;
import static ua.com.fielden.platform.web.centre.CentreUpdater.commitCentreDiffWithoutConflicts;
import static ua.com.fielden.platform.web.centre.CentreUpdater.commitCentreWithoutConflicts;
import static ua.com.fielden.platform.web.centre.CentreUpdater.createEmptyDifferences;
import static ua.com.fielden.platform.web.centre.CentreUpdater.defaultRunAutomatically;
import static ua.com.fielden.platform.web.centre.CentreUpdater.extendDiffsWithNonIntrusiveDifferences;
import static ua.com.fielden.platform.web.centre.CentreUpdater.getDefaultCentre;
import static ua.com.fielden.platform.web.centre.CentreUpdater.loadableConfigurations;
import static ua.com.fielden.platform.web.centre.CentreUpdater.makePreferred;
import static ua.com.fielden.platform.web.centre.CentreUpdater.obtainTitleFrom;
import static ua.com.fielden.platform.web.centre.CentreUpdater.removeCentres;
import static ua.com.fielden.platform.web.centre.CentreUpdater.retrievePreferredConfigName;
import static ua.com.fielden.platform.web.centre.CentreUpdater.updateCentre;
import static ua.com.fielden.platform.web.centre.CentreUpdater.updateCentreConfigUuid;
import static ua.com.fielden.platform.web.centre.CentreUpdater.updateCentreDesc;
import static ua.com.fielden.platform.web.centre.CentreUpdaterUtils.FETCH_CONFIG;
import static ua.com.fielden.platform.web.centre.CentreUpdaterUtils.FETCH_CONFIG_AND_INSTRUMENT;
import static ua.com.fielden.platform.web.centre.CentreUpdaterUtils.findConfigOpt;
import static ua.com.fielden.platform.web.centre.CentreUpdaterUtils.findConfigOptByUuid;
import static ua.com.fielden.platform.web.centre.CentreUpdaterUtils.saveNewEntityCentreManager;
import static ua.com.fielden.platform.web.centre.CentreUtils.isFreshCentreChanged;
import static ua.com.fielden.platform.web.centre.WebApiUtils.LINK_CONFIG_TITLE;
import static ua.com.fielden.platform.web.factories.webui.ResourceFactoryUtils.extractSaveAsName;
import static ua.com.fielden.platform.web.factories.webui.ResourceFactoryUtils.wasLoadedPreviouslyAndConfigUuid;
import static ua.com.fielden.platform.web.resources.webui.CentreResourceUtils.CENTRE_DIRTY;
import static ua.com.fielden.platform.web.resources.webui.CentreResourceUtils.CONFIG_DOES_NOT_EXIST;
import static ua.com.fielden.platform.web.resources.webui.CentreResourceUtils.META_VALUES;
import static ua.com.fielden.platform.web.resources.webui.CentreResourceUtils.STALE_CRITERIA_MESSAGE;
import static ua.com.fielden.platform.web.resources.webui.CentreResourceUtils.complementCriteriaEntityBeforeRunning;
import static ua.com.fielden.platform.web.resources.webui.CentreResourceUtils.createCriteriaEntityWithoutConflicts;
import static ua.com.fielden.platform.web.resources.webui.CentreResourceUtils.createCriteriaMetaValues;
import static ua.com.fielden.platform.web.resources.webui.CentreResourceUtils.createCriteriaMetaValuesCustomObject;
import static ua.com.fielden.platform.web.resources.webui.CentreResourceUtils.createCriteriaMetaValuesCustomObjectWithResult;
import static ua.com.fielden.platform.web.resources.webui.CentreResourceUtils.createCriteriaMetaValuesCustomObjectWithSaveAsInfo;
import static ua.com.fielden.platform.web.resources.webui.CentreResourceUtils.createCriteriaValidationPrototype;
import static ua.com.fielden.platform.web.resources.webui.CentreResourceUtils.isAutoRunning;
import static ua.com.fielden.platform.web.resources.webui.CentreResourceUtils.isRunning;
import static ua.com.fielden.platform.web.resources.webui.CentreResourceUtils.isSorting;
import static ua.com.fielden.platform.web.resources.webui.CentreResourceUtils.updateInheritedFromShared;
import static ua.com.fielden.platform.web.resources.webui.EntityValidationResource.VALIDATION_COUNTER;
import static ua.com.fielden.platform.web.resources.webui.MultiActionUtils.createPrimaryActionIndicesForCentre;
import static ua.com.fielden.platform.web.resources.webui.MultiActionUtils.createPropertyActionIndicesForCentre;
import static ua.com.fielden.platform.web.resources.webui.MultiActionUtils.createSecondaryActionIndicesForCentre;
import static ua.com.fielden.platform.web.utils.EntityResourceUtils.getEntityType;
import static ua.com.fielden.platform.web.utils.WebUiResourceUtils.handleUndesiredExceptions;
import static ua.com.fielden.platform.web.utils.WebUiResourceUtils.restoreCentreContextHolder;
import static ua.com.fielden.platform.web.utils.WebUiResourceUtils.restoreModifiedPropertiesHolderFrom;

import java.util.*;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.Supplier;
import java.util.stream.Collectors;
import java.util.stream.Stream;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.restlet.Context;
Expand All @@ -92,7 +9,6 @@
import org.restlet.resource.Get;
import org.restlet.resource.Post;
import org.restlet.resource.Put;

import ua.com.fielden.platform.criteria.generator.ICriteriaGenerator;
import ua.com.fielden.platform.dao.IEntityDao;
import ua.com.fielden.platform.data.generator.IGenerator;
Expand Down Expand Up @@ -133,6 +49,47 @@
import ua.com.fielden.platform.web.interfaces.IDeviceProvider;
import ua.com.fielden.platform.web.resources.RestServerUtil;

import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.Supplier;
import java.util.stream.Collectors;
import java.util.stream.Stream;

import static java.lang.String.format;
import static java.util.Optional.*;
import static java.util.UUID.randomUUID;
import static java.util.concurrent.TimeUnit.SECONDS;
import static ua.com.fielden.platform.data.generator.IGenerator.FORCE_REGENERATION_KEY;
import static ua.com.fielden.platform.data.generator.IGenerator.shouldForceRegeneration;
import static ua.com.fielden.platform.error.Result.failure;
import static ua.com.fielden.platform.security.tokens.Template.READ;
import static ua.com.fielden.platform.security.tokens.TokenUtils.authoriseReading;
import static ua.com.fielden.platform.streaming.ValueCollectors.toLinkedHashMap;
import static ua.com.fielden.platform.types.either.Either.left;
import static ua.com.fielden.platform.types.either.Either.right;
import static ua.com.fielden.platform.types.tuples.T2.t2;
import static ua.com.fielden.platform.utils.CollectionUtil.linkedMapOf;
import static ua.com.fielden.platform.utils.EntityUtils.areEqual;
import static ua.com.fielden.platform.utils.EntityUtils.equalsEx;
import static ua.com.fielden.platform.web.centre.CentreConfigUtils.*;
import static ua.com.fielden.platform.web.centre.CentreUpdater.removeCentres;
import static ua.com.fielden.platform.web.centre.CentreUpdater.*;
import static ua.com.fielden.platform.web.centre.CentreUpdaterUtils.*;
import static ua.com.fielden.platform.web.centre.CentreUtils.isFreshCentreChanged;
import static ua.com.fielden.platform.web.centre.WebApiUtils.LINK_CONFIG_TITLE;
import static ua.com.fielden.platform.web.factories.webui.ResourceFactoryUtils.extractSaveAsName;
import static ua.com.fielden.platform.web.factories.webui.ResourceFactoryUtils.wasLoadedPreviouslyAndConfigUuid;
import static ua.com.fielden.platform.web.resources.webui.CentreResourceUtils.*;
import static ua.com.fielden.platform.web.resources.webui.EntityValidationResource.VALIDATION_COUNTER;
import static ua.com.fielden.platform.web.resources.webui.MultiActionUtils.*;
import static ua.com.fielden.platform.web.utils.EntityResourceUtils.getEntityType;
import static ua.com.fielden.platform.web.utils.WebUiResourceUtils.*;

/**
* The web resource for criteria serves as a back-end mechanism of criteria retrieval. It provides a base implementation for handling the following methods:
* <ul>
Expand Down Expand Up @@ -606,7 +563,7 @@ public Representation put(final Representation envelope) {
final EnhancedCentreEntityQueryCriteria<?, ?> freshCentreAppliedCriteriaEntity;

if (isRunning) {
if (isAutoRunning(customObject) && isDefault(saveAsName) && defaultRunAutomatically(miType, webUiConfig)) { // do not clear criteria in case where user explicitly changed runAutomatically from false (Centre DSL value) to true in Configure dialog
if (isAutoRunning(customObject) && isDefault(saveAsName) && ofNullable(webUiConfig.getCentres().get(miType)).map(EntityCentre::isRunAutomaticallyAndAllowsCritClearing).orElse(false)) { // do not clear criteria in case where user explicitly changed runAutomatically from false (Centre DSL value) to true in Configure dialog or if NO_CRITERIA_CLEARING option was used
// clear current 'default' surrogate centres -- this is to make them empty before auto-running; saved configurations will not be touched
final ICentreDomainTreeManagerAndEnhancer previousFreshCentre = updateCentre(user, miType, FRESH_CENTRE_NAME, saveAsName, device(), webUiConfig, eccCompanion, mmiCompanion, userCompanion, companionFinder);
final ICentreDomainTreeManagerAndEnhancer defaultCentre = getDefaultCentre(miType, webUiConfig);
Expand Down
Loading