1 /*******************************************************************************
\r
2 * Copyright (c) 2007, 2011 Association for Decentralized Information Management in
\r
4 * All rights reserved. This program and the accompanying materials
\r
5 * are made available under the terms of the Eclipse Public License v1.0
\r
6 * which accompanies this distribution, and is available at
\r
7 * http://www.eclipse.org/legal/epl-v10.html
\r
10 * VTT Technical Research Centre of Finland - initial API and implementation
\r
11 *******************************************************************************/
\r
12 package org.simantics.history;
\r
14 import java.io.File;
\r
15 import java.io.IOException;
\r
16 import java.io.InputStream;
\r
17 import java.io.OutputStream;
\r
19 import org.simantics.databoard.binding.Binding;
\r
20 import org.simantics.history.impl.CollectorImpl;
\r
21 import org.simantics.history.impl.FileHistory;
\r
22 import org.simantics.history.impl.FlushPolicy;
\r
23 import org.simantics.history.impl.MemoryHistory;
\r
24 import org.simantics.history.util.HistoryExportUtil;
\r
27 * Facade-class for History Services.
\r
29 * There are two main services HistoryManager and Collector.
\r
30 * There are two main implementations file and memory.
\r
32 * @author toni.kalajainen
\r
34 public class History {
\r
37 * Open a file based history manager.
\r
38 * (Note, Trend does not need flush policy)
\r
41 * @return history manager
\r
43 public static HistoryManager openFileHistory(File workarea)
\r
45 return new FileHistory(workarea);
\r
49 * Create a transient memory history
\r
51 * @return no history
\r
53 public static HistoryManager createMemoryHistory()
\r
55 return new MemoryHistory();
\r
61 * @param historyManager
\r
64 public static Collector createCollector(HistoryManager historyManager)
\r
66 CollectorImpl result = new CollectorImpl(historyManager);
\r
73 * @param historyManager
\r
74 * @param flushPolicy
\r
77 public static Collector createCollector(HistoryManager historyManager, FlushPolicy flushPolicy)
\r
79 CollectorImpl result = new CollectorImpl(historyManager);
\r
80 result.setFlushPolicy(flushPolicy);
\r
85 * Export whole history manager to an output stream.
\r
88 * @param timeBinding
\r
92 * @throws IOException
\r
93 * @throws HistoryException
\r
95 public static void exportHistory( HistoryManager history, Binding timeBinding, Double from, Double end, OutputStream os )
\r
96 throws IOException, HistoryException
\r
98 HistoryExportUtil eu = new HistoryExportUtil();
\r
99 eu.exportHistory(history, timeBinding, from, end, os);
\r
103 * Import a history manager from an input stream
\r
107 * @throws IOException
\r
108 * @throws HistoryException
\r
110 public static void importHistory( HistoryManager history, InputStream is )
\r
111 throws IOException, HistoryException
\r
113 HistoryExportUtil eu = new HistoryExportUtil();
\r
114 eu.importHistory(history, is);
\r