Skip to content

Commit

Permalink
fixed fetching data from BE
Browse files Browse the repository at this point in the history
  • Loading branch information
alexsilaghi committed Oct 14, 2024
1 parent e93dcc2 commit 363ca00
Show file tree
Hide file tree
Showing 9 changed files with 76 additions and 48 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,13 @@
}

.removeButtonCell {
width: 30px;
height: 30px;
}

.removeButtonCell > div {
margin-top: 2px;
margin-bottom: 2px;
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
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.GetEntityLogicalDefinitionAction;
import edu.stanford.bmir.protege.web.shared.logicaldefinition.GetEntityLogicalDefinitionResult;
import edu.stanford.bmir.protege.web.shared.logicaldefinition.LogicalDefinition;
import edu.stanford.bmir.protege.web.shared.logicaldefinition.SaveLogicalDefinitionAction;
import edu.stanford.bmir.protege.web.shared.postcoordination.*;
Expand Down Expand Up @@ -57,9 +58,6 @@ public class LogicalDefinitionPortletViewImpl extends Composite implements Logic

private List<OWLEntityData> ancestorsList = new ArrayList<>();


private OWLClass superClass;

private List<PostCoordinationTableAxisLabel> labels;

private WhoficCustomScalesValues superclassScalesValue;
Expand Down Expand Up @@ -97,14 +95,7 @@ public LogicalDefinitionPortletViewImpl(DispatchServiceManager dispatchServiceMa
});

this.ancestorDropdown.addChangeHandler((changeEvent) -> {
dispatchServiceManager.execute(GetEntityCustomScalesAction.create(ancestorDropdown.getSelectedValue(), projectId), postcoordination -> {
this.superclassScalesValue = postcoordination.getWhoficCustomScaleValues();
});
dispatchServiceManager.execute(GetEntityPostCoordinationAction.create(ancestorDropdown.getSelectedValue(), projectId), postcoordination -> {

this.superclassSpecification = postcoordination.getPostCoordinationSpecification();
populateAvailableAxisValues();
});
fetchDropdownData();
});

switchToReadOnly();
Expand All @@ -114,7 +105,16 @@ public LogicalDefinitionPortletViewImpl(DispatchServiceManager dispatchServiceMa
this.saveValuesButton.addClickHandler(event -> saveValues());
}

private void fetchDropdownData() {
dispatchServiceManager.execute(GetEntityCustomScalesAction.create(ancestorDropdown.getSelectedValue(), projectId), postcoordination -> {
this.superclassScalesValue = postcoordination.getWhoficCustomScaleValues();
});
dispatchServiceManager.execute(GetEntityPostCoordinationAction.create(ancestorDropdown.getSelectedValue(), projectId), postcoordination -> {

this.superclassSpecification = postcoordination.getPostCoordinationSpecification();
populateAvailableAxisValues();
});
}


@Override
Expand All @@ -132,7 +132,6 @@ public void setEntity(OWLEntity owlEntity, ProjectId projectId) {
this.projectId = projectId;
this.superClassTable.resetTable();
this.necessaryConditionsTable.resetTable();
this.superClass = null;
switchToReadOnly();


Expand All @@ -146,36 +145,40 @@ public void setEntity(OWLEntity owlEntity, ProjectId projectId) {
ancestorDropdown.addItem(ancestor.getBrowserText(), ancestor.getIri().toString());
}

dispatchServiceManager.execute(GetPostCoordinationTableConfigurationAction.create("ICD"), config -> {
dispatchServiceManager.execute(GetPostCoordinationTableConfigurationAction.create("ICD"), (config) -> {
this.labels = config.getLabels();
});

});

//populateWithExistingDefinition(owlEntity, projectId);
populateWithExistingDefinition(owlEntity, projectId);

}

