Skip to content

Commit

Permalink
Revert "interim fix for who-icatx/icatx-project#111 refactored Change…
Browse files Browse the repository at this point in the history
…EntityParentsResult to include the linearizationPathParent check"

This reverts commit 983c5e9.
  • Loading branch information
soimugeo committed Jan 17, 2025
1 parent 983c5e9 commit e94baf9
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 77 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1251,12 +1251,6 @@ public interface Messages extends com.google.gwt.i18n.client.Messages {
"Please correct this in order to save changes")
SafeHtml classHierarchy_parentsHaveRetiredAncestors(String classesWithRetiredParents);

@DefaultMessage("<em>A Linearization Path Parent cannot be removed <br>" +
"Following parent is a linearization path parent: <strong>{0}</strong></em><br>" +
"<br>" +
"Please change the linearization path parent before removing the parent")
SafeHtml classHierarchy_removeParentThatIsLinearizationPathParent(String linearizationPathParent);

@DefaultMessage("<em>A released class cannot be moved to a retired parent!")
String classHierarchy_cannotMoveReleasedClassToRetiredParent();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import edu.stanford.bmir.protege.web.client.library.modal.ModalPresenter;
import edu.stanford.bmir.protege.web.shared.entity.OWLEntityData;
import edu.stanford.bmir.protege.web.shared.hierarchy.ChangeEntityParentsAction;
import edu.stanford.bmir.protege.web.shared.hierarchy.ChangeEntityParentsResult;
import edu.stanford.bmir.protege.web.shared.hierarchy.GetHierarchyParentsAction;
import edu.stanford.bmir.protege.web.shared.issues.CreateEntityDiscussionThreadAction;
import edu.stanford.bmir.protege.web.shared.project.ProjectId;
Expand Down Expand Up @@ -98,33 +99,39 @@ private void handleHierarchyChange(ModalCloser closer) {
.collect(toImmutableSet());
dispatch.execute(ChangeEntityParentsAction.create(projectId, parentsSet, entity.asOWLClass(), view.getReasonForChange()),
changeEntityParentsResult -> {
if (changeEntityParentsResult.isSuccess()) {
view.clearClassesWithCycleErrors();
view.clearClassesWithRetiredParentsErrors();
if (isResultValid(changeEntityParentsResult)) {
view.clearClassesWithCycle();
view.clearClassesWithRetiredParents();
dispatch.execute(
CreateEntityDiscussionThreadAction.create(projectId, entity, view.getReasonForChange()),
threadActionResult -> closer.closeModal());
return;
}

if(changeEntityParentsResult.hasClassesWithRetiredParents()){
view.clearClassesWithRetiredParentsErrors();
if(hasClassesWithRetiredParents(changeEntityParentsResult)){
view.clearClassesWithRetiredParents();
Set<OWLEntityData> classesWithRetiredParents = changeEntityParentsResult.getClassesWithRetiredParents();
view.markClassesWithRetiredParents(classesWithRetiredParents);
}

if(changeEntityParentsResult.hasClassesWithCycle()){
view.clearClassesWithCycleErrors();
if(hasClassesWithCycles(changeEntityParentsResult)){
view.clearClassesWithCycle();
Set<OWLEntityData> classesWithCycles = changeEntityParentsResult.getClassesWithCycle();
view.markClassesWithCycles(classesWithCycles);
}

if(changeEntityParentsResult.hasLinearizationPathParent()){
view.clearLinearizationPathParentErrors();
OWLEntityData linearizationPathParent = changeEntityParentsResult.getLinearizationPathParent().get();
view.markLinearizationPathParent(linearizationPathParent);
}
});
}
}

private boolean isResultValid(ChangeEntityParentsResult changeEntityParentsResult) {
return !hasClassesWithCycles(changeEntityParentsResult) && !hasClassesWithRetiredParents(changeEntityParentsResult);
}

private boolean hasClassesWithCycles(ChangeEntityParentsResult changeEntityParentsResult) {
return !changeEntityParentsResult.getClassesWithCycle().isEmpty();
}

private boolean hasClassesWithRetiredParents(ChangeEntityParentsResult changeEntityParentsResult) {
return !changeEntityParentsResult.getClassesWithRetiredParents().isEmpty();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,11 @@ public interface EditParentsView extends IsWidget, HasBusy {

List<OWLPrimitiveData> getNewParentList();

void clearClassesWithCycleErrors();
void clearClassesWithCycle();

void markClassesWithCycles(Set<OWLEntityData> classesWithCycles);

void clearClassesWithRetiredParentsErrors();
void clearClassesWithRetiredParents();

void markClassesWithRetiredParents(Set<OWLEntityData> classesWithRetiredParents);

void clearLinearizationPathParentErrors();

void markLinearizationPathParent(OWLEntityData classesWithRetiredParents);
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,6 @@ public class EditParentsViewImpl extends Composite implements EditParentsView {
@UiField
HTML classesWithRetiredParentsField;

@UiField
HTML linearizationPathParentField;

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

interface EditParentsViewImplUiBinder extends UiBinder<HTMLPanel, EditParentsViewImpl> {
Expand Down Expand Up @@ -103,11 +100,11 @@ public boolean isReasonForChangeSet() {
reasonForChangeErrorLabel.addStyleName(WebProtegeClientBundle.BUNDLE.style().errorLabel());
return false;
}
clearReasonForChangeErrors();
clearErrors();
return true;
}

public void clearReasonForChangeErrors() {
public void clearErrors() {
reasonForChangeErrorLabel.setText("");
reasonForChangeErrorLabel.removeStyleName(WebProtegeClientBundle.BUNDLE.style().errorLabel());
}
Expand All @@ -117,9 +114,8 @@ public void clearReasonForChangeErrors() {
public void clear() {
textBox.setText("");
reasonForChangeTextBox.setText("");
clearReasonForChangeErrors();
clearClassesWithCycleErrors();
clearLinearizationPathParentErrors();
clearErrors();
clearClassesWithCycle();
}

@Nonnull
Expand All @@ -134,7 +130,7 @@ public List<OWLPrimitiveData> getNewParentList() {
}

@Override
public void clearClassesWithCycleErrors() {
public void clearClassesWithCycle() {
classesWithCyclesWarningField.setVisible(false);
classesWithCyclesWarningField.setHTML("");
}
Expand All @@ -147,7 +143,7 @@ public void markClassesWithCycles(Set<OWLEntityData> classesWithCycles) {
}

@Override
public void clearClassesWithRetiredParentsErrors() {
public void clearClassesWithRetiredParents() {
classesWithRetiredParentsField.setVisible(false);
classesWithRetiredParentsField.setHTML("");
}
Expand All @@ -158,16 +154,4 @@ public void markClassesWithRetiredParents(Set<OWLEntityData> classesWithRetiredP
classesWithCyclesWarningField.setHTML(messages.classHierarchy_parentsHaveRetiredAncestors(classes));
classesWithCyclesWarningField.setVisible(true);
}

@Override
public void clearLinearizationPathParentErrors() {
linearizationPathParentField.setVisible(false);
linearizationPathParentField.setHTML("");
}

@Override
public void markLinearizationPathParent(OWLEntityData linearizationPathParent) {
linearizationPathParentField.setHTML(messages.classHierarchy_removeParentThatIsLinearizationPathParent(linearizationPathParent.getBrowserText()));
linearizationPathParentField.setVisible(true);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,6 @@
<g:HTML ui:field="classesWithRetiredParentsField"
visible="false"
addStyleNames="{wp.style.warningLabel} {style.warningField}"/>
<g:HTML ui:field="linearizationPathParentField"
visible="false"
addStyleNames="{wp.style.warningLabel} {style.warningField}"/>
</div>
</g:HTMLPanel>
</ui:UiBinder>
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import edu.stanford.bmir.protege.web.shared.entity.OWLEntityData;

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


Expand All @@ -21,9 +20,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("classesWithRetiredParents") @Nonnull Set<OWLEntityData> classesWithRetiredParents) {
return new AutoValue_ChangeEntityParentsResult(classesWithCycle, classesWithRetiredParents);
}

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

@JsonProperty("linearizationPathParent")
@Nonnull
public abstract Optional<OWLEntityData> getLinearizationPathParent();

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

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

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

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

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

0 comments on commit e94baf9

Please sign in to comment.