From 24424db994346cc480d02e69876e04149a0de4b6 Mon Sep 17 00:00:00 2001 From: swsalvi Date: Mon, 8 Sep 2025 19:06:33 -0400 Subject: [PATCH 1/5] Initial commit. --- .../mvvm/view/concept/ConceptController.java | 254 +++++++++--------- .../EditDescriptionFormController.java | 17 ++ .../EditFullyQualifiedNameController.java | 25 +- .../mvvm/viewmodel/ConceptViewModel.java | 37 ++- .../mvvm/view/concept/concept-details.fxml | 65 ++--- 5 files changed, 227 insertions(+), 171 deletions(-) diff --git a/kview/src/main/java/dev/ikm/komet/kview/mvvm/view/concept/ConceptController.java b/kview/src/main/java/dev/ikm/komet/kview/mvvm/view/concept/ConceptController.java index c4884daab..3a5749cd3 100644 --- a/kview/src/main/java/dev/ikm/komet/kview/mvvm/view/concept/ConceptController.java +++ b/kview/src/main/java/dev/ikm/komet/kview/mvvm/view/concept/ConceptController.java @@ -34,7 +34,7 @@ import static dev.ikm.komet.kview.mvvm.viewmodel.ConceptViewModel.CURRENT_ENTITY; import static dev.ikm.komet.kview.mvvm.viewmodel.ConceptViewModel.CURRENT_JOURNAL_WINDOW_TOPIC; import static dev.ikm.komet.kview.mvvm.viewmodel.ConceptViewModel.EDIT; -import static dev.ikm.komet.kview.mvvm.viewmodel.ConceptViewModel.FULLY_QUALIFIED_NAME; +import static dev.ikm.komet.kview.mvvm.viewmodel.ConceptViewModel.FULLY_QUALIFIED_NAMES; import static dev.ikm.komet.kview.mvvm.viewmodel.ConceptViewModel.OTHER_NAMES; import static dev.ikm.komet.kview.mvvm.viewmodel.FormViewModel.MODE; import static dev.ikm.komet.kview.mvvm.viewmodel.StampFormViewModelBase.StampProperties.IS_CONFIRMED_OR_SUBMITTED; @@ -111,7 +111,6 @@ import dev.ikm.tinkar.terms.TinkarTerm; import javafx.application.Platform; import javafx.beans.InvalidationListener; -import javafx.beans.property.ObjectProperty; import javafx.collections.ObservableList; import javafx.css.PseudoClass; import javafx.event.ActionEvent; @@ -215,20 +214,28 @@ public class ConceptController { @FXML private Button editConceptButton; - @FXML - private TextFlow fqnContainer; +// @FXML +// private TextFlow fqnContainer; - @FXML - private Text latestFqnText; +// @FXML +// private Text latestFqnText; - @FXML - private Text fqnDescriptionSemanticText; +// @FXML +// private Text fqnDescriptionSemanticText; - @FXML - private TextFlow fqnDateAddedTextFlow; +// @FXML +// private TextFlow fqnDateAddedTextFlow; +// @FXML +// private Label fqnAddDateLabel; + + @FXML + private Text fullyQualifiedNameHeaderText; + /** + * Responsible for holding rows of other names (regular) description semantics. + */ @FXML - private Label fqnAddDateLabel; + private KLExpandableNodeListControl fullyQualifiedNameNodeListControl; @FXML private Text otherNamesHeaderText; @@ -437,12 +444,15 @@ public void initialize() { eventBus.subscribe(conceptTopic, ClosePropertiesPanelEvent.class, closePropertiesPanelEventSubscriber); // Listener when user enters a new fqn - ObjectProperty fqnProp = getConceptViewModel().getProperty(FULLY_QUALIFIED_NAME); - fqnProp.addListener(observable -> { - // not null, populate banner area. - DescrName fqnDescrName = fqnProp.get(); - updateConceptBanner(); - updateFQNConceptDescription(fqnDescrName); + ObservableList fullyQualifiedNames = getConceptViewModel().getObservableList(FULLY_QUALIFIED_NAMES); + fullyQualifiedNames.addListener((InvalidationListener) observable -> { + if(!fullyQualifiedNames.isEmpty()){ + DescrName fqnDescrName = fullyQualifiedNames.get(0); + updateConceptBanner(); + } + updateFullyQualifiedNamesDescription(fullyQualifiedNames); +// updateConceptBanner(); +// updateFQNConceptDescription(fqnDescrName); }); ObservableList otherNames = getConceptViewModel().getObservableList(OTHER_NAMES); otherNames.addListener((InvalidationListener) obs -> { @@ -464,7 +474,7 @@ public void initialize() { if (CREATE.equals(conceptViewModel.getPropertyValue(MODE))) { if (evt.getEventType() == CreateConceptEvent.ADD_FQN) { - getConceptViewModel().setPropertyValue(FULLY_QUALIFIED_NAME, descrName); + getConceptViewModel().setPropertyValue(FULLY_QUALIFIED_NAMES, descrName); } else if (evt.getEventType() == CreateConceptEvent.ADD_OTHER_NAME) { otherNames.add(descrName); }else if (evt.getEventType() == CreateConceptEvent.EDIT_OTHER_NAME){ // Since we are @@ -499,7 +509,7 @@ public void initialize() { if (EDIT.equals(conceptViewModel.getPropertyValue(MODE))) { if (evt.getEventType() == EditConceptEvent.EDIT_FQN) { // the listener will fire on the FQN when we update this - getConceptViewModel().setPropertyValue(FULLY_QUALIFIED_NAME, descrName); + getConceptViewModel().setPropertyValue(FULLY_QUALIFIED_NAMES, descrName); } } }; @@ -677,7 +687,7 @@ private void setUpDescriptionContextMenu(Button addDescriptionButton) { private void onAddDescriptionButtonPressed(ActionEvent actionEvent) { if (this.conceptViewModel.getPropertyValue(MODE).equals(CREATE) && - (getConceptViewModel().getPropertyValue(FULLY_QUALIFIED_NAME) == null)) { + (getConceptViewModel().getPropertyValue(FULLY_QUALIFIED_NAMES) == null)) { // Show the context menu with 'Add Fully Qualified' option when it is a new concept in create mode and // there is no fully qualified name. fireContextMenuEvent(actionEvent, Side.RIGHT, 2, 0); @@ -726,7 +736,7 @@ private ContextMenu buildMenuOptionContextMenu() { Object[][] menuItems; // show the 'Add Fully Qualified' option when it is a new concept in create mode and there is no fully qualified name if (this.conceptViewModel.getPropertyValue(MODE).equals(CREATE) && - (getConceptViewModel().getPropertyValue(FULLY_QUALIFIED_NAME) == null)) { + (getConceptViewModel().getPropertyValue(FULLY_QUALIFIED_NAMES) == null)) { menuItems = new Object[][]{ {"ADD DESCRIPTION", true, new String[]{"menu-header-left-align"}, null, null}, {MenuHelper.SEPARATOR}, @@ -904,12 +914,12 @@ public void updateConceptBanner() { // TODO do a null check on the entityFacade // Title (FQN of concept) final ViewCalculator viewCalculator = conceptViewModel.getViewProperties().calculator(); - String conceptNameStr = viewCalculator.languageCalculator().getPreferredDescriptionTextWithFallbackOrNid(entityFacade.nid()); + String conceptNameStr = viewCalculator.languageCalculator().getDescriptionTextOrNid(entityFacade.nid()); fqnTitleText.setText(conceptNameStr); conceptNameTooltip.setText(conceptNameStr); // Definition description text - definitionTextField.setText(viewCalculator.languageCalculator().getPreferredDescriptionTextWithFallbackOrNid(entityFacade.nid())); + definitionTextField.setText(viewCalculator.languageCalculator().getDescriptionTextOrNid(entityFacade.nid())); setupDisplayUUID(entityFacade, viewCalculator); @@ -955,33 +965,46 @@ private void setupDisplayUUID(EntityFacade entityFacade, ViewCalculator viewCalc identifierControl.setPublicId(idStr); } - public void updateFQNConceptDescription(DescrName fqnDescrName) { - // populate UI with FQN and other names. e.g. Hello Solor (English | Case-insensitive) - // Latest FQN - String fullyQualifiedName = fqnDescrName.getNameText(); - latestFqnText.setText(fullyQualifiedName); - - fqnContainer.setOnMouseClicked(event -> eventBus.publish(conceptTopic, - new EditConceptFullyQualifiedNameEvent(latestFqnText, - EditConceptFullyQualifiedNameEvent.EDIT_FQN, fqnDescrName))); - // these should never be null, if the drop-downs are populated then the - // submit button will not be enabled on the Add FQN form - if (fqnDescrName.getCaseSignificance() != null && fqnDescrName.getLanguage() != null) { - fqnDescriptionSemanticText.setText(" (" + fqnDescrName.getCaseSignificance().description() - + ", " + fqnDescrName.getLanguage().description() + ")"); - } else { - LOG.error("missing case sensitivity and language when adding a fully qualified name"); - fqnDescriptionSemanticText.setText(""); - } +// public void updateFQNConceptDescription(DescrName fqnDescrName) { +// // populate UI with FQN and other names. e.g. Hello Solor (English | Case-insensitive) +// // Latest FQN +// String fullyQualifiedName = fqnDescrName.getNameText(); +// latestFqnText.setText(fullyQualifiedName); +// +// fqnContainer.setOnMouseClicked(event -> eventBus.publish(conceptTopic, +// new EditConceptFullyQualifiedNameEvent(latestFqnText, +// EditConceptFullyQualifiedNameEvent.EDIT_FQN, fqnDescrName))); +// // these should never be null, if the drop-downs are populated then the +// // submit button will not be enabled on the Add FQN form +// if (fqnDescrName.getCaseSignificance() != null && fqnDescrName.getLanguage() != null) { +// fqnDescriptionSemanticText.setText(" (" + fqnDescrName.getCaseSignificance().description() +// + ", " + fqnDescrName.getLanguage().description() + ")"); +// } else { +// LOG.error("missing case sensitivity and language when adding a fully qualified name"); +// fqnDescriptionSemanticText.setText(""); +// } +// +// fqnContainer.getChildren().setAll(latestFqnText, fqnDescriptionSemanticText); +// } - fqnContainer.getChildren().setAll(latestFqnText, fqnDescriptionSemanticText); + public void updateFullyQualifiedNamesDescription(List descrNameViewModels) { + fullyQualifiedNameNodeListControl.getItems().clear(); + descrNameViewModels.forEach(fullyQualifedName -> { + // start adding a row + VBox fullyQualifiedNameVBox = generateDescriptionSemanticRow(fullyQualifedName); + TextFlow firstRow = (TextFlow) fullyQualifiedNameVBox.getChildren().getFirst(); + firstRow.setOnMouseClicked(event -> eventBus.publish(conceptTopic, + new EditOtherNameConceptEvent(fullyQualifiedNameVBox, + EditConceptFullyQualifiedNameEvent.EDIT_FQN, fullyQualifedName))); + fullyQualifiedNameNodeListControl.getItems().add(fullyQualifiedNameVBox); + }); } public void updateOtherNamesDescription(List descrNameViewModels) { otherNamesNodeListControl.getItems().clear(); descrNameViewModels.forEach(otherName -> { // start adding a row - VBox otherNameBox = generateOtherNameRow(otherName); + VBox otherNameBox = generateDescriptionSemanticRow(otherName); TextFlow firstRow = (TextFlow) otherNameBox.getChildren().getFirst(); firstRow.setOnMouseClicked(event -> eventBus.publish(conceptTopic, new EditOtherNameConceptEvent(otherNameBox, @@ -1005,6 +1028,7 @@ public void updateConceptDescription() { // populate UI with FQN and other names. e.g. Hello Solor (English | Case-insensitive) Map> descriptionSemanticsMap = latestDescriptionSemantics(entityFacade); otherNamesNodeListControl.getItems().clear(); + fullyQualifiedNameNodeListControl.getItems().clear(); //Obtain the index field of DESCRIPTION_TYPE PatternEntityVersion patternEntityVersion = (PatternEntityVersion)viewCalculator.latest(DESCRIPTION_PATTERN.nid()).get(); @@ -1017,11 +1041,18 @@ public void updateConceptDescription() { if (isFQN) { // Latest FQN - updateFQNSemantics(semanticEntityVersion, fieldDescriptions); + // updateFQNSemantics(semanticEntityVersion, fieldDescriptions); + VBox fullyQualifiedNameBox = generateDescriptionSemanticRow(semanticEntityVersion, fieldDescriptions); + PublicId fullyQuallifiedNamePublicId = (PublicId) fullyQualifiedNameBox.getChildren().getFirst().getUserData(); + TextFlow row = (TextFlow) fullyQualifiedNameBox.getChildren().getFirst(); + row.setOnMouseClicked(event -> eventBus.publish(conceptTopic, + new EditConceptFullyQualifiedNameEvent(fullyQualifiedNameBox, + EditConceptFullyQualifiedNameEvent.EDIT_FQN, fullyQuallifiedNamePublicId))); + fullyQualifiedNameNodeListControl.getItems().add(fullyQualifiedNameBox); LOG.debug("FQN Name = " + semanticEntityVersion + " " + fieldDescriptions); } else if (isOtherName) { // start adding a row - VBox otherNameBox = generateOtherNameRow(semanticEntityVersion, fieldDescriptions); + VBox otherNameBox = generateDescriptionSemanticRow(semanticEntityVersion, fieldDescriptions); PublicId otherNamePublicId = (PublicId) otherNameBox.getChildren().getFirst().getUserData(); TextFlow firstRow = (TextFlow) otherNameBox.getChildren().getFirst(); firstRow.setOnMouseClicked(event -> eventBus.publish(conceptTopic, @@ -1033,6 +1064,10 @@ public void updateConceptDescription() { } }); + final int fullyQualifiedNameCount = fullyQualifiedNameNodeListControl.getItems().size(); + fullyQualifiedNameHeaderText.setText(fullyQualifiedNameCount > 0 ? + String.format("FULLY QUALIFIED NAMES (%d):", fullyQualifiedNameCount) : "FULLY QUALIFIED NAMES:"); + final int otherNamesCount = otherNamesNodeListControl.getItems().size(); otherNamesHeaderText.setText(otherNamesCount > 0 ? String.format("OTHER NAMES (%d):", otherNamesCount) : "OTHER NAMES:"); @@ -1045,7 +1080,7 @@ public void updateConceptDescription() { * @param fieldDescriptions * @return */ - private VBox generateOtherNameRow(SemanticEntityVersion semanticEntityVersion, List fieldDescriptions) { + private VBox generateDescriptionSemanticRow(SemanticEntityVersion semanticEntityVersion, List fieldDescriptions) { VBox textFlowsBox = new VBox(); String descrSemanticStr = String.join(", ", fieldDescriptions); @@ -1107,7 +1142,7 @@ private VBox generateOtherNameRow(SemanticEntityVersion semanticEntityVersion, L return textFlowsBox; } - private VBox generateOtherNameRow(DescrName otherName) { + private VBox generateDescriptionSemanticRow(DescrName otherName) { VBox textFlowsBox = new VBox(); ViewCalculator viewCalculator = conceptViewModel.getViewProperties().calculator(); ConceptEntity caseSigConcept = otherName.getCaseSignificance(); @@ -1187,51 +1222,51 @@ private VBox generateOtherNameRow(DescrName otherName) { return textFlowsBox; } - private void updateFQNSemantics(SemanticEntityVersion semanticEntityVersion, List fieldDescriptions) { - DateTimeFormatter DATE_TIME_FORMATTER = dateFormatter("MMM dd, yyyy"); - ViewCalculator viewCalculator = conceptViewModel.getViewProperties().calculator(); - String fqnTextDescr = viewCalculator.languageCalculator().getDescriptionTextOrNid(semanticEntityVersion.entity()); - // obtain the fqn description - latestFqnText.setText(fqnTextDescr); - System.out.println(" Inside FQN Semantics: " + fqnTextDescr); - - this.fqnPublicId = semanticEntityVersion.publicId(); - fqnContainer.setOnMouseClicked(event -> eventBus.publish(conceptTopic, - new EditConceptFullyQualifiedNameEvent(latestFqnText, - EditConceptFullyQualifiedNameEvent.EDIT_FQN, fqnPublicId))); - - String descrSemanticStr = String.join(", ", fieldDescriptions); - if (!fieldDescriptions.isEmpty()) { - fqnDescriptionSemanticText.setText(" (%s)".formatted(descrSemanticStr)); - } else { - fqnDescriptionSemanticText.setText(""); - } - - fqnContainer.getChildren().setAll(latestFqnText, fqnDescriptionSemanticText); - - // update date - String dateAddedStr = ""; - if (semanticEntityVersion.stamp() == null) { - dateAddedStr = LocalDate.now().format(DateTimeFormatter.ofPattern("MMM d, yyyy")).toString(); - } else { - Long fieldMilis = semanticEntityVersion.stamp().time(); - if (fieldMilis.equals(PREMUNDANE_TIME)) { - dateAddedStr = PREMUNDANE; - } else { - LocalDate localDate = Instant.ofEpochMilli(fieldMilis).atZone(ZoneId.systemDefault()).toLocalDate(); - dateAddedStr = localDate.format(DateTimeFormatter.ofPattern("MMM d, yyyy")).toString(); - } - } - fqnAddDateLabel.setText("Date Added: " + dateAddedStr); - - Region spacer = new Region(); - spacer.setMinWidth(10); - - Hyperlink attachmentHyperlink = createActionLink(IconsHelper.createIcon(ATTACHMENT)); - Hyperlink commentsHyperlink = createActionLink(IconsHelper.createIcon(COMMENTS)); - - fqnDateAddedTextFlow.getChildren().setAll(fqnAddDateLabel, spacer, attachmentHyperlink, commentsHyperlink); - } +// private void updateFQNSemantics(SemanticEntityVersion semanticEntityVersion, List fieldDescriptions) { +// DateTimeFormatter DATE_TIME_FORMATTER = dateFormatter("MMM dd, yyyy"); +// ViewCalculator viewCalculator = conceptViewModel.getViewProperties().calculator(); +// String fqnTextDescr = viewCalculator.languageCalculator().getDescriptionTextOrNid(semanticEntityVersion.entity()); +// // obtain the fqn description +// latestFqnText.setText(fqnTextDescr); +// System.out.println(" Inside FQN Semantics: " + fqnTextDescr); +// +// this.fqnPublicId = semanticEntityVersion.publicId(); +// fqnContainer.setOnMouseClicked(event -> eventBus.publish(conceptTopic, +// new EditConceptFullyQualifiedNameEvent(latestFqnText, +// EditConceptFullyQualifiedNameEvent.EDIT_FQN, fqnPublicId))); +// +// String descrSemanticStr = String.join(", ", fieldDescriptions); +// if (!fieldDescriptions.isEmpty()) { +// fqnDescriptionSemanticText.setText(" (%s)".formatted(descrSemanticStr)); +// } else { +// fqnDescriptionSemanticText.setText(""); +// } +// +// fqnContainer.getChildren().setAll(latestFqnText, fqnDescriptionSemanticText); +// +// // update date +// String dateAddedStr = ""; +// if (semanticEntityVersion.stamp() == null) { +// dateAddedStr = LocalDate.now().format(DateTimeFormatter.ofPattern("MMM d, yyyy")).toString(); +// } else { +// Long fieldMilis = semanticEntityVersion.stamp().time(); +// if (fieldMilis.equals(PREMUNDANE_TIME)) { +// dateAddedStr = PREMUNDANE; +// } else { +// LocalDate localDate = Instant.ofEpochMilli(fieldMilis).atZone(ZoneId.systemDefault()).toLocalDate(); +// dateAddedStr = localDate.format(DateTimeFormatter.ofPattern("MMM d, yyyy")).toString(); +// } +// } +// fqnAddDateLabel.setText("Date Added: " + dateAddedStr); +// +// Region spacer = new Region(); +// spacer.setMinWidth(10); +// +// Hyperlink attachmentHyperlink = createActionLink(IconsHelper.createIcon(ATTACHMENT)); +// Hyperlink commentsHyperlink = createActionLink(IconsHelper.createIcon(COMMENTS)); +// +// fqnDateAddedTextFlow.getChildren().setAll(fqnAddDateLabel, spacer, attachmentHyperlink, commentsHyperlink); +// } /** * Creates a hyperlink with the provided SVG icon. @@ -1401,14 +1436,12 @@ private void makeSheetItem(ViewProperties viewProperties, public void clearView() { definitionTextField.setText(""); identifierControl.setPublicId(""); - fqnAddDateLabel.setText(""); stampViewControl.clear(); notAvailInferredAxiomLabel.setVisible(true); notAvailStatedAxiomLabel.setVisible(true); - fqnContainer.getChildren().clear(); - fqnDateAddedTextFlow.getChildren().clear(); + fullyQualifiedNameNodeListControl.getItems().clear(); otherNamesNodeListControl.getItems().clear(); } @FXML @@ -1520,37 +1553,6 @@ private void popupAddContextMenu(ActionEvent actionEvent) { MenuHelper.fireContextMenuEvent(actionEvent, Side.BOTTOM, 0, 0); } - // TODO: I don't think this is needed but keeping it for a while because I've wrongly seen intellij flag something as not used -// private void updateUIStamp(ViewModel stampViewModel) { -// long time = stampViewModel.getValue(TIME); -// stampViewControl.setLastUpdated(TimeUtils.toDateString(time)); -// ViewProperties viewProperties = stampViewModel.getValue(VIEW_PROPERTIES); -// if(viewProperties == null){ -// viewProperties = conceptViewModel.getViewProperties(); -// } -// EntityFacade authorConcept = viewProperties.nodeView().editCoordinate().getAuthorForChanges(); -// stampViewModel.setValue(AUTHOR, authorConcept); -// -// if (authorConcept == null) { -// LOG.warn("Stamp should have an Author and doesn't"); -// return; -// } -// stampViewControl.setAuthor(ViewCalculatorUtils.getDescriptionTextWithFallbackOrNid(authorConcept, conceptViewModel.getViewProperties())); -// -// ConceptEntity moduleEntity = stampViewModel.getValue(MODULE); -// if (moduleEntity == null) { -// LOG.warn("Must select a valid module for Stamp."); -// return; -// } -// stampViewControl.setModule(ViewCalculatorUtils.getDescriptionTextWithFallbackOrNid(moduleEntity, conceptViewModel.getViewProperties())); -// -// ConceptEntity pathEntity = stampViewModel.getValue(PATH); -// stampViewControl.setPath(ViewCalculatorUtils.getDescriptionTextWithFallbackOrNid(pathEntity, conceptViewModel.getViewProperties())); -// -// State status = stampViewModel.getValue(STATUS); -// stampViewControl.setStatus(ViewCalculatorUtils.getDescriptionTextWithFallbackOrNid(status, conceptViewModel.getViewProperties())); -// } - public void compactSizeWindow() { descriptionsTitledPane.setExpanded(false); axiomsTitledPane.setExpanded(false); diff --git a/kview/src/main/java/dev/ikm/komet/kview/mvvm/view/properties/EditDescriptionFormController.java b/kview/src/main/java/dev/ikm/komet/kview/mvvm/view/properties/EditDescriptionFormController.java index d3317c79f..1635d5f7f 100644 --- a/kview/src/main/java/dev/ikm/komet/kview/mvvm/view/properties/EditDescriptionFormController.java +++ b/kview/src/main/java/dev/ikm/komet/kview/mvvm/view/properties/EditDescriptionFormController.java @@ -24,6 +24,7 @@ import static dev.ikm.komet.kview.mvvm.viewmodel.DescrNameViewModel.NAME_TYPE; import static dev.ikm.komet.kview.mvvm.viewmodel.DescrNameViewModel.STATUS; import static dev.ikm.tinkar.terms.TinkarTerm.DESCRIPTION_CASE_SIGNIFICANCE; +import static dev.ikm.tinkar.terms.TinkarTerm.DESCRIPTION_TYPE; import static dev.ikm.tinkar.terms.TinkarTerm.LANGUAGE_CONCEPT_NID_FOR_DESCRIPTION; import dev.ikm.komet.framework.view.ViewProperties; import dev.ikm.komet.kview.events.ClosePropertiesPanelEvent; @@ -160,6 +161,7 @@ public void initialize() { caseSignificanceComboBox.valueProperty().bindBidirectional(otherNameViewModel.getProperty(CASE_SIGNIFICANCE)); statusComboBox.valueProperty().bindBidirectional(otherNameViewModel.getProperty(STATUS)); languageComboBox.valueProperty().bindBidirectional(otherNameViewModel.getProperty(LANGUAGE)); + typeDisplayComboBox.valueProperty().bindBidirectional(otherNameViewModel.getProperty(NAME_TYPE)); InvalidationListener invalidationListener = obs -> validateForm(); @@ -168,6 +170,7 @@ public void initialize() { caseSignificanceComboBox.valueProperty().addListener(invalidationListener); statusComboBox.valueProperty().addListener(invalidationListener); languageComboBox.valueProperty().addListener(invalidationListener); + typeDisplayComboBox.valueProperty().addListener(invalidationListener); validateForm(); } @@ -369,6 +372,19 @@ public void setConceptAndPopulateForm(PublicId publicId) { findByNid(languageComboBox.getItems(), langConceptFacade.nid()) .ifPresent(concept -> otherNameViewModel.setPropertyValue(LANGUAGE, concept)); + // get all descendant types + IntIdSet descriptionTypeDecendants = viewProperties.parentView().calculator().descendentsOf(DESCRIPTION_TYPE.nid()); + Set allDescritionTypes = + descriptionTypeDecendants.intStream() + .mapToObj(typeNid -> (ConceptEntity) Entity.getFast(typeNid)) + .collect(Collectors.toSet()); + setupComboBox(typeDisplayComboBox, allDescritionTypes); + //Set selected value for DESCRIPTION TYPE + int indexType = patternEntityVersion.indexForMeaning(DESCRIPTION_TYPE); + ConceptFacade typeConceptFacade = (ConceptFacade) latestEntityVersion.get().fieldValues().get(indexType); + findByNid(typeDisplayComboBox.getItems(), typeConceptFacade.nid()) + .ifPresent(concept -> otherNameViewModel.setPropertyValue(NAME_TYPE, concept)); + //initial state of edit screen, the submit button should be disabled submitButton.setDisable(true); @@ -414,6 +430,7 @@ public void setConceptAndPopulateForm(DescrName descrName) { setupComboBox(statusComboBox, fetchDescendentsOfConcept(getViewProperties(), TinkarTerm.STATUS_VALUE.publicId())); setupComboBox(caseSignificanceComboBox, otherNameViewModel.findAllCaseSignificants(getViewProperties())); setupComboBox(languageComboBox, fetchDescendentsOfConcept(getViewProperties(), TinkarTerm.LANGUAGE.publicId())); + setupComboBox(typeDisplayComboBox, fetchDescendentsOfConcept(getViewProperties(), DESCRIPTION_TYPE.publicId())); otherNameViewModel.setPropertyValue(NAME_TEXT, descrName.getNameText()) .setPropertyValue(CASE_SIGNIFICANCE, descrName.getCaseSignificance()) .setPropertyValue(STATUS, descrName.getStatus()) diff --git a/kview/src/main/java/dev/ikm/komet/kview/mvvm/view/properties/EditFullyQualifiedNameController.java b/kview/src/main/java/dev/ikm/komet/kview/mvvm/view/properties/EditFullyQualifiedNameController.java index cebfbf81a..c0ab647c6 100644 --- a/kview/src/main/java/dev/ikm/komet/kview/mvvm/view/properties/EditFullyQualifiedNameController.java +++ b/kview/src/main/java/dev/ikm/komet/kview/mvvm/view/properties/EditFullyQualifiedNameController.java @@ -24,6 +24,7 @@ import static dev.ikm.komet.kview.mvvm.viewmodel.DescrNameViewModel.NAME_TYPE; import static dev.ikm.komet.kview.mvvm.viewmodel.DescrNameViewModel.STATUS; import static dev.ikm.tinkar.terms.TinkarTerm.DESCRIPTION_CASE_SIGNIFICANCE; +import static dev.ikm.tinkar.terms.TinkarTerm.DESCRIPTION_TYPE; import static dev.ikm.tinkar.terms.TinkarTerm.LANGUAGE_CONCEPT_NID_FOR_DESCRIPTION; import dev.ikm.komet.framework.view.ViewProperties; import dev.ikm.komet.kview.events.ClosePropertiesPanelEvent; @@ -154,6 +155,7 @@ public void initialize() { caseSignificanceComboBox.valueProperty().bindBidirectional(fqnViewModel.getProperty(CASE_SIGNIFICANCE)); statusComboBox.valueProperty().bindBidirectional(fqnViewModel.getProperty(STATUS)); languageComboBox.valueProperty().bindBidirectional(fqnViewModel.getProperty(LANGUAGE)); + typeDisplayComboBox.valueProperty().bindBidirectional(fqnViewModel.getProperty(NAME_TYPE)); InvalidationListener invalidationListener = obs -> validateForm(); @@ -162,6 +164,7 @@ public void initialize() { caseSignificanceComboBox.valueProperty().addListener(invalidationListener); statusComboBox.valueProperty().addListener(invalidationListener); languageComboBox.valueProperty().addListener(invalidationListener); + typeDisplayComboBox.valueProperty().addListener(invalidationListener); validateForm(); submitButton.setOnAction(this::updateFQN); @@ -275,8 +278,8 @@ public void setConceptAndPopulateForm(PublicId publicId) { Latest latestEntityVersion = viewCalculator.latest(nid); latestEntityVersion.ifPresent(semanticEntityVersion -> { StampEntity stampEntity = latestEntityVersion.get().stamp(); - String otherName = viewCalculator.getDescriptionText(nid).get(); - this.fqnText.setText(otherName); + String fullyQualifiedName = viewCalculator.getDescriptionText(nid).get(); + this.fqnText.setText(fullyQualifiedName); // get all descendant modules IntIdSet moduleDescendents = viewProperties.parentView().calculator().descendentsOf(TinkarTerm.MODULE.nid()); @@ -332,6 +335,20 @@ public void setConceptAndPopulateForm(PublicId publicId) { findByNid(languageComboBox.getItems(), langConceptFacade.nid()) .ifPresent(concept -> fqnViewModel.setPropertyValue(LANGUAGE, concept)); + + // get all descendant types + IntIdSet descriptionTypeDecendants = viewProperties.parentView().calculator().descendentsOf(DESCRIPTION_TYPE.nid()); + Set allDescritionTypes = + descriptionTypeDecendants.intStream() + .mapToObj(typeNid -> (ConceptEntity) Entity.getFast(typeNid)) + .collect(Collectors.toSet()); + setupComboBox(typeDisplayComboBox, allDescritionTypes); + //Set selected value for DESCRIPTION TYPE + int indexType = patternEntityVersion.indexForMeaning(DESCRIPTION_TYPE); + ConceptFacade typeConceptFacade = (ConceptFacade) latestEntityVersion.get().fieldValues().get(indexType); + findByNid(typeDisplayComboBox.getItems(), typeConceptFacade.nid()) + .ifPresent(concept -> fqnViewModel.setPropertyValue(NAME_TYPE, concept)); + //initial state of edit screen, the submit button should be disabled submitButton.setDisable(true); @@ -408,10 +425,12 @@ public void setConceptAndPopulateForm(DescrName descrName) { setupComboBox(statusComboBox, fetchDescendentsOfConcept(getViewProperties(), TinkarTerm.STATUS_VALUE.publicId())); setupComboBox(caseSignificanceComboBox, fqnViewModel.findAllCaseSignificants(getViewProperties())); setupComboBox(languageComboBox, fetchDescendentsOfConcept(getViewProperties(), TinkarTerm.LANGUAGE.publicId())); + setupComboBox(typeDisplayComboBox, fetchDescendentsOfConcept(getViewProperties(), DESCRIPTION_TYPE.publicId())); fqnViewModel.setPropertyValue(NAME_TEXT, descrName.getNameText()) .setPropertyValue(CASE_SIGNIFICANCE, descrName.getCaseSignificance()) .setPropertyValue(STATUS, descrName.getStatus()) .setPropertyValue(MODULE, descrName.getModule()) - .setPropertyValue(LANGUAGE, descrName.getLanguage()); + .setPropertyValue(LANGUAGE, descrName.getLanguage()) + .setPropertyValue(NAME_TYPE, descrName.getNameType()); } } diff --git a/kview/src/main/java/dev/ikm/komet/kview/mvvm/viewmodel/ConceptViewModel.java b/kview/src/main/java/dev/ikm/komet/kview/mvvm/viewmodel/ConceptViewModel.java index 3d2e9fb70..b0155d559 100644 --- a/kview/src/main/java/dev/ikm/komet/kview/mvvm/viewmodel/ConceptViewModel.java +++ b/kview/src/main/java/dev/ikm/komet/kview/mvvm/viewmodel/ConceptViewModel.java @@ -71,7 +71,7 @@ public class ConceptViewModel extends FormViewModel { // Known properties // -------------------------------------------- public static String CURRENT_ENTITY = "entityFacade"; - public static String FULLY_QUALIFIED_NAME = "fqn"; + public static String FULLY_QUALIFIED_NAMES = "fullyQualifiedNames"; public static String CONCEPT_STAMP_VIEW_MODEL = "stampViewModel"; public static String OTHER_NAMES = "otherNames"; @@ -84,7 +84,7 @@ public class ConceptViewModel extends FormViewModel { public ConceptViewModel() { super(); // addProperty(MODE, VIEW); By default addProperty(CURRENT_ENTITY, (EntityFacade) null) - .addProperty(FULLY_QUALIFIED_NAME, (Object) null) + .addProperty(FULLY_QUALIFIED_NAMES, (Collection) new ArrayList<>()) .addProperty(OTHER_NAMES, (Collection) new ArrayList<>()) .addProperty(CONCEPT_STAMP_VIEW_MODEL, (ViewModel) null) .addProperty(AXIOM, (String) null); @@ -92,15 +92,31 @@ public ConceptViewModel() { //FIXME add a STAMP validator // In Create Mode the fqn is required. - addValidator(FULLY_QUALIFIED_NAME, "Fully Qualified Name",(ReadOnlyObjectProperty prop, ViewModel vm) -> { - if (prop.isNull().get() - || prop.get() instanceof DescrNameViewModel fqnViewModel + addValidator(FULLY_QUALIFIED_NAMES, "Fully Qualified Names",(ReadOnlyObjectProperty prop, ViewModel vm) -> { + if ((prop.isNull().get() + || prop.get() instanceof List list + && list.isEmpty()) + || (prop.isNull().get() + || prop.get() instanceof List list + && !list.isEmpty() + && list.get(0) instanceof DescrNameViewModel fqnViewModel && fqnViewModel.getPropertyValue(NAME_TYPE) != TinkarTerm.FULLY_QUALIFIED_NAME_DESCRIPTION_TYPE && fqnViewModel.getPropertyValue(NAME_TEXT) != null - && fqnViewModel.getPropertyValue(NAME_TEXT).toString().isBlank()) { - - return new ValidationMessage(FULLY_QUALIFIED_NAME, MessageType.ERROR, "${%s} is required".formatted(FULLY_QUALIFIED_NAME)); + && fqnViewModel.getPropertyValue(NAME_TEXT).toString().isBlank() + )){ + return new ValidationMessage(FULLY_QUALIFIED_NAMES, MessageType.ERROR, "${%s} is required".formatted(FULLY_QUALIFIED_NAMES)); } +// if (prop.isNull().get() +// || prop.get() instanceof List list +// && !list.isEmpty() +// && list.get(0) instanceof DescrNameViewModel fqnViewModel +// && fqnViewModel.getPropertyValue(NAME_TYPE) != TinkarTerm.FULLY_QUALIFIED_NAME_DESCRIPTION_TYPE +// && fqnViewModel.getPropertyValue(NAME_TEXT) != null +// && fqnViewModel.getPropertyValue(NAME_TEXT).toString().isBlank() +// ) { +// +// return new ValidationMessage(FULLY_QUALIFIED_NAMES, MessageType.ERROR, "${%s} is required".formatted(FULLY_QUALIFIED_NAMES)); +// } return VALID; }); @@ -144,7 +160,8 @@ public boolean createConcept(StampFormViewModelBase stampFormViewModel) { } // Create concept - DescrName fqnDescrName = getPropertyValue(FULLY_QUALIFIED_NAME); + List fqnList = getPropertyValue(FULLY_QUALIFIED_NAMES); + DescrName fqnDescrName = fqnList.get(0); Transaction transaction = Transaction.make("New concept for: " + fqnDescrName.getNameText()); @@ -171,7 +188,7 @@ public boolean createConcept(StampFormViewModelBase stampFormViewModel) { ConceptFacade conceptFacade = EntityProxy.Concept.make(conceptRecord.publicId()) ; // add the Fully Qualified Name to the new concept - saveFQNwithinCreateConcept(transaction, stampEntity, getValue(FULLY_QUALIFIED_NAME), conceptFacade); + saveFQNwithinCreateConcept(transaction, stampEntity, fqnDescrName, conceptFacade); AxiomBuilderRecord ab = newConceptBuilder.axiomBuilder(); diff --git a/kview/src/main/resources/dev/ikm/komet/kview/mvvm/view/concept/concept-details.fxml b/kview/src/main/resources/dev/ikm/komet/kview/mvvm/view/concept/concept-details.fxml index f5e7bd7e5..2b20037bc 100644 --- a/kview/src/main/resources/dev/ikm/komet/kview/mvvm/view/concept/concept-details.fxml +++ b/kview/src/main/resources/dev/ikm/komet/kview/mvvm/view/concept/concept-details.fxml @@ -2,7 +2,7 @@ - + @@ -18,7 +18,6 @@ - @@ -40,9 +39,8 @@ - - + @@ -153,22 +151,22 @@
- + - - + + - - + + - + - + @@ -189,12 +187,7 @@ - @@ -229,23 +222,31 @@ - + - - - - - - - - + + + + + + + + + + + + From dcf6bbcdac7aab952f1db7d0ddbabf708bb2c6c6 Mon Sep 17 00:00:00 2001 From: swsalvi Date: Tue, 9 Sep 2025 17:10:22 -0400 Subject: [PATCH 2/5] Fixed issues w.r.t description type. --- .../mvvm/view/concept/ConceptController.java | 34 ++--- .../AddFullyQualifiedNameController.java | 41 +++--- .../properties/AddOtherNameController.java | 43 ++++--- .../EditFullyQualifiedNameController.java | 44 ++----- .../view/properties/PropertiesController.java | 33 +++-- .../mvvm/viewmodel/ConceptViewModel.java | 42 +------ .../mvvm/viewmodel/DescrNameViewModel.java | 118 ++++++++---------- .../mvvm/viewmodel/OtherNameViewModel.java | 15 ++- 8 files changed, 161 insertions(+), 209 deletions(-) diff --git a/kview/src/main/java/dev/ikm/komet/kview/mvvm/view/concept/ConceptController.java b/kview/src/main/java/dev/ikm/komet/kview/mvvm/view/concept/ConceptController.java index 3a5749cd3..2aa4b5fc3 100644 --- a/kview/src/main/java/dev/ikm/komet/kview/mvvm/view/concept/ConceptController.java +++ b/kview/src/main/java/dev/ikm/komet/kview/mvvm/view/concept/ConceptController.java @@ -214,23 +214,9 @@ public class ConceptController { @FXML private Button editConceptButton; -// @FXML -// private TextFlow fqnContainer; - -// @FXML -// private Text latestFqnText; - -// @FXML -// private Text fqnDescriptionSemanticText; - -// @FXML -// private TextFlow fqnDateAddedTextFlow; - -// @FXML -// private Label fqnAddDateLabel; - @FXML private Text fullyQualifiedNameHeaderText; + /** * Responsible for holding rows of other names (regular) description semantics. */ @@ -451,8 +437,7 @@ public void initialize() { updateConceptBanner(); } updateFullyQualifiedNamesDescription(fullyQualifiedNames); -// updateConceptBanner(); -// updateFQNConceptDescription(fqnDescrName); + }); ObservableList otherNames = getConceptViewModel().getObservableList(OTHER_NAMES); otherNames.addListener((InvalidationListener) obs -> { @@ -474,11 +459,14 @@ public void initialize() { if (CREATE.equals(conceptViewModel.getPropertyValue(MODE))) { if (evt.getEventType() == CreateConceptEvent.ADD_FQN) { - getConceptViewModel().setPropertyValue(FULLY_QUALIFIED_NAMES, descrName); + fullyQualifiedNames.clear(); + fullyQualifiedNames.add(descrName); } else if (evt.getEventType() == CreateConceptEvent.ADD_OTHER_NAME) { otherNames.add(descrName); - }else if (evt.getEventType() == CreateConceptEvent.EDIT_OTHER_NAME){ // Since we are + }else if (evt.getEventType() == CreateConceptEvent.EDIT_OTHER_NAME) { // Since we are updateOtherNamesDescription(otherNames); + }else { // Since we are + updateFullyQualifiedNamesDescription(fullyQualifiedNames); } // Attempts to write data boolean isWritten = conceptViewModel.createConcept(propertiesController.getStampFormViewModel()); @@ -509,7 +497,7 @@ public void initialize() { if (EDIT.equals(conceptViewModel.getPropertyValue(MODE))) { if (evt.getEventType() == EditConceptEvent.EDIT_FQN) { // the listener will fire on the FQN when we update this - getConceptViewModel().setPropertyValue(FULLY_QUALIFIED_NAMES, descrName); + fullyQualifiedNames.add(descrName); } } }; @@ -687,7 +675,7 @@ private void setUpDescriptionContextMenu(Button addDescriptionButton) { private void onAddDescriptionButtonPressed(ActionEvent actionEvent) { if (this.conceptViewModel.getPropertyValue(MODE).equals(CREATE) && - (getConceptViewModel().getPropertyValue(FULLY_QUALIFIED_NAMES) == null)) { + getConceptViewModel().getObservableList(FULLY_QUALIFIED_NAMES).isEmpty()) { // Show the context menu with 'Add Fully Qualified' option when it is a new concept in create mode and // there is no fully qualified name. fireContextMenuEvent(actionEvent, Side.RIGHT, 2, 0); @@ -736,7 +724,7 @@ private ContextMenu buildMenuOptionContextMenu() { Object[][] menuItems; // show the 'Add Fully Qualified' option when it is a new concept in create mode and there is no fully qualified name if (this.conceptViewModel.getPropertyValue(MODE).equals(CREATE) && - (getConceptViewModel().getPropertyValue(FULLY_QUALIFIED_NAMES) == null)) { + getConceptViewModel().getObservableList(FULLY_QUALIFIED_NAMES).isEmpty()) { menuItems = new Object[][]{ {"ADD DESCRIPTION", true, new String[]{"menu-header-left-align"}, null, null}, {MenuHelper.SEPARATOR}, @@ -994,7 +982,7 @@ public void updateFullyQualifiedNamesDescription(List descrNameViewMo VBox fullyQualifiedNameVBox = generateDescriptionSemanticRow(fullyQualifedName); TextFlow firstRow = (TextFlow) fullyQualifiedNameVBox.getChildren().getFirst(); firstRow.setOnMouseClicked(event -> eventBus.publish(conceptTopic, - new EditOtherNameConceptEvent(fullyQualifiedNameVBox, + new EditConceptFullyQualifiedNameEvent(fullyQualifiedNameVBox, EditConceptFullyQualifiedNameEvent.EDIT_FQN, fullyQualifedName))); fullyQualifiedNameNodeListControl.getItems().add(fullyQualifiedNameVBox); }); diff --git a/kview/src/main/java/dev/ikm/komet/kview/mvvm/view/properties/AddFullyQualifiedNameController.java b/kview/src/main/java/dev/ikm/komet/kview/mvvm/view/properties/AddFullyQualifiedNameController.java index 2f0e548e8..637c8ce25 100644 --- a/kview/src/main/java/dev/ikm/komet/kview/mvvm/view/properties/AddFullyQualifiedNameController.java +++ b/kview/src/main/java/dev/ikm/komet/kview/mvvm/view/properties/AddFullyQualifiedNameController.java @@ -15,24 +15,37 @@ */ package dev.ikm.komet.kview.mvvm.view.properties; -import dev.ikm.komet.kview.mvvm.view.AbstractBasicController; +import static dev.ikm.komet.kview.mvvm.model.DataModelHelper.fetchDescendentsOfConcept; +import static dev.ikm.komet.kview.mvvm.viewmodel.DescrNameViewModel.CASE_SIGNIFICANCE; +import static dev.ikm.komet.kview.mvvm.viewmodel.DescrNameViewModel.IS_SUBMITTED; +import static dev.ikm.komet.kview.mvvm.viewmodel.DescrNameViewModel.LANGUAGE; +import static dev.ikm.komet.kview.mvvm.viewmodel.DescrNameViewModel.MODULE; +import static dev.ikm.komet.kview.mvvm.viewmodel.DescrNameViewModel.NAME_TEXT; +import static dev.ikm.komet.kview.mvvm.viewmodel.DescrNameViewModel.NAME_TYPE; +import static dev.ikm.komet.kview.mvvm.viewmodel.DescrNameViewModel.STATUS; +import static dev.ikm.tinkar.terms.TinkarTerm.DESCRIPTION_TYPE; +import dev.ikm.komet.framework.view.ViewProperties; import dev.ikm.komet.kview.events.ClosePropertiesPanelEvent; import dev.ikm.komet.kview.events.CreateConceptEvent; import dev.ikm.komet.kview.mvvm.model.DescrName; +import dev.ikm.komet.kview.mvvm.view.AbstractBasicController; import dev.ikm.komet.kview.mvvm.viewmodel.DescrNameViewModel; -import dev.ikm.tinkar.events.EvtBus; -import dev.ikm.tinkar.events.EvtBusFactory; -import dev.ikm.komet.framework.view.ViewProperties; import dev.ikm.tinkar.common.id.PublicId; import dev.ikm.tinkar.entity.ConceptEntity; import dev.ikm.tinkar.entity.Entity; +import dev.ikm.tinkar.events.EvtBus; +import dev.ikm.tinkar.events.EvtBusFactory; import dev.ikm.tinkar.terms.EntityFacade; import dev.ikm.tinkar.terms.State; import dev.ikm.tinkar.terms.TinkarTerm; import javafx.beans.InvalidationListener; import javafx.event.ActionEvent; import javafx.fxml.FXML; -import javafx.scene.control.*; +import javafx.scene.control.Button; +import javafx.scene.control.ComboBox; +import javafx.scene.control.Label; +import javafx.scene.control.ListCell; +import javafx.scene.control.TextField; import javafx.util.Callback; import javafx.util.StringConverter; import org.carlfx.cognitive.loader.InjectViewModel; @@ -43,8 +56,6 @@ import java.util.Optional; import java.util.UUID; -import static dev.ikm.komet.kview.mvvm.viewmodel.DescrNameViewModel.*; - public class AddFullyQualifiedNameController extends AbstractBasicController { private static final Logger LOG = LoggerFactory.getLogger(AddFullyQualifiedNameController.class); @@ -58,7 +69,7 @@ public class AddFullyQualifiedNameController extends AbstractBasicController { private TextField fullyQualifiedNameTextField; @FXML - private ComboBox typeDisplayComboBox; + private ComboBox typeDisplayComboBox; @FXML private ComboBox caseSignificanceComboBox; @@ -114,6 +125,7 @@ public void initialize() { setupComboBox(statusComboBox, formValid); setupComboBox(caseSignificanceComboBox, formValid); setupComboBox(languageComboBox, formValid); + setupComboBox(typeDisplayComboBox, formValid); } /** @@ -139,16 +151,19 @@ public void populate(ComboBox comboBox, Collection entities) { public void updateView() { // populate form combo fields module, status, case significance, lang. - populate(moduleComboBox, fqnViewModel.findAllModules(getViewProperties())); - populate(statusComboBox, fqnViewModel.findAllStatuses(getViewProperties())); + populate(moduleComboBox, fetchDescendentsOfConcept(getViewProperties(), TinkarTerm.MODULE.publicId())); + populate(statusComboBox, fetchDescendentsOfConcept(getViewProperties(), TinkarTerm.STATUS_VALUE.publicId())); populate(caseSignificanceComboBox, fqnViewModel.findAllCaseSignificants(getViewProperties())); - populate(languageComboBox, fqnViewModel.findAllLanguages(getViewProperties())); + populate(languageComboBox, fetchDescendentsOfConcept(getViewProperties(), TinkarTerm.LANGUAGE.publicId())); + populate(typeDisplayComboBox, fetchDescendentsOfConcept(getViewProperties(), DESCRIPTION_TYPE.publicId())); // Set UI to default values caseSignificanceComboBox.setValue(TinkarTerm.DESCRIPTION_NOT_CASE_SENSITIVE); statusComboBox.setValue(Entity.getFast(State.ACTIVE.nid())); moduleComboBox.setValue(TinkarTerm.DEVELOPMENT_MODULE); languageComboBox.setValue(TinkarTerm.ENGLISH_LANGUAGE); + typeDisplayComboBox.setValue(TinkarTerm.FULLY_QUALIFIED_NAME_DESCRIPTION_TYPE); + } @Override @@ -158,10 +173,6 @@ public void clearView() { statusComboBox.setValue(null); caseSignificanceComboBox.setValue(null); languageComboBox.setValue(null); -// if (fqnViewModel != null) { -// copyUIToViewModelProperties(); -// fqnViewModel.save(true); // make UI properties as model values -// } moduleComboBox.getItems().clear(); statusComboBox.getItems().clear(); caseSignificanceComboBox.getItems().clear(); diff --git a/kview/src/main/java/dev/ikm/komet/kview/mvvm/view/properties/AddOtherNameController.java b/kview/src/main/java/dev/ikm/komet/kview/mvvm/view/properties/AddOtherNameController.java index d80d2f7f6..b2824704d 100644 --- a/kview/src/main/java/dev/ikm/komet/kview/mvvm/view/properties/AddOtherNameController.java +++ b/kview/src/main/java/dev/ikm/komet/kview/mvvm/view/properties/AddOtherNameController.java @@ -15,22 +15,38 @@ */ package dev.ikm.komet.kview.mvvm.view.properties; -import dev.ikm.komet.kview.mvvm.view.AbstractBasicController; +import static dev.ikm.komet.kview.mvvm.model.DataModelHelper.fetchDescendentsOfConcept; +import static dev.ikm.komet.kview.mvvm.viewmodel.DescrNameViewModel.CASE_SIGNIFICANCE; +import static dev.ikm.komet.kview.mvvm.viewmodel.DescrNameViewModel.IS_SUBMITTED; +import static dev.ikm.komet.kview.mvvm.viewmodel.DescrNameViewModel.LANGUAGE; +import static dev.ikm.komet.kview.mvvm.viewmodel.DescrNameViewModel.MODULE; +import static dev.ikm.komet.kview.mvvm.viewmodel.DescrNameViewModel.NAME_TEXT; +import static dev.ikm.komet.kview.mvvm.viewmodel.DescrNameViewModel.NAME_TYPE; +import static dev.ikm.komet.kview.mvvm.viewmodel.DescrNameViewModel.STATUS; +import static dev.ikm.komet.kview.mvvm.viewmodel.OtherNameViewModel.OtherNameProperties.DESCRIPTION_CASE_SIGNIFICANCE; +import static dev.ikm.komet.kview.mvvm.viewmodel.OtherNameViewModel.OtherNameProperties.DESCRIPTION_LANGUAGE; +import static dev.ikm.komet.kview.mvvm.viewmodel.OtherNameViewModel.OtherNameProperties.HAS_OTHER_NAME; +import static dev.ikm.tinkar.terms.TinkarTerm.DESCRIPTION_TYPE; +import dev.ikm.komet.framework.view.ViewProperties; import dev.ikm.komet.kview.events.ClosePropertiesPanelEvent; import dev.ikm.komet.kview.events.CreateConceptEvent; +import dev.ikm.komet.kview.mvvm.view.AbstractBasicController; import dev.ikm.komet.kview.mvvm.viewmodel.OtherNameViewModel; +import dev.ikm.tinkar.entity.ConceptEntity; import dev.ikm.tinkar.entity.Entity; import dev.ikm.tinkar.events.EvtBus; import dev.ikm.tinkar.events.EvtBusFactory; -import dev.ikm.komet.framework.view.ViewProperties; -import dev.ikm.tinkar.entity.ConceptEntity; import dev.ikm.tinkar.terms.EntityFacade; import dev.ikm.tinkar.terms.State; import dev.ikm.tinkar.terms.TinkarTerm; import javafx.beans.InvalidationListener; import javafx.event.ActionEvent; import javafx.fxml.FXML; -import javafx.scene.control.*; +import javafx.scene.control.Button; +import javafx.scene.control.ComboBox; +import javafx.scene.control.Label; +import javafx.scene.control.ListCell; +import javafx.scene.control.TextField; import javafx.util.Callback; import javafx.util.StringConverter; import org.carlfx.cognitive.loader.InjectViewModel; @@ -41,11 +57,6 @@ import java.util.Optional; import java.util.UUID; -import static dev.ikm.komet.kview.mvvm.viewmodel.DescrNameViewModel.*; -import static dev.ikm.komet.kview.mvvm.viewmodel.OtherNameViewModel.OtherNameProperties.FQN_CASE_SIGNIFICANCE; -import static dev.ikm.komet.kview.mvvm.viewmodel.OtherNameViewModel.OtherNameProperties.FQN_LANGUAGE; -import static dev.ikm.komet.kview.mvvm.viewmodel.OtherNameViewModel.OtherNameProperties.HAS_OTHER_NAME; - public class AddOtherNameController extends AbstractBasicController { private static final Logger LOG = LoggerFactory.getLogger(AddOtherNameController.class); @@ -116,6 +127,7 @@ public void initialize() { setupComboBox(statusComboBox, formValid); setupComboBox(caseSignificanceComboBox, formValid); setupComboBox(languageComboBox, formValid); + setupComboBox(typeDisplayComboBox, formValid); } /** @@ -230,22 +242,25 @@ private void saveOtherName(ActionEvent actionEvent) { @Override public void updateView() { // populate form combo fields module, status, case significance, lang. - populate(moduleComboBox, otherNameViewModel.findAllModules(getViewProperties())); - populate(statusComboBox, otherNameViewModel.findAllStatuses(getViewProperties())); + populate(typeDisplayComboBox, fetchDescendentsOfConcept(getViewProperties(), DESCRIPTION_TYPE.publicId())); + populate(moduleComboBox, fetchDescendentsOfConcept(getViewProperties(), TinkarTerm.MODULE.publicId())); + populate(statusComboBox, fetchDescendentsOfConcept(getViewProperties(), TinkarTerm.STATUS_VALUE.publicId())); populate(caseSignificanceComboBox, otherNameViewModel.findAllCaseSignificants(getViewProperties())); - populate(languageComboBox, otherNameViewModel.findAllLanguages(getViewProperties())); + populate(languageComboBox, fetchDescendentsOfConcept(getViewProperties(), TinkarTerm.LANGUAGE.publicId())); + + typeDisplayComboBox.setValue(TinkarTerm.REGULAR_NAME_DESCRIPTION_TYPE); boolean hasOtherName = getViewModel().getValue(HAS_OTHER_NAME); if (hasOtherName) { - caseSignificanceComboBox.setValue(getViewModel().getValue(FQN_CASE_SIGNIFICANCE)); + caseSignificanceComboBox.setValue(getViewModel().getValue(DESCRIPTION_CASE_SIGNIFICANCE)); } else { caseSignificanceComboBox.setValue(TinkarTerm.DESCRIPTION_NOT_CASE_SENSITIVE); } statusComboBox.setValue(Entity.getFast(State.ACTIVE.nid())); moduleComboBox.setValue(TinkarTerm.DEVELOPMENT_MODULE); if (hasOtherName) { - languageComboBox.setValue(getViewModel().getValue(FQN_LANGUAGE)); + languageComboBox.setValue(getViewModel().getValue(DESCRIPTION_LANGUAGE)); } else { languageComboBox.setValue(TinkarTerm.ENGLISH_LANGUAGE); } diff --git a/kview/src/main/java/dev/ikm/komet/kview/mvvm/view/properties/EditFullyQualifiedNameController.java b/kview/src/main/java/dev/ikm/komet/kview/mvvm/view/properties/EditFullyQualifiedNameController.java index c0ab647c6..5276e3eeb 100644 --- a/kview/src/main/java/dev/ikm/komet/kview/mvvm/view/properties/EditFullyQualifiedNameController.java +++ b/kview/src/main/java/dev/ikm/komet/kview/mvvm/view/properties/EditFullyQualifiedNameController.java @@ -26,6 +26,7 @@ import static dev.ikm.tinkar.terms.TinkarTerm.DESCRIPTION_CASE_SIGNIFICANCE; import static dev.ikm.tinkar.terms.TinkarTerm.DESCRIPTION_TYPE; import static dev.ikm.tinkar.terms.TinkarTerm.LANGUAGE_CONCEPT_NID_FOR_DESCRIPTION; +import static dev.ikm.tinkar.terms.TinkarTerm.STATUS_VALUE; import dev.ikm.komet.framework.view.ViewProperties; import dev.ikm.komet.kview.events.ClosePropertiesPanelEvent; import dev.ikm.komet.kview.events.CreateConceptEvent; @@ -33,7 +34,6 @@ import dev.ikm.komet.kview.mvvm.model.DescrName; import dev.ikm.komet.kview.mvvm.view.BasicController; import dev.ikm.komet.kview.mvvm.viewmodel.DescrNameViewModel; -import dev.ikm.tinkar.common.id.IntIdSet; import dev.ikm.tinkar.common.id.PublicId; import dev.ikm.tinkar.coordinate.stamp.calculator.Latest; import dev.ikm.tinkar.coordinate.view.calculator.ViewCalculator; @@ -68,9 +68,7 @@ import java.util.Collection; import java.util.List; import java.util.Optional; -import java.util.Set; import java.util.UUID; -import java.util.stream.Collectors; public class EditFullyQualifiedNameController implements BasicController { @@ -155,7 +153,7 @@ public void initialize() { caseSignificanceComboBox.valueProperty().bindBidirectional(fqnViewModel.getProperty(CASE_SIGNIFICANCE)); statusComboBox.valueProperty().bindBidirectional(fqnViewModel.getProperty(STATUS)); languageComboBox.valueProperty().bindBidirectional(fqnViewModel.getProperty(LANGUAGE)); - typeDisplayComboBox.valueProperty().bindBidirectional(fqnViewModel.getProperty(NAME_TYPE)); + typeDisplayComboBox.valueProperty().bind(fqnViewModel.getProperty(NAME_TYPE)); InvalidationListener invalidationListener = obs -> validateForm(); @@ -282,23 +280,14 @@ public void setConceptAndPopulateForm(PublicId publicId) { this.fqnText.setText(fullyQualifiedName); // get all descendant modules - IntIdSet moduleDescendents = viewProperties.parentView().calculator().descendentsOf(TinkarTerm.MODULE.nid()); - Set allModules = - moduleDescendents.intStream() - .mapToObj(moduleNid -> (ConceptEntity) Entity.getFast(moduleNid)) - .collect(Collectors.toSet()); - setupComboBox(moduleComboBox, allModules); + setupComboBox(moduleComboBox, fetchDescendentsOfConcept(viewProperties,TinkarTerm.MODULE.publicId())); // populate the current module and select it (e.g. 'SNOMED CT core module') findByNid(moduleComboBox.getItems(), stampEntity.moduleNid()) .ifPresent(concept -> fqnViewModel.setPropertyValue(MODULE, concept)); // get all statuses - IntIdSet statusDescendents = viewProperties.parentView().calculator().descendentsOf(TinkarTerm.STATUS_VALUE.nid()); - Set allStatuses = statusDescendents.intStream() - .mapToObj(statusNid -> (ConceptEntity) Entity.getFast(statusNid)) - .collect(Collectors.toSet()); - setupComboBox(statusComboBox, allStatuses); + setupComboBox(statusComboBox, fetchDescendentsOfConcept(viewProperties,STATUS_VALUE.publicId())); // populate the current status (ACTIVE | INACTIVE) and select it findByNid(statusComboBox.getItems(), stampEntity.stateNid()) @@ -306,15 +295,12 @@ public void setConceptAndPopulateForm(PublicId publicId) { // populate all case significance choices - IntIdSet caseSenseDescendents = viewProperties.parentView().calculator().descendentsOf(DESCRIPTION_CASE_SIGNIFICANCE.nid()); - Set allCaseDescendents = caseSenseDescendents.intStream() - .mapToObj(caseNid -> (ConceptEntity) Entity.getFast(caseNid)) - .collect(Collectors.toSet()); - setupComboBox(caseSignificanceComboBox, allCaseDescendents); + setupComboBox(caseSignificanceComboBox, fetchDescendentsOfConcept(viewProperties,DESCRIPTION_CASE_SIGNIFICANCE.publicId())); // get case concept's case sensitivity (e.g. 'Case insensitive') PatternEntity patternEntity = latestEntityVersion.get().pattern(); PatternEntityVersion patternEntityVersion = viewCalculator.latest(patternEntity).get(); + int indexCaseSig = patternEntityVersion.indexForMeaning(DESCRIPTION_CASE_SIGNIFICANCE); ConceptFacade caseSigConceptFacade = (ConceptFacade) latestEntityVersion.get().fieldValues().get(indexCaseSig); findByNid(caseSignificanceComboBox.getItems(), caseSigConceptFacade.nid()) @@ -322,27 +308,15 @@ public void setConceptAndPopulateForm(PublicId publicId) { // get all available languages - IntIdSet languageDescendents = viewProperties.parentView().calculator().descendentsOf(TinkarTerm.LANGUAGE.nid()); - Set allLangs = languageDescendents.intStream() - .mapToObj(langNid -> (ConceptEntity) Entity.getFast(langNid)) - .collect(Collectors.toSet()); - setupComboBox(languageComboBox, allLangs); - + setupComboBox(languageComboBox, fetchDescendentsOfConcept(viewProperties, TinkarTerm.LANGUAGE.publicId())); // get the language (e.g. 'English language') int indexLang = patternEntityVersion.indexForMeaning(LANGUAGE_CONCEPT_NID_FOR_DESCRIPTION); ConceptFacade langConceptFacade = (ConceptFacade) latestEntityVersion.get().fieldValues().get(indexLang); - findByNid(languageComboBox.getItems(), langConceptFacade.nid()) .ifPresent(concept -> fqnViewModel.setPropertyValue(LANGUAGE, concept)); - // get all descendant types - IntIdSet descriptionTypeDecendants = viewProperties.parentView().calculator().descendentsOf(DESCRIPTION_TYPE.nid()); - Set allDescritionTypes = - descriptionTypeDecendants.intStream() - .mapToObj(typeNid -> (ConceptEntity) Entity.getFast(typeNid)) - .collect(Collectors.toSet()); - setupComboBox(typeDisplayComboBox, allDescritionTypes); + setupComboBox(typeDisplayComboBox, fetchDescendentsOfConcept(viewProperties, DESCRIPTION_TYPE.publicId())); //Set selected value for DESCRIPTION TYPE int indexType = patternEntityVersion.indexForMeaning(DESCRIPTION_TYPE); ConceptFacade typeConceptFacade = (ConceptFacade) latestEntityVersion.get().fieldValues().get(indexType); @@ -422,7 +396,7 @@ private Optional findByNid(List items, int nid) { */ public void setConceptAndPopulateForm(DescrName descrName) { setupComboBox(moduleComboBox, fetchDescendentsOfConcept(getViewProperties(), TinkarTerm.MODULE.publicId())); - setupComboBox(statusComboBox, fetchDescendentsOfConcept(getViewProperties(), TinkarTerm.STATUS_VALUE.publicId())); + setupComboBox(statusComboBox, fetchDescendentsOfConcept(getViewProperties(), STATUS_VALUE.publicId())); setupComboBox(caseSignificanceComboBox, fqnViewModel.findAllCaseSignificants(getViewProperties())); setupComboBox(languageComboBox, fetchDescendentsOfConcept(getViewProperties(), TinkarTerm.LANGUAGE.publicId())); setupComboBox(typeDisplayComboBox, fetchDescendentsOfConcept(getViewProperties(), DESCRIPTION_TYPE.publicId())); diff --git a/kview/src/main/java/dev/ikm/komet/kview/mvvm/view/properties/PropertiesController.java b/kview/src/main/java/dev/ikm/komet/kview/mvvm/view/properties/PropertiesController.java index 90f95edc7..b65abc16d 100644 --- a/kview/src/main/java/dev/ikm/komet/kview/mvvm/view/properties/PropertiesController.java +++ b/kview/src/main/java/dev/ikm/komet/kview/mvvm/view/properties/PropertiesController.java @@ -15,8 +15,28 @@ */ package dev.ikm.komet.kview.mvvm.view.properties; +import static dev.ikm.komet.kview.events.StampEvent.ADD_STAMP; +import static dev.ikm.komet.kview.events.StampEvent.CREATE_STAMP; +import static dev.ikm.komet.kview.fxutils.CssHelper.genText; +import static dev.ikm.komet.kview.mvvm.viewmodel.DescrNameViewModel.CASE_SIGNIFICANCE; +import static dev.ikm.komet.kview.mvvm.viewmodel.DescrNameViewModel.IS_SUBMITTED; +import static dev.ikm.komet.kview.mvvm.viewmodel.DescrNameViewModel.LANGUAGE; +import static dev.ikm.komet.kview.mvvm.viewmodel.DescrNameViewModel.MODULE; +import static dev.ikm.komet.kview.mvvm.viewmodel.DescrNameViewModel.NAME_TEXT; +import static dev.ikm.komet.kview.mvvm.viewmodel.DescrNameViewModel.PARENT_PUBLIC_ID; +import static dev.ikm.komet.kview.mvvm.viewmodel.DescrNameViewModel.STATUS; +import static dev.ikm.komet.kview.mvvm.viewmodel.OtherNameViewModel.OtherNameProperties.DESCRIPTION_CASE_SIGNIFICANCE; +import static dev.ikm.komet.kview.mvvm.viewmodel.OtherNameViewModel.OtherNameProperties.DESCRIPTION_LANGUAGE; +import static dev.ikm.komet.kview.mvvm.viewmodel.OtherNameViewModel.OtherNameProperties.HAS_OTHER_NAME; +import static dev.ikm.komet.kview.mvvm.viewmodel.StampFormViewModelBase.StampType.CONCEPT; import dev.ikm.komet.framework.view.ViewProperties; -import dev.ikm.komet.kview.events.*; +import dev.ikm.komet.kview.events.AddFullyQualifiedNameEvent; +import dev.ikm.komet.kview.events.AddOtherNameToConceptEvent; +import dev.ikm.komet.kview.events.EditConceptFullyQualifiedNameEvent; +import dev.ikm.komet.kview.events.EditOtherNameConceptEvent; +import dev.ikm.komet.kview.events.OpenPropertiesPanelEvent; +import dev.ikm.komet.kview.events.ShowEditDescriptionPanelEvent; +import dev.ikm.komet.kview.events.StampEvent; import dev.ikm.komet.kview.mvvm.view.common.StampAddController; import dev.ikm.komet.kview.mvvm.viewmodel.StampAddFormViewModel; import dev.ikm.komet.kview.mvvm.viewmodel.StampCreateFormViewModel; @@ -48,13 +68,6 @@ import java.io.Serializable; import java.util.UUID; -import static dev.ikm.komet.kview.events.StampEvent.ADD_STAMP; -import static dev.ikm.komet.kview.events.StampEvent.CREATE_STAMP; -import static dev.ikm.komet.kview.fxutils.CssHelper.genText; -import static dev.ikm.komet.kview.mvvm.viewmodel.DescrNameViewModel.*; -import static dev.ikm.komet.kview.mvvm.viewmodel.OtherNameViewModel.OtherNameProperties.*; -import static dev.ikm.komet.kview.mvvm.viewmodel.StampFormViewModelBase.StampType.CONCEPT; - /** * The properties window providing tabs of Edit, Hierarchy, History, and Comments. * This view is associated with the view file history-change-selection.fxml. @@ -270,8 +283,8 @@ public void initialize() throws IOException { .setValue(STATUS, TinkarTerm.ACTIVE_STATE) .setValue(IS_SUBMITTED, false) - .setValue(FQN_CASE_SIGNIFICANCE, addFullyQualifiedNameController.getViewModel().getValue(CASE_SIGNIFICANCE)) - .setValue(FQN_LANGUAGE, addFullyQualifiedNameController.getViewModel().getValue(LANGUAGE)) + .setValue(DESCRIPTION_CASE_SIGNIFICANCE, addFullyQualifiedNameController.getViewModel().getValue(CASE_SIGNIFICANCE)) + .setValue(DESCRIPTION_LANGUAGE, addFullyQualifiedNameController.getViewModel().getValue(LANGUAGE)) .setValue(HAS_OTHER_NAME, hasOtherNames); diff --git a/kview/src/main/java/dev/ikm/komet/kview/mvvm/viewmodel/ConceptViewModel.java b/kview/src/main/java/dev/ikm/komet/kview/mvvm/viewmodel/ConceptViewModel.java index b0155d559..272bd5770 100644 --- a/kview/src/main/java/dev/ikm/komet/kview/mvvm/viewmodel/ConceptViewModel.java +++ b/kview/src/main/java/dev/ikm/komet/kview/mvvm/viewmodel/ConceptViewModel.java @@ -15,8 +15,6 @@ */ package dev.ikm.komet.kview.mvvm.viewmodel; -import static dev.ikm.komet.kview.mvvm.viewmodel.DescrNameViewModel.NAME_TEXT; -import static dev.ikm.komet.kview.mvvm.viewmodel.DescrNameViewModel.NAME_TYPE; import static dev.ikm.komet.kview.mvvm.viewmodel.StampFormViewModelBase.StampProperties.IS_CONFIRMED_OR_SUBMITTED; import static dev.ikm.komet.kview.mvvm.viewmodel.StampFormViewModelBase.StampProperties.STATUS; import static dev.ikm.tinkar.coordinate.stamp.StampFields.MODULE; @@ -47,8 +45,8 @@ import dev.ikm.tinkar.terms.EntityProxy; import dev.ikm.tinkar.terms.State; import dev.ikm.tinkar.terms.TinkarTerm; -import javafx.beans.property.ReadOnlyObjectProperty; import javafx.beans.property.ReadOnlyStringProperty; +import javafx.collections.ObservableList; import org.carlfx.cognitive.validator.MessageType; import org.carlfx.cognitive.validator.ValidationMessage; import org.carlfx.cognitive.viewmodel.ViewModel; @@ -92,36 +90,15 @@ public ConceptViewModel() { //FIXME add a STAMP validator // In Create Mode the fqn is required. - addValidator(FULLY_QUALIFIED_NAMES, "Fully Qualified Names",(ReadOnlyObjectProperty prop, ViewModel vm) -> { - if ((prop.isNull().get() - || prop.get() instanceof List list - && list.isEmpty()) - || (prop.isNull().get() - || prop.get() instanceof List list - && !list.isEmpty() - && list.get(0) instanceof DescrNameViewModel fqnViewModel - && fqnViewModel.getPropertyValue(NAME_TYPE) != TinkarTerm.FULLY_QUALIFIED_NAME_DESCRIPTION_TYPE - && fqnViewModel.getPropertyValue(NAME_TEXT) != null - && fqnViewModel.getPropertyValue(NAME_TEXT).toString().isBlank() - )){ + addValidator(FULLY_QUALIFIED_NAMES, "Fully Qualified Names",(ObservableList observableList, ViewModel _ ) -> { + if (observableList.isEmpty()){ return new ValidationMessage(FULLY_QUALIFIED_NAMES, MessageType.ERROR, "${%s} is required".formatted(FULLY_QUALIFIED_NAMES)); } -// if (prop.isNull().get() -// || prop.get() instanceof List list -// && !list.isEmpty() -// && list.get(0) instanceof DescrNameViewModel fqnViewModel -// && fqnViewModel.getPropertyValue(NAME_TYPE) != TinkarTerm.FULLY_QUALIFIED_NAME_DESCRIPTION_TYPE -// && fqnViewModel.getPropertyValue(NAME_TEXT) != null -// && fqnViewModel.getPropertyValue(NAME_TEXT).toString().isBlank() -// ) { -// -// return new ValidationMessage(FULLY_QUALIFIED_NAMES, MessageType.ERROR, "${%s} is required".formatted(FULLY_QUALIFIED_NAMES)); -// } return VALID; }); // Axiom should be selected - addValidator(AXIOM, "Axiom",(ReadOnlyStringProperty prop, ViewModel vm) -> { + addValidator(AXIOM, "Axiom",(ReadOnlyStringProperty prop, ViewModel _ ) -> { if (prop.isNull().get() || (prop.get() instanceof String axiom && !(SUFFICIENT_SET.equals(axiom) || NECESSARY_SET.equals(axiom)))) { @@ -129,15 +106,6 @@ public ConceptViewModel() { } return VALID; }); - -// addValidator("isReadyToCreate", (vm) -> -// vm.getPropertyValue("mode").equals(CREATE) -// && vm.getPropertyValue("axiom").isEmpty() -// && vm.getPropertyValue("fqn").isEmpty() -// ? new ValidationMessage(ERROR, "Must have a ${fqn} & ${axiom} to create") -// : VALID); - - } /** @@ -160,7 +128,7 @@ public boolean createConcept(StampFormViewModelBase stampFormViewModel) { } // Create concept - List fqnList = getPropertyValue(FULLY_QUALIFIED_NAMES); + List fqnList = getObservableList(FULLY_QUALIFIED_NAMES); DescrName fqnDescrName = fqnList.get(0); Transaction transaction = Transaction.make("New concept for: " + fqnDescrName.getNameText()); diff --git a/kview/src/main/java/dev/ikm/komet/kview/mvvm/viewmodel/DescrNameViewModel.java b/kview/src/main/java/dev/ikm/komet/kview/mvvm/viewmodel/DescrNameViewModel.java index b707ba490..b9537853a 100644 --- a/kview/src/main/java/dev/ikm/komet/kview/mvvm/viewmodel/DescrNameViewModel.java +++ b/kview/src/main/java/dev/ikm/komet/kview/mvvm/viewmodel/DescrNameViewModel.java @@ -18,17 +18,13 @@ import static dev.ikm.komet.kview.lidr.mvvm.model.DataModelHelper.CASE_SIGNIFICANCE_OPTIONS; import dev.ikm.komet.framework.view.ViewProperties; import dev.ikm.komet.kview.mvvm.model.DescrName; -import dev.ikm.tinkar.common.id.IntIdSet; import dev.ikm.tinkar.common.id.PublicId; import dev.ikm.tinkar.common.service.TinkExecutor; import dev.ikm.tinkar.entity.ConceptEntity; -import dev.ikm.tinkar.entity.ConceptEntityVersion; import dev.ikm.tinkar.entity.Entity; import dev.ikm.tinkar.entity.EntityService; -import dev.ikm.tinkar.entity.EntityVersion; import dev.ikm.tinkar.entity.RecordListBuilder; import dev.ikm.tinkar.entity.SemanticEntity; -import dev.ikm.tinkar.entity.SemanticEntityVersion; import dev.ikm.tinkar.entity.SemanticRecord; import dev.ikm.tinkar.entity.SemanticRecordBuilder; import dev.ikm.tinkar.entity.SemanticVersionRecordBuilder; @@ -39,8 +35,6 @@ import dev.ikm.tinkar.terms.TinkarTerm; import javafx.beans.property.ReadOnlyObjectProperty; import javafx.beans.property.ReadOnlyStringProperty; -import org.carlfx.cognitive.validator.MessageType; -import org.carlfx.cognitive.validator.ValidationMessage; import org.carlfx.cognitive.validator.ValidationResult; import org.carlfx.cognitive.viewmodel.ViewModel; import org.eclipse.collections.api.factory.Lists; @@ -48,10 +42,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.util.ArrayList; -import java.util.List; import java.util.Set; -import java.util.stream.Collectors; public class DescrNameViewModel extends FormViewModel { @@ -128,68 +119,61 @@ public DescrNameViewModel() { ; } - public Set findAllLanguages(ViewProperties viewProperties) { - IntIdSet languageDescendents = viewProperties.calculator().descendentsOf(TinkarTerm.LANGUAGE.nid()); - Set allLangs = languageDescendents.intStream() - .mapToObj(langNid -> (ConceptEntity) Entity.getFast(langNid)) - .collect(Collectors.toSet()); - return allLangs; - } - - public Set findAllStatuses(ViewProperties viewProperties) { - Entity statusEntity = EntityService.get().getEntityFast(TinkarTerm.STATUS_VALUE); - IntIdSet statusDescendents = viewProperties.calculator().descendentsOf(statusEntity.nid()); - Set allStatuses = statusDescendents.intStream() - .mapToObj(statusNid -> (ConceptEntity) Entity.getFast(statusNid)) - .collect(Collectors.toSet()); - return allStatuses; - } - - public Set findAllCaseSignificants(ViewProperties viewProperties) { - - - //FIXME after connect-a-thon put this query back -// IntIdSet caseSenseDescendents = viewProperties.calculator().descendentsOf(TinkarTerm.DESCRIPTION_CASE_SIGNIFICANCE.nid()); -// Set allCaseDescendents = caseSenseDescendents.intStream() -// .mapToObj(caseNid -> (ConceptEntity) Entity.getFast(caseNid)) +// public Set findAllLanguages(ViewProperties viewProperties) { +// IntIdSet languageDescendents = viewProperties.calculator().descendentsOf(TinkarTerm.LANGUAGE.nid()); +// Set allLangs = languageDescendents.intStream() +// .mapToObj(langNid -> (ConceptEntity) Entity.getFast(langNid)) +// .collect(Collectors.toSet()); +// return allLangs; +// } + +// public Set findAllStatuses(ViewProperties viewProperties) { +// Entity statusEntity = EntityService.get().getEntityFast(TinkarTerm.STATUS_VALUE); +// IntIdSet statusDescendents = viewProperties.calculator().descendentsOf(statusEntity.nid()); +// Set allStatuses = statusDescendents.intStream() +// .mapToObj(statusNid -> (ConceptEntity) Entity.getFast(statusNid)) // .collect(Collectors.toSet()); +// return allStatuses; +// } + public Set findAllCaseSignificants(ViewProperties viewProperties) { + //FIXME after connect-a-thon put this query back or call fetchDescendentsOfConcept(getViewProperties(), TinkarTerm.DESCRIPTION_CASE_SIGNIFICANCE.publicId()) return CASE_SIGNIFICANCE_OPTIONS; } - public List findAllModules(ViewProperties viewProperties) { - try { - Entity moduleEntity = EntityService.get().getEntityFast(TinkarTerm.MODULE); - IntIdSet moduleDescendents = viewProperties.calculator().descendentsOf(moduleEntity.nid()); - - // get all descendant modules - List allModules = - moduleDescendents.intStream() - .mapToObj(moduleNid -> (ConceptEntity) Entity.getFast(moduleNid)) - .toList(); - return allModules; - } catch (Throwable th) { - addValidator(MODULES_PROPERTY, "Module Entities", (Void prop, ViewModel vm) -> new ValidationMessage(MessageType.ERROR, "PrimitiveData services are not up. Attempting to retrieve ${%s}. Must call start().".formatted(MODULES_PROPERTY), th)); - return List.of(); - } - } - public List> findAllPaths(ViewProperties viewProperties) { - try { - //List of Concepts that represent available Paths in the data - List> paths = new ArrayList<>(); - //Get all Path semantics from the Paths Pattern - int[] pathSemanticNids = EntityService.get().semanticNidsOfPattern(TinkarTerm.PATHS_PATTERN.nid()); - //For each Path semantic get the concept that the semantic is referencing - for (int pathSemanticNid : pathSemanticNids) { - SemanticEntity semanticEntity = Entity.getFast(pathSemanticNid); - int pathConceptNid = semanticEntity.referencedComponentNid(); - paths.add(EntityService.get().getEntityFast(pathConceptNid)); - } - return paths; - } catch (Throwable th) { - addValidator(PATHS_PROPERTY, "Path Entities", (Void prop, ViewModel vm) -> new ValidationMessage(MessageType.ERROR, "PrimitiveData services are not up. Attempting to retrieve ${%s}. Must call start().".formatted(PATHS_PROPERTY), th)); - return List.of(); - } - } +// public List findAllModules(ViewProperties viewProperties) { +// try { +// Entity moduleEntity = EntityService.get().getEntityFast(TinkarTerm.MODULE); +// IntIdSet moduleDescendents = viewProperties.calculator().descendentsOf(moduleEntity.nid()); +// +// // get all descendant modules +// List allModules = +// moduleDescendents.intStream() +// .mapToObj(moduleNid -> (ConceptEntity) Entity.getFast(moduleNid)) +// .toList(); +// return allModules; +// } catch (Throwable th) { +// addValidator(MODULES_PROPERTY, "Module Entities", (Void prop, ViewModel vm) -> new ValidationMessage(MessageType.ERROR, "PrimitiveData services are not up. Attempting to retrieve ${%s}. Must call start().".formatted(MODULES_PROPERTY), th)); +// return List.of(); +// } +// } +// public List> findAllPaths(ViewProperties viewProperties) { +// try { +// //List of Concepts that represent available Paths in the data +// List> paths = new ArrayList<>(); +// //Get all Path semantics from the Paths Pattern +// int[] pathSemanticNids = EntityService.get().semanticNidsOfPattern(TinkarTerm.PATHS_PATTERN.nid()); +// //For each Path semantic get the concept that the semantic is referencing +// for (int pathSemanticNid : pathSemanticNids) { +// SemanticEntity semanticEntity = Entity.getFast(pathSemanticNid); +// int pathConceptNid = semanticEntity.referencedComponentNid(); +// paths.add(EntityService.get().getEntityFast(pathConceptNid)); +// } +// return paths; +// } catch (Throwable th) { +// addValidator(PATHS_PROPERTY, "Path Entities", (Void prop, ViewModel vm) -> new ValidationMessage(MessageType.ERROR, "PrimitiveData services are not up. Attempting to retrieve ${%s}. Must call start().".formatted(PATHS_PROPERTY), th)); +// return List.of(); +// } +// } public void updateFullyQualifiedName(PublicId publicId, ViewProperties viewProperties) { Transaction transaction = Transaction.make(); diff --git a/kview/src/main/java/dev/ikm/komet/kview/mvvm/viewmodel/OtherNameViewModel.java b/kview/src/main/java/dev/ikm/komet/kview/mvvm/viewmodel/OtherNameViewModel.java index 963fd59b3..a56877883 100644 --- a/kview/src/main/java/dev/ikm/komet/kview/mvvm/viewmodel/OtherNameViewModel.java +++ b/kview/src/main/java/dev/ikm/komet/kview/mvvm/viewmodel/OtherNameViewModel.java @@ -1,22 +1,21 @@ package dev.ikm.komet.kview.mvvm.viewmodel; -import dev.ikm.tinkar.entity.ConceptEntity; - -import static dev.ikm.komet.kview.mvvm.viewmodel.OtherNameViewModel.OtherNameProperties.FQN_CASE_SIGNIFICANCE; -import static dev.ikm.komet.kview.mvvm.viewmodel.OtherNameViewModel.OtherNameProperties.FQN_LANGUAGE; +import static dev.ikm.komet.kview.mvvm.viewmodel.OtherNameViewModel.OtherNameProperties.DESCRIPTION_CASE_SIGNIFICANCE; +import static dev.ikm.komet.kview.mvvm.viewmodel.OtherNameViewModel.OtherNameProperties.DESCRIPTION_LANGUAGE; import static dev.ikm.komet.kview.mvvm.viewmodel.OtherNameViewModel.OtherNameProperties.HAS_OTHER_NAME; +import dev.ikm.tinkar.entity.ConceptEntity; public class OtherNameViewModel extends DescrNameViewModel { public enum OtherNameProperties { - FQN_CASE_SIGNIFICANCE, // The FQN Case Significance - FQN_LANGUAGE, // The FQN Language + DESCRIPTION_CASE_SIGNIFICANCE, // The FQN Case Significance + DESCRIPTION_LANGUAGE, // The FQN Language HAS_OTHER_NAME, // Whether the concept already has any other name } public OtherNameViewModel() { - addProperty(FQN_CASE_SIGNIFICANCE, (ConceptEntity) null) - .addProperty(FQN_LANGUAGE, (ConceptEntity) null) + addProperty(DESCRIPTION_CASE_SIGNIFICANCE, (ConceptEntity) null) + .addProperty(DESCRIPTION_LANGUAGE, (ConceptEntity) null) .addProperty(HAS_OTHER_NAME, false); } } \ No newline at end of file From bead98f060dc21bc4cec50b7307beb27e2feebbf Mon Sep 17 00:00:00 2001 From: swsalvi Date: Tue, 9 Sep 2025 17:56:33 -0400 Subject: [PATCH 3/5] Fixed issues w.r.t description type. --- .../mvvm/view/properties/EditFullyQualifiedNameController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kview/src/main/java/dev/ikm/komet/kview/mvvm/view/properties/EditFullyQualifiedNameController.java b/kview/src/main/java/dev/ikm/komet/kview/mvvm/view/properties/EditFullyQualifiedNameController.java index 5276e3eeb..bdda9fd5c 100644 --- a/kview/src/main/java/dev/ikm/komet/kview/mvvm/view/properties/EditFullyQualifiedNameController.java +++ b/kview/src/main/java/dev/ikm/komet/kview/mvvm/view/properties/EditFullyQualifiedNameController.java @@ -153,7 +153,7 @@ public void initialize() { caseSignificanceComboBox.valueProperty().bindBidirectional(fqnViewModel.getProperty(CASE_SIGNIFICANCE)); statusComboBox.valueProperty().bindBidirectional(fqnViewModel.getProperty(STATUS)); languageComboBox.valueProperty().bindBidirectional(fqnViewModel.getProperty(LANGUAGE)); - typeDisplayComboBox.valueProperty().bind(fqnViewModel.getProperty(NAME_TYPE)); + typeDisplayComboBox.valueProperty().bindBidirectional(fqnViewModel.getProperty(NAME_TYPE)); InvalidationListener invalidationListener = obs -> validateForm(); From e9487e022096cc54f1d246f757093fb3ed8395fa Mon Sep 17 00:00:00 2001 From: swsalvi Date: Tue, 9 Sep 2025 18:02:17 -0400 Subject: [PATCH 4/5] Removed commented code. --- .../mvvm/view/concept/ConceptController.java | 71 +------------------ .../mvvm/viewmodel/DescrNameViewModel.java | 51 ------------- 2 files changed, 1 insertion(+), 121 deletions(-) diff --git a/kview/src/main/java/dev/ikm/komet/kview/mvvm/view/concept/ConceptController.java b/kview/src/main/java/dev/ikm/komet/kview/mvvm/view/concept/ConceptController.java index 4e6ede20c..cfc6b34e5 100644 --- a/kview/src/main/java/dev/ikm/komet/kview/mvvm/view/concept/ConceptController.java +++ b/kview/src/main/java/dev/ikm/komet/kview/mvvm/view/concept/ConceptController.java @@ -436,8 +436,8 @@ public void initialize() { updateConceptBanner(); } updateFullyQualifiedNamesDescription(fullyQualifiedNames); - }); + ObservableList otherNames = getConceptViewModel().getObservableList(OTHER_NAMES); otherNames.addListener((InvalidationListener) obs -> { if (!otherNames.isEmpty()) { @@ -752,7 +752,6 @@ private ContextMenu buildMenuOptionContextMenu() { default -> null; }; - // Create a menu item. Todo: if/when you have sub menus MenuItem menuItem = menuHelper.createMenuOption( String.valueOf(menuItemObj[NAME]), /* name */ @@ -952,28 +951,6 @@ private void setupDisplayUUID(EntityFacade entityFacade, ViewCalculator viewCalc identifierControl.setPublicId(idStr); } -// public void updateFQNConceptDescription(DescrName fqnDescrName) { -// // populate UI with FQN and other names. e.g. Hello Solor (English | Case-insensitive) -// // Latest FQN -// String fullyQualifiedName = fqnDescrName.getNameText(); -// latestFqnText.setText(fullyQualifiedName); -// -// fqnContainer.setOnMouseClicked(event -> eventBus.publish(conceptTopic, -// new EditConceptFullyQualifiedNameEvent(latestFqnText, -// EditConceptFullyQualifiedNameEvent.EDIT_FQN, fqnDescrName))); -// // these should never be null, if the drop-downs are populated then the -// // submit button will not be enabled on the Add FQN form -// if (fqnDescrName.getCaseSignificance() != null && fqnDescrName.getLanguage() != null) { -// fqnDescriptionSemanticText.setText(" (" + fqnDescrName.getCaseSignificance().description() -// + ", " + fqnDescrName.getLanguage().description() + ")"); -// } else { -// LOG.error("missing case sensitivity and language when adding a fully qualified name"); -// fqnDescriptionSemanticText.setText(""); -// } -// -// fqnContainer.getChildren().setAll(latestFqnText, fqnDescriptionSemanticText); -// } - public void updateFullyQualifiedNamesDescription(List descrNameViewModels) { fullyQualifiedNameNodeListControl.getItems().clear(); descrNameViewModels.forEach(fullyQualifedName -> { @@ -1209,52 +1186,6 @@ private VBox generateDescriptionSemanticRow(DescrName otherName) { return textFlowsBox; } -// private void updateFQNSemantics(SemanticEntityVersion semanticEntityVersion, List fieldDescriptions) { -// DateTimeFormatter DATE_TIME_FORMATTER = dateFormatter("MMM dd, yyyy"); -// ViewCalculator viewCalculator = conceptViewModel.getViewProperties().calculator(); -// String fqnTextDescr = viewCalculator.languageCalculator().getDescriptionTextOrNid(semanticEntityVersion.entity()); -// // obtain the fqn description -// latestFqnText.setText(fqnTextDescr); -// System.out.println(" Inside FQN Semantics: " + fqnTextDescr); -// -// this.fqnPublicId = semanticEntityVersion.publicId(); -// fqnContainer.setOnMouseClicked(event -> eventBus.publish(conceptTopic, -// new EditConceptFullyQualifiedNameEvent(latestFqnText, -// EditConceptFullyQualifiedNameEvent.EDIT_FQN, fqnPublicId))); -// -// String descrSemanticStr = String.join(", ", fieldDescriptions); -// if (!fieldDescriptions.isEmpty()) { -// fqnDescriptionSemanticText.setText(" (%s)".formatted(descrSemanticStr)); -// } else { -// fqnDescriptionSemanticText.setText(""); -// } -// -// fqnContainer.getChildren().setAll(latestFqnText, fqnDescriptionSemanticText); -// -// // update date -// String dateAddedStr = ""; -// if (semanticEntityVersion.stamp() == null) { -// dateAddedStr = LocalDate.now().format(DateTimeFormatter.ofPattern("MMM d, yyyy")).toString(); -// } else { -// Long fieldMilis = semanticEntityVersion.stamp().time(); -// if (fieldMilis.equals(PREMUNDANE_TIME)) { -// dateAddedStr = PREMUNDANE; -// } else { -// LocalDate localDate = Instant.ofEpochMilli(fieldMilis).atZone(ZoneId.systemDefault()).toLocalDate(); -// dateAddedStr = localDate.format(DateTimeFormatter.ofPattern("MMM d, yyyy")).toString(); -// } -// } -// fqnAddDateLabel.setText("Date Added: " + dateAddedStr); -// -// Region spacer = new Region(); -// spacer.setMinWidth(10); -// -// Hyperlink attachmentHyperlink = createActionLink(IconsHelper.createIcon(ATTACHMENT)); -// Hyperlink commentsHyperlink = createActionLink(IconsHelper.createIcon(COMMENTS)); -// -// fqnDateAddedTextFlow.getChildren().setAll(fqnAddDateLabel, spacer, attachmentHyperlink, commentsHyperlink); -// } - /** * Creates a hyperlink with the provided SVG icon. * Applies consistent styling to the icon for use in action links. diff --git a/kview/src/main/java/dev/ikm/komet/kview/mvvm/viewmodel/DescrNameViewModel.java b/kview/src/main/java/dev/ikm/komet/kview/mvvm/viewmodel/DescrNameViewModel.java index b9537853a..cba1e63f0 100644 --- a/kview/src/main/java/dev/ikm/komet/kview/mvvm/viewmodel/DescrNameViewModel.java +++ b/kview/src/main/java/dev/ikm/komet/kview/mvvm/viewmodel/DescrNameViewModel.java @@ -119,61 +119,10 @@ public DescrNameViewModel() { ; } -// public Set findAllLanguages(ViewProperties viewProperties) { -// IntIdSet languageDescendents = viewProperties.calculator().descendentsOf(TinkarTerm.LANGUAGE.nid()); -// Set allLangs = languageDescendents.intStream() -// .mapToObj(langNid -> (ConceptEntity) Entity.getFast(langNid)) -// .collect(Collectors.toSet()); -// return allLangs; -// } - -// public Set findAllStatuses(ViewProperties viewProperties) { -// Entity statusEntity = EntityService.get().getEntityFast(TinkarTerm.STATUS_VALUE); -// IntIdSet statusDescendents = viewProperties.calculator().descendentsOf(statusEntity.nid()); -// Set allStatuses = statusDescendents.intStream() -// .mapToObj(statusNid -> (ConceptEntity) Entity.getFast(statusNid)) -// .collect(Collectors.toSet()); -// return allStatuses; -// } - public Set findAllCaseSignificants(ViewProperties viewProperties) { //FIXME after connect-a-thon put this query back or call fetchDescendentsOfConcept(getViewProperties(), TinkarTerm.DESCRIPTION_CASE_SIGNIFICANCE.publicId()) return CASE_SIGNIFICANCE_OPTIONS; } -// public List findAllModules(ViewProperties viewProperties) { -// try { -// Entity moduleEntity = EntityService.get().getEntityFast(TinkarTerm.MODULE); -// IntIdSet moduleDescendents = viewProperties.calculator().descendentsOf(moduleEntity.nid()); -// -// // get all descendant modules -// List allModules = -// moduleDescendents.intStream() -// .mapToObj(moduleNid -> (ConceptEntity) Entity.getFast(moduleNid)) -// .toList(); -// return allModules; -// } catch (Throwable th) { -// addValidator(MODULES_PROPERTY, "Module Entities", (Void prop, ViewModel vm) -> new ValidationMessage(MessageType.ERROR, "PrimitiveData services are not up. Attempting to retrieve ${%s}. Must call start().".formatted(MODULES_PROPERTY), th)); -// return List.of(); -// } -// } -// public List> findAllPaths(ViewProperties viewProperties) { -// try { -// //List of Concepts that represent available Paths in the data -// List> paths = new ArrayList<>(); -// //Get all Path semantics from the Paths Pattern -// int[] pathSemanticNids = EntityService.get().semanticNidsOfPattern(TinkarTerm.PATHS_PATTERN.nid()); -// //For each Path semantic get the concept that the semantic is referencing -// for (int pathSemanticNid : pathSemanticNids) { -// SemanticEntity semanticEntity = Entity.getFast(pathSemanticNid); -// int pathConceptNid = semanticEntity.referencedComponentNid(); -// paths.add(EntityService.get().getEntityFast(pathConceptNid)); -// } -// return paths; -// } catch (Throwable th) { -// addValidator(PATHS_PROPERTY, "Path Entities", (Void prop, ViewModel vm) -> new ValidationMessage(MessageType.ERROR, "PrimitiveData services are not up. Attempting to retrieve ${%s}. Must call start().".formatted(PATHS_PROPERTY), th)); -// return List.of(); -// } -// } public void updateFullyQualifiedName(PublicId publicId, ViewProperties viewProperties) { Transaction transaction = Transaction.make(); From 856a0ff7e93ec14c17a33395ff5d5991126c2c53 Mon Sep 17 00:00:00 2001 From: swsalvi Date: Tue, 9 Sep 2025 18:19:28 -0400 Subject: [PATCH 5/5] Fix for bug IIA-2836 Definition under concept title is incorrect and updates based on wrong preference --- .../ikm/komet/kview/mvvm/view/concept/ConceptController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kview/src/main/java/dev/ikm/komet/kview/mvvm/view/concept/ConceptController.java b/kview/src/main/java/dev/ikm/komet/kview/mvvm/view/concept/ConceptController.java index cfc6b34e5..71b13b98f 100644 --- a/kview/src/main/java/dev/ikm/komet/kview/mvvm/view/concept/ConceptController.java +++ b/kview/src/main/java/dev/ikm/komet/kview/mvvm/view/concept/ConceptController.java @@ -905,7 +905,7 @@ public void updateConceptBanner() { conceptNameTooltip.setText(conceptNameStr); // Definition description text - definitionTextField.setText(viewCalculator.languageCalculator().getDescriptionTextOrNid(entityFacade.nid())); + definitionTextField.setText(viewCalculator.languageCalculator().getPreferredDescriptionTextWithFallbackOrNid(entityFacade.nid())); setupDisplayUUID(entityFacade, viewCalculator);