matching in commonservice
[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.List;
14 import java.util.Set;
15
16 import eu.etaxonomy.cdm.model.common.CdmBase;
17 import eu.etaxonomy.cdm.model.common.ISourceable;
18 import eu.etaxonomy.cdm.model.common.OriginalSource;
19 import eu.etaxonomy.cdm.strategy.match.IMatchStrategy;
20 import eu.etaxonomy.cdm.strategy.match.IMatchable;
21 import eu.etaxonomy.cdm.strategy.match.MatchException;
22 import eu.etaxonomy.cdm.strategy.merge.IMergable;
23 import eu.etaxonomy.cdm.strategy.merge.IMergeStrategy;
24 import eu.etaxonomy.cdm.strategy.merge.MergeException;
25
26
27 public interface ICommonService extends IService<OriginalSource>{
28 //
29 // /** find cdmBase by UUID**/
30 // public abstract CdmBase getCdmBaseByUuid(UUID uuid);
31 //
32 // /** save a reference and return its UUID**/
33 // public abstract UUID saveCdmBase(CdmBase cdmBase);
34
35 /** find cdmBase by UUID**/
36 public ISourceable getSourcedObjectByIdInSource(Class clazz, String idInSource, String idNamespace);
37
38
39 /**
40 * Returns all CdmBase objects that reference the referencedCdmBase.
41 * For example, if referencedCdmBase is an agent it may return all taxon names
42 * that have this person as an author but also all books, articles, etc. that have
43 * this person as an author
44 * @param referencedCdmBase
45 * @return
46 */
47 public Set<CdmBase> getReferencingObjects(CdmBase referencedCdmBase);
48
49 /**
50 * Merges mergeSecond into mergeFirst. All references to mergeSecond will be replaced by references
51 * to merge first. If no merge strategy is defined (null), the DefaultMergeStrategy will be taken as default.
52 * @param <T>
53 * @param mergeFirst
54 * @param mergeSecond
55 * @param mergeStrategy
56 * @throws MergeException
57 */
58 public <T extends IMergable> void merge(T mergeFirst, T mergeSecond, IMergeStrategy mergeStrategy) throws MergeException;
59
60 /**
61 * Returns all objects that match the object to match according to the given match strategy.
62 * If no match strategy is defined the default match strategy is taken.
63 * @param <T>
64 * @param objectToMatch
65 * @param matchStrategy
66 * @return
67 * @throws MatchException
68 */
69 public <T extends IMatchable> List<T> findMatching(T objectToMatch, IMatchStrategy matchStrategy) throws MatchException;
70
71
72 public List getHqlResult(String hqlQuery);
73
74 }