Skip to content

Commit

Permalink
Added GetPostCoordinationAxisToGenericScaleAction and made call from …
Browse files Browse the repository at this point in the history
…PostCoordinationPortletPresenter to retrieve the values used for creating the ScaleValueCardPresenters.
  • Loading branch information
soimugeo committed Oct 1, 2024
1 parent d7c9421 commit 43c2a0d
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import javax.annotation.Nonnull;
import javax.inject.Inject;
import java.util.*;
import java.util.logging.Logger;
import java.util.logging.*;
import java.util.stream.Collectors;

@Portlet(id = "portlets.PostCoordination",
Expand Down Expand Up @@ -91,25 +91,30 @@ public void startPortlet(PortletUi portletUi, WebProtegeEventBus eventBus) {

view.setLabels(tableLabelsForAxes);

dispatch.execute(GetPostCoordinationAxisToGenericScaleAction.create(), axisToGenericScaleResult ->
axisToGenericScaleResult.getPostCoordinationAxisToGenericScales()
.forEach(axisToGenericScale ->
genericScale.put(axisToGenericScale.getPostcoordinationAxis(), axisToGenericScale)
)
);


compositeAxisList.addAll(result.getTableConfiguration().getCompositePostCoordinationAxes());

compositeAxisList.forEach(compositeAxis ->
compositeAxis.getSubAxis()
.forEach(subAxis -> {
PostCoordinationTableAxisLabel existingLabel = result.getLabels().stream()
.filter(label -> label.getPostCoordinationAxis().equalsIgnoreCase(subAxis))
.findFirst()
/*
ToDo:
remove the orElseGet() and add back the orElseThrow() when we have proper labels
*/
.orElseGet(() -> new PostCoordinationTableAxisLabel(subAxis, "hardCodedTableName", "hardCodedTableName"));
// .orElseThrow(() -> new RuntimeException("Couldn't find label for " + subAxis));
scaleLabelsForAxes.put(subAxis, existingLabel);
scaleLabelsForAxes.remove(compositeAxis.getPostCoordinationAxis());
}
)
compositeAxis.getSubAxis()
.forEach(subAxis -> {
PostCoordinationTableAxisLabel existingLabel = result.getLabels().stream()
.filter(label -> label.getPostCoordinationAxis().equalsIgnoreCase(subAxis))
.findFirst()
.orElseThrow(() -> {
logger.log(Level.SEVERE, "Couldn't find label for " + subAxis);
return new RuntimeException("Couldn't find label for " + subAxis);
});
scaleLabelsForAxes.put(subAxis, existingLabel);
scaleLabelsForAxes.remove(compositeAxis.getPostCoordinationAxis());
}
)
);


Expand All @@ -125,9 +130,7 @@ remove the orElseGet() and add back the orElseThrow() when we have proper labels
});
});

view.setEditButtonHandler(() -> {
this.setEditMode(true);
});
view.setEditButtonHandler(() -> this.setEditMode(true));

