this.updateSchedules = new ArrayList[CLUSTER_THREADS];
for(int i=0;i<clusterUpdateThreads.length;i++) {
clusterUpdateThreads[i] = Executors.newSingleThreadExecutor(new ClusterThreadFactory("Cluster Updater " + (i+1), false));
- updateSchedules[i] = new ArrayList<ClusterUpdateOperation>();
+ updateSchedules[i] = new ArrayList<>();
}
}
try {
+ TreeMap<ClusterUID, List<ClusterUpdateOperation>> updates = new TreeMap<>(clusterComparator);
+
main:
while(alive) {
- TreeMap<ClusterUID, List<ClusterUpdateOperation>> updates = new TreeMap<ClusterUID, List<ClusterUpdateOperation>>(clusterComparator);
-
+ if (!updates.isEmpty())
+ updates.clear();
operationQueue.pumpUpdates(updates);
if(updates.isEmpty()) {
for(int i=0;i<CLUSTER_THREADS;i++)
updateSchedules[i].clear();
+ if (updates.isEmpty())
+ return;
+
final Semaphore s = new Semaphore(0);
for(Map.Entry<ClusterUID, List<ClusterUpdateOperation>> entry : updates.entrySet()) {
Bundle-Version: 1.0.0.qualifier
Bundle-Activator: org.simantics.audit.Activator
Require-Bundle: org.eclipse.core.runtime,
- com.fasterxml.jackson.core.jackson-databind,
- com.fasterxml.jackson.core.jackson-core,
+ com.fasterxml.jackson.core.jackson-databind;bundle-version="[2.8.11,2.9.0)",
+ com.fasterxml.jackson.core.jackson-core;bundle-version="[2.8.11,2.9.0)",
org.slf4j.api,
javax.servlet-api,
- jakarta.ws.rs-api,
+ javax.ws.rs-api,
org.eclipse.jetty.server;bundle-version="9.4.24",
org.eclipse.jetty.servlet;bundle-version="9.4.24",
org.eclipse.jetty.util;bundle-version="9.4.24",
- org.glassfish.jersey.core.jersey-server,
- org.glassfish.jersey.media.jersey-media-json-jackson,
- org.glassfish.jersey.containers.jersey-container-servlet-core,
- org.glassfish.jersey.core.jersey-client,
- org.glassfish.jersey.core.jersey-common
+ org.glassfish.jersey.core.jersey-server;bundle-version="[2.25.1,2.26.0)",
+ org.glassfish.jersey.media.jersey-media-json-jackson;bundle-version="[2.25.1,2.26.0)",
+ org.glassfish.jersey.containers.jersey-container-servlet-core;bundle-version="[2.25.1,2.26.0)",
+ org.glassfish.jersey.core.jersey-client;bundle-version="[2.25.1,2.26.0)",
+ org.glassfish.jersey.core.jersey-common;bundle-version="[2.25.1,2.26.0)"
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Bundle-ActivationPolicy: lazy
Export-Package: org.simantics.audit.server
public GENatTableThemeConfiguration(GETreeData treeData, int style) {
super();
+ TextPainter cellTextPainter = new TextPainter();
+ cellTextPainter.setTrimText(false);
this.oddRowBgColor = GUIHelper.getColor(250, 250, 250);
this.defaultCellPainter =
new GEStyler(treeData,
new GEIconPainter(
new PaddingDecorator(
- new TextPainter(),
+ cellTextPainter,
0,
5,
0,
style.setAttributeValue(CellStyleAttributes.IMAGE, image);
wrapper.setSpecificConfigAttribute(CellConfigAttributes.CELL_STYLE, DisplayMode.NORMAL, "BODY", style);
+ wrapper.setSpecificConfigAttribute(CellConfigAttributes.CELL_STYLE, DisplayMode.SELECT, "BODY", style);
+ wrapper.setSpecificConfigAttribute(CellConfigAttributes.CELL_STYLE, DisplayMode.SELECT_HOVER, "BODY", style);
// wrapper.setSpecificConfigAttribute(CellStyleAttributes.FOREGROUND_COLOR, DisplayMode.NORMAL, "BODY", style.getAttributeValue(CellStyleAttributes.FOREGROUND_COLOR));
// wrapper.setSpecificConfigAttribute(CellStyleAttributes.BACKGROUND_COLOR, DisplayMode.NORMAL, "BODY", style.getAttributeValue(CellStyleAttributes.BACKGROUND_COLOR));
// wrapper.setSpecificConfigAttribute(CellStyleAttributes.FONT, DisplayMode.NORMAL, "BODY", style.getAttributeValue(CellStyleAttributes.FONT));
org.eclipse.e4.ui.bindings;bundle-version="0.11.0",
org.eclipse.e4.core.di.annotations,
org.eclipse.e4.core.services,
- com.fasterxml.jackson.core.jackson-core;bundle-version="2.8.2",
+ com.fasterxml.jackson.core.jackson-core;bundle-version="[2.8.11,2.9.0)",
org.slf4j.api
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Bundle-ActivationPolicy: lazy
/*******************************************************************************
- * Copyright (c) 2011 Association for Decentralized Information Management in
- * Industry THTH ry.
+ * Copyright (c) 2011,2020 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
* which accompanies this distribution, and is available at
*
* Contributors:
* VTT Technical Research Centre of Finland - initial API and implementation
+ * Semantum Oy - #501
*******************************************************************************/
package org.simantics.charts.editor;
import org.eclipse.jface.action.IStatusLineManager;
import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.preference.PreferenceDialog;
+import org.eclipse.jface.window.Window;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.FileDialog;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.dialogs.PreferencesUtil;
import org.eclipse.ui.handlers.HandlerUtil;
import org.eclipse.ui.preferences.ScopedPreferenceStore;
import org.simantics.charts.ui.CSVProgressMonitor;
IStatusLineManager status = editor.getEditorSite().getActionBars().getStatusLineManager();
final Shell shell = HandlerUtil.getActiveShell(event);
- final AtomicBoolean result = new AtomicBoolean(false);
+ // Find a good value to use for START_TIME based on the current horizontal ruler
+ // time range and the data start time.
+ IPreferenceStore csvnode = new ScopedPreferenceStore( InstanceScope.INSTANCE, CSVPreferences.P_NODE );
+ double oldStartTime = csvnode.getDouble(CSVPreferences.P_CSV_START_TIME);
+ double timeStep = csvnode.getDouble(CSVPreferences.P_CSV_TIME_STEP);
+ double visibleChartMinTime = trendNode.horizRuler.from;
+ double dataStartTime = trendNode.horizRuler.getItemFromTime();
+ // Find the first sample time that contains data if startTime < _from
+ double n = Math.max(0, Math.ceil((visibleChartMinTime-dataStartTime) / timeStep));
+ double temporaryStartTime = dataStartTime + n*timeStep;
+ csvnode.setValue(CSVPreferences.P_CSV_START_TIME, temporaryStartTime);
+
try {
+ PreferenceDialog dialog = PreferencesUtil.createPreferenceDialogOn(
+ shell, "org.simantics.modeling.csv.preferences",
+ new String[] { "org.simantics.modeling.csv.preferences" },
+ null);
+ dialog.setMessage("Select Used CSV Export Settings");
+ if (dialog.open() != Window.OK)
+ return null;
+
+ AtomicBoolean result = new AtomicBoolean(false);
PlatformUI.getWorkbench().getProgressService().busyCursorWhile(new IRunnableWithProgress() {
@Override
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
ErrorLogger.defaultLogError(e.getCause());
} catch (InterruptedException e) {
ErrorLogger.defaultLogError(e);
+ } finally {
+ csvnode.setValue(CSVPreferences.P_CSV_START_TIME, oldStartTime);
}
return null;
for (TrendItem i : t.spec.items) {
if (i.hidden) continue;
- List<Bean> items = im.search("variableId", i.variableId);
+ List<Bean> items = im.search("groupItemId", i.groupItemId, "variableId", i.variableId);
Collections.sort(items, SamplingFormat.INTERVAL_COMPARATOR);
if (items.isEmpty()) continue;
Bean config = items.get(0);
--- /dev/null
+package org.simantics.charts.editor;
+
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.preference.PreferenceDialog;
+import org.eclipse.jface.window.IShellProvider;
+import org.eclipse.ui.dialogs.PreferencesUtil;
+
+/**
+ * @author Tuukka Lehtonen
+ */
+public class ChartPreferencesAction extends Action {
+
+ private static final String CHART_DEFAULTS_PREF_PAGE_ID = "org.simantics.charts.defaults"; //$NON-NLS-1$
+ private static final String CHART_PREF_PAGE_ID = "org.simantics.charts.pref"; //$NON-NLS-1$
+ private static final String CSV_PREF_PAGE_ID = "org.simantics.modeling.csv.preferences"; //$NON-NLS-1$
+
+ private IShellProvider shell;
+
+ public ChartPreferencesAction(IShellProvider shell) {
+ super(Messages.ChartPreferencesAction_ChartPreferences);
+ this.shell = shell;
+ }
+
+ @Override
+ public void run() {
+ PreferenceDialog dialog = PreferencesUtil.createPreferenceDialogOn(
+ shell.getShell(),
+ CHART_PREF_PAGE_ID,
+ new String[] {
+ CHART_PREF_PAGE_ID,
+ CHART_DEFAULTS_PREF_PAGE_ID,
+ CSV_PREF_PAGE_ID
+ },
+ null);
+ dialog.open();
+ }
+
+}
\ No newline at end of file
--- /dev/null
+package org.simantics.charts.editor;
+
+import org.eclipse.osgi.util.NLS;
+
+public class Messages extends NLS {
+ private static final String BUNDLE_NAME = "org.simantics.charts.editor.messages"; //$NON-NLS-1$
+ public static String ChartPreferencesAction_ChartPreferences;
+ static {
+ // initialize resource bundle
+ NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+ }
+
+ private Messages() {
+ }
+}
if (chartItem != null) {
manager.add(new HideItemsAction("Hide Item", true, Collections.singletonList(chartItem)));
manager.add(new Separator());
+ manager.add(new ChartPreferencesAction(getSite()));
+ manager.add(new Separator());
manager.add(new PropertiesAction("Item Properties", canvas, chartItem));
manager.add(new PropertiesAction("Chart Properties", canvas, chart));
}
manager.add(new SendCommandAction("Zoom to Fit Vertically", IMG_ZOOM_TO_FIT_VERT, cvsCtx, Commands.ZOOM_TO_FIT_VERT));
manager.add(new SendCommandAction("Autoscale Chart", IMG_AUTOSCALE, cvsCtx, Commands.AUTOSCALE));
manager.add(new Separator());
+ manager.add(new ChartPreferencesAction(getSite()));
+ manager.add(new Separator());
manager.add(new PropertiesAction("Chart Properties", canvas, chart));
}
}
--- /dev/null
+ChartPreferencesAction_ChartPreferences=Chart Preferences
labelBuilder.append(")");
}
- List<Bean> historyItems = im.search("variableId", item.variableReference);
+ List<Bean> historyItems = im.search("groupItemId", item.groupItemId, "variableId", item.variableReference);
Collections.sort(historyItems, SamplingFormat.INTERVAL_COMPARATOR);
if (items.isEmpty()) continue;
Bean config = historyItems.get(0);
// Output
@Optional public String subscription = "Default";
- @Optional public String unit = "";
+ @Optional public String unit;
@Optional public Double min, max, deadband, interval, gain, bias;
@Optional public DrawMode drawmode;
@Optional public Scale scale;
public String getHeader() {
return getType() + getRange();
}
+
+ /**
+ * Returns true when no change sets are included.
+ */
+ public boolean isEmpty() {
+ return begin == 0 && end == 0;
+ }
}
import org.simantics.db.common.procedure.wrapper.NoneToAsyncProcedure;
import org.simantics.db.common.request.ReadRequest;
import org.simantics.db.common.request.WriteRequest;
-import org.simantics.db.common.utils.Logger;
import org.simantics.db.exception.CancelTransactionException;
import org.simantics.db.exception.DatabaseException;
import org.simantics.db.procedure.AsyncListener;
import org.simantics.db.request.WriteResult;
import org.simantics.utils.DataContainer;
import org.simantics.utils.datastructures.Pair;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class MergingGraphRequestProcessor implements AsyncRequestProcessor {
+ private static final Logger LOGGER = LoggerFactory.getLogger(MergingGraphRequestProcessor.class);
+
private static class SyncWriteRequestAdapter implements Write {
private Semaphore semaphore = new Semaphore(0);
try {
semaphore.acquire();
} catch (InterruptedException e) {
- Logger.defaultLogError(e);
+ LOGGER.error("SyncWriteRequestAdapter interrupted", e);
}
}
try {
MergingGraphRequestProcessor.this.wait(transactionKeepalivePeriod);
} catch (InterruptedException e) {
- Logger.defaultLogError(e);
+ LOGGER.error("MergedRead interrupted", e);
}
if (requestQueue.isEmpty())
break;
} catch(Throwable t) {
- Logger.defaultLogError(t);
+ LOGGER.error("MergedRead failed", t);
// if(currentRequest.second instanceof AsyncProcedure<?>) {
// ((AsyncProcedure<?>)currentRequest.second).exception(graph, t);
} else {
- try{
+ try {
if(currentRequest.second instanceof AsyncProcedure<?>) {
if(currentRequest.first instanceof AsyncRead) {
} catch(Throwable t) {
- Logger.defaultLogError(t);
+ LOGGER.error("MergedRead failed", t);
// if(currentRequest.second instanceof AsyncProcedure<?>) {
// ((AsyncProcedure<?>)currentRequest.second).exception(graph, t);
try {
MergingGraphRequestProcessor.this.wait(transactionKeepalivePeriod);
} catch (InterruptedException e) {
- Logger.defaultLogError(e);
+ LOGGER.error("RunnerWriteGraphRequest interrupted", e);
}
if (requestQueue.isEmpty())
break;
graph.syncRequest(adapter);
if(callback != null) callback.accept(null);
} catch(Throwable t) {
- Logger.defaultLogError(t);
+ LOGGER.error("RunnerWriteGraphRequest failed", t);
if(callback != null) callback.accept(t);
}
else if(currentRequest.first instanceof DelayedWrite) graph.syncRequest((DelayedWrite)currentRequest.first);
if(callback != null) callback.accept(null);
} catch(Throwable t) {
- Logger.defaultLogError(t);
+ LOGGER.error("RunnerWriteGraphRequest failed", t);
if(callback != null) callback.accept(t);
}
Throwable t = throwable.get();
if(t != null) {
- Logger.defaultLogError(t);
+ LOGGER.error("syncRequest(AsyncMultiRead, AsyncMultiProcedure) failed", t);
throw new RuntimeException(t.getMessage());
}
Throwable t = throwable.get();
if(t != null) {
- Logger.defaultLogError(t);
+ LOGGER.error("syncRequest(AsyncRead, AsyncProcedure) failed", t);
throw new RuntimeException(t.getMessage());
}
@Override
public void exception(Throwable t) {
- Logger.defaultLogError(t);
+ LOGGER.error("asyncRequest(AsyncRead) failed", t);
}
});
Throwable t = throwable.get();
if(t != null) {
- Logger.defaultLogError(t);
+ LOGGER.error("syncRequest(AsyncRead) failed", t);
throw new RuntimeException(t.getMessage());
}
Throwable t = throwable.get();
if(t != null) {
- Logger.defaultLogError(t);
+ LOGGER.error("syncRequest(AsyncMultiRead) failed", t);
throw new RuntimeException(t.getMessage());
}
@Override
public void exception(Throwable t) {
- Logger.defaultLogError(t);
+ LOGGER.error("asyncRequest(Read) failed", t);
}
});
throw new UnsupportedOperationException();
}
+ @Override
+ public <T> T l0() {
+ return processor.l0();
+ }
+
}
public class ProcessorBase implements AsyncRequestProcessor {
+ @Override
+ public <T> T l0() {
+ throw new UnsupportedOperationException();
+ }
+
@Override
public <T> void asyncRequest(AsyncMultiRead<T> request, AsyncMultiProcedure<T> procedure) {
throw new UnsupportedOperationException();
* @author Hannu Niemistö
*/
public class AdaptValue extends ResourceRead<Object> {
-
+
public AdaptValue(Resource resource) {
super(resource);
}
}
};
-
+
@Override
public Object perform(ReadGraph graph) throws DatabaseException {
- String uri = graph.getURI(resource);
- if(Layer0.URIs.Functions_functionApplication.equals(uri)) return functionApplication;
+ Layer0 L0 = graph.l0();
+ if (L0.Functions_functionApplication.equalsResource(resource))
+ return functionApplication;
ComputationalValue ev = graph.adapt(resource, ComputationalValue.class);
return ev.getValue(graph, resource);
-
}
}
}
}
+ /**
+ * Reorders elements with a minimum number of writes. The set of elements must remain the same.
+ */
+ public static void reorder(WriteGraph g, Resource l, Iterable<Resource> order) throws DatabaseException {
+ Resource newPrev = l;
+ for (Resource r : order) {
+ Resource prev = OrderedSetUtils.prev(g, l, r);
+ if (!prev.equals(newPrev)) {
+ g.deny(prev, l, r);
+ g.claim(newPrev, l, r);
+ }
+ newPrev = r;
+ }
+ Resource newLast = newPrev;
+ Resource last = OrderedSetUtils.prev(g, l, l);
+ if (!last.equals(newLast)) {
+ g.deny(last, l, l);
+ g.claim(newLast, l, l);
+ }
+ }
+
/**
* Converts ordered set into a list.
*/
Statement stm = getSingleStatement(resource, relation);
- return adaptContextual(stm.getObject(), new RelationContextImpl(resource, stm), RelationContext.class, clazz);
+ Object o = adaptContextual(stm.getObject(), new RelationContextImpl(resource, stm), RelationContext.class, clazz);
+ if (clazz.isInstance(o))
+ return (T)o;
+ throw new AdaptionException("Returned value is not expected class , got " + o.getClass().getName()+ " , expected " + clazz.getName());
}
try {
- int result = processor.getSingleObject(this, subject, relation);
- if(result == 0) return null;
-
- return processor.querySupport.getResource(result);
+ int result = processor.getSingleObject(this, subject, relation);
+ if(result == 0) return null;
+
+ return processor.querySupport.getResource(result);
- } catch (ManyObjectsForFunctionalRelationException e) {
+ } catch (ManyObjectsForFunctionalRelationException e) {
+
+ throw new ManyObjectsForFunctionalRelationException("Many objects in " + subject + " for functional relation " + relation);
- throw new ManyObjectsForFunctionalRelationException("subject=" + subject + ", relation=" + relation, e);
-
} catch (DatabaseException e) {
throw new ServiceException(e);
else return getTopLevelGraphStatic(impl.parentGraph);
}
+ @SuppressWarnings("unchecked")
+ @Override
+ public <T> T l0() {
+ return (T) processor.getL0();
+ }
+
}
import java.io.IOException;
import java.io.PrintWriter;
import java.io.StringWriter;
+import java.util.IdentityHashMap;
+import java.util.Map;
import java.util.TreeMap;
import java.util.function.Consumer;
import org.simantics.databoard.Bindings;
+import org.simantics.databoard.Datatypes;
import org.simantics.databoard.accessor.Accessor;
import org.simantics.databoard.binding.Binding;
import org.simantics.databoard.binding.error.BindingConstructionException;
import org.simantics.databoard.primitives.MutableString;
import org.simantics.databoard.serialization.SerializationException;
import org.simantics.databoard.serialization.Serializer;
+import org.simantics.databoard.type.ArrayType;
+import org.simantics.databoard.type.BooleanType;
+import org.simantics.databoard.type.ByteType;
import org.simantics.databoard.type.Datatype;
+import org.simantics.databoard.type.DoubleType;
+import org.simantics.databoard.type.FloatType;
+import org.simantics.databoard.type.IntegerType;
+import org.simantics.databoard.type.LongType;
+import org.simantics.databoard.type.StringType;
+import org.simantics.databoard.type.VariantType;
import org.simantics.databoard.util.binary.RandomAccessBinary;
import org.simantics.db.DevelopmentKeys;
import org.simantics.db.ExternalValueSupport;
import org.simantics.utils.Development;
import org.simantics.utils.datastructures.Pair;
-import gnu.trove.map.hash.THashMap;
-
final public class WriteGraphImpl extends ReadGraphImpl implements WriteGraph {
}
- THashMap<Class<?>, Resource> builtinValues = new THashMap<Class<?>, Resource>(32);
+ Map<Object, Resource> builtinValues = new IdentityHashMap<>(40);
private void initBuiltinValues(Layer0 b) {
builtinValues.put(MutableByte.class, b.Byte);
builtinValues.put(MutableBoolean.class, b.Boolean);
+ builtinValues.put(Datatypes.DOUBLE, b.Double);
+ builtinValues.put(Datatypes.STRING, b.String);
+ builtinValues.put(Datatypes.INTEGER, b.Integer);
+ builtinValues.put(Datatypes.LONG, b.Long);
+ builtinValues.put(Datatypes.FLOAT, b.Float);
+ builtinValues.put(Datatypes.BYTE, b.Byte);
+ builtinValues.put(Datatypes.BOOLEAN, b.Boolean);
+ builtinValues.put(Datatypes.VARIANT, b.Variant);
+
+ builtinValues.put(Datatypes.DOUBLE_ARRAY, b.DoubleArray);
+ builtinValues.put(Datatypes.STRING_ARRAY, b.StringArray);
+ builtinValues.put(Datatypes.INTEGER_ARRAY, b.IntegerArray);
+ builtinValues.put(Datatypes.LONG_ARRAY, b.LongArray);
+ builtinValues.put(Datatypes.FLOAT_ARRAY, b.FloatArray);
+ builtinValues.put(Datatypes.BYTE_ARRAY, b.ByteArray);
+ builtinValues.put(Datatypes.BOOLEAN_ARRAY, b.BooleanArray);
+ builtinValues.put(Datatypes.VARIANT_ARRAY, b.VariantArray);
+ }
+
+ private static Datatype canonicalizeToBuiltinDatatype(Datatype datatype) {
+ if (datatype instanceof ArrayType) {
+ ArrayType at = (ArrayType) datatype;
+ datatype = at.componentType();
+ if (datatype instanceof ByteType) {
+ return Datatypes.BYTE_ARRAY;
+ } else if (datatype instanceof DoubleType) {
+ return Datatypes.DOUBLE_ARRAY;
+ } else if (datatype instanceof FloatType) {
+ return Datatypes.FLOAT_ARRAY;
+ } else if (datatype instanceof IntegerType) {
+ return Datatypes.INTEGER_ARRAY;
+ } else if (datatype instanceof LongType) {
+ return Datatypes.LONG_ARRAY;
+ } else if (datatype instanceof BooleanType) {
+ return Datatypes.BOOLEAN_ARRAY;
+ } else if (datatype instanceof StringType) {
+ return Datatypes.STRING_ARRAY;
+ } else if (datatype instanceof VariantType) {
+ return Datatypes.VARIANT_ARRAY;
+ }
+ return null;
+ }
+ if (datatype instanceof ByteType) {
+ return Datatypes.BYTE;
+ } else if (datatype instanceof DoubleType) {
+ return Datatypes.DOUBLE;
+ } else if (datatype instanceof FloatType) {
+ return Datatypes.FLOAT;
+ } else if (datatype instanceof IntegerType) {
+ return Datatypes.INTEGER;
+ } else if (datatype instanceof LongType) {
+ return Datatypes.LONG;
+ } else if (datatype instanceof BooleanType) {
+ return Datatypes.BOOLEAN;
+ } else if (datatype instanceof StringType) {
+ return Datatypes.STRING;
+ } else if (datatype instanceof VariantType) {
+ return Datatypes.VARIANT;
+ }
+ return null;
+ }
+
+ private Resource resolveBuiltinResourceType(Class<?> valueClass, Datatype datatype) {
+ Resource type = builtinValues.get(valueClass);
+ return type != null ? type : builtinValues.get(datatype);
+ }
+
+ private Resource resolveBuiltinResourceTypeByCanonicalizedDatatype(Datatype datatype, Resource defaultResult) {
+ Datatype cdt = canonicalizeToBuiltinDatatype(datatype);
+ return cdt != null ? builtinValues.get(cdt) : defaultResult;
}
@Override
initBuiltinValues(b);
Resource literal = newResource();
- Class<?> clazz = value.getClass();
- Resource type = builtinValues.get(clazz);
+ Datatype dt = binding.type();
+ Resource type = resolveBuiltinResourceType(value.getClass(), dt);
if (type == null) {
- type = b.Literal;
+ type = resolveBuiltinResourceTypeByCanonicalizedDatatype(dt, b.Literal);
Resource dataType = newResource();
claim(dataType, b.InstanceOf, null, b.DataType);
- claimValue(dataType, binding.type(), DATA_TYPE_BINDING);
+ claimValue(dataType, dt, DATA_TYPE_BINDING);
claim(literal, b.HasDataType, b.HasDataType_Inverse, dataType);
}
} else {
- Class<?> clazz = value.getClass();
- Resource type = builtinValues.get(clazz);
Resource literal = newResource();
+ Datatype dt = binding.type();
+ Resource type = resolveBuiltinResourceType(value.getClass(), dt);
if (type == null) {
- type = b.Literal;
+ type = resolveBuiltinResourceTypeByCanonicalizedDatatype(dt, b.Literal);
Resource dataType = newResource();
claim(dataType, b.InstanceOf, null, b.DataType);
- claimValue(dataType, binding.type(), DATA_TYPE_BINDING);
+ claimValue(dataType, dt, DATA_TYPE_BINDING);
claim(literal, b.HasDataType, null, dataType);
}
claim(literal, b.InstanceOf, null, type);
public final class Objects extends CollectionBinaryQuery<IntProcedure> implements IntProcedure {
- public Objects(final int r1, final int r2) {
- super(r1, r2);
- }
-
- @Override
- final public void removeEntry(QueryProcessor provider) {
- provider.cache.remove(this);
- }
-
- final static private IntArray getAssertionMap(ReadGraphImpl graph, final int r1, final int r2, final Objects entry) throws DatabaseException {
-
- class AssertionMapProc implements IntProcedure {
-
- boolean first = true;
-
- private IntArray result;
-
- public void addStatement(int s, int p, int o) {
-
- if(result.size() == 0) {
- result.add(s);
- result.add(p);
- result.add(o);
- } else {
- for(int i = 0;i < result.sizeOrData ; i+=3) {
- int existingP = result.data[i+1];
- if(p == existingP) {
- int existingO = result.data[i+2];
- if(existingO == o) return;
- }
- }
- result.add(s);
- result.add(p);
- result.add(o);
- }
-
- }
-
- @Override
- public void execute(ReadGraphImpl graph, int type) throws DatabaseException {
- if(result == null) {
- result = QueryCacheBase.resultAssertedStatements(graph, type, r2, entry, null);
- } else {
- if (first) {
- IntArray ia = result;
- result = new IntArray();
- if(ia.data != null) {
- for(int i = 0;i < ia.sizeOrData ; i+=3) addStatement(ia.data[i],ia.data[i+1],ia.data[i+2]);
- }
- first = false;
- }
- IntArray ia = QueryCacheBase.resultAssertedStatements(graph, type, r2, entry, null);
- if(ia.data != null) {
- for(int i = 0;i < ia.sizeOrData ; i+=3) addStatement(ia.data[i],ia.data[i+1],ia.data[i+2]);
- }
- }
- }
+ public Objects(final int r1, final int r2) {
+ super(r1, r2);
+ }
- @Override
- public void finished(ReadGraphImpl graph) {
- }
+ @Override
+ final public void removeEntry(QueryProcessor provider) {
+ provider.cache.remove(this);
+ }
- @Override
- public void exception(ReadGraphImpl graph, Throwable throwable) {
- }
+ final static private IntArray getAssertionMap(ReadGraphImpl graph, final int r1, final int r2, final Objects entry) throws DatabaseException {
+
+ class AssertionMapProc implements IntProcedure {
+
+ boolean first = true;
+
+ private IntArray result;
+
+ public void addStatement(int s, int p, int o) {
+
+ if(result.size() == 0) {
+ result.add(s);
+ result.add(p);
+ result.add(o);
+ } else {
+ for(int i = 0;i < result.sizeOrData ; i+=3) {
+ int existingP = result.data[i+1];
+ if(p == existingP) {
+ int existingO = result.data[i+2];
+ if(existingO == o) return;
+ }
+ }
+ result.add(s);
+ result.add(p);
+ result.add(o);
+ }
+
+ }
+
+ @Override
+ public void execute(ReadGraphImpl graph, int type) throws DatabaseException {
+ if(result == null) {
+ result = QueryCacheBase.resultAssertedStatements(graph, type, r2, entry, null);
+ } else {
+ if (first) {
+ IntArray ia = result;
+ result = new IntArray();
+ if(ia.data != null) {
+ for(int i = 0;i < ia.sizeOrData ; i+=3) addStatement(ia.data[i],ia.data[i+1],ia.data[i+2]);
+ }
+ first = false;
+ }
+ IntArray ia = QueryCacheBase.resultAssertedStatements(graph, type, r2, entry, null);
+ if(ia.data != null) {
+ for(int i = 0;i < ia.sizeOrData ; i+=3) addStatement(ia.data[i],ia.data[i+1],ia.data[i+2]);
+ }
+ }
+ }
+
+ @Override
+ public void finished(ReadGraphImpl graph) {
+ }
+
+ @Override
+ public void exception(ReadGraphImpl graph, Throwable throwable) {
+ }
- }
+ }
- AssertionMapProc amp = new AssertionMapProc();
+ AssertionMapProc amp = new AssertionMapProc();
- // This dependency could be cut
- QueryCache.runnerPrincipalTypes(graph, r1, entry, null, amp);
+ // This dependency could be cut
+ QueryCache.runnerPrincipalTypes(graph, r1, entry, null, amp);
- return amp.result;
+ return amp.result;
- }
+ }
- final static private void forSingleAssertion(ReadGraphImpl graph, final int r1, final int r2, final Objects parent, final IntProcedure procedure) throws DatabaseException {
+ final static private void forSingleAssertion(ReadGraphImpl graph, final int r1, final int r2, final Objects parent, final IntProcedure procedure) throws DatabaseException {
- IntArray map = getAssertionMap(graph, r1, r2, parent);
- if(map == null) {
- procedure.finished(graph);
- return;
- }
+ IntArray map = getAssertionMap(graph, r1, r2, parent);
+ if(map == null) {
+ procedure.finished(graph);
+ return;
+ }
- int size = map.size();
- if(size == 3) {
- int value = map.data[2];
- procedure.execute(graph, value);
- procedure.finished(graph);
- } else if(size == 0) {
- procedure.finished(graph);
- } else {
+ int size = map.size();
+ if(size == 3) {
+ int value = map.data[2];
+ procedure.execute(graph, value);
+ procedure.finished(graph);
+ } else if(size == 0) {
+ procedure.finished(graph);
+ } else {
- int candidateS = map.data[0];
- int candidateO = map.data[2];
+ int candidateS = map.data[0];
+ int candidateO = map.data[2];
- IntSet candidateIs = null;
- try {
- candidateIs = QueryCache.resultSuperTypes(graph, candidateS, parent, null);
- } catch (DatabaseException e) {
- procedure.exception(graph, e);
- return;
- }
+ IntSet candidateIs = null;
+ try {
+ candidateIs = QueryCache.resultSuperTypes(graph, candidateS, parent, null);
+ } catch (DatabaseException e) {
+ procedure.exception(graph, e);
+ return;
+ }
- for(int i=3;i<map.size();i+=3) {
+ for(int i=3;i<map.size();i+=3) {
- int nextS = map.data[i];
- int nextO = map.data[i+2];
+ int nextS = map.data[i];
+ int nextO = map.data[i+2];
- if(nextS != candidateS) {
+ if(nextS != candidateS) {
- if(candidateIs.contains(nextS)) {
+ if(candidateIs.contains(nextS)) {
- // Next is a super type of candidate => ignore next
+ // Next is a super type of candidate => ignore next
- } else {
+ } else {
- IntSet nextIs = null;
- try {
- nextIs = QueryCache.resultSuperTypes(graph, nextS, parent, null);
- } catch (DatabaseException e) {
- procedure.exception(graph, e);
- return;
- }
+ IntSet nextIs = null;
+ try {
+ nextIs = QueryCache.resultSuperTypes(graph, nextS, parent, null);
+ } catch (DatabaseException e) {
+ procedure.exception(graph, e);
+ return;
+ }
- if(nextIs.contains(candidateS)) {
+ if(nextIs.contains(candidateS)) {
- // Candidate is a super type of next => next is the new candidate
+ // Candidate is a super type of next => next is the new candidate
- candidateS = nextS;
- candidateO = nextO;
- candidateIs = nextIs;
+ candidateS = nextS;
+ candidateO = nextO;
+ candidateIs = nextIs;
- } else {
+ } else {
- // candidate and next are unrelated => error
- ManyObjectsForFunctionalRelationException exception = new ManyObjectsForFunctionalRelationException("Functional relation has conflicting assertions " + r1 + ", " + r2 + " " + map , r1);
- procedure.exception(graph, exception);
- return;
+ // candidate and next are unrelated => error
+ ManyObjectsForFunctionalRelationException exception = new ManyObjectsForFunctionalRelationException("Functional relation has conflicting assertions " + r1 + ", " + r2 + " " + map , r1);
+ procedure.exception(graph, exception);
+ return;
- }
+ }
- }
+ }
- }
+ }
- }
+ }
- procedure.execute(graph, candidateO);
- procedure.finished(graph);
+ procedure.execute(graph, candidateO);
+ procedure.finished(graph);
- }
+ }
- }
+ }
- final static InternalProcedure<IntSet> NOP = new InternalProcedure<IntSet>() {
+ final static InternalProcedure<IntSet> NOP = new InternalProcedure<IntSet>() {
- @Override
- public void execute(ReadGraphImpl graph, IntSet result) {
- }
+ @Override
+ public void execute(ReadGraphImpl graph, IntSet result) {
+ }
- @Override
- public void exception(ReadGraphImpl graph, Throwable throwable) {
- }
+ @Override
+ public void exception(ReadGraphImpl graph, Throwable throwable) {
+ }
- };
+ };
- final static TripleIntProcedure NOPT = new TripleIntProcedure() {
+ final static TripleIntProcedure NOPT = new TripleIntProcedure() {
- @Override
- public void exception(ReadGraphImpl graph, Throwable throwable) {
- }
+ @Override
+ public void exception(ReadGraphImpl graph, Throwable throwable) {
+ }
- @Override
- public void execute(ReadGraphImpl graph, int s, int p, int o) {
- }
+ @Override
+ public void execute(ReadGraphImpl graph, int s, int p, int o) {
+ }
- @Override
- public void finished(ReadGraphImpl graph) {
- }
+ @Override
+ public void finished(ReadGraphImpl graph) {
+ }
- };
+ };
- // Search for one statement
- final public void computeFunctionalIndex(ReadGraphImpl graph, final QueryProcessor provider, final RelationInfo ri, final IntProcedure procedure) throws DatabaseException {
- computeFunctionalIndex(graph, r1(), r2(), this, ri, procedure);
- }
+ // Search for one statement
+ final public void computeFunctionalIndex(ReadGraphImpl graph, final QueryProcessor provider, final RelationInfo ri, final IntProcedure procedure) throws DatabaseException {
+ computeFunctionalIndex(graph, r1(), r2(), this, ri, procedure);
+ }
- // Search for one statement
- final static public void computeFunctionalIndex(ReadGraphImpl graph, final int r1, final int r2, final Objects parent, final RelationInfo ri, final IntProcedure procedure) throws DatabaseException {
+ // Search for one statement
+ final static public void computeFunctionalIndex(ReadGraphImpl graph, final int r1, final int r2, final Objects parent, final RelationInfo ri, final IntProcedure procedure) throws DatabaseException {
- if(ri.isFinal) {
+ if(ri.isFinal) {
- int result = graph.processor.querySupport.getFunctionalObject(r1, r2);
+ int result = graph.processor.querySupport.getFunctionalObject(r1, r2);
- if(result == 0) {
+ if(result == 0) {
- // Check for assertions
- forSingleAssertion(graph, r1, r2, parent, procedure);
+ // Check for assertions
+ forSingleAssertion(graph, r1, r2, parent, procedure);
- } else if (result == -1) {
+ } else if (result == -1) {
- graph.processor.querySupport.getObjects(graph, r1, r2, new IntProcedure() {
+ graph.processor.querySupport.getObjects(graph, r1, r2, new IntProcedure() {
- @Override
- public void execute(ReadGraphImpl graph, int i) throws DatabaseException {
- procedure.execute(graph, i);
- }
+ @Override
+ public void execute(ReadGraphImpl graph, int i) throws DatabaseException {
+ procedure.execute(graph, i);
+ }
- @Override
- public void exception(ReadGraphImpl graph, Throwable t) {
- if(DebugException.DEBUG) new DebugException(t).printStackTrace();
- }
+ @Override
+ public void exception(ReadGraphImpl graph, Throwable t) {
+ if(DebugException.DEBUG) new DebugException(t).printStackTrace();
+ }
- @Override
- public void finished(ReadGraphImpl graph) {
- }
+ @Override
+ public void finished(ReadGraphImpl graph) {
+ }
- });
+ });
- // Check for assertions
- forSingleAssertion(graph, r1, r2, parent, procedure);
+ // Check for assertions
+ forSingleAssertion(graph, r1, r2, parent, procedure);
- } else {
+ } else {
- // If functional relation was found there is no need to check assertions
+ // If functional relation was found there is no need to check assertions
procedure.execute(graph, result);
procedure.finished(graph);
-
- }
+ }
- } else {
+ } else {
- // Note! The dependency is intentionally cut!
+ // Note! The dependency is intentionally cut!
IntSet direct = QueryCache.resultDirectPredicates(graph, r1, null, null);
direct.forEach(graph, new SyncIntProcedure() {
- boolean found = false;
-
- @Override
- public void run(ReadGraphImpl graph) throws DatabaseException {
-
- if(found) {
- procedure.finished(graph);
- } else {
+ /*
+ * 0 = not found
+ * 1 = found
+ * 2 = exception
+ */
+ int found = 0;
- // Check for assertions
- forSingleAssertion(graph, r1, r2, parent, procedure);
+ @Override
+ public void run(ReadGraphImpl graph) throws DatabaseException {
- }
+ if(found == 1) {
- }
+ procedure.finished(graph);
- @Override
- public void execute(ReadGraphImpl graph, final int pred) throws DatabaseException {
+ } else if(found == 0) {
- if(found) return;
+ // Check for assertions
+ forSingleAssertion(graph, r1, r2, parent, procedure);
- if(pred == r2) {
+ }
- // Note! The dependency is intentionally cut!
- QueryCache.runnerDirectObjects(graph, r1, pred, null, null, new IntProcedure() {
+ }
- @Override
- public void execute(ReadGraphImpl graph, int i) throws DatabaseException {
+ @Override
+ public void execute(ReadGraphImpl graph, final int pred) throws DatabaseException {
- if(!found) {
+ if(found > 0)
+ return;
- procedure.execute(graph, i);
- found = true;
+ if(pred == r2) {
- } else {
+ // Note! The dependency is intentionally cut!
+ QueryCache.runnerDirectObjects(graph, r1, pred, null, null, new IntProcedure() {
- ManyObjectsForFunctionalRelationException exception = new ManyObjectsForFunctionalRelationException("Functional relation has more than one statement (r1=" + r1 + ", r2=" + r2 + ").", r1);
- procedure.exception(graph, exception);
+ @Override
+ public void execute(ReadGraphImpl graph, int i) throws DatabaseException {
- }
+ if(found == 0) {
- }
+ procedure.execute(graph, i);
+ found = 1;
- @Override
- public void finished(ReadGraphImpl graph) {
- }
+ } else {
- @Override
- public void exception(ReadGraphImpl graph, Throwable t) throws DatabaseException {
- procedure.exception(graph, t);
- }
+ ManyObjectsForFunctionalRelationException exception = new ManyObjectsForFunctionalRelationException("Functional relation has more than one statement (r1=" + r1 + ", r2=" + r2 + ").", r1);
+ procedure.exception(graph, exception);
+ found = 2;
- });
+ }
- } else {
+ }
- QueryCache.runnerSuperRelations(graph, pred, parent, null, new InternalProcedure<IntSet>() {
+ @Override
+ public void finished(ReadGraphImpl graph) {
+ }
- @Override
- public void execute(ReadGraphImpl graph, IntSet result) throws DatabaseException {
+ @Override
+ public void exception(ReadGraphImpl graph, Throwable t) throws DatabaseException {
- if(found) return;
+ procedure.exception(graph, t);
+ found = 2;
- if(result.contains(r2)) {
+ }
- // Note! The dependency is intentionally cut!
- QueryCache.runnerDirectObjects(graph, r1, pred, null, null, new IntProcedure() {
+ });
- @Override
- public void execute(ReadGraphImpl graph, int i) throws DatabaseException {
+ } else {
- if(!found) {
+ QueryCache.runnerSuperRelations(graph, pred, parent, null, new InternalProcedure<IntSet>() {
- procedure.execute(graph, i);
- found = true;
+ @Override
+ public void execute(ReadGraphImpl graph, IntSet result) throws DatabaseException {
- } else {
+ if(found > 0)
+ return;
- ManyObjectsForFunctionalRelationException exception = new ManyObjectsForFunctionalRelationException("Functional relation has more than one statement (r1=" + r1 + ", r2=" + r2 + ").", r1);
- procedure.exception(graph, exception);
+ if(result.contains(r2)) {
- }
+ // Note! The dependency is intentionally cut!
+ QueryCache.runnerDirectObjects(graph, r1, pred, null, null, new IntProcedure() {
- }
+ @Override
+ public void execute(ReadGraphImpl graph, int i) throws DatabaseException {
- @Override
- public void finished(ReadGraphImpl graph) {
- }
+ if(found == 0) {
- @Override
- public void exception(ReadGraphImpl graph, Throwable t) throws DatabaseException {
- procedure.exception(graph, t);
- }
+ procedure.execute(graph, i);
+ found = 1;
- });
+ } else {
- }
+ ManyObjectsForFunctionalRelationException exception = new ManyObjectsForFunctionalRelationException("Functional relation has more than one statement (r1=" + r1 + ", r2=" + r2 + ").", r1);
+ procedure.exception(graph, exception);
+ found = 2;
- }
+ }
- @Override
- public void exception(ReadGraphImpl graph, Throwable t) throws DatabaseException {
- procedure.exception(graph, t);
- }
+ }
- });
+ @Override
+ public void finished(ReadGraphImpl graph) {
+ }
- }
+ @Override
+ public void exception(ReadGraphImpl graph, Throwable t) throws DatabaseException {
+ procedure.exception(graph, t);
+ found = 2;
+ }
- }
+ });
- @Override
- public void finished(ReadGraphImpl graph) throws DatabaseException {
+ }
- dec(graph);
+ }
- }
+ @Override
+ public void exception(ReadGraphImpl graph, Throwable t) throws DatabaseException {
+ procedure.exception(graph, t);
+ found = 2;
+ }
- });
+ });
+ }
- }
+ }
- }
+ @Override
+ public void finished(ReadGraphImpl graph) throws DatabaseException {
+ dec(graph);
+ }
- final static private void forAssertions(ReadGraphImpl graph, final int r1, final int r2, final Objects parent, final IntProcedure procedure) throws DatabaseException {
+ });
- // Note! The dependency is intentionally cut!
- QueryCache.runnerPrincipalTypes(graph, r1, null, null, new SyncIntProcedure() {
- @Override
- public void run(ReadGraphImpl graph) throws DatabaseException {
- procedure.finished(graph);
- }
-
- TripleIntProcedure proc = new TripleIntProcedure() {
+ }
- @Override
- public void execute(ReadGraphImpl graph, int s, int p, int o) throws DatabaseException {
- procedure.execute(graph, o);
- }
+ }
- @Override
- public void finished(ReadGraphImpl graph) throws DatabaseException {
- dec(graph);
- }
+ final static private void forAssertions(ReadGraphImpl graph, final int r1, final int r2, final Objects parent, final IntProcedure procedure) throws DatabaseException {
- @Override
- public void exception(ReadGraphImpl graph, Throwable t) throws DatabaseException {
- if(DebugException.DEBUG) new DebugException(t).printStackTrace();
- procedure.exception(graph, t);
- dec(graph);
- }
+ // Note! The dependency is intentionally cut!
+ QueryCache.runnerPrincipalTypes(graph, r1, null, null, new SyncIntProcedure() {
- };
+ @Override
+ public void run(ReadGraphImpl graph) throws DatabaseException {
+ procedure.finished(graph);
+ }
- @Override
- public void execute(ReadGraphImpl graph, int type) throws DatabaseException {
+ TripleIntProcedure proc = new TripleIntProcedure() {
- inc();
- QueryCache.runnerAssertedStatements(graph, type, r2, parent, null, proc);
+ @Override
+ public void execute(ReadGraphImpl graph, int s, int p, int o) throws DatabaseException {
+ procedure.execute(graph, o);
+ }
- }
+ @Override
+ public void finished(ReadGraphImpl graph) throws DatabaseException {
+ dec(graph);
+ }
- @Override
- public void finished(ReadGraphImpl graph) throws DatabaseException {
- dec(graph);
- }
+ @Override
+ public void exception(ReadGraphImpl graph, Throwable t) throws DatabaseException {
+ if(DebugException.DEBUG) new DebugException(t).printStackTrace();
+ procedure.exception(graph, t);
+ dec(graph);
+ }
- });
+ };
+ @Override
+ public void execute(ReadGraphImpl graph, int type) throws DatabaseException {
- }
+ inc();
+ QueryCache.runnerAssertedStatements(graph, type, r2, parent, null, proc);
- final public static void computeNotFunctionalFinalIndex(ReadGraphImpl graph, final int r1, final int r2, final QueryProcessor provider, RelationInfo ri, AsyncMultiProcedure<Resource> procedure) {
- throw new Error();
- }
+ }
- final public void computeNotFunctionalIndex(ReadGraphImpl graph, RelationInfo ri, final IntProcedure procedure) throws DatabaseException {
- computeNotFunctionalIndex(graph, r1(), r2(), this, ri, procedure);
- }
+ @Override
+ public void finished(ReadGraphImpl graph) throws DatabaseException {
+ dec(graph);
+ }
- final static public void computeNotFunctionalIndex(ReadGraphImpl graph, final int r1, final int r2, final Objects parent, RelationInfo ri, final IntProcedure procedure) throws DatabaseException {
+ });
- if(ri.isFinal) {
- graph.processor.querySupport.getObjects(graph, r1, r2, new IntProcedure() {
+ }
- @Override
- public void execute(ReadGraphImpl graph, int i) throws DatabaseException {
- procedure.execute(graph, i);
- }
+ final public static void computeNotFunctionalFinalIndex(ReadGraphImpl graph, final int r1, final int r2, final QueryProcessor provider, RelationInfo ri, AsyncMultiProcedure<Resource> procedure) {
+ throw new Error();
+ }
- @Override
- public void exception(ReadGraphImpl graph, Throwable t) throws DatabaseException {
- if(DebugException.DEBUG) new DebugException(t).printStackTrace();
- procedure.exception(graph, t);
- }
+ final public void computeNotFunctionalIndex(ReadGraphImpl graph, RelationInfo ri, final IntProcedure procedure) throws DatabaseException {
+ computeNotFunctionalIndex(graph, r1(), r2(), this, ri, procedure);
+ }
- @Override
- public void finished(ReadGraphImpl graph) {
- }
+ final static public void computeNotFunctionalIndex(ReadGraphImpl graph, final int r1, final int r2, final Objects parent, RelationInfo ri, final IntProcedure procedure) throws DatabaseException {
- });
+ if(ri.isFinal) {
- if(ri.isAsserted) {
- forAssertions(graph, r1, r2, parent, procedure);
- } else {
- procedure.finished(graph);
- }
+ graph.processor.querySupport.getObjects(graph, r1, r2, new IntProcedure() {
- } else {
+ @Override
+ public void execute(ReadGraphImpl graph, int i) throws DatabaseException {
+ procedure.execute(graph, i);
+ }
- // Note! The dependency is intentionally cut!
- IntSet direct = QueryCache.resultDirectPredicates(graph, r1, null, null);
- direct.forEach(graph, new SyncIntProcedure() {
+ @Override
+ public void exception(ReadGraphImpl graph, Throwable t) throws DatabaseException {
+ if(DebugException.DEBUG) new DebugException(t).printStackTrace();
+ procedure.exception(graph, t);
+ }
- @Override
- public void run(ReadGraphImpl graph) throws DatabaseException {
- forAssertions(graph, r1, r2, parent, procedure);
- }
+ @Override
+ public void finished(ReadGraphImpl graph) {
+ }
- @Override
- public void execute(ReadGraphImpl graph, final int pred) throws DatabaseException {
+ });
- if(pred == r2) {
+ if(ri.isAsserted) {
+ forAssertions(graph, r1, r2, parent, procedure);
+ } else {
+ procedure.finished(graph);
+ }
- inc();
+ } else {
- // Note! The dependency is intentionally cut!
- QueryCache.runnerDirectObjects(graph, r1, pred, null, null, new IntProcedure() {
+ // Note! The dependency is intentionally cut!
+ IntSet direct = QueryCache.resultDirectPredicates(graph, r1, null, null);
+ direct.forEach(graph, new SyncIntProcedure() {
- @Override
- public void execute(ReadGraphImpl graph, int i) throws DatabaseException {
- procedure.execute(graph, i);
- }
+ @Override
+ public void run(ReadGraphImpl graph) throws DatabaseException {
+ forAssertions(graph, r1, r2, parent, procedure);
+ }
- @Override
- public void finished(ReadGraphImpl graph) throws DatabaseException {
- dec(graph);
- }
+ @Override
+ public void execute(ReadGraphImpl graph, final int pred) throws DatabaseException {
- @Override
- public void exception(ReadGraphImpl graph, Throwable t) throws DatabaseException {
- procedure.exception(graph, t);
- dec(graph);
- }
+ if(pred == r2) {
- });
+ // Note! The dependency is intentionally cut!
+ QueryCache.runnerDirectObjects(graph, r1, pred, null, null, new IntProcedure() {
- } else {
+ @Override
+ public void execute(ReadGraphImpl graph, int i) throws DatabaseException {
+ procedure.execute(graph, i);
+ }
- inc();
+ @Override
+ public void finished(ReadGraphImpl graph) throws DatabaseException {
+ }
- QueryCache.runnerSuperRelations(graph, pred, parent, null, new InternalProcedure<IntSet>() {
+ @Override
+ public void exception(ReadGraphImpl graph, Throwable t) throws DatabaseException {
+ procedure.exception(graph, t);
+ }
- @Override
- public void execute(ReadGraphImpl graph, IntSet result) throws DatabaseException {
+ });
- if(result.contains(r2)) {
+ } else {
- inc();
+ try {
- // Note! The dependency is intentionally cut!
- QueryCache.runnerDirectObjects(graph, r1, pred, null, null, new IntProcedure() {
+ IntSet result = QueryCache.resultSuperRelations(graph, pred, parent, null);
+ if(result.contains(r2)) {
- @Override
- public void execute(ReadGraphImpl graph, int i) throws DatabaseException {
- procedure.execute(graph, i);
- }
+ inc();
- @Override
- public void finished(ReadGraphImpl graph) throws DatabaseException {
- dec(graph);
- }
+ // Note! The dependency is intentionally cut!
+ QueryCache.runnerDirectObjects(graph, r1, pred, null, null, new IntProcedure() {
- @Override
- public void exception(ReadGraphImpl graph, Throwable t) throws DatabaseException {
- if(DebugException.DEBUG) new DebugException(t).printStackTrace();
- procedure.exception(graph, t);
- dec(graph);
- }
+ @Override
+ public void execute(ReadGraphImpl graph, int i) throws DatabaseException {
+ procedure.execute(graph, i);
+ }
- });
+ @Override
+ public void finished(ReadGraphImpl graph) throws DatabaseException {
+ dec(graph);
+ }
- }
+ @Override
+ public void exception(ReadGraphImpl graph, Throwable t) throws DatabaseException {
+ if(DebugException.DEBUG) new DebugException(t).printStackTrace();
+ procedure.exception(graph, t);
+ dec(graph);
+ }
- dec(graph);
+ });
- }
+ }
- @Override
- public void exception(ReadGraphImpl graph, Throwable t) throws DatabaseException {
- procedure.exception(graph, t);
- dec(graph);
- }
+ } catch (Throwable e) {
+ procedure.exception(graph, e);
+ }
- });
+ }
- }
+ }
- }
+ @Override
+ public void finished(ReadGraphImpl graph) throws DatabaseException {
+ dec(graph);
+ }
- @Override
- public void finished(ReadGraphImpl graph) throws DatabaseException {
- dec(graph);
- }
+ });
- });
+ }
- }
+ }
- }
+ public Object compute(ReadGraphImpl graph, final IntProcedure procedure) throws DatabaseException {
+ computeForEach(graph, r1(), r2(), this, procedure);
+ return getResult();
+ }
- public Object compute(ReadGraphImpl graph, final IntProcedure procedure) throws DatabaseException {
- computeForEach(graph, r1(), r2(), this, procedure);
- return getResult();
- }
+ public static void computeForEach(ReadGraphImpl graph, final int r1, final int r2, final Objects entry, final IntProcedure procedure_) throws DatabaseException {
- public static void computeForEach(ReadGraphImpl graph, final int r1, final int r2, final Objects entry, final IntProcedure procedure_) throws DatabaseException {
+ IntProcedure procedure = entry != null ? entry : procedure_;
- IntProcedure procedure = entry != null ? entry : procedure_;
-
RelationInfo ri = QueryCache.resultRelationInfoQuery(graph, r2, entry, null);
graph.ensureLoaded(r1, r2);
if(ri.isFunctional) {
} else {
computeNotFunctionalIndex(graph, r1, r2, entry, ri, procedure);
}
-
- if(entry != null) entry.performFromCache(graph, procedure_);
- }
+ if(entry != null) entry.performFromCache(graph, procedure_);
- @Override
- public String toString() {
- return "Objects[" + r1() + " - " + r2() + "]";
- }
+ }
- @Override
- public Object performFromCache(ReadGraphImpl graph, final IntProcedure procedure) throws DatabaseException {
+ @Override
+ public String toString() {
+ return "Objects[" + r1() + " - " + r2() + "]";
+ }
- assert(isReady());
+ @Override
+ public Object performFromCache(ReadGraphImpl graph, final IntProcedure procedure) throws DatabaseException {
- if(handleException(graph, procedure)) return getResult();
+ assert(isReady());
- final IntArray value = (IntArray)getResult();
- if(value.data == null) {
- if(value.sizeOrData != IntArray.NO_DATA) procedure.execute(graph, value.sizeOrData);
- } else {
- for(int i = 0;i < value.sizeOrData ; i++) procedure.execute(graph, value.data[i]);
- }
+ if(handleException(graph, procedure)) return getResult();
- procedure.finished(graph);
-
- return value;
+ final IntArray value = (IntArray)getResult();
+ if(value.data == null) {
+ if(value.sizeOrData != IntArray.NO_DATA) procedure.execute(graph, value.sizeOrData);
+ } else {
+ for(int i = 0;i < value.sizeOrData ; i++) procedure.execute(graph, value.data[i]);
+ }
+
+ procedure.finished(graph);
- }
+ return value;
- @Override
- public void recompute(ReadGraphImpl graph) throws DatabaseException {
+ }
- compute(graph, new IntProcedureAdapter() {
+ @Override
+ public void recompute(ReadGraphImpl graph) throws DatabaseException {
- @Override
- public void finished(ReadGraphImpl graph) {
- }
+ compute(graph, new IntProcedureAdapter() {
- @Override
- public void exception(ReadGraphImpl graph, Throwable t) {
- new Error("Error in recompute.", t).printStackTrace();
- }
+ @Override
+ public void finished(ReadGraphImpl graph) {
+ }
- });
+ @Override
+ public void exception(ReadGraphImpl graph, Throwable t) {
+ new Error("Error in recompute.", t).printStackTrace();
+ }
- }
+ });
- @Override
- public int type() {
- return RequestFlags.IMMEDIATE_UPDATE;
- }
+ }
- @Override
- boolean isImmutable(ReadGraphImpl graph) {
- return graph.processor.isImmutable(r1());
- }
+ @Override
+ public int type() {
+ return RequestFlags.IMMEDIATE_UPDATE;
+ }
+
+ @Override
+ boolean isImmutable(ReadGraphImpl graph) {
+ return graph.processor.isImmutable(r1());
+ }
@Override
public void execute(ReadGraphImpl graph, int i) throws DatabaseException {
return L0;
}
+ public Layer0 getL0() {
+ return L0;
+ }
+
public static ThreadLocal<Integer> thread = new ThreadLocal<Integer>() {
protected Integer initialValue() {
return -1;
*******************************************************************************/
package org.simantics.db.impl.query;
-import java.util.concurrent.atomic.AtomicBoolean;
-
import org.simantics.db.RelationInfo;
import org.simantics.db.common.exception.DebugException;
import org.simantics.db.exception.DatabaseException;
import org.simantics.db.request.RequestFlags;
public final class Statements extends CollectionBinaryQuery<TripleIntProcedure> implements TripleIntProcedure {
-
+
public Statements(final int r1, final int r2) {
super(r1, r2);
}
-
+
final public static void queryEach(ReadGraphImpl graph, final int r1, final int r2, final QueryProcessor provider, final CacheEntry parent, final ListenerBase listener, final TripleIntProcedure procedure) throws DatabaseException {
-
- assert(r1 != 0);
- assert(r2 != 0);
-
+
+ assert(r1 != 0);
+ assert(r2 != 0);
+
if(parent == null && listener == null) {
- Statements.computeForEach(graph, r1, r2, null, procedure);
- return;
+ Statements.computeForEach(graph, r1, r2, null, procedure);
+ return;
}
-
+
QueryCache.runnerStatements(graph, r1, r2, parent, listener, procedure);
-
+
}
- @Override
- final public void removeEntry(QueryProcessor provider) {
+ @Override
+ final public void removeEntry(QueryProcessor provider) {
provider.cache.remove(this);
- }
-
+ }
+
final static TripleIntProcedure NOPT = new TripleIntProcedure() {
- @Override
- public void exception(ReadGraphImpl graph, Throwable throwable) {
- }
+ @Override
+ public void exception(ReadGraphImpl graph, Throwable throwable) {
+ }
- @Override
- public void execute(ReadGraphImpl graph, int s, int p, int o) {
- }
+ @Override
+ public void execute(ReadGraphImpl graph, int s, int p, int o) {
+ }
+
+ @Override
+ public void finished(ReadGraphImpl graph) {
+ }
- @Override
- public void finished(ReadGraphImpl graph) {
- }
-
};
-
+
final static private IntArray getAssertionMap(ReadGraphImpl graph, final int r1, final int r2, final Statements entry) throws DatabaseException {
-
+
class AssertionMapProc implements IntProcedure {
-
- boolean first = true;
-
- private IntArray result;
-
- public void addStatement(int s, int p, int o) {
-
- if(result.size() == 0) {
- result.add(s);
- result.add(p);
- result.add(o);
- } else {
- for(int i = 0;i < result.sizeOrData ; i+=3) {
- int existingP = result.data[i+1];
- if(p == existingP) {
- int existingO = result.data[i+2];
- if(existingO == o) return;
- }
- }
- result.add(s);
- result.add(p);
- result.add(o);
- }
-
- }
-
+
+ boolean first = true;
+
+ private IntArray result;
+
+ public void addStatement(int s, int p, int o) {
+
+ if(result.size() == 0) {
+ result.add(s);
+ result.add(p);
+ result.add(o);
+ } else {
+ for(int i = 0;i < result.sizeOrData ; i+=3) {
+ int existingP = result.data[i+1];
+ if(p == existingP) {
+ int existingO = result.data[i+2];
+ if(existingO == o) return;
+ }
+ }
+ result.add(s);
+ result.add(p);
+ result.add(o);
+ }
+
+ }
+
@Override
public void execute(ReadGraphImpl graph, int type) throws DatabaseException {
if(result == null) {
- result = QueryCache.resultAssertedStatements(graph, type, r2, entry, null);
+ result = QueryCache.resultAssertedStatements(graph, type, r2, entry, null);
} else {
- if (first) {
- IntArray ia = result;
- result = new IntArray();
- if(ia.data != null) {
- for(int i = 0;i < ia.sizeOrData ; i+=3) addStatement(ia.data[i],ia.data[i+1],ia.data[i+2]);
- }
- first = false;
- }
- IntArray ia = QueryCache.resultAssertedStatements(graph, type, r2, entry, null);
- if(ia.data != null) {
- for(int i = 0;i < ia.sizeOrData ; i+=3) addStatement(ia.data[i],ia.data[i+1],ia.data[i+2]);
- }
+ if (first) {
+ IntArray ia = result;
+ result = new IntArray();
+ if(ia.data != null) {
+ for(int i = 0;i < ia.sizeOrData ; i+=3) addStatement(ia.data[i],ia.data[i+1],ia.data[i+2]);
+ }
+ first = false;
+ }
+ IntArray ia = QueryCache.resultAssertedStatements(graph, type, r2, entry, null);
+ if(ia.data != null) {
+ for(int i = 0;i < ia.sizeOrData ; i+=3) addStatement(ia.data[i],ia.data[i+1],ia.data[i+2]);
+ }
}
}
public void finished(ReadGraphImpl graph) {
}
- @Override
- public void exception(ReadGraphImpl graph, Throwable throwable) {
- }
+ @Override
+ public void exception(ReadGraphImpl graph, Throwable throwable) {
+ }
}
-
+
AssertionMapProc amp = new AssertionMapProc();
// This dependency could be cut
QueryCache.runnerPrincipalTypes(graph, r1, entry, null, amp);
-
+
return amp.result;
-
+
}
-
+
final static private void forSingleAssertion(ReadGraphImpl graph, final int r1, final int r2, final Statements parent, final TripleIntProcedure procedure) throws DatabaseException {
-
- IntArray map = getAssertionMap(graph, r1, r2, parent);
- if(map == null) {
- procedure.finished(graph);
+
+ IntArray map = getAssertionMap(graph, r1, r2, parent);
+ if(map == null) {
+ procedure.finished(graph);
return;
- }
-
+ }
+
int size = map.size();
if(size == 3) {
- int s = map.data[0];
- int p = map.data[1];
- int o = map.data[2];
-
- procedure.execute(graph, s,p,o);
- procedure.finished(graph);
+ int s = map.data[0];
+ int p = map.data[1];
+ int o = map.data[2];
+
+ procedure.execute(graph, s,p,o);
+ procedure.finished(graph);
} else if(size == 0) {
- procedure.finished(graph);
-
+ procedure.finished(graph);
+
} else {
- int candidateS = map.data[0];
- int candidateP = map.data[1];
- int candidateO = map.data[2];
-
- IntSet candidateIs = null;
- try {
- candidateIs = QueryCache.resultSuperTypes(graph, candidateS, parent, null);
- } catch (DatabaseException e) {
- procedure.exception(graph, e);
- return;
- }
-
- for(int i=3;i<map.size();i+=3) {
-
- int nextS = map.data[i];
- int nextP = map.data[i+1];
- int nextO = map.data[i+2];
-
- if(nextS != candidateS) {
-
- if(candidateIs.contains(nextS)) {
-
- // Next is a super type of candidate => ignore next
-
- } else {
-
- IntSet nextIs = null;
- try {
- nextIs = QueryCache.resultSuperTypes(graph, nextS, parent, null);
- } catch (DatabaseException e) {
- procedure.exception(graph, e);
- return;
- }
-
- if(nextIs.contains(candidateS)) {
-
- // Candidate is a super type of next => next is the new candidate
-
- candidateS = nextS;
- candidateP = nextP;
- candidateO = nextO;
- candidateIs = nextIs;
-
- } else {
- // candidate and next are unrelated => error
- ManyObjectsForFunctionalRelationException exception = new ManyObjectsForFunctionalRelationException("Functional relation has conflicting assertions.", r1);
- procedure.exception(graph, exception);
- return;
- }
-
- }
-
- }
-
- }
-
+ int candidateS = map.data[0];
+ int candidateP = map.data[1];
+ int candidateO = map.data[2];
+
+ IntSet candidateIs = null;
+ try {
+ candidateIs = QueryCache.resultSuperTypes(graph, candidateS, parent, null);
+ } catch (DatabaseException e) {
+ procedure.exception(graph, e);
+ return;
+ }
+
+ for(int i=3;i<map.size();i+=3) {
+
+ int nextS = map.data[i];
+ int nextP = map.data[i+1];
+ int nextO = map.data[i+2];
+
+ if(nextS != candidateS) {
+
+ if(candidateIs.contains(nextS)) {
+
+ // Next is a super type of candidate => ignore next
+
+ } else {
+
+ IntSet nextIs = null;
+ try {
+ nextIs = QueryCache.resultSuperTypes(graph, nextS, parent, null);
+ } catch (DatabaseException e) {
+ procedure.exception(graph, e);
+ return;
+ }
+
+ if(nextIs.contains(candidateS)) {
+
+ // Candidate is a super type of next => next is the new candidate
+
+ candidateS = nextS;
+ candidateP = nextP;
+ candidateO = nextO;
+ candidateIs = nextIs;
+
+ } else {
+ // candidate and next are unrelated => error
+ ManyObjectsForFunctionalRelationException exception = new ManyObjectsForFunctionalRelationException("Functional relation has conflicting assertions.", r1);
+ procedure.exception(graph, exception);
+ return;
+ }
+
+ }
+
+ }
+
+ }
+
procedure.execute(graph, candidateS, candidateP, candidateO);
procedure.finished(graph);
-
+
}
-
+
}
-
+
final static InternalProcedure<IntSet> NOP = new InternalProcedure<IntSet>() {
- @Override
- public void execute(ReadGraphImpl graph, IntSet result) {
- }
+ @Override
+ public void execute(ReadGraphImpl graph, IntSet result) {
+ }
+
+ @Override
+ public void exception(ReadGraphImpl graph, Throwable throwable) {
+ }
- @Override
- public void exception(ReadGraphImpl graph, Throwable throwable) {
- }
-
};
-
- // Search for one statement
- final static public void computeFunctionalIndex(ReadGraphImpl graph, final int r1, final int r2, final Statements parent, final RelationInfo ri, final TripleIntProcedure procedure) throws DatabaseException {
-
+
+ // Search for one statement
+ final static public void computeFunctionalIndex(ReadGraphImpl graph, final int r1, final int r2, final Statements parent, final RelationInfo ri, final TripleIntProcedure procedure) throws DatabaseException {
+
if(ri.isFinal) {
-
- int result = graph.processor.querySupport.getFunctionalObject(r1, r2);
- if(result == 0) {
+ int result = graph.processor.querySupport.getFunctionalObject(r1, r2);
- // Check for assertions
- forSingleAssertion(graph, r1, r2, parent, procedure);
+ if(result == 0) {
- } else if(result == -1) {
+ // Check for assertions
+ forSingleAssertion(graph, r1, r2, parent, procedure);
- graph.processor.querySupport.getObjects(graph, r1, r2, new IntProcedure() {
+ } else if(result == -1) {
+
+ graph.processor.querySupport.getObjects(graph, r1, r2, new IntProcedure() {
+
+ @Override
+ public void execute(ReadGraphImpl graph, int i) throws DatabaseException {
+ procedure.execute(graph, r1, r2, i);
+ }
- @Override
- public void execute(ReadGraphImpl graph, int i) throws DatabaseException {
- procedure.execute(graph, r1, r2, i);
- }
+ @Override
+ public void exception(ReadGraphImpl graph, Throwable t) {
+ if(DebugException.DEBUG) new DebugException(t).printStackTrace();
+ }
- @Override
- public void exception(ReadGraphImpl graph, Throwable t) {
- if(DebugException.DEBUG) new DebugException(t).printStackTrace();
- }
+ @Override
+ public void finished(ReadGraphImpl graph) {
+ }
- @Override
- public void finished(ReadGraphImpl graph) {
- }
+ });
- });
+ // Check for assertions
+ forSingleAssertion(graph, r1, r2, parent, procedure);
- // Check for assertions
- forSingleAssertion(graph, r1, r2, parent, procedure);
-
- } else {
+ } else {
- // If functional relation was found there is no need to check assertions
+ // If functional relation was found there is no need to check assertions
procedure.execute(graph, r1, r2, result);
procedure.finished(graph);
-
- }
-
+ }
+
+
} else {
-
- final AtomicBoolean found = new AtomicBoolean(false);
-
+
// Note! The dependency is intentionally cut!
IntSet direct = QueryCache.resultDirectPredicates(graph, r1, null, null);
direct.forEach(graph, new SyncIntProcedure() {
-
+
+ /*
+ * 0 = not found
+ * 1 = found
+ * 2 = exception
+ */
+ int found = 0;
+
@Override
public void run(ReadGraphImpl graph) throws DatabaseException {
-
- if(found.get()) {
- procedure.finished(graph);
- } else {
+
+ if(found == 1) {
+
+ procedure.finished(graph);
+
+ } else if(found == 0) {
+
// Check for assertions
forSingleAssertion(graph, r1, r2, parent, procedure);
+
}
-
+
}
@Override
public void execute(ReadGraphImpl graph, final int pred) throws DatabaseException {
-
- if(found.get()) return;
+
+ if(found > 0)
+ return;
if(pred == r2) {
-
- inc();
-
+
// Note! The dependency is intentionally cut!
QueryCache.runnerDirectObjects(graph, r1, pred, null, null, new IntProcedure() {
@Override
public void execute(ReadGraphImpl graph, int i) throws DatabaseException {
-
- if(found.compareAndSet(false, true)) {
+
+ if(found == 0) {
+
procedure.execute(graph, r1, pred, i);
- } else {
- ManyObjectsForFunctionalRelationException exception = new ManyObjectsForFunctionalRelationException("Functional relation has more than one statement.", r1);
- procedure.exception(graph, exception);
- }
+ found = 1;
+
+ } else {
+
+ ManyObjectsForFunctionalRelationException exception = new ManyObjectsForFunctionalRelationException("Functional relation has more than one statement.", r1);
+ procedure.exception(graph, exception);
+ found = 2;
+
+ }
}
@Override
public void finished(ReadGraphImpl graph) throws DatabaseException {
- dec(graph);
}
-
- @Override
- public void exception(ReadGraphImpl graph, Throwable t) throws DatabaseException {
- procedure.exception(graph, t);
- dec(graph);
- }
+
+ @Override
+ public void exception(ReadGraphImpl graph, Throwable t) throws DatabaseException {
+
+ procedure.exception(graph, t);
+ found = 2;
+
+ }
});
} else {
-
- inc();
-
+
QueryCache.runnerSuperRelations(graph, pred, parent, null, new InternalProcedure<IntSet>() {
-
+
@Override
public void execute(ReadGraphImpl graph, IntSet result) throws DatabaseException {
-
- if(found.get()) {
- dec(graph);
+
+ if(found > 0)
return;
- }
if(result.contains(r2)) {
-
+
inc();
-
+
// Note! The dependency is intentionally cut!
QueryCache.runnerDirectObjects(graph, r1, pred, null, null, new IntProcedure() {
-
+
@Override
public void execute(ReadGraphImpl graph, int i) throws DatabaseException {
-
- if(found.compareAndSet(false, true)) {
- procedure.execute(graph, r1, pred, i);
- } else {
- ManyObjectsForFunctionalRelationException exception = new ManyObjectsForFunctionalRelationException("Functional relation has more than one statement.", r1);
- procedure.exception(graph, exception);
- }
-
+
+ if(found == 0) {
+
+ procedure.execute(graph, r1, pred, i);
+ found = 1;
+
+ } else {
+
+ ManyObjectsForFunctionalRelationException exception = new ManyObjectsForFunctionalRelationException("Functional relation has more than one statement (r1=" + r1 + ", r2=" + r2 + ").", r1);
+ procedure.exception(graph, exception);
+ found = 2;
+
+ }
+
}
-
+
@Override
public void finished(ReadGraphImpl graph) throws DatabaseException {
- dec(graph);
}
-
- @Override
- public void exception(ReadGraphImpl graph, Throwable t) throws DatabaseException {
- procedure.exception(graph, t);
- dec(graph);
- }
+
+ @Override
+ public void exception(ReadGraphImpl graph, Throwable t) throws DatabaseException {
+ procedure.exception(graph, t);
+ found = 2;
+ }
});
-
+
}
-
- dec(graph);
-
+
+ }
+
+ @Override
+ public void exception(ReadGraphImpl graph, Throwable t) throws DatabaseException {
+ procedure.exception(graph, t);
+ found = 2;
}
-
- @Override
- public void exception(ReadGraphImpl graph, Throwable t) throws DatabaseException {
- procedure.exception(graph, t);
- dec(graph);
- }
});
-
+
}
-
+
}
@Override
public void finished(ReadGraphImpl graph) throws DatabaseException {
dec(graph);
}
-
+
});
-
+
}
- }
-
+ }
+
final static private void forAssertions(ReadGraphImpl graph, final int r1, final int r2, final Statements parent, final TripleIntProcedure procedure) throws DatabaseException {
- QueryCache.runnerPrincipalTypes(graph, r1, parent, null, new SyncIntProcedure() {
-
+ QueryCache.runnerPrincipalTypes(graph, r1, parent, null, new SyncIntProcedure() {
+
@Override
public void run(ReadGraphImpl graph) throws DatabaseException {
procedure.finished(graph);
}
-
+
TripleIntProcedure proc = new TripleIntProcedureAdapter() {
@Override
public void execute(ReadGraphImpl graph, int s, int p, int o) throws DatabaseException {
- procedure.execute(graph, s, p, o);
+ procedure.execute(graph, s, p, o);
}
@Override
public void finished(ReadGraphImpl graph) throws DatabaseException {
dec(graph);
}
-
- @Override
- public void exception(ReadGraphImpl graph, Throwable t) throws DatabaseException {
+
+ @Override
+ public void exception(ReadGraphImpl graph, Throwable t) throws DatabaseException {
dec(graph);
- procedure.exception(graph, t);
- }
+ procedure.exception(graph, t);
+ }
};
inc();
QueryCache.runnerAssertedStatements(graph, type, r2, parent, null, proc);
}
-
+
@Override
public void finished(ReadGraphImpl graph) throws DatabaseException {
dec(graph);
}
-
+
@Override
public void exception(ReadGraphImpl graph, Throwable t) throws DatabaseException {
dec(graph);
}
-
+
});
-
+
}
- final static public void computeNotFunctionalIndex(ReadGraphImpl graph, final int r1, final int r2, final Statements parent, final RelationInfo ri, final TripleIntProcedure procedure) throws DatabaseException {
+ final static public void computeNotFunctionalIndex(ReadGraphImpl graph, final int r1, final int r2, final Statements parent, final RelationInfo ri, final TripleIntProcedure procedure) throws DatabaseException {
- if(ri.isFinal) {
+ if(ri.isFinal) {
- graph.processor.querySupport.getObjects(graph, r1, r2, new IntProcedure() {
+ graph.processor.querySupport.getObjects(graph, r1, r2, new IntProcedure() {
- @Override
- public void execute(ReadGraphImpl graph, int i) throws DatabaseException {
- procedure.execute(graph, r1, r2, i);
- }
+ @Override
+ public void execute(ReadGraphImpl graph, int i) throws DatabaseException {
+ procedure.execute(graph, r1, r2, i);
+ }
- @Override
- public void exception(ReadGraphImpl graph, Throwable t) throws DatabaseException {
- if(DebugException.DEBUG) new DebugException(t).printStackTrace();
- procedure.exception(graph, t);
- }
+ @Override
+ public void exception(ReadGraphImpl graph, Throwable t) throws DatabaseException {
+ if(DebugException.DEBUG) new DebugException(t).printStackTrace();
+ procedure.exception(graph, t);
+ }
- @Override
- public void finished(ReadGraphImpl graph) {
- }
+ @Override
+ public void finished(ReadGraphImpl graph) {
+ }
- });
+ });
- if(ri.isAsserted) {
- forAssertions(graph, r1, r2, parent, procedure);
- } else {
- procedure.finished(graph);
- }
+ if(ri.isAsserted) {
+ forAssertions(graph, r1, r2, parent, procedure);
+ } else {
+ procedure.finished(graph);
+ }
} else {
// Note! The dependency is intentionally cut!
IntSet direct = QueryCache.resultDirectPredicates(graph, r1, null, null);
direct.forEach(graph, new SyncIntProcedure() {
-
+
@Override
public void run(ReadGraphImpl graph) throws DatabaseException {
forAssertions(graph, r1, r2, parent, procedure);
public void execute(ReadGraphImpl graph, final int pred2) throws DatabaseException {
if(pred2 == r2) {
-
- inc();
-
+
// Note! The dependency is intentionally cut!
QueryCache.runnerDirectObjects(graph, r1, pred2, null, null, new IntProcedure() {
@Override
public void execute(ReadGraphImpl graph, int i) throws DatabaseException {
- procedure.execute(graph, r1, pred2, i);
+ procedure.execute(graph, r1, pred2, i);
}
@Override
public void finished(ReadGraphImpl graph) throws DatabaseException {
- dec(graph);
}
-
- @Override
- public void exception(ReadGraphImpl graph, Throwable t) throws DatabaseException {
- procedure.exception(graph, t);
- dec(graph);
- }
+
+ @Override
+ public void exception(ReadGraphImpl graph, Throwable t) throws DatabaseException {
+ procedure.exception(graph, t);
+ }
});
} else {
-
-// inc();
try {
-
+
IntSet result = QueryCache.resultSuperRelations(graph, pred2, parent, null);
if(result.contains(r2)) {
});
}
-
+
} catch (Throwable e) {
procedure.exception(graph, e);
}
}
-
+
}
@Override
public void finished(ReadGraphImpl graph) throws DatabaseException {
dec(graph);
}
-
+
});
-
+
}
-
+
}
-
+
public static void computeForEach(ReadGraphImpl graph, final int r1, final int r2, final Statements entry, final TripleIntProcedure procedure_) throws DatabaseException {
-
+
TripleIntProcedure procedure = entry != null ? entry : procedure_;
-
+
RelationInfo ri = QueryCache.resultRelationInfoQuery(graph, r2, entry, null);
graph.ensureLoaded(r1, r2);
if(ri.isFunctional) {
}
if(entry != null) entry.performFromCache(graph, procedure_);
-
+
}
-
+
@Override
public String toString() {
- return "Statements[" + r1() + " - " + r2() + "]";
+ return "Statements[" + r1() + " - " + r2() + "]";
}
final private void finish(ReadGraphImpl graph, TripleIntProcedure procedure) throws DatabaseException {
-
+
assert(assertPending());
synchronized(this) {
final IntArray value = (IntArray)getResult();
for(int i=0;i<value.size();i+=3) {
- procedure.execute(graph, value.data[i], value.data[i+1], value.data[i+2]);
+ procedure.execute(graph, value.data[i], value.data[i+1], value.data[i+2]);
}
-
+
procedure.finished(graph);
-
+
}
synchronized public void addOrSet(int s, int p, int o) {
-
- assert(assertPending());
-
- IntArray value = (IntArray)getResult();
+
+ assert(assertPending());
+
+ IntArray value = (IntArray)getResult();
value.add(s);
value.add(p);
value.add(o);
-
+
}
final static public int r1(long id) {
return (int)(id>>>32);
}
-
+
final static public int r2(long id) {
return (int)id;
}
-
+
final public void addOrSetFunctional(int s, long po) {
-
- addOrSetFunctional(s, r1(po), r2(po));
-
+
+ addOrSetFunctional(s, r1(po), r2(po));
+
}
final public void addOrSetFunctional(int s, int p, int o) {
-
- assert(assertPending());
-
- IntArray value = (IntArray)getResult();
+
+ assert(assertPending());
+
+ IntArray value = (IntArray)getResult();
value.add(s);
value.add(p);
value.add(o);
-
+
}
-
+
@Override
public Object performFromCache(ReadGraphImpl graph, final TripleIntProcedure procedure) throws DatabaseException {
- assert(isReady());
+ assert(isReady());
final IntArray value = (IntArray)getResult();
- if(handleException(graph, procedure)) return value;
-
+ if(handleException(graph, procedure)) return value;
+
for(int i=0;i<value.size();i+=3) {
- procedure.execute(graph, value.data[i], value.data[i+1], value.data[i+2]);
+ procedure.execute(graph, value.data[i], value.data[i+1], value.data[i+2]);
}
procedure.finished(graph);
-
+
return value;
-
+
}
-
+
@Override
public void recompute(ReadGraphImpl graph) throws DatabaseException {
-
+
computeForEach(graph, r1(), r2(), this, new TripleIntProcedureAdapter() {
@Override
public void finished(ReadGraphImpl graph) {
}
-
- @Override
- public void exception(ReadGraphImpl graph, Throwable t) {
- new Error("Error in recompute.", t).printStackTrace();
+
+ @Override
+ public void exception(ReadGraphImpl graph, Throwable t) {
+ new Error("Error in recompute.", t).printStackTrace();
}
});
-
+
}
@Override
public int type() {
return RequestFlags.IMMEDIATE_UPDATE;
}
-
+
@Override
boolean isImmutable(ReadGraphImpl graph) {
- return graph.processor.isImmutable(r1());
+ return graph.processor.isImmutable(r1());
}
@Override
public void exception(ReadGraphImpl graph, Throwable throwable) throws DatabaseException {
except(throwable);
}
-
+
}
*/
public abstract class ContextualRelatedValue implements ConverterComputationalValue {
- @SuppressWarnings("unchecked")
- @Override
- public <T> T getValue(ReadGraph graph, Resource resource) throws DatabaseException {
- return (T) new FunctionImpl3<ReadGraph, Resource, Object, Object>() {
- @Override
- public Object apply(ReadGraph graph, Resource converter, Object context) {
- SCLContext sclContext = SCLContext.getCurrent();
- Object oldGraph = sclContext.get("graph");
- try {
- if (context instanceof Variable) {
- Variable variable = (Variable)context;
- try {
- Function1<Object,Object> fn = getFunction(graph, variable.getParent(graph).getRepresents(graph), variable.getRepresents(graph), variable.getPredicateResource(graph));
- sclContext.put("graph", graph);
- return fn.apply(variable);
- } catch (DatabaseException e) {
- throw new RuntimeDatabaseException(e);
- }
- } if (context instanceof Resource) {
- Resource resource = (Resource)context;
- try {
- // Here converter is the object and context is the subject
- Function1<Object,Object> fn = getFunction(graph, resource, converter, null);
- return fn.apply(resource);
- } catch (DatabaseException e) {
- throw new RuntimeDatabaseException(e);
- }
- } else {
- throw new IllegalStateException("Unknown context " + context);
+ private final FunctionImpl3<ReadGraph, Resource, Object, Object> function = new FunctionImpl3<ReadGraph, Resource, Object, Object>() {
+ @Override
+ public Object apply(ReadGraph graph, Resource converter, Object context) {
+ SCLContext sclContext = SCLContext.getCurrent();
+ Object oldGraph = sclContext.get("graph");
+ try {
+ if (context instanceof Variable) {
+ Variable variable = (Variable)context;
+ try {
+ Function1<Object,Object> fn = getFunction(graph, variable.getParent(graph).getRepresents(graph), variable.getRepresents(graph), variable.getPredicateResource(graph));
+ sclContext.put("graph", graph);
+ return fn.apply(variable);
+ } catch (DatabaseException e) {
+ throw new RuntimeDatabaseException(e);
+ }
+ } if (context instanceof Resource) {
+ Resource resource = (Resource)context;
+ try {
+ // Here converter is the object and context is the subject
+ Function1<Object,Object> fn = getFunction(graph, resource, converter, null);
+ return fn.apply(resource);
+ } catch (DatabaseException e) {
+ throw new RuntimeDatabaseException(e);
}
- } finally {
- sclContext.put("graph", oldGraph);
+ } else {
+ throw new IllegalStateException("Unknown context " + context);
}
+ } finally {
+ sclContext.put("graph", oldGraph);
}
- };
+ }
+ };
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public <T> T getValue(ReadGraph graph, Resource resource) throws DatabaseException {
+ return (T) function;
}
}
return graph.getValue2(object, variable);
} else {
for (Pair<PropertyInfo, Resource> assertion : assertions.values()) {
- if (assertion.first.predicate.equals(variable.property.predicate)) {
+ if (assertion.first.predicate.equals(variable.getPossiblePredicateResource(graph))) {
return graph.getValue2(assertion.second, variable);
}
}
return graph.getValue2(object, variable, binding);
} else {
for (Pair<PropertyInfo, Resource> assertion : assertions.values()) {
- if (assertion.first.predicate.equals(variable.property.predicate)) {
+ if (assertion.first.predicate.equals(variable.getPossiblePredicateResource(graph))) {
return graph.getValue2(assertion.second, variable, binding);
}
}
if(property instanceof StandardGraphPropertyVariable) {
StandardGraphPropertyVariable variable = (StandardGraphPropertyVariable)property;
if (variable.parentResource != null) {
- Statement stm = graph.getPossibleStatement(variable.parentResource, variable.property.predicate);
- return stm != null && stm.isAsserted(variable.parentResource);
+ Resource predicate = variable.getPossiblePredicateResource(graph);
+ if (predicate != null) {
+ Statement stm = graph.getPossibleStatement(variable.parentResource, predicate);
+ return stm != null && stm.isAsserted(variable.parentResource);
+ }
}
}
return Boolean.FALSE;
throw new InvalidVariableException("Variable is not represented by any resource (URI=" + variable.getPossibleURI(graph) + ").");
try {
- return graph.getRelatedValue2(variable.parentResource, variable.property.predicate, variable);
+ return graph.getRelatedValue2(variable.parentResource, variable.getPredicateResource(graph), variable);
} catch (NoSingleResultException e) {
throw new MissingVariableValueException(variable.getPossibleURI(graph), e);
} catch (DoesNotContainValueException e) {
if (variable.parentResource == null)
throw new MissingVariableException("Variable is not represented by any resource (URI=" + variable.getPossibleURI(graph) + ").", context.getPossibleRepresents(graph));
+
try {
- return graph.getRelatedValue2(variable.parentResource, variable.property.predicate, variable);
+ return graph.getRelatedValue2(variable.parentResource, variable.getPredicateResource(graph), variable);
} catch (NoSingleResultException e) {
throw new MissingVariableValueException(variable.getPossibleURI(graph), e);
} catch (DoesNotContainValueException e) {
}
+ public static boolean isMarkedReadOnly(ReadGraph graph, Resource r) throws DatabaseException {
+ return Boolean.TRUE.equals( graph.getPossibleRelatedValue(r, graph.<Layer0>l0().readOnly, Bindings.BOOLEAN) );
+ }
+
private static TransferableGraph1 makeTG(ReadGraph graph, Resource r) throws DatabaseException {
SimanticsClipboardImpl cp = new SimanticsClipboardImpl();
--- /dev/null
+package org.simantics.db.layer0.variable;
+
+import org.simantics.db.Resource;
+import org.simantics.db.exception.AssumptionException;
+
+public class NoPredicateResourceException extends AssumptionException {
+
+ private static final long serialVersionUID = -374051341908276908L;
+
+ public NoPredicateResourceException(Throwable cause) {
+ super(cause);
+ }
+
+ public NoPredicateResourceException(String message, Throwable cause, Resource... rs) {
+ super(message, cause, rs);
+ }
+
+ public NoPredicateResourceException(String message, Resource... resources) {
+ super(message, resources);
+ }
+
+ public NoPredicateResourceException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public NoPredicateResourceException(String message, int... args) {
+ super(message, args);
+ }
+
+ public NoPredicateResourceException(String message) {
+ super(message);
+ }
+
+}
import org.simantics.db.exception.DatatypeNotFoundException;
import org.simantics.db.exception.ValidationException;
import org.simantics.db.layer0.exception.InvalidVariableException;
+import org.simantics.db.layer0.exception.MissingVariableException;
import org.simantics.db.layer0.exception.MissingVariableValueException;
import org.simantics.db.layer0.exception.PendingVariableException;
import org.simantics.db.layer0.function.All;
@Override
public String getPossibleLabel(ReadGraph graph) throws DatabaseException {
+ if (property.predicate == null)
+ return null;
return graph.getPossibleRelatedValue2(property.predicate, graph.getService(Layer0.class).HasLabel, parent, Bindings.STRING);
}
@Override
public String getLabel(ReadGraph graph) throws DatabaseException {
+ if (property.predicate == null)
+ throw new NoPredicateResourceException("No predicate resource for property " + getName(graph));
return graph.getRelatedValue2(property.predicate, graph.getService(Layer0.class).HasLabel, parent, Bindings.STRING);
}
if(Development.DEVELOPMENT) {
if(Development.<Boolean>getProperty(DevelopmentKeys.L0_VALIDATION, Bindings.BOOLEAN)) {
- String error = L0Validations.checkValueType(graph, parentResource, property.predicate);
- if(error != null) {
- LOGGER.error(error);
- throw new ValidationException(error);
+ if (property.predicate != null) {
+ String error = L0Validations.checkValueType(graph, parentResource, property.predicate);
+ if(error != null) {
+ LOGGER.error(error);
+ throw new ValidationException(error);
+ }
}
}
}
if(Development.DEVELOPMENT) {
if(Development.<Boolean>getProperty(DevelopmentKeys.L0_VALIDATION, Bindings.BOOLEAN)) {
- String error = L0Validations.checkValueType(graph, parentResource, property.predicate);
- if(error != null) {
- LOGGER.error(error);
- throw new ValidationException(error);
+ if (property.predicate != null) {
+ String error = L0Validations.checkValueType(graph, parentResource, property.predicate);
+ if(error != null) {
+ LOGGER.error(error);
+ throw new ValidationException(error);
+ }
}
}
}
if(Development.DEVELOPMENT) {
if(Development.<Boolean>getProperty(DevelopmentKeys.L0_VALIDATION, Bindings.BOOLEAN)) {
- String error = L0Validations.checkValueType(graph, parentResource, property.predicate);
- if(error != null) {
- LOGGER.error(error);
- throw new ValidationException(error);
+ if (property.predicate != null) {
+ String error = L0Validations.checkValueType(graph, parentResource, property.predicate);
+ if(error != null) {
+ LOGGER.error(error);
+ throw new ValidationException(error);
+ }
}
}
}
if(Development.DEVELOPMENT) {
if(Development.<Boolean>getProperty(DevelopmentKeys.L0_VALIDATION, Bindings.BOOLEAN)) {
- String error = L0Validations.checkValueType(graph, parentResource, property.predicate);
- if(error != null) {
- LOGGER.error(error);
- throw new ValidationException(error);
+ if (property.predicate != null) {
+ String error = L0Validations.checkValueType(graph, parentResource, property.predicate);
+ if(error != null) {
+ LOGGER.error(error);
+ throw new ValidationException(error);
+ }
}
}
}
@Override
public Variable getPredicate(ReadGraph graph) throws DatabaseException {
+ if (property.predicate == null)
+ throw new MissingVariableException("No predicate for property " + getName(graph));
return Variables.getVariable(graph, graph.getURI(property.predicate));
}
@Override
public Resource getPredicateResource(ReadGraph graph) throws DatabaseException {
+ if (property.predicate == null)
+ throw new NoPredicateResourceException("No predicate for property " + getName(graph));
return property.predicate;
}
import org.simantics.db.SessionReference;
import org.simantics.db.VirtualGraph;
import org.simantics.db.authentication.UserAuthenticationAgent;
-import org.simantics.db.common.utils.Logger;
import org.simantics.db.exception.DatabaseException;
import org.simantics.db.exception.InvalidAuthenticationException;
import org.simantics.db.exception.InvalidUserException;
import org.simantics.db.impl.query.QueryProcessor;
import org.simantics.db.impl.query.QuerySupport;
import org.simantics.db.service.ServerInformation;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
final public class SessionImplDb extends SessionImplSocket {
+ private static final Logger LOGGER = LoggerFactory.getLogger(SessionImplDb.class);
+
/**
* Cached ServerInformation structure fetched from the server at connection
* time. It should never change during a single session and therefore it
try {
newId = cluster.createResource(clusterTranslator);
} catch (DatabaseException e) {
- Logger.defaultLogError(e);
+ LOGGER.error("createResource failed", e);
return null;
}
return new ResourceImpl(resourceSupport, newId);
// clusterTable.dispose(); clusterTable = null;
// throw e;
} catch (Throwable e) {
- e.printStackTrace();
- Logger.defaultLogError("Unhandled error. See exception for details.", e);
+ LOGGER.error("Unhandled error. See exception for details.", e);
graphSession = null;
clusterTable.dispose(); clusterTable = null;
throw new Exception(e);
try {
getClusterTable().refresh(csid, this, clusterUID);
} catch (Throwable t) {
- Logger.defaultLogError("Refesh failed.", t);
+ LOGGER.error("refresh({}, {}) failed", thread, csid, t);
}
}
assert (null != writer);
} catch (Throwable t) {
if (!(t instanceof CancelTransactionException))
- Logger.defaultLogError("Write transaction caused an unexpected error, see exception.", t);
+ LOGGER.error("Write transaction caused an unexpected error, see exception.", t);
writeState.except(t);
} finally {
writer.asyncBarrier.dec();
// Log it first, just to be safe that the error is always logged.
if (!(e instanceof CancelTransactionException))
- Logger.defaultLogError("Write transaction caused an unexpected error, see exception.", e);
+ LOGGER.error("Write transaction caused an unexpected error, see exception.", e);
// writeState.getGraph().state.barrier.dec();
// writeState.getGraph().waitAsync(request);
if (t instanceof DatabaseException) callback.accept((DatabaseException) t);
else callback.accept(new DatabaseException(t));
} else
- Logger.defaultLogError("Unhandled exception", t);
+ LOGGER.error("Unhandled exception", t);
}
};
callback.exception(new DatabaseException(e));
state.stopWriteTransaction(clusterStream);
- Logger.defaultLogError("Write transaction caused an unexpected error, see exception.", e);
+ LOGGER.error("Write transaction caused an unexpected error, see exception.", e);
} finally {
if(throwable != null) {
throwable.set(th);
} else {
- Logger.defaultLogError("Unhandled exception", th);
+ LOGGER.error("Unhandled exception", th);
}
}
if(throwable != null) {
throwable.set(t);
} else {
- Logger.defaultLogError("Unhandled exception", t);
+ LOGGER.error("Unhandled exception", t);
}
try {
if(throwable != null) {
throwable.set(t2);
} else {
- Logger.defaultLogError("Unhandled exception", t2);
+ LOGGER.error("Unhandled exception", t2);
}
}
*/
@SuppressWarnings("unchecked")
@Override
- public synchronized <T> T peekService(Class<T> api) {
-
- if(serviceKey1 == api) {
- return (T)service1;
- } else if (serviceKey2 == api) {
- // Promote this key
- Object result = service2;
- service2 = service1;
- serviceKey2 = serviceKey1;
- service1 = result;
- serviceKey1 = api;
- return (T)result;
- }
+ public <T> T peekService(Class<T> api) {
+ if (Layer0.class == api)
+ return (T) L0;
- if (Layer0.class == api)
- return (T) L0;
- if (ServerInformation.class == api)
- return (T) getCachedServerInformation();
- else if (WriteGraphImpl.class == api)
- return (T) writeState.getGraph();
- else if (ClusterBuilder.class == api)
- return (T)new ClusterBuilderImpl(this, (WriteOnlySupport)writeState.getGraph().writeSupport);
- else if (ClusterBuilderFactory.class == api)
- return (T)new ClusterBuilderFactoryImpl(this);
+ synchronized (this) {
+ if (serviceKey1 == api) {
+ return (T) service1;
+ }
+ if (serviceKey2 == api) {
+ // Promote this key
+ Object result = service2;
+ service2 = service1;
+ serviceKey2 = serviceKey1;
+ service1 = result;
+ serviceKey1 = api;
+ return (T)result;
+ }
- service2 = service1;
- serviceKey2 = serviceKey1;
+ if (ServerInformation.class == api)
+ return (T) getCachedServerInformation();
+ else if (WriteGraphImpl.class == api)
+ return (T) writeState.getGraph();
+ else if (ClusterBuilder.class == api)
+ return (T)new ClusterBuilderImpl(this, (WriteOnlySupport)writeState.getGraph().writeSupport);
+ else if (ClusterBuilderFactory.class == api)
+ return (T)new ClusterBuilderFactoryImpl(this);
- service1 = serviceLocator.peekService(api);
- serviceKey1 = api;
+ service2 = service1;
+ serviceKey2 = serviceKey1;
- return (T)service1;
+ service1 = serviceLocator.peekService(api);
+ serviceKey1 = api;
+ return (T)service1;
+ }
}
/*
try {
h.valuesChanged(ctx);
} catch (Exception e) {
- Logger.defaultLogError("monitor handler notification produced the following exception", e);
+ LOGGER.error("monitor handler notification produced the following exception", e);
} catch (LinkageError e) {
- Logger.defaultLogError("monitor handler notification produced a linkage error", e);
+ LOGGER.error("monitor handler notification produced a linkage error", e);
}
}
}
state.setCombine(false);
}
+ @SuppressWarnings("unchecked")
+ @Override
+ public <T> T l0() {
+ return (T) L0;
+ }
+
}
import org.simantics.db.ServerI;
import org.simantics.db.VirtualGraph;
import org.simantics.db.authentication.UserAuthenticationAgent;
-import org.simantics.db.common.utils.Logger;
import org.simantics.db.exception.DatabaseException;
import org.simantics.db.exception.InvalidAuthenticationException;
import org.simantics.db.exception.InvalidUserException;
import org.simantics.db.impl.VirtualGraphImpl;
import org.simantics.db.impl.query.QueryProcessor;
import org.simantics.db.service.ServerInformation;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import fi.vtt.simantics.procore.BackdoorAuthenticator;
import fi.vtt.simantics.procore.ProCoreServerReference;
import fi.vtt.simantics.procore.SessionManagerSource;
public class SessionImplVirtual extends SessionImplSocket {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(SessionImplVirtual.class);
+
protected VirtualGraphImpl virtualGraphImpl;
public SessionImplVirtual(UserAuthenticationAgent authAgent)
throws DatabaseException {
} catch (InvalidUserException e) {
throw e;
} catch (IOException e) {
- Logger.defaultLogError("I/O error. See exception for details.", e);
+ LOGGER.error("I/O error. See exception for details.", e);
graphSession = null;
throw new DatabaseException(e);
} catch (Throwable e) {
- e.printStackTrace();
- Logger.defaultLogError("Unhandled error. See exception for details.", e);
+ LOGGER.error("Unhandled error. See exception for details.", e);
graphSession = null;
throw new DatabaseException(e);
}
try {
return gs.getServerInformation();
} catch (DatabaseException e) {
- Logger.defaultLogError("Failed to get server info.", e);
+ LOGGER.error("Failed to get server info.", e);
return null;
}
}
import org.simantics.db.WriteGraph;
import org.simantics.db.common.MetadataUtils;
import org.simantics.db.common.exception.DebugException;
-import org.simantics.db.common.utils.Logger;
import org.simantics.db.exception.DatabaseException;
import org.simantics.db.exception.ImmutableException;
import org.simantics.db.exception.ServiceException;
import org.simantics.db.request.WriteResult;
import org.simantics.db.request.WriteTraits;
import org.simantics.db.service.ByteReader;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class WriteSupportImpl implements WriteSupport {
+ private static final Logger LOGGER = LoggerFactory.getLogger(WriteSupportImpl.class);
+
final private SessionImplSocket session;
final private QueryProcessor queryProcessor;
final private State state;
try {
addSetValue(((ResourceImpl) resource).id, value, value.length);
} catch (DatabaseException e) {
- Logger.defaultLogError(e);
+ LOGGER.error("writeOnly setValue({}, {}, byte[{}]) failed", provider, resource, value.length, e);
}
}
} else {
try {
addSetValue(((ResourceImpl) resource).id, value, value.length);
} catch (DatabaseException e) {
- Logger.defaultLogError(e);
+ LOGGER.error("setValue({}, {}, byte[{}]) failed", provider, resource, value.length, e);
}
}
queryProcessor.releaseWrite(session.writeState.getGraph());
try {
cluster.removeValue(key, session.clusterTranslator);
} catch (DatabaseException e) {
- Logger.defaultLogError(e);
+ LOGGER.error("denyValue({}, {}) failed", provider, resource, e);
return;
}
queryProcessor.updateValue(key);
if (null != c && c != cluster)
session.clusterTable.replaceCluster(c);
} catch (DatabaseException e) {
- Logger.defaultLogError(e);
+ LOGGER.error("claimImpl({}, {}, {}) failed", subject, predicate, object, e);
throw new RuntimeException(e);
}
queryProcessor.updateStatements(subject, predicate);
if (null != c && c != cluster)
session.clusterTable.replaceCluster(c);
} catch (DatabaseException e) {
- Logger.defaultLogError(e);
+ LOGGER.error("claimImpl2({}, {}, {}) failed", subject, predicate, object, e);
}
if (cluster.isWriteOnly())
return;
try {
cluster.denyRelation(subject, predicate, object, session.clusterTranslator);
} catch (DatabaseException e) {
- Logger.defaultLogError(e);
+ LOGGER.error("removeStatement({}, {}, {}) failed", subject, predicate, object, e);
return false;
}
queryProcessor.updateStatements(subject, predicate);
* @see MergingGraphRequestProcessor
* @see AsyncRequestProcessor
*/
-public interface RequestProcessor extends RequestProcessorSpecific, ServiceLocator {
+public interface RequestProcessor extends RequestProcessorSpecific, ServiceLocator, ResourceLocator {
Resource getRootLibrary();
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2020 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
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Semantum Oy - initial API and implementation
+ *******************************************************************************/
+package org.simantics.db;
+
+/**
+ * @author Tuukka Lehtonen
+ * @since 1.43.0
+ */
+public interface ResourceLocator {
+
+ /**
+ * Layer0 is an integral part of Simantics database modelling and for performance
+ * reasons deserves simplest possible access to its resource class.
+ *
+ * @return returns the internally cached
+ * <code>org.simantics.layer0.Layer0</code> instance
+ */
+ public <T> T l0();
+
+}
org.eclipse.core.runtime;bundle-version="3.6.0",
org.eclipse.ui;bundle-version="3.6.0",
org.simantics.ui;bundle-version="1.0.0",
- com.fasterxml.jackson.core.jackson-core;bundle-version="2.8.8",
+ com.fasterxml.jackson.core.jackson-core;bundle-version="[2.8.11,2.9.0)",
org.slf4j.api,
- com.fasterxml.jackson.core.jackson-databind;bundle-version="2.8.8"
+ com.fasterxml.jackson.core.jackson-databind;bundle-version="[2.8.11,2.9.0)"
Automatic-Module-Name: org.simantics.debug.graphical
out.print(" HOR");
else
out.print(" VER");
+ if (hidden)
+ out.print(" HIDDEN");
+ out.print(" @ " + position);
for(RoutePoint point : points) {
out.print(" ("+point.x+","+point.y+")");
}
out.print(" (data=" + data + ")");
+ if (nextTransient != null)
+ out.print(" (next transient line=" + nextTransient.getData() + ")");
+ if (terminal != null)
+ out.print(" (terminal=" + terminal.getData() + ")");
out.println();
}
public boolean isDegenerated() {
return p1.getX() == p2.getX() && p1.getY() == p2.getY();
}
+
+ @Override
+ public String toString() {
+ return String.format("(%f, %f) (%f, %f)", p1.getX(), p1.getY(), p2.getX(), p2.getY());
+ }
}
package org.simantics.diagram.connection.splitting;
-import gnu.trove.set.hash.THashSet;
-
+import java.awt.geom.Line2D;
import java.awt.geom.Point2D;
+import java.util.ArrayList;
import org.simantics.diagram.connection.RouteGraph;
import org.simantics.diagram.connection.RouteLine;
import org.simantics.diagram.connection.RouteNode;
+import org.simantics.diagram.connection.RoutePoint;
import org.simantics.diagram.connection.RouteTerminal;
+import org.simantics.diagram.connection.segments.Segment;
+
+import gnu.trove.set.hash.THashSet;
public class SplittedRouteGraph {
public final RouteLine splitLine;
}
}
- /**
+ public static final class PickResult {
+ /**
+ * The connection route line nearest to {@link #pickPoint}.
+ */
+ public final RouteLine nearestLine;
+ /**
+ * Original pick point in canvas coordinates.
+ */
+ public final Point2D pickPoint;
+ /**
+ * Intersection point in canvas coordinates of {@link #nearestLine} and
+ * perpendicular line from {@link #pickPoint} to {@link #nearestLine}.
+ */
+ public final Point2D intersectionPoint;
+
+ public PickResult(RouteLine nearestLine, Point2D pickPoint, Point2D intersectionPoint) {
+ this.nearestLine = nearestLine;
+ this.pickPoint = pickPoint;
+ this.intersectionPoint = intersectionPoint;
+ }
+ }
+
+ public static PickResult pickNearestLine(RouteGraph rg, double x, double y) {
+ Segment nearestSegment = null;
+ RouteLine nearestLine = null;
+
+ ArrayList<Segment> segments = new ArrayList<>();
+ double minDistanceSq = Double.MAX_VALUE;
+ for (RouteLine line : rg.getAllLines()) {
+ segments.clear();
+ line.collectSegments(segments);
+ for (Segment segment : segments) {
+ RoutePoint p1 = segment.p1;
+ RoutePoint p2 = segment.p2;
+ double distanceSq = Line2D.ptSegDistSq(p1.getX(), p1.getY(), p2.getX(), p2.getY(), x, y);
+ if (distanceSq < minDistanceSq) {
+ minDistanceSq = distanceSq;
+ nearestSegment = segment;
+ nearestLine = line;
+ }
+ }
+ }
+
+ if (nearestSegment == null)
+ return null;
+
+ RoutePoint p1 = nearestSegment.p1;
+ RoutePoint p2 = nearestSegment.p2;
+ Point2D p = pointToLineIntersection(p1.getX(), p1.getY(), p2.getX(), p2.getY(), x, y);
+ return new PickResult(nearestLine, new Point2D.Double(x, y), p);
+ }
+
+ private static Point2D pointToLineIntersection(double x1, double y1, double x2, double y2, double px, double py) {
+ double d = Math.pow(x2 - x1, 2.0) + Math.pow(y2 - y1, 2.0);
+ if (d == 0) {
+ return new Point2D.Double(x1, y1);
+ } else {
+ double u = ((px - x1) * (x2 - x1) + (py - y1) * (y2 - y1)) / d;
+ if (u > 1.0) {
+ return new Point2D.Double(x2, y2);
+ } else if (u <= 0.0) {
+ return new Point2D.Double(x1, y1);
+ } else {
+ return new Point2D.Double(x2 * u + x1 * (1.0-u), (y2 * u + y1 * (1.0- u)));
+ }
+ }
+ }
+
+ /**
* @param point
* @param line
* @return the specified point instance snapped to the specified line
import org.simantics.db.exception.DatabaseException;
import org.simantics.db.management.ISessionContext;
import org.simantics.db.procedure.Procedure;
+import org.simantics.diagram.runtime.RuntimeDiagramManager;
import org.simantics.diagram.stubs.DiagramResource;
import org.simantics.utils.ObjectUtils;
import org.simantics.utils.ui.SWTUtils;
}
protected void editorActivated(IEditorPart part) {
- Resource resource = part.getAdapter(Resource.class);
+ RuntimeDiagramManager rdm = part.getAdapter(RuntimeDiagramManager.class);
+ Resource resource = null;
+ if (rdm != null)
+ resource = rdm.getRuntimeDiagram();
+ if (resource == null)
+ resource = part.getAdapter(Resource.class);
lastInputResource = resource;
if (ownerIsVisible) {
testAndChangeInput(resource);
else this.priority = 0;
GroupStyleProfileEntry.this.style = graph.adapt(style, Style.class);
+ GroupStyleProfileEntry.this.style.setPriority(this.priority);
GroupStyleProfileEntry.this.group = graph.adapt(group, Group.class);
}
ThreadUtils.syncExec(workerThread, new Runnable() {
@Override
public void run() {
- try {
+ try {
cctx.getDefaultHintContext().setHint(Hints.KEY_PAGE_DESC, _marginaaliViiva);
+ if (!fitDiagramContentsToPageMargins) {
+ // Prevent PDF printing from drawing page borders if the
+ // print area is fitted directly to the page size.
+ // This avoids unwanted black half-visible edges.
+ cctx.getDefaultHintContext().setHint(Hints.KEY_DISPLAY_PAGE, false);
+ }
String bottomLabel = diagramName;
if ( drawingTemplate != null && activeProfileEntries.contains(TMPL.DrawingTemplate) ) bottomLabel = null;
* @throws DatabaseException
*/
public static Resource join(WriteGraph g, Resource flag, Resource otherFlag) throws DatabaseException {
+ return join(g, flag, otherFlag, true);
+ }
+
+ /**
+ * @param g
+ * @param flag
+ * @param otherFlag
+ * @return the created DIA.ConnectionJoin instance
+ * @throws DatabaseException
+ */
+ public static Resource join(WriteGraph g, Resource flag, Resource otherFlag, boolean activateDiagramMapping) throws DatabaseException {
DiagramResource DIA = DiagramResource.getInstance(g);
StructuralResource2 STR = StructuralResource2.getInstance(g);
Resource connectionJoin = g.newResource();
g.claim(connectionJoin, DIA.JoinsFlag, flag);
g.claim(connectionJoin, DIA.JoinsFlag, otherFlag);
- IActivationManager manager = g.getService(IActivationManager.class);
- for(Resource diagram : OrderedSetUtils.getSubjects(g, flag))
- manager.activateOnce(g, diagram);
- for(Resource diagram : OrderedSetUtils.getSubjects(g, otherFlag))
- manager.activateOnce(g, diagram);
+ if (activateDiagramMapping) {
+ activateMappingForParentDiagramsOf(g, flag, otherFlag);
+ }
+
return connectionJoin;
}
+ public static void activateMappingForParentDiagramsOf(WriteGraph graph, Resource... elements) throws DatabaseException {
+ IActivationManager manager = graph.getService(IActivationManager.class);
+ Set<Resource> diagrams = new HashSet<>(elements.length);
+ for (Resource e : elements) {
+ diagrams.addAll(OrderedSetUtils.getSubjects(graph, e));
+ }
+ for (Resource diagram : diagrams) {
+ manager.activateOnce(graph, diagram);
+ }
+ }
+
public static void disconnectFlag(WriteGraph graph, Resource flag) throws DatabaseException {
// Remove any :ConnectionJoin's this flag is joined by
// if there's less than two flags joined by the join.
return flags;
}
-
-}
+}
\ No newline at end of file
package org.simantics.diagram.flag;
-import gnu.trove.map.hash.TObjectIntHashMap;
-
import java.awt.geom.AffineTransform;
import java.awt.geom.Point2D;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.List;
import org.simantics.databoard.Bindings;
import org.simantics.db.ReadGraph;
import org.simantics.diagram.connection.RoutePoint;
import org.simantics.diagram.connection.RouteTerminal;
import org.simantics.diagram.connection.splitting.SplittedRouteGraph;
+import org.simantics.diagram.connection.splitting.SplittedRouteGraph.PickResult;
import org.simantics.diagram.content.ConnectionUtil;
import org.simantics.diagram.stubs.DiagramResource;
import org.simantics.diagram.synchronization.graph.AddElement;
+import org.simantics.diagram.synchronization.graph.BasicResources;
import org.simantics.diagram.synchronization.graph.DiagramGraphUtil;
import org.simantics.diagram.synchronization.graph.RouteGraphModification;
import org.simantics.g2d.elementclass.FlagClass;
import org.simantics.modeling.ModelingResources;
import org.simantics.structural.stubs.StructuralResource2;
+import gnu.trove.map.hash.TObjectIntHashMap;
+
/**
* A class that handles splitting a route graph connection in two with diagram
* local flags.
RouteGraphModification modis = new RouteGraphModification(ss, rg);
TObjectIntHashMap<RouteNode> idMap = modis.getIdMap();
+ if (DEBUG) {
+ System.out.println("Split canvas position: " + splitCanvasPos);
+ rg.print();
+ }
+
// Find the edge to disconnect in the graph.
// Bisect the nearest route line.
- RouteLine line = SplittedRouteGraph.findNearestLine(rg, splitCanvasPos);
- if (DEBUG)
- rg.print();
- if (line == null)
+ PickResult picked = SplittedRouteGraph.pickNearestLine(rg, splitCanvasPos.getX(), splitCanvasPos.getY());
+ if (picked == null)
return;
+
+ RouteLine line = picked.nearestLine;
+
if (DEBUG) {
+ System.out.println("picked nearest line:");
line.print(System.out);
for (RoutePoint rp : line.getPoints())
System.out.println("RP: " + rp.getX() + ", " + rp.getY());
}
// Get exact intersection point on the line
- double isectX = splitCanvasPos.getX();
- double isectY = splitCanvasPos.getY();
- SplittedRouteGraph srg;
- if (line.isHorizontal()) {
- isectY = line.getPosition();
- srg = rg.splitGraph(line, isectX);
- }
- else {
- isectX = line.getPosition();
- srg = rg.splitGraph(line, isectY);
- }
+ double isectX = picked.intersectionPoint.getX();
+ double isectY = picked.intersectionPoint.getY();
+ SplittedRouteGraph srg = rg.splitGraph(line, line.isHorizontal() ? isectX : isectY);
if (DEBUG)
System.out.println(srg);
-
+
// Disconnect
if(rg.isSimpleConnection()) {
RouteNode na = srg.terminals1.iterator().next();
idMap.get(srg.splitLine)
));
}
-
- ArrayList<Resource> interfaceNodes1Resources = new ArrayList<Resource>(srg.interfaceNodes1.size());
- for(RouteNode n : srg.interfaceNodes1)
- interfaceNodes1Resources.add(ss.getResource((Long)n.getData()));
- ArrayList<Resource> interfaceNodes2Resources = new ArrayList<Resource>(srg.interfaceNodes2.size());
- for(RouteNode n : srg.interfaceNodes2)
- interfaceNodes2Resources.add(ss.getResource((Long)n.getData()));
-
- ArrayList<Resource> lines2Resources = new ArrayList<Resource>(srg.lines2.size());
- for(RouteLine n : srg.lines2)
- lines2Resources.add(ss.getResource((Long)n.getData()));
-
- ArrayList<Resource> terminals1Resources = new ArrayList<Resource>(srg.terminals1.size());
- for(RouteTerminal n : srg.terminals1)
- terminals1Resources.add(ss.getResource((Long)n.getData()));
- ArrayList<Resource> terminals2Resources = new ArrayList<Resource>(srg.terminals2.size());
- for(RouteTerminal n : srg.terminals2)
- terminals2Resources.add(ss.getResource((Long)n.getData()));
+ ArrayList<Resource> terminals1Resources = toResources(srg.terminals1);
+ ArrayList<Resource> terminals2Resources = toResources(srg.terminals2);
+
+ boolean mustFlip = analyzePartInputs(graph, terminals1Resources, terminals2Resources);
+
+ ArrayList<Resource> interfaceNodes1 = toResources(mustFlip ? srg.interfaceNodes2 : srg.interfaceNodes1);
+ ArrayList<Resource> interfaceNodes2 = toResources(mustFlip ? srg.interfaceNodes1 : srg.interfaceNodes2);
+
+ ArrayList<Resource> lines2 = toResources(mustFlip ? srg.lines1 : srg.lines2);
+ ArrayList<Resource> terminals1 = mustFlip ? terminals2Resources : terminals1Resources;
+ ArrayList<Resource> terminals2 = mustFlip ? terminals1Resources : terminals2Resources;
+
doSplit(graph, connection,
- interfaceNodes1Resources,
- interfaceNodes2Resources,
- lines2Resources,
- terminals1Resources,
- terminals2Resources,
+ interfaceNodes1,
+ interfaceNodes2,
+ lines2,
+ terminals1,
+ terminals2,
line.isHorizontal(),
+ mustFlip,
isectX, isectY);
modis.addModi(new RouteGraphModification.Split(
- modis.toIds(interfaceNodes1Resources),
- modis.toIds(interfaceNodes2Resources),
- modis.toIds(lines2Resources),
- modis.toIds(terminals1Resources),
- modis.toIds(terminals2Resources),
+ modis.toIds(interfaceNodes1),
+ modis.toIds(interfaceNodes2),
+ modis.toIds(lines2),
+ modis.toIds(terminals1),
+ modis.toIds(terminals2),
line.isHorizontal(),
+ mustFlip,
isectX, isectY
));
-
}
-
+
+ private ArrayList<Resource> toResources(Collection<? extends RouteNode> nodes) throws DatabaseException {
+ ArrayList<Resource> result = new ArrayList<>(nodes.size());
+ for (RouteNode n : nodes)
+ result.add(ss.getResource((Long)n.getData()));
+ return result;
+ }
+
+ /**
+ * @param graph
+ * @param terminals1
+ * @param terminals2
+ * @return <code>true</code> if inputs need to be flipped, i.e. if terminals2
+ * contains the output terminals and terminals1 doesn't.
+ * @throws DatabaseException
+ */
+ private boolean analyzePartInputs(ReadGraph graph, List<Resource> terminals1, List<Resource> terminals2) throws DatabaseException {
+ @SuppressWarnings("unused")
+ int inputs1 = 0, outputs1 = 0;
+ for(Resource connector : terminals1) {
+ if(graph.hasStatement(connector, DIA.IsHeadConnectorOf))
+ ++inputs1;
+ else
+ ++outputs1;
+ }
+ @SuppressWarnings("unused")
+ int inputs2 = 0, outputs2 = 0;
+ for(Resource connector : terminals2) {
+ if(graph.hasStatement(connector, DIA.IsHeadConnectorOf))
+ ++inputs2;
+ else
+ ++outputs2;
+ }
+
+ boolean mustFlip = outputs1 == 0;
+
+ if (DEBUG) {
+ System.out.println("inputs1: " + inputs1);
+ System.out.println("outputs1: " + outputs1);
+ System.out.println("inputs2: " + inputs2);
+ System.out.println("outputs2: " + outputs2);
+ System.out.println("=> type1: " + (mustFlip ? FlagClass.Type.In : FlagClass.Type.Out));
+ System.out.println("=> type2: " + (mustFlip ? FlagClass.Type.Out : FlagClass.Type.In));
+ System.out.println("=> must flip route graph parts to split: " + mustFlip);
+ }
+
+ return mustFlip;
+ }
+
+ private static String routeNodeDebugInfo(ReadGraph graph, Resource c) throws DatabaseException {
+ BasicResources BR = BasicResources.getInstance(graph);
+ String ctr = NameUtils.getSafeName(graph, c, true);
+ for (Resource e : graph.getObjects(c, BR.STR.Connects)) {
+ ctr += " --> " + NameUtils.getSafeName(graph, e);
+ }
+ for (Resource e : graph.getObjects(c, BR.DIA.AreConnected)) {
+ ctr += " <-> " + NameUtils.getSafeName(graph, e);
+ }
+ return ctr;
+ }
+
+ /**
+ * Internal routine that is only public because
+ * {@link RouteGraphModification#runUpdates(WriteGraph)} needs to invoke it.
+ *
+ * Assumes that #1 parameters will stay with the existing connection and #2
+ * parameters will go to the newly created connection.
+ */
public void doSplit(WriteGraph graph,
Resource connection,
ArrayList<Resource> interfaceNodes1Resources,
ArrayList<Resource> lines2Resources,
ArrayList<Resource> terminals1Resources,
ArrayList<Resource> terminals2Resources,
- boolean isHorizontal,
+ boolean isHorizontal,
+ boolean invertFlagRotation,
double isectX, double isectY) throws DatabaseException {
+ // 1 = output, 2 = input
+ FlagClass.Type
+ type1 = FlagClass.Type.Out,
+ type2 = FlagClass.Type.In;
+
if (DEBUG) {
System.out.println("doSplit:");
System.out.println(NameUtils.getSafeName(graph, connection, true));
for (Resource i : interfaceNodes1Resources)
- System.out.println("i1: " + NameUtils.getSafeName(graph, i, true));
+ System.out.println("i1: " + routeNodeDebugInfo(graph, i));
for (Resource i : interfaceNodes2Resources)
- System.out.println("i2: " + NameUtils.getSafeName(graph, i, true));
+ System.out.println("i2: " + routeNodeDebugInfo(graph, i));
for (Resource l : lines2Resources)
- System.out.println("l2r: " + NameUtils.getSafeName(graph, l, true));
+ System.out.println("l2r: " + routeNodeDebugInfo(graph, l));
for (Resource t : terminals1Resources)
- System.out.println("t1: " + NameUtils.getSafeName(graph, t, true));
+ System.out.println("t1: " + routeNodeDebugInfo(graph, t));
for (Resource t : terminals2Resources)
- System.out.println("t2: " + NameUtils.getSafeName(graph, t, true));
+ System.out.println("t2: " + routeNodeDebugInfo(graph, t));
System.out.println("is horizontal: " + isHorizontal);
System.out.println("@(x,y): " + isectX + ", " + isectY);
}
ConnectionUtil cu = new ConnectionUtil(graph);
Resource diagram = OrderedSetUtils.getSingleOwnerList(graph, connection, DIA.Diagram);
- Resource connectionType = graph.getSingleType(connection, DIA.Connection);
+ Resource diagramConnectionType = graph.getSingleType(connection, DIA.Connection);
Resource hasConnectionType = graph.getPossibleObject(connection, STR.HasConnectionType);
- Resource newConnection = cu.newConnection(diagram, connectionType);
+ Resource newConnection = cu.newConnection(diagram, diagramConnectionType);
if (hasConnectionType != null)
graph.claim(newConnection, STR.HasConnectionType, null, hasConnectionType);
// Give running name to connection increment the counter attached to the diagram.
AddElement.claimFreshElementName(graph, diagram, newConnection);
+ String commonLabel = DiagramFlagPreferences
+ .getActiveFlagLabelingScheme(graph)
+ .generateLabel(graph, diagram);
+
+ Point2D pos1, pos2;
+ double theta;
+ double flagDist = 3.0;
+ if(isHorizontal) {
+ theta = 0.0;
+ pos1 = new Point2D.Double(isectX-flagDist, isectY);
+ pos2 = new Point2D.Double(isectX+flagDist, isectY);
+ } else {
+ theta = Math.PI*0.5;
+ pos1 = new Point2D.Double(isectX, isectY-flagDist);
+ pos2 = new Point2D.Double(isectX, isectY+flagDist);
+ }
+
+ if (invertFlagRotation) {
+ theta += Math.PI;
+ Point2D p = pos1;
+ pos1 = pos2;
+ pos2 = p;
+ }
+
// WORKAROUND for mapping problems:
// If any terminal of the split connection contains a flag, make sure their STR.Joins relations are all removed
// to give mapping a chance to fix them properly.
graph.claim(rn, predicate, newConnection);
}
- // 1 = output, 2 = input
- FlagClass.Type type1, type2;
-
- FlagLabelingScheme scheme = DiagramFlagPreferences.getActiveFlagLabelingScheme(graph);
- String commonLabel = scheme.generateLabel(graph, diagram);
-
// Create flags and connect both disconnected ends to them.
- Point2D pos1, pos2;
- double theta;
- double flagDist = 3.0;
- if(isHorizontal) {
- theta = 0.0;
- pos1 = new Point2D.Double(isectX-flagDist, isectY);
- pos2 = new Point2D.Double(isectX+flagDist, isectY);
- }
- else {
- theta = Math.PI*0.5;
- pos1 = new Point2D.Double(isectX, isectY-flagDist);
- pos2 = new Point2D.Double(isectX, isectY+flagDist);
- }
-
- // Chooses flag directions
- {
- @SuppressWarnings("unused")
- int inputs1 = 0, outputs1 = 0;
- for(Resource connector : terminals1Resources) {
- if(graph.hasStatement(connector, DIA.IsHeadConnectorOf))
- ++inputs1;
- else
- ++outputs1;
- }
- @SuppressWarnings("unused")
- int inputs2 = 0, outputs2 = 0;
- for(Resource connector : terminals2Resources) {
- if(graph.hasStatement(connector, DIA.IsHeadConnectorOf))
- ++inputs2;
- else
- ++outputs2;
- }
-
- if(outputs1 == 0) {
- type1 = FlagClass.Type.In;
- type2 = FlagClass.Type.Out;
- theta += Math.PI;
- }
- else {
- type1 = FlagClass.Type.Out;
- type2 = FlagClass.Type.In;
- }
- if (DEBUG) {
- System.out.println("inputs1: " + inputs1);
- System.out.println("outputs1: " + outputs1);
- System.out.println("=> type1: " + type1);
- System.out.println("inputs2: " + inputs2);
- System.out.println("outputs2: " + outputs2);
- System.out.println("=> type2: " + type2);
- }
- }
Resource flag1 = createFlag(graph, diagram, getFlagTransform(pos1, theta), type1, commonLabel);
Resource flag2 = createFlag(graph, diagram, getFlagTransform(pos2, theta), type2, commonLabel);
+
if (DEBUG) {
+ System.out.println("LABEL FOR NEW FLAGS: " + commonLabel);
System.out.println("FLAG1: " + NameUtils.getSafeName(graph, flag1, true));
System.out.println("FLAG2: " + NameUtils.getSafeName(graph, flag2, true));
}
-// System.out.println("conn1: " + NameUtils.getSafeLabel(graph, type1 == FlagClass.Type.In ? DIA.HasPlainConnector : DIA.HasArrowConnector));
-// System.out.println("conn2: " + NameUtils.getSafeLabel(graph, type2 == FlagClass.Type.In ? DIA.HasPlainConnector : DIA.HasArrowConnector));
- Resource flagConnector1 = cu.newConnector(connection,
- type1 == FlagClass.Type.In ? DIA.HasPlainConnector : DIA.HasArrowConnector);
- Resource flagConnector2 = cu.newConnector(newConnection,
- type2 == FlagClass.Type.In ? DIA.HasPlainConnector : DIA.HasArrowConnector);
+ Resource flagConnector1 = cu.newConnector(connection, DIA.HasArrowConnector);
+ Resource flagConnector2 = cu.newConnector(newConnection, DIA.HasPlainConnector);
graph.claim(flag1, DIA.Flag_ConnectionPoint, flagConnector1);
graph.claim(flag2, DIA.Flag_ConnectionPoint, flagConnector2);
double position = isHorizontal ? isectY : isectX;
- connectFlag(graph, isHorizontal, position, connection, flagConnector1,
- interfaceNodes1Resources);
- connectFlag(graph, isHorizontal, position, newConnection, flagConnector2,
- interfaceNodes2Resources);
-
- FlagUtil.join(graph, flag1, flag2);
-
- // Move mapping relations to new connection if necessary
- if(type1 == FlagClass.Type.In) {
- moveStatements(graph, connection, newConnection, MOD.ElementToComponent);
- moveStatements(graph, connection, newConnection, MOD.DiagramConnectionToConnection);
- moveStatements(graph, connection, newConnection, MOD.DiagramConnectionToConnectionSpecial);
- FlagUtil.fixBindsStatements(graph, graph.getPossibleObject(newConnection, MOD.DiagramConnectionToConnection));
- }
- else
- FlagUtil.fixBindsStatements(graph, graph.getPossibleObject(connection, MOD.DiagramConnectionToConnection));
+ connectFlag(graph, isHorizontal, position, connection, flagConnector1, interfaceNodes1Resources);
+ connectFlag(graph, isHorizontal, position, newConnection, flagConnector2, interfaceNodes2Resources);
+
+ // Join the flags without activatingn diagram mapping at this point
+ FlagUtil.join(graph, flag1, flag2, false);
+ FlagUtil.fixBindsStatements(graph, graph.getPossibleObject(connection, MOD.DiagramConnectionToConnection));
+
+ // Finally ensure that all the diagrams related to the operation are mapped properly in one go
+ FlagUtil.activateMappingForParentDiagramsOf(graph, flag1, flag2);
}
/**
}
}
- private static void moveStatements(WriteGraph graph, Resource from, Resource to, Resource relation) throws DatabaseException {
- if(from.equals(to))
- return;
- for(Statement stat : graph.getStatements(from, relation))
- if(stat.getSubject().equals(from))
- graph.claim(to, stat.getPredicate(), stat.getObject());
- graph.deny(from, relation);
- }
-
private void connectFlag(WriteGraph graph, boolean isHorizontal, double position, Resource connection, Resource flagConnector, Collection<Resource> interfaceNodes)
throws DatabaseException {
if(interfaceNodes.size() > 1) {
}
public static void splitConnection(WriteGraph graph, Resource connection, double x, double y) throws DatabaseException {
+ // TODO: provide a proper runtimeDiagram parameter to load to support also connections attached to flags attached to diagram template flag tables
RouteGraph rg = RouteGraphUtils.load(graph, null, connection);
new RouteGraphConnectionSplitter(graph).split(graph, connection, rg, new Point2D.Double(x, y));
}
Resource flag = context.element;
Resource runtimeDiagram = context.runtime;
+ if (runtimeDiagram == null)
+ return flagTransformImpl(graph, converter, context);
Resource diagram = graph.getPossibleObject(runtimeDiagram, DIA.RuntimeDiagram_HasConfiguration);
if (diagram == null)
abstract protected String getNodePrefix();
abstract protected Class<?> getNodeClass();
-
+
+ public IconButtonStyleBase(Object identity) {
+ super(identity);
+ }
+
+ public IconButtonStyleBase() {
+ super();
+ }
+
private AffineTransform translateAndScaleIfNeeded(AffineTransform tr, Vec2d offset, boolean relativeTransform) {
if(relativeTransform) {
if(!offset.isZero()) {
}
public void register(INode node) {
- // We use ths size of this map to determine whether updates are needed, this is done in AWT thread
+ // We use the size of this map to determine whether updates are needed, this is done in AWT thread
synchronized(requesters) {
if(requesters.size() == 0) {
if(state.compareAndSet(false, true)) {
- ThreadUtils.getNonBlockingWorkExecutor().scheduleAtFixedRate(this, 0, 500, TimeUnit.MILLISECONDS);
+ ThreadUtils.getNonBlockingWorkExecutor().scheduleWithFixedDelay(this, 0, 500, TimeUnit.MILLISECONDS);
}
}
ICanvasContext context = DiagramNodeUtil.getPossibleCanvasContext((G2DNode)node);
Resource composite = graph.getPossibleObject(diagram, ModelingResources.getInstance(graph).DiagramToComposite);
if (composite != null) {
variable = Variables.getPossibleVariable(graph, composite);
+ } else {
+ variable = Variables.getPossibleVariable(graph, diagram);
}
}
this.group = group;
}
+ public ISymbolItem getSubject() {
+ return proxy;
+ }
+
@Override
public String getName() {
return proxy.getName();
import org.simantics.diagram.symbolcontribution.CompositeSymbolGroup;
import org.simantics.diagram.symbolcontribution.IIdentifiedObject;
import org.simantics.diagram.symbolcontribution.ISymbolProvider;
-import org.simantics.diagram.symbolcontribution.IdentifiedObject;
import org.simantics.diagram.symbolcontribution.SymbolProviderFactory;
import org.simantics.diagram.symbollibrary.IModifiableSymbolGroup;
import org.simantics.diagram.symbollibrary.ISymbolGroup;
json.append(" \"res\" : [");
int pos = 0;
for(int i=0;i<res.length;i++) {
- if(pos > 0) json.append(",");
- Object r = res[i];
- if(r instanceof IdentifiedObject) {
- Object id = ((IdentifiedObject) r).getId();
- if(id instanceof IAdaptable) {
- Object resource = ((IAdaptable) id).getAdapter(Resource.class);
- if(resource != null) {
- long rid = ((Resource)resource).getResourceId();
- json.append(Long.toString(rid));
- pos++;
- }
- }
- }
+ if(pos > 0) json.append(",");
+ Object r = res[i];
+ if(r instanceof IAdaptable) {
+ Resource resource = ((IAdaptable) r).getAdapter(Resource.class);
+ if(resource != null) {
+ long rid = resource.getResourceId();
+ json.append(Long.toString(rid));
+ pos++;
+ }
+ }
}
json.append("] }");
- StringSelection text = new StringSelection(json.toString());
- PlaintextTransfer plainText = new PlaintextTransfer(json.toString());
+ String jsonText = json.toString();
+ StringSelection text = new StringSelection(jsonText);
+ PlaintextTransfer plainText = new PlaintextTransfer(jsonText);
return new MultiTransferable(local, text, plainText);
*******************************************************************************/
package org.simantics.diagram.synchronization.graph;
-import gnu.trove.map.hash.THashMap;
-
import java.util.Map;
import java.util.Set;
import java.util.function.BiFunction;
import org.simantics.graph.db.TransferableGraphs;
import org.simantics.graph.representation.TransferableGraph1;
import org.simantics.layer0.Layer0;
+import org.simantics.utils.datastructures.BinaryFunction;
+
+import gnu.trove.map.hash.THashMap;
+import gnu.trove.set.hash.THashSet;
/**
* This class contains utility methods for the basic cut/copy operations
public static final boolean DEBUG_COPY = DebugPolicy.DEBUG_COPY_PASTE;
+ private static class Statement4 {
+ public final Statement stm;
+ public final Resource inverse;
+ public Statement4(Statement stm, Resource inverse) {
+ this.stm = stm;
+ this.inverse = inverse;
+ }
+ }
+
/**
* @param context a synchronization context instance, such as
* {@link GraphToDiagramSynchronizer}
* @throws DatabaseException
*/
public static Resource copy2(WriteGraph graph, Resource source,
- BiFunction<ReadGraph, Statement, StatementEvaluation> advisor) throws DatabaseException {
- return copy2(graph, source, 0, advisor, new THashMap<Object, Object>());
+ BiFunction<ReadGraph, Statement, StatementEvaluation> advisor)
+ throws DatabaseException
+ {
+ return copy2(graph, source, advisor, new THashMap<>());
}
/**
* @throws DatabaseException
*/
public static Resource copy2(WriteGraph graph, Resource source,
- BiFunction<ReadGraph, Statement, StatementEvaluation> advisor, Map<Object, Object> copyMap)
- throws DatabaseException {
- return copy2(graph, source, 0, advisor, copyMap);
+ BiFunction<ReadGraph, Statement, StatementEvaluation> advisor,
+ Map<Object, Object> copyMap)
+ throws DatabaseException
+ {
+ Set<Statement4> pendingStatements = new THashSet<>();
+ Resource result = copy2(graph, source, 0, advisor, copyMap, pendingStatements);
+ postProcessStatements(graph, copyMap, pendingStatements);
+ return result;
+ }
+
+ /**
+ * Post-process pending statement
+ *
+ * Rule: If both the subject and object of a pending source statement have
+ * been copied, then the pending statement should also be copied.
+ */
+ private static void postProcessStatements(
+ WriteGraph graph,
+ Map<Object, Object> copyMap,
+ Set<Statement4> pendingStatements)
+ throws DatabaseException
+ {
+ if (pendingStatements.isEmpty())
+ return;
+
+ if (DEBUG_COPY)
+ System.out.println("post processing " + pendingStatements.size() + " pending statements");
+ for (Statement4 srcStm : pendingStatements) {
+ // At this point, it is certain that srcStm subject has been copied
+ // but test it anyway.
+ Resource subjectCopy = (Resource) copyMap.get(srcStm.stm.getSubject());
+ Resource objectCopy = (Resource) copyMap.get(srcStm.stm.getObject());
+ if (subjectCopy == null || objectCopy == null) {
+ if (DEBUG_COPY)
+ System.out.println("skipping pending statement: " + NameUtils.toString(graph, srcStm.stm));
+ continue;
+ }
+ if (DEBUG_COPY)
+ System.out.println("copying pending statement: " + NameUtils.toString(graph, srcStm.stm));
+ graph.claim(subjectCopy, srcStm.stm.getPredicate(), srcStm.inverse, objectCopy);
+ }
}
private static Resource copy2(final WriteGraph graph, final Resource source, final int level,
- BiFunction<ReadGraph, Statement, StatementEvaluation> advisor, Map<Object, Object> copyMap)
+ BiFunction<ReadGraph, Statement, StatementEvaluation> advisor, Map<Object, Object> copyMap,
+ Set<Statement4> pendingSourceStatements)
throws DatabaseException {
if (DEBUG_COPY)
System.out.println("[" + level + "] CopyAdvisorUtil.copy(" + NameUtils.getSafeName(graph, source) + ", advisor=" + advisor + ")");
if (DEBUG_COPY)
System.out.println("[" + level + "]\t\tcopy whole object");
- Resource clone = copy2(graph, obj, level + 1, advisor, copyMap);
+ Resource clone = copy2(graph, obj, level + 1, advisor, copyMap, pendingSourceStatements);
graph.claim(copy, relation, inverse, clone);
}
} else {
- if (DEBUG_COPY)
- System.out.println("[" + level + "]\t\tskipping statement");
+ if (graph.isSubrelationOf(relation, L0.IsRelatedTo)) {
+ if (DEBUG_COPY)
+ System.out.println("[" + level + "]\t\tmarking statement as pending for post-processing");
+ pendingSourceStatements.add(new Statement4(stm, inverse));
+ } else {
+ if (DEBUG_COPY)
+ System.out.println("[" + level + "]\t\tskipping weak statement");
+ }
}
}
}
List<Resource> graphOrder = OrderedSetUtils.toList(g, l);
Set<Resource> graphContents = new HashSet<Resource>(graphOrder);
- List<Resource> diagramOrder = new ArrayList<Resource>(order.size());
- Map<Resource, Integer> diagramOrderIndex = new HashMap<Resource, Integer>(order.size());
- int i = 0;
+ List<Resource> newGraphOrder = new ArrayList<>();
for (IElement e : order) {
Object obj = ElementUtils.getObject(e);
if (obj instanceof Resource) {
// This prevents errors in situations where #order contains
// elements that no longer exist in the diagram.
if (graphContents.contains(r)) {
- diagramOrder.add(r);
- diagramOrderIndex.put(r, Integer.valueOf(i));
- ++i;
+ newGraphOrder.add(r);
}
}
}
- // Reorder the backend list according to diagramOrder
- i = 0;
- for (Resource r : graphOrder) {
- Integer di = diagramOrderIndex.get(r);
- if (di != null) {
- int targetIndex = di;
- int graphIndex = i++;
- if (graphIndex != targetIndex) {
- // Check if the predecessor of r is already correct.
- // If it is, we don't have to do anything for r.
- Resource graphPrev = OrderedSetUtils.prev(g, l, r);
- Resource after = null;
- if (targetIndex == 0) {
- after = l;
- if (l.equals(graphPrev))
- continue;
- } else {
- after = diagramOrder.get(targetIndex - 1);
- if (after.equals(graphPrev))
- continue;
- }
-
- // r needs to be repositioned.
- OrderedSetUtils.remove(g, l, r);
- OrderedSetUtils.addAfter(g, l, after, r);
+ // Safety measure for possible missing elements
+ if (graphOrder.size() != newGraphOrder.size()) {
+ Set<Resource> added = new HashSet<Resource>(newGraphOrder);
+ for (Resource r : graphOrder) {
+ if (!added.contains(r)) {
+ newGraphOrder.add(r);
}
}
}
+
+ OrderedSetUtils.reorder(g, l, newGraphOrder);
}
}
int[] lines2;
int[] terminals1;
int[] terminals2;
- boolean isHorizontal;
+ boolean isHorizontal;
+ boolean invertFlagRotation;
double isectX;
double isectY;
public Split(int[] interface1, int[] interface2, int[] lines2,
int[] terminals1, int[] terminals2, boolean isHorizontal,
+ boolean invertFlagRotation,
double isectX, double isectY) {
this.interface1 = interface1;
this.interface2 = interface2;
this.terminals1 = terminals1;
this.terminals2 = terminals2;
this.isHorizontal = isHorizontal;
+ this.invertFlagRotation = invertFlagRotation;
this.isectX = isectX;
this.isectY = isectY;
}
this.terminals1 = readInts(it);
this.terminals2 = readInts(it);
this.isHorizontal = Boolean.parseBoolean(it.next());
+ this.invertFlagRotation = Boolean.parseBoolean(it.next());
this.isectX = Double.parseDouble(it.next());
this.isectY = Double.parseDouble(it.next());
}
b.append("$");
b.append(isHorizontal);
b.append("$");
+ b.append(invertFlagRotation);
+ b.append("$");
b.append(isectX);
b.append("$");
b.append(isectY);
toResources(modi.terminals1),
toResources(modi.terminals2),
modi.isHorizontal,
+ modi.invertFlagRotation,
modi.isectX,
modi.isectY
);
StandardAssertedGraphPropertyVariable ass = (StandardAssertedGraphPropertyVariable)property;
if("dataDefinitions".equals(ass.property.name) || "commands".equals(ass.property.name) || "pollingFunction".equals(ass.property.name)) {
storePropertyValueAndExceptions(graph, parent, ass.property.name, property, map);
+ continue;
}
- continue;
}
Resource predicate = property.getPossiblePredicateResource(graph);
if(predicate != null) {
StandardAssertedGraphPropertyVariable ass = (StandardAssertedGraphPropertyVariable)property;
if("dataDefinitions".equals(ass.property.name) || "commands".equals(ass.property.name) || "pollingFunction".equals(ass.property.name)) {
result.add(ass.property.name);
+ continue;
}
- continue;
}
Resource predicate = property.getPossiblePredicateResource(graph);
if(predicate != null) {
package org.simantics.document.server.request;
import org.simantics.db.ReadGraph;
+import org.simantics.db.common.request.UnaryRead;
import org.simantics.db.exception.DatabaseException;
import org.simantics.db.layer0.variable.Variable;
import org.simantics.db.layer0.variable.Variables;
-import org.simantics.db.request.Read;
import org.simantics.document.server.handler.AbstractEventHandler;
import org.simantics.structural.stubs.StructuralResource2;
-public class HandleEventRequest implements Read<AbstractEventHandler> {
-
- final String id;
+public class HandleEventRequest extends UnaryRead<String, AbstractEventHandler> {
public HandleEventRequest(String id) {
- this.id = id;
+ super(id);
}
@Override
StructuralResource2.getInstance(graph);
- Variable variable = Variables.getPossibleVariable(graph, id);
+ Variable variable = Variables.getPossibleVariable(graph, parameter);
if(variable == null) return null;
// System.err.println("EVENT " + variable.getURI(graph));
if(handler instanceof AbstractEventHandler)
return (AbstractEventHandler) handler;
else
- throw new DatabaseException("Handler for " + id + " is not instance of AbstractEventHandler (it is instance of " + (handler != null ? handler.getClass() : null) + ")");
+ throw new DatabaseException("Handler for " + parameter + " is not instance of AbstractEventHandler (it is instance of " + (handler != null ? handler.getClass() : null) + ")");
}
}
\ No newline at end of file
G2D.Color <T L0.Literal
@L0.assert L0.HasDataType $(Float[4])
+ @L0.assert L0.HasValueType "Vector Float"
L0.HasDescription "A 4-component BGRA color as floats."
+
G2D.HasColor <R L0.HasProperty : L0.FunctionalRelation
L0.HasLabel "Color"
--> G2D.Color
return result;
}
+
+ /**
+ * We need to have separate class for SelectionNode, so that SCLSceneGraph can handle this properly.
+ *
+ */
+ public static class SelectionShapeNode extends ShapeNode {
+
+ private static final long serialVersionUID = -5393630944240940166L;
+
+ }
+
public void paintSelectionFrame(int selectionId, G2DParentNode elementNode, G2DParentNode selectionNode, final IElement e, Color color) {
// The element node already has the correct transform.
AffineTransform selectionTransform = ElementUtils.getTransform(e);// no it doesnt ... new AffineTransform();
Outline outline = (Outline) es.getAdapter(Outline.class);
if (outline == null || outline.getElementShape(e) == null)
continue;
- ShapeNode shapenode = shapeholder.getOrCreateNode(getNodeId("outline", e, es), ShapeNode.class);
+ ShapeNode shapenode = shapeholder.getOrCreateNode(getNodeId("outline", e, es), SelectionShapeNode.class);
// shapenode.setShape(es.getSelectionShape(e));
// shapenode.setStroke(SELECTION_STROKE);
// shapenode.setScaleStroke(true);
G2DParentNode shapeholder = selectionNode.getOrCreateNode(getNodeId("outlines", e), G2DParentNode.class);
for (SelectionOutline es : shapeHandlers) {
- ShapeNode shapenode = shapeholder.getOrCreateNode(getNodeId("outline", e, es), ShapeNode.class);
+ ShapeNode shapenode = shapeholder.getOrCreateNode(getNodeId("outline", e, es), SelectionShapeNode.class);
// shapenode.setShape(es.getSelectionShape(e));
// shapenode.setStroke(SELECTION_STROKE);
// shapenode.setScaleStroke(true);
int index = elements.indexOf(e);
if (index != -1 && selectedElements.contains(e)) {
changed |= diagram.moveTo(e, nextPos);
- nextPos = index;
}
+ nextPos = index;
}
if (changed) {
notifyZOrderListeners(diagram);
int index = elements.indexOf(e);
if (index != -1 && selectedElements.contains(e)) {
changed |= diagram.moveTo(e, nextPos);
- nextPos = index;
}
+ nextPos = index;
}
if (changed) {
notifyZOrderListeners(diagram);
pickRect = s.getBounds2D();
Shape es = ElementUtils.getElementShapeOrBounds(e);
+ // getElementShapeOrBounds returns shape or bounds in local coords!
+ es = ElementUtils.getTransform(e).createTransformedShape(es);
PathIterator iter = es.getPathIterator(null);
Collection<double[]> segments = new ArrayList<double[]>();
PathUtils.toLineSegments(iter, segments);
for (double[] seg : segments) {
if (pickRect.intersectsLine(seg[0], seg[1], seg[2], seg[3]))
return true;
+ if (pickRect.contains(seg[0], seg[1]))
+ return true;
+ if (pickRect.contains(seg[2], seg[3]))
+ return true;
}
+
return false;
}
ctx.getThreadAccess().asyncExec(() -> {
//System.out.println(Thread.currentThread() + ": update scene graph(" + el + ")");
// Update scene graph and repaint.
- el.getElementClass().getSingleItem(GalleryItemSGNode.class).update(el);
- ctx.getContentContext().setDirty();
+ if (!ctx.isDisposed()) {
+ el.getElementClass().getSingleItem(GalleryItemSGNode.class).update(el);
+ ctx.getContentContext().setDirty();
+ }
});
break;
}
import org.simantics.g2d.image.Image;
import org.simantics.scenegraph.Node;
import org.simantics.scenegraph.g2d.G2DParentNode;
-import org.simantics.scenegraph.g2d.nodes.ShapeNode;
+import org.simantics.scenegraph.g2d.nodes.ShapeNode2;
/**
* @author Tuukka Lehtonen
private static final EnumSet<Feature> defaultFeats = VECTOR;
Shape shape;
- Paint paint;
+ Paint fillPaint;
+ Paint strokePaint;
Stroke stroke;
EnumSet<Feature> feats;
boolean scaleStroke = false;
}
public ShapeImage(Shape shape, Paint fill, Stroke stroke, boolean scaleStroke) {
- this(shape, fill, stroke, scaleStroke, defaultFeats);
+ this(shape, fill, stroke, fill, scaleStroke, defaultFeats);
}
public ShapeImage(Shape shape, Paint fill, Stroke stroke, EnumSet<Feature> features) {
- this(shape, fill, stroke, false, features);
+ this(shape, fill, stroke, fill, false, features);
+ }
+ public ShapeImage(Shape shape, Paint fill, Stroke stroke, Paint strokeColor, boolean scaleStroke) {
+ this(shape, fill, stroke, strokeColor, scaleStroke, defaultFeats);
}
- public ShapeImage(Shape shape, Paint fill, Stroke stroke, boolean scaleStroke, EnumSet<Feature> features) {
+ public ShapeImage(Shape shape, Paint fill, Stroke stroke, Paint strokeColor, boolean scaleStroke, EnumSet<Feature> features) {
this.shape = shape;
- this.paint = fill;
+ this.fillPaint = fill;
+ this.strokePaint = strokeColor;
this.stroke = stroke;
this.scaleStroke = scaleStroke;
this.feats = features;
@Override
public Node init(G2DParentNode parent) {
- ShapeNode shapeNode = parent.getOrCreateNode("ShapeImage", ShapeNode.class);
+ ShapeNode2 shapeNode = parent.getOrCreateNode("ShapeImage", ShapeNode2.class);
shapeNode.setShape(shape);
shapeNode.setStroke(stroke);
- shapeNode.setFill(paint != null);
- shapeNode.setColor(paint != null ? paint : Color.BLACK);
+ shapeNode.setFillColor(fillPaint);
+ shapeNode.setStrokeColor(strokePaint != null ? strokePaint : Color.BLACK);
shapeNode.setScaleStroke(scaleStroke);
return shapeNode;
}
// long delay = 1000 / 25; this sounds quite frequent
long delay = 1000 / 10;
lastTrigger = System.currentTimeMillis();
- timer.scheduleAtFixedRate(task, delay, delay, TimeUnit.MILLISECONDS);
+ timer.scheduleWithFixedDelay(task, delay, delay, TimeUnit.MILLISECONDS);
}
@HintListener(Class = Hints.class, Field = "KEY_CANVAS_BOUNDS")
return;
long interval = getInterval();
- future = ThreadUtils.getNonBlockingWorkExecutor().scheduleAtFixedRate(onTimer, DEFAULT_INTERVAL, interval, TimeUnit.MILLISECONDS);
+ future = ThreadUtils.getNonBlockingWorkExecutor().scheduleWithFixedDelay(onTimer, DEFAULT_INTERVAL, interval, TimeUnit.MILLISECONDS);
}
private void cancelTimer() {
private static Path replaceExtension(Path p, String newExtension) {
String newName = p.getFileName().toString();
- if (newName.contains("."))
- newName = newName.split("\\.")[0];
+ int lastDot = newName.lastIndexOf('.');
+ if (lastDot > -1)
+ newName = newName.substring(0, lastDot);
return p.resolveSibling(newName + newExtension);
}
}
Identity consistsOf = findExternal(tg, "http://www.simantics.org/Layer0-1.1/ConsistsOf");
Identity hasName = findExternal(tg, "http://www.simantics.org/Layer0-1.1/HasName");
- for (int i = 0; i < tg.statements.length; i += 4) {
- if (tg.statements[i] == parentResource) {
- if (tg.statements[i + 1] == consistsOf.resource) {
- Identity identity = getIdentity(tg, tg.statements[i + 3]);
- if (identity != null) {
- if (identity.definition instanceof Internal) {
- Internal internal = (Internal) identity.definition;
- result.put(internal.name, identity);
- }
- } else {
- int possibleNameResource = getPossibleObject2(tg, tg.statements[i + 3], hasName);
- if (possibleNameResource != NOT_FOUND) {
- Value value = findValue(tg, possibleNameResource);
- if (value != null) {
- try {
- String name = (String) value.value.getValue(Bindings.STRING);
- result.put(name, new Identity(tg.statements[i + 3], new Internal(tg.statements[i], name)));
- } catch (AdaptException e) {
- e.printStackTrace();
+ if(consistsOf != null && hasName != null) {
+ for (int i = 0; i < tg.statements.length; i += 4) {
+ if (tg.statements[i] == parentResource) {
+ if (tg.statements[i + 1] == consistsOf.resource) {
+ Identity identity = getIdentity(tg, tg.statements[i + 3]);
+ if (identity != null) {
+ if (identity.definition instanceof Internal) {
+ Internal internal = (Internal) identity.definition;
+ result.put(internal.name, identity);
+ }
+ } else {
+ int possibleNameResource = getPossibleObject2(tg, tg.statements[i + 3], hasName);
+ if (possibleNameResource != NOT_FOUND) {
+ Value value = findValue(tg, possibleNameResource);
+ if (value != null) {
+ try {
+ String name = (String) value.value.getValue(Bindings.STRING);
+ result.put(name, new Identity(tg.statements[i + 3], new Internal(tg.statements[i], name)));
+ } catch (AdaptException e) {
+ e.printStackTrace();
+ }
}
}
}
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Require-Bundle: org.simantics.history;bundle-version="1.0.0",
org.eclipse.core.runtime;bundle-version="3.13.0",
- org.glassfish.jersey.core.jersey-server,
- jakarta.ws.rs-api,
+ org.glassfish.jersey.core.jersey-server;bundle-version="[2.25.1,2.26.0)",
+ javax.ws.rs-api,
org.simantics.scl.compiler,
org.simantics.scl.osgi,
org.eclipse.jetty.servlet,
- org.glassfish.jersey.containers.jersey-container-servlet-core,
+ org.glassfish.jersey.containers.jersey-container-servlet-core;bundle-version="[2.25.1,2.26.0)",
javax.servlet-api,
org.eclipse.jetty.server;bundle-version="9.4.24",
org.eclipse.jetty.util;bundle-version="9.4.24",
org.eclipse.jetty.io;bundle-version="9.4.24",
org.eclipse.jetty.servlets;bundle-version="9.4.24",
- com.fasterxml.jackson.core.jackson-core;bundle-version="2.8.8",
- com.fasterxml.jackson.core.jackson-annotations;bundle-version="2.8.0",
- com.fasterxml.jackson.core.jackson-databind;bundle-version="2.8.8",
- org.glassfish.jersey.media.jersey-media-json-jackson;bundle-version="2.25.1",
+ com.fasterxml.jackson.core.jackson-core;bundle-version="[2.8.11,2.9.0)",
+ com.fasterxml.jackson.core.jackson-annotations;bundle-version="[2.8.11,2.9.0)",
+ com.fasterxml.jackson.core.jackson-databind;bundle-version="[2.8.11,2.9.0)",
+ org.glassfish.jersey.media.jersey-media-json-jackson;bundle-version="[2.25.1,2.26.0)",
org.slf4j.api,
- org.glassfish.jersey.core.jersey-client,
- org.glassfish.jersey.core.jersey-common;bundle-version="2.25.1",
+ org.glassfish.jersey.core.jersey-client;bundle-version="[2.25.1,2.26.0)",
+ org.glassfish.jersey.core.jersey-common;bundle-version="[2.25.1,2.26.0)",
org.simantics.scl.runtime,
gnu.trove3;bundle-version="3.0.3",
org.simantics.charts;bundle-version="0.0.1",
*/
public class CSVFormatter {
+ /**
+ * This is the tolerance used to decide whether or not the last data point of
+ * the exported items is included in the exported material or not. If
+ * <code>0 <= (t - t(lastDataPoint) < {@value #RESAMPLING_END_TIMESTAMP_INCLUSION_TOLERANCE}</code>
+ * is true, then the last exported data point will be
+ * <code>lastDataPoint</code>, with timestamp <code>t(lastDataPoint)</code> even
+ * if <code>t > t(lastDataPoint)</code>.
+ *
+ * <p>
+ * This works around problems where floating point inaccuracy causes a data
+ * point to be left out from the the export when it would be fair for the user
+ * to expect the data to be exported would contain a point with time stamp
+ * <code>9.999999999999996</code> when sampling with time-step <code>1.0</code>
+ * starting from time <code>0.0</code>.
+ */
+ private static final double RESAMPLING_END_TIMESTAMP_INCLUSION_TOLERANCE = 1e-13;
+
List<Item> items = new ArrayList<Item>();
double from = -Double.MAX_VALUE;
double end = Double.MAX_VALUE;
// Sampling based on given startTime and timeStep
if(timeStep > 0) {
- // Find the first sample time that contains data
+ // Find the first sample time that contains data if startTime < _from
double n = Math.max(0, Math.ceil((_from-startTime) / timeStep));
time = startTime + n*timeStep;
BigDecimal bigTime = new BigDecimal(String.valueOf(time));
BigDecimal bigTimeStep = new BigDecimal(String.valueOf(timeStep));
+ // Loop kill-switch for the case where timeStep > 0
+ boolean breakAfterNextWrite = false;
+
+// System.out.println("time: " + time);
+// System.out.println("timeStep: " + timeStep);
+// System.out.println("_end: " + Double.toString(_end));
+
for (Item i : items) i.iter.gotoTime(time);
do {
if ( monitor!=null && monitor.isCanceled() ) return;
sb.append( lineFeed );
- // Read next values, and the following times
- if ( timeStep>0.0 ) {
- bigTime = bigTime.add(bigTimeStep);
- time = bigTime.doubleValue();
+ if (breakAfterNextWrite)
+ break;
+
+ // Read next values, and the following times
+ if ( timeStep>0.0 ) {
+ bigTime = bigTime.add(bigTimeStep);
+ time = bigTime.doubleValue();
+
+ // gitlab #529: prevent last data point from getting dropped
+ // due to small imprecisions in re-sampling mode.
+ double diff = time - _end;
+ if (diff > 0 && diff <= RESAMPLING_END_TIMESTAMP_INCLUSION_TOLERANCE) {
+ time = _end;
+ breakAfterNextWrite = true;
+ // Take floating point inaccuracy into account when re-sampling
+ // to prevent the last data point from being left out if there
+ // is small-enough imprecision in the last data point time stamp
+ // to be considered negligible compared to expected stepped time.
+ }
+
} else {
// Get smallest end time that is larger than current time
Double nextTime = null;
if(contains(i, time)) hasMore = true;
}
+ //System.out.println("hasMore @ " + time + " (" + bigTime + ") = " + hasMore);
if(!hasMore) break;
} while (time<=_end);
private Formatter evaluateFormatter(Format format, DecimalSeparator target) {
// Probe decimal separator
String onePointTwo = format.format(1.2);
- System.out.println("formatted zeroPointOne: " + onePointTwo);
+ //System.out.println("formatted zeroPointOne: " + onePointTwo);
DecimalSeparator formatSeparator;
if (onePointTwo.indexOf('.') != -1) {
Bundle-Activator: org.simantics.issues.ui.internal.Activator
Export-Package: org.simantics.issues.ui,
org.simantics.issues.ui.contribution,
- org.simantics.issues.ui.handler
+ org.simantics.issues.ui.handler,
+ org.simantics.issues.ui.property
Bundle-Vendor: VTT Technical Research Centre of Finland
Automatic-Module-Name: org.simantics.issues.ui
--- /dev/null
+package org.simantics.issues.ui.property;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.eclipse.jface.layout.GridDataFactory;
+import org.eclipse.jface.layout.GridLayoutFactory;
+import org.eclipse.jface.viewers.CellLabelProvider;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.TableViewerColumn;
+import org.eclipse.jface.viewers.ViewerCell;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.IWorkbenchSite;
+import org.simantics.browsing.ui.swt.widgets.impl.WidgetSupport;
+import org.simantics.databoard.Bindings;
+import org.simantics.db.ReadGraph;
+import org.simantics.db.Resource;
+import org.simantics.db.common.procedure.adapter.TransientCacheListener;
+import org.simantics.db.common.request.ResourceRead;
+import org.simantics.db.common.utils.NameUtils;
+import org.simantics.db.exception.DatabaseException;
+import org.simantics.db.management.ISessionContext;
+import org.simantics.db.request.Read;
+import org.simantics.issues.Severity;
+import org.simantics.issues.common.IssueResourceContexts;
+import org.simantics.issues.common.ListModelIssuesBySeverity;
+import org.simantics.issues.common.SimpleIssue;
+import org.simantics.layer0.Layer0;
+import org.simantics.modeling.ModelingResources;
+import org.simantics.selectionview.PropertyTabContributorImpl;
+
+/**
+ * A very simple property tab for listing issues of a selected object.
+ *
+ * @author luukkainen
+ *
+ */
+public class IssuesTab extends PropertyTabContributorImpl{
+
+
+ private TableViewer viewer;
+ private Resource model;
+ private Resource element;
+
+ private List<SimpleIssue> result;
+
+ public IssuesTab(ReadGraph graph, Resource model, Resource element) throws DatabaseException {
+ this.model = model;
+ this.element = element;
+
+ Layer0 L0 = Layer0.getInstance(graph);
+ List<Resource> contexts = getContexts(graph, element);
+ Map<Severity, List<Resource>> issuesBySeverity = graph.syncRequest(
+ new ListModelIssuesBySeverity(model, true, true, Severity.NOTE),
+ TransientCacheListener.<Map<Severity, List<Resource>>>instance());
+
+ result = new ArrayList<>();
+ for (Severity severity : Severity.values()) {
+ List<Resource> issues = issuesBySeverity.get(severity);
+ if (issues != null) {
+ for (Resource issue : issues) {
+ Set<Resource> issueContexts = graph.syncRequest(new IssueResourceContexts(issue));
+ if (!Collections.disjoint(issueContexts, contexts)) {
+ SimpleIssue si = new SimpleIssue((String) graph.getRelatedValue(issue, L0.HasLabel, Bindings.STRING),
+ severity, issue);
+ result.add(si);
+ System.out.println(si.label + " " + si.severity);
+ }
+ }
+ }
+ }
+ }
+
+
+ /**
+ * @see org.simantics.modeling.ui.diagram.style.IssueDecorationStyle
+ *
+ * @param graph
+ * @param element
+ * @return
+ * @throws DatabaseException
+ */
+ protected List<Resource> getContexts(ReadGraph graph, Resource element) throws DatabaseException {
+
+ ModelingResources MOD = ModelingResources.getInstance(graph);
+ List<Resource> result = new ArrayList<Resource>(3);
+ result.add(element);
+ Resource config = graph.getPossibleObject(element, MOD.ElementToComponent);
+ if (config != null && result.indexOf(config) == -1) result.add(config);
+ config = graph.getPossibleObject(element, MOD.DiagramConnectionToConnection);
+ if (config != null && result.indexOf(config) == -1) result.add(config);
+ // For diagram reference element support
+ config = graph.getPossibleObject(element, MOD.HasParentComponent);
+ if (config != null && result.indexOf(config) == -1) result.add(config);
+ return result;
+
+ }
+
+
+ @Override
+ public void createControls(Composite body, IWorkbenchSite site, ISessionContext context, WidgetSupport support) {
+ GridLayoutFactory.fillDefaults().numColumns(2).spacing(0, 0).applyTo(body);
+
+ viewer = new TableViewer(body);
+
+ TableViewerColumn issueColumn = new TableViewerColumn(viewer, SWT.LEFT);
+ TableViewerColumn severityColumn = new TableViewerColumn(viewer, SWT.LEFT);
+
+ issueColumn.setLabelProvider(new CellLabelProvider() {
+
+ @Override
+ public void update(ViewerCell cell) {
+ SimpleIssue issue = (SimpleIssue)cell.getElement();
+ cell.setText(issue.label);
+
+ }
+ });
+ severityColumn.setLabelProvider(new CellLabelProvider() {
+
+ @Override
+ public void update(ViewerCell cell) {
+ SimpleIssue issue = (SimpleIssue)cell.getElement();
+ cell.setText(issue.severity.name());
+ }
+ });
+
+ issueColumn.getColumn().setWidth(300);
+ issueColumn.getColumn().setText("Issue");
+
+ severityColumn.getColumn().setWidth(100);
+ severityColumn.getColumn().setText("Severity");
+
+ viewer.getTable().setHeaderVisible(true);
+ viewer.getTable().setLinesVisible(true);
+
+ viewer.setContentProvider(new IStructuredContentProvider() {
+
+ @Override
+ public Object[] getElements(Object inputElement) {
+ List<SimpleIssue> list = (List<SimpleIssue>)inputElement;
+ return list.toArray();
+ }
+ });
+
+ viewer.setInput(result);
+ GridDataFactory.fillDefaults().grab(true, true).applyTo(viewer.getControl());
+
+ }
+
+ @Override
+ public Read<String> getPartNameReadRequest(ISelection forSelection) {
+ return new ObjectTitleRead(element);
+ }
+
+ public static class ObjectTitleRead extends ResourceRead<String> {
+ public ObjectTitleRead(Resource resource) {
+ super(resource);
+ }
+
+ @Override
+ public String perform(ReadGraph graph) throws DatabaseException {
+ return NameUtils.getSafeName(graph, resource);
+ }
+ }
+
+}
//##########################################################################
MOD.ChangeInformation <T L0.Literal
+ @L0.assert L0.HasValueType "ChangeInformation"
@L0.assert L0.HasDataType ${ createdBy : String, createdAt : Long, modifiedBy : String, modifiedAt : Long }
MOD.Functions.modificationTimeTextLong : L0.Function
MOD.StructuralComponentContentDumpFunction
@L0.sclValue "structuralComponentContentDump" "Resource -> <ReadGraph> Vector Byte"
+STR.ComponentType
+ MOD.contentDumpFunction
+ MOD.StructuralComponentTypeContentDumpFunction
+ @L0.sclValue "structuralComponentTypeContentDump" "Resource -> <ReadGraph> Vector Byte"
+
SEL.GenericParameterType
MOD.contentDumpFunction
MOD.GenericParameterTypeContentDumpFunction
import org.simantics.db.Resource;
import org.simantics.db.Statement;
import org.simantics.db.common.adaption.SimpleContextualAdapter;
+import org.simantics.db.exception.AdaptionException;
import org.simantics.db.exception.DatabaseException;
import org.simantics.db.layer0.property.OrderedResource;
import org.simantics.operation.Layer0X;
return result;
}
- return null;
+ throw new AdaptionException("No obtained double available");
}
}
import org.simantics.db.common.request.UniqueRead;
import org.simantics.db.common.request.WriteRequest;
import org.simantics.db.exception.DatabaseException;
+import org.simantics.db.layer0.util.Layer0Utils;
import org.simantics.db.procedure.Listener;
import org.simantics.db.request.Read;
import org.simantics.modeling.ComponentTypeScriptRequest;
StructuralResource2 STR = StructuralResource2.getInstance(graph);
currentText = graph.getRelatedValue(resource, STR.ComponentTypeScript_code, Bindings.STRING);
Resource owner = graph.getPossibleObject(resource, STR.ComponentType_hasScript_Inverse);
- immutable = owner != null && StructuralUtils.isImmutable(graph, owner);
+ immutable = Layer0Utils.isMarkedReadOnly(graph, resource)
+ || owner != null && StructuralUtils.isImmutable(graph, owner);
errorHappened = false;
return new Document(currentText != null ? currentText : ""); //$NON-NLS-1$
}
import org.simantics.db.common.request.UniqueRead;
import org.simantics.db.exception.DatabaseException;
import org.simantics.db.layer0.request.combinations.Combinators;
-import org.simantics.db.request.Read;
import org.simantics.layer0.Layer0;
import org.simantics.scl.ui.editor.SCLSourceViewerConfigurationNew;
import org.simantics.structural.stubs.StructuralResource2;
import org.simantics.ui.workbench.IResourceEditorInput;
import org.simantics.ui.workbench.TitleUpdater;
import org.simantics.ui.workbench.ToolTipRequest;
+import org.simantics.utils.ui.ExceptionUtils;
/**
* @author Hannu Niemistö
*/
public class ComponentTypeScriptEditor extends SCLModuleEditor {
+ protected ComponentTypeScriptDocumentProvider docProvider;
+ protected String scriptType = "";
+ protected int scriptTypeIndex = 0;
+
public ComponentTypeScriptEditor() {
super();
}
@Override
protected void preInitialize() {
- setDocumentProvider(new ComponentTypeScriptDocumentProvider(this));
+ docProvider = new ComponentTypeScriptDocumentProvider(this);
+ setDocumentProvider(docProvider);
SCLSourceViewerConfigurationNew sourceViewerConfiguration = new SCLSourceViewerConfigurationNew(resourceManager);
setSourceViewerConfiguration(sourceViewerConfiguration);
-
}
protected ParametrizedRead<IResourceEditorInput, Boolean> getInputValidator() {
- return new ParametrizedRead<IResourceEditorInput, Boolean>() {
- @Override
- public Read<Boolean> get(IResourceEditorInput parameter) {
- return Combinators.constant(Boolean.TRUE);
- }
- };
+ // No-op validator that always returns true
+ return param -> Combinators.constant(Boolean.TRUE);
}
@Override
@Override
public void run(ReadGraph graph) throws DatabaseException {
StructuralResource2 STR = StructuralResource2.getInstance(graph);
- final String type = graph.getPossibleRelatedValue(script, STR.ComponentTypeScript_type);
+ String type = graph.getPossibleRelatedValue(script, STR.ComponentTypeScript_type);
if(type != null)
+ scriptType = type;
combo.getDisplay().asyncExec(() -> {
for(int i=0;i<EXECUTION_PHASES.length;++i)
if(EXECUTION_PHASES[i].equals(type)) {
combo.select(i);
+ scriptTypeIndex = i;
return;
}
});
}
combo.addSelectionListener(org.eclipse.swt.events.SelectionListener.widgetSelectedAdapter(e -> {
int id = combo.getSelectionIndex();
+ if (id == scriptTypeIndex)
+ return;
+ if (docProvider.isReadOnly(getEditorInput())) {
+ // Return configured selection
+ combo.select(scriptTypeIndex);
+ return;
+ }
+ String newType = EXECUTION_PHASES[id];
Simantics.getSession().asyncRequest((WriteGraph graph) -> {
StructuralResource2 STR = StructuralResource2.getInstance(graph);
String currentType = graph.getPossibleRelatedValue(script, STR.ComponentTypeScript_type);
- String newType = EXECUTION_PHASES[id];
if(!newType.equals(currentType))
graph.claimLiteral(script, STR.ComponentTypeScript_type, newType, Bindings.STRING);
+ }, exc -> {
+ if (exc == null) {
+ scriptType = newType;
+ scriptTypeIndex = id;
+ } else {
+ ExceptionUtils.logError(exc);
+ }
});
}));
GridDataFactory.fillDefaults().grab(true, false).applyTo(combo);
import org.simantics.db.function.DbConsumer;
import org.simantics.db.layer0.QueryIndexUtils;
import org.simantics.layer0.Layer0;
+import org.simantics.modeling.ModelingResources;
import org.simantics.modeling.userComponent.ComponentTypeCommands;
import org.simantics.modeling.utils.ComponentTypeViewerPropertyInfo;
import org.simantics.scl.runtime.function.Function2;
String newValue2 = newValue;
Resource possibleGraphType = null;
- Resource root = graph.syncRequest(new IndexRoot(componentType));
- Resource L0Res = graph.getResource("http://www.simantics.org/Layer0-1.1");
Layer0 L0 = Layer0.getInstance(graph);
-
- Collection<Resource> graphTypes1 = QueryIndexUtils.searchByTypeAndName(graph, L0Res, L0.ValueType, newValue);
- Collection<Resource> graphTypes2 = QueryIndexUtils.searchByTypeAndName(graph, root, L0.ValueType, newValue);
-
- Collection<Resource> graphTypes = new HashSet<>(graphTypes1);
- graphTypes.addAll(graphTypes2);
-
- Set<Pair<Resource, String>> candidates = new HashSet<>();
- for (Resource graphType : graphTypes) {
- Collection<Statement> stms = graph.getAssertedStatements(graphType, L0.HasValueType);
- if(stms.size() == 1) {
- // Only accept valueType if it asserts HasValueType with the same name
- String hasValueType = graph.getValue(stms.iterator().next().getObject(), Bindings.STRING);
- if (hasValueType.equals(newValue)) {
- candidates.add(new Pair<>(graphType, hasValueType));
+ ModelingResources MOD = ModelingResources.getInstance(graph);
+
+ Resource previousRange = graph.getPossibleObject(propertyInfo.resource, L0.HasRange);
+ if (previousRange != null && graph.isInheritedFrom(previousRange, MOD.MonitorValue)) {
+ // Do not override range of derived properties
+ possibleGraphType = previousRange;
+ } else {
+ Resource root = graph.syncRequest(new IndexRoot(componentType));
+
+ Resource L0Res = graph.getResource("http://www.simantics.org/Layer0-1.1");
+
+ Collection<Resource> graphTypes1 = QueryIndexUtils.searchByTypeAndName(graph, L0Res, L0.ValueType, newValue);
+ Collection<Resource> graphTypes2 = QueryIndexUtils.searchByTypeAndName(graph, root, L0.ValueType, newValue);
+
+ Collection<Resource> graphTypes = new HashSet<>(graphTypes1);
+ graphTypes.addAll(graphTypes2);
+
+ Set<Pair<Resource, String>> candidates = new HashSet<>();
+ for (Resource graphType : graphTypes) {
+ Collection<Statement> stms = graph.getAssertedStatements(graphType, L0.HasValueType);
+ if(stms.size() == 1) {
+ // Only accept valueType if it asserts HasValueType with the same name
+ String hasValueType = graph.getValue(stms.iterator().next().getObject(), Bindings.STRING);
+ if (hasValueType.equals(newValue)) {
+ candidates.add(new Pair<>(graphType, hasValueType));
+ }
}
}
- }
- // We support only graph types with unique name at this point. Later we could implement UI to let the user to select from multiple graph types.
- if (candidates.size() == 1) {
- Pair<Resource, String> result = candidates.iterator().next();
- possibleGraphType = result.first;
- newValue2 = result.second;
+ // We support only graph types with unique name at this point. Later we could implement UI to let the user to select from multiple graph types.
+ if (candidates.size() == 1) {
+ Pair<Resource, String> result = candidates.iterator().next();
+ possibleGraphType = result.first;
+ newValue2 = result.second;
+ }
}
ComponentTypeCommands.editType(graph, componentType, propertyInfo.resource, convertDefaultValue, newValue2, possibleGraphType);
import org.simantics.scl.ui.editor.TextAndErrors;
import org.simantics.structural2.scl.procedural.CompileProceduralComponentTypeRequest;
import org.simantics.structural2.scl.procedural.ProceduralComponentTypeCompilationException;
+import org.simantics.structural2.utils.StructuralUtils;
import org.simantics.ui.workbench.ResourceEditorInput;
import org.simantics.utils.logging.TimeLogger;
import org.simantics.utils.ui.SWTUtils;
@Override
public Document perform(ReadGraph graph) throws DatabaseException {
currentText = graph.getValue(resource, Bindings.STRING);
+ immutable = StructuralUtils.isImmutable(graph, resource);
errorHappened = false;
return new Document(currentText != null ? currentText : ""); //$NON-NLS-1$
}
import org.simantics.db.Resource;
import org.simantics.db.Statement;
import org.simantics.db.common.adaption.SimpleContextualAdapter;
+import org.simantics.db.exception.AdaptionException;
import org.simantics.db.exception.DatabaseException;
import org.simantics.db.layer0.property.OrderedResource;
import org.simantics.diagram.stubs.DiagramResource;
if(result != null) return result;
}
- return null;
+ throw new AdaptionException("No obtained color available");
}
import org.simantics.db.Resource;
import org.simantics.db.Statement;
import org.simantics.db.common.adaption.SimpleContextualAdapter;
+import org.simantics.db.exception.AdaptionException;
import org.simantics.db.exception.DatabaseException;
import org.simantics.db.layer0.property.OrderedResource;
import org.simantics.operation.Layer0X;
if(result != null) return result;
}
- return null;
+ throw new AdaptionException("No obtained expression available");
}
import org.simantics.db.Resource;
import org.simantics.db.Statement;
import org.simantics.db.common.adaption.SimpleContextualAdapter;
+import org.simantics.db.exception.AdaptionException;
import org.simantics.db.exception.DatabaseException;
import org.simantics.db.layer0.property.OrderedResource;
import org.simantics.diagram.stubs.DiagramResource;
if(result != null) return result;
}
- return null;
+ throw new AdaptionException("No obtained font available");
}
import org.simantics.db.Resource;
import org.simantics.db.Statement;
import org.simantics.db.common.adaption.SimpleContextualAdapter;
+import org.simantics.db.exception.AdaptionException;
import org.simantics.db.exception.DatabaseException;
import org.simantics.db.layer0.property.OrderedResource;
import org.simantics.diagram.stubs.DiagramResource;
if(result != null) return result;
}
- return null;
+ throw new AdaptionException("No obtained formatter available");
}
private static final String DECORATION_NODE_NAME = "issueDecorations"; //$NON-NLS-1$
- private List<Resource> getContexts(ReadGraph graph, Resource element) throws DatabaseException {
+ protected List<Resource> getContexts(ReadGraph graph, Resource element) throws DatabaseException {
ModelingResources MOD = ModelingResources.getInstance(graph);
List<Resource> result = new ArrayList<Resource>(3);
});
END(task);
} catch (Throwable t) {
- viewer = null;
LOGGER.error("Failed to complete loading of diagram {} in the canvas thread", viewer.diagramResource, t);
+ viewer = null;
}
}
});
package org.simantics.modeling.ui.expression;
-import java.util.Stack;
-
-import org.simantics.basicexpression.analysis.DepthFirstAdapter;
-import org.simantics.basicexpression.node.AConstantValue;
-import org.simantics.basicexpression.node.ADivMultiplicative;
-import org.simantics.basicexpression.node.AMultMultiplicative;
-import org.simantics.basicexpression.node.APlusExpression;
import org.simantics.basicexpression.node.AStringValue;
+import org.simantics.modeling.InvertBasicExpressionVisitorBase;
import org.simantics.utils.datastructures.Triple;
-public class InvertBasicExpressionVisitor extends DepthFirstAdapter {
-
- Stack<Object> stack = new Stack<Object>();
-
- public Object getResult() {
- return stack.pop();
- }
-
- public void outAConstantValue(AConstantValue node) {
- stack.push(Double.valueOf(node.toString()));
- }
+public class InvertBasicExpressionVisitor extends InvertBasicExpressionVisitorBase {
+ @Override
public void outAStringValue(AStringValue node) {
String value = node.toString();
stack.push(Triple.make(1.0, 0.0, value.substring(1, value.length() - 2).trim()));
}
- @SuppressWarnings("unchecked")
- public void outAPlusExpression(APlusExpression node) {
-
- final Object o1 = stack.pop();
- final Object o2 = stack.pop();
-
- if(o1 instanceof Double && o2 instanceof Triple) {
- Triple<Double, Double, String> p = (Triple<Double, Double, String>)o2;
- stack.push(Triple.make(p.first, p.second + (Double)o1, p.third));
- } else if (o2 instanceof Double && o1 instanceof Triple) {
- Triple<Double, Double, String> p = (Triple<Double, Double, String>)o1;
- stack.push(Triple.make(p.first, p.second + (Double)o2, p.third));
- } else if (o2 instanceof Double && o1 instanceof Double) {
- stack.push((Double)o1 + (Double)o2);
- } else {
- stack.push(Double.NaN);
- }
-
- }
-
- @SuppressWarnings("unchecked")
- public void outAMinusExpression(APlusExpression node) {
-
- final Object o1 = stack.pop();
- final Object o2 = stack.pop();
-
- if(o1 instanceof Double && o2 instanceof Triple) {
- Triple<Double, Double, String> p = (Triple<Double, Double, String>)o2;
- stack.push(Triple.make(-p.first, (Double)o1 - p.second, p.third ));
- } else if (o2 instanceof Double && o1 instanceof Triple) {
- Triple<Double, Double, String> p = (Triple<Double, Double, String>)o1;
- stack.push(Triple.make(p.first, p.second - (Double)o2, p.third));
- } else if (o2 instanceof Double && o1 instanceof Double) {
- stack.push((Double)o1 - (Double)o2);
- } else {
- stack.push(Double.NaN);
- }
-
- }
-
- @SuppressWarnings("unchecked")
- public void outAMultMultiplicative(AMultMultiplicative node) {
-
- final Object o1 = stack.pop();
- final Object o2 = stack.pop();
-
- if(o1 instanceof Double && o2 instanceof Triple) {
- Triple<Double, Double, String> p = (Triple<Double, Double, String>)o2;
- stack.push(Triple.make(p.first * (Double)o1, p.second * (Double)o1, p.third));
- } else if (o2 instanceof Double && o1 instanceof Triple) {
- Triple<Double, Double, String> p = (Triple<Double, Double, String>)o1;
- stack.push(Triple.make(p.first * (Double)o2, p.second * (Double)o2, p.third));
- } else if (o2 instanceof Double && o1 instanceof Double) {
- stack.push((Double)o1 * (Double)o2);
- } else {
- stack.push(Double.NaN);
- }
-
- }
-
- @SuppressWarnings("unchecked")
- public void outADivMultiplicative(ADivMultiplicative node) {
-
- final Object o1 = stack.pop();
- final Object o2 = stack.pop();
-
- if(o1 instanceof Double && o2 instanceof Triple) {
- stack.push(Double.NaN);
- } else if (o2 instanceof Double && o1 instanceof Triple) {
- Triple<Double, Double, String> p = (Triple<Double,Double, String>)o1;
- stack.push(Triple.make(p.first / (Double)o2, p.second / (Double)o2, p.third));
- } else if (o2 instanceof Double && o1 instanceof Double) {
- stack.push((Double)o1 / (Double)o2);
- } else {
- stack.push(Double.NaN);
- }
-
- }
-
}
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.handlers.HandlerUtil;
import org.simantics.Simantics;
-import org.simantics.databoard.Bindings;
import org.simantics.db.ReadGraph;
import org.simantics.db.Resource;
import org.simantics.db.common.request.UniqueRead;
import org.simantics.db.exception.DatabaseException;
import org.simantics.db.layer0.variable.Variable;
-import org.simantics.modeling.ModelingResources;
-import org.simantics.modeling.PropertyVariables;
+import org.simantics.modeling.help.HelpContexts;
import org.simantics.ui.selection.WorkbenchSelectionUtils;
-import org.simantics.utils.ui.AdaptionUtils;
import org.slf4j.LoggerFactory;
public class ContextualHelp extends AbstractHandler {
return Simantics.getSession().syncRequest(new UniqueRead<String>() {
@Override
public String perform(ReadGraph graph) throws DatabaseException {
- return getPossibleId(graph, resource, variable, sel);
+ return HelpContexts.getPossibleId(graph, resource, variable, sel);
}
});
} catch (DatabaseException e) {
return null;
}
+ /**
+ * @deprecated use {@link HelpContexts#getPossibleId(ReadGraph, Resource, Variable, Object)} instead
+ */
+ @Deprecated
public static String getPossibleId(ReadGraph graph, Resource resource, Variable variable, ISelection sel) throws DatabaseException {
- ModelingResources MOD = ModelingResources.getInstance(graph);
- if (resource != null) {
- Resource component = graph.getPossibleObject(resource, MOD.ElementToComponent);
- String id = component != null ? graph.getPossibleRelatedValue2(component, MOD.contextualHelpId, Bindings.STRING) : null;
- if (id != null)
- return id;
- id = graph.getPossibleRelatedValue2(resource, MOD.contextualHelpId, Bindings.STRING);
- if (id != null)
- return id;
- }
-
- if (variable != null) {
- String id = variable.getPossiblePropertyValue(graph, MOD.contextualHelpId, Bindings.STRING);
- if (id != null)
- return id;
- }
-
- // TODO: consider removing this block
- if (sel != null) {
- PropertyVariables vars = AdaptionUtils.adaptToSingle(sel, PropertyVariables.class);
- Variable var = vars != null ? vars.getConfiguration() : null;
- String id = var != null ? var.getPossiblePropertyValue(graph, MOD.contextualHelpId, Bindings.STRING) : null;
- if (id != null)
- return id;
- }
-
- return null;
+ return HelpContexts.getPossibleId(graph, resource, variable, sel);
}
}
ThreadUtils.asyncExec(thread, () -> {
try {
- PDFBuilder chassis = new PDFBuilder(writer, mapper, pageSize, pageDesc, fitDiagramContentsToPageMargins || isSymbol);
+ boolean fitToContent = fitDiagramContentsToPageMargins || isSymbol;
+ if (!fitToContent) {
+ // Prevent PDF printing from drawing page borders if the
+ // print area is fitted directly to the page size.
+ // This avoids unwanted black half-visible edges.
+ ctx.getDefaultHintContext().setHint(Hints.KEY_DISPLAY_PAGE, false);
+ }
+
+ PDFBuilder chassis = new PDFBuilder(writer, mapper, pageSize, pageDesc, fitToContent);
chassis.paint(ctx, true);
} catch (Throwable e) {
exception[0] = new DatabaseException(e);
import org.eclipse.jface.preference.StringFieldEditor;
import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPreferencePage;
import org.eclipse.ui.preferences.ScopedPreferenceStore;
fExtensionEditor = new StringFieldEditor(CSVPreferences.P_CSV_FILE_EXTENSION, "File extension", getFieldEditorParent());
addField(fExtensionEditor);
- fResamplingEditor = new BooleanFieldEditor(CSVPreferences.P_CSV_RESAMPLE, "Resampling", getFieldEditorParent());
+ fResamplingEditor = new BooleanFieldEditor(CSVPreferences.P_CSV_RESAMPLE, "&Resample", getFieldEditorParent());
+ fResamplingEditor.getDescriptionControl(getFieldEditorParent()).setToolTipText("Resample exported data from raw data");
addField(fResamplingEditor);
fSamplingModeEditor = new ComboFieldEditor(CSVPreferences.P_CSV_SAMPLING_MODE, "Sampling mode",
return true;
}
try {
+ @SuppressWarnings("unused")
double number = Double.parseDouble(text);
- return number>0;
+ return true;
} catch (NumberFormatException e1) {
return false;
}
};
fStartEditor.setEmptyStringAllowed(true);
fStartEditor.setErrorMessage("Enter valid start time value (s)");
+ fStartEditor.getTextControl(getFieldEditorParent()).setToolTipText("Time to start resampling from");
+ addField(fStartEditor);
fStepEditor = new StringFieldEditor(CSVPreferences.P_CSV_TIME_STEP, "Step size (s)", getFieldEditorParent()) {
protected boolean doCheckState() {
};
fStepEditor.setEmptyStringAllowed(true);
fStepEditor.setErrorMessage("Enter valid time step value (s)");
+ fStepEditor.getTextControl(getFieldEditorParent()).setToolTipText("Time step to use when resampling");
addField(fStepEditor);
Group significantDigitsGroup = new Group(getFieldEditorParent(), SWT.NONE);
addField(fDoubleDigitsEditor);
GridLayoutFactory.swtDefaults().numColumns(2).applyTo(significantDigitsGroup);
+
+ updateSampling(getPreferenceStore().getBoolean(CSVPreferences.P_CSV_RESAMPLE));
}
/**
} else if (source == fColumnSeparatorEditor) {
columnSeparatorValue = (String) event.getNewValue();
validate = true;
+ } else if (source == fResamplingEditor) {
+ updateSampling();
}
if (validate) {
if (decimalSeparatorValue.equals(columnSeparatorValue)) {
super.propertyChange(event);
}
+ private void updateSampling() {
+ updateSampling(fResamplingEditor.getBooleanValue());
+ }
+
+ private void updateSampling(boolean resample) {
+ Label fStartLabel = fStartEditor.getLabelControl(getFieldEditorParent());
+ Label fStepLabel = fStepEditor.getLabelControl(getFieldEditorParent());
+ Color gray = fStartLabel.getDisplay().getSystemColor(SWT.COLOR_DARK_GRAY);
+ fStartLabel.setForeground(resample ? null : gray);
+ fStepLabel.setForeground(resample ? null : gray);
+ }
+
}
import org.simantics.db.exception.NoSingleResultException;
import org.simantics.db.exception.ServiceException;
import org.simantics.db.management.ISessionContext;
+import org.simantics.db.procedure.Listener;
import org.simantics.db.request.Read;
import org.simantics.diagram.adapter.DefaultConnectionClassFactory;
import org.simantics.diagram.adapter.FlagClassFactory;
import org.simantics.utils.page.PageOrientation;
import org.simantics.utils.threads.AWTThread;
import org.simantics.utils.threads.IThreadWorkQueue;
+import org.simantics.utils.threads.ThreadUtils;
import org.simantics.utils.ui.ErrorLogger;
DiagramDesc diagramDesc = Simantics.getSession().syncRequest(DiagramRequests.getDiagramDesc(diagramResource));
if (diagramDesc != null)
setDiagramDesc(ctx, diagramDesc);
+
+ // Create a listener to react to page setting changes.
+ Simantics.getSession().asyncRequest(DiagramRequests.getDiagramDesc(diagramResource), new Listener<DiagramDesc>() {
+ @Override
+ public void execute(DiagramDesc result) {
+ if (result != null && ctx != null) {
+ ThreadUtils.asyncExec(ctx.getThreadAccess(), () -> {
+ if (ctx != null) {
+ setDiagramDesc(ctx, result);
+ }
+ });
+ }
+ }
+
+ @Override
+ public void exception(Throwable t) {
+ ErrorLogger.defaultLogError(t);
+ }
+
+ @Override
+ public boolean isDisposed() {
+ return DiagramSceneGraphProvider.this.ctx == null;
+ }
+ });
} catch (DatabaseException e) {
ErrorLogger.defaultLogError(e);
}
protected void setDiagramDesc(ICanvasContext ctx, DiagramDesc diagramDesc) {
IHintContext hints = ctx.getDefaultHintContext();
hints.setHint(Hints.KEY_PAGE_DESC, diagramDesc.getPageDesc());
- //hints.setHint(Hints.KEY_DISPLAY_PAGE, diagramDesc.isPageBordersVisible());
+ hints.setHint(Hints.KEY_DISPLAY_PAGE, diagramDesc.isPageBordersVisible());
hints.setHint(Hints.KEY_DISPLAY_MARGINS, diagramDesc.isMarginsVisible());
}
}
try {
-
- IModelingRules modelingRules = Simantics.getSession().syncRequest(DiagramRequests.getModelingRules(resource, null));
- if (modelingRules != null) {
- initialHints.setHint(DiagramModelHints.KEY_MODELING_RULES, modelingRules);
- }
-
- initialHints.setHint(SynchronizationHints.COPY_ADVISOR, getCopyAdvisor());
+ fillInitialDiagramHints(initialHints);
final RuntimeDiagramManager runtimeDiagramManager = RuntimeDiagramManager.create(Simantics.getSession(), resource, modelURI, RVI);
return ctx.getSceneGraph();
}
+ protected void fillInitialDiagramHints(IHintContext initialHints) throws DatabaseException {
+ IModelingRules modelingRules = Simantics.getSession().syncRequest(DiagramRequests.getModelingRules(resource, null));
+ if (modelingRules != null) {
+ initialHints.setHint(DiagramModelHints.KEY_MODELING_RULES, modelingRules);
+ }
+
+ initialHints.setHint(SynchronizationHints.COPY_ADVISOR, getCopyAdvisor());
+ }
+
protected IElementClassProvider createElementClassProvider(ReadGraph graph) throws DatabaseException {
DiagramResource dr = DiagramResource.getInstance(graph);
return ElementClassProviders.mappedProvider(
org.simantics.modeling.adapters,
org.simantics.modeling.export,
org.simantics.modeling.flags,
+ org.simantics.modeling.help,
org.simantics.modeling.mapping,
org.simantics.modeling.migration,
org.simantics.modeling.preferences,
--- /dev/null
+importJava "org.simantics.modeling.adapters.ChangeInformation" where
+ data ChangeInformation
pgraphContentDump :: Resource -> <ReadGraph> Vector Byte
graphFileContentDump :: Resource -> <ReadGraph> Vector Byte
structuralComponentContentDump :: Resource -> <ReadGraph> Vector Byte
+ structuralComponentTypeContentDump :: Resource -> <ReadGraph> Vector Byte
genericParameterTypeContentDump :: Resource -> <ReadGraph> Vector Byte
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
+import java.util.Collection;
+import java.util.Map;
import java.util.TreeMap;
import java.util.TreeSet;
import org.simantics.db.ReadGraph;
import org.simantics.db.Resource;
import org.simantics.db.common.utils.CommonDBUtils;
+import org.simantics.db.common.utils.NameUtils;
import org.simantics.db.exception.DatabaseException;
import org.simantics.db.layer0.variable.Variable;
import org.simantics.db.layer0.variable.Variables;
return graph.getRelatedValue(resource, GF.HasFiledata, Bindings.BYTE_ARRAY);
}
- public static byte[] structuralComponentContentDump(ReadGraph graph, Resource resource) throws DatabaseException {
-
- StringBuilder dump = new StringBuilder();
+ private static StringBuilder structuralComponentContentDump(ReadGraph graph, Resource resource, StringBuilder dump) throws DatabaseException {
Variable v = Variables.getVariable(graph, resource);
-
+
TreeSet<String> types = new TreeSet<>();
for(Resource t : graph.getPrincipalTypes(resource)) {
types.add(graph.getURI(t));
dump.append("\n");
}
}
+
+ return dump;
+ }
+
+ public static byte[] structuralComponentContentDump(ReadGraph graph, Resource resource) throws DatabaseException {
+ return structuralComponentContentDump(graph, resource, new StringBuilder()).toString().getBytes(UTF8);
+ }
+
+ public static byte[] structuralComponentTypeContentDump(ReadGraph graph, Resource resource) throws DatabaseException {
+ StringBuilder dump = structuralComponentContentDump(graph, resource, new StringBuilder());
+
+ StructuralResource2 STR = StructuralResource2.getInstance(graph);
+
+ // Dump procedural component type code if present
+ String proceduralCode = graph.getPossibleRelatedValue(resource, STR.ProceduralComponentType_code, Bindings.STRING);
+ if (proceduralCode != null) {
+ dump
+ .append("\n---- ProceduralComponentType.code begins ----\n")
+ .append(proceduralCode)
+ .append("---- ProceduralComponentType.code ends ----\n");
+ }
+
+ // Dump component type SCL scripts
+ Collection<Resource> scripts = graph.getObjects(resource, STR.ComponentType_hasScript);
+ if (!scripts.isEmpty()) {
+ dump.append("\nComponentType.hasScript (").append(scripts.size()).append(")\n");
+ TreeMap<String,Resource> sortedScripts = new TreeMap<>();
+ for (Resource script : scripts)
+ sortedScripts.put(NameUtils.getSafeName(graph, script), script);
+ for (Map.Entry<String, Resource> entry : sortedScripts.entrySet()) {
+ String name = entry.getKey();
+ Resource script = entry.getValue();
+ String type = graph.getPossibleRelatedValue(script, STR.ComponentTypeScript_type, Bindings.STRING);
+ String code = graph.getPossibleRelatedValue(script, STR.ComponentTypeScript_code, Bindings.STRING);
+ dump
+ .append("---- script `").append(name).append("` of type `").append(type).append("` begins ----\n")
+ .append(code)
+ .append("\n---- script `").append(name).append("` of type `").append(type).append("` ends ----\n");
+ }
+ }
+
return dump.toString().getBytes(UTF8);
}
package org.simantics.modeling;
-import java.util.Stack;
-
import org.simantics.basicexpression.Expressions;
-import org.simantics.basicexpression.analysis.DepthFirstAdapter;
-import org.simantics.basicexpression.node.AConstantValue;
-import org.simantics.basicexpression.node.ADivMultiplicative;
-import org.simantics.basicexpression.node.AMultMultiplicative;
-import org.simantics.basicexpression.node.APlusExpression;
-import org.simantics.basicexpression.node.AVariablePrimary;
import org.simantics.db.ReadGraph;
import org.simantics.db.Resource;
import org.simantics.db.WriteGraph;
import org.simantics.utils.datastructures.Pair;
import org.simantics.utils.datastructures.Triple;
-public class InvertBasicExpressionVisitor extends DepthFirstAdapter {
-
- Stack<Object> stack = new Stack<Object>();
-
- public Object getResult() {
- if(stack.size() != 1) return null;
- return stack.pop();
- }
-
- public void outAConstantValue(AConstantValue node) {
- stack.push(Double.valueOf(node.toString()));
- }
-
- @Override
- public void outAVariablePrimary(AVariablePrimary node) {
- String value = node.toString().trim();
- stack.push(Triple.make(1.0, 0.0, value));
- }
-
- @SuppressWarnings("unchecked")
- public void outAPlusExpression(APlusExpression node) {
-
- final Object o1 = stack.pop();
- final Object o2 = stack.pop();
-
- if(o1 instanceof Double && o2 instanceof Triple) {
- Triple<Double, Double, String> p = (Triple<Double, Double, String>)o2;
- stack.push(Triple.make(p.first, p.second + (Double)o1, p.third));
- } else if (o2 instanceof Double && o1 instanceof Triple) {
- Triple<Double, Double, String> p = (Triple<Double, Double, String>)o1;
- stack.push(Triple.make(p.first, p.second + (Double)o2, p.third));
- } else if (o2 instanceof Double && o1 instanceof Double) {
- stack.push((Double)o1 + (Double)o2);
- } else {
- stack.push(Double.NaN);
- }
-
- }
-
- @SuppressWarnings("unchecked")
- public void outAMinusExpression(APlusExpression node) {
-
- final Object o1 = stack.pop();
- final Object o2 = stack.pop();
-
- if(o1 instanceof Double && o2 instanceof Triple) {
- Triple<Double, Double, String> p = (Triple<Double, Double, String>)o2;
- stack.push(Triple.make(-p.first, (Double)o1 - p.second, p.third ));
- } else if (o2 instanceof Double && o1 instanceof Triple) {
- Triple<Double, Double, String> p = (Triple<Double, Double, String>)o1;
- stack.push(Triple.make(p.first, p.second - (Double)o2, p.third));
- } else if (o2 instanceof Double && o1 instanceof Double) {
- stack.push((Double)o1 - (Double)o2);
- } else {
- stack.push(Double.NaN);
- }
-
- }
-
- @SuppressWarnings("unchecked")
- public void outAMultMultiplicative(AMultMultiplicative node) {
-
- final Object o1 = stack.pop();
- final Object o2 = stack.pop();
-
- if(o1 instanceof Double && o2 instanceof Triple) {
- Triple<Double, Double, String> p = (Triple<Double, Double, String>)o2;
- stack.push(Triple.make(p.first * (Double)o1, p.second * (Double)o1, p.third));
- } else if (o2 instanceof Double && o1 instanceof Triple) {
- Triple<Double, Double, String> p = (Triple<Double, Double, String>)o1;
- stack.push(Triple.make(p.first * (Double)o2, p.second * (Double)o2, p.third));
- } else if (o2 instanceof Double && o1 instanceof Double) {
- stack.push((Double)o1 * (Double)o2);
- } else {
- stack.push(Double.NaN);
- }
-
- }
-
- @SuppressWarnings("unchecked")
- public void outADivMultiplicative(ADivMultiplicative node) {
-
- final Object o1 = stack.pop();
- final Object o2 = stack.pop();
-
- if(o1 instanceof Double && o2 instanceof Triple) {
- stack.push(Double.NaN);
- } else if (o2 instanceof Double && o1 instanceof Triple) {
- Triple<Double, Double, String> p = (Triple<Double,Double, String>)o1;
- stack.push(Triple.make(p.first / (Double)o2, p.second / (Double)o2, p.third));
- } else if (o2 instanceof Double && o1 instanceof Double) {
- stack.push((Double)o1 / (Double)o2);
- } else {
- stack.push(Double.NaN);
- }
-
- }
+public class InvertBasicExpressionVisitor extends InvertBasicExpressionVisitorBase {
private static final String MAGIC = "_111_";
-
+
private static String replaced(String expression) {
return expression.replaceAll("\\.([A-Za-z])", MAGIC + "$1");
}
-
+
public static void invert(WriteGraph graph, Variable base, String expression, Object value) throws DatabaseException {
InvertBasicExpressionVisitor visitor = new InvertBasicExpressionVisitor();
Expressions.evaluate(replaced(expression), visitor);
}
- public static Variable possibleInvertibleExpressionReferencedProperty(ReadGraph graph, Variable base, String expression) throws DatabaseException {
+ @SuppressWarnings("unchecked")
+ private static Triple<Double, Double, String> possibleInvertibleExpression(ReadGraph graph, Variable base, String expression) throws DatabaseException {
if (base == null || expression == null || expression.isEmpty())
return null;
InvertBasicExpressionVisitor visitor = new InvertBasicExpressionVisitor();
//System.out.println("invert : " + expression + " -> " + replaced(expression) + " for " + base.getURI(graph));
Expressions.evaluate(replaced(expression), visitor);
- Object pair = visitor.getResult();
- if(pair == null)
- return null;
- if(pair instanceof Triple) {
- @SuppressWarnings("unchecked")
- Triple<Double, Double, String> data = (Triple<Double, Double, String>)pair;
- String key = data.third.replace(MAGIC,".");
- String path = getVariablePath(graph, base, key);
- if (path == null)
- return null;
- Variable targetVariable = base.browsePossible(graph, path);
- return targetVariable;
- }
+ Object result = visitor.getResult();
+ if (result instanceof Triple)
+ return (Triple<Double, Double, String>) result;
return null;
}
+ public static Variable possibleInvertibleExpressionReferencedProperty(ReadGraph graph, Variable base, String expression) throws DatabaseException {
+ Triple<Double, Double, String> data = possibleInvertibleExpression(graph, base, expression);
+ if (data == null)
+ return null;
+ String path = getVariablePath(graph, base, data.third.replace(MAGIC, "."));
+ return path != null ? base.browsePossible(graph, path) : null;
+ }
+
+ public static Triple<Double, Double, Variable> possibleInvertibleExpressionReferencedTransformedProperty(ReadGraph graph, Variable base, String expression) throws DatabaseException {
+ Triple<Double, Double, String> data = possibleInvertibleExpression(graph, base, expression);
+ if (data == null)
+ return null;
+ String path = getVariablePath(graph, base, data.third.replace(MAGIC, "."));
+ if (path == null)
+ return null;
+ Variable targetVariable = base.browsePossible(graph, path);
+ return targetVariable != null ? Triple.make(data.first, data.second, targetVariable) : null;
+ }
+
}
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2020 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
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Semantum Oy - initial API and implementation
+ *******************************************************************************/
+package org.simantics.modeling;
+
+import java.util.Stack;
+
+import org.simantics.basicexpression.analysis.DepthFirstAdapter;
+import org.simantics.basicexpression.node.AConstantValue;
+import org.simantics.basicexpression.node.ADivMultiplicative;
+import org.simantics.basicexpression.node.AMinusExpression;
+import org.simantics.basicexpression.node.AMultMultiplicative;
+import org.simantics.basicexpression.node.APlusExpression;
+import org.simantics.basicexpression.node.AVariablePrimary;
+import org.simantics.utils.datastructures.Triple;
+
+/**
+ * @author Tuukka Lehtonen
+ */
+public class InvertBasicExpressionVisitorBase extends DepthFirstAdapter {
+
+ protected Stack<Object> stack = new Stack<>();
+
+ public InvertBasicExpressionVisitorBase() {
+ super();
+ }
+
+ public Object getResult() {
+ if(stack.size() != 1) return null;
+ return stack.pop();
+ }
+
+ @Override
+ public void outAConstantValue(AConstantValue node) {
+ stack.push(Double.valueOf(node.toString()));
+ }
+
+ @Override
+ public void outAVariablePrimary(AVariablePrimary node) {
+ String value = node.toString().trim();
+ stack.push(Triple.make(1.0, 0.0, value));
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public void outAPlusExpression(APlusExpression node) {
+
+ final Object o1 = stack.pop();
+ final Object o2 = stack.pop();
+
+ if(o1 instanceof Double && o2 instanceof Triple) {
+ Triple<Double, Double, String> p = (Triple<Double, Double, String>)o2;
+ stack.push(Triple.make(p.first, p.second + (Double)o1, p.third));
+ } else if (o2 instanceof Double && o1 instanceof Triple) {
+ Triple<Double, Double, String> p = (Triple<Double, Double, String>)o1;
+ stack.push(Triple.make(p.first, p.second + (Double)o2, p.third));
+ } else if (o2 instanceof Double && o1 instanceof Double) {
+ stack.push((Double)o1 + (Double)o2);
+ } else {
+ stack.push(Double.NaN);
+ }
+
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public void outAMinusExpression(AMinusExpression node) {
+
+ final Object o1 = stack.pop();
+ final Object o2 = stack.pop();
+
+ // o2 - o1
+ if(o1 instanceof Double && o2 instanceof Triple) {
+ // <triple> o2 - double o1
+ Triple<Double, Double, String> p = (Triple<Double, Double, String>)o2;
+ stack.push(Triple.make(p.first, p.second - (Double)o1, p.third));
+ } else if (o2 instanceof Double && o1 instanceof Triple) {
+ // double o2 - <triple> o1
+ Triple<Double, Double, String> p = (Triple<Double, Double, String>)o1;
+ stack.push(Triple.make(-p.first, (Double)o2 - p.second, p.third));
+ } else if (o2 instanceof Double && o1 instanceof Double) {
+ stack.push((Double)o2 - (Double)o1);
+ } else {
+ stack.push(Double.NaN);
+ }
+
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public void outAMultMultiplicative(AMultMultiplicative node) {
+
+ final Object o1 = stack.pop();
+ final Object o2 = stack.pop();
+
+ if(o1 instanceof Double && o2 instanceof Triple) {
+ Triple<Double, Double, String> p = (Triple<Double, Double, String>)o2;
+ stack.push(Triple.make(p.first * (Double)o1, p.second * (Double)o1, p.third));
+ } else if (o2 instanceof Double && o1 instanceof Triple) {
+ Triple<Double, Double, String> p = (Triple<Double, Double, String>)o1;
+ stack.push(Triple.make(p.first * (Double)o2, p.second * (Double)o2, p.third));
+ } else if (o2 instanceof Double && o1 instanceof Double) {
+ stack.push((Double)o1 * (Double)o2);
+ } else {
+ stack.push(Double.NaN);
+ }
+
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public void outADivMultiplicative(ADivMultiplicative node) {
+
+ final Object o1 = stack.pop();
+ final Object o2 = stack.pop();
+
+ // o2 / o1
+ if(o1 instanceof Double && o2 instanceof Triple) {
+ // <triple> o2 / double o1
+ Triple<Double, Double, String> p = (Triple<Double,Double, String>)o2;
+ stack.push(Triple.make(p.first / (Double)o1, p.second / (Double)o1, p.third));
+ } else if (o2 instanceof Double && o1 instanceof Triple) {
+ // double o2 / <triple> o1
+ stack.push(Double.NaN);
+ } else if (o2 instanceof Double && o1 instanceof Double) {
+ stack.push((Double)o2 / (Double)o1);
+ } else {
+ stack.push(Double.NaN);
+ }
+
+ }
+
+}
\ No newline at end of file
import org.simantics.db.Statement;
import org.simantics.db.VirtualGraph;
import org.simantics.db.WriteGraph;
+import org.simantics.db.WriteOnlyGraph;
import org.simantics.db.common.Indexing;
import org.simantics.db.common.NamedResource;
import org.simantics.db.common.QueryMemoryWatcher;
import org.simantics.db.common.request.PossibleIndexRoot;
import org.simantics.db.common.request.ReadRequest;
import org.simantics.db.common.request.ResourceRead2;
+import org.simantics.db.common.request.WriteOnlyRequest;
import org.simantics.db.common.request.WriteRequest;
import org.simantics.db.common.request.WriteResultRequest;
import org.simantics.db.common.utils.ListUtils;
import org.simantics.db.layer0.util.TransferableGraphConfiguration2;
import org.simantics.db.layer0.variable.Variable;
import org.simantics.db.layer0.variable.Variables;
-import org.simantics.db.request.Read;
import org.simantics.db.service.ClusterControl;
import org.simantics.db.service.CollectionSupport;
import org.simantics.db.service.GraphChangeListenerSupport;
return DiagramGraphUtil.getModelingRules(graph, diagramResource, null);
}
+ //-------------------------------------------------------------------------
+
+ private static final String VG_CHANGE_INFORMATION = "changeInformation"; //$NON-NLS-1$
+
public static void markChanged(WriteGraph graph, Resource r) throws DatabaseException {
- VirtualGraphSupport support = Simantics.getSession().getService(VirtualGraphSupport.class);
- VirtualGraph vg = support.getWorkspacePersistent("changeInformation");
- graph.syncRequest(new WriteRequest(vg) {
+ VirtualGraph vg = Simantics.getSession().getService(VirtualGraphSupport.class)
+ .getWorkspacePersistent(VG_CHANGE_INFORMATION);
+ ModelingResources MOD = ModelingResources.getInstance(graph);
+ graph.syncRequest(new WriteOnlyRequest(vg) {
@Override
- public void perform(WriteGraph graph) throws DatabaseException {
- ModelingResources MOD = ModelingResources.getInstance(graph);
+ public void perform(WriteOnlyGraph graph) throws DatabaseException {
graph.claim(r, MOD.changed, MOD.changed, r);
}
});
}
-
+
+ public static void markChanged(RequestProcessor processor, Iterable<Resource> rs) throws DatabaseException {
+ VirtualGraph vg = Simantics.getSession().getService(VirtualGraphSupport.class)
+ .getWorkspacePersistent(VG_CHANGE_INFORMATION);
+ ModelingResources MOD = ModelingResources.getInstance(processor);
+ processor.syncRequest(new WriteOnlyRequest(vg) {
+ @Override
+ public void perform(WriteOnlyGraph graph) throws DatabaseException {
+ for (Resource r : rs) {
+ graph.claim(r, MOD.changed, MOD.changed, r);
+ }
+ }
+ });
+ }
+
}
import gnu.trove.map.hash.THashMap;
import org.simantics.db.ReadGraph;
+import org.simantics.db.Resource;
import org.simantics.db.exception.DatabaseException;
import org.simantics.db.layer0.request.PropertyInfo;
import org.simantics.db.layer0.request.PropertyInfoRequest;
public THashMap<String, Pair<String,Type>> perform(ReadGraph graph) throws DatabaseException {
THashMap<String, Pair<String,Type>> propertyMap = new THashMap<String, Pair<String,Type>>();
for(Variable child : variable.getChildren(graph)) {
- for(Variable property : child.getProperties(graph)) {
- PropertyInfo propertyInfo = graph.syncRequest(new PropertyInfoRequest(property.getPredicateResource(graph)));
+ for(Variable property : child.getProperties(graph)) {
+ Resource predicate = property.getPossiblePredicateResource(graph);
+ if (predicate == null)
+ continue;
+
+ PropertyInfo propertyInfo = graph.syncRequest(new PropertyInfoRequest(predicate));
propertyMap.put(child.getName(graph) + "." + propertyInfo.name,
Pair.make("/" + child.getName(graph) + "#" + propertyInfo.name,
SCLTypeUtils.getType(propertyInfo)));
- }
+ }
}
- for(Variable property : variable.getProperties(graph)) {
- PropertyInfo propertyInfo = graph.syncRequest(new PropertyInfoRequest(property.getPredicateResource(graph)));
+ for(Variable property : variable.getProperties(graph)) {
+ Resource predicate = property.getPossiblePredicateResource(graph);
+ if (predicate == null)
+ continue;
+
+ PropertyInfo propertyInfo = graph.syncRequest(new PropertyInfoRequest(predicate));
propertyMap.put(propertyInfo.name,
Pair.make("#" + propertyInfo.name,
SCLTypeUtils.getType(propertyInfo)));
- }
+ }
+
return propertyMap;
}
import org.simantics.g2d.diagram.DiagramHints;
import org.simantics.g2d.diagram.IDiagram;
import org.simantics.g2d.diagram.handler.DataElementMap;
+import org.simantics.g2d.diagram.participant.ElementPainter.SelectionShapeNode;
import org.simantics.g2d.diagram.participant.Selection;
import org.simantics.g2d.element.IElement;
import org.simantics.g2d.scenegraph.ICanvasSceneGraphProvider;
if (!hasContent)
return;
String svg = printSVGDocument(doc);
- parentBuilder.append(MAIN_SECTION, "<g class=\"" +node.getSimpleClassName() +"\">");
- parentBuilder.append(MAIN_SECTION, svg);
- parentBuilder.append(MAIN_SECTION, "\n</g>");
+ if (node instanceof SelectionShapeNode) {
+ SingleElementNode parentSEN = (SingleElementNode)NodeUtil.getNearestParentOfType(node, SingleElementNode.class);
+ if(parentSEN != null) {
+ String key = getKey(parentSEN);
+ RenderSVGContext parentBuilder2 = getParentBuilder(parentSEN);
+ parentBuilder2.append(SELECTION_SECTION, "\n<g style=\"visibility:hidden\" class=\"selection\" id=\"" + key + "\">");
+ parentBuilder2.append(SELECTION_SECTION, svg);
+ parentBuilder2.append(SELECTION_SECTION, "\n</g>");
+
+ parentBuilder2.append(SELECTION_MASK_SECTION, "\n<g class=\"selectionMask\" id=\"" + key /*+ "\" transform=\"" + matrixString + "\"*/+ "\">");
+ Rectangle2D rect = node.getBounds();
+ // NaN
+ if(rect.getHeight() == rect.getHeight() && rect.getWidth() == rect.getWidth()) {
+ parentBuilder2.append(SELECTION_MASK_SECTION,"<rect style=\"fill:#fff\" opacity=\"" + OPACITY + "\"");
+ parentBuilder2.append(SELECTION_MASK_SECTION," x=\"" + rect.getX() + "\" y=\"" + rect.getY() + "\"");
+ parentBuilder2.append(SELECTION_MASK_SECTION," width=\"" + rect.getWidth() + "\" height=\"" + rect.getHeight() + "\"");
+ parentBuilder2.append(SELECTION_MASK_SECTION,"></rect>");
+ }
+ parentBuilder2.append(SELECTION_MASK_SECTION,"\n</g>");
+ }
+ } else {
+ parentBuilder.append(MAIN_SECTION, "<g class=\"" +node.getSimpleClassName() +"\">");
+ parentBuilder.append(MAIN_SECTION, svg);
+ parentBuilder.append(MAIN_SECTION, "\n</g>");
+ }
} catch (Exception e) {
// TODO: There are nodes that do not behave well when rendered to SVG. For backwards compatibility, we don't handle the exceptions.
}
import org.simantics.databoard.type.StringType;
import org.simantics.db.layer0.request.PropertyInfo;
import org.simantics.scl.compiler.types.TCon;
+import org.simantics.scl.compiler.types.TVar;
import org.simantics.scl.compiler.types.Type;
import org.simantics.scl.compiler.types.Types;
import org.simantics.scl.compiler.types.kinds.Kinds;
private static final Logger LOGGER = LoggerFactory.getLogger(SCLTypeUtils.class);
private static final THashMap<String, Type> TYPE_MAP = new THashMap<String, Type>();
+ private static final TVar STAR = Types.var(Kinds.STAR);
+
private static void add(TCon type) {
TYPE_MAP.put(type.name, type);
}
Types.functionE(new Type[] {variable, Types.RESOURCE}, Types.READ_GRAPH, Types.RESOURCE));
add((TCon)Types.RESOURCE);
+ add(Types.con("Simantics/ChangeInformation", "ChangeInformation")); // MOD.ChangeInformation
add(Types.con("Simantics/GUID", "GUID")); // L0.GUID
add(Types.con("Simantics/Variables", "StructuredProperty")); // L0.methods
add(Types.con("Simantics/Variables", "ValueAccessor")); // L0.ValueAccessor
Type type = TYPE_MAP.get(typeText);
if(type == null) {
LOGGER.warn("SCLTypeUtils.getType cannot transform '" + typeText + "' to type. Returns a as default.");
- return Types.var(Kinds.STAR);
+ return STAR;
}
return type;
}
return Types.list(getType(((ArrayType)dataType).componentType));
else {
LOGGER.warn("SCLTypeUtils.getType cannot transform data type '" + dataType + "' to type. Returns a as default.");
- return Types.var(Kinds.STAR);
+ return STAR;
}
}
- public static Type getType(PropertyInfo propertyInfo) {
+ public static Type getType(PropertyInfo propertyInfo, boolean warnOfNoTypeInformation) {
if(propertyInfo.requiredValueType != null)
return getType(propertyInfo.requiredValueType);
else if(propertyInfo.requiredDatatype != null)
return getType(propertyInfo.requiredDatatype);
else {
- LOGGER.warn(propertyInfo.name + " doesn't have type information. Returns a as default.");
- return Types.var(Kinds.STAR);
+ if (warnOfNoTypeInformation)
+ LOGGER.warn(propertyInfo.name + " doesn't have type information. Returns a as default.");
+ return STAR;
}
}
+
+ public static Type getType(PropertyInfo propertyInfo) {
+ return getType(propertyInfo, propertyInfo.isHasProperty);
+ }
}
import org.simantics.databoard.Bindings;
import org.simantics.db.Resource;
import org.simantics.db.common.primitiverequest.PossibleRelatedValue2;
-import org.simantics.db.common.utils.Logger;
import org.simantics.db.exception.DatabaseException;
import org.simantics.db.layer0.adapter.ActionFactory;
import org.simantics.modeling.ModelingResources;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class Help implements ActionFactory {
+ private static final Logger LOGGER = LoggerFactory.getLogger(Help.class);
+
@Override
public Runnable create(Object target) {
-
- if(!(target instanceof Resource))
+ if (!(target instanceof Resource))
return null;
- final Resource resource = (Resource)target;
-
- return new Runnable() {
- @Override
- public void run() {
-
- try {
- ModelingResources MOD = ModelingResources.getInstance(Simantics.getSession());
- String id = Simantics.sync(new PossibleRelatedValue2<String>(resource, MOD.contextualHelpId, Bindings.STRING));
- if(id == null) {
- PlatformUI.getWorkbench().getHelpSystem().displayDynamicHelp();
- return;
- }
- PlatformUI.getWorkbench().getHelpSystem().displayHelp(id);
- } catch (DatabaseException e) {
- Logger.defaultLogError(e);
+ final Resource resource = (Resource) target;
+
+ return () -> {
+ try {
+ ModelingResources MOD = ModelingResources.getInstance(Simantics.getSession());
+ String id = Simantics.sync(new PossibleRelatedValue2<String>(resource, MOD.contextualHelpId, Bindings.STRING));
+ if (id == null) {
+ PlatformUI.getWorkbench().getHelpSystem().displayDynamicHelp();
+ return;
}
-
+ PlatformUI.getWorkbench().getHelpSystem().displayHelp(id);
+ } catch (DatabaseException e) {
+ LOGGER.error("Failed to display help for resource {}", resource, e);
}
};
}
+
}
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2020 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
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Semantum Oy- initial API and implementation
+ *******************************************************************************/
+package org.simantics.modeling.help;
+
+import org.simantics.databoard.Bindings;
+import org.simantics.db.ReadGraph;
+import org.simantics.db.Resource;
+import org.simantics.db.exception.DatabaseException;
+import org.simantics.db.layer0.variable.Variable;
+import org.simantics.modeling.ModelingResources;
+import org.simantics.modeling.PropertyVariables;
+import org.simantics.utils.ui.AdaptionUtils;
+
+/**
+ * @author Tuukka Lehtonen
+ * @since 1.46.0
+ */
+public class HelpContexts {
+
+ /**
+ * @param graph
+ * @param resource
+ * @param variable
+ * @param selection optional <code>ISelection</code>
+ * @return
+ * @throws DatabaseException
+ */
+ public static String getPossibleId(ReadGraph graph, Resource resource, Variable variable, Object selection) throws DatabaseException {
+ ModelingResources MOD = ModelingResources.getInstance(graph);
+ if (resource != null) {
+ Resource component = graph.getPossibleObject(resource, MOD.ElementToComponent);
+ String id = component != null ? graph.getPossibleRelatedValue2(component, MOD.contextualHelpId, Bindings.STRING) : null;
+ if (id != null)
+ return id;
+ id = graph.getPossibleRelatedValue2(resource, MOD.contextualHelpId, Bindings.STRING);
+ if (id != null)
+ return id;
+ }
+
+ if (variable != null) {
+ String id = variable.getPossiblePropertyValue(graph, MOD.contextualHelpId, Bindings.STRING);
+ if (id != null)
+ return id;
+ }
+
+ // TODO: consider removing this block
+ if (selection != null) {
+ PropertyVariables vars = AdaptionUtils.adaptToSingle(selection, PropertyVariables.class);
+ Variable var = vars != null ? vars.getConfiguration() : null;
+ String id = var != null ? var.getPossiblePropertyValue(graph, MOD.contextualHelpId, Bindings.STRING) : null;
+ if (id != null)
+ return id;
+ }
+
+ return null;
+ }
+
+ public static String getPossibleId(ReadGraph graph, Variable variable, String property) throws DatabaseException {
+ ModelingResources MOD = ModelingResources.getInstance(graph);
+ Variable prop = variable != null ? variable.getPossibleProperty(graph, property) : null;
+ return prop != null ? prop.getPossiblePropertyValue(graph, MOD.contextualHelpId, Bindings.STRING) : null;
+ }
+
+}
import org.simantics.modeling.services.ComponentNamingUtil;
import org.simantics.modeling.services.NamingException;
import org.simantics.project.IProject;
-import org.simantics.structural.stubs.StructuralResource2;
import gnu.trove.map.hash.THashMap;
@Override
public Object copy(ISynchronizationContext context, WriteGraph graph, Resource source, Resource sourceContainer,
Resource targetContainer, Map<Object, Object> map) throws DatabaseException {
- StructuralResource2 STR = StructuralResource2.getInstance(graph);
Resource copy = CopyAdvisorUtil.copy2(graph, source, null, map);
Layer0 L0 = Layer0.getInstance(graph);
import org.simantics.db.layer0.request.VariableRead;
import org.simantics.db.layer0.scl.AbstractExpressionCompilationContext;
import org.simantics.db.layer0.scl.AbstractExpressionCompilationRequest;
-import org.simantics.db.layer0.util.RuntimeEnvironmentRequest;
+import org.simantics.db.layer0.util.RuntimeEnvironmentRequest2;
import org.simantics.db.layer0.variable.Variable;
import org.simantics.layer0.Layer0;
import org.simantics.modeling.ProceduralSubstructureMapRequest;
public CompilationContext perform(ReadGraph graph)
throws DatabaseException {
Resource indexRoot = graph.syncRequest(new IndexRoot(componentType));
- RuntimeEnvironment runtimeEnvironment = graph.syncRequest(new RuntimeEnvironmentRequest(indexRoot));
+ RuntimeEnvironment runtimeEnvironment = graph.syncRequest(new RuntimeEnvironmentRequest2(componentType, indexRoot));
THashMap<String, Pair<String,Type>> propertyMap =
graph.sync(new ProceduralSubstructureMapRequest(componentVariable));
return new CompilationContext(runtimeEnvironment, propertyMap);
import org.simantics.db.exception.DatabaseException;
import org.simantics.db.layer0.scl.AbstractExpressionCompilationContext;
import org.simantics.db.layer0.scl.AbstractExpressionCompilationRequest;
-import org.simantics.db.layer0.util.RuntimeEnvironmentRequest;
+import org.simantics.db.layer0.util.RuntimeEnvironmentRequest2;
import org.simantics.db.layer0.variable.Variable;
import org.simantics.layer0.Layer0;
import org.simantics.modeling.ComponentTypeSubstructure;
public CompilationContext perform(ReadGraph graph)
throws DatabaseException {
Resource indexRoot = graph.syncRequest(new IndexRoot(resource));
- RuntimeEnvironment runtimeEnvironment = graph.syncRequest(new RuntimeEnvironmentRequest(indexRoot));
+ RuntimeEnvironment runtimeEnvironment = graph.syncRequest(new RuntimeEnvironmentRequest2(resource, indexRoot));
return new CompilationContext(runtimeEnvironment, ComponentTypeSubstructure.forType(graph, resource));
}
});
import org.simantics.db.common.procedure.adapter.TransientCacheListener;
import org.simantics.db.common.request.IndexRoot;
import org.simantics.db.common.request.ResourceRead2;
+import org.simantics.db.common.request.RuntimeEnvironmentRequest;
import org.simantics.db.exception.DatabaseException;
-import org.simantics.db.layer0.util.RuntimeEnvironmentRequest;
import org.simantics.db.layer0.variable.Variable;
import org.simantics.layer0.Layer0;
import org.simantics.scl.compiler.common.names.Name;
public static void setRequiredType(WriteGraph g, Resource componentType, Resource property,
String requiredType, Resource possibleType) throws DatabaseException {
Layer0 L0 = Layer0.getInstance(g);
+ ModelingResources MOD = ModelingResources.getInstance(g);
g.claimLiteral(property, L0.RequiresValueType, requiredType);
if (componentType != null) {
if(g.hasStatement(possibleType, L0.Enumeration)) {
// This value type is an enumeration - let's constrain the range of this predicate to match the enumeration type only
g.claim(property, L0.HasRange, possibleType);
+ } else if (g.isInheritedFrom(possibleType, MOD.MonitorValue)) {
+ // Support derived properties
+ g.claim(property, L0.HasRange, possibleType);
}
}
import java.nio.charset.StandardCharsets;
import java.util.Collection;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.Map;
+import java.util.Set;
import java.util.TreeMap;
import org.simantics.Simantics;
private Resource ontology;
private Map<Resource, String> names = new HashMap<>();
- private Map<Resource,Resource> parents = new HashMap<>();
+ private Map<Resource,Resource> parents = new TreeMap<>();
private Map<Resource, File> libraryFolders = new HashMap<>();
private Map<Resource, byte[]> contentDumps = new HashMap<>();
private void readNameAndParent(ReadGraph graph, Resource container, Resource r) throws DatabaseException {
+ String name = NameUtils.getSafeName(graph, r);
parents.put(r, container);
- names.put(r, NameUtils.getSafeName(graph, r));
+ names.put(r, FileUtils.escapeFileName(name));
}
- private Collection<Resource> containers() {
- return parents.values();
+ /*
+ * This shall return containers sorted by full path.
+ * This makes processing order stable and ensures that
+ * directories are processed before their contents.
+ */
+ private Collection<Resource> sortedContainers(File rootFolder) {
+ Set<Resource> parentSet = new HashSet<Resource>(parents.values());
+ TreeMap<String,Resource> result = new TreeMap<>();
+ for(Resource r : parentSet) {
+ File f = getFolder(rootFolder, r);
+ result.put(f.getAbsolutePath(), r);
+ }
+ return result.values();
+ }
+
+ private Collection<Resource> sortedResources(File rootFolder) {
+ TreeMap<String,Resource> result = new TreeMap<>();
+ for(Resource r : parents.keySet()) {
+ byte[] dump = contentDumps.get(r);
+ if(dump == null)
+ dump = "".getBytes(StandardCharsets.UTF_8);
+ if(isParent(r)) {
+ if(dump.length > 0) {
+ File f = new File(getFolder(rootFolder, r), "__contents__");
+ result.put(f.getAbsolutePath(), r);
+ }
+ } else {
+ File f = getFile(rootFolder, r);
+ result.put(f.getAbsolutePath(), r);
+ }
+ }
+ return result.values();
}
private void readHierarchy(ReadGraph graph, Resource container) throws DatabaseException {
public void write(File unsafeFolder) throws IOException {
File folder = escapeFile(unsafeFolder);
FileUtils.delete(folder.toPath());
- folder.mkdirs();
+ folder.getParentFile().mkdirs();
writeDirectories(folder);
writeResources(folder);
}
+ Resource getParent(Resource r) {
+ return parents.get(r);
+ }
+
private File getFolder(File root, Resource library) {
if(ontology.equals(library))
return root;
- Resource parent = parents.get(library);
+ Resource parent = getParent(library);
if(parent == null)
throw new IllegalStateException("null parent for " + library);
File parentFolder = getFolder(root, parent);
- return new File(parentFolder, FileUtils.escapeFileName(names.get(library)));
+ return new File(parentFolder, names.get(library));
}
private File getFile(File rootFolder, Resource r) {
- Resource parent = parents.get(r);
+ Resource parent = getParent(r);
File folder = getFolder(rootFolder, parent);
- return new File(folder, FileUtils.escapeFileName(names.get(r)));
+ return new File(folder, names.get(r));
}
+ private File makeUnique(File original, Resource r) {
+ int counter = 2;
+ File file = new File(original.getParent(), original.getName());
+ File test = file;
+ while(test.exists()) {
+ // Here we have a name clash with small and big letters! (windows)
+ test = new File(file.getParent(), file.getName() + "____" + (counter++));
+ }
+ // Enforce this renaming in future operations also
+ names.put(r, test.getName());
+ return test;
+ }
+
private void writeDirectories(File rootFolder) {
- for(Resource library : containers()) {
- File folder = getFolder(rootFolder, library);
+ // Here stuff shall be returned in alphabetical order
+ for(Resource library : sortedContainers(rootFolder)) {
+ File folder = makeUnique(getFolder(rootFolder, library), library);
folder.mkdirs();
libraryFolders.put(library, folder);
}
}
private void writeResources(File rootFolder) throws IOException {
- for(Resource r : parents.keySet()) {
+ // Here stuff shall be returned in alphabetical order
+ for(Resource r : sortedResources(rootFolder)) {
writeResource(rootFolder, r);
}
}
}
private void write(File rootFolder, Resource resource, byte[] bytes) throws IOException {
- FileUtils.writeFile(getFile(rootFolder, resource), bytes);
+ FileUtils.writeFile(makeUnique(getFile(rootFolder, resource), resource), bytes);
}
}
\ No newline at end of file
*/
public class OntologicalRequirementEnforceRequest extends WriteRequest {
+ private static final String PROP_WRITE_CHANGED_TAGS = "org.simantics.modeling.writeChangedTags"; //$NON-NLS-1$
+
private Collection<Resource> creates;
private Collection<Resource> modis;
private Collection<Resource> ids;
private String author;
private long time;
+ private static String getAuthor() {
+ return System.getProperty("user.name", ""); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ private static boolean writeChangedTags() {
+ return !System.getProperty(PROP_WRITE_CHANGED_TAGS, "") //$NON-NLS-1$
+ .equalsIgnoreCase("false"); //$NON-NLS-1$
+ }
+
public OntologicalRequirementEnforceRequest(Collection<Resource> creates, Collection<Resource> modis, Collection<Resource> ids) {
this(creates,
modis,
ids,
- System.getProperty("user.name", ""),
+ getAuthor(),
System.currentTimeMillis());
}
@Override
public void perform(WriteGraph graph) throws DatabaseException {
- update(graph, creates, modis, ids, true, author, time, true);
+ update(graph, creates, modis, ids, true, author, time, true, writeChangedTags());
}
public static void update(
modis,
ids,
addComment,
- System.getProperty("user.name", ""),
+ getAuthor(),
System.currentTimeMillis(),
disableDependencyIndexing);
String author,
long time,
boolean disableDependencyIndexing) throws DatabaseException
+ {
+ update(graph, creates, modis, ids, addComment, author, time, disableDependencyIndexing, writeChangedTags());
+ }
+
+ public static void update(
+ WriteGraph graph,
+ Collection<Resource> creates,
+ Collection<Resource> modis,
+ Collection<Resource> ids,
+ boolean addComment,
+ String author,
+ long time,
+ boolean disableDependencyIndexing,
+ boolean writeChangedTags) throws DatabaseException
{
if (disableDependencyIndexing)
Layer0Utils.setDependenciesIndexingDisabled(graph, true);
-
+
ModelingResources MOD = ModelingResources.getInstance(graph);
Layer0 L0 = Layer0.getInstance(graph);
for (Resource c : creates) {
CommonDBUtils.selectClusterSet(graph, c);
graph.claimLiteral(c, MOD.changeInformation, MOD.changeInformation_Inverse, MOD.ChangeInformation, info, ChangeInformation.BINDING);
- ModelingUtils.markChanged(graph, c);
}
+ if (writeChangedTags)
+ ModelingUtils.markChanged(graph, creates);
}
for (Resource m : modis) {
info.modifiedBy = author;
CommonDBUtils.selectClusterSet(graph, m);
graph.claimLiteral(m, MOD.changeInformation, MOD.changeInformation_Inverse, MOD.ChangeInformation, info, ChangeInformation.BINDING);
- ModelingUtils.markChanged(graph, m);
}
-
+ if (writeChangedTags)
+ ModelingUtils.markChanged(graph, modis);
+
for (Resource r : ids) {
if (!graph.hasStatement(r, L0.identifier)) {
CommonDBUtils.selectClusterSet(graph, r);
}
}
- graph.addMetadata( graph.getMetadata(CommentMetadata.class).add("Updated change information") );
-
+ graph.addMetadata( graph.getMetadata(CommentMetadata.class).add("Updated change information") ); //$NON-NLS-1$
graph.addMetadata( graph.getMetadata(ChangeHistoryUpdated.class) );
-
}
}
\ No newline at end of file
public boolean checkChanges(ReadGraph g, IForwardMapping<Domain, Range> map, Domain domainElement, Range rangeElement) throws MappingException {
Domain value = domainAccessor.get(g, domainElement);
Range mappedValue = value == null ? null : map.map(g, value);
- return mappedValue == rangeAccessor.get(rangeElement);
+ return mappedValue != rangeAccessor.get(rangeElement);
}
@Override
public boolean checkChanges(ReadGraph g, IForwardMapping<Domain, Range> map, Domain domainElement, Range rangeElement) throws MappingException {
LOGGER.trace(" MappedElementsRule.updateRange");
ArrayList<Range> mappedValue = getMappedValue(g, map, domainElement);
- return Objects.equals(mappedValue, rangeAccessor.get(rangeElement));
+ return !Objects.equals(mappedValue, rangeAccessor.get(rangeElement));
}
private ArrayList<Range> getMappedValue(ReadGraph g, IForwardMapping<Domain, Range> map, Domain domainElement)
public boolean checkChanges(ReadGraph g, IForwardMapping<Domain, Range> map, Domain domainElement,
Range rangeElement) throws MappingException {
Object value = rangeAccessor.get(rangeElement);
- return Objects.equals(value, domainAccessor.get(g, domainElement));
+ return !Objects.equals(value, domainAccessor.get(g, domainElement));
}
public void createDomain(WriteGraph g, IBackwardMapping<Domain,Range> map, Domain domainElement, Range rangeElement) throws MappingException {
org.simantics.scenegraph;bundle-version="1.1.1",
org.eclipse.core.runtime;bundle-version="3.6.0",
org.simantics.diagram.ontology;bundle-version="1.1.1",
- org.simantics.db.common
+ org.slf4j.api
Bundle-ActivationPolicy: lazy
Bundle-Activator: org.simantics.scenegraph.profile.impl.Activator
Import-Package: org.simantics
import org.simantics.db.Resource;
import org.simantics.db.Session;
import org.simantics.db.common.session.SessionEventListenerAdapter;
-import org.simantics.db.common.utils.Logger;
import org.simantics.db.procedure.Procedure;
+import org.simantics.db.service.QueryControl;
import org.simantics.db.service.SessionEventSupport;
import org.simantics.scenegraph.INode;
import org.simantics.scenegraph.g2d.G2DSceneGraph;
import org.simantics.utils.datastructures.disposable.IDisposable;
import org.simantics.utils.threads.IThreadWorkQueue;
import org.simantics.utils.threads.ThreadUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class ProfileObserver implements EvaluationContext {
+ private static final Logger LOGGER = LoggerFactory.getLogger(ProfileObserver.class);
+
private final Session session;
/**
private volatile boolean dirty = true;
private volatile boolean disposed = false;
+ private boolean needSynchronizedUpdates = false;
private List<Pair<Style, Object>> updates = new ArrayList<>();
private boolean updateAll;
this.sceneGraph = sceneGraph;
this.constants.putAll(constants);
this.notification = notification;
+ this.needSynchronizedUpdates = session.getService(QueryControl.class).getAmountOfQueryThreads() > 1;
attachSessionListener();
public void update(Style style, Object item) {
if (DebugPolicy.DEBUG_PROFILE_OBSERVER_UPDATE)
System.out.println("Profile observer marked dirty.");
-
- updates.add(Pair.make(style, item));
+
+ if (needSynchronizedUpdates) {
+ synchronized (updates) {
+ updates.add(Pair.make(style, item));
+ }
+ } else {
+ updates.add(Pair.make(style, item));
+ }
//updateAll = true;
dirty = true;
}
e.apply(ProfileObserver.this);
}
updateAll = false;
- updates.clear();
+ if (needSynchronizedUpdates) {
+ synchronized (updates) {
+ updates.clear();
+ }
+ } else {
+ updates.clear();
+ }
} else {
- List<Pair<Style, Object>> updatesCopy = new ArrayList<>(updates);
- updates.clear();
+ List<Pair<Style, Object>> updatesCopy;
+ if (needSynchronizedUpdates) {
+ synchronized (updates) {
+ updatesCopy = new ArrayList<>(updates);
+ updates.clear();
+ }
+ } else {
+ updatesCopy = new ArrayList<>(updates);
+ updates.clear();
+ }
+
for (Pair<Style, Object> update : updatesCopy) {
Style style = update.first;
Object item = update.second;
@Override
public void exception(Throwable t) {
- Logger.defaultLogError(t);
+ LOGGER.error("RuntimeProfileActiveEntries request failed", t);
}
});
}
@Override
public void exception(Throwable throwable) {
- Logger.defaultLogError(throwable);
+ LOGGER.error("Exception occurred during diagram profile observation", throwable);
}
@SuppressWarnings("unchecked")
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2007, 2010 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
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * VTT Technical Research Centre of Finland - initial API and implementation
+ *******************************************************************************/
+package org.simantics.scenegraph.g2d.nodes;
+
+import java.awt.BasicStroke;
+import java.awt.Color;
+import java.awt.Graphics2D;
+import java.awt.Paint;
+import java.awt.Shape;
+import java.awt.Stroke;
+import java.awt.geom.AffineTransform;
+import java.awt.geom.Rectangle2D;
+
+import org.simantics.scenegraph.g2d.G2DNode;
+import org.simantics.scenegraph.utils.GeometryUtils;
+import org.simantics.scenegraph.utils.InitValueSupport;
+
+/**
+ * A scene graph node that renders a specified AWT {@link Shape} by optionally
+ * filling or drawing it.
+ *
+ * This is similar to ShapeNode, but allows separate stroke and fill colors.
+ * Due to API changes, I've done separate implementation. -MLuu
+ *
+ *
+ * @author luukkainen
+ * @author J-P Laine
+ * @author Tuukka Lehtonen
+ *
+ */
+public class ShapeNode2 extends G2DNode implements InitValueSupport {
+
+ private static final long serialVersionUID = -5700299566608619380L;
+
+ protected static final Stroke DEFAULT_STROKE = new BasicStroke(2);
+
+ protected Shape shape = null;
+ protected Stroke stroke = DEFAULT_STROKE;
+ protected Paint strokeColor = Color.BLACK;
+ protected Paint fillColor = null;
+ protected boolean scaleStroke = false;
+ protected boolean scaleShape = false;
+
+ protected transient Shape dynamicShape = null;
+ protected transient Stroke dynamicStroke = null;
+ protected transient Paint dynamicStrokeColor = null;
+ protected transient Paint dynamicFillColor = null;
+ protected transient Boolean dynamicScaleStroke = null;
+ protected transient Boolean dynamicScaleShape = null;
+
+ @PropertySetter("shape")
+ @SyncField("shape")
+ public void setShape(Shape shape) {
+ this.shape = shape;
+ repaint();
+ }
+
+ @PropertySetter("stroke")
+ @SyncField("stroke")
+ public void setStroke(Stroke stroke) {
+ this.stroke = stroke;
+ }
+
+ @PropertySetter("strokeColor")
+ @SyncField("strokeColor")
+ public void setStrokeColor(Paint color) {
+ this.strokeColor = color;
+ }
+
+ @PropertySetter("fillColor")
+ @SyncField("fillColor")
+ public void setFillColor(Paint color) {
+ this.fillColor = color;
+ }
+
+
+ @SyncField("scaleStroke")
+ public void setScaleStroke(boolean scaleStroke) {
+ this.scaleStroke = scaleStroke;
+ }
+
+ @SyncField("scaleShape")
+ public void setScaleShape(boolean scaleShape) {
+ this.scaleShape = scaleShape;
+ }
+
+ @Override
+ public void render(Graphics2D g2d) {
+ Shape shape = dynamicShape != null ? dynamicShape : this.shape;
+ if (shape == null)
+ return;
+
+ AffineTransform ot = setupRender(g2d);
+ renderShape(g2d, shape);
+ if (ot != null)
+ g2d.setTransform(ot);
+ }
+
+ /**
+ * @param g2d
+ * @return current transform
+ */
+ protected AffineTransform setupRender(Graphics2D g2d) {
+ AffineTransform old = null;
+ if (!transform.isIdentity()) {
+ old = g2d.getTransform();
+ g2d.transform(transform);
+ }
+
+
+ boolean scaleShape = Boolean.TRUE.equals(dynamicScaleShape) ? true : this.scaleShape;
+ if (scaleShape) {
+ double xs = g2d.getTransform().getScaleX();
+ double ys = g2d.getTransform().getScaleY();
+ g2d.scale(1/xs, 1/ys);
+ }
+
+ return old;
+ }
+
+ protected void renderShape(Graphics2D g2d, Shape s) {
+ Paint color = dynamicFillColor != null ? dynamicFillColor : this.fillColor;
+ if (color != null) {
+ g2d.setPaint(color);
+ g2d.fill(s);
+ }
+
+ Stroke stroke = dynamicStroke != null ? dynamicStroke : this.stroke;
+ if (stroke != null) {
+ color = dynamicStrokeColor != null ? dynamicStrokeColor : this.strokeColor;
+ if (color != null) g2d.setPaint(color);
+
+ boolean scaleStroke = Boolean.TRUE.equals(dynamicScaleStroke) ? true : this.scaleStroke;
+ if (scaleStroke && stroke instanceof BasicStroke) {
+ BasicStroke bs = GeometryUtils.scaleStroke(stroke, (float) (1.0 / GeometryUtils.getScale(g2d.getTransform())));
+ g2d.setStroke(bs);
+ } else {
+ g2d.setStroke(stroke);
+ }
+
+ g2d.draw(s);
+ }
+ }
+
+ @Override
+ public Rectangle2D getBoundsInLocal() {
+ if(shape == null) return null;
+ return shape.getBounds2D();
+ }
+
+ public void setValue(String key, Object value) {
+ if ("shape".equals(key))
+ dynamicShape = (Shape) value;
+ else if ("stroke".equals(key))
+ dynamicStroke = (Stroke) value;
+ else if ("strokeColor".equals(key))
+ dynamicStrokeColor = (Paint) value;
+ else if ("fillColor".equals(key))
+ dynamicFillColor = (Paint) value;
+ else if ("scaleStroke".equals(key))
+ dynamicScaleStroke = (Boolean) value;
+ else if ("scaleShape".equals(key))
+ dynamicScaleShape = (Boolean) value;
+// else super.setValue(key, value);
+ }
+
+ @Override
+ public void initValues() {
+ dynamicShape = null;
+ dynamicStroke = null;
+ dynamicStrokeColor = null;
+ dynamicFillColor = null;
+ dynamicScaleStroke = null;
+ dynamicScaleShape = null;
+ }
+
+ @Override
+ public String toString() {
+ return super.toString() + " [shape=" + shape + ",color=" + strokeColor + ",fill=" + fillColor +"]";
+ }
+
+}
return getModule(moduleName, null);
}
+ public void update(String moduleName) {
+ getModuleEntry(moduleName, null).notifyAboutUpdate();
+ }
+
public Failable<RuntimeModule> getRuntimeModule(String moduleName, UpdateListener listener) {
return getModuleEntry(moduleName, listener).getRuntimeModule();
}
org.simantics.scl.osgi;bundle-version="1.0.4",
org.jdom2;bundle-version="2.0.6",
org.junit;bundle-version="4.12.0";resolution:=optional,
- com.fasterxml.jackson.core.jackson-core;bundle-version="2.8.2",
- com.fasterxml.jackson.core.jackson-databind
+ com.fasterxml.jackson.core.jackson-core;bundle-version="[2.8.11,2.9.0)",
+ com.fasterxml.jackson.core.jackson-databind;bundle-version="[2.8.11,2.9.0)"
Bundle-ClassPath: .
Automatic-Module-Name: org.simantics.scl.data
package org.simantics.scl.reflection.internal;
-import java.util.concurrent.ForkJoinPool;
-
import org.eclipse.core.runtime.ILog;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
-import org.simantics.scl.reflection.internal.registry.BindingRegistry;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public void start(BundleContext context) throws Exception {
this.context = context;
instance = this;
-
- primeBindingRegistry();
- }
-
- private static void primeBindingRegistry() {
- LOGGER.info("Priming BindingRegistry");
- ForkJoinPool.commonPool().submit(() -> {
- try {
- // this forces static initialzation of the registry in advance
- BindingRegistry.primeBindingRegistry();
- } catch (Exception e) {
- LOGGER.error("Could not prime binding registry", e);
- }
- LOGGER.info("Priming done");
- });
}
@Override
}
}
- public static void primeBindingRegistry() {
- for (Namespace ns : namespaces.values()) {
- ns.initializeValues();
- }
- }
-
static {
initialize();
if (DEBUG_INIT) {
}
}
- synchronized void initializeValues() {
+ private synchronized void initializeValues() {
if(values == null) {
initializeTypes();
TypeBindingScheme scheme = MinimalTypeBindingScheme.INSTANCE;
Bundle-SymbolicName: org.simantics.scl.rest
Bundle-Version: 1.0.0.qualifier
Bundle-Activator: org.simantics.scl.rest.Activator
-Require-Bundle: org.glassfish.jersey.core.jersey-server,
+Require-Bundle: org.glassfish.jersey.core.jersey-server;bundle-version="[2.25.1,2.26.0)",
org.simantics.scl.compiler,
org.simantics.scl.osgi,
- org.glassfish.jersey.containers.jersey-container-servlet-core,
+ org.glassfish.jersey.containers.jersey-container-servlet-core;bundle-version="[2.25.1,2.26.0)",
javax.servlet-api,
org.eclipse.jetty.servlet;bundle-version="9.4.24",
org.eclipse.jetty.server;bundle-version="9.4.24",
org.eclipse.jetty.util;bundle-version="9.4.24",
org.eclipse.jetty.io;bundle-version="9.4.24",
- com.fasterxml.jackson.core.jackson-core;bundle-version="2.8.8",
- com.fasterxml.jackson.core.jackson-annotations;bundle-version="2.8.0",
- com.fasterxml.jackson.core.jackson-databind;bundle-version="2.8.8",
- org.glassfish.jersey.media.jersey-media-json-jackson;bundle-version="2.25.1",
- org.glassfish.jersey.media.jersey-media-multipart;bundle-version="2.25.1",
+ com.fasterxml.jackson.core.jackson-core;bundle-version="[2.8.11,2.9.0)",
+ com.fasterxml.jackson.core.jackson-annotations;bundle-version="[2.8.11,2.9.0)",
+ com.fasterxml.jackson.core.jackson-databind;bundle-version="[2.8.11,2.9.0)",
+ org.glassfish.jersey.media.jersey-media-json-jackson;bundle-version="[2.25.1,2.26.0)",
+ org.glassfish.jersey.media.jersey-media-multipart;bundle-version="[2.25.1,2.26.0)",
org.slf4j.api,
org.jvnet.mimepull;bundle-version="1.9.6",
- org.glassfish.jersey.core.jersey-client,
- org.glassfish.jersey.core.jersey-common;bundle-version="2.25.1",
+ org.glassfish.jersey.core.jersey-client;bundle-version="[2.25.1,2.26.0)",
+ org.glassfish.jersey.core.jersey-common;bundle-version="[2.25.1,2.26.0)",
org.simantics.scl.runtime,
org.eclipse.osgi;bundle-version="3.15.100",
- jakarta.ws.rs-api;bundle-version="2.1.6"
+ javax.ws.rs-api,
+ org.glassfish.hk2.external.aopalliance-repackaged;bundle-version="2.5.0",
+ org.glassfish.jersey.bundles.repackaged.jersey-guava;bundle-version="[2.25.1,2.26.0)",
+ org.glassfish.hk2.api;bundle-version="2.5.0",
+ org.glassfish.hk2.locator;bundle-version="2.5.0",
+ org.glassfish.hk2.osgi-resource-locator;bundle-version="1.0.1",
+ org.glassfish.hk2.utils;bundle-version="2.5.0",
+ javassist;bundle-version="3.20.0"
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Bundle-ActivationPolicy: lazy
Automatic-Module-Name: org.simantics.scl.rest
</extension>
<extension
point="org.eclipse.ui.bindings">
- <key
- commandId="org.eclipse.ui.views.showView"
- schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
- sequence="M2+M3+Q S">
- <parameter
- id="org.eclipse.ui.views.showView.viewId"
- value="org.simantics.scl.ui.console">
- </parameter>
- </key>
- <key
- platform="carbon"
- schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
- sequence="M2+M3+Q S">
- </key>
- <key
- platform="carbon"
- commandId="org.eclipse.ui.views.showView"
- schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
- sequence="M1+M3+Q S">
- <parameter
- id="org.eclipse.ui.views.showView.viewId"
- value="org.simantics.scl.ui.console">
- </parameter>
- </key>
<key
commandId="org.simantics.scl.editor.openModule"
schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
*******************************************************************************/
package org.simantics.scl.ui.assist;
+import org.eclipse.jface.fieldassist.ContentProposalAdapter;
import org.eclipse.jface.fieldassist.IControlContentAdapter;
import org.eclipse.jface.fieldassist.IControlContentAdapter2;
import org.eclipse.swt.custom.StyledText;
public void insertControlContents(Control control, String contents, int cursorPosition) {
StyledText text = ((StyledText)control);
cursorPosition = Math.min(cursorPosition, contents.length());
- int caretEndRange = text.getCaretOffset();
+
+ int caretOffset = text.getCaretOffset();
String currentText = text.getText();
-
- int offset = caretEndRange;
- int length = currentText.length();
- while (--offset >= 0 && (Character.isJavaIdentifierPart(currentText.charAt(offset)) && !Character.isWhitespace(currentText.charAt(offset))))
- length--;
-
- int nameSpaceBeginRange = currentText.lastIndexOf(".", caretEndRange - 1); //$NON-NLS-1$
- if (nameSpaceBeginRange > length)
- length = nameSpaceBeginRange;
- int endRange = currentText.length();
- if (caretEndRange < endRange)
- endRange = caretEndRange;
- text.setSelection(length, endRange);
+ int replacementOffset = findPrefixMatchOffset(currentText, caretOffset, contents);
+
+// System.out.println("text: " + currentText);
+// System.out.println("proposal to fill: " + contents);
+// System.out.format("longest match of proposed contents found from text @ offset %d: \"%s[%s]%s\"%n",
+// replacementOffset,
+// currentText.substring(0, replacementOffset),
+// currentText.substring(replacementOffset, caretOffset),
+// currentText.substring(caretOffset));
+
+ // The text between [replaceOffset, caretOffset) will be replaced with `contents`
+ text.setSelection(replacementOffset, caretOffset);
text.insert(contents);
- // calculate the initial count of letters that was typed when the proposal was accepted to insert the caret
- // at the right position
- int proposalFirstLettersCount = endRange - (length);
- text.setCaretOffset(caretEndRange + cursorPosition - proposalFirstLettersCount);
+ text.setSelection(replacementOffset + contents.length());
+ }
+
+ /**
+ * Find offset of longest prefix match of <code>match</code> in
+ * <code>text</code> ending at offset <code>endOffset</code>.
+ *
+ * Example:
+ * <pre>
+ * ... res (=text)
+ * resource (=match)
+ * resourc
+ * resour
+ * resou
+ * reso
+ * res match! return endOffset - 3
+ * </pre>
+ *
+ * @param text the text from which to find the match
+ * @param endOffset endOffset until which to search for the longest match
+ * @param match the text to prefix-match
+ * @return
+ */
+ private static int findPrefixMatchOffset(String text, int endOffset, String match) {
+ for (int i = match.length(); i >= 0; --i) {
+ if (text.regionMatches(true, endOffset - i, match, 0, i))
+ return endOffset - i;
+ }
+ return 0;
}
/*
import java.util.concurrent.Executor;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
-import java.util.logging.Level;
-import java.util.logging.Logger;
import org.simantics.databoard.Bindings;
import org.simantics.databoard.accessor.error.AccessorException;
import org.simantics.history.util.subscription.SubscriptionItem;
import org.simantics.simulation.data.Datasource.DatasourceListener;
import org.simantics.utils.datastructures.Triple;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* This adapter reads data from Datasource and writes to an open Subscription.
*/
public class DatasourceAdapter implements DatasourceListener {
- protected Logger logger = Logger.getLogger( DatasourceAdapter.class.toString() );
+ protected Logger logger = LoggerFactory.getLogger( DatasourceAdapter.class );
protected Collector session;
protected boolean loaded = false;
protected List<VariableHandle> handles = new ArrayList<VariableHandle>();
result.add(Triple.make(key, binding, value));
} catch (AccessorException e) {
if (failedIds.add(key))
- logger.log(Level.SEVERE, e.toString(), e);
+ logger.error(e.toString(), e);
continue;
}
}
value = handle.getValue(source);
} catch (AccessorException e) {
if (failedIds.add(key))
- logger.log(Level.SEVERE, e.toString(), e);
+ logger.error(e.toString(), e);
continue;
}
Binding binding = handle.binding();
try {
session.setValue( key, binding, value );
} catch (HistoryException e) {
- logger.log(Level.SEVERE, e.toString(), e);
+ logger.error(e.toString(), e);
}
} else {
Binding binding = bindings.get(i);
if (binding != null) {
session.setValue( key, binding, value );
- }
+ }
}
}
try {
session.endStep();
} catch (HistoryException e) {
- logger.log(Level.SEVERE, e.toString(), e);
+ logger.error(e.toString(), e);
}
}
} catch (HistoryException e) {
- logger.log(Level.SEVERE, e.toString(), e);
+ logger.error(e.toString(), e);
} finally {
stepLock.unlock();
}
public Executor getExecutor() {
return null;
}
-
}
// Resource experiment = graph.syncRequest(new PossibleExperiment(subscriptionItem));
// String runIdentifier = ""; // experiment.getIdentifier();
-
+
+ item.groupItemId = graph.getPossibleRelatedValue(subscriptionItem, L0.HasName, Bindings.STRING);
+ if (item.groupItemId == null) continue;
+
item.variableReference = rvi.toPossibleString(graph, configuration);
if (item.variableReference == null) continue;
public static class CSVItem {
public String modelUri;
public String label;
+ public String groupItemId;
public String variableReference;
public String unit;
}
labelBuilder.append(")");
}
- List<Bean> historyItems = im.search("variableId", item.variableReference);
+ List<Bean> historyItems = im.search("groupItemId", item.groupItemId, "variableId", item.variableReference);
Collections.sort(historyItems, SamplingFormat.INTERVAL_COMPARATOR);
if (items.isEmpty()) continue;
Bean config = historyItems.get(0);
*/
public static HistoryImportResult importHistoryArchive(HistoryManager history, Path path) throws IOException, HistoryException {
HistoryImportResult result = new HistoryImportResult();
- try (RandomAccessBinary rab = new BinaryFile(path.toFile())) {
+ try (RandomAccessBinary rab = new BinaryFile(path.toFile(), "r")) {
importHistoryArchive(history, rab, result);
return result;
} catch (IOException e) {
*/
THashSet<T> potentiallyUpdatedComponents = new THashSet<>();
+ /**
+ * Is this potentially an undo/redo-related synchronization?
+ *
+ * Default is true for backwards compatibility.
+ */
+ protected boolean isUndo = true;
+
public SynchronizationEventHandlerBase(Solver solver, ReferenceResolverBase<T> resolver, SolverNameUtil nameUtil,
ComponentFactory<T> componentFactory, ModuleUpdaterFactoryBase<T> moduleUpdaterFactory, MappingBase<T> mapping) {
this.solver = solver;
this.resolver = resolver;
}
+ /**
+ * Mark the undo/redo status of this handler.
+ *
+ * Set 'isUndo' to false when processing a normal synchronization and true when
+ * processing an undo/redo.
+ *
+ * When 'isUndo' is false, loading of component solver state from the state undo context
+ * is skipped for added components.
+ */
+ public void setAsUndo(boolean isUndo) {
+ this.isUndo = isUndo;
+ }
+
@Override
public void beginSynchronization() {
if(TRACE_EVENTS) {
else {
component.attached = false;
context.setModuleName(nameUtil.getFreshName(parentSolverComponentName, name));
- context.addPostUpdateAction(new Runnable() {
- @Override
- public void run() {
- context.stateLoadedFromUndo = mapping.undoContext.loadState(solver,
- context.component.componentId,
- context.component.uid);
- }
- });
+ if (isUndo) {
+ context.addPostUpdateAction(new Runnable() {
+ @Override
+ public void run() {
+ context.stateLoadedFromUndo = mapping.undoContext.loadState(solver,
+ context.component.componentId,
+ context.component.uid);
+ }
+ });
+ }
updater.create(context, properties, connections);
solverComponentNameToComponent.put(context.getModuleName(), component);
}
@Override
public Map<String, Variable> getVariables(ReadGraph graph, Variable context, Map<String, Variable> map) throws DatabaseException {
-
- Resource type = context.getPossibleType(graph);
+ StructuralResource2 STR = StructuralResource2.getInstance(graph);
+ Resource type = context.getPossibleType(graph, STR.Component);
if(type == null) return null;
StructuralComponentClass clazz = StructuralComponentClass.get(graph, type);
}
return map;
} else if (StructuralComponentClass.DEFINED.equals(clazz)) {
- StructuralResource2 STR = StructuralResource2.getInstance(graph);
Resource def = graph.getSingleObject(type, STR.IsDefinedBy);
Map<String, Resource> children = graph.syncRequest(new UnescapedChildMapOfResource(def), TransientCacheListener.instance());
return StandardChildDomainChildren.getStandardChildDomainChildVariables(graph, context, children, map);
Variable firstRepresentedParent = findFirstParentWithRepresentation(graph, parameter, STR);
if (firstRepresentedParent == null)
return null;
- Resource realParentComposite = graph.getPossibleObject(firstRepresentedParent.getRepresents(graph), L0.PartOf);
- if (realParentComposite == null)
- return null;
- isInsideStructure = graph.hasStatement(realParentComposite, STR.Defines);
+ Resource representedParent = firstRepresentedParent.getRepresents(graph);
+ Resource representedParentType = graph.getPossibleType(representedParent, STR.Component);
+ if (representedParentType != null && graph.isInstanceOf(representedParentType, STR.ProceduralComponentType)) {
+ isInsideStructure = !parameter.equals(firstRepresentedParent);
+ } else {
+ Resource realParentComposite = graph.getPossibleObject(representedParent, L0.PartOf);
+ if (realParentComposite == null)
+ return null;
+ isInsideStructure = graph.hasStatement(realParentComposite, STR.Defines);
+ }
Variable firstParentComposite = findFirstParentComposite(graph, firstRepresentedParent, STR);
if (firstParentComposite != null) {
import org.simantics.db.common.procedure.adapter.TransientCacheListener;
import org.simantics.db.common.request.PossibleIndexRoot;
import org.simantics.db.common.request.ResourceRead2;
+import org.simantics.db.common.request.RuntimeEnvironmentRequest;
import org.simantics.db.exception.DatabaseException;
import org.simantics.db.layer0.scl.AbstractExpressionCompilationContext;
import org.simantics.db.layer0.scl.AbstractExpressionCompilationRequest;
-import org.simantics.db.layer0.util.RuntimeEnvironmentRequest;
import org.simantics.db.layer0.util.RuntimeEnvironmentRequest2;
import org.simantics.layer0.Layer0;
import org.simantics.scl.compiler.elaboration.expressions.EApply;
import org.simantics.db.common.request.IndexRoot;
import org.simantics.db.common.request.UnaryRead;
import org.simantics.db.exception.DatabaseException;
-import org.simantics.db.layer0.util.RuntimeEnvironmentRequest;
+import org.simantics.db.layer0.util.RuntimeEnvironmentRequest2;
import org.simantics.scl.compiler.environment.specification.EnvironmentSpecification;
import org.simantics.scl.compiler.runtime.RuntimeEnvironment;
import org.simantics.structural2.scl.ComponentTypeProperty;
public ProceduralComponentTypeCompilationContext perform(ReadGraph graph)
throws DatabaseException {
Resource indexRoot = graph.syncRequest(new IndexRoot(parameter));
- RuntimeEnvironment runtimeEnvironment = graph.syncRequest(new RuntimeEnvironmentRequest(indexRoot) {
+ RuntimeEnvironment runtimeEnvironment = graph.syncRequest(new RuntimeEnvironmentRequest2(parameter, indexRoot) {
@Override
protected void fillEnvironmentSpecification(
EnvironmentSpecification environmentSpecification) {
}
public static boolean isImmutable(ReadGraph graph, Resource r) throws DatabaseException {
+ // Marking a resource L0.readOnly also makes it immutable
+ if (graph.isImmutable(r) || Layer0Utils.isMarkedReadOnly(graph, r))
+ return true;
StructuralResource2 STR = StructuralResource2.getInstance(graph);
Resource uc = graph.syncRequest(new PossibleTypedParent(r, STR.ComponentType));
- return graph.isImmutable(r)
- // Anything under a published or locked user component is published as well
- || (uc != null && (Layer0Utils.isPublished(graph, uc)
+ return // Anything under a published or locked user component is published as well
+ (uc != null && (Layer0Utils.isPublished(graph, uc)
|| graph.hasStatement(uc, STR.ComponentType_Locked)))
// Anything under a published container (shared library) is published as well
|| Layer0Utils.isContainerPublished(graph, r)
return (end-from) / getWidth();
}
+ /**
+ * @return the current starting sample time calculated from all visible chart
+ * items.
+ */
+ public double getItemFromTime() {
+ return iFrom;
+ }
+
/**
* @return the current ending sample time calculated from all visible chart
* items.
unpack="false"/>
<plugin
- id="jakarta.ws.rs-api"
+ id="javax.ws.rs-api"
download-size="0"
install-size="0"
version="0.0.0"
unpack="false"/>
<plugin
- id="jakarta.validation.jakarta.validation-api"
+ id="javax.validation.api"
download-size="0"
install-size="0"
version="0.0.0"
unpack="false"/>
<plugin
- id="jakarta.ws.rs-api"
+ id="javax.ws.rs-api"
download-size="0"
install-size="0"
version="0.0.0"
unpack="false"/>
<plugin
- id="jakarta.validation.jakarta.validation-api"
+ id="javax.validation.api"
download-size="0"
install-size="0"
version="0.0.0"
unpack="false"/>
<plugin
- id="jakarta.xml.bind-api"
+ id="org.glassfish.hk2.external.aopalliance-repackaged"
+ download-size="0"
+ install-size="0"
+ version="0.0.0"
+ unpack="false"/>
+
+ <plugin
+ id="org.glassfish.jersey.bundles.repackaged.jersey-guava"
+ download-size="0"
+ install-size="0"
+ version="0.0.0"
+ unpack="false"/>
+
+ <plugin
+ id="org.glassfish.hk2.api"
+ download-size="0"
+ install-size="0"
+ version="0.0.0"
+ unpack="false"/>
+
+ <plugin
+ id="org.glassfish.hk2.locator"
+ download-size="0"
+ install-size="0"
+ version="0.0.0"
+ unpack="false"/>
+
+ <plugin
+ id="org.glassfish.hk2.utils"
+ download-size="0"
+ install-size="0"
+ version="0.0.0"
+ unpack="false"/>
+
+ <plugin
+ id="javassist"
download-size="0"
install-size="0"
version="0.0.0"
<jaxen.version>1.2.0</jaxen.version>
<jdom.version>2.0.6</jdom.version>
<jdom.version.actual>2.0.6.b0001</jdom.version.actual>
- <jackson.version>2.10.2</jackson.version>
- <jackson.version.actual>2.10.2.b0001</jackson.version.actual>
+ <jackson.version>2.8.11</jackson.version>
+ <jackson.version.actual>2.8.11</jackson.version.actual>
<javax.version>3.1.0</javax.version>
- <jakarta.version>2.1.6</jakarta.version>
- <!-- This can be removed once jakarta version is bumped -->
- <jakarta.version.actual>2.1.6.b0005</jakarta.version.actual>
- <jersey.version>2.30.1</jersey.version>
- <!-- This can be removed once jersey version is bumped -->
- <jersey.version.actual>2.30.1.b0005</jersey.version.actual>
+ <jersey.version>2.25.1</jersey.version>
<jfreechart.version>1.5.0</jfreechart.version>
<slf4j.version>1.7.30</slf4j.version>
<slf4j.version.actual>1.7.30</slf4j.version.actual>
<ini4j.version>0.5.4</ini4j.version>
<commons-collections.version>4.4</commons-collections.version>
<commons-compress.version>1.20</commons-compress.version>
+ <commons-csv.version>1.6</commons-csv.version>
<commons-lang.version>2.6</commons-lang.version>
<commons-logging.version>1.2</commons-logging.version>
<commons-io.version>1.4</commons-io.version>
<plugin>
<groupId>org.eclipse.tycho.extras</groupId>
<artifactId>tycho-p2-extras-plugin</artifactId>
- <version>1.0.0</version>
+ <version>1.7.0</version>
</plugin>
<plugin>
<groupId>org.reficio</groupId>
<artifactId>p2-maven-plugin</artifactId>
- <version>1.2.0</version>
+ <version>1.3.0</version>
<executions>
<execution>
<id>default-cli</id>
<Bundle-SymbolicName>org.apache.commons.compress</Bundle-SymbolicName>
</instructions>
</artifact>
+ <artifact>
+ <id>org.apache.commons:commons-csv:${commons-csv.version}</id>
+ <source>true</source>
+ </artifact>
<artifact>
<id>commons-lang:commons-lang:${commons-lang.version}</id>
<source>true</source>
<id>org.apache.aries.spifly:org.apache.aries.spifly.dynamic.bundle:${org.apache.aries.spifly.dynamic.bundle.version}</id>
<source>true</source>
</artifact>
- <artifact>
- <id>jakarta.ws.rs:jakarta.ws.rs-api:${jakarta.version}</id>
- <source>true</source>
- <override>true</override>
- <instructions>
- <Bundle-Version>${jakarta.version.actual}</Bundle-Version>
- <Require-Bundle>
- jakarta.xml.bind-api
- </Require-Bundle>
- <Import-Package>!javax.*,*;resolution:=optional</Import-Package>
- <Export-Package>
- javax.ws.rs;version="${jakarta.version}",
- javax.ws.rs.core;version="${jakarta.version}",
- javax.ws.rs.ext;version="${jakarta.version}",
- javax.ws.rs.client;version="${jakarta.version}",
- javax.ws.rs.container;version="${jakarta.version}",
- javax.ws.rs.sse;version="${jakarta.version}"
- </Export-Package>
- </instructions>
- </artifact>
- <artifact>
- <id>org.glassfish.jersey.core:jersey-common:${jersey.version}</id>
- <source>true</source>
- <override>true</override>
- <instructions>
- <Bundle-Version>${jersey.version.actual}</Bundle-Version>
- <Require-Bundle>
- javax.annotation,
- javax.inject,
- jakarta.validation.jakarta.validation-api,
- jakarta.ws.rs-api,
- jakarta.xml.bind-api
- </Require-Bundle>
- <Import-Package>!javax.*,*;resolution:=optional</Import-Package>
- <Export-Package>
- org.glassfish.jersey.*;version="${jersey.version}"
- </Export-Package>
- </instructions>
- </artifact>
<artifact>
<id>org.glassfish.jersey.core:jersey-server:${jersey.version}</id>
<source>true</source>
- <override>true</override>
- <instructions>
- <Bundle-Version>${jersey.version.actual}</Bundle-Version>
- <Require-Bundle>
- javax.annotation,
- javax.inject,
- jakarta.validation.jakarta.validation-api,
- jakarta.ws.rs-api,
- jakarta.xml.bind-api
- </Require-Bundle>
- <Import-Package>!javax.*,*;resolution:=optional</Import-Package>
- </instructions>
</artifact>
<artifact>
<id>org.glassfish.jersey.core:jersey-client:${jersey.version}</id>
<source>true</source>
- <override>true</override>
- <instructions>
- <Bundle-Version>${jersey.version.actual}</Bundle-Version>
- <Require-Bundle>
- javax.annotation,
- javax.inject,
- jakarta.validation.jakarta.validation-api,
- jakarta.ws.rs-api,
- jakarta.xml.bind-api
- </Require-Bundle>
- <Import-Package>!javax.*,*;resolution:=optional</Import-Package>
- </instructions>
</artifact>
-
<artifact>
<id>org.glassfish.jersey.media:jersey-media-multipart:${jersey.version}</id>
<source>true</source>
- <!-- For some reason p2-maven-plugin does not work with the below plugin and only generates sources for that -->
- <!-- <override>true</override>
- <instructions>
- <Bundle-Version>${jersey.version.actual}</Bundle-Version>
- <Require-Bundle>
- jakarta.ws.rs-api,
- </Require-Bundle>
- <Import-Package>!javax.*,*;resolution:=optional</Import-Package>
- </instructions> -->
- </artifact>
- <artifact>
- <id>org.glassfish.jersey.ext:jersey-entity-filtering:${jersey.version}</id>
- <source>true</source>
- <override>true</override>
- <instructions>
- <Bundle-Version>${jersey.version.actual}</Bundle-Version>
- <Require-Bundle>
- jakarta.ws.rs-api,
- org.glassfish.jersey.core.jersey-server
- </Require-Bundle>
- <Import-Package>!javax.*,*;resolution:=optional</Import-Package>
- </instructions>
</artifact>
<artifact>
<id>org.glassfish.jersey.media:jersey-media-json-jackson:${jersey.version}</id>
<source>true</source>
- <override>true</override>
<excludes>
<exclude>com.fasterxml.jackson.*</exclude>
</excludes>
- <instructions>
- <Bundle-Version>${jersey.version.actual}</Bundle-Version>
- <Require-Bundle>
- javax.annotation,
- javax.inject,
- jakarta.validation.jakarta.validation-api,
- jakarta.ws.rs-api,
- jakarta.xml.bind-api
- </Require-Bundle>
- <Import-Package>!javax.*,*;resolution:=optional</Import-Package>
- </instructions>
</artifact>
<artifact>
<id>org.glassfish.jersey.containers:jersey-container-servlet-core:${jersey.version}</id>
<source>true</source>
- <override>true</override>
- <instructions>
- <Bundle-Version>${jersey.version.actual}</Bundle-Version>
- <Require-Bundle>
- javax.annotation,
- javax.inject,
- jakarta.validation.jakarta.validation-api,
- jakarta.ws.rs-api,
- jakarta.xml.bind-api
- </Require-Bundle>
- <Import-Package>!javax.*,*;resolution:=optional</Import-Package>
- </instructions>
</artifact>
<artifact>
<id>org.jboss.windup.decompiler:decompiler-procyon:${decompiler-procyon.version}</id>
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?pde?>
<!-- generated with https://github.com/eclipse-cbi/targetplatform-dsl -->
-<target name="Eclipse 2019-12 (4.14)" sequenceNumber="1582928275">
+<target name="Eclipse 2019-12 (4.14)" sequenceNumber="1603197307">
<locations>
<location includeMode="slicer" includeAllPlatforms="true" includeSource="true" includeConfigurePhase="false" type="InstallableUnit">
<unit id="com.google.guava" version="21.0.0.v20170206-1425"/>
<unit id="com.esotericsoftware.minlog.source" version="1.3.0"/>
<unit id="com.esotericsoftware.reflectasm" version="1.11.3"/>
<unit id="com.esotericsoftware.reflectasm.source" version="1.11.3"/>
- <unit id="com.fasterxml.jackson.core.jackson-annotations" version="2.10.2"/>
- <unit id="com.fasterxml.jackson.core.jackson-annotations.source" version="2.10.2"/>
- <unit id="com.fasterxml.jackson.core.jackson-core" version="2.10.2"/>
- <unit id="com.fasterxml.jackson.core.jackson-core.source" version="2.10.2"/>
- <unit id="com.fasterxml.jackson.core.jackson-databind" version="2.10.2"/>
- <unit id="com.fasterxml.jackson.core.jackson-databind.source" version="2.10.2"/>
- <unit id="com.fasterxml.jackson.dataformat.jackson-dataformat-csv" version="2.10.2"/>
- <unit id="com.fasterxml.jackson.dataformat.jackson-dataformat-csv.source" version="2.10.2"/>
- <unit id="com.fasterxml.jackson.dataformat.jackson-dataformat-xml" version="2.10.2"/>
- <unit id="com.fasterxml.jackson.dataformat.jackson-dataformat-xml.source" version="2.10.2"/>
- <unit id="com.fasterxml.jackson.datatype.jackson-datatype-jsr310" version="2.10.2"/>
- <unit id="com.fasterxml.jackson.datatype.jackson-datatype-jsr310.source" version="2.10.2"/>
- <unit id="com.fasterxml.jackson.jaxrs.jackson-jaxrs-base" version="2.10.2"/>
- <unit id="com.fasterxml.jackson.jaxrs.jackson-jaxrs-base.source" version="2.10.2"/>
- <unit id="com.fasterxml.jackson.jaxrs.jackson-jaxrs-json-provider" version="2.10.2"/>
- <unit id="com.fasterxml.jackson.jaxrs.jackson-jaxrs-json-provider.source" version="2.10.2"/>
- <unit id="com.fasterxml.jackson.module.jackson-module-jaxb-annotations" version="2.10.2"/>
- <unit id="com.fasterxml.jackson.module.jackson-module-jaxb-annotations.source" version="2.10.2"/>
- <unit id="com.fasterxml.woodstox.woodstox-core" version="6.0.3"/>
- <unit id="com.fasterxml.woodstox.woodstox-core.source" version="6.0.3"/>
+ <unit id="com.fasterxml.jackson.core.jackson-annotations" version="2.8.11"/>
+ <unit id="com.fasterxml.jackson.core.jackson-annotations.source" version="2.8.11"/>
+ <unit id="com.fasterxml.jackson.core.jackson-core" version="2.8.11"/>
+ <unit id="com.fasterxml.jackson.core.jackson-core.source" version="2.8.11"/>
+ <unit id="com.fasterxml.jackson.core.jackson-databind" version="2.8.11"/>
+ <unit id="com.fasterxml.jackson.core.jackson-databind.source" version="2.8.11"/>
+ <unit id="com.fasterxml.jackson.dataformat.jackson-dataformat-csv" version="2.8.11"/>
+ <unit id="com.fasterxml.jackson.dataformat.jackson-dataformat-csv.source" version="2.8.11"/>
+ <unit id="com.fasterxml.jackson.dataformat.jackson-dataformat-xml" version="2.8.11"/>
+ <unit id="com.fasterxml.jackson.dataformat.jackson-dataformat-xml.source" version="2.8.11"/>
+ <unit id="com.fasterxml.jackson.datatype.jackson-datatype-jsr310" version="2.8.11"/>
+ <unit id="com.fasterxml.jackson.datatype.jackson-datatype-jsr310.source" version="2.8.11"/>
+ <unit id="com.fasterxml.jackson.jaxrs.jackson-jaxrs-base" version="2.8.11"/>
+ <unit id="com.fasterxml.jackson.jaxrs.jackson-jaxrs-base.source" version="2.8.11"/>
+ <unit id="com.fasterxml.jackson.jaxrs.jackson-jaxrs-json-provider" version="2.8.11"/>
+ <unit id="com.fasterxml.jackson.jaxrs.jackson-jaxrs-json-provider.source" version="2.8.11"/>
+ <unit id="com.fasterxml.jackson.module.jackson-module-jaxb-annotations" version="2.8.11"/>
+ <unit id="com.fasterxml.jackson.module.jackson-module-jaxb-annotations.source" version="2.8.11"/>
+ <unit id="com.fasterxml.woodstox.woodstox-core" version="5.0.3"/>
+ <unit id="com.fasterxml.woodstox.woodstox-core.source" version="5.0.3"/>
<unit id="com.healthmarketscience.jackcess" version="2.1.3"/>
<unit id="com.healthmarketscience.jackcess.source" version="2.1.3"/>
+ <unit id="com.influxdb.client-core" version="1.5.0"/>
+ <unit id="com.influxdb.client-core.source" version="1.5.0"/>
<unit id="com.influxdb.client-java" version="1.5.0"/>
<unit id="com.influxdb.client-java.source" version="1.5.0"/>
<unit id="com.koloboke.api-jdk8" version="1.0.0"/>
<unit id="it.unimi.dsi.fastutil" version="8.3.1"/>
<unit id="it.unimi.dsi.fastutil.source" version="8.3.1"/>
<unit id="jakarta-regexp" version="1.4.0"/>
+ <unit id="javassist" version="3.20.0.GA"/>
+ <unit id="javassist.source" version="3.20.0.GA"/>
<unit id="javax.servlet-api" version="3.1.0"/>
<unit id="javax.servlet-api.source" version="3.1.0"/>
- <unit id="jakarta.xml.bind-api" version="2.3.2"/>
- <unit id="jakarta.xml.bind-api.source" version="2.3.2"/>
- <unit id="jakarta.validation.jakarta.validation-api" version="2.0.2"/>
- <unit id="jakarta.validation.jakarta.validation-api.source" version="2.0.2"/>
- <unit id="jakarta.ws.rs-api" version="2.1.6.b0005"/>
- <unit id="jakarta.ws.rs-api.source" version="2.1.6.b0005"/>
+ <unit id="javax.ws.rs-api" version="2.0.1"/>
+ <unit id="javax.ws.rs-api.source" version="2.0.1"/>
+ <unit id="javax.validation.api" version="1.1.0.Final"/>
+ <unit id="javax.validation.api.source" version="1.1.0.Final"/>
+ <unit id="javax.annotation-api" version="1.2.0"/>
+ <unit id="javax.annotation-api.source" version="1.2.0"/>
<unit id="net.jcip.annotations" version="1.0.0"/>
<unit id="net.jcip.annotations.source" version="1.0.0"/>
<unit id="net.ucanaccess" version="3.0.7"/>
<unit id="org.apache.commons.collections4.source" version="4.1.0"/>
<unit id="org.apache.commons.compress" version="1.20.0"/>
<unit id="org.apache.commons.compress.source" version="1.20.0"/>
+ <unit id="org.apache.commons.csv" version="1.6.0"/>
+ <unit id="org.apache.commons.csv.source" version="1.6.0"/>
<unit id="org.apache.commons.io" version="2.4.0"/>
<unit id="org.apache.commons.io.source" version="2.4.0"/>
<unit id="org.apache.commons.lang" version="2.6.0"/>
<unit id="org.eclipse.jetty.servlets.source" version="9.4.24.v20191120"/>
<unit id="com.github.benmanes.caffeine" version="2.8.1"/>
<unit id="com.github.benmanes.caffeine.source" version="2.8.1"/>
- <unit id="org.glassfish.hk2.osgi-resource-locator" version="1.0.3"/>
- <unit id="org.glassfish.hk2.osgi-resource-locator.source" version="1.0.3"/>
- <unit id="org.glassfish.hk2.external.jakarta.inject" version="2.6.1"/>
- <unit id="org.glassfish.hk2.external.jakarta.inject.source" version="2.6.1"/>
- <unit id="org.glassfish.jersey.core.jersey-client" version="2.30.1.b0005"/>
- <unit id="org.glassfish.jersey.core.jersey-client.source" version="2.30.1.b0005"/>
- <unit id="org.glassfish.jersey.core.jersey-common" version="2.30.1.b0005"/>
- <unit id="org.glassfish.jersey.core.jersey-common.source" version="2.30.1.b0005"/>
- <unit id="org.glassfish.jersey.core.jersey-server" version="2.30.1.b0005"/>
- <unit id="org.glassfish.jersey.core.jersey-server.source" version="2.30.1.b0005"/>
- <unit id="org.glassfish.jersey.ext.jersey-entity-filtering" version="2.30.1.b0005"/>
- <unit id="org.glassfish.jersey.ext.jersey-entity-filtering.source" version="2.30.1.b0005"/>
- <unit id="org.glassfish.jersey.media.jersey-media-json-jackson" version="2.30.1.b0005"/>
- <unit id="org.glassfish.jersey.media.jersey-media-json-jackson.source" version="2.30.1.b0005"/>
- <unit id="org.glassfish.jersey.media.jersey-media-multipart" version="2.30.1"/>
- <unit id="org.glassfish.jersey.media.jersey-media-multipart.source" version="2.30.1"/>
- <unit id="org.glassfish.jersey.containers.jersey-container-servlet-core" version="2.30.1.b0005"/>
- <unit id="org.glassfish.jersey.containers.jersey-container-servlet-core.source" version="2.30.1.b0005"/>
+ <unit id="org.glassfish.hk2.api" version="2.5.0.b32"/>
+ <unit id="org.glassfish.hk2.api.source" version="2.5.0.b32"/>
+ <unit id="org.glassfish.hk2.locator" version="2.5.0.b32"/>
+ <unit id="org.glassfish.hk2.locator.source" version="2.5.0.b32"/>
+ <unit id="org.glassfish.hk2.osgi-resource-locator" version="1.0.1"/>
+ <unit id="org.glassfish.hk2.osgi-resource-locator.source" version="1.0.1"/>
+ <unit id="org.glassfish.hk2.utils" version="2.5.0.b32"/>
+ <unit id="org.glassfish.hk2.utils.source" version="2.5.0.b32"/>
+ <unit id="org.glassfish.jersey.bundles.repackaged.jersey-guava" version="2.25.1"/>
+ <unit id="org.glassfish.jersey.bundles.repackaged.jersey-guava.source" version="2.25.1"/>
+ <unit id="org.glassfish.hk2.external.aopalliance-repackaged" version="2.5.0.b32"/>
+ <unit id="org.glassfish.hk2.external.aopalliance-repackaged.source" version="2.5.0.b32"/>
+ <unit id="org.glassfish.jersey.core.jersey-client" version="2.25.1"/>
+ <unit id="org.glassfish.jersey.core.jersey-client.source" version="2.25.1"/>
+ <unit id="org.glassfish.jersey.core.jersey-common" version="2.25.1"/>
+ <unit id="org.glassfish.jersey.core.jersey-common.source" version="2.25.1"/>
+ <unit id="org.glassfish.jersey.core.jersey-server" version="2.25.1"/>
+ <unit id="org.glassfish.jersey.core.jersey-server.source" version="2.25.1"/>
+ <unit id="org.glassfish.jersey.ext.jersey-entity-filtering" version="2.25.1"/>
+ <unit id="org.glassfish.jersey.ext.jersey-entity-filtering.source" version="2.25.1"/>
+ <unit id="org.glassfish.jersey.media.jersey-media-json-jackson" version="2.25.1"/>
+ <unit id="org.glassfish.jersey.media.jersey-media-json-jackson.source" version="2.25.1"/>
+ <unit id="org.glassfish.jersey.media.jersey-media-multipart" version="2.25.1"/>
+ <unit id="org.glassfish.jersey.media.jersey-media-multipart.source" version="2.25.1"/>
+ <unit id="org.glassfish.jersey.containers.jersey-container-servlet-core" version="2.25.1"/>
+ <unit id="org.glassfish.jersey.containers.jersey-container-servlet-core.source" version="2.25.1"/>
<unit id="org.hsqldb.hsqldb" version="2.3.1"/>
<unit id="org.hsqldb.hsqldb.source" version="2.3.1"/>
<unit id="org.ini4j" version="0.5.4"/>
<unit id="org.jfree.jchart.source" version="1.5.0"/>
<unit id="org.jsoup" version="1.12.2"/>
<unit id="org.jsoup.source" version="1.12.2"/>
- <unit id="org.jvnet.mimepull" version="1.9.11"/>
- <unit id="org.jvnet.mimepull.source" version="1.9.11"/>
+ <unit id="org.jvnet.mimepull" version="1.9.6"/>
+ <unit id="org.jvnet.mimepull.source" version="1.9.6"/>
<unit id="org.mozilla.rhino" version="1.7.12"/>
<unit id="org.mozilla.rhino.source" version="1.7.12"/>
<unit id="org.objenesis" version="2.5.1"/>
<unit id="org.zeroturnaround.zt-exec.source" version="1.11.0"/>
<unit id="com.impossibl.pgjdbc-ng" version="0.8.3"/>
<unit id="com.impossibl.pgjdbc-ng.source" version="0.8.3"/>
- <unit id="stax2-api" version="4.2.0"/>
- <unit id="stax2-api.source" version="4.2.0"/>
- <repository location="http://www.simantics.org/download/master/external-components/maven/"/>
+ <unit id="stax2-api" version="3.1.4"/>
+ <unit id="stax2-api.source" version="3.1.4"/>
+ <repository location="http://www.simantics.org/download/release/1.43.0.1/external-components/maven/"/>
</location>
<location includeMode="slicer" includeAllPlatforms="true" includeSource="true" includeConfigurePhase="false" type="InstallableUnit">
<unit id="org.apache.batik.feature.feature.group" version="0.0.0"/>
<unit id="org.apache.poi.feature.feature.group" version="0.0.0"/>
<unit id="io.grpc.feature.feature.group" version="0.0.0"/>
- <repository location="http://www.simantics.org/download/master/external-components/manual"/>
+ <repository location="http://www.simantics.org/download/release/1.43.0.1/external-components/manual"/>
</location>
</locations>
</target>
org.eclipse.collections.feature.source.feature.group
}
-location "http://www.simantics.org/download/master/external-components/maven/" {
+location "http://www.simantics.org/download/release/1.43.0.1/external-components/maven/" {
bouncycastle.bcmail-jdk14
bouncycastle.bcprov-jdk14
ch.qos.logback.classic
com.fasterxml.woodstox.woodstox-core.source
com.healthmarketscience.jackcess
com.healthmarketscience.jackcess.source
+ com.influxdb.client-core
+ com.influxdb.client-core.source
com.influxdb.client-java
com.influxdb.client-java.source
com.koloboke.api-jdk8
it.unimi.dsi.fastutil
it.unimi.dsi.fastutil.source
jakarta-regexp
+ javassist
+ javassist.source
javax.servlet-api
javax.servlet-api.source
- jakarta.xml.bind-api
- jakarta.xml.bind-api.source
- jakarta.validation.jakarta.validation-api
- jakarta.validation.jakarta.validation-api.source
- jakarta.ws.rs-api
- jakarta.ws.rs-api.source
+ javax.ws.rs-api
+ javax.ws.rs-api.source
+ javax.validation.api
+ javax.validation.api.source
+ javax.annotation-api
+ javax.annotation-api.source
net.jcip.annotations
net.jcip.annotations.source
net.ucanaccess
org.apache.commons.collections4.source
org.apache.commons.compress
org.apache.commons.compress.source
+ org.apache.commons.csv
+ org.apache.commons.csv.source
org.apache.commons.io
org.apache.commons.io.source
org.apache.commons.lang
org.eclipse.jetty.servlets.source
com.github.benmanes.caffeine
com.github.benmanes.caffeine.source
- //org.glassfish.hk2.api
- //org.glassfish.hk2.api.source
- //org.glassfish.hk2.locator
- //org.glassfish.hk2.locator.source
+ org.glassfish.hk2.api
+ org.glassfish.hk2.api.source
+ org.glassfish.hk2.locator
+ org.glassfish.hk2.locator.source
org.glassfish.hk2.osgi-resource-locator
org.glassfish.hk2.osgi-resource-locator.source
- //org.glassfish.hk2.utils
- //org.glassfish.hk2.utils.source
- //org.glassfish.jersey.bundles.repackaged.jersey-guava
- //org.glassfish.jersey.bundles.repackaged.jersey-guava.source
- //org.glassfish.hk2.external.aopalliance-repackaged
- //org.glassfish.hk2.external.aopalliance-repackaged.source
- org.glassfish.hk2.external.jakarta.inject
- org.glassfish.hk2.external.jakarta.inject.source
+ org.glassfish.hk2.utils
+ org.glassfish.hk2.utils.source
+ org.glassfish.jersey.bundles.repackaged.jersey-guava
+ org.glassfish.jersey.bundles.repackaged.jersey-guava.source
+ org.glassfish.hk2.external.aopalliance-repackaged
+ org.glassfish.hk2.external.aopalliance-repackaged.source
org.glassfish.jersey.core.jersey-client
org.glassfish.jersey.core.jersey-client.source
org.glassfish.jersey.core.jersey-common
stax2-api.source
}
-location "http://www.simantics.org/download/master/external-components/manual" {
+location "http://www.simantics.org/download/release/1.43.0.1/external-components/manual" {
org.apache.batik.feature.feature.group lazy
org.apache.poi.feature.feature.group lazy
io.grpc.feature.feature.group lazy
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?pde?>
<!-- generated with https://github.com/eclipse-cbi/targetplatform-dsl -->
-<target name="Simantics 1.43.0" sequenceNumber="1582927656">
+<target name="Simantics 1.43.0" sequenceNumber="1603197307">
<locations>
<location includeMode="slicer" includeAllPlatforms="true" includeSource="true" includeConfigurePhase="false" type="InstallableUnit">
<unit id="com.google.guava" version="21.0.0.v20170206-1425"/>
<unit id="com.esotericsoftware.minlog.source" version="1.3.0"/>
<unit id="com.esotericsoftware.reflectasm" version="1.11.3"/>
<unit id="com.esotericsoftware.reflectasm.source" version="1.11.3"/>
- <unit id="com.fasterxml.jackson.core.jackson-annotations" version="2.10.2"/>
- <unit id="com.fasterxml.jackson.core.jackson-annotations.source" version="2.10.2"/>
- <unit id="com.fasterxml.jackson.core.jackson-core" version="2.10.2"/>
- <unit id="com.fasterxml.jackson.core.jackson-core.source" version="2.10.2"/>
- <unit id="com.fasterxml.jackson.core.jackson-databind" version="2.10.2"/>
- <unit id="com.fasterxml.jackson.core.jackson-databind.source" version="2.10.2"/>
- <unit id="com.fasterxml.jackson.dataformat.jackson-dataformat-csv" version="2.10.2"/>
- <unit id="com.fasterxml.jackson.dataformat.jackson-dataformat-csv.source" version="2.10.2"/>
- <unit id="com.fasterxml.jackson.dataformat.jackson-dataformat-xml" version="2.10.2"/>
- <unit id="com.fasterxml.jackson.dataformat.jackson-dataformat-xml.source" version="2.10.2"/>
- <unit id="com.fasterxml.jackson.datatype.jackson-datatype-jsr310" version="2.10.2"/>
- <unit id="com.fasterxml.jackson.datatype.jackson-datatype-jsr310.source" version="2.10.2"/>
- <unit id="com.fasterxml.jackson.jaxrs.jackson-jaxrs-base" version="2.10.2"/>
- <unit id="com.fasterxml.jackson.jaxrs.jackson-jaxrs-base.source" version="2.10.2"/>
- <unit id="com.fasterxml.jackson.jaxrs.jackson-jaxrs-json-provider" version="2.10.2"/>
- <unit id="com.fasterxml.jackson.jaxrs.jackson-jaxrs-json-provider.source" version="2.10.2"/>
- <unit id="com.fasterxml.jackson.module.jackson-module-jaxb-annotations" version="2.10.2"/>
- <unit id="com.fasterxml.jackson.module.jackson-module-jaxb-annotations.source" version="2.10.2"/>
- <unit id="com.fasterxml.woodstox.woodstox-core" version="6.0.3"/>
- <unit id="com.fasterxml.woodstox.woodstox-core.source" version="6.0.3"/>
+ <unit id="com.fasterxml.jackson.core.jackson-annotations" version="2.8.11"/>
+ <unit id="com.fasterxml.jackson.core.jackson-annotations.source" version="2.8.11"/>
+ <unit id="com.fasterxml.jackson.core.jackson-core" version="2.8.11"/>
+ <unit id="com.fasterxml.jackson.core.jackson-core.source" version="2.8.11"/>
+ <unit id="com.fasterxml.jackson.core.jackson-databind" version="2.8.11"/>
+ <unit id="com.fasterxml.jackson.core.jackson-databind.source" version="2.8.11"/>
+ <unit id="com.fasterxml.jackson.dataformat.jackson-dataformat-csv" version="2.8.11"/>
+ <unit id="com.fasterxml.jackson.dataformat.jackson-dataformat-csv.source" version="2.8.11"/>
+ <unit id="com.fasterxml.jackson.dataformat.jackson-dataformat-xml" version="2.8.11"/>
+ <unit id="com.fasterxml.jackson.dataformat.jackson-dataformat-xml.source" version="2.8.11"/>
+ <unit id="com.fasterxml.jackson.datatype.jackson-datatype-jsr310" version="2.8.11"/>
+ <unit id="com.fasterxml.jackson.datatype.jackson-datatype-jsr310.source" version="2.8.11"/>
+ <unit id="com.fasterxml.jackson.jaxrs.jackson-jaxrs-base" version="2.8.11"/>
+ <unit id="com.fasterxml.jackson.jaxrs.jackson-jaxrs-base.source" version="2.8.11"/>
+ <unit id="com.fasterxml.jackson.jaxrs.jackson-jaxrs-json-provider" version="2.8.11"/>
+ <unit id="com.fasterxml.jackson.jaxrs.jackson-jaxrs-json-provider.source" version="2.8.11"/>
+ <unit id="com.fasterxml.jackson.module.jackson-module-jaxb-annotations" version="2.8.11"/>
+ <unit id="com.fasterxml.jackson.module.jackson-module-jaxb-annotations.source" version="2.8.11"/>
+ <unit id="com.fasterxml.woodstox.woodstox-core" version="5.0.3"/>
+ <unit id="com.fasterxml.woodstox.woodstox-core.source" version="5.0.3"/>
<unit id="com.healthmarketscience.jackcess" version="2.1.3"/>
<unit id="com.healthmarketscience.jackcess.source" version="2.1.3"/>
+ <unit id="com.influxdb.client-core" version="1.5.0"/>
+ <unit id="com.influxdb.client-core.source" version="1.5.0"/>
<unit id="com.influxdb.client-java" version="1.5.0"/>
<unit id="com.influxdb.client-java.source" version="1.5.0"/>
<unit id="com.koloboke.api-jdk8" version="1.0.0"/>
<unit id="it.unimi.dsi.fastutil" version="8.3.1"/>
<unit id="it.unimi.dsi.fastutil.source" version="8.3.1"/>
<unit id="jakarta-regexp" version="1.4.0"/>
+ <unit id="javassist" version="3.20.0.GA"/>
+ <unit id="javassist.source" version="3.20.0.GA"/>
<unit id="javax.servlet-api" version="3.1.0"/>
<unit id="javax.servlet-api.source" version="3.1.0"/>
- <unit id="jakarta.xml.bind-api" version="2.3.2"/>
- <unit id="jakarta.xml.bind-api.source" version="2.3.2"/>
- <unit id="jakarta.validation.jakarta.validation-api" version="2.0.2"/>
- <unit id="jakarta.validation.jakarta.validation-api.source" version="2.0.2"/>
- <unit id="jakarta.ws.rs-api" version="2.1.6.b0005"/>
- <unit id="jakarta.ws.rs-api.source" version="2.1.6.b0005"/>
+ <unit id="javax.ws.rs-api" version="2.0.1"/>
+ <unit id="javax.ws.rs-api.source" version="2.0.1"/>
+ <unit id="javax.validation.api" version="1.1.0.Final"/>
+ <unit id="javax.validation.api.source" version="1.1.0.Final"/>
+ <unit id="javax.annotation-api" version="1.2.0"/>
+ <unit id="javax.annotation-api.source" version="1.2.0"/>
<unit id="net.jcip.annotations" version="1.0.0"/>
<unit id="net.jcip.annotations.source" version="1.0.0"/>
<unit id="net.ucanaccess" version="3.0.7"/>
<unit id="org.apache.commons.collections4.source" version="4.1.0"/>
<unit id="org.apache.commons.compress" version="1.20.0"/>
<unit id="org.apache.commons.compress.source" version="1.20.0"/>
+ <unit id="org.apache.commons.csv" version="1.6.0"/>
+ <unit id="org.apache.commons.csv.source" version="1.6.0"/>
<unit id="org.apache.commons.io" version="2.4.0"/>
<unit id="org.apache.commons.io.source" version="2.4.0"/>
<unit id="org.apache.commons.lang" version="2.6.0"/>
<unit id="org.eclipse.jetty.servlets.source" version="9.4.24.v20191120"/>
<unit id="com.github.benmanes.caffeine" version="2.8.1"/>
<unit id="com.github.benmanes.caffeine.source" version="2.8.1"/>
- <unit id="org.glassfish.hk2.osgi-resource-locator" version="1.0.3"/>
- <unit id="org.glassfish.hk2.osgi-resource-locator.source" version="1.0.3"/>
- <unit id="org.glassfish.hk2.external.jakarta.inject" version="2.6.1"/>
- <unit id="org.glassfish.hk2.external.jakarta.inject.source" version="2.6.1"/>
- <unit id="org.glassfish.jersey.core.jersey-client" version="2.30.1.b0005"/>
- <unit id="org.glassfish.jersey.core.jersey-client.source" version="2.30.1.b0005"/>
- <unit id="org.glassfish.jersey.core.jersey-common" version="2.30.1.b0005"/>
- <unit id="org.glassfish.jersey.core.jersey-common.source" version="2.30.1.b0005"/>
- <unit id="org.glassfish.jersey.core.jersey-server" version="2.30.1.b0005"/>
- <unit id="org.glassfish.jersey.core.jersey-server.source" version="2.30.1.b0005"/>
- <unit id="org.glassfish.jersey.ext.jersey-entity-filtering" version="2.30.1.b0005"/>
- <unit id="org.glassfish.jersey.ext.jersey-entity-filtering.source" version="2.30.1.b0005"/>
- <unit id="org.glassfish.jersey.media.jersey-media-json-jackson" version="2.30.1.b0005"/>
- <unit id="org.glassfish.jersey.media.jersey-media-json-jackson.source" version="2.30.1.b0005"/>
- <unit id="org.glassfish.jersey.media.jersey-media-multipart" version="2.30.1"/>
- <unit id="org.glassfish.jersey.media.jersey-media-multipart.source" version="2.30.1"/>
- <unit id="org.glassfish.jersey.containers.jersey-container-servlet-core" version="2.30.1.b0005"/>
- <unit id="org.glassfish.jersey.containers.jersey-container-servlet-core.source" version="2.30.1.b0005"/>
+ <unit id="org.glassfish.hk2.api" version="2.5.0.b32"/>
+ <unit id="org.glassfish.hk2.api.source" version="2.5.0.b32"/>
+ <unit id="org.glassfish.hk2.locator" version="2.5.0.b32"/>
+ <unit id="org.glassfish.hk2.locator.source" version="2.5.0.b32"/>
+ <unit id="org.glassfish.hk2.osgi-resource-locator" version="1.0.1"/>
+ <unit id="org.glassfish.hk2.osgi-resource-locator.source" version="1.0.1"/>
+ <unit id="org.glassfish.hk2.utils" version="2.5.0.b32"/>
+ <unit id="org.glassfish.hk2.utils.source" version="2.5.0.b32"/>
+ <unit id="org.glassfish.jersey.bundles.repackaged.jersey-guava" version="2.25.1"/>
+ <unit id="org.glassfish.jersey.bundles.repackaged.jersey-guava.source" version="2.25.1"/>
+ <unit id="org.glassfish.hk2.external.aopalliance-repackaged" version="2.5.0.b32"/>
+ <unit id="org.glassfish.hk2.external.aopalliance-repackaged.source" version="2.5.0.b32"/>
+ <unit id="org.glassfish.jersey.core.jersey-client" version="2.25.1"/>
+ <unit id="org.glassfish.jersey.core.jersey-client.source" version="2.25.1"/>
+ <unit id="org.glassfish.jersey.core.jersey-common" version="2.25.1"/>
+ <unit id="org.glassfish.jersey.core.jersey-common.source" version="2.25.1"/>
+ <unit id="org.glassfish.jersey.core.jersey-server" version="2.25.1"/>
+ <unit id="org.glassfish.jersey.core.jersey-server.source" version="2.25.1"/>
+ <unit id="org.glassfish.jersey.ext.jersey-entity-filtering" version="2.25.1"/>
+ <unit id="org.glassfish.jersey.ext.jersey-entity-filtering.source" version="2.25.1"/>
+ <unit id="org.glassfish.jersey.media.jersey-media-json-jackson" version="2.25.1"/>
+ <unit id="org.glassfish.jersey.media.jersey-media-json-jackson.source" version="2.25.1"/>
+ <unit id="org.glassfish.jersey.media.jersey-media-multipart" version="2.25.1"/>
+ <unit id="org.glassfish.jersey.media.jersey-media-multipart.source" version="2.25.1"/>
+ <unit id="org.glassfish.jersey.containers.jersey-container-servlet-core" version="2.25.1"/>
+ <unit id="org.glassfish.jersey.containers.jersey-container-servlet-core.source" version="2.25.1"/>
<unit id="org.hsqldb.hsqldb" version="2.3.1"/>
<unit id="org.hsqldb.hsqldb.source" version="2.3.1"/>
<unit id="org.ini4j" version="0.5.4"/>
<unit id="org.jfree.jchart.source" version="1.5.0"/>
<unit id="org.jsoup" version="1.12.2"/>
<unit id="org.jsoup.source" version="1.12.2"/>
- <unit id="org.jvnet.mimepull" version="1.9.11"/>
- <unit id="org.jvnet.mimepull.source" version="1.9.11"/>
+ <unit id="org.jvnet.mimepull" version="1.9.6"/>
+ <unit id="org.jvnet.mimepull.source" version="1.9.6"/>
<unit id="org.mozilla.rhino" version="1.7.12"/>
<unit id="org.mozilla.rhino.source" version="1.7.12"/>
<unit id="org.objenesis" version="2.5.1"/>
<unit id="org.zeroturnaround.zt-exec.source" version="1.11.0"/>
<unit id="com.impossibl.pgjdbc-ng" version="0.8.3"/>
<unit id="com.impossibl.pgjdbc-ng.source" version="0.8.3"/>
- <unit id="stax2-api" version="4.2.0"/>
- <unit id="stax2-api.source" version="4.2.0"/>
- <repository location="http://www.simantics.org/download/master/external-components/maven/"/>
+ <unit id="stax2-api" version="3.1.4"/>
+ <unit id="stax2-api.source" version="3.1.4"/>
+ <repository location="http://www.simantics.org/download/release/1.43.0.1/external-components/maven/"/>
</location>
<location includeMode="slicer" includeAllPlatforms="true" includeSource="true" includeConfigurePhase="false" type="InstallableUnit">
<unit id="org.apache.batik.feature.feature.group" version="0.0.0"/>
<unit id="org.apache.poi.feature.feature.group" version="0.0.0"/>
<unit id="io.grpc.feature.feature.group" version="0.0.0"/>
- <repository location="http://www.simantics.org/download/master/external-components/manual"/>
+ <repository location="http://www.simantics.org/download/release/1.43.0.1/external-components/manual"/>
</location>
<location includeMode="slicer" includeAllPlatforms="true" includeSource="true" includeConfigurePhase="false" type="InstallableUnit">
<unit id="org.simantics.sdk.feature.group" version="0.0.0"/>
<unit id="org.simantics.sdk.source.feature.group" version="0.0.0"/>
- <repository location="http://www.simantics.org/download/master/sdk"/>
+ <repository location="http://www.simantics.org/download/release/1.43.0.1/sdk"/>
</location>
</locations>
</target>
with source allEnvironments
-include "http://www.simantics.org/download/master/org.simantics.sdk.build.targetdefinition.tpd"
+include "./org.simantics.sdk.build.targetdefinition.tpd"
-location "http://www.simantics.org/download/master/sdk" {
+location "http://www.simantics.org/download/release/1.43.0.1/sdk" {
org.simantics.sdk.feature.group lazy
org.simantics.sdk.source.feature.group lazy
}