Project

General

Profile

Download (4.48 KB) Statistics
| Branch: | Tag: | Revision:
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
*/
9
package eu.etaxonomy.taxeditor.session;
10

    
11
import java.util.Collection;
12

    
13
import eu.etaxonomy.cdm.api.service.UpdateResult;
14
import eu.etaxonomy.cdm.cache.CdmTransientEntityCacher;
15
import eu.etaxonomy.cdm.model.common.CdmBase;
16
import eu.etaxonomy.cdm.model.common.ICdmBase;
17
import eu.etaxonomy.cdm.persistence.dto.MergeResult;
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
 */
29
public interface ICdmEntitySessionManager {
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
     */
38
    public abstract ICdmEntitySession newSession(ICdmEntitySessionEnabled sessionOwner, boolean setAsActive);
39

    
40
    /**
41
     * Makes the {@link NullSession} the active session.
42
     * @return the null session
43
     */
44
    public ICdmEntitySession bindNullSession();
45

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

    
53
	/**
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)
65
     */
66
	public abstract <T extends Object> T load(T object, boolean update);
67

    
68
    /**
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)
73
     */
74
	public abstract <T extends CdmBase> T load(T cdmBase, boolean update);
75

    
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
     */
82
	public abstract UpdateResult load(UpdateResult updateResult, boolean update);
83

    
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);
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
     */
99
	public abstract <T extends CdmBase> Collection<T> load(Collection<T> cdmBaseList, boolean update);
100

    
101
    /**
102
     * @return the active session
103
     */
104
    public ICdmEntitySession getActiveSession();
105

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

    
112
    public void addSessionObserver(ICdmEntitySessionManagerObserver sessionObserver);
113

    
114
    public boolean isRemoting();
115

    
116
    public void dispose(ICdmEntitySessionEnabled owner);
117

    
118
    public void disposeAll();
119

    
120
    public <T extends CdmBase> void update();
121

    
122
    /**
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
126
     */
127
    public boolean contains(ICdmEntitySessionEnabled sessionOwner);
128

    
129
    /**
130
     * Returns the {@link NullSession} singleton instance (within this session manager)
131
     * @return the null session
132
     */
133
    public ICdmEntitySession getNullSession();
134
}
(7-7/9)