Project

General

Profile

« Previous | Next » 

Revision 6f33eb6e

Added by Andreas Müller almost 4 years ago

cleanup

View differences:

eu.etaxonomy.taxeditor.cdmlib/src/main/java/eu/etaxonomy/taxeditor/session/ICdmEntitySessionManager.java
1
/**
2
* Copyright (C) 2015 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
*/
1 9
package eu.etaxonomy.taxeditor.session;
2 10

  
3 11
import java.util.Collection;
4 12

  
5 13
import eu.etaxonomy.cdm.api.service.UpdateResult;
14
import eu.etaxonomy.cdm.cache.CdmTransientEntityCacher;
6 15
import eu.etaxonomy.cdm.model.common.CdmBase;
16
import eu.etaxonomy.cdm.model.common.ICdmBase;
7 17
import eu.etaxonomy.cdm.persistence.dto.MergeResult;
8 18

  
19
/**
20
 * Manager to manage all {@link ICdmEntitySession}s.
21
 * <p>
22
 * It allows to create new sessions, handles binding and disposing, registering
23
 * and notifying observers, thread handling and also offers
24
 * convenient methods to load the active session.
25
 *
26
 * @author c.mathew
27
 * @date 2014
28
 */
9 29
public interface ICdmEntitySessionManager {
10 30

  
31
    /**
32
     * Creates a new session for the sessionOwner.
33
     *
34
     * @param sessionOwner the session owner
35
     * @param setAsActive if
36
     * @return the new session
37
     */
11 38
    public abstract ICdmEntitySession newSession(ICdmEntitySessionEnabled sessionOwner, boolean setAsActive);
12 39

  
13 40
    /**
14
     * @param sessionOwner
15
     * @return
41
     * Makes the {@link NullSession} the active session.
42
     * @return the null session
16 43
     */
17 44
    public ICdmEntitySession bindNullSession();
18 45

  
19

  
46
	/**
47
	 * Makes the session belonging to the session owner the active session.
48
	 *
49
	 * @param sessionOwner
50
	 */
20 51
	public abstract void bind(ICdmEntitySessionEnabled sessionOwner);
21 52

  
22

  
23 53
	/**
24
     * @see eu.etaxonomy.cdm.cache.CdmTransientEntityCacher#load(Collection, boolean)
54
	 * Loads an object intto the active session and returns the cached object
55
	 * which is the identical (same) object if an equal object did not yet exist
56
	 * in the session. If an equal object existed the cached object is returned.
57
	 * This cached object is equal (x.equals(x')) but not identical (x != x').
58
	 *
59
	 * @param object the object to load into the cache
60
	 * @param update if <code>true</code>, the state of the object graph
61
	 *   attached to the object is copied on the according objects in the cache
62
	 * @return the cached object
63
	 * @see CdmTransientEntityCacher#load(Object, boolean)
64
	 * @see CdmTransientEntityCacher#load(CdmBase, boolean)
25 65
     */
26
	public abstract <T extends Object> T load(T obj, boolean update);
66
	public abstract <T extends Object> T load(T object, boolean update);
27 67

  
28 68
    /**
29
     * @see eu.etaxonomy.cdm.cache.CdmTransientEntityCacher#load(Collection, boolean)
69
     * Loads an {@link CdmBase} into the active session as explained in {@link #load(Object, boolean)}.
70
     *
71
     * @see #load(Object, boolean)
72
     * @see CdmTransientEntityCacher#load(CdmBase, boolean)
30 73
     */
31 74
	public abstract <T extends CdmBase> T load(T cdmBase, boolean update);
32 75

  
33

  
76
    /**
77
     * Loads an {@link UpdateResult} into the active session as explained in {@link #load(Object, boolean)}.
78
     *
79
     * @see #load(Object, boolean)
80
     * @see CdmTransientEntityCacher#load(UpdateResult, boolean)
81
     */
34 82
	public abstract UpdateResult load(UpdateResult updateResult, boolean update);
35 83

  
36
	public abstract MergeResult load(MergeResult mergeResult, boolean update);
37

  
84
    /**
85
     * Loads an {@link MergeResult} into the active session as explained in {@link #load(Object, boolean)}.
86
     *
87
     * @see #load(Object, boolean)
88
     * @see CdmTransientEntityCacher#load(MergeResult, boolean)
89
     */
90
	public abstract <T extends ICdmBase> MergeResult<T> load(MergeResult<T> mergeResult, boolean update);
38 91

  
92
    /**
93
     * Loads an {@link Collection} of {@link CdmBase} objects into the active session as
94
     * explained in {@link #load(Object, boolean)}.
95
     *
96
     * @see #load(Object, boolean)
97
     * @see CdmTransientEntityCacher#load(Collection, boolean)
98
     */
39 99
	public abstract <T extends CdmBase> Collection<T> load(Collection<T> cdmBaseList, boolean update);
40 100

  
41

  
42 101
    /**
43
     * @return
102
     * @return the active session
44 103
     */
45 104
    public ICdmEntitySession getActiveSession();
46 105

  
106
    /**
107
     * Returns all sessions managed by this {@link ICdmEntitySessionManager session manager}
108
     * @return
109
     */
47 110
    public Collection<ICdmEntitySession> getSessions();
48 111

  
49 112
    public void addSessionObserver(ICdmEntitySessionManagerObserver sessionObserver);
50 113

  
51

  
52

  
53

  
54 114
    public boolean isRemoting();
55 115

  
56
    /**
57
     * @param owner
58
     */
59 116
    public void dispose(ICdmEntitySessionEnabled owner);
60 117

  
61
    /**
62
     *
63
     */
64 118
    public void disposeAll();
65 119

  
66

  
67
    /**
68
     *
69
     */
70 120
    public <T extends CdmBase> void update();
71 121

  
72 122
    /**
73
     * @param sessionOwner
74
     * @return
123
     * Returns <code>true</code> if there is a session managed for the given session owner.
124
     * @param sessionOwner the session owner
125
     * @return <code>true</code> if a session exists
75 126
     */
76 127
    public boolean contains(ICdmEntitySessionEnabled sessionOwner);
77 128

  
78 129
    /**
79
     * @return
130
     * Returns the {@link NullSession} singleton instance (within this session manager)
131
     * @return the null session
80 132
     */
81 133
    public ICdmEntitySession getNullSession();
82 134

  
83

  
84 135
}

Also available in: Unified diff