Skip to content

Commit

Permalink
wip released classes check
Browse files Browse the repository at this point in the history
  • Loading branch information
soimugeoWB committed Jun 11, 2024
1 parent 7289d6d commit 9fea957
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import edu.stanford.bmir.protege.web.client.tag.ProjectTagsStyleManager;
import edu.stanford.bmir.protege.web.client.user.LoggedInUserProvider;
import edu.stanford.bmir.protege.web.shared.entity.EntityNode;
import edu.stanford.bmir.protege.web.shared.entity.EntityStatus;
import edu.stanford.bmir.protege.web.shared.lang.DisplayNameSettings;
import edu.stanford.bmir.protege.web.shared.shortform.DictionaryLanguage;
import edu.stanford.bmir.protege.web.shared.tag.Tag;
Expand All @@ -17,6 +18,7 @@
import javax.annotation.Nonnull;
import javax.inject.Inject;
import java.util.Collection;
import java.util.Set;

import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.collect.ImmutableList.toImmutableList;
Expand Down Expand Up @@ -233,6 +235,9 @@ private void renderNoDisplayName(EntityNode node, StringBuilder sb) {
private DataResource getIcon(@Nonnull EntityNode node) {
OWLEntity entity = node.getEntity();
if (entity.isOWLClass()) {
if(containsIgnoreCase(node.getEntityStatuses(), "released")){
return BUNDLE.releasedClassIcon();
}
return BUNDLE.svgClassIcon();
}
else if (entity.isOWLObjectProperty()) {
Expand All @@ -255,4 +260,13 @@ else if (entity.isOWLNamedIndividual()) {
public void setPrimaryDisplayLanguage(@Nonnull DictionaryLanguage language) {
this.primaryLanguages = ImmutableList.of(checkNotNull(language));
}



private static boolean containsIgnoreCase(Set<EntityStatus> entityStatuses, String searchStr) {
if (searchStr == null || entityStatuses == null ||entityStatuses.isEmpty()) {
return false;
}
return entityStatuses.stream().anyMatch(entityStatus -> entityStatus.getStatus().equalsIgnoreCase(searchStr));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ private void handleBrowserTextChanged(BrowserTextChangedEvent event) {
node.getWatches(),
node.getOpenCommentCount(),
node.getTags(),
node.getEntityStatus());
node.getEntityStatuses());
nodeIndex.updateNode(updatedNode);
});
}
Expand Down Expand Up @@ -116,7 +116,7 @@ private void updateWatches(EntityNode node, Set<Watch> updatedWatches) {
updatedWatches,
node.getOpenCommentCount(),
node.getTags(),
node.getEntityStatus());
node.getEntityStatuses());
nodeIndex.updateNode(updatedNode);
}

Expand All @@ -134,7 +134,7 @@ private void handleCommentPosted(CommentPostedEvent event) {
node.getWatches(),
event.getOpenCommentCountForEntity(),
node.getTags(),
node.getEntityStatus());
node.getEntityStatuses());
nodeIndex.updateNode(updatedNode);
});
});
Expand All @@ -154,7 +154,7 @@ private void handleDiscussionThreadStatusChanged(DiscussionThreadStatusChangedEv
node.getWatches(),
event.getOpenCommentsCountForEntity(),
node.getTags(),
node.getEntityStatus());
node.getEntityStatuses());
nodeIndex.updateNode(updatedNode);
});
});
Expand All @@ -173,7 +173,7 @@ private void handleEntityDeprecatedChanged(EntityDeprecatedChangedEvent event) {
node.getWatches(),
node.getOpenCommentCount(),
node.getTags(),
node.getEntityStatus());
node.getEntityStatuses());
nodeIndex.updateNode(updatedNode);
});
}
Expand All @@ -191,7 +191,7 @@ private void handleEntityTagsChanged(EntityTagsChangedEvent event) {
node.getWatches(),
node.getOpenCommentCount(),
event.getTags(),
node.getEntityStatus());
node.getEntityStatuses());
nodeIndex.updateNode(updatedNode);
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ public interface WebProtegeClientBundle extends ClientBundle {
@DataResource.MimeType("image/svg+xml")
DataResource svgClassIcon();

@Source("released.png")
@DataResource.MimeType("image/png")
DataResource releasedClassIcon();

@Source("deprecated-class.svg")
@DataResource.MimeType("image/svg+xml")
DataResource svgDeprecatedClassIcon();
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,9 @@ public OWLEntityData getEntityData() {
@Nonnull
public abstract ImmutableMap<DictionaryLanguage, String> getShortForms();

public abstract ImmutableSet<EntityStatus> getEntityStatus();

@JsonProperty("statuses")
public abstract ImmutableSet<EntityStatus> getEntityStatuses();

@JsonProperty("shortForms")
public ImmutableList<ShortForm> getShortFormsList() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import javax.annotation.Nonnull;

@AutoValue
public abstract class EntityStatus implements IsSerializable {
public abstract class EntityStatus implements IsSerializable, Comparable<EntityStatus> {

public static final String STATUS = "_status";

Expand All @@ -21,4 +21,10 @@ public static EntityStatus get(@Nonnull @JsonProperty(STATUS) String status) {
@JsonProperty(STATUS)
@Nonnull
public abstract String getStatus();


@Override
public int compareTo(EntityStatus o) {
return this.getStatus().compareToIgnoreCase(o.getStatus());
}
}

0 comments on commit 9fea957

Please sign in to comment.