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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand All @@ -58,7 +69,7 @@ public class AddFullyQualifiedNameController extends AbstractBasicController {
private TextField fullyQualifiedNameTextField;

@FXML
private ComboBox<ConceptEntity> typeDisplayComboBox;
private ComboBox<EntityFacade> typeDisplayComboBox;

@FXML
private ComboBox<EntityFacade> caseSignificanceComboBox;
Expand Down Expand Up @@ -114,6 +125,7 @@ public void initialize() {
setupComboBox(statusComboBox, formValid);
setupComboBox(caseSignificanceComboBox, formValid);
setupComboBox(languageComboBox, formValid);
setupComboBox(typeDisplayComboBox, formValid);
}

/**
Expand All @@ -139,16 +151,19 @@ public void populate(ComboBox comboBox, Collection<ConceptEntity> 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
Expand All @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand Down Expand Up @@ -116,6 +127,7 @@ public void initialize() {
setupComboBox(statusComboBox, formValid);
setupComboBox(caseSignificanceComboBox, formValid);
setupComboBox(languageComboBox, formValid);
setupComboBox(typeDisplayComboBox, formValid);
}

/**
Expand Down Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();

Expand All @@ -168,6 +170,7 @@ public void initialize() {
caseSignificanceComboBox.valueProperty().addListener(invalidationListener);
statusComboBox.valueProperty().addListener(invalidationListener);
languageComboBox.valueProperty().addListener(invalidationListener);
typeDisplayComboBox.valueProperty().addListener(invalidationListener);
validateForm();
}

Expand Down Expand Up @@ -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<ConceptEntity> 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);

Expand Down Expand Up @@ -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())
Expand Down
Loading