Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/upload-postcoordination-file' in…
Browse files Browse the repository at this point in the history
…to upload-postcoordination-file

# Conflicts:
#	webprotege-gwt-ui-client/src/main/java/edu/stanford/bmir/protege/web/client/postcoordination/PostCoordinationPortletPresenter.java
  • Loading branch information
alexsilaghi committed Sep 27, 2024
2 parents f94362a + 9bf2bb2 commit 4a341b4
Show file tree
Hide file tree
Showing 6 changed files with 91 additions and 103 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ public class PostCoordinationPortletPresenter extends AbstractWebProtegePortletP
private final List<PostCoordinationCompositeAxis> compositeAxisList = new ArrayList<>();
private final Map<String, PostCoordinationAxisToGenericScale> genericScale = new HashMap<>();

private final List<PostCoordinationCustomScales> postCoordinationCustomScalesList = new ArrayList<>();


@Inject
public PostCoordinationPortletPresenter(@Nonnull SelectionModel selectionModel,
Expand Down Expand Up @@ -110,37 +112,6 @@ remove the orElseGet() and add back the orElseThrow() when we have proper labels
)
);

/*
ToDo:
1. populate genericScale using a dispatch request.
2. populate a list of scaleCustomizations from BE with the real scale values for each axis/subaxis
*/
// Map<String, ScaleValueCardPresenter> axisMapWithValues = tableLabelsForAxes.values()
// .stream()
// .collect(Collectors.toMap(
// PostCoordinationTableAxisLabel::getPostCoordinationAxis,
// tabelAxisLabel -> {
// PostCoordinationAxisToGenericScale genericScale1 = genericScale.getOrDefault(
// tabelAxisLabel.getPostCoordinationAxis(),
// new PostCoordinationAxisToGenericScale(tabelAxisLabel.getPostCoordinationAxis(), "", ScaleAllowMultiValue.NotAllowed)
// );
// return createScaleValueCardPresenter(
// tabelAxisLabel,
// new PostCoordinationScaleValue(
// tabelAxisLabel.getPostCoordinationAxis(),
// tabelAxisLabel.getScaleLabel(),
// new ArrayList<>(Arrays.asList("iri1.1", "iri1.2", "iri1.3")),
// genericScale1)
// );
// }
// ));
//
// scaleValueCardPresenters.putAll(axisMapWithValues);
//Do batch action for all scaleValues
dispatch.beginBatch();
scaleValueCardPresenters.values().forEach(presenter -> presenter.start(view.getScaleValueCardsView()));
dispatch.executeCurrentBatch();


view.setTableCellChangedHandler(handleTableCellChanged());

Expand All @@ -166,12 +137,27 @@ protected void handleReloadRequest() {

@Override
protected void handleAfterSetEntity(Optional<OWLEntity> entityData) {
clearScaleValueCards();
logger.info("Fac fetch la entity " + entityData);
entityData.ifPresent(owlEntity -> dispatch.execute(GetEntityCustomScalesAction.create(owlEntity.getIRI().toString(), getProjectId()),
(result) -> {
logger.info("ALEX a venit si scales " + result);
postCoordinationCustomScalesList.addAll(result.getWhoficCustomScaleValues().getScaleCustomizations());
}));

entityData.ifPresent(owlEntity -> dispatch.execute(GetEntityPostCoordinationAction.create(owlEntity.getIRI().toString(), getProjectId()),
(result) -> view.setTableData(result.getPostCoordinationSpecification())));
(result) -> {
logger.info("ALEX post coord result: " + result);
view.setTableData(result.getPostCoordinationSpecification());
}));


entityData.ifPresent(owlEntity -> dispatch.execute(GetEntityCustomScalesAction.create(owlEntity.getIRI().toString(), getProjectId()),
(result)-> logger.info("ALEX a venit si scales " + result)));
}

private void clearScaleValueCards() {
scaleValueCardPresenters.clear();
postCoordinationCustomScalesList.clear();
view.getScaleValueCardsView().clear();
}

