reverting last commit - will be committed again later
[cdmlib.git] / cdmlib-services / src / main / java / eu / etaxonomy / cdm / api / service / ICommonService.java
1 // $Id$
2 /**
3 * Copyright (C) 2007 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
6 *
7 * The contents of this file are subject to the Mozilla Public License Version 1.1
8 * See LICENSE.TXT at the top of this package for the full license terms.
9 */
10
11 package eu.etaxonomy.cdm.api.service;
12
13 import java.util.Collection;
14 import java.util.List;
15 import java.util.Map;
16 import java.util.Set;
17
18 import eu.etaxonomy.cdm.database.DatabaseSchemaMismatchException;
19 import eu.etaxonomy.cdm.model.common.CdmBase;
20 import eu.etaxonomy.cdm.model.common.CdmMetaData;
21 import eu.etaxonomy.cdm.model.common.ISourceable;
22 import eu.etaxonomy.cdm.model.common.OriginalSourceBase;
23 import eu.etaxonomy.cdm.model.common.CdmMetaData.MetaDataPropertyName;
24 import eu.etaxonomy.cdm.strategy.match.IMatchStrategy;
25 import eu.etaxonomy.cdm.strategy.match.IMatchable;
26 import eu.etaxonomy.cdm.strategy.match.MatchException;
27 import eu.etaxonomy.cdm.strategy.merge.IMergable;
28 import eu.etaxonomy.cdm.strategy.merge.IMergeStrategy;
29 import eu.etaxonomy.cdm.strategy.merge.MergeException;
30
31
32 public interface ICommonService extends IService<OriginalSourceBase>{
33 //
34 // /** find cdmBase by UUID**/
35 // public abstract CdmBase getCdmBaseByUuid(UUID uuid);
36 //
37 // /** save a reference and return its UUID**/
38 // public abstract UUID saveCdmBase(CdmBase cdmBase);
39
40 /**
41 * Saves all meta data
42 * @param metaData
43 */
44 public void saveAllMetaData(Collection<CdmMetaData> metaData);
45
46 /**
47 * Returns all meta data.
48 * @return
49 */
50 public Map<MetaDataPropertyName, CdmMetaData> getCdmMetaData();
51
52
53 /**
54 * Returns a map of identifiable entities of class <code>clazz</code> which have an original source of
55 * with namespace <code>idNamespace</code> and with an idInSource in <code>idInSourceSet</code> <BR>
56 * The key of the map is the idInSource. If there are multiple objects that have the same id an arbitrary one is chosen.
57 * @param clazz
58 * @param idInSourceSet
59 * @param idNamespace
60 * @return
61 */
62 public Map<String, ? extends ISourceable> getSourcedObjectsByIdInSource(Class clazz, Set<String> idInSourceSet, String idNamespace);
63
64 /**
65 * Returns a list of identifiable entities according to their class, idInSource and idNamespace
66 * @param clazz
67 * @param idInSource
68 * @param idNamespace
69 * @return
70 */
71 public ISourceable getSourcedObjectByIdInSource(Class clazz, String idInSource, String idNamespace);
72
73
74 /**
75 * Returns all CdmBase objects that reference the referencedCdmBase.
76 * For example, if referencedCdmBase is an agent it may return all taxon names
77 * that have this person as an author but also all books, articles, etc. that have
78 * this person as an author
79 * @param referencedCdmBase
80 * @return
81 */
82 public Set<CdmBase> getReferencingObjects(CdmBase referencedCdmBase);
83
84 /**
85 * Merges mergeSecond into mergeFirst. All references to mergeSecond will be replaced by references
86 * to merge first. If no merge strategy is defined (null), the DefaultMergeStrategy will be taken as default.
87 * @param <T>
88 * @param mergeFirst
89 * @param mergeSecond
90 * @param mergeStrategy
91 * @throws MergeException
92 */
93 public <T extends IMergable> void merge(T mergeFirst, T mergeSecond, IMergeStrategy mergeStrategy) throws MergeException;
94
95 /**
96 * Returns all objects that match the object to match according to the given match strategy.
97 * If no match strategy is defined the default match strategy is taken.
98 * @param <T>
99 * @param objectToMatch
100 * @param matchStrategy
101 * @return
102 * @throws MatchException
103 */
104 public <T extends IMatchable> List<T> findMatching(T objectToMatch, IMatchStrategy matchStrategy) throws MatchException;
105
106
107 public List getHqlResult(String hqlQuery);
108
109 }