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;
@Override
public void perform(AsyncReadGraph graph, final AsyncProcedure<Severity> procedure) {
+
final IssueResource ISSUE = graph.getService(IssueResource.class);
- //System.out.println(getClass().getSimpleName() + ": " + resource);
+
+ AtomicReference<Severity> maxSeverity = new AtomicReference<Severity>();
graph.forEachObject(resource, ISSUE.Issue_HasContext_Inverse, new AsyncMultiProcedure<Resource>() {
- AtomicReference<Severity> maxSeverity = new AtomicReference<Severity>();
@Override
public void execute(AsyncReadGraph graph, final Resource issue) {
}
@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<Resource>() {
+ @Override
+ public void execute(AsyncReadGraph graph, final Resource element) {
+
+ graph.asyncRequest(new ResourceRead<Resource>(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<Resource>() {
+
+ @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());
+
}
/**