import org.eclipse.jface.wizard.WizardPage;\r
import org.eclipse.swt.SWT;\r
import org.eclipse.swt.custom.CCombo;\r
+import org.eclipse.swt.custom.ScrolledComposite;\r
import org.eclipse.swt.events.ModifyListener;\r
import org.eclipse.swt.events.SelectionAdapter;\r
import org.eclipse.swt.events.SelectionEvent;\r
\r
@Override\r
public void createControl(Composite parent) {\r
- Composite container = new Composite(parent, SWT.NONE);\r
+ ScrolledComposite scroller = new ScrolledComposite(parent, SWT.V_SCROLL);\r
+ scroller.setExpandHorizontal(true);\r
+ scroller.setExpandVertical(true);\r
+\r
+ Composite container = new Composite(scroller, SWT.NONE);\r
+ scroller.setContent(container);\r
GridLayoutFactory.swtDefaults().spacing(20, 10).numColumns(3).applyTo(container);\r
new Label(container, SWT.NONE).setText("Select a model:");\r
model = new CCombo(container, SWT.BORDER);\r
item = new Table(container, SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION | SWT.CHECK);\r
{\r
item.setToolTipText("Selects the Subscription Items");\r
- GridDataFactory.fillDefaults().grab(true, false).span(2, 1).hint(SWT.DEFAULT, 105).applyTo(item);\r
+ GridDataFactory.fillDefaults().grab(true, true).span(2, 1).hint(SWT.DEFAULT, 105).applyTo(item);\r
}\r
item.addSelectionListener(new SelectionAdapter() {\r
@Override\r
\r
model.addSelectionListener(s);\r
\r
- setControl(container);\r
+ scroller.setMinSize(container.computeSize(SWT.DEFAULT, SWT.DEFAULT));\r
+\r
+ setControl(scroller);\r
validatePage();\r
\r
}\r
mon.worked(1);\r
}\r
}\r
-\r
- s.release();\r
-\r
} catch (DatabaseException e) {\r
- throw new IllegalStateException(e);\r
+ Logger.defaultLogError("DatabaseException occured during initializing index", e);\r
+ } catch (Throwable t) {\r
+ Logger.defaultLogError("Fatal error occured during initializing index", t);\r
+ } finally {\r
+ s.release();\r
}\r
- \r
}\r
- \r
});\r
- \r
}\r
- \r
try {\r
s.acquire(INDEXING_THREAD_COUNT);\r
} catch (InterruptedException e) {\r
e.printStackTrace();\r
}\r
- \r
}\r
- \r
});\r
\r
// http://www.gossamer-threads.com/lists/lucene/java-dev/47895\r
// Map<Long, Map<String,byte[]>> metadatas = getMetadatas(graph, support, revisionId, Long.MAX_VALUE);\r
\r
for(Map.Entry<Long, Map<String,byte[]>> e : metadatas.entrySet()) {\r
-// System.err.println("metadata " + e.getKey() + " " + e.getValue());\r
-// long csid = e.getKey();\r
+\r
Map<String,byte[]> metadata = e.getValue();\r
-// if(metadata == null) \r
-// continue;\r
-// if(metadata != null) {\r
- \r
-// for(ChangeSetIdentifier csi : csis) {\r
-// if(csi.getId() < fromRevision) { // TODO remove this test when DB api is fixed\r
-// System.err.println("ManagementSupport.getChangeSetIdentifiers returned identifiers outside of the requested range.");\r
-// continue;\r
-// }\r
-// Map<String,byte[]> metadata = getMetadata(graph, support, csi);\r
-// if(metadata == null) \r
-// continue;\r
- \r
+\r
browseChanges: {\r
byte[] changesData = metadata.get(DependencyChanges.class.getName());\r
if(changesData == null || changesData.length == 0) \r
visitor.visit(graph, change, inverted);\r
}\r
\r
- browseUndos: {\r
- byte[] undoMetadata = metadata.get(UndoMetadata.class.getName());\r
- if(undoMetadata == null || undoMetadata.length == 0) \r
- break browseUndos;\r
+ byte[] undoMetadata = metadata.get(UndoMetadata.class.getName());\r
+ if(undoMetadata != null && undoMetadata.length != 0) { \r
UndoMetadata undo = UndoMetadata.deserialise(graph.getSession(), undoMetadata);\r
visitDependencyChangesBetween(graph, model, undo.getBeginCSId(), undo.getEndCSId(), visitor, \r
undo.isRedo() ? inverted : !inverted);\r
}\r
}\r
- }\r
+ }\r
\r
-// public static Map<Resource, Collection<Change>> getDependencyChangeIndexFrom(ReadGraph graph, long revisionId) throws DatabaseException {\r
-//\r
-// \r
-// \r
-// Map<Resource, Collection<Change>> index = new HashMap<Resource, Collection<Change>>();\r
-//\r
-// for(Map<Resource, Collection<Change>> entry : getDependencyChangesFrom(graph, revisionId)) {\r
-// if(DEBUG) System.out.println("getDependencyChangeIndexFrom process " + entry);\r
-// Collection<DependencyChangeEntry> list = index.get(entry.getOwner());\r
-// if(list == null) {\r
-// list = new ArrayList<DependencyChangeEntry>();\r
-// index.put(entry.getOwner(), list);\r
-// }\r
-// list.add(entry);\r
-// }\r
-// \r
-// return index;\r
-// \r
-// }\r
- \r
}\r
public void clear() {\r
clusterSets.clear();\r
}\r
+ \r
+ @Override\r
+ public void setReadDirectory(Path read) {\r
+ // TODO Auto-generated method stub\r
+ \r
+ }\r
@Override\r
- public void updateReadAndWriteDirectories(Path read, Path write) {\r
+ public void updateWriteDirectory(Path write) {\r
// Nothing to do here\r
}\r
\r
\r
final private static boolean DEBUG = false;\r
final private static Map<String, ClusterSets> sClusterSets = new HashMap<String, ClusterSets>();\r
- private Path writeDirectory;\r
private Path readDirectory;\r
+ private Path writeDirectory;\r
private String databaseId; // Unique identifier for database of session. Initialized in connect. \r
private ClusterSets clusterSets; // Cluster sets for session. Initialized in connect.\r
public ClusterSetsSupportImpl2() {\r
clusterSets.clear();\r
}\r
@Override\r
- public void updateReadAndWriteDirectories(Path read, Path write) {\r
- setDirectories(read, write);\r
- }\r
- \r
- private void setDirectories(Path readDirectory, Path writeDirectory) {\r
- this.readDirectory = readDirectory;\r
- this.writeDirectory = writeDirectory;\r
+ public void updateWriteDirectory(Path write) {\r
+ this.writeDirectory = write;\r
if(clusterSets != null) {\r
clusterSets.setWriteDirectory(writeDirectory.toFile());\r
clusterSets.touch();\r
}\r
}\r
\r
+ @Override\r
+ public void setReadDirectory(Path read) {\r
+ this.readDirectory = read;\r
+ }\r
+\r
}\r
import org.simantics.databoard.serialization.Serializer;\r
import org.simantics.db.ChangeSetIdentifier;\r
import org.simantics.db.Database;\r
-import org.simantics.db.Operation;\r
-import org.simantics.db.SessionReference;\r
import org.simantics.db.Database.Session.ChangeSetData;\r
import org.simantics.db.Database.Session.ChangeSetIds;\r
import org.simantics.db.Database.Session.ClusterChanges;\r
import org.simantics.db.Database.Session.ClusterIds;\r
import org.simantics.db.Database.Session.Refresh;\r
+import org.simantics.db.Operation;\r
+import org.simantics.db.SessionReference;\r
import org.simantics.db.common.UndoContextEx;\r
import org.simantics.db.common.utils.Logger;\r
import org.simantics.db.exception.DatabaseException;\r
import org.simantics.scl.runtime.function.FunctionImpl1;\r
import org.simantics.utils.threads.ThreadUtils;\r
\r
-import fi.vtt.simantics.procore.ProCoreSessionReference;\r
import gnu.trove.iterator.TLongObjectIterator;\r
import gnu.trove.map.hash.THashMap;\r
import gnu.trove.map.hash.TLongObjectHashMap;\r
clusters[i] = new ClusterUID(first[i], second[i]);\r
return clusters;\r
}\r
+ public boolean rolledback() {\r
+ return dbSession.rolledback();\r
+ }\r
}\r
class BuiltinData {\r
final long id;\r
public boolean refreshEnabled() {\r
return false;\r
}\r
+ @Override\r
+ public boolean rolledback() {\r
+ return false;\r
+ }\r
}\r
private AtomicLong changeSetId = new AtomicLong(Constants.NullChangeSetId);\r
private AtomicLong transactionId = new AtomicLong(Constants.NullTransactionId);\r
package fi.vtt.simantics.procore.internal;\r
\r
import java.io.File;\r
-import java.io.IOException;\r
\r
import org.simantics.db.Database;\r
import org.simantics.db.SessionManager;\r
import org.simantics.db.impl.query.QuerySupport;\r
import org.simantics.db.service.ServerInformation;\r
\r
-import fi.vtt.simantics.procore.BackdoorAuthenticator;\r
-\r
final public class SessionImplDb extends SessionImplSocket {\r
\r
/**\r
this.clusterControl = new ClusterControlImpl(this);\r
serviceLocator.registerService(ClusterControl.class, clusterControl);\r
this.clusterSetsSupport = new ClusterSetsSupportImpl2(); // Using same path as virtual graphs.\r
- this.clusterSetsSupport.updateReadAndWriteDirectories(t.toPath(), t.toPath());\r
+ this.clusterSetsSupport.setReadDirectory(t.toPath());\r
+ this.clusterSetsSupport.updateWriteDirectory(t.toPath());\r
serviceLocator.registerService(ClusterSetsSupport.class, clusterSetsSupport);\r
}\r
\r
// This is used by QueryProcessor among others.\r
String databaseId = GraphSessionVirtual.serverInfo.databaseId;\r
String serverId = GraphSessionVirtual.serverInfo.serverId;\r
- virtualGraphServerSupport.connect(databaseId + "." + serverId);\r
- virtualGraphImpl = (VirtualGraphImpl)virtualGraphServerSupport.getWorkspacePersistent("virtualGraph" + "." + serverId);\r
try {\r
+ virtualGraphServerSupport.connect(databaseId + "." + serverId);\r
+ virtualGraphImpl = (VirtualGraphImpl)virtualGraphServerSupport.getWorkspacePersistent("virtualGraph" + "." + serverId);\r
requestManager = new SessionRequestManager(this, state);\r
clusterStream = new ClusterStream(this, graphSession, true);\r
clusterTranslator = new ClusterTranslatorImpl(this);\r
import org.simantics.db.service.ServerInformation;\r
import org.simantics.db.service.TransferableGraphSupport;\r
import org.simantics.db.service.VirtualGraphSupport;\r
+import org.simantics.db.service.XSupport;\r
import org.simantics.layer0.Layer0;\r
import org.simantics.utils.FileUtils;\r
\r
this.virtualGraphStoragePath = path;\r
}\r
\r
- void connect(String dbString) {\r
+ void connect(String dbString) throws Exception {\r
+ virtualId = new AtomicInteger(-2);\r
+ this.dbString = dbString;\r
\r
- virtualId = new AtomicInteger(-2);\r
-\r
- this.dbString = dbString;\r
+ XSupport support = session.getService(XSupport.class);\r
+ if (support.rolledback()) {\r
+ for (File file : virtualGraphStoragePath.listFiles()) {\r
+ if (!file.delete()) {\r
+ throw new IOException("Could not delete file " + file.getAbsolutePath());\r
+ }\r
+ }\r
+ }\r
\r
File file = new File(virtualGraphStoragePath, "virtualGraphs." + dbString + ".dat");\r
-\r
+ \r
// System.out.println("scanning " + file.getAbsolutePath());\r
\r
if(file.exists()) {\r
\r
hasVirtuals = true;\r
\r
+ String databaseId = session.getService(ServerInformation.class).getDatabaseId();\r
+ String matcher = ".W." + databaseId + ".vg.";\r
+ \r
// Load existing workspace persistent graphs\r
for(File virtualGraph : virtualGraphStoragePath.listFiles(new FilenameFilter() {\r
@Override\r
public boolean accept(File dir, String name) {\r
- return name.endsWith(".vg");\r
+ boolean matches = name.contains(matcher);\r
+ return matches;\r
}\r
})) {\r
String name = virtualGraph.getName();\r
Database db = session.graphSession.dbSession.getDatabase();\r
db.purgeDatabase();\r
}\r
+\r
+ @Override\r
+ public boolean rolledback() {\r
+ return session.graphSession.rolledback();\r
+ }\r
}\r
public boolean refreshEnabled() {\r
return true;\r
}\r
+ @Override\r
+ public boolean rolledback() {\r
+ return false;\r
+ }\r
}\r
class SessionManager {\r
private ConcurrentHashMap<Client, SessionI> sessionMap = new ConcurrentHashMap<Client, SessionI>();\r
\r
public <T> T clone(ClusterUID clusterUID, ClusterCreator clusterCreator) throws DatabaseException;\r
public boolean refreshEnabled();\r
+ public boolean rolledback();\r
}\r
public Session newSession(ServiceLocator locator) throws SDBException;\r
interface Journal {\r
void put(long resourceId, long clusterId);\r
void save() throws IOException;\r
void clear();\r
- void updateReadAndWriteDirectories(Path read, Path write);\r
+ void updateWriteDirectory(Path write);\r
+ void setReadDirectory(Path read);\r
\r
}\r
throws DatabaseException;\r
public void purge() throws DatabaseException;\r
\r
+ public boolean rolledback();\r
+ \r
}\r
bin.includes = META-INF/,\\r
.,\\r
OSGI-INF/,\\r
- plugin.xml\r
+ plugin.xml,\\r
+ scl/\r
OSGI-INF/FileReferenceFileImport.xml,\\r
OSGI-INF/LibraryFolderFileImport.xml,\\r
scl/\r
source.. = src/\r
+src.includes = scl/\r
return;\r
service.remove(resource.get());\r
removeResourceForPath(file);\r
+ try {\r
+ Files.delete(file);\r
+ } catch (IOException e) {\r
+ Files.delete(file);\r
+ }\r
} catch (Throwable t) {\r
if (callback.isPresent()) {\r
callback.get().accept(t);\r
import static java.nio.file.StandardWatchEventKinds.ENTRY_MODIFY;\r
import static java.nio.file.StandardWatchEventKinds.OVERFLOW;\r
\r
+import java.io.FileNotFoundException;\r
import java.io.IOException;\r
import java.io.RandomAccessFile;\r
import java.nio.file.FileSystem;\r
}\r
\r
FileImportService.performFileImport(newPath, Optional.of(t -> {\r
- if (t instanceof FileSystemException) {\r
+ if ((t instanceof FileSystemException) || (t instanceof FileNotFoundException)) {\r
try {\r
syncPath(newPath);\r
} catch (IOException e) {\r
import org.simantics.db.common.NamedResource;\r
import org.simantics.db.exception.DatabaseException;\r
import org.simantics.db.layer0.variable.Variable;\r
-import org.simantics.db.procedure.Procedure;\r
import org.simantics.modeling.typicals.TypicalUtil;\r
import org.simantics.modeling.ui.typicals.NewTypicalDiagramInstance;\r
import org.simantics.scenegraph.loader.ScenegraphLoaderUtils;\r
}\r
final Collection<NamedResource> namedTypicals = TypicalUtil.toNamedResources(session, typicals);\r
\r
- return TypicalUtil.syncExec(new Consumer<Procedure<Resource>>() {\r
- @Override\r
- public void accept(final Procedure<Resource> procedure) {\r
- NewTypicalDiagramInstance.asyncQueryFromList(namedTypicals, selectedTypical -> {\r
- if (selectedTypical == null) {\r
- procedure.execute(null);\r
- return;\r
- }\r
- try {\r
+ return TypicalUtil.syncExec(procedure -> {\r
+ NewTypicalDiagramInstance.asyncQueryFromList(namedTypicals, selectedTypical -> {\r
+ try {\r
+ if (selectedTypical != null) {\r
session.syncRequest(TypicalUtil.instantiateTemplate(target, selectedTypical, instance -> {\r
try {\r
Set<Resource> customlyNamed = new HashSet<Resource>();\r
procedure.exception(e);\r
}\r
}));\r
- } catch (Throwable e) {\r
- procedure.exception(e);\r
- } finally {\r
- procedure.execute(null);\r
}\r
- });\r
- }\r
+ } catch (Throwable e) {\r
+ procedure.exception(e);\r
+ } finally {\r
+ procedure.execute(null);\r
+ }\r
+ });\r
});\r
}\r
\r
-}
\ No newline at end of file
+}\r
\r
@Override\r
public Runnable create(Object target_) {\r
- final Resource target = (Resource) target_;\r
- return new Runnable() {\r
- @Override\r
- public void run() {\r
- Job job = new DatabaseJob("Instantiate Typical") {\r
- @Override\r
- protected IStatus run(IProgressMonitor monitor) {\r
- monitor.beginTask("Instantiate Typical...", IProgressMonitor.UNKNOWN);\r
+ Resource target = (Resource) target_;\r
+ return () -> {\r
+ Job job = new DatabaseJob("Instantiate Typical") {\r
+ @Override\r
+ protected IStatus run(IProgressMonitor monitor) {\r
+ monitor.beginTask("Instantiate Typical...", IProgressMonitor.UNKNOWN);\r
\r
- final Session session = Simantics.getSession();\r
- session.markUndoPoint();\r
- try {\r
- final AtomicReference<Resource> model = new AtomicReference<Resource>();\r
- Function2<Resource, Resource, Resource> instantiator = session.syncRequest(new UniqueRead<Function2<Resource, Resource, Resource>>() {\r
- @Override\r
- public Function2<Resource, Resource, Resource> perform(ReadGraph graph) throws DatabaseException {\r
- model.set( graph.sync(new PossibleModel(target)) );\r
- if (model.get() == null)\r
- throw new CancelTransactionException("Cannot find a model from the input selection. Typical diagram instantiation not possible.");\r
+ Session session = Simantics.getSession();\r
+ session.markUndoPoint();\r
+ try {\r
+ AtomicReference<Resource> model = new AtomicReference<Resource>();\r
+ Function2<Resource, Resource, Resource> instantiator = session.syncRequest(new UniqueRead<Function2<Resource, Resource, Resource>>() {\r
+ @Override\r
+ public Function2<Resource, Resource, Resource> perform(ReadGraph graph) throws DatabaseException {\r
+ model.set( graph.sync(new PossibleModel(target)) );\r
+ if (model.get() == null)\r
+ throw new CancelTransactionException("Cannot find a model from the input selection. Typical diagram instantiation not possible.");\r
\r
- ModelingResources MOD = ModelingResources.getInstance(graph);\r
- Function2<Resource, Resource, Resource> instantiator = graph.getRelatedValue2(model.get(), MOD.StructuralModel_typicalInstantiationFunction);\r
- return instantiator;\r
- }\r
- });\r
+ ModelingResources MOD = ModelingResources.getInstance(graph);\r
+ Function2<Resource, Resource, Resource> instantiator = graph.getRelatedValue2(model.get(), MOD.StructuralModel_typicalInstantiationFunction);\r
+ return instantiator;\r
+ }\r
+ });\r
\r
- instantiator.apply(model.get(), target);\r
+ instantiator.apply(model.get(), target);\r
\r
- return Status.OK_STATUS;\r
- } catch (CancelTransactionException e) {\r
- return new Status(IStatus.INFO , Activator.PLUGIN_ID, e.getMessage());\r
- } catch (DatabaseException e) {\r
- return new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e);\r
- } finally {\r
- monitor.done();\r
- }\r
+ return Status.OK_STATUS;\r
+ } catch (CancelTransactionException e) {\r
+ return new Status(IStatus.INFO , Activator.PLUGIN_ID, e.getMessage());\r
+ } catch (DatabaseException e) {\r
+ return new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e);\r
+ } finally {\r
+ monitor.done();\r
}\r
- };\r
- //job.setUser(true);\r
- job.schedule();\r
- }\r
+ }\r
+ };\r
+ //job.setUser(true);\r
+ job.schedule();\r
};\r
}\r
\r
import org.simantics.db.ReadGraph;\r
import org.simantics.db.Resource;\r
import org.simantics.db.WriteGraph;\r
-import org.simantics.db.common.request.ReadRequest;\r
import org.simantics.db.common.request.WriteRequest;\r
import org.simantics.db.exception.DatabaseException;\r
import org.simantics.db.layer0.request.external.EclipsePreferencePrimitiveRead;\r
import org.simantics.db.layer0.util.RemoverUtil;\r
import org.simantics.db.layer0.util.SimanticsClipboard;\r
import org.simantics.db.service.DebugSupport;\r
+import org.simantics.db.service.ServiceActivityMonitor;\r
\r
public class SCL {\r
public static void killPlatformWrite(WriteGraph graph) throws DatabaseException {\r
// but unfortunately this does not work either...\r
// so we synchronize by a familiar write transaction\r
// And then wait still some more\r
- for(int i=0;i<3;i++) {\r
- Simantics.getSession().syncRequest(new WriteRequest() {\r
- @Override\r
- public void perform(WriteGraph graph) throws DatabaseException {\r
- }\r
-\r
- @Override\r
- public String toString() {\r
- return "Utils sync";\r
- }\r
- });\r
-\r
- // And then wait still some more\r
- Simantics.getSession().syncRequest(new ReadRequest() {\r
- @Override\r
- public void run(ReadGraph graph) throws DatabaseException {\r
- }\r
- });\r
- }\r
+// for(int i=0;i<3;i++) {\r
+ Simantics.getSession().syncRequest(new WriteRequest() {\r
+ @Override\r
+ public void perform(WriteGraph graph) throws DatabaseException {\r
+ }\r
+\r
+ @Override\r
+ public String toString() {\r
+ return "Utils sync";\r
+ }\r
+ });\r
+//\r
+// // And then wait still some more\r
+// Simantics.getSession().syncRequest(new ReadRequest() {\r
+// @Override\r
+// public void run(ReadGraph graph) throws DatabaseException {\r
+// }\r
+// });\r
+// }\r
}\r
\r
public static void syncGraph() throws Exception {\r
- sync();\r
+ try {\r
+ Simantics.getSession().getService(ServiceActivityMonitor.class).waitForCompletion();\r
+ } catch (InterruptedException e) {\r
+ throw new DatabaseException(e);\r
+ }\r
\r
// OK, now the experiment activate job should be scheduled\r
// Wait for the job to finish\r
}\r
};\r
\r
- public static Collection<NamedResource> toNamedResources(RequestProcessor processor, final Collection<Resource> rs) throws DatabaseException {\r
+ public static List<NamedResource> toNamedResources(RequestProcessor processor, final Collection<Resource> rs) throws DatabaseException {\r
return toNamedResources(processor, rs, new TypicalNamingFunction());\r
}\r
\r
- public static Collection<NamedResource> toNamedResources(RequestProcessor processor, final Collection<Resource> rs, final Function2<ReadGraph, Resource, String> namingFunction) throws DatabaseException {\r
- return processor.syncRequest(new UniqueRead<Collection<NamedResource>>() {\r
+ public static List<NamedResource> toNamedResources(RequestProcessor processor, final Collection<Resource> rs, final Function2<ReadGraph, Resource, String> namingFunction) throws DatabaseException {\r
+ return processor.syncRequest(new UniqueRead<List<NamedResource>>() {\r
@Override\r
- public Collection<NamedResource> perform(ReadGraph graph) throws DatabaseException {\r
+ public List<NamedResource> perform(ReadGraph graph) throws DatabaseException {\r
return toNamedResources(graph, rs, namingFunction);\r
}\r
});\r
}\r
\r
- public static Collection<NamedResource> toNamedResources(ReadGraph graph, Collection<Resource> rs, final Function2<ReadGraph, Resource, String> namingFunction) throws DatabaseException {\r
- Collection<NamedResource> result = new ArrayList<NamedResource>(rs.size());\r
+ public static List<NamedResource> toNamedResources(ReadGraph graph, Collection<Resource> rs, final Function2<ReadGraph, Resource, String> namingFunction) throws DatabaseException {\r
+ List<NamedResource> result = new ArrayList<>(rs.size());\r
for (Resource r : rs)\r
result.add(new NamedResource(namingFunction.apply(graph, r), r));\r
return result;\r
return s;\r
}\r
\r
- public static WriteResult<Resource> instantiateTemplate(final Resource target, final NamedResource template,\r
- final Consumer<Pair<WriteGraph, Resource>> successContinuation) {\r
+ public static WriteResult<Resource> instantiateTemplate(\r
+ Resource target,\r
+ NamedResource template,\r
+ Consumer<Pair<WriteGraph, Resource>> successContinuation)\r
+ {\r
return new WriteResultRequest<Resource>() {\r
@Override\r
public Resource perform(WriteGraph graph) throws DatabaseException {\r
THashMap<String, THashMap<String, BranchPoint[]>> combined =\r
new THashMap<String, THashMap<String, BranchPoint[]>>();\r
\r
- public void addCoverage(Module module) {\r
+ public void addCoverage(Module module, boolean persistOverBranchpointReset) {\r
THashMap<String, BranchPoint[]> branchPointMap = module.getBranchPoints();\r
if(branchPointMap == null)\r
return;\r
@Override\r
public boolean execute(String name, BranchPoint[] branchPoints) {\r
BranchPoint[] oldBranchPoints = oldBranchPointMap_.get(name);\r
- if(oldBranchPoints == null)\r
- oldBranchPointMap_.put(name, branchPoints);\r
- else\r
+ if(oldBranchPoints == null) {\r
+ if (persistOverBranchpointReset) {\r
+ // Clone the branchPoints array so that if will last over a reset\r
+ BranchPoint[] clonedBranchPoints = cloneBranchPoints(branchPoints);\r
+ oldBranchPointMap_.put(name, clonedBranchPoints);\r
+ } else {\r
+ // No need to copy so resetting branchpoints will reset this as well\r
+ oldBranchPointMap_.put(name, branchPoints);\r
+ }\r
+ } else {\r
combineCounters(oldBranchPoints, branchPoints);\r
+ }\r
return true;\r
}\r
});\r
}\r
\r
+ private static BranchPoint[] cloneBranchPoints(BranchPoint[] oldBranchPoints) {\r
+ BranchPoint[] newBranchPoints = new BranchPoint[oldBranchPoints.length];\r
+ for (int i = 0; i < oldBranchPoints.length; i++) {\r
+ BranchPoint bp = oldBranchPoints[i];\r
+ BranchPoint[] children = cloneBranchPoints(bp.getChildren());\r
+ newBranchPoints[i] = new BranchPoint(bp.getLocation(), bp.getCodeSize(), children);\r
+ }\r
+ return newBranchPoints;\r
+ }\r
+ \r
private static void combineCounters(BranchPoint[] oldBranchPoints, BranchPoint[] branchPoints) {\r
if(oldBranchPoints.length != branchPoints.length)\r
throw new IllegalArgumentException("Incompatible branch points.");\r
for(int i=0;i<branchPoints.length;++i) {\r
BranchPoint oldBP = oldBranchPoints[i];\r
BranchPoint newBP = branchPoints[i];\r
- if(oldBP.location != newBP.location)\r
+ if(oldBP.getLocation() != newBP.getLocation())\r
throw new IllegalArgumentException("Incompatible branch points.");\r
- oldBP.visitCounter += newBP.visitCounter;\r
- combineCounters(oldBP.children, newBP.children);\r
+ oldBP.incrementVisitCounter(newBP.getVisitCounter());\r
+ combineCounters(oldBP.getChildren(), newBP.getChildren());\r
}\r
}\r
\r
int totalFunctionCodeSize = 0;\r
int uncoveredFunctionCodeSize = 0;\r
for(BranchPoint branchPoint : entry.getValue()) {\r
- totalFunctionCodeSize += branchPoint.codeSize;\r
+ totalFunctionCodeSize += branchPoint.getCodeSize();\r
uncoveredFunctionCodeSize += uncoveredCodeSize(branchPoint);\r
}\r
int coveredFunctionCodeSize = totalFunctionCodeSize - uncoveredFunctionCodeSize;\r
}\r
\r
private static int uncoveredCodeSize(BranchPoint branchPoint) {\r
- if(branchPoint.visitCounter == 0)\r
- return branchPoint.codeSize;\r
+ if(branchPoint.getVisitCounter() == 0)\r
+ return branchPoint.getCodeSize();\r
else {\r
int sum = 0;\r
- for(BranchPoint child : branchPoint.children)\r
+ for(BranchPoint child : branchPoint.getChildren())\r
sum += uncoveredCodeSize(child);\r
return sum;\r
}\r
for(BranchPoint bp : branchPoints) {
for(int i=0;i<ind;++i)
System.out.print(" ");
- System.out.println(bp.codeSize);
- printCoverageTree(bp.children, ind+1);
+ System.out.println(bp.getCodeSize());
+ printCoverageTree(bp.getChildren(), ind+1);
}
}
public class BranchPoint {
public static final BranchPoint[] EMPTY_ARRAY = new BranchPoint[0];
- public final long location;
- public final int codeSize;
- public final BranchPoint[] children;
+ private final long location;
+ private final int codeSize;
+ private final BranchPoint[] children;
public int visitCounter;
public void resetVisitCountersRecursively() {
visitCounter = 0;
- for(BranchPoint branchPoint : children)
+ for(BranchPoint branchPoint : getChildren())
branchPoint.resetVisitCountersRecursively();
}
+
+ public long getLocation() {
+ return location;
+ }
+
+ public int getCodeSize() {
+ return codeSize;
+ }
+
+ public int getVisitCounter() {
+ return visitCounter;
+ }
+
+ public void incrementVisitCounter(int amount) {
+ visitCounter = visitCounter + amount;
+ }
+
+ public BranchPoint[] getChildren() {
+ return children;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder();
+ sb.append("BP[visitCounter=").append(visitCounter).append(", codeSize=").append(codeSize).append(", location=").append(location);
+ if (children.length > 0)
+ sb.append(", children=").append(children.length);
+ sb.append("]");
+ return sb.toString();
+ }
+
}
try {\r
platformShutdownRunnable.run(null);\r
} catch (InvocationTargetException e) {\r
- Activator.logError(getClass().getSimpleName() + ".openWindows failed", e);\r
+ Activator.logError(getClass().getSimpleName() + ".openWindows failed", e.getCause());\r
} catch (InterruptedException e) {\r
Activator.logError(getClass().getSimpleName() + ".openWindows failed", e);\r
}\r
// 1. Assert there is a database at <workspace>/db\r
session = setupDatabase(databaseDriverId, progressMonitor, workspacePolicy, userAgent);\r
TimeLogger.log("Database setup complete");\r
-\r
+ \r
+ // 1.1 \r
+ XSupport support = session.getService(XSupport.class);\r
+ if (support.rolledback()) {\r
+ try {\r
+ DatabaseIndexing.deleteAllIndexes();\r
+ } catch (IOException e) {\r
+ throw new PlatformException(e);\r
+ }\r
+ }\r
+ \r
// 2. Assert all graphs, and correct versions, are installed to the database\r
synchronizeOntologies(progressMonitor, ontologyPolicy, requireSynchronize);\r
TimeLogger.log("Synchronized ontologies");\r