private void populateWithExistingDefinition(OWLEntity owlEntity, ProjectId projectId) {
dispatchServiceManager.execute(GetEntityLogicalDefinitionAction.create(projectId, owlEntity.asOWLClass()), getEntityLogicalDefinitionResult -> {
LogicalDefinition definition = getEntityLogicalDefinitionResult.getLogicalDefinitions().get(0);
List<LogicalDefinitionTableRow> superClassTableRows = definition.getAxis2filler().stream()
.map(LogicalDefinitionTableRow::new)
.collect(Collectors.toList());

List<LogicalDefinitionTableRow> necessaryConditionsTableRows = getEntityLogicalDefinitionResult.getNecessaryConditions().stream()
.map(LogicalDefinitionTableRow::new)
.collect(Collectors.toList());

superClassTable.addExistingRows(superClassTableRows);
necessaryConditionsTable.addExistingRows(necessaryConditionsTableRows);
dispatchServiceManager.execute(GetEntityLogicalDefinitionAction.create(projectId, owlEntity.asOWLClass()), (GetEntityLogicalDefinitionResult getEntityLogicalDefinitionResult) -> {
if(getEntityLogicalDefinitionResult.getLogicalDefinitions() != null && !getEntityLogicalDefinitionResult.getLogicalDefinitions().isEmpty()) {
LogicalDefinition definition = getEntityLogicalDefinitionResult.getLogicalDefinitions().get(0);
List<LogicalDefinitionTableRow> superClassTableRows = definition.getAxis2filler().stream()
.map(LogicalDefinitionTableRow::new)
.collect(Collectors.toList());

superClassTable.addExistingRows(superClassTableRows);

for(int i = 0; i < ancestorDropdown.getItemCount(); i++){
if(definition.getLogicalDefinitionParent().getIri().toString().equalsIgnoreCase(ancestorDropdown.getValue(i))) {
ancestorDropdown.setItemSelected(i, true);
}
}
fetchDropdownData();
}
if(getEntityLogicalDefinitionResult.getNecessaryConditions() != null && !getEntityLogicalDefinitionResult.getNecessaryConditions().isEmpty()) {

superClass = definition.getLogicalDefinitionParent().getEntity();
List<LogicalDefinitionTableRow> necessaryConditionsTableRows = getEntityLogicalDefinitionResult.getNecessaryConditions().stream()
.map(LogicalDefinitionTableRow::new)
.collect(Collectors.toList());

for(int i = 0; i < ancestorDropdown.getItemCount(); i++){
if(definition.getLogicalDefinitionParent().getIri().toString().equalsIgnoreCase(ancestorDropdown.getValue(i))) {
ancestorDropdown.setItemSelected(i, true);
}
necessaryConditionsTable.addExistingRows(necessaryConditionsTableRows);
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ public class LogicalDefinitionTable implements IsWidget {
private ListBox valuesDropdown = new ListBox();
private LogicalDefinitionResourceBundle.LogicalDefinitionCss style;

private Map<String, String> availableAxis = new HashMap<>();

private boolean readOnly = true;
private List<LogicalDefinitionTableRow> tableRows = new ArrayList<>();

public LogicalDefinitionTable(LogicalDefinitionTableConfig config) {
Expand Down Expand Up @@ -70,6 +69,7 @@ public void resetTable(){
this.tableRows = new ArrayList<>();
this.valuesDropdown.clear();
this.axisDropdown.clear();
this.readOnly = true;
}

public void setAvailableAxis(Map<String, DropdownElement> specification) {
Expand Down Expand Up @@ -107,11 +107,13 @@ public void setAvailableValues(Map<String, String> availableValues) {
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<LogicalDefinitionTableRow> getRows(){
Expand Down Expand Up @@ -197,17 +199,19 @@ private void addNewRowToTable(LogicalDefinitionTableRow row) {
}

private void removeSuperClassAxis(String postCoordinationLabel, String postCoordinationAxis, String postCoordinationValue) {
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);
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());
this.tableRows = this.tableRows.stream()
.filter(r -> !r.getPostCoordinationAxis().equalsIgnoreCase(postCoordinationAxis))
.collect(Collectors.toList());
}
}

static class DropdownElement {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ public class LogicalDefinitionTableRow {

private String postCoordinationAxis;
private String postCoordinationAxisLabel;


private String postCoordinationValue;

private String postCoordinationValueLabel;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.SaveLogicalDefinitionAction;
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;
Expand Down Expand Up @@ -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 = SaveLogicalDefinitionAction.class),
@Type(value = GetEntityLogicalDefinitionAction.class)
})
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME)
public interface Action<R extends Result> extends IsSerializable {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.SaveLogicalDefinitionResult;
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;
Expand Down Expand Up @@ -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(SaveLogicalDefinitionResult.class)
})
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME)
public interface Result extends IsSerializable {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@
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.LogicalDefinition;
import edu.stanford.bmir.protege.web.shared.logicaldefinition.SaveLogicalDefinitionResult;
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.*;
Expand Down Expand Up @@ -1028,6 +1031,11 @@ public class RpcWhiteList implements IsSerializable, Action, Result {

PostCoordinationCustomScales _PostCoordinationCustomScales;

SaveLogicalDefinitionResult _SaveLogicalDefinitionResult;

LogicalDefinition _LogicalDefinition;

GetEntityLogicalDefinitionResult _GetEntityLogicalDefinitionResult;

public RpcWhiteList() {
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,17 @@

import java.util.List;

import static edu.stanford.bmir.protege.web.shared.logicaldefinition.GetEntityLogicalDefinitionAction.CHANNEL;
import static edu.stanford.bmir.protege.web.shared.logicaldefinition.SaveLogicalDefinitionAction.CHANNEL;


@AutoValue
@GwtCompatible(serializable = true)
@JsonTypeName(CHANNEL)
public abstract class SaveLogicalDefinitionAction implements Action<SaveLogicalDefinitionResult> {

public static final String CHANNEL = "icatx.logicalDefinitions.UpdateLogicalDefinition";


@JsonCreator
public static SaveLogicalDefinitionAction create(@JsonProperty("logicalDefinitions") List<LogicalDefinition> logicalDefinitions,
@JsonProperty("necessaryConditions") List<PropertyClassValue> necessaryConditions) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
import com.google.common.annotations.GwtCompatible;
import edu.stanford.bmir.protege.web.shared.dispatch.Result;

import static edu.stanford.bmir.protege.web.shared.logicaldefinition.GetEntityLogicalDefinitionAction.CHANNEL;
import static edu.stanford.bmir.protege.web.shared.logicaldefinition.SaveLogicalDefinitionAction.CHANNEL;


@AutoValue
@GwtCompatible(serializable = true)
Expand Down

0 comments on commit 363ca00

Please sign in to comment.