View Javadoc

1   /*
2    * This file is a part of CAST project.
3    * (c) Copyright 2007, AGH University of Science & Technology
4    * https://caribou.iisg.agh.edu.pl/trac/cast
5    *
6    * Licensed under the Eclipse Public License, Version 1.0 (the "License").
7    * You may not use this file except in compliance with the License.
8    * You may obtain a copy of the License at
9    * http://www.eclipse.org/legal/epl-v10.html
10   */
11  /*
12   * File: IPersistenceProvider.java
13   * Created: 2009-07-06
14   * Author: tmilos
15   * $Id$
16   */
17  
18  package pl.edu.agh.cast.data.persistence;
19  
20  import java.util.Collection;
21  import java.util.List;
22  import java.util.Map;
23  import java.util.UUID;
24  
25  import org.eclipse.core.runtime.IProgressMonitor;
26  
27  import pl.edu.agh.cast.data.model.DataSetDescriptor;
28  import pl.edu.agh.cast.data.model.IDataSet;
29  import pl.edu.agh.cast.data.model.IElement;
30  import pl.edu.agh.cast.data.model.Type;
31  import pl.edu.agh.cast.data.model.domain.DomainDataSetDescriptor;
32  import pl.edu.agh.cast.data.model.presentation.IPresentationDataSet;
33  import pl.edu.agh.cast.data.model.presentation.IPresentationElement;
34  import pl.edu.agh.cast.data.model.presentation.PresentationDataSetDescriptor;
35  import pl.edu.agh.cast.data.model.visual.VisualDataSetDescriptor;
36  
37  /**
38   * Interface of data model persistence provider.
39   *
40   * @author AGH CAST Team
41   */
42  public interface IPersistenceProvider {
43  
44  	/**
45  	 * Sets the path to configuration/storage file.
46  	 *
47  	 * @param filePath
48  	 *            path to configuration/storage file
49  	 */
50  	public void setConfig(String filePath);
51  
52  	/**
53  	 * Initializes the instance of {@link IPersistenceProvider}.
54  	 */
55  	public void initialize();
56  
57  	/**
58  	 * Destroys the instance of {@link IPersistenceProvider}.
59  	 */
60  	public void destroy();
61  
62  	/**
63  	 * Returns descriptors of all available data sets.
64  	 *
65  	 * @return list of descriptors of available data sets
66  	 */
67  	public List<DataSetDescriptor> getDataSetDescriptors();
68  
69  	/**
70  	 * Returns descriptors of all available data sets of given type (and sub-types).
71  	 *
72  	 * @param dsType
73  	 *            the type (super-type) of the data sets whose descriptors should be returned
74  	 * @return list of descriptors of data sets of given type
75  	 */
76  	public List<DataSetDescriptor> getDataSetDescriptors(Type dsType);
77  
78  	/**
79  	 * Returns descriptors of all available domain data sets.
80  	 *
81  	 * @return list of descriptors of available domain data sets
82  	 */
83  	public List<DomainDataSetDescriptor> getDomainDataSetDescriptors();
84  
85  	/**
86  	 * Returns descriptors of all available presentation data sets.
87  	 *
88  	 * @return list of descriptors of available presentation data sets
89  	 */
90  	public List<PresentationDataSetDescriptor> getPresentationDataSetDescriptors();
91  
92  	/**
93  	 * Returns descriptors of all available visual data sets.
94  	 *
95  	 * @return list of descriptors of available visual data sets
96  	 */
97  	public List<VisualDataSetDescriptor> getVisualDataSetDescriptors();
98  
99  	/**
100 	 * Returns the descriptor of data set with given ID.
101 	 *
102 	 * @param id
103 	 *            the ID of the data set
104 	 * @return the descriptor of data set with given ID
105 	 */
106 	public DataSetDescriptor getDataSetDescriptor(UUID id);
107 
108 	/**
109 	 * Returns the data set with given ID.
110 	 *
111 	 * @param <T>
112 	 *            the type of data set to be returned
113 	 * @param id
114 	 *            the ID of the data set
115 	 * @return the data set with given ID
116 	 */
117 	public <T extends IDataSet<? extends IElement>> T getDataSet(UUID id);
118 
119 	/**
120 	 * Returns the data set described by given descriptor.
121 	 *
122 	 * @param <T>
123 	 *            the type of data set to be returned
124 	 * @param descriptor
125 	 *            the descriptor of the data set
126 	 * @return the data set with described by given descriptor
127 	 */
128 	public <T extends IDataSet<? extends IElement>> T getDataSet(DataSetDescriptor descriptor);
129 
130 	/**
131 	 * Returns the data sets with given IDs.
132 	 *
133 	 * @param <T>
134 	 *            the type of data sets to be returned
135 	 * @param ids
136 	 *            collection of data set IDs
137 	 * @return a map of data sets with given IDs, indexed by IDs
138 	 */
139 	public <T extends IDataSet<? extends IElement>> Map<UUID, T> getDataSetsById(Collection<UUID> ids);
140 
141 	/**
142 	 * Returns the data sets described by given descriptors.
143 	 *
144 	 * @param <T>
145 	 *            the type of data sets to be returned
146 	 * @param descriptors
147 	 *            collection of descriptor of the data sets
148 	 * @return a map of data sets described by given descriptors, indexed by IDs
149 	 */
150 	public <T extends IDataSet<? extends IElement>> Map<UUID, T> getDataSets(Collection<DataSetDescriptor> descriptors);
151 
152 	/**
153 	 * Saves the given data set.
154 	 *
155 	 * @param dataSet
156 	 *            the data set to save
157 	 * @return the ID of the data set (as saved)
158 	 */
159 	public UUID saveDataSet(IDataSet<? extends IElement> dataSet);
160 
161 	/**
162 	 * Saves the given data set.
163 	 *
164 	 * @param dataSet
165 	 *            the data set to save
166 	 * @param monitor
167 	 *            operation progress monitor
168 	 * @return the ID of the data set (as saved)
169 	 */
170 	public UUID saveDataSet(IDataSet<? extends IElement> dataSet, IProgressMonitor monitor);
171 
172 	/**
173 	 * Saves the given collection of data sets.
174 	 *
175 	 * @param dataSets
176 	 *            collection of data sets to save
177 	 * @return a map containing new IDs (as saved) of the data sets indexed by their old IDs
178 	 */
179 	public Map<UUID, UUID> saveDataSets(Collection<IDataSet<? extends IElement>> dataSets);
180 
181 	/**
182 	 * Saves the given collection of data sets.
183 	 *
184 	 * @param dataSets
185 	 *            collection of data sets to save
186 	 * @param monitor
187 	 *            operation progress monitor
188 	 * @return a map containing new IDs (as saved) of the data sets indexed by their old IDs
189 	 */
190 	public Map<UUID, UUID> saveDataSets(Collection<IDataSet<? extends IElement>> dataSets, IProgressMonitor monitor);
191 
192 	/**
193 	 * Saves the given presentation data set with associated visual data set and returns their new version.
194 	 *
195 	 * @param <T>
196 	 *            the type of presentation data set
197 	 *
198 	 * @param presentationDataSet
199 	 *            the presentation data set to save
200 	 * @return the new version of presentation data set (with associated visual data set) as saved
201 	 */
202 	public <T extends IPresentationDataSet<? extends IPresentationElement<? extends IElement>>> T saveDiagram(
203 	        T presentationDataSet);
204 
205 	/**
206 	 * Saves the given presentation data set with associated visual data set and returns their new version.
207 	 *
208 	 * @param <T>
209 	 *            the type of presentation data set
210 	 *
211 	 * @param presentationDataSet
212 	 *            the presentation data set to save
213 	 * @param monitor
214 	 *            operation progress monitor
215 	 * @return the new version of presentation data set (with associated visual data set) as saved
216 	 */
217 	public <T extends IPresentationDataSet<? extends IPresentationElement<? extends IElement>>> T saveDiagram(
218 	        T presentationDataSet, IProgressMonitor monitor);
219 
220 	/**
221 	 * Changes the name of the data set with given ID.
222 	 *
223 	 * @param id
224 	 *            the data set ID
225 	 * @param newName
226 	 *            the new name to set
227 	 * @return the ID of renamed data set
228 	 */
229 	public UUID renameDataSet(UUID id, String newName);
230 
231 }