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

Entity Centre: API for config modification and running #2224

Open
3 tasks
jhou-pro opened this issue Mar 28, 2024 · 1 comment
Open
3 tasks

Entity Centre: API for config modification and running #2224

jhou-pro opened this issue Mar 28, 2024 · 1 comment

Comments

@jhou-pro
Copy link
Contributor

Description

Currently there is an abstraction (ICriteriaEntityRestorer) that allows running of Entity Centre in functional entity companion. However this is only narrowed down to the cases where selectionCriteria was added into the context of functional entity.

At this stage there is a need to have API for the following three cases:

  • Create default Entity Centre configuration from miType with ability modify it through ICentreDomainTreeManagerAndEnhancer and to run it; no database interactions needed here
  • Create Entity Centre configuration copy from miType + saveAsName for current user with ability modify it through ICentreDomainTreeManagerAndEnhancer and to run it; original configuration should not be affected; original configuration should always drive downstream changes
  • Create Entity Centre configuration copy from miType + saveAsName + user with ability modify it through ICentreDomainTreeManagerAndEnhancer and to run it; original configuration should not be affected; original configuration should always drive downstream changes; configuration "sharing" mechanism may be used for implementation i.e. to guard security aspect of this

Impl details

ICriteriaEntityCreator interface may be added for these three cases. Some thoughts:

  1. miType at first may be represented as String full class name, until we consider moving this UI concept to pojo-bl modules
  2. configUuid should be considered to be used instead of saveAsName
  3. at this stage we only use PREVIOUSLY_RUN surrogate centre for running named/default configuration; for second/third cases we probably want to take SAVED configuration and make a copy from it
  4. we don't want to have second/third cases present in Load Config dialog for respective users

Expected outcome

Ability for developer to run any centre configuration inside [functional] entity companions.

@jhou-pro
Copy link
Contributor Author

First case may be achieved with following (but one PREVIOUSLY_RUN EntityCentreConfig record will be created each time):

final var centreContextHolder = new CentreContextHolder();
centreContextHolder.setCustomObject(linkedMapOf(t2("@@miType", "fielden.main.menu.work.MiReWorkActivity"), t2("@@saveAsName", UUID.randomUUID().toString())));
centreContextHolder.setModifHolder(linkedMapOf(t2("version", 0)));
final var criteriaEntity = criteriaEntityRestorer.restoreCriteriaEntity(centreContextHolder);

final var rootType = ReWorkActivity.class;
criteriaEntity.getCentreDomainTreeMangerAndEnhancer().getFirstTick().setValue(rootType, ReWorkActivity_.scheduledStart_, new DateTime().withTimeAtStartOfDay().toDate());
criteriaEntity.getCentreDomainTreeMangerAndEnhancer().getFirstTick().setValue2(rootType, ReWorkActivity_.scheduledStart_, new DateTime().withTime(23, 59, 59, 999).toDate());

final var was = co(rootType).getFirstEntities(
    from(criteriaEntity.createQuery().modelAsEntity(rootType))
    .with(criteriaEntity.createResultSetFetchProvider().copy(rootType).fetchModel())
    .with(criteriaEntity.getParameters())
    .with(DynamicOrderingBuilder.createOrderingModel(rootType, criteriaEntity.getCentreDomainTreeMangerAndEnhancer().getSecondTick().orderedProperties(rootType)))
    .model(),
    100
);
System.out.println("was = " + was);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant