Skip to content

Commit

Permalink
fix for who-icatx/icatx-project#111. finished ChangeEntityParentsResult
Browse files Browse the repository at this point in the history
  • Loading branch information
soimugeo committed Jan 17, 2025
1 parent 9c01150 commit ee08ef6
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import java.util.Optional;
import java.util.Set;
import java.util.logging.Logger;
import java.util.stream.Collectors;

import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.collect.ImmutableSet.toImmutableSet;
Expand Down Expand Up @@ -121,8 +122,11 @@ private void handleHierarchyChange(ModalCloser closer) {

if(changeEntityParentsResult.hasLinearizationPathParent()){
view.clearLinearizationPathParentErrors();
OWLEntityData linearizationPathParent = changeEntityParentsResult.getLinearizationPathParent().get();
view.markLinearizationPathParent(linearizationPathParent);
String parents = changeEntityParentsResult.getLinearizationPathParents()
.stream()
.map(OWLEntityData::getBrowserText)
.collect(Collectors.joining(", "));
view.markLinearizationPathParent(parents);
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,5 @@ public interface EditParentsView extends IsWidget, HasBusy {

void clearLinearizationPathParentErrors();

void markLinearizationPathParent(OWLEntityData classesWithRetiredParents);
void markLinearizationPathParent(String linearizationPathParents);
}
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,8 @@ public void clearLinearizationPathParentErrors() {
}

@Override
public void markLinearizationPathParent(OWLEntityData linearizationPathParent) {
linearizationPathParentField.setHTML(messages.classHierarchy_removeParentThatIsLinearizationPathParent(linearizationPathParent.getBrowserText()));
public void markLinearizationPathParent(String linearizationPathParents) {
linearizationPathParentField.setHTML(messages.classHierarchy_removeParentThatIsLinearizationPathParent(linearizationPathParents));
linearizationPathParentField.setVisible(true);
}
}
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
package edu.stanford.bmir.protege.web.shared.hierarchy;

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;
import edu.stanford.bmir.protege.web.shared.entity.OWLEntityData;

import javax.annotation.Nonnull;
import java.util.Optional;
import javax.annotation.*;
import java.util.Set;

/**
Expand All @@ -26,8 +23,8 @@ public abstract class ChangeEntityParentsResult implements Result {
@JsonCreator
public static ChangeEntityParentsResult create(@JsonProperty("classesWithCycle") @Nonnull Set<OWLEntityData> classesWithCycle,
@JsonProperty("classesWithRetiredParents") @Nonnull Set<OWLEntityData> classesWithRetiredParents,
@JsonProperty("linearizationPathParent") Optional<OWLEntityData> linearizationPathParent ) {
return new AutoValue_ChangeEntityParentsResult(classesWithCycle, classesWithRetiredParents, linearizationPathParent);
@JsonProperty("linearizationPathParents") @Nullable Set<OWLEntityData> linearizationPathParents) {
return new AutoValue_ChangeEntityParentsResult(classesWithCycle, classesWithRetiredParents, linearizationPathParents);
}

@JsonProperty("classesWithCycle")
Expand All @@ -38,27 +35,27 @@ public static ChangeEntityParentsResult create(@JsonProperty("classesWithCycle")
@Nonnull
public abstract Set<OWLEntityData> getClassesWithRetiredParents();

@JsonProperty("linearizationPathParent")
@Nonnull
public abstract Optional<OWLEntityData> getLinearizationPathParent();
@JsonProperty("linearizationPathParents")
@Nullable
public abstract Set<OWLEntityData> getLinearizationPathParents();

public boolean hasClassesWithCycle(){
public boolean hasClassesWithCycle() {
return !getClassesWithCycle().isEmpty();
}

public boolean hasClassesWithRetiredParents(){
public boolean hasClassesWithRetiredParents() {
return !getClassesWithRetiredParents().isEmpty();
}

public boolean hasLinearizationPathParent(){
return getLinearizationPathParent().isPresent();
public boolean hasLinearizationPathParent() {
return !getLinearizationPathParents().isEmpty();
}

public boolean isFailure(){
return hasClassesWithRetiredParents()||hasClassesWithCycle()||hasLinearizationPathParent();
public boolean isFailure() {
return hasClassesWithRetiredParents() || hasClassesWithCycle() || hasLinearizationPathParent();
}

public boolean isSuccess(){
public boolean isSuccess() {
return !isFailure();
}
}

0 comments on commit ee08ef6

Please sign in to comment.