view.setCancelButtonHandler(() -> {
handleAfterSetEntity(this.entityIri);
Expand Down Expand Up @@ -160,9 +163,7 @@ protected void handleReloadRequest() {
protected void handleAfterSetEntity(Optional<OWLEntity> entityData) {
this.entityIri = entityData;
entityData.ifPresent(owlEntity -> dispatch.execute(GetEntityCustomScalesAction.create(owlEntity.getIRI().toString(), getProjectId()),
(result) -> {
postCoordinationCustomScalesList.addAll(result.getWhoficCustomScaleValues().getScaleCustomizations());
}));
(result) -> postCoordinationCustomScalesList.addAll(result.getWhoficCustomScaleValues().getScaleCustomizations())));

entityData.ifPresent(owlEntity -> dispatch.execute(GetEntityPostCoordinationAction.create(owlEntity.getIRI().toString(), getProjectId()),
(result) -> {
Expand Down Expand Up @@ -201,7 +202,7 @@ private void addScaleValueCardPresenter(String axisIri) {
ToDo:
return an error here if we don't have a value in genericScale
*/
new PostCoordinationAxisToGenericScale(axisIri, "", ScaleAllowMultiValue.NotAllowed)
new PostCoordinationAxisToGenericScale(axisIri, "", "NotAllowed")
);
List<String> existingScaleValueForAxis = postCoordinationCustomScalesList.stream().filter(customScaleValue -> customScaleValue.getPostcoordinationAxis().equals(axisIri))
.flatMap(customScaleValue -> customScaleValue.getPostcoordinationScaleValues().stream())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import com.google.gwt.user.client.ui.VerticalPanel;
import edu.stanford.bmir.protege.web.client.dispatch.DispatchServiceManager;
import edu.stanford.bmir.protege.web.shared.entity.GetRenderedOwlEntitiesAction;
import edu.stanford.bmir.protege.web.shared.postcoordination.PostCoordinationTableAxisLabel;
import edu.stanford.bmir.protege.web.shared.postcoordination.*;
import edu.stanford.bmir.protege.web.shared.project.ProjectId;

import java.util.HashSet;
Expand Down Expand Up @@ -41,14 +41,14 @@ private void bindView() {

private void initTable() {
view.clearTable();
view.addHeader(postCoordinationAxis.getScaleLabel(), scaleValue.getGenericScale().getAllowMultiValue());
view.addHeader(postCoordinationAxis.getScaleLabel(), ScaleAllowMultiValue.valueOf(scaleValue.getGenericScale().getAllowMultiValue()));
view.addSelectValueButton();

dispatchServiceManager.execute(GetRenderedOwlEntitiesAction.create(projectId, new HashSet<>(scaleValue.getValueIris())),
result -> {
result.getRenderedEntities()
.forEach(renderedEntity -> addRow(!renderedEntity.getBrowserText().equals("") ? renderedEntity.getBrowserText() : renderedEntity.getEntity().toStringID()));
view.setEditMode(!isReadOnly);
result.getRenderedEntities()
.forEach(renderedEntity -> addRow(!renderedEntity.getBrowserText().equals("") ? renderedEntity.getBrowserText() : renderedEntity.getEntity().toStringID()));
view.setEditMode(!isReadOnly);
}
);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package edu.stanford.bmir.protege.web.shared.postcoordination;

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;

@AutoValue
@GwtCompatible(serializable = true)
@JsonTypeName("webprotege.postcoordination.GetPostCoordinationAxisToGenericScale")
public class GetPostCoordinationAxisToGenericScaleAction implements Action<GetPostCoordinationAxisToGenericScaleResult> {

public static GetPostCoordinationAxisToGenericScaleAction create() {
return new AutoValue_GetPostCoordinationAxisToGenericScaleAction();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package edu.stanford.bmir.protege.web.shared.postcoordination;

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 java.util.List;

@AutoValue
@GwtCompatible(serializable = true)
@JsonTypeName("webprotege.postcoordination.GetPostCoordinationAxisToGenericScale")
public abstract class GetPostCoordinationAxisToGenericScaleResult implements Result {

public abstract List<PostCoordinationAxisToGenericScale> getPostCoordinationAxisToGenericScales();
}
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
package edu.stanford.bmir.protege.web.client.postcoordination.scaleValuesCard;
package edu.stanford.bmir.protege.web.shared.postcoordination;

public class PostCoordinationAxisToGenericScale {
private final String postcoordinationAxis;
private final String genericPostcoordinationScaleTopClass;
private final ScaleAllowMultiValue allowMultiValue;
private final String allowMultiValue;

public PostCoordinationAxisToGenericScale(String postcoordinationAxis,
String genericPostcoordinationScaleTopClass,
ScaleAllowMultiValue allowMultiValue) {
String allowMultiValue) {
this.postcoordinationAxis = postcoordinationAxis;
this.genericPostcoordinationScaleTopClass = genericPostcoordinationScaleTopClass;
this.allowMultiValue = allowMultiValue;
}

public PostCoordinationAxisToGenericScale create(String postcoordinationAxis,
String genericPostcoordinationScaleTopClass,
ScaleAllowMultiValue allowMultiValue) {
String allowMultiValue) {
return new PostCoordinationAxisToGenericScale(postcoordinationAxis, genericPostcoordinationScaleTopClass, allowMultiValue);
}

Expand All @@ -27,7 +27,7 @@ public String getGenericPostcoordinationScaleTopClass() {
return genericPostcoordinationScaleTopClass;
}

public ScaleAllowMultiValue getAllowMultiValue() {
public String getAllowMultiValue() {
return allowMultiValue;
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package edu.stanford.bmir.protege.web.client.postcoordination.scaleValuesCard;
package edu.stanford.bmir.protege.web.shared.postcoordination;

import java.util.*;

Expand Down

0 comments on commit 43c2a0d

Please sign in to comment.