X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.issues.common%2Fsrc%2Forg%2Fsimantics%2Fissues%2Fcommon%2FMaxIssueSeveritySingle.java;h=89816d6faa42fb2c3d70ae3443901ce3194d85bb;hp=e8ed917aad52182f701f1060fb5a289ce49f1325;hb=6c13a0fe40ac29598b401abded6460285c95c3c8;hpb=c818c98e04cc069eb25c7842e5e099907380f0bc diff --git a/bundles/org.simantics.issues.common/src/org/simantics/issues/common/MaxIssueSeveritySingle.java b/bundles/org.simantics.issues.common/src/org/simantics/issues/common/MaxIssueSeveritySingle.java index e8ed917aa..89816d6fa 100644 --- a/bundles/org.simantics.issues.common/src/org/simantics/issues/common/MaxIssueSeveritySingle.java +++ b/bundles/org.simantics.issues.common/src/org/simantics/issues/common/MaxIssueSeveritySingle.java @@ -14,8 +14,12 @@ package org.simantics.issues.common; import java.util.concurrent.atomic.AtomicReference; import org.simantics.db.AsyncReadGraph; +import org.simantics.db.ReadGraph; import org.simantics.db.Resource; import org.simantics.db.common.request.ResourceAsyncRead; +import org.simantics.db.common.request.ResourceRead; +import org.simantics.db.common.utils.ListUtils; +import org.simantics.db.exception.DatabaseException; import org.simantics.db.procedure.AsyncMultiProcedure; import org.simantics.db.procedure.AsyncProcedure; import org.simantics.issues.Severity; @@ -52,11 +56,12 @@ public class MaxIssueSeveritySingle extends ResourceAsyncRead{ @Override public void perform(AsyncReadGraph graph, final AsyncProcedure procedure) { + final IssueResource ISSUE = graph.getService(IssueResource.class); - //System.out.println(getClass().getSimpleName() + ": " + resource); + + AtomicReference maxSeverity = new AtomicReference(); graph.forEachObject(resource, ISSUE.Issue_HasContext_Inverse, new AsyncMultiProcedure() { - AtomicReference maxSeverity = new AtomicReference(); @Override public void execute(AsyncReadGraph graph, final Resource issue) { @@ -69,13 +74,54 @@ public class MaxIssueSeveritySingle extends ResourceAsyncRead{ } @Override public void finished(AsyncReadGraph graph) { - procedure.execute(graph, maxSeverity.get()); } @Override public void exception(AsyncReadGraph graph, Throwable throwable) { procedure.exception(graph, throwable); } }); + + graph.forEachObject(resource, ISSUE.Issue_ContextList_Element_Inverse, new AsyncMultiProcedure() { + @Override + public void execute(AsyncReadGraph graph, final Resource element) { + + graph.asyncRequest(new ResourceRead(element) { + @Override + public Resource perform(ReadGraph graph) throws DatabaseException { + Resource list = ListUtils.getListElementList(graph, resource); + return graph.getSingleObject(list, ISSUE.Issue_HasContexts_Inverse); + } + }, new AsyncProcedure() { + + @Override + public void execute(AsyncReadGraph graph, Resource issue) { + /* + * Compare severity of each related issue and find the maximum severity. + * The issues that are not resolved and have active issue source manager + * are taken into account. + */ + acceptIfNotResolved(graph, procedure, ISSUE, issue, maxSeverity); + } + + @Override + public void exception(AsyncReadGraph graph, Throwable throwable) { + procedure.exception(graph, throwable); + } + }); + + + } + @Override + public void finished(AsyncReadGraph graph) { + } + @Override + public void exception(AsyncReadGraph graph, Throwable throwable) { + procedure.exception(graph, throwable); + } + }); + + procedure.execute(graph, maxSeverity.get()); + } /**