1 /*******************************************************************************
2 * Copyright (c) 2007, 2010 Association for Decentralized Information Management
4 * All rights reserved. This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License v1.0
6 * which accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
10 * VTT Technical Research Centre of Finland - initial API and implementation
11 *******************************************************************************/
12 package org.simantics.spreadsheet.graph;
14 import java.util.ArrayList;
15 import java.util.Collection;
16 import java.util.Collections;
17 import java.util.List;
19 import java.util.function.Consumer;
21 import org.eclipse.e4.core.contexts.IEclipseContext;
22 import org.eclipse.e4.ui.di.UISynchronize;
23 import org.eclipse.jface.dialogs.Dialog;
24 import org.eclipse.ui.PlatformUI;
25 import org.simantics.Simantics;
26 import org.simantics.databoard.Bindings;
27 import org.simantics.databoard.binding.Binding;
28 import org.simantics.databoard.binding.mutable.MutableVariant;
29 import org.simantics.databoard.binding.mutable.Variant;
30 import org.simantics.db.AsyncReadGraph;
31 import org.simantics.db.ReadGraph;
32 import org.simantics.db.RequestProcessor;
33 import org.simantics.db.Resource;
34 import org.simantics.db.WriteGraph;
35 import org.simantics.db.common.procedure.adapter.AsyncListenerSupport;
36 import org.simantics.db.common.procedure.adapter.ListenerSupport;
37 import org.simantics.db.common.procedure.adapter.SyncListenerSupport;
38 import org.simantics.db.common.procedure.adapter.TransientCacheAsyncListener;
39 import org.simantics.db.common.procedure.single.SingleSetSyncListenerDelegate;
40 import org.simantics.db.common.request.ReadRequest;
41 import org.simantics.db.common.request.ResourceRead;
42 import org.simantics.db.common.request.UnaryRead;
43 import org.simantics.db.common.request.UniqueRead;
44 import org.simantics.db.common.request.WriteRequest;
45 import org.simantics.db.common.request.WriteResultRequest;
46 import org.simantics.db.common.session.SessionEventListenerAdapter;
47 import org.simantics.db.exception.DatabaseException;
48 import org.simantics.db.layer0.StandardRealm;
49 import org.simantics.db.layer0.request.PossibleURIVariable;
50 import org.simantics.db.layer0.request.VariableName;
51 import org.simantics.db.layer0.request.VariableRead;
52 import org.simantics.db.layer0.variable.ProxyVariables;
53 import org.simantics.db.layer0.variable.Variable;
54 import org.simantics.db.layer0.variable.Variables;
55 import org.simantics.db.procedure.SyncListener;
56 import org.simantics.db.request.Write;
57 import org.simantics.db.service.SessionEventSupport;
58 import org.simantics.layer0.Layer0;
59 import org.simantics.spreadsheet.Adaptable;
60 import org.simantics.spreadsheet.CellEditor;
61 import org.simantics.spreadsheet.ClientModel;
62 import org.simantics.spreadsheet.ClientModel.OperationMode;
63 import org.simantics.spreadsheet.SheetCommands;
64 import org.simantics.spreadsheet.event.model.RemoveCellHandler;
65 import org.simantics.spreadsheet.resource.SpreadsheetResource;
66 import org.simantics.ui.selection.WorkbenchSelectionUtils;
67 import org.simantics.utils.datastructures.Pair;
68 import org.simantics.utils.strings.AlphanumComparator;
69 import org.simantics.utils.threads.logger.ITask;
70 import org.simantics.utils.threads.logger.ThreadLogger;
71 import org.slf4j.Logger;
72 import org.slf4j.LoggerFactory;
74 import gnu.trove.map.hash.THashMap;
75 import gnu.trove.map.hash.TObjectIntHashMap;
77 class FilteredVariableProperties extends UnaryRead<Variable, Collection<Pair<String,Variable>>> {
79 final static String CLASSIFICATION = SpreadsheetResource.URIs.Attribute;
81 public FilteredVariableProperties(Variable variable) {
86 public Collection<Pair<String,Variable>> perform(ReadGraph graph) throws DatabaseException {
87 ArrayList<Pair<String,Variable>> result = new ArrayList<Pair<String,Variable>>();
88 for(Variable var : parameter.getProperties(graph, CLASSIFICATION)) {
89 String name = var.getName(graph);
90 String uri = var.getURI(graph);
91 result.add(Pair.make(name, var));
92 Variable expression = var.getPossibleProperty(graph, "expression");
93 if(expression != null)
94 result.add(Pair.make(name + "#expression", expression));
95 Variable editable = var.getPossibleProperty(graph, "editable");
97 result.add(Pair.make(name + "#editable", editable));
104 public class GraphUI implements Adaptable, ListenerSupport, AsyncListenerSupport, SyncListenerSupport {
106 private static final Logger LOGGER = LoggerFactory.getLogger(GraphUI.class);
108 final public static boolean DEBUG = false;
110 final private RequestProcessor processor;
112 private CellEditor<Write> cellEditor;
114 private Variable run;
115 private ClientModel client;
117 private Map<String, PropertyListener> listenerCache = new THashMap<>();
119 public GraphUI(RequestProcessor processor) {
120 this.processor = processor;
123 public void addCell(ReadGraph graph, Pair<String, Variable> child, final ClientModel client) throws DatabaseException {
125 if(DEBUG) System.out.println("GraphUI adds cell " + child.second.getURI(graph));
127 final String childName = child.second.getName(graph);
128 Boolean immutable = child.second.getPossiblePropertyValue(graph, "immutable", Bindings.BOOLEAN);
129 if(immutable != null && immutable) {
130 Collection<Variable> properties = child.second.getProperties(graph, FilteredVariableProperties.CLASSIFICATION);
131 addProperties(graph, properties, client, childName);
133 PropertyListener listener = listenerCache.get(child.first);
134 if (listener == null) {
135 listener = propertyListener(client, childName);
136 listenerCache.put(child.first, listener);
138 graph.asyncRequest(new FilteredVariableProperties(child.second), listener);
143 public void removeCell(ReadGraph graph, Pair<String, Variable> child, final ClientModel client) throws DatabaseException {
145 if(DEBUG) System.out.println("GraphUI removed cell " + child.first);
147 client.clear(child.first);
148 PropertyListener listener = listenerCache.remove(child.first);
149 if (listener != null)
154 public void loadCells(ReadGraph graph, Variable container, boolean immutable, final ClientModel client) throws DatabaseException {
156 if(DEBUG) System.out.println("GraphUI loads cells from " + container.getURI(graph));
159 for(Pair<String, Variable> cell : graph.syncRequest(new Cells(container), TransientCacheAsyncListener.<Collection<Pair<String, Variable>>>instance())) {
160 addCell(graph, cell, client);
163 graph.syncRequest(new Cells(container), new SingleSetSyncListenerDelegate<Pair<String, Variable>>(GraphUI.this) {
166 public void add(ReadGraph graph, final Pair<String, Variable> child) throws DatabaseException {
167 addCell(graph, child, client);
171 public void remove(ReadGraph graph, final Pair<String, Variable> child) throws DatabaseException {
172 removeCell(graph, child, client);
179 private SessionEventListenerAdapter listener;
181 private String currentSource;
183 private boolean disposed;
185 public Resource load(final Variable variable, final ClientModel client) throws DatabaseException {
187 // for (PropertyListener listener : listenerCache.values())
188 // listener.dispose();
190 // listenerCache.clear();
194 assert(variable != null);
197 this.client = client;
199 SessionEventSupport support = processor.getService(SessionEventSupport.class);
201 for (PropertyListener listener : listenerCache.values()) {
204 listenerCache.clear();
207 support.removeListener(listener);
209 listener = new SessionEventListenerAdapter() {
212 public void writeTransactionFinished() {
218 support.addListener(listener);
220 this.cellEditor = processor.sync(new VariableRead<CellEditor<Write>>(variable) {
223 public CellEditor<Write> perform(ReadGraph graph) throws DatabaseException {
224 SpreadsheetResource SHEET = SpreadsheetResource.getInstance(graph);
225 return variable.getPropertyValue(graph, SHEET.cellEditor);
230 final ITask task = ThreadLogger.getInstance().begin("GraphUI.init");
234 Map<String,Variable> sources = processor.syncRequest(new Sources(variable));
236 List<String> sheetList = processor.syncRequest(new Sheets(variable));
237 String currentSheet = processor.syncRequest(new VariableName(variable));
239 Map<String, Resource> stateList = processor.syncRequest(new SpreadsheetStates(variable));
241 if(currentSource == null) currentSource = "Sheet";
243 ArrayList<String> sourceList = new ArrayList<String>(sources.keySet());
245 Collections.sort(sourceList, AlphanumComparator.CASE_INSENSITIVE_COMPARATOR);
246 if(!sourceList.contains(currentSource)) sourceList.add(currentSource);
248 client.setProperty(ClientModel.SOURCES, ClientModel.SOURCES_AVAILABLE, sourceList.toArray(new String[sourceList.size()]));
249 client.setProperty(ClientModel.SOURCES, ClientModel.SOURCES_CURRENT, currentSource);
251 client.setProperty(ClientModel.SHEETS, ClientModel.SHEETS_AVAILABLE, sheetList.toArray(new String[sheetList.size()]));
252 client.setProperty(ClientModel.SHEETS, ClientModel.SHEETS_CURRENT, currentSheet);
254 client.setProperty(ClientModel.STATES, ClientModel.STATES_AVAILABLE, stateList.keySet().toArray(new String[stateList.size()]));
256 client.setProperty(ClientModel.CONTEXT, ClientModel.CONTEXT_CURRENT, variable);
258 client.setProperty(ClientModel.MODE, ClientModel.MODE_CURRENT, OperationMode.OPERATION);
260 String currentState = processor.syncRequest(new UniqueRead<String>() {
263 public String perform(ReadGraph graph) throws DatabaseException {
264 Resource book = variable.getParent(graph).getRepresents(graph);
265 Resource ic = graph.getPossibleObject(book, SpreadsheetResource.getInstance(graph).Book_HasDefaultInitialCondition);
268 return graph.getRelatedValue2(ic, Layer0.getInstance(graph).HasName, Bindings.STRING);
272 client.setProperty(ClientModel.STATES, ClientModel.STATES_CURRENT, currentState);
274 processor.syncRequest(new ReadRequest() {
277 public void run(ReadGraph graph) throws DatabaseException {
279 loadCells(graph, variable, false, client);
281 graph.syncRequest(new Ranges(variable), new SingleSetSyncListenerDelegate<Variable>(GraphUI.this) {
284 public void add(ReadGraph graph, final Variable range) throws DatabaseException {
286 if(DEBUG) System.out.println("GraphUI adds range " + range.getURI(graph));
288 Boolean immutable = range.getPossiblePropertyValue(graph, "immutable", Bindings.BOOLEAN);
289 loadCells(graph, range, immutable != null && immutable, client);
294 public void remove(ReadGraph graph, final Variable range) throws DatabaseException {
301 graph.syncRequest(new SheetLines(variable), new SingleSetSyncListenerDelegate<Variable>(GraphUI.this) {
304 public void add(ReadGraph graph, final Variable range) throws DatabaseException {
306 if(DEBUG) System.out.println("GraphUI adds line " + range.getURI(graph));
308 Boolean immutable = range.getPossiblePropertyValue(graph, "immutable", Bindings.BOOLEAN);
309 loadCells(graph, range, immutable != null && immutable, client);
314 public void remove(ReadGraph graph, final Variable range) throws DatabaseException {
322 // public void remove(ReadGraph graph, Variable child) throws DatabaseException {
324 // String location = locations.get(cellResource);
325 // assert(location != null);
327 // client.setProperty(location, "Label", null);
328 // client.setProperty(location, "Expression", null);
342 private static class PropertyListener extends SingleSetSyncListenerDelegate<Pair<String,Variable>> {
344 private static final Logger LOGGER = LoggerFactory.getLogger(PropertyListener.class);
346 private ClientModel client;
347 private String childName;
348 private boolean listenerDisposed;
350 public PropertyListener(AsyncListenerSupport support, ClientModel client, String childName) {
352 this.client = client;
353 this.childName = childName;
357 public void add(ReadGraph graph, final Pair<String,Variable> property) throws DatabaseException {
360 System.out.println("GraphUI adds property " + property.second.getURI(graph));
362 graph.asyncRequest(new CellValue(property.second), new SyncListener<Object>() {
365 public void execute(ReadGraph graph, final Object value) throws DatabaseException {
367 String propertyName = property.first;
370 System.out.println("GraphUI detected content change(1) at " + childName + " - " + propertyName + " -> " + value);
371 client.setProperty(childName, propertyName, value);
376 public void exception(ReadGraph graph, Throwable throwable) throws DatabaseException {
378 LOGGER.error("PropertyListener.exception", throwable);
380 String propertyName = property.first;
381 if("content".equals(propertyName)) {
382 if(throwable == null) throwable = new Exception();
383 String message = throwable.getMessage();
384 if(message == null) message = throwable.toString();
385 client.setProperty(childName, propertyName, Variant.ofInstance(message));
387 client.setProperty(childName, propertyName, null);
393 public boolean isDisposed() {
394 return listenerDisposed;
400 public void dispose() {
401 listenerDisposed = true;
405 public String toString() {
406 return super.toString() + ":" + childName;
411 private PropertyListener propertyListener(final ClientModel client, final String childName) {
412 return new PropertyListener(this, client, childName);
415 private void addProperties(ReadGraph graph, final Collection<Variable> properties, final ClientModel client, final String childName) throws DatabaseException {
417 for(Variable property : properties) {
419 if(DEBUG) System.out.println("GraphUI adds immutable property " + property.getURI(graph));
421 final String propertyName = property.getName(graph);
423 Object value = property.getValue(graph);
425 if(DEBUG) System.out.println("GraphUI detected change at " + childName + " - " + propertyName + " -> " + value);
426 client.setProperty(childName, propertyName, value);
428 String expression = property.getPossiblePropertyValue(graph, "expression", Bindings.STRING);
429 if(expression != null) {
430 if(DEBUG) System.out.println("GraphUI detected change at " + childName + " - " + (propertyName + "#expression") + " -> " + value);
431 client.setProperty(childName, propertyName + "#expression", expression);
434 Boolean editable = property.getPossiblePropertyValue(graph, "editable", Bindings.STRING);
435 if(editable != null) {
436 if(DEBUG) System.out.println("GraphUI detected change at " + childName + " - " + (propertyName + "#editable") + " -> " + value);
437 client.setProperty(childName, propertyName + "#editable", editable);
444 @SuppressWarnings("unchecked")
446 public <T> T getAdapter(Class<T> clazz) {
448 if(Variable.class == clazz) {
452 } else if(RemoveCellHandler.class == clazz) {
454 return (T) new RemoveCellHandler() {
457 public void handle(final String location) {
459 processor.asyncRequest(new ReadRequest() {
462 public void run(ReadGraph graph) throws DatabaseException {
464 Variable cellVariable = run.getPossibleChild(graph, location);
465 if(cellVariable != null) {
466 final Resource config = cellVariable.getPossiblePropertyValue(graph, "Represents");
469 graph.asyncRequest(new WriteRequest() {
472 public void perform(WriteGraph graph) throws DatabaseException {
474 Layer0 l0 = Layer0.getInstance(graph);
475 // SpreadsheetResource sr = SpreadsheetResource.getInstance(graph);
476 graph.deny(config, l0.PartOf);
477 // graph.deny(config, sr.RowOf);
478 // graph.deny(config, sr.ColumnOf);
495 } else if(CellEditor.class == clazz) {
497 return (T)new CellEditor<Write>() {
500 public <E> void edit(Transaction<Write> transaction, String location, String property, E value, Binding binding, Consumer<?> callback) {
502 if (ClientModel.ITERATION_ENABLED.equals(location)) {
503 Simantics.getSession().asyncRequest(new ReadRequest() {
505 public void run(ReadGraph graph) throws DatabaseException {
506 getBook(graph).setIterationEnabled((boolean)value);
512 if (ClientModel.MODE.equals(location)) {
513 if (ClientModel.MODE_CURRENT.equals(property)) {
514 client.setProperty(location, property, value);
520 if (ClientModel.CONTEXT.equals(location)) {
521 if(ClientModel.CONTEXT_CURRENT.equals(property)) {
522 if(value instanceof String) {
524 Variable newContext = processor.syncRequest(new UnaryRead<String, Variable>((String)value) {
527 public Variable perform(ReadGraph graph) throws DatabaseException {
529 String sheetName = run.getName(graph);
531 Variable book = Variables.getContext(graph, run);
532 Resource bookResource = book.getRepresents(graph);
534 Variable input = Variables.getVariable(graph, parameter);
535 Variable proxy = ProxyVariables.makeProxyVariable(graph, Variables.getVariable(graph, bookResource), input);
537 return proxy.getChild(graph, sheetName);
539 // return variable.getParent(graph).getChild(graph, parameter);
544 load(newContext, client);
546 } catch (DatabaseException e) {
547 LOGGER.error("edit failed for model key '" + ClientModel.CONTEXT_CURRENT + "'", e);
553 if(ClientModel.SHEETS.equals(location)) {
554 if(ClientModel.SHEETS_CURRENT.equals(property)) {
556 if(value instanceof String) {
560 Variable newInput = processor.syncRequest(new UnaryRead<String, Variable>((String)value) {
563 public Variable perform(ReadGraph graph) throws DatabaseException {
564 return run.getParent(graph).getChild(graph, parameter);
569 load(newInput, client);
571 } catch (DatabaseException e) {
572 LOGGER.error("edit failed for model key '" + ClientModel.SHEETS_CURRENT + "'", e);
578 if(ClientModel.STATES.equals(location)) {
579 if(ClientModel.STATES_CURRENT.equals(property)) {
580 if(value instanceof String) {
581 final String parameter = (String) value;
584 String uri = processor.syncRequest(new WriteResultRequest<String>() {
587 public String perform(WriteGraph graph) throws DatabaseException {
589 Map<String, Resource> states = graph.syncRequest(new SpreadsheetStates(run));
591 Resource state = null;
592 for (Map.Entry<String, Resource> entry : states.entrySet()) {
593 if (entry.getKey().equals(parameter)) {
594 state = entry.getValue();
599 Variable context = Variables.getContext(graph, run);
600 Resource bookResource = context.getRepresents(graph);
601 SpreadsheetGraphUtils.setDefaultInitialConditionForBook(graph, bookResource, state);
603 String contextURI = context.getURI(graph);
605 String sessionName = context.getParent(graph).getURI(graph);
606 SpreadsheetSessionManager.getInstance().removeRealm(graph, sessionName);
607 SpreadsheetSessionManager.getInstance().getOrCreateRealm(graph, sessionName);
610 return run.getURI(graph);
613 Variable newInput = processor.syncRequest(new PossibleURIVariable(uri));
614 load(newInput, client);
615 // fullSynchronize();
617 } catch (DatabaseException e) {
618 LOGGER.error("edit failed for model key '" + ClientModel.STATES_CURRENT + "'", e);
624 if(ClientModel.SOURCES.equals(location)) {
625 if(ClientModel.SOURCES_CURRENT.equals(property)) {
627 Resource res = WorkbenchSelectionUtils.getPossibleResource(value);
630 Variable newInput = processor.syncRequest(new ResourceRead<Variable>(res) {
633 public Variable perform(ReadGraph graph) throws DatabaseException {
634 Variable base = ProxyVariables.proxyVariableBase(graph, run);
635 Variable in = Variables.getVariable(graph, resource);
636 currentSource = in.getURI(graph);
637 return ProxyVariables.makeProxyVariable(graph, base, in);
642 load(newInput, client);
646 } else if(value instanceof String) {
648 Variable newInput = processor.syncRequest(new UnaryRead<String, Variable>((String)value) {
651 public Variable perform(ReadGraph graph) throws DatabaseException {
653 Variable base = ProxyVariables.proxyVariableBase(graph, run);
654 Map<String,Variable> sources = graph.syncRequest(new Sources(base));
656 Variable found = sources.get(parameter);
657 if(found == null) return null;
659 currentSource = parameter;
661 return ProxyVariables.makeProxyVariable(graph, base, found);
667 load(newInput, client);
671 } catch (DatabaseException e) {
672 LOGGER.error("edit failed for model key '" + ClientModel.SOURCES_CURRENT + "'", e);
677 boolean needsCommit = false;
678 if (transaction == null) {
679 OperationMode mode = client.getPropertyAt(ClientModel.MODE, ClientModel.MODE_CURRENT);
680 transaction = startTransaction(mode);
681 // if (mode.equals(OperationMode.OPERATION))
682 transaction.setContext(run);
685 final Transaction<Write> finalTransaction = transaction;
686 cellEditor.edit(transaction, location, property, value, binding, new Consumer<Object>() {
689 public void accept(Object param) {
690 if (finalTransaction.needSynchronization() != null)
691 synchronize(finalTransaction.needSynchronization());
695 transaction.commit();
699 public void edit(Transaction<Write> transaction, String location, Variant variant, Consumer<?> callback) {
700 boolean needsCommit = false;
701 if (transaction == null) {
702 OperationMode mode = client.getPropertyAt(ClientModel.MODE, ClientModel.MODE_CURRENT);
703 transaction = startTransaction(mode);
704 // if (mode.equals(OperationMode.OPERATION))
705 transaction.setContext(run);
708 final Transaction<Write> finalTransaction = transaction;
709 cellEditor.edit(transaction, location, variant, new Consumer<Object>() {
712 public void accept(Object param) {
713 if (finalTransaction.needSynchronization() != null)
714 synchronize(finalTransaction.needSynchronization());
718 transaction.commit();
722 public void copy(final Transaction<Write> transaction, String location, MutableVariant variant, Consumer<?> callback) {
723 cellEditor.edit(transaction, location, variant, new Consumer<Object>() {
726 public void accept(Object param) {
727 if (transaction.needSynchronization() != null)
728 synchronize(transaction.needSynchronization());
734 public Transaction<Write> startTransaction(OperationMode mode) {
735 return cellEditor.startTransaction(mode);
740 } else if (SheetCommands.class == clazz ) {
742 return (T) new SheetCommands() {
745 public void saveState() {
747 Simantics.getSession().asyncRequest(new ReadRequest() {
750 public void run(ReadGraph graph) throws DatabaseException {
751 IEclipseContext context = PlatformUI.getWorkbench().getService(IEclipseContext.class);
753 Resource uiContextResource = run.getRepresents(graph);
754 Resource bookResource = Variables.getContext(graph, run).getRepresents(graph);
755 Layer0 L0 = Layer0.getInstance(graph);
756 String uiContextName = graph.getRelatedValue2(uiContextResource, L0.HasName, Bindings.STRING);
757 String bookName = graph.getRelatedValue2(bookResource, L0.HasName, Bindings.STRING);
759 UISynchronize synchronizer = context.get(UISynchronize.class);
760 synchronizer.asyncExec(() -> {
761 Pair<String, Resource>[] pairs = new Pair[] {Pair.make(uiContextName, uiContextResource), Pair.make(bookName, bookResource) };
762 SaveSpreadsheetStateDialog dialog = new SaveSpreadsheetStateDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor().getSite(), "Save Spreadsheet state", pairs);
763 if (dialog.open() == Dialog.OK) {
764 Object[] result = dialog.getSelection();
765 if (result != null) {
766 Pair<Resource, String> p = (Pair<Resource, String>) result[0];
767 Simantics.getSession().asyncRequest(new WriteRequest() {
770 public void perform(WriteGraph graph) throws DatabaseException {
772 Variable parent = run.getParent(graph);
773 Variable base = ProxyVariables.proxyVariableBase(graph, parent);
774 SpreadsheetGraphUtils.saveInitialCondition(graph, parent, p.first, p.second);
793 public void exception(Throwable t) {
798 public boolean isDisposed() {
803 public void exception(AsyncReadGraph graph, Throwable t) {
804 LOGGER.error("Failed to read properties.", t);
808 public void exception(ReadGraph graph, Throwable t) {
809 LOGGER.error("Failed to read properties.", t);
812 public void dispose() {
813 for (PropertyListener listener : listenerCache.values())
816 listenerCache.clear();
817 SessionEventSupport support = processor.getService(SessionEventSupport.class);
818 support.removeListener(listener);
822 private void synchronize(List<Object> list) {
823 Simantics.getSession().asyncRequest(new FullSynchronizeBook(run, list));
826 public static class FullSynchronizeBook extends ReadRequest {
828 private final Variable run;
829 private final List<Object> location;
831 public FullSynchronizeBook(Variable run, List<Object> cellLocation) {
833 this.location = cellLocation;
837 public void run(ReadGraph graph) throws DatabaseException {
838 String uri = run.getURI(graph);
839 String parentUri = run.getParent(graph).getURI(graph);
840 System.err.println("Full sync for book " + parentUri);
842 Resource sheetResource = run.getRepresents(graph);
843 Variable sheetVariable = Variables.getVariable(graph, sheetResource);
845 TObjectIntHashMap<Variable> changes = null;
846 if (location != null) {
847 changes = new TObjectIntHashMap<>(location.size());
848 for (Object loc : location) {
849 Variable var = (Variable) loc;
853 SpreadsheetGraphUtils.partialSynchronization(graph, run.getParent(graph), changes);
858 private SpreadsheetBook getBook(ReadGraph graph) throws DatabaseException {
859 String sessionName = run.getParent(graph).getParent(graph).getURI(graph);
860 StandardRealm<SheetNode, SpreadsheetBook> realm = SpreadsheetSessionManager.getInstance().getOrCreateRealm(graph, sessionName);
861 SpreadsheetBook book = realm.getEngine();