1 /*******************************************************************************
2 * Copyright (c) 2007, 2018 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.request.PossibleURIVariable;
49 import org.simantics.db.layer0.request.VariableName;
50 import org.simantics.db.layer0.request.VariableRead;
51 import org.simantics.db.layer0.variable.ProxyVariables;
52 import org.simantics.db.layer0.variable.Variable;
53 import org.simantics.db.layer0.variable.Variables;
54 import org.simantics.db.procedure.SyncListener;
55 import org.simantics.db.request.Write;
56 import org.simantics.db.service.SessionEventSupport;
57 import org.simantics.layer0.Layer0;
58 import org.simantics.simulator.toolkit.StandardRealm;
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.syncRequest(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(SyncListenerSupport 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.syncRequest(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) {
460 processor.syncRequest(new ReadRequest() {
463 public void run(ReadGraph graph) throws DatabaseException {
465 Variable cellVariable = run.getPossibleChild(graph, location);
466 if(cellVariable != null) {
467 final Resource config = cellVariable.getPossiblePropertyValue(graph, "Represents");
470 graph.asyncRequest(new WriteRequest() {
473 public void perform(WriteGraph graph) throws DatabaseException {
475 Layer0 l0 = Layer0.getInstance(graph);
476 // SpreadsheetResource sr = SpreadsheetResource.getInstance(graph);
477 graph.deny(config, l0.PartOf);
478 // graph.deny(config, sr.RowOf);
479 // graph.deny(config, sr.ColumnOf);
491 } catch (DatabaseException e) {
492 LOGGER.error("Unexpected exception while removing cell", e);
499 } else if(CellEditor.class == clazz) {
501 return (T)new CellEditor<Write>() {
504 public <E> void edit(Transaction<Write> transaction, String location, String property, E value, Binding binding, Consumer<?> callback) {
506 if (ClientModel.ITERATION_ENABLED.equals(location)) {
507 Simantics.getSession().asyncRequest(new ReadRequest() {
509 public void run(ReadGraph graph) throws DatabaseException {
510 getBook(graph).setIterationEnabled((boolean)value);
516 if (ClientModel.MODE.equals(location)) {
517 if (ClientModel.MODE_CURRENT.equals(property)) {
518 client.setProperty(location, property, value);
524 if (ClientModel.CONTEXT.equals(location)) {
525 if(ClientModel.CONTEXT_CURRENT.equals(property)) {
526 if(value instanceof String) {
528 Variable newContext = processor.syncRequest(new UnaryRead<String, Variable>((String)value) {
531 public Variable perform(ReadGraph graph) throws DatabaseException {
533 String sheetName = run.getName(graph);
535 Variable book = Variables.getContext(graph, run);
536 Resource bookResource = book.getRepresents(graph);
538 Variable input = Variables.getVariable(graph, parameter);
539 Variable proxy = ProxyVariables.makeProxyVariable(graph, Variables.getVariable(graph, bookResource), input);
541 return proxy.getChild(graph, sheetName);
543 // return variable.getParent(graph).getChild(graph, parameter);
548 load(newContext, client);
550 } catch (DatabaseException e) {
551 LOGGER.error("edit failed for model key '" + ClientModel.CONTEXT_CURRENT + "'", e);
557 if(ClientModel.SHEETS.equals(location)) {
558 if(ClientModel.SHEETS_CURRENT.equals(property)) {
560 if(value instanceof String) {
564 Variable newInput = processor.syncRequest(new UnaryRead<String, Variable>((String)value) {
567 public Variable perform(ReadGraph graph) throws DatabaseException {
568 return run.getParent(graph).getChild(graph, parameter);
573 load(newInput, client);
575 } catch (DatabaseException e) {
576 LOGGER.error("edit failed for model key '" + ClientModel.SHEETS_CURRENT + "'", e);
582 if(ClientModel.STATES.equals(location)) {
583 if(ClientModel.STATES_CURRENT.equals(property)) {
584 if(value instanceof String) {
585 final String parameter = (String) value;
588 String uri = processor.syncRequest(new WriteResultRequest<String>() {
591 public String perform(WriteGraph graph) throws DatabaseException {
593 Map<String, Resource> states = graph.syncRequest(new SpreadsheetStates(run));
595 Resource state = null;
596 for (Map.Entry<String, Resource> entry : states.entrySet()) {
597 if (entry.getKey().equals(parameter)) {
598 state = entry.getValue();
603 Variable context = Variables.getContext(graph, run);
604 Resource bookResource = context.getRepresents(graph);
605 SpreadsheetGraphUtils.setDefaultInitialConditionForBook(graph, bookResource, state);
607 String contextURI = context.getURI(graph);
609 String sessionName = context.getParent(graph).getURI(graph);
610 SpreadsheetSessionManager.getInstance().removeRealm(graph, sessionName);
611 SpreadsheetSessionManager.getInstance().getOrCreateRealm(graph, sessionName);
614 return run.getURI(graph);
617 Variable newInput = processor.syncRequest(new PossibleURIVariable(uri));
618 load(newInput, client);
619 // fullSynchronize();
621 } catch (DatabaseException e) {
622 LOGGER.error("edit failed for model key '" + ClientModel.STATES_CURRENT + "'", e);
628 if(ClientModel.SOURCES.equals(location)) {
629 if(ClientModel.SOURCES_CURRENT.equals(property)) {
631 Resource res = WorkbenchSelectionUtils.getPossibleResource(value);
634 Variable newInput = processor.syncRequest(new ResourceRead<Variable>(res) {
637 public Variable perform(ReadGraph graph) throws DatabaseException {
638 Variable base = ProxyVariables.proxyVariableBase(graph, run);
639 Variable in = Variables.getVariable(graph, resource);
640 currentSource = in.getURI(graph);
641 return ProxyVariables.makeProxyVariable(graph, base, in);
646 load(newInput, client);
650 } else if(value instanceof String) {
652 Variable newInput = processor.syncRequest(new UnaryRead<String, Variable>((String)value) {
655 public Variable perform(ReadGraph graph) throws DatabaseException {
657 Variable base = ProxyVariables.proxyVariableBase(graph, run);
658 Map<String,Variable> sources = graph.syncRequest(new Sources(base));
660 Variable found = sources.get(parameter);
661 if(found == null) return null;
663 currentSource = parameter;
665 return ProxyVariables.makeProxyVariable(graph, base, found);
671 load(newInput, client);
675 } catch (DatabaseException e) {
676 LOGGER.error("edit failed for model key '" + ClientModel.SOURCES_CURRENT + "'", e);
681 boolean needsCommit = false;
682 if (transaction == null) {
683 OperationMode mode = client.getPropertyAt(ClientModel.MODE, ClientModel.MODE_CURRENT);
684 transaction = startTransaction(mode);
685 // if (mode.equals(OperationMode.OPERATION))
686 transaction.setContext(run);
689 final Transaction<Write> finalTransaction = transaction;
690 cellEditor.edit(transaction, location, property, value, binding, new Consumer<Object>() {
693 public void accept(Object param) {
694 if (finalTransaction.needSynchronization() != null)
695 synchronize(finalTransaction.needSynchronization());
699 transaction.commit();
703 public void edit(Transaction<Write> transaction, String location, Variant variant, Consumer<?> callback) {
704 boolean needsCommit = false;
705 if (transaction == null) {
706 OperationMode mode = client.getPropertyAt(ClientModel.MODE, ClientModel.MODE_CURRENT);
707 transaction = startTransaction(mode);
708 // if (mode.equals(OperationMode.OPERATION))
709 transaction.setContext(run);
712 final Transaction<Write> finalTransaction = transaction;
713 cellEditor.edit(transaction, location, variant, new Consumer<Object>() {
716 public void accept(Object param) {
717 if (finalTransaction.needSynchronization() != null)
718 synchronize(finalTransaction.needSynchronization());
722 transaction.commit();
726 public void copy(final Transaction<Write> transaction, String location, MutableVariant variant, Consumer<?> callback) {
727 cellEditor.edit(transaction, location, variant, new Consumer<Object>() {
730 public void accept(Object param) {
731 if (transaction.needSynchronization() != null)
732 synchronize(transaction.needSynchronization());
738 public Transaction<Write> startTransaction(OperationMode mode) {
739 return cellEditor.startTransaction(mode);
744 } else if (SheetCommands.class == clazz ) {
746 return (T) new SheetCommands() {
749 public void saveState() {
751 Simantics.getSession().asyncRequest(new ReadRequest() {
754 public void run(ReadGraph graph) throws DatabaseException {
755 IEclipseContext context = PlatformUI.getWorkbench().getService(IEclipseContext.class);
757 Resource uiContextResource = run.getRepresents(graph);
758 Resource bookResource = Variables.getContext(graph, run).getRepresents(graph);
759 Layer0 L0 = Layer0.getInstance(graph);
760 String uiContextName = graph.getRelatedValue2(uiContextResource, L0.HasName, Bindings.STRING);
761 String bookName = graph.getRelatedValue2(bookResource, L0.HasName, Bindings.STRING);
763 UISynchronize synchronizer = context.get(UISynchronize.class);
764 synchronizer.asyncExec(() -> {
765 Pair<String, Resource>[] pairs = new Pair[] {Pair.make(uiContextName, uiContextResource), Pair.make(bookName, bookResource) };
766 SaveSpreadsheetStateDialog dialog = new SaveSpreadsheetStateDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor().getSite(), "Save Spreadsheet state", pairs);
767 if (dialog.open() == Dialog.OK) {
768 Object[] result = dialog.getSelection();
769 if (result != null) {
770 Pair<Resource, String> p = (Pair<Resource, String>) result[0];
771 Simantics.getSession().asyncRequest(new WriteRequest() {
774 public void perform(WriteGraph graph) throws DatabaseException {
776 Variable parent = run.getParent(graph);
777 Variable base = ProxyVariables.proxyVariableBase(graph, parent);
778 SpreadsheetGraphUtils.saveInitialCondition(graph, parent, p.first, p.second);
797 public void exception(Throwable t) {
798 LOGGER.error("Failed to read properties.", t);
802 public boolean isDisposed() {
807 public void exception(AsyncReadGraph graph, Throwable t) {
808 LOGGER.error("Failed to read properties.", t);
812 public void exception(ReadGraph graph, Throwable t) {
813 LOGGER.error("Failed to read properties.", t);
816 public void dispose() {
817 for (PropertyListener listener : listenerCache.values())
820 listenerCache.clear();
821 SessionEventSupport support = processor.getService(SessionEventSupport.class);
822 support.removeListener(listener);
826 private void synchronize(List<Object> list) {
827 Simantics.getSession().asyncRequest(new FullSynchronizeBook(run, list));
830 public static class FullSynchronizeBook extends ReadRequest {
832 private final Variable run;
833 private final List<Object> location;
835 public FullSynchronizeBook(Variable run, List<Object> cellLocation) {
837 this.location = cellLocation;
841 public void run(ReadGraph graph) throws DatabaseException {
842 String uri = run.getURI(graph);
843 String parentUri = run.getParent(graph).getURI(graph);
844 System.err.println("Full sync for book " + parentUri);
846 Resource sheetResource = run.getRepresents(graph);
847 Variable sheetVariable = Variables.getVariable(graph, sheetResource);
849 TObjectIntHashMap<Variable> changes = null;
850 if (location != null) {
851 changes = new TObjectIntHashMap<>(location.size());
852 for (Object loc : location) {
853 Variable var = (Variable) loc;
857 SpreadsheetGraphUtils.partialSynchronization(graph, run.getParent(graph), changes);
862 private SpreadsheetBook getBook(ReadGraph graph) throws DatabaseException {
863 String sessionName = run.getParent(graph).getParent(graph).getURI(graph);
864 StandardRealm<SheetNode, SpreadsheetBook> realm = SpreadsheetSessionManager.getInstance().getOrCreateRealm(graph, sessionName);
865 SpreadsheetBook book = realm.getEngine();