// 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;
Bundle-RequiredExecutionEnvironment: JavaSE-11
Require-Bundle: org.simantics.db;bundle-version="1.1.0";visibility:=reexport,
gnu.trove3;bundle-version="3.0.3",
- org.apache.log4j;bundle-version="1.2.15",
org.simantics.layer0;bundle-version="1.0.0";visibility:=reexport,
org.simantics.graph;bundle-version="1.1.4",
org.simantics.scl.reflection;bundle-version="1.0.0";visibility:=reexport,
+++ /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.db.common.utils;
-
-import java.util.Properties;
-
-import org.apache.log4j.Logger;
-
-/*
- *
- * @deprecated in favor of org.simantics.db.common.Logger. Will be removed in Simantics 1.2
- *
- */
-@Deprecated
-public class ErrorLogger {
- public static final boolean ECHO = false;
- public static final Properties defaultProperties = new Properties();
- static {
- defaultProperties.put("log4j.rootCategory", "ERROR, default");
- defaultProperties.put("log4j.appender.default", "org.apache.log4j.FileAppender");
- defaultProperties.put("log4j.appender.default.File", "db-client-deprecated.log");
- defaultProperties.put("log4j.appender.default.append", "false");
- defaultProperties.put("log4j.appender.default.layout", "org.apache.log4j.PatternLayout");
- defaultProperties.put("log4j.appender.default.layout.ConversionPattern", "%-6r [%15.15t] %-5p %30.30c - %m%n");
- }
- private static LogManager defaultLogManager = new LogManager(defaultProperties);
- private static final ErrorLogger defaultErrorLogger = new ErrorLogger(LogManager.class);
- private Logger logger;
- ErrorLogger(Class<?> clazz) {
- logger = defaultLogManager.getLogger(clazz);
- }
-
- /**
- * Log a trace event.
- *
- * @param message message of the trace
- * @param exception the exception, or <code>null</code>
- */
- public void logTrace(String message, Throwable exception) {
- // Errors are much more useful with a stack trace!
- if (exception == null) {
- exception = new RuntimeException();
- }
- logger.trace(message, exception);
- }
-
- /**
- * Log an info event.
- *
- * @param message message of the info
- * @param exception the exception, or <code>null</code>
- */
- public void logInfo(String message, Throwable exception) {
- // Errors are much more useful with a stack trace!
- if (exception == null) {
- exception = new RuntimeException();
- }
- logger.info(message, exception);
- }
-
- /**
- * Log an error event.
- *
- * @param message message of the error
- * @param exception the exception, or <code>null</code>
- */
- public void logError(String message, Throwable exception) {
- // Errors are much more useful with a stack trace!
- if (exception == null) {
- exception = new RuntimeException();
- }
- logger.error(message, exception);
- }
-
- public static ErrorLogger getDefault() {
- return defaultErrorLogger;
- }
-
- public static LogManager getDefaultLogManager() {
- return defaultLogManager;
- }
- public static void defaultLogError(Throwable exception) {
- getDefault().logError(exception.getLocalizedMessage(), exception);
- if(ECHO) exception.printStackTrace();
- }
- public static void defaultLogError(String message) {
- getDefault().logError(message, null);
- if(ECHO)
- System.err.println(message);
- }
- public static void defaultLogError(String message, Throwable exception) {
- getDefault().logError(message, exception);
- if(ECHO)
- System.err.println(message);
- }
- public static void defaultLogInfo(String message) {
- getDefault().logInfo(message, null);
- if(ECHO)
- System.err.println(message);
- }
- public static void defaultLogTrace(String message) {
- getDefault().logTrace(message, null);
- if(ECHO)
- System.err.println(message);
- }
-}
+++ /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.db.common.utils;
-
-import java.util.Properties;
-
-import org.apache.log4j.Hierarchy;
-import org.apache.log4j.Level;
-import org.apache.log4j.Logger;
-import org.apache.log4j.PropertyConfigurator;
-import org.apache.log4j.spi.LoggerFactory;
-import org.apache.log4j.spi.RootLogger;
-
-/**
- * This class encapsulates a Log4J Hierarchy and centralizes all Logger access.
- */
-public class LogManager {
-
- private Hierarchy hierarchy;
-
- /**
- * Creates a new LogManager. Saves the log and state location.
- * Creates a new Hierarchy and add a new EventListener to it.
- * Configure the hierarchy with the properties passed. Add this object to
- * the list of active log managers.
- *
- * @param properties log configuration properties
- */
- public LogManager(Properties properties) {
- this.hierarchy = new Hierarchy(new RootLogger(Level.DEBUG));
- new PropertyConfigurator().doConfigure(properties, this.hierarchy);
- }
-
- /**
- * Checks if this PluginLogManager is disabled for this level.
- *
- * @param level level value
- * @return boolean true if it is disabled
- */
- public boolean isDisabled(int level) {
- return this.hierarchy.isDisabled(level);
- }
-
- /**
- * Enable logging for logging requests with level l or higher. By default
- * all levels are enabled.
- *
- * @param level level object
- */
- public void setThreshold(Level level) {
- this.hierarchy.setThreshold(level);
- }
-
- /**
- * The string version of setThreshold(Level level)
- *
- * @param level level string
- */
- public void setThreshold(String level) {
- this.hierarchy.setThreshold(level);
- }
-
- /**
- * Get the repository-wide threshold.
- *
- * @return Level
- */
- public Level getThreshold() {
- return this.hierarchy.getThreshold();
- }
-
- /**
- * Returns a new logger instance named as the first parameter using the
- * default factory. If a logger of that name already exists, then it will be
- * returned. Otherwise, a new logger will be instantiated and then linked
- * with its existing ancestors as well as children.
- *
- * @param clazz the class to get the logger for
- * @return Logger
- */
- public Logger getLogger(Class<?> clazz) {
- return this.hierarchy.getLogger(clazz.getName());
- }
-
- /**
- * Returns a new logger instance named as the first parameter using the
- * default factory. If a logger of that name already exists, then it will be
- * returned. Otherwise, a new logger will be instantiated and then linked
- * with its existing ancestors as well as children.
- *
- * @param name logger name
- * @return Logger
- */
- public Logger getLogger(String name) {
- return this.hierarchy.getLogger(name);
- }
-
- /**
- * The same as getLogger(String name) but using a factory instance instead
- * of a default factory.
- *
- * @param name logger name
- * @param factory factory instance
- * @return Logger
- */
- public Logger getLogger(String name, LoggerFactory factory) {
- return this.hierarchy.getLogger(name, factory);
- }
-
- /**
- * Returns the root of this hierarchy.
- *
- * @return Logger
- */
- public Logger getRootLogger() {
- return this.hierarchy.getRootLogger();
- }
-
- /**
- * Checks if this logger exists.
- *
- * @return Logger
- */
- public Logger exists(String name) {
- return this.hierarchy.exists(name);
- }
-
- /**
- * Disposes the logger hierarchy
- */
- public void shutdown() {
- this.hierarchy.shutdown();
- }
-
- /**
- * Resets configuration values to its defaults.
- */
- public void resetConfiguration() {
- this.hierarchy.resetConfiguration();
- }
-
-}
\ No newline at end of file
+++ /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.db.impl.graph;
-
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.Set;
-
-import org.simantics.db.Resource;
-import org.simantics.db.impl.query.IntSet;
-import org.simantics.db.impl.query.QuerySupport;
-
-public class ArraySet implements Set<Resource> {
-
- final Resource[] set;
-
- ArraySet(IntSet intSet, QuerySupport support) {
-
- if(intSet.data == null) {
- if(intSet.sizeOrData != IntSet.NO_DATA) {
- set = new Resource[] { support.getResource(intSet.sizeOrData) };
- } else {
- set = Resource.NONE;
- }
- } else {
- set = new Resource[intSet.sizeOrData];
- for(int i=0;i<intSet.sizeOrData;i++) set[i] = support.getResource(intSet.data[i]);
- }
-
- }
-
- @Override
- public boolean add(Resource e) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public boolean addAll(Collection<? extends Resource> c) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void clear() {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public boolean contains(Object o) {
- for(int i=0;i<set.length;i++) if(o.equals(set[i])) return true;
- return false;
- }
-
- @Override
- public boolean containsAll(Collection<?> c) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public boolean isEmpty() {
- return set.length == 0;
- }
-
- @Override
- public Iterator<Resource> iterator() {
-
- class ArraySetIterator implements Iterator<Resource> {
-
- int next = 0;
-
- @Override
- public boolean hasNext() {
- return next < set.length;
- }
-
- @Override
- public Resource next() {
- return set[next++];
- }
-
- @Override
- public void remove() {
- throw new UnsupportedOperationException();
- }
-
- }
-
- return new ArraySetIterator();
-
- }
-
- @Override
- public boolean remove(Object o) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public boolean removeAll(Collection<?> c) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public boolean retainAll(Collection<?> c) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public int size() {
- return set.length;
- }
-
- @Override
- public Object[] toArray() {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public <T> T[] toArray(T[] a) {
- throw new UnsupportedOperationException();
- }
-
-}
});
}
-
+
+ @Override
+ public void serializeValue(QuerySerializer serializer) {
+ IntArray is = getResult();
+ is.serialize(serializer);
+ }
+
}
--- /dev/null
+package org.simantics.db.impl.query;
+
+import org.simantics.db.exception.DatabaseException;
+
+public class AssertedPredicatesFactory extends QueryFactoryBase {
+
+ @Override
+ public CacheEntryBase readKeyAndValue(QueryDeserializer deserializer) throws DatabaseException {
+ AssertedPredicates result = reference(deserializer);
+ IntArray ia = IntArray.deserialize(deserializer);
+ result.setResult(ia);
+ result.setReady();
+ return result;
+ }
+
+ @Override
+ public <T extends CacheEntryBase> T reference(QueryDeserializer deserializer) throws DatabaseException {
+ return (T)deserializer.readAssertedPredicates();
+ }
+
+}
--- /dev/null
+package org.simantics.db.impl.query;
+
+import org.simantics.db.exception.DatabaseException;
+
+public class AssertedStatementsFactory extends QueryFactoryBase {
+
+ @Override
+ public CacheEntryBase readKeyAndValue(QueryDeserializer deserializer) throws DatabaseException {
+ AssertedStatements result = reference(deserializer);
+ IntArray ia = IntArray.deserialize(deserializer);
+ result.setResult(ia);
+ result.setReady();
+ return result;
+ }
+
+ @Override
+ public <T extends CacheEntryBase> T reference(QueryDeserializer deserializer) throws DatabaseException {
+ return (T)deserializer.readAssertedStatements();
+ }
+
+}
return graph.processor.cache.performQuery(graph, id, this, procedure);
}
+ @Override
+ public String classId() {
+ return null;
+ }
+
}
}
}
+ @Override
+ public String classId() {
+ return null;
+ }
+
}
abstract public void removeEntry(QueryProcessor provider);
+ @Override
+ public long cluster(QueryProcessor processor) {
+ return processor.cluster(r1());
+ }
+
+ @Override
+ public void serializeKey(QuerySerializer serializer) {
+ serializer.addResource(r1());
+ serializer.addResource(r2());
+ }
+
}
*******************************************************************************/
package org.simantics.db.impl.query;
+import java.util.Collection;
+
import org.simantics.db.exception.DatabaseException;
import org.simantics.db.impl.graph.ReadGraphImpl;
abstract Query getQuery();
abstract CacheEntry pruneFirstParents();
+ abstract void pruneParentSet();
abstract void removeParent(CacheEntry entry);
abstract void addParent(CacheEntry entry);
abstract boolean hasParents();
- abstract Iterable<CacheEntry<?>> getParents(QueryProcessor processor);
+ abstract Collection<CacheEntry<?>> getParents(QueryProcessor processor);
abstract CacheEntry getFirstParent(QueryProcessor processor);
abstract boolean moreThanOneParent(QueryProcessor processor);
abstract int parentCount(QueryProcessor processor);
package org.simantics.db.impl.query;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.Iterator;
import org.simantics.databoard.Bindings;
}
}
-
+
+ @Override
+ void pruneParentSet() {
+ // First parent is discarded => look for more parents
+ if(p2OrParents instanceof QueryIdentityHashSet) {
+
+ QueryIdentityHashSet set = (QueryIdentityHashSet)p2OrParents;
+ set.removeDiscardedReally();
+ if(set.isEmpty()) p2OrParents = null;
+
+ } else if(p2OrParents instanceof CacheEntry) {
+
+ CacheEntry entry = (CacheEntry)p2OrParents;
+ if(entry.isDiscarded()) {
+ // Second entry is also discarded => all empty
+ p2OrParents = null;
+ }
+
+ } else {
+
+ // Nothing left
+
+ }
+ }
+
@Override
final public void removeParent(CacheEntry entry) {
}
@Override
- final public Iterable<CacheEntry<?>> getParents(QueryProcessor processor) {
+ final public Collection<CacheEntry<?>> getParents(QueryProcessor processor) {
ArrayList<CacheEntry<?>> result = new ArrayList<CacheEntry<?>>();
if(p1 != null) result.add(p1);
public CacheEntryBase() {
}
+
+ public String classId() {
+ return getClass().getName();
+ }
+
+ public void serializeKey(QuerySerializer serializer) {
+ throw new IllegalStateException("Cannot serialize query key for " + this);
+ }
+
+ public void serializeValue(QuerySerializer serializer) {
+ throw new IllegalStateException("Cannot serialize query value for " + this);
+ }
+
+ public void serializeParents(QuerySerializer serializer) {
+ Collection<CacheEntry<?>> ps = getParents(serializer.getQueryProcessor());
+ int sizePos = serializer.writeUnknownSize();
+ int actual = 0;
+ for(CacheEntry<?> entry : ps) {
+ CacheEntryBase b = (CacheEntryBase)entry;
+ String cid = b.classId();
+ if(cid == null)
+ continue;
+ serializer.serializeId(b.classId());
+ b.serializeKey(serializer);
+ actual++;
+ }
+ serializer.setUnknownSize(sizePos, actual);
+ }
+
+ public long cluster(QueryProcessor processor) {
+ throw new IllegalStateException("Cannot compute query cluster for " + this);
+ }
+
+ public void serialize(QuerySerializer serializer) {
+ serializer.serializeId(classId());
+ serializeKey(serializer);
+ serializeValue(serializer);
+ serializeParents(serializer);
+ }
}
}
+ @Override
+ public void serializeValue(QuerySerializer serializer) {
+ ObjectResourceIdMap<String> is = getResult();
+ serializer.writeLE(is.size());
+ for(String s : is.keySet()) {
+ serializer.addString(s);
+ serializer.addResource(is.getId(s));
+ }
+ }
+
@Override
public String toString() {
return "ChildMap[" + id + "]";
--- /dev/null
+package org.simantics.db.impl.query;
+
+import org.simantics.db.ObjectResourceIdMap;
+import org.simantics.db.exception.DatabaseException;
+
+public class ChildMapFactory extends QueryFactoryBase {
+
+ @Override
+ public CacheEntryBase readKeyAndValue(QueryDeserializer deserializer) throws DatabaseException {
+ ChildMap result = reference(deserializer);
+ ObjectResourceIdMap<String> map = deserializer.createChildMap();
+ int size = deserializer.readLE4();
+ for(int i=0;i<size;i++) {
+ String key = deserializer.readString();
+ int r2 = deserializer.readResource();
+ map.putId(key, r2);
+ }
+ result.setResult(map);
+ result.setReady();
+ return result;
+ }
+
+ @Override
+ public <T extends CacheEntryBase> T reference(QueryDeserializer deserializer) throws DatabaseException {
+ return (T)deserializer.readChildMap();
+ }
+
+}
*******************************************************************************/
package org.simantics.db.impl.query;
-
-
-
abstract public class CollectionBinaryQuery<T> extends BinaryQuery<T> {
public CollectionBinaryQuery(final int r1, final int r2) {
if(size == 0) setResult(IntArray.EMPTY);
else v.trim();
}
-
+
+ @Override
+ public void serializeValue(QuerySerializer serializer) {
+ IntArray is = getResult();
+ is.serialize(serializer);
+ }
+
}
except(throwable);
}
+ @Override
+ public void serializeValue(QuerySerializer serializer) {
+ IntArray is = getResult();
+ is.serialize(serializer);
+ }
+
}
--- /dev/null
+package org.simantics.db.impl.query;
+
+import org.simantics.db.exception.DatabaseException;
+
+public class DirectObjectsFactory extends QueryFactoryBase {
+
+ @Override
+ public CacheEntryBase readKeyAndValue(QueryDeserializer deserializer) throws DatabaseException {
+ DirectObjects result = reference(deserializer);
+ IntArray ia = IntArray.deserialize(deserializer);
+ result.setResult(ia);
+ result.setReady();
+ return result;
+ }
+
+ @Override
+ public <T extends CacheEntryBase> T reference(QueryDeserializer deserializer) throws DatabaseException {
+ return (T)deserializer.readDirectObjects();
+ }
+
+}
import org.simantics.db.impl.graph.ReadGraphImpl;
import org.simantics.db.impl.procedure.InternalProcedure;
-public final class DirectPredicates extends UnaryQueryP<IntSet> {
+public final class DirectPredicates extends UnaryQueryPIntSet {
DirectPredicates(final int resource) {
super(resource);
--- /dev/null
+package org.simantics.db.impl.query;
+
+import org.simantics.db.exception.DatabaseException;
+
+public class DirectPredicatesFactory extends QueryFactoryBase {
+
+ @Override
+ public CacheEntryBase readKeyAndValue(QueryDeserializer deserializer) throws DatabaseException {
+ DirectPredicates result = reference(deserializer);
+ IntSet is = IntSet.deserialize(deserializer);
+ result.setResult(is);
+ result.setReady();
+ return result;
+ }
+
+ @Override
+ public <T extends CacheEntryBase> T reference(QueryDeserializer deserializer) throws DatabaseException {
+ return (T)deserializer.readDirectPredicates();
+ }
+
+}
final LinkedList<T> items = new LinkedList<T>();
protected ExternalRead<T> id;
- protected ReadGraphImpl graph;
+ protected QueryProcessor processor;
protected boolean registered = false;
@Override
public void discard() {
id.unregistered();
id = null;
- graph = null;
+ processor = null;
super.discard();
}
public ExternalReadEntry(ExternalRead<T> request, ReadGraphImpl graph) {
assert request != null;
this.id = request;
- this.graph = graph;
+ this.processor = graph.processor;
}
@Override
synchronized(items) {
items.addLast(result);
- graph.processor.updatePrimitive(id);
+ processor.updatePrimitive(id);
// TODO: implement flags/logic in ExternalRead to state that all but the latest request result can be evaporated
// In some cases where data is produced really fast this might be necessary but currently this queueing will do.
}
@Override
public boolean isDisposed() {
- return registered && (isDiscarded() || !graph.processor.isBound(this));
+ return registered && (isDiscarded() || !processor.isBound(this));
}
-
+
+ @Override
+ public String classId() {
+ return null;
+ }
+
}
import java.util.Arrays;
+import org.simantics.db.exception.DatabaseException;
+
final public class IntArray {
}
return result;
}
-
+
+ public void serialize(QuerySerializer serializer) {
+ int size = size();
+ serializer.writeLE(size);
+ if(size == 1) {
+ serializer.addResource(sizeOrData);
+ } else {
+ for(int i=0;i<size;i++)
+ serializer.addResource(data[i]);
+ }
+ }
+
+ public static IntArray deserialize(QueryDeserializer deserializer) throws DatabaseException {
+ int size = deserializer.readLE4();
+ IntArray result = new IntArray();
+ for(int i=0;i<size;i++) {
+ result.add(deserializer.readResource());
+ }
+ return result;
+ }
+
@Override
public boolean equals(Object object) {
if (this == object)
public int[] data;
- /** the index after the last entry in the list */
- public int sizeOrData;
+ private int sizeOrData;
/** the default capacity for new lists */
protected static final int DEFAULT_CAPACITY = 3;
private IntSet() {
support = null;
+ data = null;
+ sizeOrData = NO_DATA;
}
public IntSet(QuerySupport support) {
}
procedure.finished(graph);
}
+
+ public void serialize(QuerySerializer serializer) {
+ serializer.writeLE(size());
+ forEach(new TIntProcedure() {
+
+ @Override
+ public boolean execute(int value) {
+ serializer.addResource(value);
+ return true;
+ }
+ });
+ }
+
+ public static IntSet deserialize(QueryDeserializer deserializer) throws DatabaseException {
+ int size = deserializer.readLE4();
+ IntSet result = new IntSet();
+ for(int i=0;i<size;i++) {
+ result.add(deserializer.readResource());
+ }
+ return result;
+ }
}
\ No newline at end of file
except(throwable);
}
+ @Override
+ public void serializeValue(QuerySerializer serializer) {
+ IntArray is = getResult();
+ is.serialize(serializer);
+ }
+
}
--- /dev/null
+package org.simantics.db.impl.query;
+
+import org.simantics.db.exception.DatabaseException;
+
+public class ObjectsFactory extends QueryFactoryBase {
+
+ @Override
+ public CacheEntryBase readKeyAndValue(QueryDeserializer deserializer) throws DatabaseException {
+ Objects result = reference(deserializer);
+ IntArray ia = IntArray.deserialize(deserializer);
+ result.setResult(ia);
+ result.setReady();
+ return result;
+ }
+
+ @Override
+ public <T extends CacheEntryBase> T reference(QueryDeserializer deserializer) throws DatabaseException {
+ return (T)deserializer.readObjects();
+ }
+
+}
--- /dev/null
+package org.simantics.db.impl.query;
+
+import org.simantics.db.exception.DatabaseException;
+
+public class OrderedSetFactory extends QueryFactoryBase {
+
+ @Override
+ public CacheEntryBase readKeyAndValue(QueryDeserializer deserializer) throws DatabaseException {
+ OrderedSet result = reference(deserializer);
+ IntArray ia = IntArray.deserialize(deserializer);
+ result.setResult(ia);
+ result.setReady();
+ return result;
+ }
+
+ @Override
+ public <T extends CacheEntryBase> T reference(QueryDeserializer deserializer) throws DatabaseException {
+ return (T)deserializer.readOrderedSet();
+ }
+
+}
import gnu.trove.procedure.TIntProcedure;
-final public class Predicates extends UnaryQueryP<IntSet> {
+final public class Predicates extends UnaryQueryPIntSet {
Predicates(final int r) {
super(r);
--- /dev/null
+package org.simantics.db.impl.query;
+
+import org.simantics.db.exception.DatabaseException;
+
+public class PredicatesFactory extends QueryFactoryBase {
+
+ @Override
+ public CacheEntryBase readKeyAndValue(QueryDeserializer deserializer) throws DatabaseException {
+ Predicates result = reference(deserializer);
+ IntSet ia = IntSet.deserialize(deserializer);
+ result.setResult(ia);
+ result.setReady();
+ return result;
+ }
+
+ @Override
+ public <T extends CacheEntryBase> T reference(QueryDeserializer deserializer) throws DatabaseException {
+ return (T)deserializer.readPredicates();
+ }
+
+}
--- /dev/null
+package org.simantics.db.impl.query;
+
+import org.simantics.db.exception.DatabaseException;
+
+public class PrincipalTypesFactory extends QueryFactoryBase {
+
+ @Override
+ public CacheEntryBase readKeyAndValue(QueryDeserializer deserializer) throws DatabaseException {
+ PrincipalTypes result = reference(deserializer);
+ IntArray ia = IntArray.deserialize(deserializer);
+ result.setResult(ia);
+ result.setReady();
+ return result;
+ }
+
+ @Override
+ public <T extends CacheEntryBase> T reference(QueryDeserializer deserializer) throws DatabaseException {
+ return (T)deserializer.readPrincipalTypes();
+ }
+
+}
import java.util.Collection;
import java.util.concurrent.Semaphore;
-import org.simantics.databoard.Bindings;
import org.simantics.db.AsyncReadGraph;
-import org.simantics.db.DevelopmentKeys;
import org.simantics.db.ObjectResourceIdMap;
import org.simantics.db.ReadGraph;
import org.simantics.db.RelationInfo;
-import org.simantics.db.common.utils.Logger;
import org.simantics.db.exception.DatabaseException;
import org.simantics.db.impl.graph.ReadGraphImpl;
import org.simantics.db.impl.procedure.InternalProcedure;
import org.simantics.db.request.ExternalRead;
import org.simantics.db.request.MultiRead;
import org.simantics.db.request.Read;
-import org.simantics.utils.Development;
import gnu.trove.map.hash.THashMap;
import gnu.trove.map.hash.TObjectIntHashMap;
static boolean shouldCache(QueryProcessor processor, Object o) {
return false;
}
+
+ AssertedPredicates getOrCreateAssertedPredicates(int r) {
+ AssertedPredicates entry = (AssertedPredicates)assertedPredicatesMap.get(r);
+ if(entry == null) {
+ entry = new AssertedPredicates(r);
+ assertedPredicatesMap.put(keyR(r), entry);
+ }
+ return entry;
+ }
+ AssertedStatements getOrCreateAssertedStatements(int r1, int r2) {
+ AssertedStatements entry = (AssertedStatements)assertedStatementsMap.get(r1, r2);
+ if(entry == null) {
+ entry = new AssertedStatements(r1, r2);
+ assertedStatementsMap.put(keyR2(r1, r2), entry);
+ }
+ return entry;
+ }
+
+ ChildMap getOrCreateChildMap(int r) {
+ ChildMap entry = (ChildMap)childMapMap.get(r);
+ if(entry == null) {
+ entry = new ChildMap(r);
+ childMapMap.put(keyR(r), entry);
+ }
+ return entry;
+ }
+
+ DirectObjects getOrCreateDirectObjects(int r1, int r2) {
+ DirectObjects entry = (DirectObjects)directObjectsMap.get(r1, r2);
+ if(entry == null) {
+ entry = new DirectObjects(r1, r2);
+ directObjectsMap.put(keyR2(r1, r2), entry);
+ }
+ return entry;
+ }
+
+ DirectPredicates getOrCreateDirectPredicates(int r) {
+ DirectPredicates entry = (DirectPredicates)directPredicatesMap.get(r);
+ if(entry == null) {
+ entry = new DirectPredicates(r);
+ directPredicatesMap.put(keyR(r), entry);
+ }
+ return entry;
+ }
+
+ Objects getOrCreateObjects(int r1, int r2) {
+ Objects entry = (Objects)objectsMap.get(r1, r2);
+ if(entry == null) {
+ entry = new Objects(r1, r2);
+ objectsMap.put(keyR2(r1, r2), entry);
+ }
+ return entry;
+ }
+
+ OrderedSet getOrCreateOrderedSet(int r) {
+ OrderedSet entry = (OrderedSet)orderedSetMap.get(r);
+ if(entry == null) {
+ entry = new OrderedSet(r);
+ orderedSetMap.put(keyR(r), entry);
+ }
+ return entry;
+ }
+
+ Predicates getOrCreatePredicates(int r) {
+ Predicates entry = (Predicates)predicatesMap.get(r);
+ if(entry == null) {
+ entry = new Predicates(r);
+ predicatesMap.put(keyR(r), entry);
+ }
+ return entry;
+ }
+
+ PrincipalTypes getOrCreatePrincipalTypes(int r) {
+ PrincipalTypes entry = (PrincipalTypes)principalTypesMap.get(r);
+ if(entry == null) {
+ entry = new PrincipalTypes(r);
+ principalTypesMap.put(keyR(r), entry);
+ }
+ return entry;
+ }
+
+ RelationInfoQuery getOrCreateRelationInfoQuery(int r) {
+ RelationInfoQuery entry = (RelationInfoQuery)relationInfoQueryMap.get(r);
+ if(entry == null) {
+ entry = new RelationInfoQuery(r);
+ relationInfoQueryMap.put(keyR(r), entry);
+ }
+ return entry;
+ }
+
+ Statements getOrCreateStatements(int r1, int r2) {
+ Statements entry = (Statements)statementsMap.get(r1, r2);
+ if(entry == null) {
+ entry = new Statements(r1, r2);
+ statementsMap.put(keyR2(r1, r2), entry);
+ }
+ return entry;
+ }
+
+ SuperRelations getOrCreateSuperRelations(int r) {
+ SuperRelations entry = (SuperRelations)superRelationsMap.get(r);
+ if(entry == null) {
+ entry = new SuperRelations(r);
+ superRelationsMap.put(keyR(r), entry);
+ }
+ return entry;
+ }
+
+ SuperTypes getOrCreateSuperTypes(int r) {
+ SuperTypes entry = (SuperTypes)superTypesMap.get(r);
+ if(entry == null) {
+ entry = new SuperTypes(r);
+ superTypesMap.put(keyR(r), entry);
+ }
+ return entry;
+ }
+
+ TypeHierarchy getOrCreateTypeHierarchy(int r) {
+ TypeHierarchy entry = (TypeHierarchy)typeHierarchyMap.get(r);
+ if(entry == null) {
+ entry = new TypeHierarchy(r);
+ typeHierarchyMap.put(keyR(r), entry);
+ }
+ return entry;
+ }
+
+ Types getOrCreateTypes(int r) {
+ Types entry = (Types)typesMap.get(r);
+ if(entry == null) {
+ entry = new Types(r);
+ typesMap.put(keyR(r), entry);
+ }
+ return entry;
+ }
+
+ URIToResource getOrCreateURIToResource(String s) {
+ URIToResource entry = (URIToResource)uRIToResourceMap.get(s);
+ if(entry == null) {
+ entry = new URIToResource(s);
+ uRIToResourceMap.put(keyID(s), entry);
+ }
+ return entry;
+ }
+
+ ValueQuery getOrCreateValueQuery(int r) {
+ ValueQuery entry = (ValueQuery)valueQueryMap.get(r);
+ if(entry == null) {
+ entry = new ValueQuery(r);
+ valueQueryMap.put(keyR(r), entry);
+ }
+ return entry;
+ }
+
}
\ No newline at end of file
} else {
+ entry.pruneParentSet();
support.setLevel(entry, parent.getLevel() + 1);
}
--- /dev/null
+package org.simantics.db.impl.query;
+
+import java.lang.reflect.InvocationTargetException;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.simantics.db.ObjectResourceIdMap;
+import org.simantics.db.exception.DatabaseException;
+import org.simantics.db.impl.ClusterBase;
+import org.simantics.db.impl.ClusterSupport;
+import org.simantics.db.impl.ClusterTraitsBase;
+import org.simantics.db.service.Bytes;
+import org.slf4j.LoggerFactory;
+
+import gnu.trove.map.hash.TIntLongHashMap;
+
+public class QueryDeserializer {
+
+ private static final org.slf4j.Logger LOGGER = LoggerFactory.getLogger(QueryDeserializer.class);
+
+ QueryCache qc;
+ QuerySupport qs;
+ ClusterSupport cs;
+
+ private byte[] bytes;
+ private int byteIndex;
+
+ private TIntLongHashMap clusterKeys = new TIntLongHashMap();
+ private Map<Integer,QueryFactory> ids = new HashMap<Integer,QueryFactory>();
+
+ public QueryDeserializer(QueryProcessor qp, byte[] bytes) {
+ this.qc = qp.cache;
+ this.qs = qp.querySupport;
+ this.cs = qs.getClusterSupport();;
+ this.bytes = bytes;
+ }
+
+ public byte readByte() {
+ return bytes[byteIndex++];
+ }
+
+ public int readLE4() {
+ int result = Bytes.readLE4(bytes, byteIndex);
+ byteIndex += 4;
+ return result;
+ }
+
+ public long readLE8() {
+ long result = Bytes.readLE8(bytes, byteIndex);
+ byteIndex += 8;
+ return result;
+ }
+
+ public byte[] readBytes(int len) {
+ byte[] result = Arrays.copyOfRange(bytes, byteIndex, byteIndex+len);
+ byteIndex += len;
+ return result;
+ }
+
+ public void readHeaders() {
+ int idsSize = readLE4();
+ for(int i=0;i<idsSize;i++) {
+ int size = readLE4();
+ byte[] data = readBytes(size);
+ String id = new String(data);
+ int key = readLE4();
+ try {
+ Class<QueryFactory> clazz = (Class<QueryFactory>)getClass().getClassLoader().loadClass(id + "Factory");
+ QueryFactory qf = clazz.getDeclaredConstructor().newInstance();
+ ids.put(key, qf);
+ } catch (ClassNotFoundException e) {
+ LOGGER.error("Error while resolving QueryFactory", e);
+ } catch (InstantiationException e) {
+ LOGGER.error("Error while resolving QueryFactory", e);
+ } catch (IllegalAccessException e) {
+ LOGGER.error("Error while resolving QueryFactory", e);
+ } catch (IllegalArgumentException e) {
+ LOGGER.error("Error while resolving QueryFactory", e);
+ } catch (InvocationTargetException e) {
+ LOGGER.error("Error while resolving QueryFactory", e);
+ } catch (NoSuchMethodException e) {
+ LOGGER.error("Error while resolving QueryFactory", e);
+ } catch (SecurityException e) {
+ LOGGER.error("Error while resolving QueryFactory", e);
+ }
+ }
+ int clusterKeysSize = readLE4();
+ for(int i=0;i<clusterKeysSize;i++) {
+ long cluster = readLE8();
+ int key = readLE4();
+ clusterKeys.put(key, cluster);
+ }
+ }
+
+ public QueryFactory readFactory() {
+ int key = readLE4();
+ return ids.get(key);
+ }
+
+ public void readQueries() {
+ int count = readLE4();
+ for(int i=0;i<count;i++) {
+ QueryFactory qf = readFactory();
+ try {
+ qf.read(this);
+ } catch (DatabaseException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ public int readResource() throws DatabaseException {
+ int key = readLE4();
+ if(key < 0)
+ return key;
+ int clusterKey = ClusterTraitsBase.getClusterKeyFromResourceKey(key);
+ long cluster = clusterKeys.get(clusterKey);
+ ClusterBase cb = cs.getClusterByClusterId(cluster);
+ return ClusterTraitsBase.createResourceKey(cb.getClusterKey(), ClusterTraitsBase.getResourceIndexFromResourceKey(key));
+ }
+
+ public byte[] readByteArray() {
+ int len = readLE4();
+ if(len == -1)
+ return null;
+ return readBytes(len);
+ }
+
+ public String readString() {
+ return new String(readByteArray());
+ }
+
+ public ObjectResourceIdMap<String> createChildMap() {
+ return qs.createChildMap();
+ }
+
+ AssertedPredicates readAssertedPredicates() throws DatabaseException {
+ int r = readResource();
+ return qc.getOrCreateAssertedPredicates(r);
+ }
+
+ AssertedStatements readAssertedStatements() throws DatabaseException {
+ int r1 = readResource();
+ int r2 = readResource();
+ return qc.getOrCreateAssertedStatements(r1, r2);
+ }
+
+ ChildMap readChildMap() throws DatabaseException {
+ int r = readResource();
+ return qc.getOrCreateChildMap(r);
+ }
+
+ DirectObjects readDirectObjects() throws DatabaseException {
+ int r1 = readResource();
+ int r2 = readResource();
+ return qc.getOrCreateDirectObjects(r1, r2);
+ }
+
+ DirectPredicates readDirectPredicates() throws DatabaseException {
+ int r = readResource();
+ return qc.getOrCreateDirectPredicates(r);
+ }
+
+ Objects readObjects() throws DatabaseException {
+ int r1 = readResource();
+ int r2 = readResource();
+ return qc.getOrCreateObjects(r1, r2);
+ }
+
+ OrderedSet readOrderedSet() throws DatabaseException {
+ int r = readResource();
+ return qc.getOrCreateOrderedSet(r);
+ }
+
+ Predicates readPredicates() throws DatabaseException {
+ int r = readResource();
+ return qc.getOrCreatePredicates(r);
+ }
+
+ PrincipalTypes readPrincipalTypes() throws DatabaseException {
+ int r = readResource();
+ return qc.getOrCreatePrincipalTypes(r);
+ }
+
+ RelationInfoQuery readRelationInfoQuery() throws DatabaseException {
+ int r = readResource();
+ return qc.getOrCreateRelationInfoQuery(r);
+ }
+
+ Statements readStatements() throws DatabaseException {
+ int r1 = readResource();
+ int r2 = readResource();
+ return qc.getOrCreateStatements(r1, r2);
+ }
+
+ SuperRelations readSuperRelations() throws DatabaseException {
+ int r = readResource();
+ return qc.getOrCreateSuperRelations(r);
+ }
+
+ SuperTypes readSuperTypes() throws DatabaseException {
+ int r = readResource();
+ return qc.getOrCreateSuperTypes(r);
+ }
+
+ TypeHierarchy readTypeHierarchy() throws DatabaseException {
+ int r = readResource();
+ return qc.getOrCreateTypeHierarchy(r);
+ }
+
+ Types readTypes() throws DatabaseException {
+ int r = readResource();
+ return qc.getOrCreateTypes(r);
+ }
+
+ URIToResource readURIToResource() throws DatabaseException {
+ String s = readString();
+ return qc.getOrCreateURIToResource(s);
+ }
+
+ ValueQuery readValueQuery() throws DatabaseException {
+ int r = readResource();
+ return qc.getOrCreateValueQuery(r);
+ }
+
+}
--- /dev/null
+package org.simantics.db.impl.query;
+
+import org.simantics.db.exception.DatabaseException;
+
+public interface QueryFactory {
+ public CacheEntryBase read(QueryDeserializer deserializer) throws DatabaseException;
+ public <T extends CacheEntryBase> T reference(QueryDeserializer deserializer) throws DatabaseException;
+}
--- /dev/null
+package org.simantics.db.impl.query;
+
+import org.simantics.db.exception.DatabaseException;
+
+abstract public class QueryFactoryBase implements QueryFactory {
+
+ abstract protected CacheEntryBase readKeyAndValue(QueryDeserializer deserializer) throws DatabaseException;
+
+ public void readParents(QueryDeserializer deserializer, CacheEntryBase entry) throws DatabaseException {
+ int ps = deserializer.readLE4();
+ for(int i=0;i<ps;i++) {
+ QueryFactory qf = deserializer.readFactory();
+ CacheEntryBase ceb = qf.reference(deserializer);
+ entry.addParent(ceb);
+ }
+ }
+
+ @Override
+ final public CacheEntryBase read(QueryDeserializer deserializer) throws DatabaseException {
+ CacheEntryBase entry = readKeyAndValue(deserializer);
+ readParents(deserializer, entry);
+ return entry;
+ }
+
+}
*******************************************************************************/
package org.simantics.db.impl.query;
-import gnu.trove.impl.hash.THash;
+import java.util.Collection;
import org.simantics.db.exception.DatabaseException;
import org.simantics.db.impl.graph.ReadGraphImpl;
+import gnu.trove.impl.hash.THash;
+
/**
* An open addressed hashing implementation for Object types.
}
@Override
- public Iterable<CacheEntry> getParents(QueryProcessor processor) {
+ public Collection<CacheEntry> getParents(QueryProcessor processor) {
// TODO Auto-generated method stub
return null;
}
// TODO Auto-generated method stub
return null;
}
-
+
+ @Override
+ void pruneParentSet() {
+ }
+
};
/**
}
}
-
+
+ final public void removeDiscardedReally() {
+
+ tempDisableAutoCompaction();
+ try {
+
+ for(int i=0;i<_set.length;i++) {
+ CacheEntry entry = _set[i];
+ if(entry != null && REMOVED != entry) {
+ if(entry.isDiscarded()) removeAt(i);
+ }
+ }
+
+ } finally {
+ reenableAutoCompaction(false);
+ }
+
+ }
+
/**
* Creates an iterator over the values of the set. The iterator
* supports element deletion.
@Override
public void run() {
- ListenerEntry entry = addedEntries.get(base);
+ ListenerEntry entry = addedEntries.remove(base);
if(entry != null) entry.setLastKnown(result);
}
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
+import org.eclipse.core.runtime.Platform;
import org.simantics.databoard.Bindings;
import org.simantics.db.AsyncReadGraph;
import org.simantics.db.DevelopmentKeys;
import org.simantics.db.Session;
import org.simantics.db.Statement;
import org.simantics.db.VirtualGraph;
+import org.simantics.db.common.ByteFileReader;
import org.simantics.db.common.procedure.adapter.AsyncMultiProcedureAdapter;
import org.simantics.db.common.utils.Logger;
import org.simantics.db.exception.DatabaseException;
import org.simantics.db.request.ExternalRead;
import org.simantics.db.request.MultiRead;
import org.simantics.db.request.RequestFlags;
+import org.simantics.db.service.Bytes;
import org.simantics.layer0.Layer0;
import org.simantics.utils.DataContainer;
import org.simantics.utils.Development;
+import org.simantics.utils.FileUtils;
import org.simantics.utils.datastructures.Pair;
import org.simantics.utils.datastructures.collections.CollectionUtils;
import org.simantics.utils.datastructures.disposable.AbstractDisposable;
}
+ public synchronized void save() throws IOException {
+
+ long start = System.nanoTime();
+
+ Collection<CacheEntryBase> caches = allCaches(new CacheCollectionResult()).toCollection();
+ Map<Long,List<CacheEntryBase>> cachesByCluster = new HashMap<>();
+ for(CacheEntryBase entry : caches) {
+ String clazz = entry.classId();
+ if(clazz == null)
+ continue;
+ long cluster = entry.cluster(this);
+ List<CacheEntryBase> queries = cachesByCluster.get(cluster);
+ if(queries == null) {
+ queries = new ArrayList<>();
+ cachesByCluster.put(cluster, queries);
+ }
+ queries.add(entry);
+ }
+
+ File workspace = Platform.getLocation().toFile();
+ File dir = new File(workspace, "queryData");
+ FileUtils.deleteAll(dir);
+
+ dir.mkdir();
+
+ for(Long cluster : cachesByCluster.keySet()) {
+
+ List<CacheEntryBase> queries = cachesByCluster.get(cluster);
+ QuerySerializer serializer = new QuerySerializer(this);
+ int count = 0;
+ int pos = serializer.writeUnknownSize();
+ for(CacheEntryBase entry : queries) {
+ String clazz = entry.classId();
+ if(clazz == null)
+ continue;
+ try {
+ entry.serialize(serializer);
+ count++;
+ } catch (IllegalStateException e) {
+ System.err.println(e.getMessage());
+ }
+ }
+ serializer.setUnknownSize(pos, count);
+
+ System.err.println(serializer.bytes().length + " bytes for cluster " + cluster);
+ FileUtils.writeFile(new File(dir, "" + cluster + ".queryData"), serializer.bytes());
+
+ }
+
+ long end = System.nanoTime();
+
+ System.err.println("saved queries in " + 1e-6*(end-start) + "ms.");
+
+ }
+
+ public void restore() throws IOException {
+
+ long start = System.nanoTime();
+
+ File workspace = Platform.getLocation().toFile();
+ File dir = new File(workspace, "queryData");
+ dir.mkdir();
+
+ for(File f : FileUtils.listFilesByExtension(dir, "queryData")) {
+ byte[] bytes = FileUtils.readFile(f);
+ QueryDeserializer qd = new QueryDeserializer(this, bytes);
+ qd.readHeaders();
+ qd.readQueries();
+ }
+
+ long end = System.nanoTime();
+
+ System.err.println("restored queries in " + 1e-6*(end-start) + "ms.");
+
+ }
+
boolean removeQuery(CacheEntry entry) {
// This entry has been removed before. No need to do anything here.
}
return result;
}
+
+ public long cluster(int resource) {
+ if(resource <= 0)
+ return 0;
+ return querySupport.getClusterId(resource);
+ }
public void assertDone() {
}
--- /dev/null
+package org.simantics.db.impl.query;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import org.simantics.db.impl.ClusterTraitsBase;
+
+import gnu.trove.list.array.TByteArrayList;
+import gnu.trove.map.hash.TLongIntHashMap;
+import gnu.trove.procedure.TLongIntProcedure;
+
+public class QuerySerializer {
+
+ private QueryProcessor processor;
+ private QuerySupport querySupport;
+ private TByteArrayList bytes = new TByteArrayList();
+ private TLongIntHashMap clusterKeys = new TLongIntHashMap();
+ private Map<String,Integer> ids = new HashMap<String,Integer>();
+
+ public QuerySerializer(QueryProcessor processor) {
+ this.processor = processor;
+ this.querySupport = processor.querySupport;
+ }
+
+ public int writeUnknownSize() {
+ int pos = bytes.size();
+ bytes.add((byte)0);
+ bytes.add((byte)0);
+ bytes.add((byte)0);
+ bytes.add((byte)0);
+ return pos;
+ }
+
+ public void setUnknownSize(int pos, int value) {
+ bytes.set(pos, (byte) (value & 0xFF));
+ bytes.set(pos+1, (byte) ((value >>> 8) & 0xFF));
+ bytes.set(pos+2, (byte) ((value >>> 16) & 0xFF));
+ bytes.set(pos+3, (byte) ((value >>> 24) & 0xFF));
+ }
+
+ public void serializeId(String classId) {
+ Integer id = ids.get(classId);
+ if(id == null) {
+ id = ids.size() + 1;
+ ids.put(classId, id);
+ }
+ writeLE(id);
+ }
+
+ public void addResource(int r) {
+ if(r < 0) {
+ writeLE(r);
+ } else {
+ long clusterId = querySupport.getClusterId(r);
+ int clusterKey = clusterKeys.get(clusterId);
+ if(clusterKey == 0) {
+ clusterKey = clusterKeys.size() + 1;
+ clusterKeys.put(clusterId, clusterKey);
+ }
+ int i = ClusterTraitsBase.createResourceKeyNoThrow(clusterKey, ClusterTraitsBase.getResourceIndexFromResourceKeyNoThrow(r));
+ writeLE(i);
+ }
+ }
+
+ public void addString(String s) {
+ byte[] b = s.getBytes();
+ writeLE(b.length);
+ bytes.add(b);
+ }
+
+ public void add(byte b) {
+ bytes.add(b);
+ }
+
+ public void add(byte[] bs) {
+ bytes.add(bs);
+ }
+
+ public byte[] bytes() {
+ TByteArrayList header = new TByteArrayList();
+ writeLE(header, ids.size());
+ for(Entry<String,Integer> entry : ids.entrySet()) {
+ String id = entry.getKey();
+ writeLE(header, id.length());
+ header.add(id.getBytes());
+ writeLE(header, entry.getValue());
+ }
+
+ writeLE(header, clusterKeys.size());
+ clusterKeys.forEachEntry(new TLongIntProcedure() {
+
+ @Override
+ public boolean execute(long a, int b) {
+ writeLE(header, a);
+ writeLE(header, b);
+ return true;
+ }
+
+ });
+
+ header.add(bytes.toArray());
+ return header.toArray();
+ }
+
+ public void writeLE(int value) {
+ writeLE(bytes, value);
+ }
+
+ public static void writeLE(TByteArrayList bytes, int value) {
+ bytes.add((byte) (value & 0xFF));
+ bytes.add((byte) ((value >>> 8) & 0xFF));
+ bytes.add((byte) ((value >>> 16) & 0xFF));
+ bytes.add((byte) ((value >>> 24) & 0xFF));
+ }
+
+ public void writeLE(long value) {
+ writeLE(bytes, value);
+ }
+
+ public static void writeLE(TByteArrayList bytes, long value) {
+ bytes.add((byte) (value & 0xFF));
+ bytes.add((byte) ((value >>> 8) & 0xFF));
+ bytes.add((byte) ((value >>> 16) & 0xFF));
+ bytes.add((byte) ((value >>> 24) & 0xFF));
+ bytes.add((byte) ((value >>> 32) & 0xFF));
+ bytes.add((byte) ((value >>> 40) & 0xFF));
+ bytes.add((byte) ((value >>> 48) & 0xFF));
+ bytes.add((byte) ((value >>> 56) & 0xFF));
+ }
+
+ public QueryProcessor getQueryProcessor() {
+ return processor;
+ }
+
+}
import java.io.InputStream;
+import org.simantics.db.ObjectResourceIdMap;
import org.simantics.db.Resource;
import org.simantics.db.Session;
import org.simantics.db.VirtualGraph;
import org.simantics.db.exception.DatabaseException;
import org.simantics.db.exception.ResourceNotFoundException;
+import org.simantics.db.impl.ClusterSupport;
import org.simantics.db.impl.graph.ReadGraphImpl;
public interface QuerySupport extends ResourceTranslator {
Session getSession();
-
+
+ ClusterSupport getClusterSupport();
+
+ ObjectResourceIdMap<String> createChildMap();
+
boolean isImmutable(int id);
long getClusterId(int id);
int getId(Resource resource);
except(throwable);
}
+ @Override
+ public String classId() {
+ return null;
+ }
+
}
return RequestFlags.IMMEDIATE_UPDATE;
}
+ @Override
+ public void serializeValue(QuerySerializer serializer) {
+ RelationInfo ri = getResult();
+ serializer.addResource(ri.predicate);
+ serializer.add(ri.isFunctional ? (byte)1 : 0);
+ serializer.add(ri.isFinal ? (byte)1 : 0);
+ serializer.add(ri.isAsserted ? (byte)1 : 0);
+ }
+
}
--- /dev/null
+package org.simantics.db.impl.query;
+
+import org.simantics.db.RelationInfo;
+import org.simantics.db.exception.DatabaseException;
+
+public class RelationInfoQueryFactory extends QueryFactoryBase {
+
+ @Override
+ public CacheEntryBase readKeyAndValue(QueryDeserializer deserializer) throws DatabaseException {
+ RelationInfoQuery result = reference(deserializer);
+ int r = deserializer.readResource();
+ int isFunctional = deserializer.readByte();
+ int isFinal = deserializer.readByte();
+ int isAsserted = deserializer.readByte();
+ RelationInfo ri = new RelationInfo(r, isFunctional == 1, isFinal == 1, isAsserted == 1);
+ result.setResult(ri);
+ result.setReady();
+ return result;
+ }
+
+ @Override
+ public <T extends CacheEntryBase> T reference(QueryDeserializer deserializer) throws DatabaseException {
+ return (T)deserializer.readRelationInfoQuery();
+ }
+
+}
--- /dev/null
+package org.simantics.db.impl.query;
+
+import org.simantics.db.exception.DatabaseException;
+
+public class StatementsFactory extends QueryFactoryBase {
+
+ @Override
+ public CacheEntryBase readKeyAndValue(QueryDeserializer deserializer) throws DatabaseException {
+ Statements result = reference(deserializer);
+ IntArray ia = IntArray.deserialize(deserializer);
+ result.setResult(ia);
+ result.setReady();
+ return result;
+ }
+
+ @Override
+ public <T extends CacheEntryBase> T reference(QueryDeserializer deserializer) throws DatabaseException {
+ return (T)deserializer.readStatements();
+ }
+
+}
import gnu.trove.procedure.TIntProcedure;
import gnu.trove.set.hash.TIntHashSet;
-public final class SuperRelations extends UnaryQueryP<IntSet> {
+public final class SuperRelations extends UnaryQueryPIntSet {
SuperRelations(final int resource) {
super(resource);
--- /dev/null
+package org.simantics.db.impl.query;
+
+import org.simantics.db.exception.DatabaseException;
+
+public class SuperRelationsFactory extends QueryFactoryBase {
+
+ @Override
+ public CacheEntryBase readKeyAndValue(QueryDeserializer deserializer) throws DatabaseException {
+ SuperRelations result = reference(deserializer);
+ IntSet ia = IntSet.deserialize(deserializer);
+ result.setResult(ia);
+ result.setReady();
+ return result;
+ }
+
+ @Override
+ public <T extends CacheEntryBase> T reference(QueryDeserializer deserializer) throws DatabaseException {
+ return (T)deserializer.readSuperRelations();
+ }
+
+}
import gnu.trove.procedure.TIntProcedure;
-public final class SuperTypes extends UnaryQueryP<IntSet> {
+public final class SuperTypes extends UnaryQueryPIntSet {
SuperTypes(int resource) {
super(resource);
--- /dev/null
+package org.simantics.db.impl.query;
+
+import org.simantics.db.exception.DatabaseException;
+
+public class SuperTypesFactory extends QueryFactoryBase {
+
+ @Override
+ public CacheEntryBase readKeyAndValue(QueryDeserializer deserializer) throws DatabaseException {
+ SuperTypes result = reference(deserializer);
+ IntSet ia = IntSet.deserialize(deserializer);
+ result.setResult(ia);
+ result.setReady();
+ return result;
+ }
+
+ @Override
+ public <T extends CacheEntryBase> T reference(QueryDeserializer deserializer) throws DatabaseException {
+ return (T)deserializer.readSuperTypes();
+ }
+
+}
import gnu.trove.procedure.TIntProcedure;
-public final class TypeHierarchy extends UnaryQueryP<IntSet> {
+public final class TypeHierarchy extends UnaryQueryPIntSet {
TypeHierarchy(int resource) {
super(resource);
--- /dev/null
+package org.simantics.db.impl.query;
+
+import org.simantics.db.exception.DatabaseException;
+
+public class TypeHierarchyFactory extends QueryFactoryBase {
+
+ @Override
+ public CacheEntryBase readKeyAndValue(QueryDeserializer deserializer) throws DatabaseException {
+ TypeHierarchy result = reference(deserializer);
+ IntSet ia = IntSet.deserialize(deserializer);
+ result.setResult(ia);
+ result.setReady();
+ return result;
+ }
+
+ @Override
+ public <T extends CacheEntryBase> T reference(QueryDeserializer deserializer) throws DatabaseException {
+ return (T)deserializer.readTypeHierarchy();
+ }
+
+}
import gnu.trove.procedure.TIntProcedure;
-public final class Types extends UnaryQueryP<IntSet> {
+public final class Types extends UnaryQueryPIntSet {
Types(int resource) {
super(resource);
--- /dev/null
+package org.simantics.db.impl.query;
+
+import org.simantics.db.exception.DatabaseException;
+
+public class TypesFactory extends QueryFactoryBase {
+
+ @Override
+ public CacheEntryBase readKeyAndValue(QueryDeserializer deserializer) throws DatabaseException {
+ Types result = reference(deserializer);
+ IntSet ia = IntSet.deserialize(deserializer);
+ result.setResult(ia);
+ result.setReady();
+ return result;
+ }
+
+ @Override
+ public <T extends CacheEntryBase> T reference(QueryDeserializer deserializer) throws DatabaseException {
+ return (T)deserializer.readTypes();
+ }
+
+}
except(throwable);
}
+ @Override
+ public long cluster(QueryProcessor processor) {
+ return 0;
+ }
+
+ @Override
+ public void serializeKey(QuerySerializer serializer) {
+ serializer.addString(id);
+ }
+
+ @Override
+ public void serializeValue(QuerySerializer serializer) {
+ Integer value = getResult();
+ serializer.addResource(value);
+ }
+
}
--- /dev/null
+package org.simantics.db.impl.query;
+
+import org.simantics.db.exception.DatabaseException;
+
+public class URIToResourceFactory extends QueryFactoryBase {
+
+ @Override
+ public CacheEntryBase readKeyAndValue(QueryDeserializer deserializer) throws DatabaseException {
+ URIToResource result = reference(deserializer);
+ int value = deserializer.readResource();
+ result.setResult(value);
+ result.setReady();
+ return result;
+ }
+
+ @Override
+ public <T extends CacheEntryBase> T reference(QueryDeserializer deserializer) throws DatabaseException {
+ return (T)deserializer.readURIToResource();
+ }
+
+}
import org.simantics.db.impl.graph.ReadGraphImpl;
import org.simantics.db.request.RequestFlags;
+import gnu.trove.list.array.TByteArrayList;
+
public abstract class UnaryQuery<Procedure> extends CacheEntryBase<Procedure> implements Query {
final public int id;
return graph.processor.isImmutable(id);
}
+ @Override
+ public long cluster(QueryProcessor processor) {
+ return processor.cluster(id);
+ }
+
+ @Override
+ public void serializeKey(QuerySerializer serializer) {
+ serializer.addResource(id);
+ }
+
}
--- /dev/null
+package org.simantics.db.impl.query;
+
+abstract public class UnaryQueryPIntSet extends UnaryQueryP<IntSet> {
+
+ public UnaryQueryPIntSet(int r) {
+ super(r);
+ }
+
+ @Override
+ public void serializeValue(QuerySerializer serializer) {
+ IntSet is = getResult();
+ is.serialize(serializer);
+ }
+
+}
return value;
}
+
+ @Override
+ public void serializeValue(QuerySerializer serializer) {
+ byte[] result = getResult();
+ if(result == null) {
+ serializer.writeLE(-1);
+ } else {
+ serializer.writeLE(result.length);
+ serializer.add(result);
+ }
+ }
@Override
public String toString() {
--- /dev/null
+package org.simantics.db.impl.query;
+
+import org.simantics.db.exception.DatabaseException;
+
+public class ValueQueryFactory extends QueryFactoryBase {
+
+ @Override
+ public CacheEntryBase readKeyAndValue(QueryDeserializer deserializer) throws DatabaseException {
+ ValueQuery result = reference(deserializer);
+ byte[] bytes = deserializer.readByteArray();
+ result.setResult(bytes);
+ result.setReady();
+ return result;
+ }
+
+ @Override
+ public <T extends CacheEntryBase> T reference(QueryDeserializer deserializer) throws DatabaseException {
+ return (T)deserializer.readValueQuery();
+ }
+
+}
org.simantics.databoard;bundle-version="0.6.2";visibility:=reexport,
org.simantics.db.services;bundle-version="1.1.0";visibility:=reexport,
org.simantics.db.management;bundle-version="1.1.0",
- org.apache.log4j;bundle-version="1.2.15",
org.apache.commons.io;bundle-version="1.4.0",
org.simantics.layer0;bundle-version="1.0.0";visibility:=reexport,
org.simantics.graph.db;bundle-version="1.1.5";visibility:=reexport,
b2.append('\n');
}
SCLDatabaseException exception = new SCLDatabaseException(b.toString()+b2.toString(), b2.toString(), e.getErrors());
- LOGGER.info(exception.getMessage(), exception);
throw exception;
} catch(Throwable e) {
// Should not happen!
import org.simantics.databoard.util.ObjectUtils;
import org.simantics.db.ReadGraph;
import org.simantics.db.common.request.ParametrizedPrimitiveRead;
-import org.simantics.db.common.utils.Logger;
import org.simantics.db.exception.DatabaseException;
import org.simantics.db.layer0.variable.Variables.NodeStructure;
import org.simantics.db.procedure.Listener;
import org.simantics.simulator.variable.exceptions.NodeManagerException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import gnu.trove.map.hash.THashMap;
@SuppressWarnings("rawtypes")
class NodeStructureRequest extends ParametrizedPrimitiveRead<VariableNode, NodeStructure> implements VariableNodeReadRunnable {
- private Listener<NodeStructure> listener = null;
- private NodeStructure value = Variables.PENDING_NODE_STRUCTURE;
- private boolean wasRun = false;
-
- static class Probe implements Runnable {
-
- private VariableNode node;
- public NodeStructure result;
-
- public Probe(VariableNode node) {
- this.node = node;
- }
-
- @SuppressWarnings("unchecked")
- @Override
- public void run() {
- try {
- result = NodeStructureRequest.get(node);
- node.support.structureCache.put(node.node, result, 1000000000L);
- } catch (NodeManagerException e) {
- e.printStackTrace();
- }
- }
-
- }
-
- public NodeStructureRequest(VariableNode node) {
- super(node);
- }
-
- @SuppressWarnings("unchecked")
- @Override
- public void register(ReadGraph graph, final Listener<NodeStructure> procedure) {
-
- if(procedure.isDisposed()) {
-
- // We are not listening
- NodeStructure result = (NodeStructure)parameter.support.structureCache.get(parameter.node);
-
- if(result != null) {
- // Return cached value immediately
- procedure.execute(result);
- } else {
- NodeStructureRequest.Probe probe = new Probe(parameter);
- parameter.support.manager.getRealm().asyncExec(probe);
- if(probe.result != null) {
- procedure.execute(probe.result);
- } else {
- procedure.execute(Variables.PENDING_NODE_STRUCTURE);
- }
- }
-
- return;
-
- }
-
- // We need to listen
- listener = procedure;
- // Register listening
- parameter.support.manager.addNodeListener(parameter.node, this);
- synchronized(this) {
- if(wasRun) {
- procedure.execute(value);
- } else {
- NodeStructure result = (NodeStructure)parameter.support.structureCache.get(parameter.node);
- if(result != null) {
- procedure.execute(result);
- } else {
- procedure.execute(Variables.PENDING_NODE_STRUCTURE);
- }
- }
- }
-
- }
-
- static class NodeListener implements VariableNodeReadRunnable {
-
- private VariableNode node;
- private NodeStructureRequest request;
-
- public NodeListener(VariableNode node, NodeStructureRequest request) {
- this.node = node;
- this.request = request;
- }
-
- @SuppressWarnings("unchecked")
- @Override
- public void run() {
- node.support.manager.addNodeListener(node.node, request);
- }
-
- }
-
- @SuppressWarnings("unchecked")
- @Override
- public void unregistered() {
- parameter.support.manager.removeNodeListener(parameter.node, this);
- parameter.support.structureCache.removeListening(parameter.node);
- listener = null;
- }
-
- @SuppressWarnings("unchecked")
- public static NodeStructure get(VariableNode parameter) throws NodeManagerException {
- List<?> children = parameter.support.manager.getChildren(parameter.node);
- List<?> properties = parameter.support.manager.getProperties(parameter.node);
- Map<String, Object> childMap = Collections.emptyMap();
- Map<String, Object> propertyMap = childMap;
- if(!children.isEmpty()) {
- childMap = new THashMap<>(children.size());
- for(Object o : children) {
- String name = parameter.support.manager.getName(o);
- childMap.put(name, o);
- }
- }
- if(!properties.isEmpty()) {
- propertyMap = new THashMap<>(properties.size());
- for(Object o : properties) {
- String name = parameter.support.manager.getName(o);
- propertyMap.put(name, o);
- }
- }
- return new NodeStructure(childMap, propertyMap);
- }
-
- @SuppressWarnings("unchecked")
- @Override
- public synchronized void run() {
- try {
- // Cache this value with infinite cache time since we are listening
- NodeStructure newValue = get(parameter);
- if (wasRun && ObjectUtils.objectEquals(value, newValue)) {
- //System.out.println("CACHE VALUE MATCH (" + newValue + ") for " + node.node);
- return;
- }
- value = newValue;
- parameter.support.structureCache.put(parameter.node, value);
- } catch (Throwable e) {
- // Must catch everything to prevent DB client from getting stuck.
- Logger.defaultLogError(e);
- // Invoke the exception method of the listener
- Listener<NodeStructure> listener = this.listener;
- if (listener != null) listener.exception(new DatabaseException("External data access error", e));
- wasRun = true;
- return;
- }
-
- // Must always invoke an existing listener, regardless of earlier errors.
- Listener<NodeStructure> listener = this.listener;
- if (listener != null) {
- listener.execute(value);
- }
- wasRun = true;
- }
-
- @Override
- public String toString() {
- return "NodeStructureRequest.run @ " + System.identityHashCode(this);
- }
+ private static final Logger LOGGER = LoggerFactory.getLogger(NodeStructureRequest.class);
+
+ private Listener<NodeStructure> listener = null;
+ private NodeStructure value = Variables.PENDING_NODE_STRUCTURE;
+ private boolean wasRun = false;
+
+ static class Probe implements Runnable {
+
+ private VariableNode node;
+ public NodeStructure result;
+
+ public Probe(VariableNode node) {
+ this.node = node;
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public void run() {
+ try {
+ result = NodeStructureRequest.get(node);
+ node.support.structureCache.put(node.node, result, 1000000000L);
+ } catch (NodeManagerException e) {
+ e.printStackTrace();
+ }
+ }
+
+ }
+
+ public NodeStructureRequest(VariableNode node) {
+ super(node);
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public void register(ReadGraph graph, final Listener<NodeStructure> procedure) {
+
+ if(procedure.isDisposed()) {
+
+ // We are not listening
+ NodeStructure result = (NodeStructure)parameter.support.structureCache.get(parameter.node);
+
+ if(result != null) {
+ // Return cached value immediately
+ procedure.execute(result);
+ } else {
+ NodeStructureRequest.Probe probe = new Probe(parameter);
+ parameter.support.manager.getRealm().asyncExec(probe);
+ if(probe.result != null) {
+ procedure.execute(probe.result);
+ } else {
+ procedure.execute(Variables.PENDING_NODE_STRUCTURE);
+ }
+ }
+
+ return;
+
+ }
+
+ // We need to listen
+ listener = procedure;
+ // Register listening
+ parameter.support.manager.addNodeListener(parameter.node, this);
+ synchronized(this) {
+ if(!wasRun) {
+ NodeStructure result = (NodeStructure)parameter.support.structureCache.get(parameter.node);
+ if(result != null) {
+ procedure.execute(result);
+ } else {
+ procedure.execute(Variables.PENDING_NODE_STRUCTURE);
+ }
+ }
+ }
+
+ }
+
+ static class NodeListener implements VariableNodeReadRunnable {
+
+ private VariableNode node;
+ private NodeStructureRequest request;
+
+ public NodeListener(VariableNode node, NodeStructureRequest request) {
+ this.node = node;
+ this.request = request;
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public void run() {
+ node.support.manager.addNodeListener(node.node, request);
+ }
+
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public void unregistered() {
+ parameter.support.manager.removeNodeListener(parameter.node, this);
+ parameter.support.structureCache.removeListening(parameter.node);
+ listener = null;
+ }
+
+ @SuppressWarnings("unchecked")
+ public static NodeStructure get(VariableNode parameter) throws NodeManagerException {
+ List<?> children = parameter.support.manager.getChildren(parameter.node);
+ List<?> properties = parameter.support.manager.getProperties(parameter.node);
+ Map<String, Object> childMap = Collections.emptyMap();
+ Map<String, Object> propertyMap = childMap;
+ if(!children.isEmpty()) {
+ childMap = new THashMap<>(children.size());
+ for(Object o : children) {
+ String name = parameter.support.manager.getName(o);
+ childMap.put(name, o);
+ }
+ }
+ if(!properties.isEmpty()) {
+ propertyMap = new THashMap<>(properties.size());
+ for(Object o : properties) {
+ String name = parameter.support.manager.getName(o);
+ propertyMap.put(name, o);
+ }
+ }
+ return new NodeStructure(childMap, propertyMap);
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public synchronized void run() {
+ try {
+ // Cache this value with infinite cache time since we are listening
+ NodeStructure newValue = get(parameter);
+ if (wasRun && ObjectUtils.objectEquals(value, newValue)) {
+ //System.out.println("CACHE VALUE MATCH (" + newValue + ") for " + node.node);
+ return;
+ }
+ value = newValue;
+ parameter.support.structureCache.put(parameter.node, value);
+ } catch (Throwable e) {
+ // Must catch everything to prevent DB client from getting stuck.
+ LOGGER.error("Error while computing node structure", e);
+ // Invoke the exception method of the listener
+ Listener<NodeStructure> listener = this.listener;
+ if (listener != null) {
+ listener.exception(new DatabaseException("External data access error", e));
+ wasRun = true;
+ }
+ return;
+ }
+
+ // Must always invoke an existing listener, regardless of earlier errors.
+ Listener<NodeStructure> listener = this.listener;
+ if (listener != null) {
+ listener.execute(value);
+ wasRun = true;
+ }
+ }
+
+ @Override
+ public String toString() {
+ return "NodeStructureRequest.run @ " + System.identityHashCode(this);
+ }
}
\ No newline at end of file
// Register listening
node.support.manager.addNodeListener(node.node, this);
synchronized(this) {
- if(wasRun) {
- procedure.execute(value);
- } else {
+ if(!wasRun) {
Variant result = (Variant)node.support.valueCache.get(node.node);
if(result != null) {
procedure.execute(result);
LOGGER.error("Error while computing node value", e);
// Invoke the exception method of the listener
Listener<Variant> listener = this.listener;
- if (listener != null) listener.exception(new DatabaseException("External data access error", e));
- wasRun = true;
+ if (listener != null) {
+ listener.exception(new DatabaseException("External data access error", e));
+ wasRun = true;
+ }
return;
}
// Must always invoke an existing listener, regardless of earlier errors.
if (listener != null) {
//System.out.println("LISTENER " + listener + " invoked with value " + value);
listener.execute(value);
+ wasRun = true;
}
- wasRun = true;
}
@Override
Bundle-SymbolicName: org.simantics.db.procore
Bundle-Version: 1.2.1.qualifier
Bundle-Vendor: VTT Technical Research Centre of Finland
-Require-Bundle: org.apache.log4j;visibility:=reexport,
- org.simantics.db;bundle-version="0.8.0";visibility:=reexport,
+Require-Bundle: org.simantics.db;bundle-version="0.8.0";visibility:=reexport,
org.simantics.db.common;bundle-version="0.8.0";visibility:=reexport,
gnu.trove3;bundle-version="3.0.0",
org.simantics.db.impl;bundle-version="0.8.0",
import org.simantics.scl.runtime.function.FunctionImpl3;
import org.simantics.utils.Development;
import org.simantics.utils.FileUtils;
+import org.slf4j.LoggerFactory;
import gnu.trove.map.hash.TIntIntHashMap;
import gnu.trove.procedure.TIntIntProcedure;
public class DebugSupportImpl implements DebugSupport {
+ private static final org.slf4j.Logger LOGGER = LoggerFactory.getLogger(DebugSupportImpl.class);
+
final private Map<String, Function2<WriteGraph, String, Object>> getCommands = new HashMap<String, Function2<WriteGraph, String, Object>>();
final private Map<String, Function3<WriteGraph, File, String, String>> listCommands = new HashMap<String, Function3<WriteGraph, File, String, String>>();
final private Map<String, Function2<WriteGraph, String, String>> execCommands = new HashMap<String, Function2<WriteGraph, String, String>>();
});
+ listCommands.put("queryData", new FunctionImpl3<WriteGraph, File, String, String>() {
+
+ @Override
+ public String apply(WriteGraph graph, File file, String args) {
+ try {
+ getSession(graph).queryProvider2.save();
+ return "Saved queries";
+ } catch (IOException e) {
+ LOGGER.error("Error while saving queries", e);
+ return e.getMessage();
+ }
+ }
+
+ });
+
listCommands.put("queryActivity", new FunctionImpl3<WriteGraph, File, String, String>() {
@Override
public int getId(T t) {
return backend.get(t);
}
-
+
}
\ No newline at end of file
import java.util.Collection;
import java.util.function.Consumer;
+import org.simantics.db.ObjectResourceIdMap;
import org.simantics.db.Resource;
import org.simantics.db.Session;
import org.simantics.db.Statement;
public ResourceSupport getSupport() {
return resourceSupport;
}
-
+
+ @Override
+ public ClusterSupport getClusterSupport() {
+ return clusterSupport;
+ }
+
+ @Override
+ public ObjectResourceIdMap<String> createChildMap() {
+ return new ObjectResourceMap<String>(session);
+ }
+
@Override
public Statement getStatement(int s, int p, int o) {
return getStatement(null, s, p, o);
serviceLocator.registerService(QuerySupport.class, querySupport);
queryProvider2 = new QueryProcessor(getAmountOfQueryThreads(), querySupport, sessionThreads);
+
+ if("true".equals(System.getProperty("org.simantics.db.persistQueries")))
+ queryProvider2.restore();
writeSupport = new WriteSupportImpl(this);
serviceLocator.registerService(WriteSupport.class, writeSupport);
package fi.vtt.simantics.procore.internal;
+import java.io.IOException;
+
import org.simantics.db.Database;
import org.simantics.db.Resource;
import org.simantics.db.Session;
ClusterImpl clusterImpl = session.clusterTable.getClusterByClusterUIDOrMakeProxy(clusterUID);
return clusterImpl.isLoaded();
}
-
+
+ @Override
+ public void saveQueries() throws DatabaseException {
+ try {
+ session.queryProvider2.save();
+ } catch (IOException e) {
+ throw new DatabaseException(e);
+ }
+ }
+
}
Import-Package: gnu.trove.impl.hash,
gnu.trove.iterator,
gnu.trove.map.hash,
- org.apache.log4j,
- org.apache.log4j.spi,
org.eclipse.core.runtime,
org.osgi.framework;version="1.3.0",
org.simantics.db,
*******************************************************************************/
package org.simantics.db;
-
-
final public class RelationInfo {
public static final RelationInfo[] NONE = new RelationInfo[0];
this.isFinal = isFinal;
this.isAsserted = isAsserted;
}
-
+
@Override
public String toString() {
return "RelationInfo[predicate=" + predicate + ", isFunctional=" + isFunctional + ", isFinal=" + isFinal + ", isAsserted=" + isAsserted + "]";
public boolean rolledback();
public boolean isClusterLoaded(ClusterUID clusterUID) throws DatabaseException;
-
+
+ public void saveQueries() throws DatabaseException;
+
}
import "Simantics/DB"
-importJava "org.simantics.debug.graphical.DebuggerCanvas" where
+importJava "org.simantics.debug.graphical.DebuggerCanvasProxy" where
data GraphDebugger
setStatementFilter :: GraphDebugger -> (Statement -> <ReadGraph,Proc> Boolean) -> <Proc> ()
--- /dev/null
+package org.simantics.debug.graphical;
+
+import org.simantics.db.Resource;
+import org.simantics.scl.runtime.function.Function;
+
+/**
+ * <code>Simantics/GraphicalDebugger</code> SCL API to avoid undesired AWT
+ * toolkit initialization.
+ *
+ * @author Tuukka Lehtonen
+ */
+public class DebuggerCanvasProxy {
+
+ DebuggerCanvas canvas;
+
+ public void setStatementFilter(@SuppressWarnings("rawtypes") Function statementFilter) {
+ canvas.setStatementFilter(statementFilter);
+ }
+
+ public void removeStatementFilter() {
+ canvas.removeStatementFilter();
+ }
+
+ public void addResource(Resource resource) {
+ canvas.addResource(resource);
+ }
+
+ public DebuggerCanvasProxy(DebuggerCanvas canvas) {
+ this.canvas = canvas;
+ }
+
+}
public class GraphicalDebugger {
- public static DebuggerCanvas newGraphDebugger() {
+ public static DebuggerCanvasProxy newGraphDebugger() {
final JFrame frame = new JFrame();
frame.setTitle("Graph debugger");
Toolkit tk = Toolkit.getDefaultToolkit();
});
frame.setVisible(true);
- return canvas;
+ return new DebuggerCanvasProxy(canvas);
}
}
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
org.simantics.views.swt;bundle-version="1.0.0",
org.simantics.views.swt.client;bundle-version="1.0.0",
org.simantics.views.ontology;bundle-version="1.0.0",
- org.simantics.selectionview;bundle-version="1.0.0"
+ org.simantics.selectionview;bundle-version="1.0.0",
+ org.slf4j.api
Import-Package: org.simantics.views
Bundle-Vendor: Semantum Oy
Export-Package: org.simantics.diagram.profile.request
import org.simantics.db.common.request.WriteRequest;
import org.simantics.db.common.utils.NameUtils;
import org.simantics.db.exception.DatabaseException;
-import org.simantics.diagram.Logger;
import org.simantics.diagram.stubs.DiagramResource;
import org.simantics.layer0.Layer0;
import org.simantics.operation.Layer0X;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class CreateGroupAction extends ModelledActionImpl<Resource> {
+ private static final Logger LOGGER = LoggerFactory.getLogger(CreateGroupAction.class);
+
public CreateGroupAction(Resource configuration) {
super(configuration);
}
});
} catch (DatabaseException e) {
-
- Logger.defaultLogError(e);
-
+ LOGGER.error("CreateGroupAction failed", e);
}
}
import org.simantics.db.common.utils.NameUtils;
import org.simantics.db.common.utils.OrderedSetUtils;
import org.simantics.db.exception.DatabaseException;
-import org.simantics.diagram.Logger;
import org.simantics.diagram.stubs.DiagramResource;
import org.simantics.layer0.Layer0;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class CreateProfileAction extends ModelledActionImpl<Resource> {
+ private static final Logger LOGGER = LoggerFactory.getLogger(CreateProfileAction.class);
+
public CreateProfileAction(Resource configuration) {
super(configuration);
}
});
} catch (DatabaseException e) {
-
- Logger.defaultLogError(e);
-
+ LOGGER.error("CreateProfileAction failed", e);
}
}
import org.simantics.db.common.request.WriteRequest;
import org.simantics.db.common.utils.NameUtils;
import org.simantics.db.exception.DatabaseException;
-import org.simantics.diagram.Logger;
import org.simantics.diagram.stubs.DiagramResource;
import org.simantics.layer0.Layer0;
import org.simantics.operation.Layer0X;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class CreateStyleAction extends ModelledActionImpl<Resource> {
+ private static final Logger LOGGER = LoggerFactory.getLogger(CreateStyleAction.class);
+
public CreateStyleAction(Resource configuration) {
super(configuration);
}
});
} catch (DatabaseException e) {
-
- Logger.defaultLogError(e);
-
+ LOGGER.error("CreateStyleAction failed", e);
}
}
org.simantics.diagram.ontology;bundle-version="1.0.0";visibility:=reexport,
org.simantics.structural.ontology;bundle-version="1.0.0",
org.simantics.layer0.utils;bundle-version="[1.0.0,2.0.0)",
- org.apache.log4j;bundle-version="1.2.15",
org.simantics.threadlog;bundle-version="1.0.0";resolution:=optional,
org.simantics.graph;bundle-version="1.1.5",
org.simantics.graph.db;bundle-version="1.1.5",
+++ /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.diagram;
-
-import java.util.Properties;
-
-import org.apache.log4j.Hierarchy;
-import org.apache.log4j.Level;
-import org.apache.log4j.Logger;
-import org.apache.log4j.PropertyConfigurator;
-import org.apache.log4j.spi.LoggerFactory;
-import org.apache.log4j.spi.RootLogger;
-
-/**
- * This class encapsulates a Log4J Hierarchy and centralizes all Logger access.
- */
-public class LogManager {
-
- private Hierarchy hierarchy;
-
- /**
- * Creates a new LogManager. Saves the log and state location.
- * Creates a new Hierarchy and add a new EventListener to it.
- * Configure the hierarchy with the properties passed. Add this object to
- * the list of active log managers.
- *
- * @param properties log configuration properties
- */
- public LogManager(Properties properties) {
- this.hierarchy = new Hierarchy(new RootLogger(Level.DEBUG));
- new PropertyConfigurator().doConfigure(properties, this.hierarchy);
- }
-
- /**
- * Checks if this PluginLogManager is disabled for this level.
- *
- * @param level level value
- * @return boolean true if it is disabled
- */
- public boolean isDisabled(int level) {
- return this.hierarchy.isDisabled(level);
- }
-
- /**
- * Enable logging for logging requests with level l or higher. By default
- * all levels are enabled.
- *
- * @param level level object
- */
- public void setThreshold(Level level) {
- this.hierarchy.setThreshold(level);
- }
-
- /**
- * The string version of setThreshold(Level level)
- *
- * @param level level string
- */
- public void setThreshold(String level) {
- this.hierarchy.setThreshold(level);
- }
-
- /**
- * Get the repository-wide threshold.
- *
- * @return Level
- */
- public Level getThreshold() {
- return this.hierarchy.getThreshold();
- }
-
- /**
- * Returns a new logger instance named as the first parameter using the
- * default factory. If a logger of that name already exists, then it will be
- * returned. Otherwise, a new logger will be instantiated and then linked
- * with its existing ancestors as well as children.
- *
- * @param clazz the class to get the logger for
- * @return Logger
- */
- public Logger getLogger(Class<?> clazz) {
- return this.hierarchy.getLogger(clazz.getName());
- }
-
- /**
- * Returns a new logger instance named as the first parameter using the
- * default factory. If a logger of that name already exists, then it will be
- * returned. Otherwise, a new logger will be instantiated and then linked
- * with its existing ancestors as well as children.
- *
- * @param name logger name
- * @return Logger
- */
- public Logger getLogger(String name) {
- return this.hierarchy.getLogger(name);
- }
-
- /**
- * The same as getLogger(String name) but using a factory instance instead
- * of a default factory.
- *
- * @param name logger name
- * @param factory factory instance
- * @return Logger
- */
- public Logger getLogger(String name, LoggerFactory factory) {
- return this.hierarchy.getLogger(name, factory);
- }
-
- /**
- * Returns the root of this hierarchy.
- *
- * @return Logger
- */
- public Logger getRootLogger() {
- return this.hierarchy.getRootLogger();
- }
-
- /**
- * Checks if this logger exists.
- *
- * @return Logger
- */
- public Logger exists(String name) {
- return this.hierarchy.exists(name);
- }
-
- /**
- * Disposes the logger hierarchy
- */
- public void shutdown() {
- this.hierarchy.shutdown();
- }
-
- /**
- * Resets configuration values to its defaults.
- */
- public void resetConfiguration() {
- this.hierarchy.resetConfiguration();
- }
-
-}
\ No newline at end of file
+++ /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.diagram;
-
-import java.util.Properties;
-
-public class Logger {
- public static final boolean ECHO = false;
- public static final Properties defaultProperties = new Properties();
- static {
- defaultProperties.put("log4j.rootCategory", "ERROR, default");
- defaultProperties.put("log4j.appender.default", "org.apache.log4j.FileAppender");
- defaultProperties.put("log4j.appender.default.File", "diagram.log");
- defaultProperties.put("log4j.appender.default.append", "false");
- defaultProperties.put("log4j.appender.default.layout", "org.apache.log4j.PatternLayout");
- defaultProperties.put("log4j.appender.default.layout.ConversionPattern", "%-6r [%15.15t] %-5p %30.30c - %m%n");
- }
- private static LogManager defaultLogManager = new LogManager(defaultProperties);
- private static final Logger defaultErrorLogger = new Logger(LogManager.class);
- private org.apache.log4j.Logger logger;
- Logger(Class<?> clazz) {
- logger = defaultLogManager.getLogger(clazz);
- }
-
- /**
- * Log a trace event.
- *
- * @param message message of the trace
- * @param exception the exception, or <code>null</code>
- */
- public void logTrace(String message, Throwable exception) {
- // Errors are much more useful with a stack trace!
- if (exception == null) {
- exception = new RuntimeException();
- }
- logger.trace(message, exception);
- }
-
- /**
- * Log an info event.
- *
- * @param message message of the info
- * @param exception the exception, or <code>null</code>
- */
- public void logInfo(String message, Throwable exception) {
- // Errors are much more useful with a stack trace!
- if (exception == null) {
- exception = new RuntimeException();
- }
- logger.info(message, exception);
- }
-
- /**
- * Log an error event.
- *
- * @param message message of the error
- * @param exception the exception, or <code>null</code>
- */
- public void logError(String message, Throwable exception) {
- // Errors are much more useful with a stack trace!
- if (exception == null) {
- exception = new RuntimeException();
- }
- logger.error(message, exception);
- }
-
- public static Logger getDefault() {
- return defaultErrorLogger;
- }
-
- public static LogManager getDefaultLogManager() {
- return defaultLogManager;
- }
- public static void defaultLogError(Throwable exception) {
- getDefault().logError(exception.getLocalizedMessage(), exception);
- if(ECHO) exception.printStackTrace();
- }
- public static void defaultLogError(String message) {
- getDefault().logError(message, null);
- if(ECHO)
- System.err.println(message);
- }
- public static void defaultLogError(String message, Throwable exception) {
- getDefault().logError(message, exception);
- if(ECHO)
- System.err.println(message);
- }
- public static void defaultLogInfo(String message) {
- getDefault().logInfo(message, null);
- if(ECHO)
- System.err.println(message);
- }
- public static void defaultLogTrace(String message) {
- getDefault().logTrace(message, null);
- if(ECHO)
- System.err.println(message);
- }
-}
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)
import org.simantics.db.layer0.variable.Variable;
import org.simantics.db.layer0.variable.Variables;
import org.simantics.db.request.Read;
-import org.simantics.diagram.Logger;
import org.simantics.diagram.content.Change;
import org.simantics.diagram.content.ConnectionUtil;
import org.simantics.diagram.content.DiagramContentChanges;
import org.simantics.utils.threads.ThreadUtils;
import org.simantics.utils.ui.ErrorLogger;
import org.simantics.utils.ui.SWTUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* CopyPasteHandler is a canvas handler for Commands.CUT, Commands.COPY and
*/
public class CopyPasteHandler extends AbstractDiagramParticipant {
+ private static final Logger LOGGER = LoggerFactory.getLogger(CopyPasteHandler.class);
+
public static final Key KEY_CUT_SELECTION_FRAME_COLOR = new KeyOf(Color.class, "CUT_SELECTION_FRAME_COLOR");
public static final Key KEY_CUT_SELECTION_CONTENT_COLOR = new KeyOf(Color.class, "CUT_SELECTION_CONTENT_COLOR");
public static final Key KEY_COPIED_SELECTION_FRAME_COLOR = new KeyOf(Color.class, "COPY_SELECTION_FRAME_COLOR");
});
}
} catch (DatabaseException e1) {
- Logger.defaultLogError(e1);
+ LOGGER.error("Monitor paste failed", e1);
}
}
return true;
import org.simantics.db.layer0.variable.Variable;
import org.simantics.db.layer0.variable.Variables;
import org.simantics.db.request.Read;
-import org.simantics.diagram.Logger;
import org.simantics.diagram.content.Change;
import org.simantics.diagram.content.ConnectionUtil;
import org.simantics.diagram.content.DiagramContentChanges;
import org.simantics.utils.threads.ThreadUtils;
import org.simantics.utils.ui.ErrorLogger;
import org.simantics.utils.ui.SWTUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* CopyPasteHandler is a canvas handler for Commands.CUT, Commands.COPY and
*/
public class CopyPasteHandler extends AbstractDiagramParticipant {
+ private static final Logger LOGGER = LoggerFactory.getLogger(CopyPasteHandler.class);
+
public static final Key KEY_CUT_SELECTION_FRAME_COLOR = new KeyOf(Color.class, "CUT_SELECTION_FRAME_COLOR");
public static final Key KEY_CUT_SELECTION_CONTENT_COLOR = new KeyOf(Color.class, "CUT_SELECTION_CONTENT_COLOR");
public static final Key KEY_COPIED_SELECTION_FRAME_COLOR = new KeyOf(Color.class, "COPY_SELECTION_FRAME_COLOR");
});
}
} catch (DatabaseException e1) {
- Logger.defaultLogError(e1);
+ LOGGER.error("Monitor paste failed", e1);
}
}
return true;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.simantics.db.Session;
import org.simantics.db.exception.DatabaseException;
-import org.simantics.diagram.Logger;
import org.simantics.diagram.adapter.GraphToDiagramSynchronizer;
import org.simantics.g2d.diagram.DiagramHints;
-import org.simantics.g2d.diagram.DiagramMutator;
import org.simantics.g2d.diagram.DiagramUtils;
import org.simantics.g2d.diagram.IDiagram;
import org.simantics.g2d.diagram.participant.AbstractDiagramParticipant;
import org.simantics.scenegraph.g2d.snap.ISnapAdvisor;
import org.simantics.ui.dnd.LocalObjectTransfer;
import org.simantics.ui.dnd.LocalObjectTransferable;
-import org.simantics.utils.datastructures.Callback;
import org.simantics.utils.logging.TimeLogger;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
abstract public class PopulateSelectionDropParticipant extends AbstractDiagramParticipant implements IDropTargetParticipant {
+ private static final Logger LOGGER = LoggerFactory.getLogger(PopulateSelectionDropParticipant.class);
+
public abstract List<ElementClassDragItem> getElements(Session session, IStructuredSelection selection) throws DatabaseException;
protected GraphToDiagramSynchronizer synchronizer;
}
- } catch (UnsupportedFlavorException e) {
- Logger.defaultLogError(e);
- } catch (IOException e) {
- Logger.defaultLogError(e);
- } catch (DatabaseException e) {
- Logger.defaultLogError(e);
+ } catch (DatabaseException | IOException | UnsupportedFlavorException e) {
+ LOGGER.error("Unexpected failure", e);
}
}
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");
+ }
}
}
}
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
);
package org.simantics.document.server.request;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashSet;
import org.simantics.db.AsyncReadGraph;
import org.simantics.db.ReadGraph;
import org.simantics.db.common.procedure.adapter.TransientCacheAsyncListener;
-import org.simantics.db.common.request.AsyncReadRequest;
+import org.simantics.db.common.request.UnaryAsyncRead;
import org.simantics.db.exception.DatabaseException;
import org.simantics.db.layer0.request.VariableRead;
import org.simantics.db.layer0.variable.Variable;
super(var);
}
- @Override
- public List<JSONObject> perform(ReadGraph graph) throws DatabaseException {
-
- long s = System.nanoTime();
-
- Set<Variable> nodes = graph.syncRequest(new NodesRequest(variable), TransientCacheAsyncListener.<Set<Variable>>instance());
- HashSet<JSONObject> rs = new HashSet<JSONObject>(); // result
- if(nodes.isEmpty()) {
- return Collections.emptyList();
- }
+ static class CollectNodesRequest extends UnaryAsyncRead<Collection<Variable>, Collection<JSONObject>> {
- if(PROFILE) {
- long dura = System.nanoTime()-s;
- System.err.println("DocumentRequest1 " + System.identityHashCode(this) + " in " + 1e-6*dura + "ms. " + variable.getURI(graph));
+ public CollectNodesRequest(Collection<Variable> nodes) {
+ super(nodes);
}
- graph.syncRequest(new AsyncReadRequest() {
+ @Override
+ public void perform(AsyncReadGraph graph, AsyncProcedure<Collection<JSONObject>> procedure) {
+ HashSet<JSONObject> rs = new HashSet<JSONObject>(); // result
- @Override
- public void run(AsyncReadGraph graph) throws DatabaseException {
+ for(Variable node : parameter) {
+ graph.asyncRequest(new NodeRequest(node), new AsyncProcedure<JSONObject> () {
- for(Variable node : nodes) {
- graph.asyncRequest(new NodeRequest(node), new AsyncProcedure<JSONObject> () {
-
- @Override
- public void execute(AsyncReadGraph graph, JSONObject result) {
- synchronized (rs) {
- rs.add(result);
- }
+ @Override
+ public void execute(AsyncReadGraph graph, JSONObject result) {
+ synchronized(rs) {
+ rs.add(result);
}
+ }
- @Override
- public void exception(AsyncReadGraph graph, Throwable throwable) {
- }
+ @Override
+ public void exception(AsyncReadGraph graph, Throwable throwable) {
+ }
+
+ });
- });
-
- }
-
}
-
- });
+ procedure.execute(graph, rs);
+
+ }
+
+ }
+
+ @Override
+ public List<JSONObject> perform(ReadGraph graph) throws DatabaseException {
+
+ long s = System.nanoTime();
+
+ Set<Variable> nodes = graph.syncRequest(new NodesRequest(variable), TransientCacheAsyncListener.<Set<Variable>>instance());
+ if(nodes.isEmpty()) {
+ return Collections.emptyList();
+ }
+
+ if(PROFILE) {
+ long dura = System.nanoTime()-s;
+ System.err.println("DocumentRequest1 " + System.identityHashCode(this) + " in " + 1e-6*dura + "ms. " + variable.getURI(graph));
+ }
+ Collection<JSONObject> rs = graph.syncRequest(new CollectNodesRequest(nodes));
if(PROFILE) {
long dura = System.nanoTime()-s;
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
import java.util.Collection;
import java.util.Collections;
+import java.util.HashSet;
import java.util.Set;
import org.simantics.db.AsyncReadGraph;
import org.simantics.db.ReadGraph;
-import org.simantics.db.common.request.AsyncReadRequest;
+import org.simantics.db.common.request.UnaryAsyncRead;
import org.simantics.db.exception.DatabaseException;
import org.simantics.db.layer0.request.VariableChildren;
import org.simantics.db.layer0.request.VariableRead;
import org.simantics.utils.threads.logger.ITask;
import org.simantics.utils.threads.logger.ThreadLogger;
-import gnu.trove.set.hash.THashSet;
-
public class NodesRequest extends VariableRead<Set<Variable>> {
public NodesRequest(Variable var) {
super(var);
}
- @Override
- public Set<Variable> perform(ReadGraph graph) throws DatabaseException {
+ static class CollectNodesRequest2 extends UnaryAsyncRead<Collection<Variable>, Set<Variable>> {
- ITask task = DocumentRequest.PROFILE ? ThreadLogger.task(this) : null;
+ public CollectNodesRequest2(Collection<Variable> nodes) {
+ super(nodes);
+ }
- StructuralResource2.getInstance(graph);
- if(variable == null)
- return Collections.emptySet();
+ @Override
+ public void perform(AsyncReadGraph graph, AsyncProcedure<Set<Variable>> procedure) {
+ HashSet<Variable> rs = new HashSet<Variable>(); // result
- Set<Variable> nodes = new THashSet<Variable>();
+ for(Variable node : parameter) {
+ graph.asyncRequest(new NodesRequest2(node), new AsyncProcedure<Set<Variable>> () {
- Collection<Variable> children = graph.syncRequest(new VariableChildren(variable));
+ @Override
+ public void execute(AsyncReadGraph graph, Set<Variable> result) {
+ synchronized(rs) {
+ rs.addAll(result);
+ }
+ }
- graph.syncRequest(new AsyncReadRequest() {
+ @Override
+ public void exception(AsyncReadGraph graph, Throwable throwable) {
+ }
- @Override
- public void run(AsyncReadGraph graph) throws DatabaseException {
+ });
- for(Variable child : children) {
- graph.asyncRequest(new NodesRequest2(child), new AsyncProcedure<Set<Variable>>() {
+ }
+ procedure.execute(graph, rs);
- @Override
- public void execute(AsyncReadGraph graph, Set<Variable> result) {
- synchronized(nodes) {
- nodes.addAll(result);
- }
- }
+ }
- @Override
- public void exception(AsyncReadGraph graph, Throwable throwable) {
- }
-
- });
- }
+ }
- }
+ @Override
+ public Set<Variable> perform(ReadGraph graph) throws DatabaseException {
+
+ ITask task = DocumentRequest.PROFILE ? ThreadLogger.task(this) : null;
+
+ StructuralResource2.getInstance(graph);
+ if(variable == null)
+ return Collections.emptySet();
+
+ Collection<Variable> children = graph.syncRequest(new VariableChildren(variable));
- });
+ Set<Variable> nodes = graph.syncRequest(new CollectNodesRequest2(children));
if(DocumentRequest.PROFILE) task.finish();
Bundle-Version: 1.0.0.qualifier
Bundle-Activator: org.simantics.fileimport.Activator
Require-Bundle: org.eclipse.core.runtime,
- org.apache.log4j,
org.simantics.db,
org.simantics,
org.simantics.graphfile;bundle-version="0.1.0",
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
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;
}
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);
}
import org.simantics.db.layer0.request.PossibleModel;
import org.simantics.db.layer0.variable.Variable;
import org.simantics.db.layer0.variable.Variables;
-import org.simantics.diagram.Logger;
import org.simantics.diagram.flag.FlagUtil;
import org.simantics.diagram.stubs.DiagramResource;
import org.simantics.diagram.ui.DiagramModelHints;
import org.simantics.utils.DataContainer;
import org.simantics.utils.threads.IThreadWorkQueue;
import org.simantics.utils.ui.ErrorLogger;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* @author Antti Villberg
protected static class SelectionElement extends AdaptableHintContext {
+ private static final Logger LOGGER = LoggerFactory.getLogger(SelectionElement.class);
+
final public Resource runtime;
final public Resource element;
}
});
} catch (DatabaseException e) {
- Logger.defaultLogError(e);
+ LOGGER.error("WorkbenchSelectionElement.getContent failed for type AnyVariable", e);
}
}
else if(contentType instanceof ParentVariable) {
return (T) type.processor.sync(new ResourceRead2<Variable>(runtime, element) {
@Override
public Variable perform(ReadGraph graph) throws DatabaseException {
-
DiagramResource DIA = DiagramResource.getInstance(graph);
- ModelingResources MOD = ModelingResources.getInstance(graph);
- Layer0 L0 = Layer0.getInstance(graph);
String uri = graph.getPossibleRelatedValue(resource, DIA.RuntimeDiagram_HasVariable);
if (uri == null)
}
});
} catch (DatabaseException e) {
- Logger.defaultLogError(e);
+ LOGGER.error("WorkbenchSelectionElement.getContent failed for type ParentVariable", e);
}
}
/*******************************************************************************
- * Copyright (c) 2007, 2010 Association for Decentralized Information Management
+ * Copyright (c) 2007, 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
import org.simantics.db.layer0.request.IsLinkedTo;
import org.simantics.db.layer0.util.Layer0Utils;
import org.simantics.db.service.SerialisationSupport;
-import org.simantics.diagram.Logger;
import org.simantics.diagram.adapter.GraphToDiagramSynchronizer;
import org.simantics.diagram.content.Change;
import org.simantics.diagram.content.DiagramContentChanges;
import org.simantics.ui.selection.WorkbenchSelectionElement;
import org.simantics.ui.workbench.e4.E4WorkbenchUtils;
import org.simantics.utils.logging.TimeLogger;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* This participant populates Elements from ElementClass-resources drops
*/
public class PopulateElementDropParticipant extends AbstractDiagramParticipant implements IDropTargetParticipant {
+ private static final Logger LOGGER = LoggerFactory.getLogger(PopulateElementDropParticipant.class);
+
@Dependency PickContext pickContext;
@Dependency TransformUtil transformUtil;
});
} catch (DatabaseException e) {
- Logger.defaultLogError(e);
+ LOGGER.error("symbolDropHandler invocation failed", e);
}
return;
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.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());
}
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,
import org.simantics.db.layer0.adapter.ActionFactory;
import org.simantics.db.layer0.variable.Variable;
import org.simantics.db.layer0.variable.Variables;
-import org.simantics.diagram.Logger;
import org.simantics.scl.runtime.function.Function1;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class SCLAction implements ActionFactory {
+ private static final Logger LOGGER = LoggerFactory.getLogger(SCLAction.class);
+
final private Resource rule;
public SCLAction(ReadGraph graph, Resource rule) throws DatabaseException {
Function1<Resource, Object> function = Simantics.getSession().syncRequest(new RuleFunctionRequest(rule));
function.apply(resource);
} catch (DatabaseException e) {
- Logger.defaultLogError(e);
+ LOGGER.error("SCLActionRunnable failed to request/apply RuleFunction {}", rule, e);
}
}
import org.simantics.db.layer0.adapter.DropActionFactory;
import org.simantics.db.layer0.variable.Variable;
import org.simantics.db.layer0.variable.Variables;
-import org.simantics.diagram.Logger;
import org.simantics.scl.runtime.function.Function3;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class SCLDropAction implements DropActionFactory {
+ private static final Logger LOGGER = LoggerFactory.getLogger(SCLDropAction.class);
+
final private Resource rule;
public SCLDropAction(ReadGraph graph, Resource rule) throws DatabaseException {
Function3<Resource, Object, Integer, Object> function = Simantics.getSession().syncRequest(new RuleFunctionRequest(rule));
function.apply(target, source, operation);
} catch (DatabaseException e) {
- Logger.defaultLogError(e);
+ LOGGER.error("SCLDropActionRunnable failed to request/apply RuleFunction {}", rule, e);
}
}
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.exception.DatabaseException;
import org.simantics.db.procedure.SyncListener;
import org.simantics.db.request.Read;
+import org.simantics.db.request.ReadExt;
+import org.simantics.db.request.RequestFlags;
import org.simantics.layer0.Layer0;
import org.simantics.modeling.ModelingUtils;
import org.simantics.modeling.internal.Activator;
}
}
+ static class PossibleResourceIU extends UnaryRead<String,Resource> implements ReadExt {
+
+ public PossibleResourceIU(String parameter) {
+ super(parameter);
+ }
+
+ @Override
+ public Resource perform(ReadGraph graph) throws DatabaseException {
+ return graph.getPossibleResource(parameter);
+ }
+
+ @Override
+ public boolean isImmutable(ReadGraph graph) throws DatabaseException {
+ return false;
+ }
+
+ @Override
+ public int getType() {
+ return RequestFlags.IMMEDIATE_UPDATE;
+ }
+
+ }
+
static class ReadModuleSource extends UnaryRead<String, ModuleSource> {
public ReadModuleSource(String moduleName) {
super(moduleName);
@Override
public ModuleSource perform(ReadGraph graph) throws DatabaseException {
- Resource moduleResource = graph.getPossibleResource(parameter);
+ Resource moduleResource = graph.syncRequest(new PossibleResourceIU(parameter));
if(moduleResource == null)
return null;
Layer0 L0 = Layer0.getInstance(graph);
public void add(Resource item) {
//System.out.println("Add to group(" + this + "): " + item);
items.put(item, item);
- observer.update();
+ observer.update(style, item);
}
@Override
// new Exception().printStackTrace();
//System.out.println("Remove from group(" + this + "): " + item);
items.remove(item);
- observer.update();
+ observer.update(style, item);
}
@Override
--- /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();
}
Bundle-RequiredExecutionEnvironment: JavaSE-11
Require-Bundle: org.simantics.utils.datastructures;bundle-version="1.0.0",
org.simantics.utils.ui;bundle-version="1.0.0",
- org.apache.log4j;bundle-version="1.2.15",
org.simantics.spreadsheet;bundle-version="1.1.0",
org.simantics.db.layer0;bundle-version="1.1.0",
org.simantics.scl.runtime;bundle-version="0.1.2",
org.simantics.project;bundle-version="1.0.1";visibility:=reexport,
org.simantics.graph.db;bundle-version="1.1.5",
org.eclipse.equinox.p2.metadata;bundle-version="2.0.0",
- org.apache.log4j;bundle-version="1.2.15",
org.simantics.layer0.utils;bundle-version="1.1.0",
org.simantics.application;bundle-version="1.1.0",
org.simantics.db.indexing;bundle-version="1.1.0",
+++ /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;
-
-import java.util.Properties;
-
-import org.apache.log4j.Hierarchy;
-import org.apache.log4j.Level;
-import org.apache.log4j.Logger;
-import org.apache.log4j.PropertyConfigurator;
-import org.apache.log4j.spi.LoggerFactory;
-import org.apache.log4j.spi.RootLogger;
-
-/**
- * This class encapsulates a Log4J Hierarchy and centralizes all Logger access.
- */
-public class LogManager {
-
- private Hierarchy hierarchy;
-
- /**
- * Creates a new LogManager. Saves the log and state location.
- * Creates a new Hierarchy and add a new EventListener to it.
- * Configure the hierarchy with the properties passed. Add this object to
- * the list of active log managers.
- *
- * @param properties log configuration properties
- */
- public LogManager(Properties properties) {
- this.hierarchy = new Hierarchy(new RootLogger(Level.DEBUG));
- new PropertyConfigurator().doConfigure(properties, this.hierarchy);
- }
-
- /**
- * Checks if this PluginLogManager is disabled for this level.
- *
- * @param level level value
- * @return boolean true if it is disabled
- */
- public boolean isDisabled(int level) {
- return this.hierarchy.isDisabled(level);
- }
-
- /**
- * Enable logging for logging requests with level l or higher. By default
- * all levels are enabled.
- *
- * @param level level object
- */
- public void setThreshold(Level level) {
- this.hierarchy.setThreshold(level);
- }
-
- /**
- * The string version of setThreshold(Level level)
- *
- * @param level level string
- */
- public void setThreshold(String level) {
- this.hierarchy.setThreshold(level);
- }
-
- /**
- * Get the repository-wide threshold.
- *
- * @return Level
- */
- public Level getThreshold() {
- return this.hierarchy.getThreshold();
- }
-
- /**
- * Returns a new logger instance named as the first parameter using the
- * default factory. If a logger of that name already exists, then it will be
- * returned. Otherwise, a new logger will be instantiated and then linked
- * with its existing ancestors as well as children.
- *
- * @param clazz the class to get the logger for
- * @return Logger
- */
- public Logger getLogger(Class<?> clazz) {
- return this.hierarchy.getLogger(clazz.getName());
- }
-
- /**
- * Returns a new logger instance named as the first parameter using the
- * default factory. If a logger of that name already exists, then it will be
- * returned. Otherwise, a new logger will be instantiated and then linked
- * with its existing ancestors as well as children.
- *
- * @param name logger name
- * @return Logger
- */
- public Logger getLogger(String name) {
- return this.hierarchy.getLogger(name);
- }
-
- /**
- * The same as getLogger(String name) but using a factory instance instead
- * of a default factory.
- *
- * @param name logger name
- * @param factory factory instance
- * @return Logger
- */
- public Logger getLogger(String name, LoggerFactory factory) {
- return this.hierarchy.getLogger(name, factory);
- }
-
- /**
- * Returns the root of this hierarchy.
- *
- * @return Logger
- */
- public Logger getRootLogger() {
- return this.hierarchy.getRootLogger();
- }
-
- /**
- * Checks if this logger exists.
- *
- * @return Logger
- */
- public Logger exists(String name) {
- return this.hierarchy.exists(name);
- }
-
- /**
- * Disposes the logger hierarchy
- */
- public void shutdown() {
- this.hierarchy.shutdown();
- }
-
- /**
- * Resets configuration values to its defaults.
- */
- public void resetConfiguration() {
- this.hierarchy.resetConfiguration();
- }
-
-}
\ No newline at end of file
import org.simantics.db.management.SingleSessionContextProviderSource;
import org.simantics.db.request.ReadInterface;
import org.simantics.db.request.WriteInterface;
+import org.simantics.db.service.XSupport;
import org.simantics.internal.FileServiceImpl;
import org.simantics.layer0.Layer0;
import org.simantics.project.IProject;
}
}
+ public static void saveQueries(Session session) {
+ try {
+ XSupport xs = session.getService(XSupport.class);
+ xs.saveQueries();
+ } catch (Exception e) {
+ LOGGER.error("Saving database queries failed.", e);
+ }
+ }
@SuppressWarnings({ "unchecked", "rawtypes" })
public static <T> T applySCL(String module, String function, Object ... args) throws DatabaseException {
} catch (Throwable t) {
LOGGER.error("Failed to flush index caches.", t);
}
+
+ if("true".equals(System.getProperty("org.simantics.db.persistQueries"))) {
+ progress.subTask("Saving Queries");
+ Simantics.saveQueries(s);
+ }
}
progress.subTask("Close Database Session");
version="0.0.0"
unpack="false"/>
- <plugin
- id="org.apache.log4j"
- download-size="0"
- install-size="0"
- version="0.0.0"
- unpack="false"/>
-
<plugin
id="org.eclipse.ui.browser"
download-size="0"
version="0.0.0"
unpack="false"/>
+ <plugin
+ id="org.apache.log4j"
+ download-size="0"
+ install-size="0"
+ version="0.0.0"
+ unpack="false"/>
+
</feature>
<td>\r
</td></tr>\r
<tr>\r
-<td> <a rel="nofollow" class="external text" href="http://www.cs.wustl.edu/~schmidt/ACE.html">ACE - Adaptive Communications Environment</a>\r
-</td>\r
-<td> <a href="#BSD_3-Clause_License">BSD 3-Clause License</a> (<a rel="nofollow" class="external free" href="http://www.cs.wustl.edu/~schmidt/ACE-copying.html">http://www.cs.wustl.edu/~schmidt/ACE-copying.html</a>)\r
-</td>\r
-<td> <pre>Copyright (c) 2000-2005 INRIA, France Telecom</pre>\r
-</td></tr>\r
-<tr>\r
-<td> <a rel="nofollow" class="external text" href="http://www.jcraft.com/jzlib/">JZlib</a>\r
-</td>\r
-<td> <a href="#BSD_3-Clause_License">BSD 3-Clause License</a> (<a rel="nofollow" class="external free" href="http://www.jcraft.com/jzlib/LICENSE.txt">http://www.jcraft.com/jzlib/LICENSE.txt</a>)\r
-</td>\r
-<td> <pre>Copyright (c) 2000,2001,2002,2003,2004 ymnk, JCraft,Inc.</pre>\r
-</td></tr>\r
-<tr>\r
<td> <a rel="nofollow" class="external text" href="http://xmlgraphics.apache.org/batik/">Batik</a> (org.apache.batik)\r
</td>\r
<td> <a href="#Apache_Software_License_2.0">Apache Software License 2.0</a>\r
<td> 1.2.3\r
</td></tr>\r
<tr>\r
-<td> <a rel="nofollow" class="external text" href="http://www.json.org/">JSON</a> (JSON_libraries)\r
+<td> <a rel="nofollow" class="external text" href="https://github.com/google/gson">Gson</a>\r
</td>\r
<td> <a href="#Apache_Software_License_2.0">Apache Software License 2.0</a>\r
</td>\r
<td>\r
</td></tr>\r
<tr>\r
-<td> <a rel="nofollow" class="external text" href="http://www.jfree.org/jcommon/">JCommon</a>, <a rel="nofollow" class="external text" href="http://www.jfree.org/jfreechart/">JFreeChart</a>\r
+<td><a rel="nofollow" class="external text" href="http://www.jfree.org/jfreechart/">JFreeChart</a>\r
</td>\r
<td> <a href="#LGPL">LGPL</a>\r
</td>\r
<td>\r
</td></tr>\r
<tr>\r
-<td valign="top"> <a rel="nofollow" class="external text" href="http://trove4j.sourceforge.net/">GNU Trove</a> (gnu.trove2, gnu.trove3)\r
+<td valign="top"> <a rel="nofollow" class="external text" href="http://trove4j.sourceforge.net/">GNU Trove</a> (gnu.trove3)\r
</td>\r
<td valign="top"> <a href="#LGPL">LGPL</a>\r
</td>\r
</td>\r
<td> <a href="#Eclipse_Public_License">EPL</a>\r
</td>\r
-<td> 9.2.0\r
+<td> 10.2.0\r
</td></tr>\r
<tr>\r
<td> <a rel="nofollow" class="external text" href="http://fastutil.di.unimi.it/">fastutil: Fast & compact type-specific collections for Java</a>\r
<td> 21.0\r
</td></tr>\r
<tr>\r
-<td> <a rel="nofollow" class="external text" href="http://aries.apache.org/Apache">Aries</a>\r
+<td valign="top"> <a rel="nofollow" class="external text" href="http://www.antlr3.org/">ANTLR v3</a>\r
</td>\r
-<td> <a href="#Apache_Software_License_2.0">Apache Software License 2.0</a>\r
+<td> <a href="#BSD_3-Clause_License">BSD 3-Clause License</a> (<a rel="nofollow" class="external free" href="http://www.antlr3.org/license.html">http://www.antlr3.org/license.html</a>)\r
</td>\r
-<td>\r
+<td> 3.5.2\r
+<pre>Copyright (c) 2010 Terence Parr</pre>\r
</td></tr>\r
<tr>\r
<td valign="top"> <a rel="nofollow" class="external text" href="http://hc.apache.org/httpclient-3.x/">Apache Commons Codec</a>\r
<td> 3.6.1\r
</td></tr>\r
<tr>\r
-<td valign="top"> <a rel="nofollow" class="external text" href="http://hc.apache.org/httpclient-3.x/">Apache HttpClient 3</a>\r
-</td>\r
-<td> <a href="#Apache_Software_License_2.0">Apache Software License 2.0</a>\r
-</td>\r
-<td> 3.1.0\r
-</td></tr>\r
-<tr>\r
<td valign="top"> <a rel="nofollow" class="external text" href="https://poi.apache.org/">Apache POI</a>\r
</td>\r
<td> <a href="#Apache_Software_License_2.0">Apache Software License 2.0</a>\r
<td> 3.15\r
</td></tr>\r
<tr>\r
-<td valign="top"> <a rel="nofollow" class="external text" href="http://www.antlr3.org/">ANTLR v3</a>\r
-</td>\r
-<td> <a href="#BSD_3-Clause_License">BSD 3-Clause License</a> (<a rel="nofollow" class="external free" href="http://www.antlr3.org/license.html">http://www.antlr3.org/license.html</a>)\r
-</td>\r
-<td> 3.5.2\r
-<pre>Copyright (c) 2010 Terence Parr</pre>\r
-</td></tr>\r
-<tr>\r
<td valign="top"> <a rel="nofollow" class="external text" href="https://lucene.apache.org/core/">Apache Lucene Core</a>\r
</td>\r
<td> <a href="#Apache_Software_License_2.0">Apache Software License 2.0</a>\r
<td> 2.6.0, only needed by Apache POI\r
</td></tr>\r
<tr>\r
+<td> <a rel="nofollow" class="external text" href="http://aries.apache.org/">Aries</a>\r
+</td>\r
+<td> <a href="#Apache_Software_License_2.0">Apache Software License 2.0</a>\r
+</td>\r
+<td>\r
+</td></tr>\r
+<tr>\r
<td valign="top"> <a rel="nofollow" class="external text" href="https://github.com/virtuald/curvesapi">curvesapi</a>\r
</td>\r
<td> <a href="#BSD_3-Clause_License">BSD 3-Clause License</a> (<a rel="nofollow" class="external free" href="https://github.com/virtuald/curvesapi/blob/master/license.txt">https://github.com/virtuald/curvesapi/blob/master/license.txt</a>), <a href="#Apache_Software_License_2.0">Apache Software License 2.0</a>\r
<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>
<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>
<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"/>
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
<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"/>
org.simantics.db.management;bundle-version="0.8.0",
gnu.trove3;bundle-version="3.0.3",
org.simantics.fastlz;bundle-version="1.0.0",
- org.apache.log4j;bundle-version="1.2.15",
org.simantics.db.impl;bundle-version="0.8.0",
org.simantics.db.layer0;bundle-version="0.8.0",
org.simantics.project;bundle-version="1.0.1",
<property name="classes.dir" value="classes.dir" />
<property name="databoard.jar" value="org.simantics.databoard_0.5.2.jar" />
<property name="trove.jar" value="gnu.trove2_2.0.4.jar" />
- <property name="log4j.jar" value="org.apache.log4j_1.2.15.20080201.jar" />
<property name="db.jar" value="db-connector-${version}.jar" />
<property name="installer.jar" value="installer.jar" />
- <property name="classpath-javac" value="${installer.dir}${db.jar}:${installer.dir}${databoard.jar}:${installer.dir}${trove.jar}:${installer.dir}${log4j.jar}" />
- <property name="classpath-manifest" value="${db.jar} ${databoard.jar} ${trove.jar} ${log4j.jar}" />
+ <property name="classpath-javac" value="${installer.dir}${db.jar}:${installer.dir}${databoard.jar}:${installer.dir}${trove.jar}" />
+ <property name="classpath-manifest" value="${db.jar} ${databoard.jar} ${trove.jar}" />
<target name="clean">
<delete dir="${classes.dir}" quiet="true" />
<target name="trove.dir" if="plugin.dir">
<copy file="${plugin.dir}${trove.jar}" toDir="${installer.dir}" />
</target>
-
- <target name="log4j.jar" if="plugin.dir">
- <copy file="${plugin.dir}${log4j.jar}" toDir="${installer.dir}" />
- </target>
<target name="db.jar" depends="clean">
<property name="origin.dir" value="../"/>
<include name="eclipse/plugins/org.eclipse.osgi_*.jar" />
<include name="external/plugins/gnu.trove*.jar" />
<include name="external/plugins/org.apache.commons.collections_*.jar" />
- <include name="external/plugins/org.apache.log4j_*.jar" />
<include name="external/plugins/org.apache.commons.io_*.jar" />
<include name="simantics/plugins/org.simantics.databoard_*.jar" />
<include name="simantics/plugins/org.simantics.db.layer0_*.jar" />