Project

General

Profile

« Previous | Next » 

Revision 76fe3732

Added by Cherian Mathew about 7 years ago

#5161 Fix problem of new entity not refreshed

View differences:

eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/annotatedlineeditor/AnnotatedLineDocumentProvider.java
237 237
				if (annotation instanceof IEntityContainer<?>) {
238 238
					IEntityContainer<?> container = (IEntityContainer<?>) annotation;
239 239
					if (container.isMarkedAsNew() || container.isDirty()) {
240
						persistenceService.save(container.getEntity()); // save
240
						Object entity = persistenceService.save(container.getEntity()); // save
241
						container.setEntity(entity);
241 242
						container.setDirty(false);
242 243
						container.markAsNew(false);
243 244
					}
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/annotatedlineeditor/IEntityContainer.java
1 1
// $Id$
2 2
/**
3 3
* Copyright (C) 2007 EDIT
4
* European Distributed Institute of Taxonomy 
4
* European Distributed Institute of Taxonomy
5 5
* http://www.e-taxonomy.eu
6
* 
6
*
7 7
* The contents of this file are subject to the Mozilla Public License Version 1.1
8 8
* See LICENSE.TXT at the top of this package for the full license terms.
9 9
*/
......
28 28
	 * @return a T object.
29 29
	 */
30 30
	T getEntity();
31
	
31

  
32
	void setEntity(Object entity);
33

  
32 34
	/**
33 35
	 * <p>getEditableText</p>
34 36
	 *
35 37
	 * @return a {@link java.lang.String} object.
36 38
	 */
37 39
	String getEditableText();
38
	
40

  
39 41
	/**
40 42
	 * <p>getAttachedEntities</p>
41 43
	 *
42 44
	 * @return a {@link java.util.Set} object.
43 45
	 */
44 46
	Set<T> getAttachedEntities();
45
	
47

  
46 48
	/**
47 49
	 * <p>markAsMerged</p>
48 50
	 *
49 51
	 * @param mergeTarget a T object.
50 52
	 */
51 53
	void markAsMerged(T mergeTarget);
52
	
54

  
53 55
	/**
54 56
	 * <p>markAsDeleted</p>
55 57
	 */
56 58
	void markAsDeleted();
57
	
59

  
58 60
	/**
59 61
	 * <p>markAsNew</p>
60 62
	 *
61 63
	 * @param isNew a boolean.
62 64
	 */
63 65
	void markAsNew(boolean isNew);
64
	
66

  
65 67
	/**
66 68
	 * <p>isMarkedAsMerged</p>
67 69
	 *
68 70
	 * @return a boolean.
69 71
	 */
70 72
	boolean isMarkedAsMerged();
71
	
73

  
72 74
	/**
73 75
	 * <p>isMarkedAsDeleted</p>
74 76
	 *
75 77
	 * @return a boolean.
76 78
	 */
77 79
	boolean isMarkedAsDeleted();
78
	
80

  
79 81
	/**
80 82
	 * <p>isMarkedAsNew</p>
81 83
	 *
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/annotatedlineeditor/IEntityPersistenceService.java
1 1
// $Id$
2 2
/**
3 3
* Copyright (C) 2007 EDIT
4
* European Distributed Institute of Taxonomy 
4
* European Distributed Institute of Taxonomy
5 5
* http://www.e-taxonomy.eu
6
* 
6
*
7 7
* The contents of this file are subject to the Mozilla Public License Version 1.1
8 8
* See LICENSE.TXT at the top of this package for the full license terms.
9 9
*/
......
24 24
 * @version 1.0
25 25
 */
26 26
public interface IEntityPersistenceService<T> {
27
	
27

  
28 28
	/**
29 29
	 * <p>create</p>
30 30
	 *
31 31
	 * @param entity a {@link java.lang.Object} object.
32 32
	 * @return a boolean.
33 33
	 */
34
	boolean create(T entity);
35
	
34
	T create(T entity);
35

  
36 36
	/**
37 37
	 * <p>save</p>
38 38
	 *
39 39
	 * @param entity a {@link java.lang.Object} object.
40 40
	 * @return a boolean.
41 41
	 */
42
	boolean save(T entity);
43
	
42
	T save(T entity);
43

  
44 44
	/**
45 45
	 * <p>merge</p>
46 46
	 *
......
49 49
	 * @return a boolean.
50 50
	 */
51 51
	boolean merge(T entity, T mergeTarget);
52
	
52

  
53 53
	/**
54 54
	 * <p>delete</p>
55 55
	 *
56 56
	 * @param entity a {@link java.lang.Object} object.
57 57
	 * @return a boolean.
58
	 * @throws ReferencedObjectUndeletableException 
58
	 * @throws ReferencedObjectUndeletableException
59 59
	 */
60 60
	boolean delete(T entity) throws ReferencedObjectUndeletableException;
61 61
}
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/annotatedlineeditor/LineAnnotation.java
1 1
// $Id$
2 2
/**
3 3
* Copyright (C) 2007 EDIT
4
* European Distributed Institute of Taxonomy 
4
* European Distributed Institute of Taxonomy
5 5
* http://www.e-taxonomy.eu
6
* 
6
*
7 7
* The contents of this file are subject to the Mozilla Public License Version 1.1
8 8
* See LICENSE.TXT at the top of this package for the full license terms.
9 9
*/
......
29 29

  
30 30
	/** Constant <code>TYPE_GENERIC="Annotation.TYPE_UNKNOWN"</code> */
31 31
	public static final String TYPE_GENERIC = Annotation.TYPE_UNKNOWN;
32
	
32

  
33 33
	private T entity;
34 34
	private ILineDisplayStrategy lineDisplayStrategy;
35 35

  
......
38 38
	private boolean markedAsNew;
39 39
	private T mergeTarget;
40 40

  
41
	
41

  
42 42
	/**
43 43
	 * <p>Constructor for LineAnnotation.</p>
44 44
	 *
......
51 51
		this.lineDisplayStrategy = lineDisplayStrategy;
52 52
		setType(TYPE_GENERIC);
53 53
	}
54
	
54

  
55 55
	/* (non-Javadoc)
56 56
	 * @see org.eclipse.jface.text.source.Annotation#getText()
57 57
	 */
......
60 60
	public String getText() {
61 61
		return getEditableText();
62 62
	}
63
	
63

  
64 64
	/* (non-Javadoc)
65 65
	 * @see org.eclipse.jface.text.source.Annotation#setText(java.lang.String)
66 66
	 */
......
68 68
	@Override
69 69
	public void setText(String text) {
70 70
		lineDisplayStrategy.setText(text, entity);
71
		dirty  = true;		
71
		dirty  = true;
72 72
		super.setText(text);
73 73
	}
74
	
74

  
75 75
	/** {@inheritDoc} */
76 76
	@Override
77 77
	public String toString() {
78 78
		// For debugging
79 79
		return getText();
80 80
	}
81
	
81

  
82 82
	/* (non-Javadoc)
83 83
	 * @see eu.etaxonomy.taxeditor.bulkeditor.IEntityContainer#getAttachedEntities()
84 84
	 */
......
87 87
	 *
88 88
	 * @return a {@link java.util.Set} object.
89 89
	 */
90
	public Set getAttachedEntities() {
90
	@Override
91
    public Set getAttachedEntities() {
91 92
		// TODO Auto-generated method stub
92 93
		return null;
93 94
	}
......
100 101
	 *
101 102
	 * @return a T object.
102 103
	 */
103
	public T getEntity() {
104
	@Override
105
    public T getEntity() {
104 106
		return entity;
105 107
	}
106 108

  
......
112 114
	 *
113 115
	 * @return a {@link java.lang.String} object.
114 116
	 */
115
	public String getEditableText() {
117
	@Override
118
    public String getEditableText() {
116 119
		return lineDisplayStrategy.getText(entity);
117 120
	}
118 121

  
......
124 127
	 *
125 128
	 * @return a T object.
126 129
	 */
127
	public T getMergeTarget() {
130
	@Override
131
    public T getMergeTarget() {
128 132
		return mergeTarget;
129 133
	}
130 134

  
......
136 140
	 *
137 141
	 * @return a boolean.
138 142
	 */
139
	public boolean isMarkedAsDeleted() {
143
	@Override
144
    public boolean isMarkedAsDeleted() {
140 145
		return super.isMarkedDeleted();
141 146
	}
142 147

  
......
148 153
	 *
149 154
	 * @return a boolean.
150 155
	 */
151
	public boolean isMarkedAsMerged() {
156
	@Override
157
    public boolean isMarkedAsMerged() {
152 158
		return markedAsMerged;
153 159
	}
154 160

  
......
160 166
	 *
161 167
	 * @return a boolean.
162 168
	 */
163
	public boolean isMarkedAsNew() {
169
	@Override
170
    public boolean isMarkedAsNew() {
164 171
		return markedAsNew;
165 172
	}
166 173

  
......
170 177
	/**
171 178
	 * <p>markAsDeleted</p>
172 179
	 */
173
	public void markAsDeleted() {
180
	@Override
181
    public void markAsDeleted() {
174 182
		super.markDeleted(true);
175 183
		if (!isMarkedAsMerged()) {
176 184
			lineDisplayStrategy.setStatusMessage(entity + " deleted.", entity);
......
185 193
	 *
186 194
	 * @param mergeTarget a T object.
187 195
	 */
188
	public void markAsMerged(T mergeTarget) {
196
	@Override
197
    public void markAsMerged(T mergeTarget) {
189 198
		this.mergeTarget = mergeTarget;
190 199
		markedAsMerged = true;
191 200
		lineDisplayStrategy.setStatusMessage("'" + entity + "' merged into '" + mergeTarget + "'.", entity);
......
195 204
	 * @see eu.etaxonomy.taxeditor.bulkeditor.IEntityContainer#markAsNew()
196 205
	 */
197 206
	/** {@inheritDoc} */
198
	public void markAsNew(boolean isNew) {
207
	@Override
208
    public void markAsNew(boolean isNew) {
199 209
		markedAsNew = isNew;
200 210
		lineDisplayStrategy.setStatusMessage("New entity created.", entity);
201 211
	}
......
204 214
	 * @see eu.etaxonomy.taxeditor.bulkeditor.IEntityContainer#setDirty(boolean)
205 215
	 */
206 216
	/** {@inheritDoc} */
207
	public void setDirty(boolean dirty) {
217
	@Override
218
    public void setDirty(boolean dirty) {
208 219
		this.dirty = dirty;
209 220
	}
210 221

  
......
216 227
	 *
217 228
	 * @return a boolean.
218 229
	 */
219
	public boolean isDirty() {
230
	@Override
231
    public boolean isDirty() {
220 232
		return dirty;
221 233
	}
222 234

  
......
228 240
	public String getHoverText() {
229 241
		return lineDisplayStrategy.getHoverText(entity);
230 242
	}
243

  
244
    /* (non-Javadoc)
245
     * @see eu.etaxonomy.taxeditor.annotatedlineeditor.IEntityContainer#setEntity(java.lang.Object)
246
     */
247
    @Override
248
    public void setEntity(Object entity) {
249
        this.entity = (T) entity;
250
    }
231 251
}
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/input/AbstractBulkEditorInput.java
255 255

  
256 256
	/** {@inheritDoc} */
257 257
	@Override
258
    public boolean create(T entity) {
258
    public T create(T entity) {
259 259
		return save(entity);
260 260
	}
261 261

  
......
316 316
		return model;
317 317
	}
318 318

  
319

  
319
	protected boolean replaceInModel(T entity) {
320
	    int index = model.indexOf(entity);
321
	    if(index >= 0) {
322
	        model.set(index, entity);
323
	        return true;
324
	    } else {
325
	        return false;
326
	    }
327
	}
320 328

  
321 329
    /* (non-Javadoc)
322 330
     * @see eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled#getRootEntities()
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/input/AgentEditorInput.java
146 146
	}
147 147

  
148 148
	@Override
149
	public boolean save(TeamOrPersonBase entity) {
149
	public TeamOrPersonBase save(TeamOrPersonBase entity) {
150 150
	    if(CdmStore.getCurrentSessionManager().isRemoting()) {
151
	        return CdmStore.getService(IAgentService.class).merge(entity) != null;
151
	        return (TeamOrPersonBase) CdmStore.getService(IAgentService.class).merge(entity);
152 152
	    } else {
153
	        return CdmStore.getService(IAgentService.class).saveOrUpdate(entity) != null;
153
	        CdmStore.getService(IAgentService.class).saveOrUpdate(entity) ;
154
	        return entity;
154 155
	    }
155 156
	}
156 157

  
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/input/GroupEditorInput.java
61 61
	 * @see eu.etaxonomy.taxeditor.annotatedlineeditor.IEntityPersistenceService#save(java.lang.Object)
62 62
	 */
63 63
	@Override
64
	public boolean save(Group entity) {
64
	public Group save(Group entity) {
65 65
	    if(CdmStore.getCurrentSessionManager().isRemoting()) {
66
	        return CdmStore.getService(IGroupService.class).merge(entity) != null;
66
	        return CdmStore.getService(IGroupService.class).merge(entity) ;
67 67
	    } else {
68
	        return CdmStore.getService(IGroupService.class).saveOrUpdate(entity) != null;
68
	        CdmStore.getService(IGroupService.class).saveOrUpdate(entity);
69
	        return entity;
69 70
	    }
70 71
	}
71 72

  
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/input/NameEditorInput.java
117 117

  
118 118
	/** {@inheritDoc} */
119 119
	@Override
120
    public boolean save(TaxonNameBase entity) {
120
    public TaxonNameBase save(TaxonNameBase entity) {
121 121
	    if(CdmStore.getCurrentSessionManager().isRemoting()) {
122
	        return CdmStore.getService(INameService.class).merge(entity) != null;
122
	        return CdmStore.getService(INameService.class).merge(entity) ;
123 123
	    } else {
124
	        return CdmStore.getService(INameService.class).saveOrUpdate(entity) != null;
124
	        CdmStore.getService(INameService.class).saveOrUpdate(entity);
125
	        return entity;
125 126
	    }
126 127
	}
127 128

  
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/input/NameRelationshipEditorInput.java
74 74
	 */
75 75
	/** {@inheritDoc} */
76 76
	@Override
77
	public boolean save(NameRelationship entity) {
77
	public NameRelationship save(NameRelationship entity) {
78 78
		// TODO Auto-generated method stub
79
		return false;
79
		return null;
80 80
	}
81 81

  
82 82
	/* (non-Javadoc)
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/input/OccurrenceEditorInput.java
17 17
import eu.etaxonomy.cdm.api.service.exception.ReferencedObjectUndeletableException;
18 18
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
19 19
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;
20
import eu.etaxonomy.cdm.strategy.cache.common.IIdentifiableEntityCacheStrategy;
20 21
import eu.etaxonomy.taxeditor.annotatedlineeditor.IEntityCreator;
21 22
import eu.etaxonomy.taxeditor.bulkeditor.IBulkEditorSortProvider;
22 23
import eu.etaxonomy.taxeditor.bulkeditor.input.entitycreator.OccurrenceCreator;
......
135 136
	 */
136 137
	/** {@inheritDoc} */
137 138
	@Override
138
    public boolean save(SpecimenOrObservationBase entity) {
139
    public SpecimenOrObservationBase<IIdentifiableEntityCacheStrategy> save(SpecimenOrObservationBase entity) {
139 140
	    if(CdmStore.getCurrentSessionManager().isRemoting()) {
140
	        return CdmStore.getService(IOccurrenceService.class).merge(entity) != null;
141
	        return CdmStore.getService(IOccurrenceService.class).merge(entity) ;
141 142
	    } else {
142
	        return CdmStore.getService(IOccurrenceService.class).save(entity) != null;
143
	        CdmStore.getService(IOccurrenceService.class).save(entity);
144
	        return entity;
143 145
	    }
144 146
	}
145 147

  
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/input/ReferenceEditorInput.java
138 138

  
139 139
	/** {@inheritDoc} */
140 140
	@Override
141
    public boolean save(Reference entity) {
141
    public Reference save(Reference entity) {
142 142
	    if(CdmStore.getCurrentSessionManager().isRemoting()) {
143
	        return CdmStore.getService(IReferenceService.class).merge(entity) != null;
143
	        return CdmStore.getService(IReferenceService.class).merge(entity);
144 144
	    } else {
145
	        return CdmStore.getService(IReferenceService.class).saveOrUpdate(entity) != null;
145
	        CdmStore.getService(IReferenceService.class).saveOrUpdate(entity);
146
	        return entity;
146 147
	    }
147 148
	}
148 149

  
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/input/TaxonEditorInput.java
70 70
		return false;
71 71
	}
72 72
	@Override
73
	public boolean save(TaxonBase entity) {
73
	public TaxonBase save(TaxonBase entity) {
74 74
	    if(CdmStore.getCurrentSessionManager().isRemoting()) {
75
	        return CdmStore.getService(ITaxonService.class).merge(entity) != null;
75
	        return CdmStore.getService(ITaxonService.class).merge(entity);
76 76
	    } else {
77
	        return CdmStore.getService(ITaxonService.class).saveOrUpdate(entity) != null;
77
	        CdmStore.getService(ITaxonService.class).saveOrUpdate(entity);
78
	        return entity;
78 79
	    }
79 80
	}
80 81

  
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/input/UserEditorInput.java
61 61
	 * @see eu.etaxonomy.taxeditor.annotatedlineeditor.IEntityPersistenceService#save(java.lang.Object)
62 62
	 */
63 63
	@Override
64
	public boolean save(User entity) {
64
	public User save(User entity) {
65 65
	    if(CdmStore.getCurrentSessionManager().isRemoting()) {
66
	        return CdmStore.getService(IUserService.class).merge(entity) != null;
66
	        return CdmStore.getService(IUserService.class).merge(entity);
67 67
	    } else {
68
	        return CdmStore.getService(IUserService.class).saveOrUpdate(entity) != null;
68
	        CdmStore.getService(IUserService.class).saveOrUpdate(entity);
69
	        return entity;
69 70
	    }
70 71

  
71 72
	}

Also available in: Unified diff