1) Term vocabularies (ranks, features, statii) are also transaction-dependent - if...
[taxeditor.git] / eclipseprojects / eu.etaxonomy.taxeditor / src / eu / etaxonomy / taxeditor / model / ICdmSessionDataRepository.java
1 /**
2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
5 *
6 * The contents of this file are subject to the Mozilla Public License Version 1.1
7 * See LICENSE.TXT at the top of this package for the full license terms.
8 */
9
10 package eu.etaxonomy.taxeditor.model;
11
12 import java.util.Collection;
13 import java.util.Set;
14 import java.util.SortedSet;
15
16 import org.eclipse.core.databinding.observable.set.IObservableSet;
17
18 import eu.etaxonomy.cdm.api.application.CdmApplicationController;
19 import eu.etaxonomy.cdm.model.common.TermVocabulary;
20 import eu.etaxonomy.cdm.model.description.Feature;
21 import eu.etaxonomy.cdm.model.name.NameRelationshipType;
22 import eu.etaxonomy.cdm.model.name.NomenclaturalStatusType;
23 import eu.etaxonomy.cdm.model.name.Rank;
24 import eu.etaxonomy.cdm.model.reference.ReferenceBase;
25 import eu.etaxonomy.cdm.model.taxon.Taxon;
26
27 /**
28 * All session data - taxa, term vocabularies, etc. - are stored in a
29 * session data repository. Any CDM data that is stored locally during execution
30 * should be kept here while the Editor is running. This makes it convenient
31 * to clear all data in case everything needs to be reloaded, for example, when
32 * the data source is changed.
33 * <p>
34 * The repository uses a CDM application controller to retrieve data.
35 * <p>
36 * Any method starting with "add" or "remove" deals with data solely in the session.
37 * For instance, <code>addTaxon(taxon)</code> will cause a new <code>taxon</code>
38 * to appear in the taxonomic tree, but will not save it to the CDM data source.
39 * <p>
40 * Any method starting with "save" or "delete" will call its corresponding "add"/"remove"
41 * method, and commit the change to the CDM data source.
42 *
43 * @author p.ciardelli
44 * @created 16.12.2008
45 * @version 1.0
46 */
47 public interface ICdmSessionDataRepository {
48
49 /**
50 * Returns the root taxa associated with the current data source, and
51 * adds them to session data if not already there.
52 *
53 * @return
54 */
55 public Set<Taxon> getRootTaxa();
56
57 /**
58 * Returns all of a taxon's children, and adds them to session data
59 * if not already there.
60 *
61 * @param parentTaxon
62 * @return
63 */
64 public Set<Taxon> getTaxonomicChildren(Taxon parentTaxon);
65
66 /**
67 * Get the default sec. reference used by the current dataset
68 * @return
69 */
70 public ReferenceBase getDefaultSec();
71
72 /**
73 * Adds a taxon to the repository.
74 *
75 * @param taxon
76 */
77 public void addTaxon(Taxon taxon);
78
79 /**
80 * Removes a taxon from the repository.
81 *
82 * @param taxon
83 */
84 public void removeTaxon(Taxon taxon);
85
86 /**
87 * Removes all taxa from the repository.
88 * replaces clearSessionTaxa
89 *
90 * @param taxon
91 */
92 public void removeAllTaxa();
93
94 /**
95 * This is a set that can be used to be notified when there are changes
96 * to the list of all taxa, or to their names, for instance, when the name
97 * of a taxon displayed in a tree changes.
98 *
99 * @return
100 */
101 public IObservableSet getObservableTaxa();
102
103 public void setApplicationController(CdmApplicationController applicationController);
104
105 /**
106 * Sets all term vocabularies to NULL to be regenerated the next time
107 * they are needed, i.e. when a new transaction is opened.
108 */
109 public void clearNonTaxonData();
110
111 /**
112 * Sets all taxon collections to NULL to be regenerated the next time
113 * they are needed.
114 */
115 public void clearTaxonData();
116
117 public void clearAllData();
118
119 public void addTaxonSetListener(ICdmTaxonSetListener listener);
120
121 public Collection<Taxon> getAllTaxa();
122
123 public boolean saveTaxon(Taxon taxon);
124
125 public boolean deleteTaxon(Taxon taxon);
126
127 public void setTaxonomicParent(Taxon taxon, Taxon newParentTaxon);
128
129 public TermVocabulary<Feature> getFeatures();
130
131 public SortedSet<Rank> getRanks();
132
133 public TermVocabulary<NomenclaturalStatusType> getNomStatii();
134
135 public SortedSet<NameRelationshipType> getNameRelationshipTypes();
136 }