/*******************************************************************************
- * Copyright (c) 2007, 2011 Association for Decentralized Information Management
+ * Copyright (c) 2007, 2019 Association for Decentralized Information Management
* in Industry THTH ry.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
*
* Contributors:
* VTT Technical Research Centre of Finland - initial API and implementation
+ * Semantum Oy - Reorganization
*******************************************************************************/
package org.simantics.issues.ui.handler;
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
- Runnable postValidation = null;
- run(postValidation);
+ try {
+ run();
+ } catch (DatabaseException e) {
+ throw new ExecutionException("Error while running active validations", e);
+ }
return null;
}
- public void run(Runnable postValidation) {
+ public static void run() throws DatabaseException {
+ Resource model = Simantics.getSession().syncRequest(new PossibleActiveModel(Simantics.getProjectResource()));
+ if(model != null)
+ run(model);
+ }
+
+ public static void run(Resource model) {
+ run(model, null);
+ }
+
+ public static void run(Resource model, Runnable postValidation) {
final Session session = Simantics.getSession();
@Override
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
try {
- Resource model = session.sync(new PossibleActiveModel(Simantics.getProjectResource()));
- if(model == null) return;
toBatchIssueSources(session,
session.syncRequest(new SelectedModelBatchIssueSources(model)),
Resource list = graph.getSingleObject(issue, ISSUE.Issue_HasContexts);
List<Resource> l = ListUtils.toList(graph, list);
if (l.size() > 0) {
- Resource mainContext = l.get(0);
- if (!graph.hasStatement(mainContext))
+ Resource mainContext = l.get(0);
+ if (!BatchValidations.isLinkedToOtherThan(graph, mainContext, issue))
result.add(mainContext);
}
}
}
} catch (OperationCanceledException e) {
- throw e;
+ throw e;
} catch (Exception e) {
throw new InvocationTargetException(e);
} finally {