1 /*******************************************************************************
2 * Copyright (c) 2007, 2011 Association for Decentralized Information Management in
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.history;
15 import java.io.IOException;
16 import java.io.InputStream;
17 import java.io.OutputStream;
19 import org.simantics.databoard.binding.Binding;
20 import org.simantics.history.impl.CollectorImpl;
21 import org.simantics.history.impl.FileHistory;
22 import org.simantics.history.impl.FlushPolicy;
23 import org.simantics.history.impl.MemoryHistory;
24 import org.simantics.history.util.HistoryExportUtil;
27 * Facade-class for History Services.
29 * There are two main services HistoryManager and Collector.
30 * There are two main implementations file and memory.
32 * @author toni.kalajainen
34 public class History {
37 * Open a file based history manager.
38 * (Note, Trend does not need flush policy)
41 * @return history manager
43 public static HistoryManager openFileHistory(File workarea)
45 return new FileHistory(workarea);
49 * Create a transient memory history
53 public static HistoryManager createMemoryHistory()
55 return new MemoryHistory();
61 * @param historyManager
64 public static Collector createCollector(HistoryManager historyManager)
66 CollectorImpl result = new CollectorImpl(historyManager);
73 * @param historyManager
77 public static Collector createCollector(HistoryManager historyManager, FlushPolicy flushPolicy)
79 CollectorImpl result = new CollectorImpl(historyManager);
80 result.setFlushPolicy(flushPolicy);
85 * Export whole history manager to an output stream.
93 * @throws HistoryException
95 public static void exportHistory( HistoryManager history, Binding timeBinding, Double from, Double end, OutputStream os )
96 throws IOException, HistoryException
98 HistoryExportUtil eu = new HistoryExportUtil();
99 eu.exportHistory(history, timeBinding, from, end, os);
103 * Import a history manager from an input stream
107 * @throws IOException
108 * @throws HistoryException
110 public static void importHistory( HistoryManager history, InputStream is )
111 throws IOException, HistoryException
113 HistoryExportUtil eu = new HistoryExportUtil();
114 eu.importHistory(history, is);