Skip to content

Commit

Permalink
Merge branch 'master-who' of https://github.com/protegeproject/webpro…
Browse files Browse the repository at this point in the history
…tege-gwt-ui into Support_hierarchy_change_operations_#8

� Conflicts:
�	webprotege-gwt-ui-client/src/main/java/edu/stanford/bmir/protege/web/client/inject/ClientProjectModule.java
  • Loading branch information
soimugeo committed Jun 3, 2024
2 parents 19e8358 + 4479ac1 commit 57f5149
Show file tree
Hide file tree
Showing 47 changed files with 30,063 additions and 129 deletions.
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<dagger.version>2.20</dagger.version>
<owlapi.version>4.5.13</owlapi.version>
<widgetmap.version>4.0.1</widgetmap.version>
<graphtree.version>1.2.0</graphtree.version>
<graphtree.version>1.2.2</graphtree.version>
<autovalue.version>1.7.1</autovalue.version>
<jackson.version>2.13.0</jackson.version>
<commons.io.version>2.7</commons.io.version>
Expand All @@ -26,7 +26,7 @@
<build.timestamp>${maven.build.timestamp}</build.timestamp>
<maven.build.timestamp.format>yyyyMMdd</maven.build.timestamp.format>
<auto-factory.version>1.0-beta7</auto-factory.version>
<junit.version>4.12</junit.version>
<junit.version>4.13.1</junit.version>
<commonmark.version>0.11.0</commonmark.version>
</properties>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -820,6 +820,10 @@ public interface Messages extends com.google.gwt.i18n.client.Messages {
@Key("search")
String search();

@DefaultMessage("Search Icd")
@Key("searchIcd")
String searchIcd();


@DefaultMessage("Search for Class")
@Key("search.class")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import javax.annotation.Nonnull;
import javax.inject.Inject;
import java.util.Optional;
import java.util.logging.Logger;

import static com.google.common.base.Preconditions.checkNotNull;

Expand All @@ -30,23 +31,31 @@ public class CreateEntityPresenter {
@Nonnull
private final DefaultCreateEntitiesPresenter defaultCreateEntitiesPresenter;

@Nonnull
private final WhoCreateClassPresenter whoCreateClassPresenter;

@Nonnull
private final CreateEntityFormPresenter createEntityFormPresenter;

private final static Logger logger = Logger.getLogger(CreateEntityPresenter.class.getName());


@Inject
public CreateEntityPresenter(@Nonnull DispatchServiceManager dispatch,
@Nonnull ProjectId projectId,
@Nonnull DefaultCreateEntitiesPresenter defaultCreateEntitiesPresenter,
@Nonnull CreateEntityFormPresenter createEntityFormPresenter) {
@Nonnull WhoCreateClassPresenter whoCreateClassPresenter, @Nonnull CreateEntityFormPresenter createEntityFormPresenter) {
this.dispatch = checkNotNull(dispatch);
this.projectId = checkNotNull(projectId);
this.defaultCreateEntitiesPresenter = checkNotNull(defaultCreateEntitiesPresenter);
this.whoCreateClassPresenter = checkNotNull(whoCreateClassPresenter);
this.createEntityFormPresenter = checkNotNull(createEntityFormPresenter);
}

public void createEntities(@Nonnull EntityType<?> entityType,
@Nonnull Optional<? extends OWLEntity> parentEntity,
@Nonnull EntitiesCreatedHandler entitiesCreatedHandler) {

parentEntity.ifPresent(owlEntity -> dispatch.execute(GetEntityCreationFormsAction.create(projectId,
owlEntity,
entityType), result -> {
Expand All @@ -63,17 +72,35 @@ private void handleEntityCreationFormsResult(@Nonnull EntityType<?> entityType,
@Nonnull Optional<? extends OWLEntity> parentEntity,
@Nonnull EntitiesCreatedHandler entitiesCreatedHandler,
@Nonnull ImmutableList<FormDescriptorDto> createEntityForms) {
if (createEntityForms.isEmpty()) {
defaultCreateEntitiesPresenter.createEntities(entityType,
parentEntity,
entitiesCreatedHandler);
}
else {

if (isImmutableListNotEmpty(createEntityForms)) {

createEntityFormPresenter.createEntities(entityType,
parentEntity,
entitiesCreatedHandler,
createEntityForms);
parentEntity,
entitiesCreatedHandler,
createEntityForms);

return;
}
if(isEntityTypeClass(entityType)){
whoCreateClassPresenter.createEntities(entityType,
parentEntity,
entitiesCreatedHandler);

return;
}

defaultCreateEntitiesPresenter.createEntities(entityType,
parentEntity,
entitiesCreatedHandler);
}

private <T> boolean isImmutableListNotEmpty(ImmutableList<T> listToCheck){
return !listToCheck.isEmpty();
}

private boolean isEntityTypeClass(EntityType entityType){
return entityType.equals(EntityType.CLASS);
}

public interface EntitiesCreatedHandler {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package edu.stanford.bmir.protege.web.client.entity;

import com.google.gwt.user.client.ui.AcceptsOneWidget;
import com.google.gwt.user.client.ui.IsWidget;
import edu.stanford.bmir.protege.web.client.progress.HasBusy;

public interface DuplicateEntitiesView extends HasBusy, IsWidget {


AcceptsOneWidget getDuplicateResultsContainer();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package edu.stanford.bmir.protege.web.client.entity;

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.AcceptsOneWidget;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.HTMLPanel;
import com.google.gwt.user.client.ui.SimplePanel;
import edu.stanford.bmir.protege.web.client.progress.BusyView;

import javax.inject.Inject;

public class DuplicateEntitiesViewImpl extends Composite implements DuplicateEntitiesView {

@UiField
BusyView busyView;

@UiField
public SimplePanel duplicateResultsContainer;

private static DuplicateEntitiesViewImpl.DuplicateEntitiesViewImplUiBinder ourUiBinder = GWT.create(DuplicateEntitiesViewImpl.DuplicateEntitiesViewImplUiBinder.class);
interface DuplicateEntitiesViewImplUiBinder extends UiBinder<HTMLPanel, DuplicateEntitiesViewImpl> {

}



@Inject
public DuplicateEntitiesViewImpl() {
initWidget(ourUiBinder.createAndBindUi(this));
}


@Override
public void setBusy(boolean busy) {
this.busyView.setVisible(busy);
}


@Override
public AcceptsOneWidget getDuplicateResultsContainer(){
return duplicateResultsContainer;
}


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<ui:UiBinder xmlns:ui='urn:ui:com.google.gwt.uibinder'
xmlns:g='urn:import:com.google.gwt.user.client.ui'
xmlns:progress="urn:import:edu.stanford.bmir.protege.web.client.progress"
>
<ui:with field="msg" type="edu.stanford.bmir.protege.web.client.Messages"/>
<ui:with field="wp" type="edu.stanford.bmir.protege.web.resources.WebProtegeClientBundle"/>
<ui:style>
.main {
display: flex;
flex-direction: column;
align-items: stretch;
}
.main strong {
background-color: #ffea8b;
color: #000;
}
.busyView {
width: 100%;
height: 100%;
}
</ui:style>

<g:HTMLPanel addStyleNames="{style.main} {wp.style.form}">
<progress:BusyViewImpl ui:field="busyView" visible="false" addStyleNames="{style.busyView}"/>
<g:Label text="Possible duplicates" addStyleNames="{wp.style.formLabel}"/>
<g:SimplePanel ui:field="duplicateResultsContainer"/>
</g:HTMLPanel>
</ui:UiBinder>
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
package edu.stanford.bmir.protege.web.client.entity;

import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.ui.AcceptsOneWidget;
import edu.stanford.bmir.protege.web.client.dispatch.DispatchServiceManager;
import edu.stanford.bmir.protege.web.client.search.EntitySearchFilterTokenFieldPresenter;
import edu.stanford.bmir.protege.web.client.search.HierarchyPopupElementSelectionHandler;
import edu.stanford.bmir.protege.web.client.search.SearchResultChosenHandler;
import edu.stanford.bmir.protege.web.client.search.SearchResultsListPresenter;
import edu.stanford.bmir.protege.web.shared.entity.OWLEntityData;
import edu.stanford.bmir.protege.web.shared.lang.LangTag;
import edu.stanford.bmir.protege.web.shared.lang.LangTagFilter;
import edu.stanford.bmir.protege.web.shared.pagination.PageRequest;
import edu.stanford.bmir.protege.web.shared.project.ProjectId;
import edu.stanford.bmir.protege.web.shared.search.EntitySearchFilter;
import edu.stanford.bmir.protege.web.shared.search.PerformEntitySearchAction;
import edu.stanford.bmir.protege.web.shared.search.PerformEntitySearchResult;
import org.semanticweb.owlapi.model.EntityType;

import javax.annotation.Nonnull;
import javax.inject.Inject;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Optional;
import java.util.Set;
import java.util.logging.Logger;

import static com.google.common.base.Preconditions.checkNotNull;

public class DuplicateEntityPresenter {


private final ProjectId projectId;

@Nonnull
private final SearchResultsListPresenter searchResultsPresenter;

private final Set<EntityType<?>> entityTypes = new HashSet<>();

private final EntitySearchFilterTokenFieldPresenter entitySearchFilterTokenFieldPresenter;

private final DispatchServiceManager dispatchServiceManager;

private DuplicateEntitiesView view;


private String langTag = "";

private HierarchyPopupElementSelectionHandler hierarchySelectionHandler = selection -> {};

private final static Logger logger = Logger.getLogger(DuplicateEntityPresenter.class.getName());


@Inject
public DuplicateEntityPresenter(@Nonnull ProjectId projectId,
@Nonnull SearchResultsListPresenter searchResultsPresenter,
@Nonnull DuplicateEntitiesView view,
@Nonnull EntitySearchFilterTokenFieldPresenter entitySearchFilterTokenFieldPresenter,
@Nonnull DispatchServiceManager dispatchServiceManager) {
this.projectId = projectId;
this.searchResultsPresenter = searchResultsPresenter;
this.view = view;
this.entitySearchFilterTokenFieldPresenter = checkNotNull(entitySearchFilterTokenFieldPresenter);
this.dispatchServiceManager = dispatchServiceManager;
}

public void start(@Nonnull AcceptsOneWidget container) {
container.setWidget(view);
hideSearchDuplicatesPanel();
searchResultsPresenter.setHierarchySelectionHandler(hierarchySelectionHandler);
searchResultsPresenter.start(this.view.getDuplicateResultsContainer());
}

public void setEntityTypes(EntityType<?>... entityTypes) {
this.entityTypes.clear();
this.entityTypes.addAll(Arrays.asList(entityTypes));
}


private void performDuplicateSearch(String entitiesText) {
if (entitiesText.length() < 1) {
hideSearchDuplicatesPanel();
searchResultsPresenter.clearSearchResults();
return;
}
int pageNumber = searchResultsPresenter.getPageNumber();
ImmutableList<EntitySearchFilter> searchFilters = entitySearchFilterTokenFieldPresenter.getSearchFilters();

dispatchServiceManager.execute(PerformEntitySearchAction.create(projectId,
entitiesText,
entityTypes,
getLangTagFilter(),
searchFilters,
PageRequest.requestPage(pageNumber)),
view,
this::processSearchActionResult);

}

private LangTagFilter getLangTagFilter() {
return LangTagFilter.get(ImmutableSet.of(LangTag.get(this.langTag)));
}

public void handleEntitiesStringChanged(String value) {
this.performDuplicateSearch(value);
}


public void setLangTag(String langTag) {
this.langTag = langTag;
}

private void processSearchActionResult(PerformEntitySearchResult result) {
if(result.getResults() == null || result.getResults().getTotalElements() == 0){
hideSearchDuplicatesPanel();
return;
}

this.view.asWidget().setVisible(true);

this.searchResultsPresenter.displaySearchResult(result.getResults());
}

private void hideSearchDuplicatesPanel(){
this.view.asWidget().setVisible(false);
}

public Optional<OWLEntityData> getSelectedSearchResult() {
return searchResultsPresenter.getSelectedSearchResult();
}

public void setHierarchySelectionHandler(HierarchyPopupElementSelectionHandler handler){
this.hierarchySelectionHandler = handler;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package edu.stanford.bmir.protege.web.client.entity;

public interface EntitiesStringChangedHandler {

void handleEntitiesStringChangedHandler(String value);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package edu.stanford.bmir.protege.web.client.entity;

import com.google.gwt.user.client.ui.AcceptsOneWidget;
import com.google.gwt.user.client.ui.IsWidget;
import edu.stanford.bmir.protege.web.client.library.dlg.HasInitialFocusable;
import org.semanticweb.owlapi.model.EntityType;

import javax.annotation.Nonnull;

/**
* Matthew Horridge Stanford Center for Biomedical Informatics Research 7 Dec 2017
*/
public interface WhoCreateClassDialogView extends IsWidget, HasInitialFocusable {

void setEntityType(@Nonnull EntityType<?> entityType);

@Nonnull
String getText();

@Nonnull
String getReasonForChange();

void clear();

@Nonnull
AcceptsOneWidget getDuplicateEntityResultsContainer();

void setEntitiesStringChangedHandler(EntitiesStringChangedHandler handler);

boolean isReasonForChangeSet();
}
Loading

0 comments on commit 57f5149

Please sign in to comment.