diff --git a/webprotege-gwt-ui-client/src/main/java/edu/stanford/bmir/protege/web/client/inject/ClientApplicationModule.java b/webprotege-gwt-ui-client/src/main/java/edu/stanford/bmir/protege/web/client/inject/ClientApplicationModule.java index c2c59dd64..fe5bb28f1 100644 --- a/webprotege-gwt-ui-client/src/main/java/edu/stanford/bmir/protege/web/client/inject/ClientApplicationModule.java +++ b/webprotege-gwt-ui-client/src/main/java/edu/stanford/bmir/protege/web/client/inject/ClientApplicationModule.java @@ -65,7 +65,6 @@ import edu.stanford.bmir.protege.web.client.library.modal.ModalViewImpl; import edu.stanford.bmir.protege.web.client.library.msgbox.InputBoxView; import edu.stanford.bmir.protege.web.client.library.msgbox.InputBoxViewImpl; -import edu.stanford.bmir.protege.web.client.linearization.*; import edu.stanford.bmir.protege.web.client.login.LoginView; import edu.stanford.bmir.protege.web.client.login.LoginViewImpl; import edu.stanford.bmir.protege.web.client.login.SignInRequestHandler; @@ -496,26 +495,6 @@ EntityTagsSelectorView provideEntityTagsSelectorView(EntityTagsSelectorViewImpl EditorPortletView provideEditorPortletView(EditorPortletViewImpl impl) { return impl; } - @Provides - LinearizationParentView provideLinearizationParentView(LinearizationParentViewImpl impl) { - return impl; - } - - - @Provides - LinearizationPortletView provideLinearizationPortletView(LinearizationPortletViewImpl impl) { - return impl; - } - - @Provides - PostCoordinationPortletView providePostCoordinationPortletView(PostCoordinationPortletViewImpl impl){ - return impl; - } - - @Provides - LinearizationCommentsView provideLienarizationCommentsView(LinearizationCommentsViewImpl impl){ - return impl; - } @Provides ProjectTagsView provideProjectTagsView(ProjectTagsViewImpl impl) { diff --git a/webprotege-gwt-ui-client/src/main/java/edu/stanford/bmir/protege/web/client/inject/ClientProjectModule.java b/webprotege-gwt-ui-client/src/main/java/edu/stanford/bmir/protege/web/client/inject/ClientProjectModule.java index 580e8bcc7..bc06e9b52 100644 --- a/webprotege-gwt-ui-client/src/main/java/edu/stanford/bmir/protege/web/client/inject/ClientProjectModule.java +++ b/webprotege-gwt-ui-client/src/main/java/edu/stanford/bmir/protege/web/client/inject/ClientProjectModule.java @@ -20,7 +20,12 @@ import edu.stanford.bmir.protege.web.client.individualslist.*; import edu.stanford.bmir.protege.web.client.lang.*; import edu.stanford.bmir.protege.web.client.library.tokenfield.*; +import edu.stanford.bmir.protege.web.client.linearization.*; import edu.stanford.bmir.protege.web.client.list.*; +import edu.stanford.bmir.protege.web.client.logicaldefinition.LogicalDefinitionPortletView; +import edu.stanford.bmir.protege.web.client.logicaldefinition.LogicalDefinitionPortletViewImpl; +import edu.stanford.bmir.protege.web.client.logicaldefinition.LogicalDefinitionTableWrapper; +import edu.stanford.bmir.protege.web.client.logicaldefinition.LogicalDefinitionTableWrapperImpl; import edu.stanford.bmir.protege.web.client.match.*; import edu.stanford.bmir.protege.web.client.ontology.annotations.*; import edu.stanford.bmir.protege.web.client.permissions.*; @@ -28,6 +33,10 @@ import edu.stanford.bmir.protege.web.client.portlet.*; import edu.stanford.bmir.protege.web.client.postcoordination.PostCoordinationChangesHandler; import edu.stanford.bmir.protege.web.client.postcoordination.PostCoordinationChangesHandlerImpl; +import edu.stanford.bmir.protege.web.client.postcoordination.PostCoordinationPortletView; +import edu.stanford.bmir.protege.web.client.postcoordination.PostCoordinationPortletViewImpl; +import edu.stanford.bmir.protege.web.client.postcoordination.PostCoordinationChangesHandler; +import edu.stanford.bmir.protege.web.client.postcoordination.PostCoordinationChangesHandlerImpl; import edu.stanford.bmir.protege.web.client.project.*; import edu.stanford.bmir.protege.web.client.projectsettings.*; import edu.stanford.bmir.protege.web.client.renderer.*; @@ -217,6 +226,39 @@ NumericValueCriteriaView provideNumericValueCriteriaView(NumericValueCriteriaVie return impl; } + + @Provides + LogicalDefinitionPortletView provideLogicalDefinitionPortletView(LogicalDefinitionPortletViewImpl impl) { + return impl; + } + +/* @Provides + LogicalDefinitionTableWrapper provideLogicalDefinitionTableWrapper(LogicalDefinitionTableWrapperImpl impl) { + return impl; + }*/ + + @Provides + LinearizationParentView provideLinearizationParentView(LinearizationParentViewImpl impl) { + return impl; + } + + + @Provides + LinearizationPortletView provideLinearizationPortletView(LinearizationPortletViewImpl impl) { + return impl; + } + + @Provides + PostCoordinationPortletView providePostCoordinationPortletView(PostCoordinationPortletViewImpl impl){ + return impl; + } + + + @Provides + LinearizationCommentsView provideLienarizationCommentsView(LinearizationCommentsViewImpl impl){ + return impl; + } + @Provides LangTagMatchesCriteriaView provideLangTagMatchesCriteriaView(LangTagMatchesCriteriaViewImpl impl) { return impl; diff --git a/webprotege-gwt-ui-client/src/main/java/edu/stanford/bmir/protege/web/client/linearization/LinearizationParentViewImpl.java b/webprotege-gwt-ui-client/src/main/java/edu/stanford/bmir/protege/web/client/linearization/LinearizationParentViewImpl.java index ff19eaffa..260ad83b7 100644 --- a/webprotege-gwt-ui-client/src/main/java/edu/stanford/bmir/protege/web/client/linearization/LinearizationParentViewImpl.java +++ b/webprotege-gwt-ui-client/src/main/java/edu/stanford/bmir/protege/web/client/linearization/LinearizationParentViewImpl.java @@ -10,7 +10,7 @@ import java.util.Iterator; import java.util.List; -import java.util.logging.Logger; + public class LinearizationParentViewImpl extends Composite implements LinearizationParentView { diff --git a/webprotege-gwt-ui-client/src/main/java/edu/stanford/bmir/protege/web/client/logicaldefinition/LogicalDefinition.css b/webprotege-gwt-ui-client/src/main/java/edu/stanford/bmir/protege/web/client/logicaldefinition/LogicalDefinition.css new file mode 100644 index 000000000..4a7f1683e --- /dev/null +++ b/webprotege-gwt-ui-client/src/main/java/edu/stanford/bmir/protege/web/client/logicaldefinition/LogicalDefinition.css @@ -0,0 +1,87 @@ +.superClassTable { + overflow: hidden; + margin-top: 15px; + border-collapse: collapse; + padding: 3px; + width: 50%; +} + +.tableText { + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; + vertical-align: middle; +} + +.definitionsEmptyState { + height: 300px; + background-repeat: no-repeat; + background-position: center; +} + +.tableText > div { + display: flex; + justify-content: start; + align-content: center; + text-align: left; + max-width: 350px; + margin: 8px; + +} + +.logicalDefinitionDropdown { + background-color: white; + margin: 5px; + padding: 3px; +} + +.superClassTableHeader .tableText > div { + font-size: 14px; + font-weight: bold; +} + +.customRowStyle { + + border-bottom: 1px solid #f2f2f2; +} + +.removeButtonCell { + width: 20px; + height: 20px; + align-self: center; +} + +.removeButtonCell > div { + margin-top: 2px; + margin-bottom: 2px; +} + + +.superClassTableHeader { + font-size: 18px; + color: #fff; + line-height: 1.4; + background-color: #186cd4; + font-family: "Helvetica Neue", "Lucida Grande", "Segoe UI", Arial, Helvetica, Verdana, sans-serif; +} + +.dropDownMandatory{ + color: red; + margin: 2px; + font-size: bold; +} + +.dropDownAllowed { + color: green; + margin: 2px; + font-size: bold; +} + +.dropDownNotSet{ + margin: 2px; +} + +.superClassName { + font-size: 12px; + font-weight: bold; +} \ No newline at end of file diff --git a/webprotege-gwt-ui-client/src/main/java/edu/stanford/bmir/protege/web/client/logicaldefinition/LogicalDefinitionPortletPresenter.java b/webprotege-gwt-ui-client/src/main/java/edu/stanford/bmir/protege/web/client/logicaldefinition/LogicalDefinitionPortletPresenter.java new file mode 100644 index 000000000..f0a389853 --- /dev/null +++ b/webprotege-gwt-ui-client/src/main/java/edu/stanford/bmir/protege/web/client/logicaldefinition/LogicalDefinitionPortletPresenter.java @@ -0,0 +1,64 @@ +package edu.stanford.bmir.protege.web.client.logicaldefinition; + +import edu.stanford.bmir.protege.web.client.dispatch.DispatchServiceManager; +import edu.stanford.bmir.protege.web.client.lang.DisplayNameRenderer; +import edu.stanford.bmir.protege.web.client.portlet.AbstractWebProtegePortletPresenter; +import edu.stanford.bmir.protege.web.client.portlet.PortletUi; +import edu.stanford.bmir.protege.web.client.selection.SelectionModel; +import edu.stanford.bmir.protege.web.shared.event.WebProtegeEventBus; +import edu.stanford.bmir.protege.web.shared.project.ProjectId; +import edu.stanford.bmir.protege.web.shared.renderer.GetEntityRenderingAction; +import edu.stanford.webprotege.shared.annotations.Portlet; +import org.semanticweb.owlapi.model.OWLEntity; + +import javax.annotation.Nonnull; +import javax.inject.Inject; +import java.util.Optional; + +@Portlet(id = "portlets.LogicalDefinition", + title = "iCat-X Logical Definition", + tooltip = "Displays the existing logical definitions on the current entity.") +public class LogicalDefinitionPortletPresenter extends AbstractWebProtegePortletPresenter { + + + private LogicalDefinitionPortletView view; + + private DispatchServiceManager dispatch; + + @Inject + public LogicalDefinitionPortletPresenter(@Nonnull SelectionModel selectionModel, + @Nonnull ProjectId projectId, + @Nonnull DisplayNameRenderer displayNameRenderer, + @Nonnull DispatchServiceManager dispatch, + @Nonnull LogicalDefinitionPortletView view) { + super(selectionModel, projectId, displayNameRenderer, dispatch); + this.view = view; + this.dispatch = dispatch; + } + + @Override + public void startPortlet(PortletUi portletUi, + WebProtegeEventBus eventBus) { + setDisplaySelectedEntityNameAsSubtitle(true); + portletUi.setWidget(view.asWidget()); + + } + + @Override + protected void handleReloadRequest() { + + } + + @Override + protected void handleAfterSetEntity(Optional entityData) { + if(!entityData.isPresent()) { + setNothingSelectedVisible(true); + setDisplayedEntity(Optional.empty()); + } else { + setNothingSelectedVisible(false); + dispatch.execute(GetEntityRenderingAction.create(getProjectId(), entityData.get()), + (result) -> setDisplayedEntity(Optional.of(result.getEntityData()))); + view.setEntity(entityData.get(), getProjectId()); + } + } +} \ No newline at end of file diff --git a/webprotege-gwt-ui-client/src/main/java/edu/stanford/bmir/protege/web/client/logicaldefinition/LogicalDefinitionPortletView.java b/webprotege-gwt-ui-client/src/main/java/edu/stanford/bmir/protege/web/client/logicaldefinition/LogicalDefinitionPortletView.java new file mode 100644 index 000000000..6498da2e8 --- /dev/null +++ b/webprotege-gwt-ui-client/src/main/java/edu/stanford/bmir/protege/web/client/logicaldefinition/LogicalDefinitionPortletView.java @@ -0,0 +1,12 @@ +package edu.stanford.bmir.protege.web.client.logicaldefinition; + +import com.google.gwt.user.client.ui.AcceptsOneWidget; +import com.google.gwt.user.client.ui.IsWidget; +import edu.stanford.bmir.protege.web.shared.HasDispose; +import edu.stanford.bmir.protege.web.shared.project.ProjectId; +import org.semanticweb.owlapi.model.OWLEntity; + +public interface LogicalDefinitionPortletView extends AcceptsOneWidget, IsWidget, HasDispose { + + void setEntity(OWLEntity owlEntity, ProjectId projectId); +} diff --git a/webprotege-gwt-ui-client/src/main/java/edu/stanford/bmir/protege/web/client/logicaldefinition/LogicalDefinitionPortletViewImpl.java b/webprotege-gwt-ui-client/src/main/java/edu/stanford/bmir/protege/web/client/logicaldefinition/LogicalDefinitionPortletViewImpl.java new file mode 100644 index 000000000..95d3ff2dd --- /dev/null +++ b/webprotege-gwt-ui-client/src/main/java/edu/stanford/bmir/protege/web/client/logicaldefinition/LogicalDefinitionPortletViewImpl.java @@ -0,0 +1,319 @@ +package edu.stanford.bmir.protege.web.client.logicaldefinition; + +import com.google.gwt.core.client.GWT; +import com.google.gwt.uibinder.client.UiBinder; +import com.google.gwt.uibinder.client.UiField; +import com.google.gwt.user.client.ui.*; +import edu.stanford.bmir.protege.web.client.dispatch.DispatchServiceManager; +import edu.stanford.bmir.protege.web.client.library.dlg.DialogButton; +import edu.stanford.bmir.protege.web.client.library.msgbox.MessageBox; +import edu.stanford.bmir.protege.web.client.library.msgbox.MessageStyle; +import edu.stanford.bmir.protege.web.client.uuid.UuidV4; +import edu.stanford.bmir.protege.web.client.uuid.UuidV4Provider; +import edu.stanford.bmir.protege.web.resources.WebProtegeClientBundle; +import edu.stanford.bmir.protege.web.shared.entity.OWLEntityData; +import edu.stanford.bmir.protege.web.shared.icd.AncestorClassHierarchy; +import edu.stanford.bmir.protege.web.shared.icd.GetClassAncestorsAction; +import edu.stanford.bmir.protege.web.shared.logicaldefinition.*; +import edu.stanford.bmir.protege.web.shared.perspective.ChangeRequestId; +import edu.stanford.bmir.protege.web.shared.postcoordination.*; +import edu.stanford.bmir.protege.web.shared.project.ProjectId; +import org.semanticweb.owlapi.model.OWLEntity; + +import javax.annotation.Nonnull; +import javax.inject.Inject; +import java.util.*; +import java.util.logging.Logger; +import java.util.stream.Collectors; + +public class LogicalDefinitionPortletViewImpl extends Composite implements LogicalDefinitionPortletView { + + Logger logger = java.util.logging.Logger.getLogger("LogicalDefinitionPortletViewImpl"); + + @UiField + HTMLPanel paneContainer; + + @UiField + Button addDefinitionButton; + + @UiField + HTMLPanel definitions; + + @UiField + HTMLPanel necessaryConditionsContainer; + + @UiField Button editValuesButton; + @UiField Button cancelButton; + + @UiField Button saveValuesButton; + + private static final LogicalDefinitionPortletViewImpl.LogicalDefinitionPortletViewImplUiBinder ourUiBinder = GWT.create(LogicalDefinitionPortletViewImpl.LogicalDefinitionPortletViewImplUiBinder.class); + + private final DispatchServiceManager dispatchServiceManager; + + private final MessageBox messageBox; + + private ProjectId projectId; + + private List ancestorsList = new ArrayList<>(); + + private List labels; + + private WhoficCustomScalesValues superclassScalesValue; + + private WhoficEntityPostCoordinationSpecification superclassSpecification; + + private List axisToGenericScales = new ArrayList<>(); + private LogicalDefinitionResourceBundle.LogicalDefinitionCss style; + + private List tableWrappers = new ArrayList<>(); + WebProtegeClientBundle BUNDLE = GWT.create(WebProtegeClientBundle.class); + + private LogicalConditions pristineData; + + private UuidV4Provider uuidV4Provider; + + private OWLEntity currentEntity; + + private final LogicalDefinitionTable necessaryConditionsTable = new LogicalDefinitionTable(new LogicalDefinitionTableConfig("Necessary Axis", + "Value", + this::initializeTable)); + + @Inject + public LogicalDefinitionPortletViewImpl(@Nonnull DispatchServiceManager dispatchServiceManager, + @Nonnull MessageBox messageBox, + @Nonnull UuidV4Provider uuidV4Provider) { + this.dispatchServiceManager = dispatchServiceManager; + this.messageBox = messageBox; + this.uuidV4Provider = uuidV4Provider; + LogicalDefinitionResourceBundle.INSTANCE.style().ensureInjected(); + style = LogicalDefinitionResourceBundle.INSTANCE.style(); + + initWidget(ourUiBinder.createAndBindUi(this)); + + necessaryConditionsContainer.add(necessaryConditionsTable); + + dispatchServiceManager.execute(GetPostcoordinationAxisToGenericScaleAction.create(), result -> { + this.axisToGenericScales = result.getPostcoordinationAxisToGenericScales(); + }); + + this.addDefinitionButton.getElement().setInnerHTML(style.getPlusSvg()); + + this.addDefinitionButton.addClickHandler((event -> { + if(tableWrappers.isEmpty()) { + definitions.getElement().getStyle().setBackgroundImage(null); + } + LogicalDefinitionTableWrapper newTable = new LogicalDefinitionTableBuilder(dispatchServiceManager, projectId) + .withLabels(this.labels) + .withAncestorsList(this.ancestorsList) + .withRemoveHandler((this::removeWrapper)) + .asNewTable(); + + this.tableWrappers.add(newTable); + this.definitions.add(newTable.asWidget()); + })); + + switchToReadOnly(); + this.editValuesButton.addClickHandler(event -> switchToEditable()); + this.saveValuesButton.addClickHandler(event -> saveValues()); + displayPlaceholder(); + } + + + @Override + public void setWidget(IsWidget w) { + + } + @Override + public void dispose() { + + } + + @Override + public void setEntity(OWLEntity owlEntity, ProjectId projectId) { + this.projectId = projectId; + this.necessaryConditionsTable.resetTable(); + this.tableWrappers = new ArrayList<>(); + this.definitions.clear(); + this.currentEntity = owlEntity; + dispatchServiceManager.execute(GetEntityCustomScalesAction.create(owlEntity.getIRI().toString(), projectId), postcoordination -> { + this.superclassScalesValue = postcoordination.getWhoficCustomScaleValues(); + }); + + dispatchServiceManager.execute(GetClassAncestorsAction.create(owlEntity.getIRI(), projectId), getHierarchyParentsResult -> { + Set result = new HashSet<>(); + populateAncestorsFromTree(getHierarchyParentsResult.getAncestorsTree(), result); + ancestorsList = new ArrayList<>(result); + + dispatchServiceManager.execute(GetPostCoordinationTableConfigurationAction.create("ICD"), config -> { + this.labels = config.getLabels(); + populateWithExistingDefinition(owlEntity, projectId); + populateAvailableAxisValues(owlEntity); + }); + }); + + switchToReadOnly(); + } + + private void populateWithExistingDefinition(OWLEntity owlEntity, ProjectId projectId) { + dispatchServiceManager.execute(GetEntityLogicalDefinitionAction.create(projectId, owlEntity.asOWLClass()), (GetEntityLogicalDefinitionResult getEntityLogicalDefinitionResult) -> { + this.pristineData = LogicalConditions.create(getEntityLogicalDefinitionResult.getLogicalDefinitions(), getEntityLogicalDefinitionResult.getNecessaryConditions()); + if(getEntityLogicalDefinitionResult.getLogicalDefinitions() != null && !getEntityLogicalDefinitionResult.getLogicalDefinitions().isEmpty()) { + definitions.getElement().getStyle().setBackgroundImage(null); + + for(LogicalDefinition logicalDefinition : getEntityLogicalDefinitionResult.getLogicalDefinitions()) { + List superClassTableRows = logicalDefinition.getAxis2filler().stream() + .map(LogicalDefinitionTableRow::new) + .collect(Collectors.toList()); + + LogicalDefinitionTableWrapper newTable = new LogicalDefinitionTableBuilder(dispatchServiceManager, projectId) + .withLabels(this.labels) + .withAncestorsList(this.ancestorsList) + .withParentIri(logicalDefinition.getLogicalDefinitionParent().getIri().toString()) + .withRemoveHandler((this::removeWrapper)) + .asExistingTable(); + + this.tableWrappers.add(newTable); + this.definitions.add(newTable.asWidget()); + + newTable.addExistingRows(superClassTableRows); + } + + } else { + displayPlaceholder(); + } + if(getEntityLogicalDefinitionResult.getNecessaryConditions() != null && !getEntityLogicalDefinitionResult.getNecessaryConditions().isEmpty()) { + + List necessaryConditionsTableRows = getEntityLogicalDefinitionResult.getNecessaryConditions().stream() + .map(LogicalDefinitionTableRow::new) + .collect(Collectors.toList()); + + necessaryConditionsTable.addExistingRows(necessaryConditionsTableRows); + } + }); + } + + private void displayPlaceholder() { + String backgroundImageUrl = BUNDLE.noDataFound().getSafeUri().asString(); + definitions.getElement().getStyle().setBackgroundImage("url(" + backgroundImageUrl + ")"); + definitions.getElement().addClassName(style.definitionsEmptyState()); + } + + private void initializeTable(String postCoordinationAxis, LogicalDefinitionTable table) { + List selectedScales = superclassScalesValue.getScaleCustomizations().stream() + .filter(s -> s.getPostcoordinationAxis().equalsIgnoreCase(postCoordinationAxis)) + .flatMap(s -> s.getPostcoordinationScaleValues().stream()) + .collect(Collectors.toList()); + + if(selectedScales.isEmpty()) { + List equivalentRoots = axisToGenericScales.stream() + .filter(axis -> axis.getPostcoordinationAxis().equalsIgnoreCase(postCoordinationAxis)) + .map(PostcoordinationAxisToGenericScale::getGenericPostcoordinationScaleTopClass) + .collect(Collectors.toList()); + selectedScales.addAll(equivalentRoots); + } + + Map map = new HashMap<>(); + for(String availableAxis : selectedScales) { + map.put(availableAxis, availableAxis); + } + + table.setAvailableValues(map); + } + + private void populateAvailableAxisValues(OWLEntity owlEntity) { + dispatchServiceManager.execute(GetEntityPostCoordinationAction.create(owlEntity.getIRI().toString(), projectId), postcoordination -> { + + this.superclassSpecification = postcoordination.getPostCoordinationSpecification(); + if(this.superclassSpecification.getPostCoordinationSpecifications() != null) { + Optional mmsSpec = this.superclassSpecification.getPostCoordinationSpecifications() + .stream().filter( spec -> spec.getLinearizationView().equalsIgnoreCase("http://id.who.int/icd/release/11/mms")) + .findFirst(); + mmsSpec.ifPresent(postCoordinationSpecification -> necessaryConditionsTable.setAvailableAxisFromSpec(postCoordinationSpecification, this.labels)); + } + }); + + } + + private void saveValues() { + List definitions = this.tableWrappers.stream().map(LogicalDefinitionTableWrapper::getLogicalDefinition).collect(Collectors.toList()); + + boolean hasDuplicates = verifyForDuplicates(definitions); + + if(!hasDuplicates) { + this.dispatchServiceManager.execute(UpdateLogicalDefinitionAction.create(ChangeRequestId.get(uuidV4Provider.get()), + projectId, + this.currentEntity.asOWLClass(), + this.pristineData, + LogicalConditions.create(definitions, necessaryConditionsTable.getValues()), + "Commit" + ), response ->{ + logger.info("ALEX response " + response); + }); + } else { + messageBox.showConfirmBox(MessageStyle.ALERT, + "Logical definition have duplicated superClasses", + "", + DialogButton.NO, + ()->{}, + DialogButton.YES, + ()->{}, + DialogButton.YES); + } + + } + + private boolean verifyForDuplicates(List definitions) { + Set parentIRISet = new HashSet<>(); + for (LogicalDefinition obj : definitions) { + String parentIRI = obj.getLogicalDefinitionParent().getIri().toString(); + if (parentIRISet.contains(parentIRI)) { + return true; + } else { + parentIRISet.add(parentIRI); + } + } + return false; + } + + private void removeWrapper(LogicalDefinitionTableWrapper wrapper) { + this.tableWrappers.remove(wrapper); + this.definitions.remove(wrapper.asWidget()); + if(tableWrappers.isEmpty()){ + displayPlaceholder(); + } + } + + private void populateAncestorsFromTree(AncestorClassHierarchy node, Set accumulator) { + accumulator.add(node.getCurrentNode()); + for(AncestorClassHierarchy child: node.getChildren()) { + populateAncestorsFromTree(child, accumulator); + } + } + private void switchToReadOnly() { + toggleButtons(true); + this.necessaryConditionsTable.setReadOnly(); + for(LogicalDefinitionTableWrapper wrapper : this.tableWrappers) { + wrapper.enableReadOnly(); + } + } + + private void toggleButtons(boolean readOnly){ + this.saveValuesButton.setVisible(!readOnly); + this.cancelButton.setVisible(!readOnly); + this.editValuesButton.setVisible(readOnly); + this.addDefinitionButton.setEnabled(!readOnly); + } + + private void switchToEditable(){ + this.toggleButtons(false); + this.necessaryConditionsTable.setEditable(); + for(LogicalDefinitionTableWrapper wrapper : this.tableWrappers) { + wrapper.enableEditable(); + } + } + + interface LogicalDefinitionPortletViewImplUiBinder extends UiBinder { + + } +} diff --git a/webprotege-gwt-ui-client/src/main/java/edu/stanford/bmir/protege/web/client/logicaldefinition/LogicalDefinitionPortletViewImpl.ui.xml b/webprotege-gwt-ui-client/src/main/java/edu/stanford/bmir/protege/web/client/logicaldefinition/LogicalDefinitionPortletViewImpl.ui.xml new file mode 100644 index 000000000..02351a883 --- /dev/null +++ b/webprotege-gwt-ui-client/src/main/java/edu/stanford/bmir/protege/web/client/logicaldefinition/LogicalDefinitionPortletViewImpl.ui.xml @@ -0,0 +1,114 @@ + + + .mainContent { + display: flex; + flex-direction: column; + } + .card { + border-radius: 5px; + overflow: auto; + -webkit-box-shadow: 0 0 40px 0 rgba(0,0,0,.15); + box-shadow: 0 0 40px 0 rgba(0,0,0,.15); + margin: 15px; + border-collapse: collapse; + padding: 10px; + position: relative!important; + height: auto!important; + + } + .cardLabel { + font-weight: bold; + padding-bottom: 5px; + font-size: 17px; + white-space: nowrap; + display: flex; + align-items: center; + } + .rowWrapper { + display: flex; + justify-content: flex-start; + } + .label { + font-size: 13px; + white-space: nowrap; + margin-right: 3vw; + text-align: center; + } + + .submitButtonWrappers { + flex-direction: row; + align-content: end; + display: flex; + justify-content: end; + width: 97%; + margin:15px; + padding: 3px; + } + .editValuesButton { + background-color: #186cd4; + border: none; + color: white; + padding: 10px 15px; + text-align: center; + text-decoration: none; + display: inline-block; + font-size: 14px; + margin: 4px 2px; + cursor: pointer; + border-radius: 8px; + } + + .editValuesButton:hover { + background-color: #1252a1; + } + .cancelButton { + background-color: #F7F7F7; + border: none; + color: var(--primary--color); + padding: 10px 15px; + text-align: center; + text-decoration: none; + display: inline-block; + font-size: 14px; + margin: 4px 2px; + cursor: pointer; + border-radius: 8px; + } + .cancelButton:hover { + background-color: #E3E3E3; + } + + .addDefinitionsButton { + width: 25px; + height: 25px; + } + + + +
+ Logical definitions + +
+ + + + + +
+ + +
+ Necessary conditions +
+
+ +
+ Edit values + Save values + Cancel +
+
+ +
\ No newline at end of file diff --git a/webprotege-gwt-ui-client/src/main/java/edu/stanford/bmir/protege/web/client/logicaldefinition/LogicalDefinitionResourceBundle.java b/webprotege-gwt-ui-client/src/main/java/edu/stanford/bmir/protege/web/client/logicaldefinition/LogicalDefinitionResourceBundle.java new file mode 100644 index 000000000..ac7e14609 --- /dev/null +++ b/webprotege-gwt-ui-client/src/main/java/edu/stanford/bmir/protege/web/client/logicaldefinition/LogicalDefinitionResourceBundle.java @@ -0,0 +1,69 @@ +package edu.stanford.bmir.protege.web.client.logicaldefinition; + +import com.google.gwt.core.client.GWT; +import com.google.gwt.resources.client.ClientBundle; +import com.google.gwt.resources.client.CssResource; + +public interface LogicalDefinitionResourceBundle extends ClientBundle { + + LogicalDefinitionResourceBundle INSTANCE = GWT.create(LogicalDefinitionResourceBundle.class); + + + @Source("LogicalDefinition.css") + LogicalDefinitionResourceBundle.LogicalDefinitionCss style(); + + interface LogicalDefinitionCss extends CssResource { + + @ClassName("superClassTable") + String superClassTable(); + + @ClassName("definitionsEmptyState") + String definitionsEmptyState(); + + @ClassName("tableText") + String tableText(); + + @ClassName("superClassTableHeader") + String superClassTableHeader(); + + @ClassName("customRowStyle") + String customRowStyle(); + + @ClassName("dropDownMandatory") + String dropDownMandatory(); + @ClassName("dropDownAllowed") + String dropDownAllowed(); + @ClassName("dropDownNotSet") + String dropDownNotSet(); + + @ClassName("logicalDefinitionDropdown") + String logicalDefinitionDropdown(); + + @ClassName("superClassName") + String superClassName(); + + @ClassName("removeButtonCell") + String removeButtonCell(); + + default String getxSvg(){ + return X_SVG; + } + + default String getPlusSvg(){ + return PLUS_SVG; + } + + default String getDeleteSvg() { + return DELETE_SVG; + } + String X_SVG = " "; + + String PLUS_SVG =" "; + + String DELETE_SVG = " "; + + + } + + +} diff --git a/webprotege-gwt-ui-client/src/main/java/edu/stanford/bmir/protege/web/client/logicaldefinition/LogicalDefinitionTable.java b/webprotege-gwt-ui-client/src/main/java/edu/stanford/bmir/protege/web/client/logicaldefinition/LogicalDefinitionTable.java new file mode 100644 index 000000000..894c72ad2 --- /dev/null +++ b/webprotege-gwt-ui-client/src/main/java/edu/stanford/bmir/protege/web/client/logicaldefinition/LogicalDefinitionTable.java @@ -0,0 +1,270 @@ +package edu.stanford.bmir.protege.web.client.logicaldefinition; + +import com.google.common.collect.ImmutableList; +import com.google.gwt.dom.client.NodeList; +import com.google.gwt.dom.client.OptionElement; +import com.google.gwt.dom.client.SelectElement; +import com.google.gwt.user.client.ui.*; +import edu.stanford.bmir.protege.web.shared.entity.OWLClassData; +import edu.stanford.bmir.protege.web.shared.entity.OWLObjectPropertyData; +import edu.stanford.bmir.protege.web.shared.frame.PropertyClassValue; +import edu.stanford.bmir.protege.web.shared.frame.State; +import edu.stanford.bmir.protege.web.shared.postcoordination.PostCoordinationSpecification; +import edu.stanford.bmir.protege.web.shared.postcoordination.PostCoordinationTableAxisLabel; +import org.semanticweb.owlapi.model.IRI; +import uk.ac.manchester.cs.owl.owlapi.OWLClassImpl; +import uk.ac.manchester.cs.owl.owlapi.OWLObjectPropertyImpl; + +import java.util.*; +import java.util.logging.Logger; +import java.util.stream.Collectors; + +public class LogicalDefinitionTable implements IsWidget { + Logger logger = java.util.logging.Logger.getLogger("LogicalDefinitionTable"); + + private LogicalDefinitionTableConfig config; + + private FlexTable flexTable = new FlexTable(); + private ListBox axisDropdown = new ListBox(); + private ListBox valuesDropdown = new ListBox(); + private LogicalDefinitionResourceBundle.LogicalDefinitionCss style; + + private boolean readOnly = true; + private List tableRows = new ArrayList<>(); + + public LogicalDefinitionTable(LogicalDefinitionTableConfig config) { + LogicalDefinitionResourceBundle.INSTANCE.style().ensureInjected(); + style = LogicalDefinitionResourceBundle.INSTANCE.style(); + this.config = config; + initializeSuperClassTableHeader(); + injectTableControls(); + setControlsHandlers(); + axisDropdown.setStyleName(style.logicalDefinitionDropdown()); + valuesDropdown.setStyleName(style.logicalDefinitionDropdown()); + } + + @Override + public Widget asWidget() { + return flexTable; + } + + + public void addExistingRows(List rows) { + this.tableRows = new ArrayList<>(); + for(LogicalDefinitionTableRow row: rows) { + this.tableRows.add(row); + addNewRowToTable(row); + } + } + + public void resetTable(){ + if(flexTable.getRowCount() > 2) { + int count = 0; + int nrOfRemovableRows = flexTable.getRowCount() - 2; + while(count < nrOfRemovableRows) { + this.flexTable.removeRow(1); + count++; + } + } + + + this.tableRows = new ArrayList<>(); + this.valuesDropdown.clear(); + this.axisDropdown.clear(); + this.readOnly = true; + } + + + public void setAvailableAxisFromSpec(PostCoordinationSpecification spec, List labels) { + Map availableAxis = new HashMap<>(); + + spec.getRequiredAxes().stream().sorted( + (s1, s2) -> getAxisName(s1, labels).compareTo(getAxisName(s2, labels))) + .forEach((requiredAxis) -> { + availableAxis.put(requiredAxis, new LogicalDefinitionTable.DropdownElement(getAxisName(requiredAxis, labels), style.dropDownMandatory())); + }); + spec.getAllowedAxes().stream().sorted((s1, s2) -> getAxisName(s1, labels).compareTo(getAxisName(s2, labels))) + .forEach((allowedAxis) -> { + availableAxis.put(allowedAxis, new LogicalDefinitionTable.DropdownElement(getAxisName(allowedAxis, labels), style.dropDownAllowed())); + }); + spec.getNotAllowedAxes().stream().sorted((s1, s2) -> getAxisName(s1, labels).compareTo(getAxisName(s2, labels))) + .forEach((notSetAxis) -> availableAxis.put(notSetAxis, new LogicalDefinitionTable.DropdownElement(getAxisName(notSetAxis, labels), style.dropDownNotSet()))) ; + + setAvailableAxis(availableAxis); + } + + private String getAxisName(String axisIri, List labels) { + return labels.stream() + .filter(entry -> entry.getPostCoordinationAxis().equalsIgnoreCase(axisIri)) + .map(PostCoordinationTableAxisLabel::getTableLabel).findFirst() + .orElse(""); + } + + private void setAvailableAxis(Map specification) { + axisDropdown.clear(); + axisDropdown.addItem("", ""); + + for(String axis : specification.keySet()) { + axisDropdown.addItem(specification.get(axis).label, axis); + } + + SelectElement selectElement = SelectElement.as(axisDropdown.getElement()); + NodeList options = selectElement.getOptions(); + + for (int i = 0; i < options.getLength(); i++) { + String optionValue = options.getItem(i).getValue(); + DropdownElement dropdownElement = specification.get(optionValue); + if(dropdownElement != null) { + options.getItem(i).addClassName(dropdownElement.cssClass); + } + } + } + + public void setAvailableValues(Map availableValues) { + + this.valuesDropdown.clear(); + + valuesDropdown.addItem("",""); + + for(String axis: availableValues.keySet()) { + valuesDropdown.addItem(axis, availableValues.get(axis)); + } + } + + + public void setEditable(){ + this.axisDropdown.setEnabled(true); + this.valuesDropdown.setEnabled(true); + this.readOnly = false; + } + + public void setReadOnly(){ + this.axisDropdown.setEnabled(false); + this.valuesDropdown.setEnabled(false); + this.readOnly = true; + } + + public List getRows(){ + return this.tableRows; + } + + public List getValues(){ + return this.tableRows.stream() + .map(row -> PropertyClassValue.get(getAxisProperty(row), getValueClassData(row), State.ASSERTED)) + .collect(Collectors.toList()); + } + + private OWLObjectPropertyData getAxisProperty(LogicalDefinitionTableRow row) { + return OWLObjectPropertyData.get(new OWLObjectPropertyImpl(IRI.create(row.getPostCoordinationAxis())), ImmutableList.of(), false); + } + + private OWLClassData getValueClassData(LogicalDefinitionTableRow row) { + return OWLClassData.get(new OWLClassImpl(IRI.create(row.getPostCoordinationValue())), ImmutableList.of(), false); + } + + private void initializeSuperClassTableHeader() { + flexTable.setStyleName(style.superClassTable()); + addHeaderCell(config.getAxisLabel(), 0); + addHeaderCell(config.getValueLabel(), 1); + addHeaderCell("", 2); + flexTable.getRowFormatter().addStyleName(0, style.superClassTableHeader()); + + } + + private void addHeaderCell(String headerText, int column) { + Widget headerCell = new Label(headerText); + flexTable.setWidget(0, column, headerCell); + flexTable.getCellFormatter().addStyleName(0, column, style.tableText()); + } + + private void injectTableControls() { + this.flexTable.setWidget(this.tableRows.size()+1, 0, axisDropdown); + this.flexTable.setWidget(this.tableRows.size()+1, 1, valuesDropdown); + } + + private void setControlsHandlers(){ + this.axisDropdown.addChangeHandler((changeEvent) -> { + String selectedPostCoordinationIri = axisDropdown.getSelectedValue(); + config.getChangeHandler().handleChange(selectedPostCoordinationIri, this); + }); + + valuesDropdown.addChangeHandler((changeEvent) -> { + String selectedPostCoordinationIri = axisDropdown.getSelectedValue(); + if(selectedPostCoordinationIri != null && !selectedPostCoordinationIri.isEmpty()){ + Optional existingRow = tableRows.stream() + .filter(row -> selectedPostCoordinationIri.equalsIgnoreCase(row.getPostCoordinationAxis())) + .findFirst(); + if(!existingRow.isPresent() && valuesDropdown.getSelectedValue() != null && !valuesDropdown.getSelectedValue().isEmpty()) { + LogicalDefinitionTableRow row = new LogicalDefinitionTableRow(); + row.setPostCoordinationAxis(axisDropdown.getSelectedValue()); + row.setPostCoordinationAxisLabel(axisDropdown.getSelectedItemText()); + row.setPostCoordinationValue(valuesDropdown.getSelectedValue()); + row.setPostCoordinationValueLabel(valuesDropdown.getSelectedValue()); + this.tableRows.add(row); + addNewRowToTable(row); + } + } + }); + } + + private void addNewRowToTable(LogicalDefinitionTableRow row) { + Widget axisCell = new Label(row.getPostCoordinationAxisLabel()); + flexTable.setWidget(this.tableRows.size(), 0, axisCell); + flexTable.setWidget(this.tableRows.size(), 1, new Label(row.getPostCoordinationValueLabel())); + flexTable.getCellFormatter().addStyleName(this.tableRows.size(), 0, style.tableText()); + flexTable.getCellFormatter().addStyleName(this.tableRows.size(), 1, style.tableText()); + + Label removeCell = new Label(); + removeCell.getElement().setInnerHTML(style.getxSvg()); + removeCell.addClickHandler((click)-> this.removeSuperClassAxis(row.getPostCoordinationAxisLabel(), row.getPostCoordinationAxis(), row.getPostCoordinationValueLabel())); + + this.flexTable.setWidget(this.tableRows.size(), 2, removeCell); + this.flexTable.setWidget(this.tableRows.size()+1, 0, axisDropdown); + this.flexTable.setWidget(this.tableRows.size()+1, 1, valuesDropdown); + + flexTable.getCellFormatter().addStyleName(this.tableRows.size(), 2, style.removeButtonCell()); + flexTable.getRowFormatter().addStyleName(this.tableRows.size(), style.customRowStyle()); + if(this.axisDropdown.getItemCount() > 0) { + this.axisDropdown.setItemSelected(0, true); + } + if(this.valuesDropdown.getItemCount() > 0){ + this.valuesDropdown.setItemSelected(0, true); + } + } + + private void removeSuperClassAxis(String postCoordinationLabel, String postCoordinationAxis, String postCoordinationValue) { + if(!readOnly) { + for(int i = 0; i < flexTable.getRowCount(); i++) { + String existingLabel = flexTable.getText(i, 0); + String existingValue = flexTable.getText(i, 1); + if(existingLabel.equalsIgnoreCase(postCoordinationLabel) && existingValue.equalsIgnoreCase(postCoordinationValue)) { + flexTable.removeRow(i); + } + } + + this.tableRows = this.tableRows.stream() + .filter(r -> !r.getPostCoordinationAxis().equalsIgnoreCase(postCoordinationAxis)) + .collect(Collectors.toList()); + } + } + + static class DropdownElement { + private final String label; + private final String cssClass; + + + DropdownElement(String label, String cssClass) { + this.label = label; + this.cssClass = cssClass; + } + + public String getLabel() { + return label; + } + + public String getCssClass() { + return cssClass; + } + } + +} diff --git a/webprotege-gwt-ui-client/src/main/java/edu/stanford/bmir/protege/web/client/logicaldefinition/LogicalDefinitionTableBuilder.java b/webprotege-gwt-ui-client/src/main/java/edu/stanford/bmir/protege/web/client/logicaldefinition/LogicalDefinitionTableBuilder.java new file mode 100644 index 000000000..37855b052 --- /dev/null +++ b/webprotege-gwt-ui-client/src/main/java/edu/stanford/bmir/protege/web/client/logicaldefinition/LogicalDefinitionTableBuilder.java @@ -0,0 +1,78 @@ +package edu.stanford.bmir.protege.web.client.logicaldefinition; + +import edu.stanford.bmir.protege.web.client.dispatch.DispatchServiceManager; +import edu.stanford.bmir.protege.web.shared.entity.OWLEntityData; +import edu.stanford.bmir.protege.web.shared.postcoordination.PostCoordinationTableAxisLabel; +import edu.stanford.bmir.protege.web.shared.project.ProjectId; + +import java.util.ArrayList; +import java.util.List; + +public class LogicalDefinitionTableBuilder { + + + private final DispatchServiceManager dispatchServiceManager; + + private final ProjectId projectId; + + private List ancestorsList = new ArrayList<>(); + + private List labels; + + private LogicalDefinitionTableWrapperImpl.RemoveTableHandler removeTableHandler; + + private String parentIri; + + public LogicalDefinitionTableBuilder(DispatchServiceManager dispatchServiceManager, ProjectId projectId) { + this.dispatchServiceManager = dispatchServiceManager; + this.projectId = projectId; + } + + + public LogicalDefinitionTableBuilder withAncestorsList(List ancestorsList) { + this.ancestorsList = ancestorsList; + return this; + } + + public LogicalDefinitionTableBuilder withLabels(List labels) { + this.labels = labels; + return this; + } + public LogicalDefinitionTableBuilder withParentIri(String parentIri) { + this.parentIri = parentIri; + return this; + } + + public LogicalDefinitionTableBuilder withRemoveHandler(LogicalDefinitionTableWrapperImpl.RemoveTableHandler removeTableHandler) { + this.removeTableHandler = removeTableHandler; + return this; + } + + public LogicalDefinitionTableWrapper asExistingTable(){ + LogicalDefinitionTableWrapper logicalDefinitionTableWrapper = new LogicalDefinitionTableWrapperImpl(dispatchServiceManager, projectId); + + logicalDefinitionTableWrapper.setAncestorList(this.ancestorsList); + logicalDefinitionTableWrapper.setLabels(this.labels); + logicalDefinitionTableWrapper.setParentIRI(this.parentIri); + logicalDefinitionTableWrapper.enableReadOnly(); + logicalDefinitionTableWrapper.asExistingTable(); + logicalDefinitionTableWrapper.setRemoveTableHandleWrapper(this.removeTableHandler); + + return logicalDefinitionTableWrapper; + } + + public LogicalDefinitionTableWrapper asNewTable() { + LogicalDefinitionTableWrapper logicalDefinitionTableWrapper = new LogicalDefinitionTableWrapperImpl(dispatchServiceManager, projectId); + + logicalDefinitionTableWrapper.setAncestorList(this.ancestorsList); + logicalDefinitionTableWrapper.setLabels(this.labels); + logicalDefinitionTableWrapper.setParentIRI(this.parentIri); + logicalDefinitionTableWrapper.enableEditable(); + logicalDefinitionTableWrapper.asNewTable(); + logicalDefinitionTableWrapper.setRemoveTableHandleWrapper(this.removeTableHandler); + + + + return logicalDefinitionTableWrapper; + } +} diff --git a/webprotege-gwt-ui-client/src/main/java/edu/stanford/bmir/protege/web/client/logicaldefinition/LogicalDefinitionTableConfig.java b/webprotege-gwt-ui-client/src/main/java/edu/stanford/bmir/protege/web/client/logicaldefinition/LogicalDefinitionTableConfig.java new file mode 100644 index 000000000..a82e5b050 --- /dev/null +++ b/webprotege-gwt-ui-client/src/main/java/edu/stanford/bmir/protege/web/client/logicaldefinition/LogicalDefinitionTableConfig.java @@ -0,0 +1,30 @@ +package edu.stanford.bmir.protege.web.client.logicaldefinition; + +public class LogicalDefinitionTableConfig { + private final String axisLabel; + private final String valueLabel; + private final ValueChangeHandler changeHandler; + + public LogicalDefinitionTableConfig(String axisLabel, String valueLabel, ValueChangeHandler changeHandler) { + this.axisLabel = axisLabel; + this.valueLabel = valueLabel; + this.changeHandler = changeHandler; + } + + public String getAxisLabel() { + return axisLabel; + } + + public String getValueLabel() { + return valueLabel; + } + + public ValueChangeHandler getChangeHandler() { + return changeHandler; + } + + public interface ValueChangeHandler { + void handleChange(String postCoordinationAxis, LogicalDefinitionTable table); + } + +} diff --git a/webprotege-gwt-ui-client/src/main/java/edu/stanford/bmir/protege/web/client/logicaldefinition/LogicalDefinitionTableRow.java b/webprotege-gwt-ui-client/src/main/java/edu/stanford/bmir/protege/web/client/logicaldefinition/LogicalDefinitionTableRow.java new file mode 100644 index 000000000..4a3142eb8 --- /dev/null +++ b/webprotege-gwt-ui-client/src/main/java/edu/stanford/bmir/protege/web/client/logicaldefinition/LogicalDefinitionTableRow.java @@ -0,0 +1,54 @@ +package edu.stanford.bmir.protege.web.client.logicaldefinition; + +import edu.stanford.bmir.protege.web.shared.frame.PropertyClassValue; + +public class LogicalDefinitionTableRow { + + private String postCoordinationAxis; + private String postCoordinationAxisLabel; + private String postCoordinationValue; + + private String postCoordinationValueLabel; + + public LogicalDefinitionTableRow(){ + + } + public LogicalDefinitionTableRow(PropertyClassValue propertyClassValue) { + this.setPostCoordinationAxis(propertyClassValue.getProperty().getEntity().getIRI().toString()); + this.setPostCoordinationAxisLabel(propertyClassValue.getProperty().getBrowserText()); + this.setPostCoordinationValue(propertyClassValue.getValue().getIri().toString()); + this.setPostCoordinationValueLabel(propertyClassValue.getValue().getBrowserText()); + } + + public String getPostCoordinationAxis() { + return postCoordinationAxis; + } + + public void setPostCoordinationAxis(String postCoordinationAxis) { + this.postCoordinationAxis = postCoordinationAxis; + } + + public String getPostCoordinationAxisLabel() { + return postCoordinationAxisLabel; + } + + public void setPostCoordinationAxisLabel(String postCoordinationAxisLabel) { + this.postCoordinationAxisLabel = postCoordinationAxisLabel; + } + + public String getPostCoordinationValue() { + return postCoordinationValue; + } + + public void setPostCoordinationValue(String postCoordinationValue) { + this.postCoordinationValue = postCoordinationValue; + } + + public String getPostCoordinationValueLabel() { + return postCoordinationValueLabel; + } + + public void setPostCoordinationValueLabel(String postCoordinationValueLabel) { + this.postCoordinationValueLabel = postCoordinationValueLabel; + } +} diff --git a/webprotege-gwt-ui-client/src/main/java/edu/stanford/bmir/protege/web/client/logicaldefinition/LogicalDefinitionTableWrapper.java b/webprotege-gwt-ui-client/src/main/java/edu/stanford/bmir/protege/web/client/logicaldefinition/LogicalDefinitionTableWrapper.java new file mode 100644 index 000000000..7eb78b5db --- /dev/null +++ b/webprotege-gwt-ui-client/src/main/java/edu/stanford/bmir/protege/web/client/logicaldefinition/LogicalDefinitionTableWrapper.java @@ -0,0 +1,36 @@ +package edu.stanford.bmir.protege.web.client.logicaldefinition; + +import com.google.gwt.user.client.ui.AcceptsOneWidget; +import com.google.gwt.user.client.ui.IsWidget; +import edu.stanford.bmir.protege.web.shared.HasDispose; +import edu.stanford.bmir.protege.web.shared.entity.OWLEntityData; +import edu.stanford.bmir.protege.web.shared.logicaldefinition.LogicalDefinition; +import edu.stanford.bmir.protege.web.shared.postcoordination.PostCoordinationTableAxisLabel; +import org.semanticweb.owlapi.model.OWLEntity; + +import java.util.List; + +public interface LogicalDefinitionTableWrapper extends AcceptsOneWidget, IsWidget, HasDispose { + + void setEntity(OWLEntity owlEntity); + + void setAncestorList(List ancestorsList); + + void setLabels(List labels); + + void addExistingRows(List rows); + + void setParentIRI(String parentIRI); + + void enableReadOnly(); + + void enableEditable(); + + void asExistingTable(); + + void asNewTable(); + + void setRemoveTableHandleWrapper(LogicalDefinitionTableWrapperImpl.RemoveTableHandler removeTableHandler); + + LogicalDefinition getLogicalDefinition(); +} diff --git a/webprotege-gwt-ui-client/src/main/java/edu/stanford/bmir/protege/web/client/logicaldefinition/LogicalDefinitionTableWrapperImpl.java b/webprotege-gwt-ui-client/src/main/java/edu/stanford/bmir/protege/web/client/logicaldefinition/LogicalDefinitionTableWrapperImpl.java new file mode 100644 index 000000000..87a1ba761 --- /dev/null +++ b/webprotege-gwt-ui-client/src/main/java/edu/stanford/bmir/protege/web/client/logicaldefinition/LogicalDefinitionTableWrapperImpl.java @@ -0,0 +1,219 @@ +package edu.stanford.bmir.protege.web.client.logicaldefinition; + +import com.google.common.collect.ImmutableMap; +import com.google.gwt.core.client.GWT; +import com.google.gwt.uibinder.client.UiBinder; +import com.google.gwt.uibinder.client.UiField; +import com.google.gwt.user.client.ui.*; +import edu.stanford.bmir.protege.web.client.dispatch.DispatchServiceManager; +import edu.stanford.bmir.protege.web.shared.entity.OWLClassData; +import edu.stanford.bmir.protege.web.shared.entity.OWLEntityData; +import edu.stanford.bmir.protege.web.shared.logicaldefinition.LogicalDefinition; +import edu.stanford.bmir.protege.web.shared.postcoordination.*; +import edu.stanford.bmir.protege.web.shared.project.ProjectId; +import org.semanticweb.owlapi.model.OWLEntity; + +import java.util.*; +import java.util.logging.Logger; +import java.util.stream.Collectors; + +public class LogicalDefinitionTableWrapperImpl extends Composite implements LogicalDefinitionTableWrapper { + Logger logger = java.util.logging.Logger.getLogger("LogicalDefinitionTableWrapperImpl"); + + @UiField + HTMLPanel paneContainer; + + @UiField + HTMLPanel ancestorWrapper; + + @UiField + ListBox ancestorDropdown; + + @UiField + Button deleteTableWrapper; + + + private final DispatchServiceManager dispatchServiceManager; + + private LogicalDefinitionResourceBundle.LogicalDefinitionCss style; + + private final ProjectId projectId; + + private List labels; + + private WhoficCustomScalesValues superclassScalesValue; + private WhoficEntityPostCoordinationSpecification superclassSpecification; + private List axisToGenericScales = new ArrayList<>(); + private static final LogicalDefinitionTableWrapperImpl.LogicalDefinitionTableWrapperImplUiBinder ourUiBinder = + GWT.create(LogicalDefinitionTableWrapperImpl.LogicalDefinitionTableWrapperImplUiBinder.class); + + private List ancestorsList; + + + private final LogicalDefinitionTable superClassTable = new LogicalDefinitionTable(new LogicalDefinitionTableConfig("Logical Definition Axis", + "Value", + this::initializeTable)); + private String parentIri; + + + public LogicalDefinitionTableWrapperImpl(DispatchServiceManager dispatchServiceManager, + ProjectId projectId) { + this.dispatchServiceManager = dispatchServiceManager; + this.projectId = projectId; + initWidget(ourUiBinder.createAndBindUi(this)); + LogicalDefinitionResourceBundle.INSTANCE.style().ensureInjected(); + style = LogicalDefinitionResourceBundle.INSTANCE.style(); + + this.ancestorDropdown.addChangeHandler((changeEvent) -> { + fetchDropdownData(ancestorDropdown.getSelectedValue()); + }); + + dispatchServiceManager.execute(GetPostcoordinationAxisToGenericScaleAction.create(), result -> { + this.axisToGenericScales = result.getPostcoordinationAxisToGenericScales(); + }); + paneContainer.add(superClassTable); + ancestorDropdown.setStyleName(style.logicalDefinitionDropdown()); + this.deleteTableWrapper.getElement().setInnerHTML(style.getDeleteSvg()); + this.deleteTableWrapper.addStyleName(style.removeButtonCell()); + + } + + @Override + public void setWidget(IsWidget w) { + + } + + @Override + public void dispose() { + + } + + private void fetchDropdownData(String iri) { + dispatchServiceManager.execute(GetEntityCustomScalesAction.create(iri, projectId), postcoordination -> { + this.superclassScalesValue = postcoordination.getWhoficCustomScaleValues(); + }); + dispatchServiceManager.execute(GetEntityPostCoordinationAction.create(iri, projectId), postcoordination -> { + + this.superclassSpecification = postcoordination.getPostCoordinationSpecification(); + populateAvailableAxisValues(); + }); + } + + private void populateAvailableAxisValues() { + Optional mmsSpec = this.superclassSpecification.getPostCoordinationSpecifications() + .stream().filter(spec -> spec.getLinearizationView().equalsIgnoreCase("http://id.who.int/icd/release/11/mms")) + .findFirst(); + + mmsSpec.ifPresent(postCoordinationSpecification -> superClassTable.setAvailableAxisFromSpec(postCoordinationSpecification, this.labels)); + } + + private void initializeTable(String postCoordinationAxis, LogicalDefinitionTable table) { + List selectedScales = superclassScalesValue.getScaleCustomizations().stream() + .filter(s -> s.getPostcoordinationAxis().equalsIgnoreCase(postCoordinationAxis)) + .flatMap(s -> s.getPostcoordinationScaleValues().stream()) + .collect(Collectors.toList()); + + if(selectedScales.isEmpty()) { + List equivalentRoots = axisToGenericScales.stream() + .filter(axis -> axis.getPostcoordinationAxis().equalsIgnoreCase(postCoordinationAxis)) + .map(PostcoordinationAxisToGenericScale::getGenericPostcoordinationScaleTopClass) + .collect(Collectors.toList()); + selectedScales.addAll(equivalentRoots); + } + + Map map = new HashMap<>(); + for(String availableAxis : selectedScales) { + map.put(availableAxis, availableAxis); + } + + table.setAvailableValues(map); + } + + @Override + public void setEntity(OWLEntity owlEntity) { + + } + + @Override + public void setAncestorList(List ancestorsList) { + this.ancestorsList = ancestorsList; + for(OWLEntityData ancestor: ancestorsList) { + ancestorDropdown.addItem(ancestor.getBrowserText(), ancestor.getIri().toString()); + } + } + + @Override + public void setLabels(List labels) { + this.labels = labels; + } + + @Override + public void addExistingRows(List rows) { + this.superClassTable.addExistingRows(rows); + } + + @Override + public void setParentIRI(String parentIRI) { + this.parentIri = parentIRI; + } + + @Override + public void enableReadOnly() { + this.ancestorDropdown.setEnabled(false); + this.superClassTable.setReadOnly(); + } + + @Override + public void enableEditable() { + this.ancestorDropdown.setEnabled(true); + this.superClassTable.setEditable(); + } + + @Override + public void asExistingTable() { + ancestorWrapper.clear(); + + for(OWLEntityData ancestor : ancestorsList) { + if(ancestor.getIri().toString().equalsIgnoreCase(this.parentIri)) { + Label label = new Label(); + label.addStyleName(style.superClassName()); + label.setText(ancestor.getBrowserText()); + this.ancestorWrapper.add(label); + fetchDropdownData(ancestor.getIri().toString()); + return; + } + } + } + + @Override + public void asNewTable() { + if(ancestorDropdown.getItemCount() > 1) { + ancestorDropdown.setItemSelected(1, true); + fetchDropdownData(ancestorDropdown.getSelectedValue()); + } + } + + @Override + public void setRemoveTableHandleWrapper(RemoveTableHandler removeTableHandler) { + this.deleteTableWrapper.addClickHandler(event -> removeTableHandler.removeTable(this)); + } + + @Override + public LogicalDefinition getLogicalDefinition() { + String superClassIri = parentIri != null ? parentIri : ancestorDropdown.getSelectedValue(); + OWLEntityData selectedAncestor = ancestorsList.stream() + .filter(ancestor -> ancestor.getIri().toString().equalsIgnoreCase(superClassIri)) + .findFirst() + .orElseThrow(() -> new RuntimeException("The selected value is not a known ancestor")); + + return LogicalDefinition.create(OWLClassData.get(selectedAncestor.asEntity().get().asOWLClass(), + ImmutableMap.of()),this.superClassTable.getValues()); + } + + interface LogicalDefinitionTableWrapperImplUiBinder extends UiBinder { + + } + public interface RemoveTableHandler { + void removeTable(LogicalDefinitionTableWrapper wrapper); + } +} diff --git a/webprotege-gwt-ui-client/src/main/java/edu/stanford/bmir/protege/web/client/logicaldefinition/LogicalDefinitionTableWrapperImpl.ui.xml b/webprotege-gwt-ui-client/src/main/java/edu/stanford/bmir/protege/web/client/logicaldefinition/LogicalDefinitionTableWrapperImpl.ui.xml new file mode 100644 index 000000000..bda1bd9be --- /dev/null +++ b/webprotege-gwt-ui-client/src/main/java/edu/stanford/bmir/protege/web/client/logicaldefinition/LogicalDefinitionTableWrapperImpl.ui.xml @@ -0,0 +1,48 @@ + + + .card { + margin: 15px; + border-bottom: 2px solid #f2f2f2; + padding-bottom: 15px; + } + .rowWrapper { + display: flex; + justify-content: space-between; + align-items: center; + } + .superclassWrapper { + display: flex; + width: 40%; + } + .label { + font-size: 13px; + white-space: nowrap; + margin-right: 3vw; + text-align: center; + align-content: center; + } + + + + +
+
+
+ Logical definition superclass : +
+ + + + +
+ + + + +
+ +
+ +
\ No newline at end of file diff --git a/webprotege-gwt-ui-client/src/main/java/edu/stanford/bmir/protege/web/resources/WebProtegeClientBundle.java b/webprotege-gwt-ui-client/src/main/java/edu/stanford/bmir/protege/web/resources/WebProtegeClientBundle.java index 1f884fcdc..1272a1ab9 100644 --- a/webprotege-gwt-ui-client/src/main/java/edu/stanford/bmir/protege/web/resources/WebProtegeClientBundle.java +++ b/webprotege-gwt-ui-client/src/main/java/edu/stanford/bmir/protege/web/resources/WebProtegeClientBundle.java @@ -23,6 +23,10 @@ public interface WebProtegeClientBundle extends ClientBundle { @DataResource.MimeType("image/svg+xml") DataResource busy(); + @Source("no_data_found.svg") + @DataResource.MimeType("image/svg+xml") + DataResource noDataFound(); + @Source("help.svg") @DataResource.MimeType("image/svg+xml") DataResource svgHelpIcon(); diff --git a/webprotege-gwt-ui-client/src/main/java/edu/stanford/bmir/protege/web/resources/no_data_found.svg b/webprotege-gwt-ui-client/src/main/java/edu/stanford/bmir/protege/web/resources/no_data_found.svg new file mode 100644 index 000000000..d8cf598c5 --- /dev/null +++ b/webprotege-gwt-ui-client/src/main/java/edu/stanford/bmir/protege/web/resources/no_data_found.svg @@ -0,0 +1,304 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + NO DATA + + diff --git a/webprotege-gwt-ui-shared/src/main/java/edu/stanford/bmir/protege/web/shared/dispatch/Action.java b/webprotege-gwt-ui-shared/src/main/java/edu/stanford/bmir/protege/web/shared/dispatch/Action.java index 3e310a5d2..227c06cfb 100644 --- a/webprotege-gwt-ui-shared/src/main/java/edu/stanford/bmir/protege/web/shared/dispatch/Action.java +++ b/webprotege-gwt-ui-shared/src/main/java/edu/stanford/bmir/protege/web/shared/dispatch/Action.java @@ -30,6 +30,8 @@ import edu.stanford.bmir.protege.web.shared.itemlist.GetUserIdCompletionsAction; import edu.stanford.bmir.protege.web.shared.lang.GetProjectLangTagsAction; import edu.stanford.bmir.protege.web.shared.linearization.*; +import edu.stanford.bmir.protege.web.shared.logicaldefinition.GetEntityLogicalDefinitionAction; +import edu.stanford.bmir.protege.web.shared.logicaldefinition.UpdateLogicalDefinitionAction; import edu.stanford.bmir.protege.web.shared.mail.GetEmailAddressAction; import edu.stanford.bmir.protege.web.shared.mail.SetEmailAddressAction; import edu.stanford.bmir.protege.web.shared.match.GetMatchingEntitiesAction; @@ -235,7 +237,9 @@ @Type(value = ProcessUploadedLinearizationAction.class), @Type(value = ProcessUploadedPostCoordinationAction.class), @Type(value = GetPostcoordinationAxisToGenericScaleAction.class), - @Type(value = SaveEntityCustomScaleAction.class) + @Type(value = SaveEntityCustomScaleAction.class), + @Type(value = UpdateLogicalDefinitionAction.class), + @Type(value = GetEntityLogicalDefinitionAction.class) }) @JsonTypeInfo(use = JsonTypeInfo.Id.NAME) public interface Action extends IsSerializable { diff --git a/webprotege-gwt-ui-shared/src/main/java/edu/stanford/bmir/protege/web/shared/dispatch/Result.java b/webprotege-gwt-ui-shared/src/main/java/edu/stanford/bmir/protege/web/shared/dispatch/Result.java index b3caca7fe..ea17910d6 100644 --- a/webprotege-gwt-ui-shared/src/main/java/edu/stanford/bmir/protege/web/shared/dispatch/Result.java +++ b/webprotege-gwt-ui-shared/src/main/java/edu/stanford/bmir/protege/web/shared/dispatch/Result.java @@ -65,6 +65,8 @@ import edu.stanford.bmir.protege.web.shared.itemlist.GetUserIdCompletionsResult; import edu.stanford.bmir.protege.web.shared.lang.GetProjectLangTagsResult; import edu.stanford.bmir.protege.web.shared.linearization.*; +import edu.stanford.bmir.protege.web.shared.logicaldefinition.GetEntityLogicalDefinitionResult; +import edu.stanford.bmir.protege.web.shared.logicaldefinition.UpdateLogicalDefinitionResult; import edu.stanford.bmir.protege.web.shared.mail.GetEmailAddressResult; import edu.stanford.bmir.protege.web.shared.mail.SetEmailAddressResult; import edu.stanford.bmir.protege.web.shared.match.GetMatchingEntitiesResult; @@ -307,7 +309,9 @@ @JsonSubTypes.Type(GetProjectChangesForHistoryViewResult.class), @JsonSubTypes.Type(ProcessUploadedLinearizationResult.class), @JsonSubTypes.Type(GetPostcoordinationAxisToGenericScaleResult.class), - @JsonSubTypes.Type(SaveEntityCustomScaleResult.class) + @JsonSubTypes.Type(SaveEntityCustomScaleResult.class), + @JsonSubTypes.Type(GetEntityLogicalDefinitionResult.class), + @JsonSubTypes.Type(UpdateLogicalDefinitionResult.class) }) @JsonTypeInfo(use = JsonTypeInfo.Id.NAME) public interface Result extends IsSerializable { diff --git a/webprotege-gwt-ui-shared/src/main/java/edu/stanford/bmir/protege/web/shared/dispatch/RpcWhiteList.java b/webprotege-gwt-ui-shared/src/main/java/edu/stanford/bmir/protege/web/shared/dispatch/RpcWhiteList.java index 93c9afcd0..94baeacf8 100644 --- a/webprotege-gwt-ui-shared/src/main/java/edu/stanford/bmir/protege/web/shared/dispatch/RpcWhiteList.java +++ b/webprotege-gwt-ui-shared/src/main/java/edu/stanford/bmir/protege/web/shared/dispatch/RpcWhiteList.java @@ -29,6 +29,10 @@ import edu.stanford.bmir.protege.web.shared.itemlist.*; import edu.stanford.bmir.protege.web.shared.lang.*; import edu.stanford.bmir.protege.web.shared.linearization.*; +import edu.stanford.bmir.protege.web.shared.logicaldefinition.GetEntityLogicalDefinitionResult; +import edu.stanford.bmir.protege.web.shared.logicaldefinition.LogicalConditions; +import edu.stanford.bmir.protege.web.shared.logicaldefinition.LogicalDefinition; +import edu.stanford.bmir.protege.web.shared.logicaldefinition.UpdateLogicalDefinitionResult; import edu.stanford.bmir.protege.web.shared.mail.*; import edu.stanford.bmir.protege.web.shared.match.*; import edu.stanford.bmir.protege.web.shared.match.criteria.*; @@ -1028,6 +1032,12 @@ public class RpcWhiteList implements IsSerializable, Action, Result { PostCoordinationCustomScales _PostCoordinationCustomScales; + UpdateLogicalDefinitionResult _SaveLogicalDefinitionResult; + + LogicalDefinition _LogicalDefinition; + + LogicalConditions _LogicalConditions; + GetEntityLogicalDefinitionResult _GetEntityLogicalDefinitionResult; public RpcWhiteList() { } diff --git a/webprotege-gwt-ui-shared/src/main/java/edu/stanford/bmir/protege/web/shared/logicaldefinition/GetEntityLogicalDefinitionAction.java b/webprotege-gwt-ui-shared/src/main/java/edu/stanford/bmir/protege/web/shared/logicaldefinition/GetEntityLogicalDefinitionAction.java new file mode 100644 index 000000000..018e589bf --- /dev/null +++ b/webprotege-gwt-ui-shared/src/main/java/edu/stanford/bmir/protege/web/shared/logicaldefinition/GetEntityLogicalDefinitionAction.java @@ -0,0 +1,37 @@ +package edu.stanford.bmir.protege.web.shared.logicaldefinition; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.google.auto.value.AutoValue; +import com.google.common.annotations.GwtCompatible; +import edu.stanford.bmir.protege.web.shared.dispatch.Action; +import edu.stanford.bmir.protege.web.shared.project.ProjectId; +import org.semanticweb.owlapi.model.OWLClass; + +import static edu.stanford.bmir.protege.web.shared.logicaldefinition.GetEntityLogicalDefinitionAction.CHANNEL; + + +@AutoValue +@GwtCompatible(serializable = true) +@JsonTypeName(CHANNEL) +public abstract class GetEntityLogicalDefinitionAction implements Action { + + public static final String CHANNEL = "icatx.logicalDefinitions.GetLogicalDefinitions"; + + + + @JsonCreator + public static GetEntityLogicalDefinitionAction create(@JsonProperty("projectId") ProjectId projectId, + @JsonProperty("subject") OWLClass subject) { + return new AutoValue_GetEntityLogicalDefinitionAction(projectId, subject); + } + + @JsonProperty("projectId") + public abstract ProjectId getProjectId(); + + @JsonProperty("subject") + public abstract OWLClass getSubject(); + + +} diff --git a/webprotege-gwt-ui-shared/src/main/java/edu/stanford/bmir/protege/web/shared/logicaldefinition/GetEntityLogicalDefinitionResult.java b/webprotege-gwt-ui-shared/src/main/java/edu/stanford/bmir/protege/web/shared/logicaldefinition/GetEntityLogicalDefinitionResult.java new file mode 100644 index 000000000..f7d6b289b --- /dev/null +++ b/webprotege-gwt-ui-shared/src/main/java/edu/stanford/bmir/protege/web/shared/logicaldefinition/GetEntityLogicalDefinitionResult.java @@ -0,0 +1,37 @@ +package edu.stanford.bmir.protege.web.shared.logicaldefinition; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.google.auto.value.AutoValue; +import com.google.common.annotations.GwtCompatible; +import edu.stanford.bmir.protege.web.shared.dispatch.Result; +import edu.stanford.bmir.protege.web.shared.frame.PropertyClassValue; + +import java.util.List; + +import static edu.stanford.bmir.protege.web.shared.logicaldefinition.GetEntityLogicalDefinitionAction.CHANNEL; + + +@AutoValue +@GwtCompatible(serializable = true) +@JsonTypeName(CHANNEL) +public abstract class GetEntityLogicalDefinitionResult implements Result { + + + + @JsonCreator + public static GetEntityLogicalDefinitionResult create(@JsonProperty("logicalDefinitions") List logicalDefinitions, + @JsonProperty("necessaryConditions") List necessaryConditions) { + return new AutoValue_GetEntityLogicalDefinitionResult(logicalDefinitions, necessaryConditions); + } + + + + @JsonProperty("logicalDefinitions") + public abstract List getLogicalDefinitions(); + + @JsonProperty("necessaryConditions") + public abstract List getNecessaryConditions(); + +} diff --git a/webprotege-gwt-ui-shared/src/main/java/edu/stanford/bmir/protege/web/shared/logicaldefinition/LogicalConditions.java b/webprotege-gwt-ui-shared/src/main/java/edu/stanford/bmir/protege/web/shared/logicaldefinition/LogicalConditions.java new file mode 100644 index 000000000..087f5b53c --- /dev/null +++ b/webprotege-gwt-ui-shared/src/main/java/edu/stanford/bmir/protege/web/shared/logicaldefinition/LogicalConditions.java @@ -0,0 +1,29 @@ +package edu.stanford.bmir.protege.web.shared.logicaldefinition; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.google.auto.value.AutoValue; +import com.google.common.annotations.GwtCompatible; +import com.google.gwt.user.client.rpc.IsSerializable; +import edu.stanford.bmir.protege.web.shared.frame.PropertyClassValue; + +import java.io.Serializable; +import java.util.List; + + +@AutoValue +@GwtCompatible(serializable = true) +public abstract class LogicalConditions implements Serializable, IsSerializable { + + + @JsonCreator + public static LogicalConditions create(@JsonProperty("logicalDefinitions") List logicalDefinitions, + @JsonProperty("necessaryConditions") List necessaryConditions) { + return new AutoValue_LogicalConditions(logicalDefinitions, necessaryConditions); + } + @JsonProperty("logicalDefinitions") + public abstract List getLogicalDefinitions(); + @JsonProperty("necessaryConditions") + public abstract List getNecessaryConditions(); + +} diff --git a/webprotege-gwt-ui-shared/src/main/java/edu/stanford/bmir/protege/web/shared/logicaldefinition/LogicalDefinition.java b/webprotege-gwt-ui-shared/src/main/java/edu/stanford/bmir/protege/web/shared/logicaldefinition/LogicalDefinition.java new file mode 100644 index 000000000..61fb79a36 --- /dev/null +++ b/webprotege-gwt-ui-shared/src/main/java/edu/stanford/bmir/protege/web/shared/logicaldefinition/LogicalDefinition.java @@ -0,0 +1,33 @@ +package edu.stanford.bmir.protege.web.shared.logicaldefinition; + + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.google.auto.value.AutoValue; +import com.google.common.annotations.GwtCompatible; +import com.google.gwt.user.client.rpc.IsSerializable; +import edu.stanford.bmir.protege.web.shared.annotations.GwtSerializationConstructor; +import edu.stanford.bmir.protege.web.shared.entity.OWLClassData; +import edu.stanford.bmir.protege.web.shared.frame.PropertyClassValue; + +import java.io.Serializable; +import java.util.List; + + +@AutoValue +@GwtCompatible(serializable = true) +public abstract class LogicalDefinition implements Serializable, IsSerializable { + + @JsonCreator + public static LogicalDefinition create(@JsonProperty("logicalDefinitionParent") OWLClassData logicalDefinitonParent, + @JsonProperty("axis2filler") List axis2filler) { + return new AutoValue_LogicalDefinition(logicalDefinitonParent, axis2filler); + } + + @JsonProperty("logicalDefinitionParent") + public abstract OWLClassData getLogicalDefinitionParent(); + + @JsonProperty("axis2filler") + public abstract List getAxis2filler(); + +} diff --git a/webprotege-gwt-ui-shared/src/main/java/edu/stanford/bmir/protege/web/shared/logicaldefinition/UpdateLogicalDefinitionAction.java b/webprotege-gwt-ui-shared/src/main/java/edu/stanford/bmir/protege/web/shared/logicaldefinition/UpdateLogicalDefinitionAction.java new file mode 100644 index 000000000..6c4aedc69 --- /dev/null +++ b/webprotege-gwt-ui-shared/src/main/java/edu/stanford/bmir/protege/web/shared/logicaldefinition/UpdateLogicalDefinitionAction.java @@ -0,0 +1,54 @@ +package edu.stanford.bmir.protege.web.shared.logicaldefinition; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.google.auto.value.AutoValue; +import com.google.common.annotations.GwtCompatible; +import edu.stanford.bmir.protege.web.shared.dispatch.Action; +import edu.stanford.bmir.protege.web.shared.perspective.ChangeRequestId; +import edu.stanford.bmir.protege.web.shared.project.ProjectId; +import org.semanticweb.owlapi.model.OWLClass; + +import java.util.List; + +import static edu.stanford.bmir.protege.web.shared.logicaldefinition.UpdateLogicalDefinitionAction.CHANNEL; + + +@AutoValue +@GwtCompatible(serializable = true) +@JsonTypeName(CHANNEL) +public abstract class UpdateLogicalDefinitionAction implements Action { + + public static final String CHANNEL = "icatx.logicalDefinitions.UpdateLogicalDefinition"; + + + @JsonCreator + public static UpdateLogicalDefinitionAction create( @JsonProperty("changeRequestId") ChangeRequestId changeRequestId, + @JsonProperty("projectId") ProjectId projectId, + @JsonProperty("subject") OWLClass subject, + @JsonProperty("pristineLogicalConditions") LogicalConditions pristineLogicalConditions, + @JsonProperty("changedLogicalConditions") LogicalConditions changedLogicalConditions, + @JsonProperty("commitMessage") String commitMessage) { + return new AutoValue_UpdateLogicalDefinitionAction(changeRequestId, + projectId, + subject, + pristineLogicalConditions, + changedLogicalConditions, + commitMessage); + + } + @JsonProperty("changeRequestId") + public abstract ChangeRequestId getChangeRequestId(); + @JsonProperty("projectId") + public abstract ProjectId projectId(); + @JsonProperty("subject") + public abstract OWLClass subject(); + @JsonProperty("pristineLogicalConditions") + public abstract LogicalConditions pristineLogicalConditions(); + @JsonProperty("changedLogicalConditions") + public abstract LogicalConditions changedLogicalConditions(); + @JsonProperty("commitMessage") + public abstract String commitMessage(); + +} diff --git a/webprotege-gwt-ui-shared/src/main/java/edu/stanford/bmir/protege/web/shared/logicaldefinition/UpdateLogicalDefinitionResult.java b/webprotege-gwt-ui-shared/src/main/java/edu/stanford/bmir/protege/web/shared/logicaldefinition/UpdateLogicalDefinitionResult.java new file mode 100644 index 000000000..3a28943ef --- /dev/null +++ b/webprotege-gwt-ui-shared/src/main/java/edu/stanford/bmir/protege/web/shared/logicaldefinition/UpdateLogicalDefinitionResult.java @@ -0,0 +1,22 @@ +package edu.stanford.bmir.protege.web.shared.logicaldefinition; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.google.auto.value.AutoValue; +import com.google.common.annotations.GwtCompatible; +import edu.stanford.bmir.protege.web.shared.dispatch.Result; + +import static edu.stanford.bmir.protege.web.shared.logicaldefinition.UpdateLogicalDefinitionAction.CHANNEL; + + +@AutoValue +@GwtCompatible(serializable = true) +@JsonTypeName(CHANNEL) +public abstract class UpdateLogicalDefinitionResult implements Result { + + + @JsonCreator + public static UpdateLogicalDefinitionResult create(){ + return new AutoValue_UpdateLogicalDefinitionResult(); + } +} diff --git a/webprotege-gwt-ui-shared/src/main/java/edu/stanford/bmir/protege/web/shared/postcoordination/PostCoordinationSpecification.java b/webprotege-gwt-ui-shared/src/main/java/edu/stanford/bmir/protege/web/shared/postcoordination/PostCoordinationSpecification.java index 1b05e1397..e68fa24a1 100644 --- a/webprotege-gwt-ui-shared/src/main/java/edu/stanford/bmir/protege/web/shared/postcoordination/PostCoordinationSpecification.java +++ b/webprotege-gwt-ui-shared/src/main/java/edu/stanford/bmir/protege/web/shared/postcoordination/PostCoordinationSpecification.java @@ -58,4 +58,16 @@ public List getNotAllowedAxes() { public List getRequiredAxes() { return requiredAxes; } + + + @Override + public String toString() { + return "PostCoordinationSpecification{" + + "linearizationView='" + linearizationView + '\'' + + ", allowedAxes=" + allowedAxes + + ", defaultAxes=" + defaultAxes + + ", notAllowedAxes=" + notAllowedAxes + + ", requiredAxes=" + requiredAxes + + '}'; + } } diff --git a/webprotege-gwt-ui-shared/src/main/java/edu/stanford/bmir/protege/web/shared/postcoordination/WhoficEntityPostCoordinationSpecification.java b/webprotege-gwt-ui-shared/src/main/java/edu/stanford/bmir/protege/web/shared/postcoordination/WhoficEntityPostCoordinationSpecification.java index 4264270e8..4913b8eac 100644 --- a/webprotege-gwt-ui-shared/src/main/java/edu/stanford/bmir/protege/web/shared/postcoordination/WhoficEntityPostCoordinationSpecification.java +++ b/webprotege-gwt-ui-shared/src/main/java/edu/stanford/bmir/protege/web/shared/postcoordination/WhoficEntityPostCoordinationSpecification.java @@ -43,4 +43,12 @@ public String getEntityType() { return entityType; } + @Override + public String toString() { + return "WhoficEntityPostCoordinationSpecification{" + + "whoficEntityIri='" + whoficEntityIri + '\'' + + ", entityType='" + entityType + '\'' + + ", postcoordinationSpecifications=" + postcoordinationSpecifications + + '}'; + } }