public void removeScaleValueCardPresenter(String axisIri) {
Expand All @@ -192,13 +178,12 @@ private void addScaleValueCardPresenter(String axisIri) {
*/
new PostCoordinationAxisToGenericScale(axisIri, "", ScaleAllowMultiValue.NotAllowed)
);
List<String> existingScaleValueForAxis = postCoordinationCustomScalesList.stream().filter(customScaleValue -> customScaleValue.getPostcoordinationAxis().equals(axisIri))
.flatMap(customScaleValue -> customScaleValue.getPostcoordinationScaleValues().stream())
.collect(Collectors.toList());
ScaleValueCardPresenter newPresenter = createScaleValueCardPresenter(
currentAxisLabels,
/*
ToDo:
create a post PostCoordinationScaleValue also using the scale value from BE if it exists. if not then use createEmpty()
*/
PostCoordinationScaleValue.createEmpty(axisIri, currentAxisLabels.getScaleLabel(), genericScale1)
PostCoordinationScaleValue.create(axisIri, currentAxisLabels.getScaleLabel(), existingScaleValueForAxis, genericScale1)
);
scaleValueCardPresenters.put(axisIri, newPresenter);
newPresenter.start(view.getScaleValueCardsView());
Expand Down Expand Up @@ -251,13 +236,12 @@ private boolean isScaleValuePresenterCreated(String axisIri) {
.filter(compositeAxis -> compositeAxis.getPostCoordinationAxis().equals(axisIri))
.findFirst();

if (compositeAxesOptional.isPresent()) {
return compositeAxesOptional.get()
.getSubAxis()
.stream()
.anyMatch(subAxis -> scaleValueCardPresenters.get(subAxis) != null);
}
return scaleValueCardPresenters.get(axisIri) != null;
return compositeAxesOptional.map(
postCoordinationCompositeAxis -> postCoordinationCompositeAxis
.getSubAxis()
.stream()
.anyMatch(subAxis -> scaleValueCardPresenters.get(subAxis) != null))
.orElseGet(() -> scaleValueCardPresenters.get(axisIri) != null);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ public class PostCoordinationScaleValue {

public PostCoordinationScaleValue(String axisIri,
String axisLabel,
List<String> valueIris, PostCoordinationAxisToGenericScale genericScale) {
List<String> valueIris,
PostCoordinationAxisToGenericScale genericScale) {
this.axisIri = axisIri;
this.axisLabel = axisLabel;
this.valueIris = valueIris;
Expand All @@ -21,7 +22,14 @@ public PostCoordinationScaleValue(String axisIri,
public static PostCoordinationScaleValue createEmpty(String axisIri,
String axisLabel,
PostCoordinationAxisToGenericScale genericScale) {
return new PostCoordinationScaleValue(axisIri, axisLabel, new ArrayList<>(), genericScale);
return create(axisIri, axisLabel, new ArrayList<>(), genericScale);
}

public static PostCoordinationScaleValue create(String axisIri,
String axisLabel,
List<String> valueIris,
PostCoordinationAxisToGenericScale genericScale) {
return new PostCoordinationScaleValue(axisIri, axisLabel, valueIris, genericScale);
}

public String getAxisIri() {
Expand All @@ -36,7 +44,7 @@ public List<String> getValueIris() {
return valueIris;
}

public PostCoordinationAxisToGenericScale getGenericScale(){
public PostCoordinationAxisToGenericScale getGenericScale() {
return genericScale;
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
package edu.stanford.bmir.protege.web.shared.postcoordination;


import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonTypeName;
import com.fasterxml.jackson.annotation.*;
import com.google.auto.value.AutoValue;
import com.google.common.annotations.GwtCompatible;
import edu.stanford.bmir.protege.web.shared.dispatch.Result;
Expand All @@ -12,15 +10,12 @@
@GwtCompatible(serializable = true)
@JsonTypeName("webprotege.postcoordination.GetEntityScaleValues")
public abstract class GetEntityCustomScalesResult implements Result {
@JsonProperty("entityIri")
public abstract String getEntityIri();

@JsonProperty("postCoordinationScaleValues")
public abstract WhoficCustomScalesValues getPostCoordinationScaleValues();
@JsonProperty("whoficCustomScaleValues")
public abstract WhoficCustomScalesValues getWhoficCustomScaleValues();

@JsonCreator
public static GetEntityCustomScalesResult create(@JsonProperty("entityIri") String entityIri,
@JsonProperty("postCoordinationScaleValues") WhoficCustomScalesValues postCoordinationScaleValues) {
return new AutoValue_GetEntityCustomScalesResult(entityIri, postCoordinationScaleValues);
public static GetEntityCustomScalesResult create(@JsonProperty("whoficCustomScaleValues") WhoficCustomScalesValues whoficCustomScaleValues) {
return new AutoValue_GetEntityCustomScalesResult(whoficCustomScaleValues);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package edu.stanford.bmir.protege.web.shared.postcoordination;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.common.annotations.GwtCompatible;
import com.google.gwt.user.client.rpc.IsSerializable;
import edu.stanford.bmir.protege.web.shared.annotations.GwtSerializationConstructor;

import java.io.Serializable;
import java.util.List;

@GwtCompatible(serializable = true)
public class PostCoordinationCustomScales implements IsSerializable, Serializable {

private List<String> postcoordinationScaleValues;
private String postcoordinationAxis;


@GwtSerializationConstructor
public PostCoordinationCustomScales(){

}

@JsonCreator
public PostCoordinationCustomScales(@JsonProperty("postcoordinationScaleValues") List<String> postcoordinationScaleValues,
@JsonProperty("postcoordinationAxis") String postcoordinationAxis) {
this.postcoordinationScaleValues = postcoordinationScaleValues;
this.postcoordinationAxis = postcoordinationAxis;
}

@JsonProperty("postcoordinationScaleValues")
public List<String> getPostcoordinationScaleValues() {
return postcoordinationScaleValues;
}

@JsonProperty("postcoordinationAxis")
public String getPostcoordinationAxis() {
return postcoordinationAxis;
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,13 @@
@GwtCompatible(serializable = true)
public class WhoficCustomScalesValues implements IsSerializable, Serializable {

@JsonProperty("whoficEntityIri")
private String whoficEntityIri;
@JsonProperty("scaleCustomizations")
private List<PostCoordinationCustomScalesRequest> scaleCustomizations;
private List<PostCoordinationCustomScales> scaleCustomizations;


@JsonCreator
public WhoficCustomScalesValues( @JsonProperty("whoficEntityIri") String whoficEntityIri,
@JsonProperty("scaleCustomizations") List<PostCoordinationCustomScalesRequest> scaleCustomizations) {
@JsonProperty("scaleCustomizations") List<PostCoordinationCustomScales> scaleCustomizations) {
this.whoficEntityIri = whoficEntityIri;
this.scaleCustomizations = scaleCustomizations;
}
Expand All @@ -29,11 +27,13 @@ public WhoficCustomScalesValues( @JsonProperty("whoficEntityIri") String whoficE
private WhoficCustomScalesValues() {
}

@JsonProperty("whoficEntityIri")
public String getWhoficEntityIri() {
return whoficEntityIri;
}

public List<PostCoordinationCustomScalesRequest> getScaleCustomizations() {
@JsonProperty("scaleCustomizations")
public List<PostCoordinationCustomScales> getScaleCustomizations() {
return scaleCustomizations;
}
}

0 comments on commit 4a341b4

Please sign in to comment.