Skip to content

Conversation

@carldea
Copy link
Contributor

@carldea carldea commented May 19, 2025

This branch contains.

  1. fix to exception when creating a semantic
  2. fix to use window topic instead of journal topic
  3. support many dnd sources such as original concept nav

@carldea carldea requested review from dholubek and swaroopsalvi May 19, 2025 22:37
Copy link
Contributor

@dukke dukke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@carldea Just had a quick look as it's a bit late here :) Added 1 comment from that very brief look.

@carldea carldea requested review from aks8m and rbradley813 May 20, 2025 04:00
ObjectProperty<EntityFacade> refComponent = genEditingViewModel.getObjectProperty(REF_COMPONENT);
//Enable edit fields button if refComponent is NOT null else disable it.
editFieldsButton.setDisable(refComponent == null);
editFieldsButton.setDisable(refComponent.isNull().get());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can do a bind here:
editFieldsButton.disableProperty().bind(refComponent.isNull());
And then I think we won't need to manually update it anymore below.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call! We should create another ticket since this is merged already.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@carldea yes, a ticket is a good idea! Do you want me to create it?
There are a bunch of places perhaps we should clean up.. including my code (for instance KLComponentSet control is still in the repo but we don't need it anymore).
Perhaps we could take some time after the demo to reduce some of our technical debt?

editFieldsButton.setDisable(refComponent.isNull().get());
//Enable reference component edit button if refComponent is NULL else disable it.
addReferenceButton.setDisable(refComponent != null);
addReferenceButton.setDisable(refComponent.isNotNull().get());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can do a bind here:
addReferenceButton.disableProperty().bind(refComponent.isNotNull());
And then I think we won't need to manually update it anymore below.

Copy link
Contributor

@dukke dukke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added some more comments.

I appreciate the commented out text saying we would get the database objects out of this control later. We share the same concerns. I understand that there's a time pressure to get this done before the demo. I hope we have time to do it later :)

if (parentMenu != null) {
parentMenu.getItems().clear();
TinkExecutor.threadPool().execute(TaskWrapper.make(new ViewMenuTask(viewCalculator, observableView),
(List<MenuItem> result) -> parentMenu.getItems().addAll(result)));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this menu already attached to a Scene? If so we'd want to use Platform.runLater to execute the code that changes the UI in the UI thread

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@carldea are we okay with editing this since it is shared code for the classic Komet's edit coordinate window in addition to the "read only for demo" one we generate for the Concept window...???

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am late getting these messages. It's too late in the game. But next time small stuff like this feel free to fix as a shared branch.
I agree with @dholubek this is read only for the demo and not to be invoked (trigger actions). But I believe the code was really lifted from classic Komet. Ideally when using a thread pool it provides activity information in the Activities tab for long running loads (building many menu options).

I think @dukke is correct that the parent (context menu) is attached to a Scene, and when adding to it (parentmenu) should be done on the JavaFX thread.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@carldea sounds good. Do you want me to add this to the ticket we mentioned?


try {
// EntityService.get().endLoadPhase();
createSemanticVersionTransactionTask(transaction).get(); // get() will block until transaction is finished (will refresh view calculator caches)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are inside the UI thread and we are blocked until get() returns, this will block the UI thread until the task is complete, and the UI will become unresponsive.
We could spawn a new thread. Inside that thread we run this code and after we have the results call all the code that updates the UI inside Platfrom.runLater

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dukke This is what we want, we would want the thread to complete before we send response. This is why we are getting the exception on create.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pedro is correct in that we should never block like this, but while fixing this issue we needed it to block in order to know diagnose why/when a transaction is finished creating a semantic. Swaroop was half/correct (from yesterday), but because of the fix in tinkar core we'd need to put the async code back in (surrounding the code above).

Let me explain.
Using a small dataset, the response time is negligible(fast), however if you use the snomed data, the creation code takes a very long time. Yesterday we found out the issue was code in the database code was asynchronous and we couldn't predict when the transaction was actually complete and the left side would query too soon and retrieve data from a stale cache.

Once we fixed that issue hence tinkar-core 1.103.0. I forgot to add the Completable futures code back in to not freeze the GUI. :(

Copy link
Contributor

@dukke dukke May 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@carldea Yeah now that you mentioned it, I do remember that in the code you posted on Teams in our group chat you were indeed creating a new thread and calling this code inside that thread.
I did a small test where I simulated a long running call to the database (using thread sleep and having the code be the same as in this PR) and indeed the UI completely froze.

I have a quick fix idea for this if you'd like me to share it.
We could change the createSemanticVersionTransactionTask method to have an additional parameter that would be a callback that is called when the transactions is finished. Something like this:

private Future<Void> createSemanticVersionTransactionTask(Transaction transaction, Runnable runAfterTransaction) {
        CommitTransactionTask commitTransactionTask = new CommitTransactionTask(transaction);
        return TinkExecutor.threadPool().submit(new Callable<Void>() {
            @Override
            public Void call() throws Exception {
                commitTransactionTask.call();
                runAfterTransaction.run();
                return null;
            }
        });
    }

Notice the runAfterTransaction runnable callback.

editFieldsButton.disableProperty().bind(newRefComponentProp.isNull());
addReferenceButton.disableProperty().bind(newRefComponentProp.isNotNull());
editFieldsButton.setDisable(newRefComponentProp.isNull().get());
addReferenceButton.setDisable(newRefComponentProp.isNotNull().get());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if we use binding above we won't need to update the disable property of the buttons again here

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was discussed and Carl specifically wanted to not have bind here. He has done this intentionally.

// Existing checks for next gen search navigator items to drag.
boolean nextGenSearchDnD = isADragAndDropInfo(dragEvent);

return classicConceptNavigatorDnD || classicSearchDnD || nextGenConceptNavigatorDnD || nextGenSearchDnD;
Copy link
Contributor

@dholubek dholubek May 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@carldea this is fixing what we can drop into a component, which is good, but it has a broad scope because the component is used by the Semantic window and the Pattern window in several places. So the permutations of testing all this is broad with classic Komet and next gen search against those two window types and all the places inside them that use the component also during edit and create modes... are we sure we want to introduce that much extra scope this late? Do we want to just stick to the transaction related fix on the Semantic?

Copy link
Contributor

@dukke dukke May 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dholubek @carldea I was thinking the same thing as Doug and I have to agree with him. :)
This is a valuable effort and it's good to have but I also think it's risky to introduce these new features at this stage (new drag and drop support).
We already post-poned 4 code line PRs that fixed bugs for the demo because we didn't want to risk it. This new drag and drop support introduces more than that and hence more risk and might not even be necessarily needed for the demo.
Would sticking to the semantic creation bug fix be better?

Copy link
Contributor

@dholubek dholubek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

approved... I made a few comments wrt to allowing both classic and next gen concepts into drag and drop and how that to me is a bit risky to add that scope this late... that is a concern of mine.

Copy link
Contributor

@swaroopsalvi swaroopsalvi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pros:

  1. Fixing create semantic issue (Exception thrown during creation fixed).
  2. Support for classic komet navigator drag and dorp and search -> Unit tested and ready.
  3. Integration tinkar-core 1.103.0 -> performance related fix in tinkar-core.
  4. Unblocks current sprint stories for updateVersion and semantic.

Cons:

  1. This is a last min change and will need some additional testing.
  2. It will freeze the UI while the save is in progress. (Side effect of the solution done.) -> Can be fixed.
  3. One of JavaFx rules to have Platform.runLater() to be used to update the UI code.

@swaroopsalvi swaroopsalvi merged commit e2c07fc into ikmdev:main May 20, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants