Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 157905
Collapse All | Expand All

(-)src/org/eclipse/hyades/resources/database/internal/impl/BasePagingList.java (-10 / +35 lines)
Lines 30-35 Link Here
30
import org.eclipse.emf.ecore.resource.ResourceSet;
30
import org.eclipse.emf.ecore.resource.ResourceSet;
31
import org.eclipse.emf.ecore.util.DelegatingEcoreEList.Dynamic;
31
import org.eclipse.emf.ecore.util.DelegatingEcoreEList.Dynamic;
32
import org.eclipse.hyades.loaders.util.IPagingList;
32
import org.eclipse.hyades.loaders.util.IPagingList;
33
import org.eclipse.hyades.models.cbe.CBEPackage;
34
import org.eclipse.hyades.models.hierarchy.HierarchyPackage;
33
import org.eclipse.hyades.models.hierarchy.util.IntList;
35
import org.eclipse.hyades.models.hierarchy.util.IntList;
34
import org.eclipse.hyades.models.hierarchy.util.PerfUtil;
36
import org.eclipse.hyades.models.hierarchy.util.PerfUtil;
35
import org.eclipse.hyades.resources.database.internal.DBCollectedExceptions;
37
import org.eclipse.hyades.resources.database.internal.DBCollectedExceptions;
Lines 45-52 Link Here
45
 * be returned in the generated and reflective EMF APIs.
47
 * be returned in the generated and reflective EMF APIs.
46
 *
48
 *
47
 * @author slavescu
49
 * @author slavescu
50
 * @since 4.4
48
 */
51
 */
49
public abstract class BasePagingList extends Dynamic implements IPagingList {
52
public abstract class BasePagingList extends Dynamic implements IPagingList {
53
	public static int RS_FETCH_SIZE = 200;
54
50
	public static class PageInfo {
55
	public static class PageInfo {
51
		List page;
56
		List page;
52
		int index;
57
		int index;
Lines 95-101 Link Here
95
	
100
	
96
	protected ResultSet rs;
101
	protected ResultSet rs;
97
	
102
	
98
	protected boolean modified=false;
103
//	protected boolean modified=false;
99
	//private List cachedIds=null;
104
	//private List cachedIds=null;
100
	
105
	
101
	protected List delegateList() {
106
	protected List delegateList() {
Lines 154-163 Link Here
154
					index = index*pagingSize;
159
					index = index*pagingSize;
155
				}
160
				}
156
				
161
				
157
				getRS().setFetchSize(200);
158
				if (!getRS().absolute(index + 1))
159
					throw new IndexOutOfBoundsException("Index: " + index + ", Size: " + delegateSize());
160
	
161
				if (getDataType() != null) {
162
				if (getDataType() != null) {
162
					loadEDataType(index, length, (EDataType) getFeatureByColumn().getEType());
163
					loadEDataType(index, length, (EDataType) getFeatureByColumn().getEType());
163
				} else {
164
				} else {
Lines 195-200 Link Here
195
			}
196
			}
196
		}
197
		}
197
198
199
		getRS().setFetchSize(RS_FETCH_SIZE);
200
		if (!getRS().absolute(index + 1))
201
			throw new IndexOutOfBoundsException("Index: " + index + ", Size: " + delegateSize());
202
198
		int i = 0;
203
		int i = 0;
199
		currentPage = new ArrayList();
204
		currentPage = new ArrayList();
200
		do {
205
		do {
Lines 223-237 Link Here
223
				return;
228
				return;
224
			}
229
			}
225
		}
230
		}
231
		getRS().setFetchSize(RS_FETCH_SIZE);
232
		if (!getRS().absolute(index + 1))
233
			throw new IndexOutOfBoundsException("Index: " + index + ", Size: " + delegateSize());
234
226
		IdsTypes idsTypes = new IdsTypes(length);
235
		IdsTypes idsTypes = new IdsTypes(length);
227
		int i = 0;
236
		int i = 0;
228
		EClass columnClass = getOutputElementType();
237
		EClass columnClass = getOutputElementType();
229
		short classId = (short)getDBMap().getClassId(columnClass);
238
		short classId = (short)getDBMap().getClassId(columnClass);
239
		//hack for defaultEvents toArray
240
		if(classId==(short)getDBMap().getClassId(HierarchyPackage.eINSTANCE.getAbstractDefaultEvent()))
241
			classId=(short)getDBMap().getClassId(CBEPackage.eINSTANCE.getCBECommonBaseEvent());
242
		
230
		do {
243
		do {
231
			i++;
244
			i++;
232
			try {
245
			try {
233
				//TODO add support for id_TYPE from query
246
				//TODO add support for id_TYPE from query
234
				if(useId_TYPE())
247
				if(useId_TYPE() && getRS().getMetaData().getColumnCount()>1)
235
					classId = getRS().getShort(getColumnPos() + 2);
248
					classId = getRS().getShort(getColumnPos() + 2);
236
				idsTypes.add(getRS().getInt(getColumnPos() + 1),classId);
249
				idsTypes.add(getRS().getInt(getColumnPos() + 1),classId);
237
			} catch (Exception e) {
250
			} catch (Exception e) {
Lines 336-344 Link Here
336
	}
349
	}
337
350
338
	protected int delegateLastIndexOf(Object object) {
351
	protected int delegateLastIndexOf(Object object) {
339
		if (object == null)
352
		if (object == null || size==0)
353
			return -1;
354
		if(size!=-1 && rs==null && currentPage!=null)
355
		{
356
			for (int i = currentPage.size()-1; i >= 0; i--) {
357
				if(currentPage.get(i)==object)
358
					return i;
359
			}
340
			return -1;
360
			return -1;
341
		return getIndex(object, -1, true);
361
		}
362
		else
363
		{
364
			return getIndex(object, -1, true);
365
		}
366
342
	}
367
	}
343
368
344
	protected ListIterator delegateListIterator() {
369
	protected ListIterator delegateListIterator() {
Lines 571-581 Link Here
571
	}
596
	}
572
	protected ResultSet getRS() {
597
	protected ResultSet getRS() {
573
		if(rs==null)
598
		if(rs==null)
574
			intiRS();
599
			initRS();
575
		return rs;
600
		return rs;
576
	}
601
	}
577
602
578
	protected abstract void intiRS();
603
	protected abstract void initRS();
579
604
580
	protected List convertToTypes(List list) {
605
	protected List convertToTypes(List list) {
581
		for (int i = 0; i < list.size(); i=i+2) {
606
		for (int i = 0; i < list.size(); i=i+2) {
(-)src/org/eclipse/hyades/resources/database/internal/impl/DynamicPagingListImpl.java (-38 / +173 lines)
Lines 12-21 Link Here
12
 **********************************************************************/
12
 **********************************************************************/
13
package org.eclipse.hyades.resources.database.internal.impl;
13
package org.eclipse.hyades.resources.database.internal.impl;
14
import java.sql.ResultSet;
14
import java.sql.ResultSet;
15
import java.sql.SQLException;
15
import java.sql.Statement;
16
import java.sql.Statement;
17
import java.util.ArrayList;
16
import java.util.Collection;
18
import java.util.Collection;
17
import java.util.Collections;
19
import java.util.Collections;
20
import java.util.Iterator;
21
import java.util.List;
18
22
23
import org.eclipse.emf.common.notify.Notification;
19
import org.eclipse.emf.common.notify.NotificationChain;
24
import org.eclipse.emf.common.notify.NotificationChain;
20
import org.eclipse.emf.ecore.EAttribute;
25
import org.eclipse.emf.ecore.EAttribute;
21
import org.eclipse.emf.ecore.EClass;
26
import org.eclipse.emf.ecore.EClass;
Lines 32-38 Link Here
32
import org.eclipse.hyades.resources.database.internal.DBResource;
37
import org.eclipse.hyades.resources.database.internal.DBResource;
33
import org.eclipse.hyades.resources.database.internal.Database;
38
import org.eclipse.hyades.resources.database.internal.Database;
34
import org.eclipse.hyades.resources.database.internal.InternalDatabase;
39
import org.eclipse.hyades.resources.database.internal.InternalDatabase;
35
import org.eclipse.hyades.resources.database.internal.ReferenceQuery;
36
import org.eclipse.hyades.resources.database.internal.extensions.DBCommandFactory;
40
import org.eclipse.hyades.resources.database.internal.extensions.DBCommandFactory;
37
import org.eclipse.hyades.resources.database.internal.extensions.IdsTypes;
41
import org.eclipse.hyades.resources.database.internal.extensions.IdsTypes;
38
import org.eclipse.hyades.resources.database.internal.extensions.JDBCHelper;
42
import org.eclipse.hyades.resources.database.internal.extensions.JDBCHelper;
Lines 46-51 Link Here
46
	private static final long serialVersionUID = 3762247548060316217L;
50
	private static final long serialVersionUID = 3762247548060316217L;
47
	protected InternalDatabase database;
51
	protected InternalDatabase database;
48
	protected int ownerId;
52
	protected int ownerId;
53
	private int updateCount;
49
	public DynamicPagingListImpl(InternalEObject owner, EStructuralFeature eStructuralFeature, DBResource resource, int pagingSize) {
54
	public DynamicPagingListImpl(InternalEObject owner, EStructuralFeature eStructuralFeature, DBResource resource, int pagingSize) {
50
		super(owner, eStructuralFeature);
55
		super(owner, eStructuralFeature);
51
		this.database = (InternalDatabase) resource.getDatabase();
56
		this.database = (InternalDatabase) resource.getDatabase();
Lines 59-65 Link Here
59
	protected void init(int pagingSize) {
64
	protected void init(int pagingSize) {
60
		this.pagingSize = pagingSize;
65
		this.pagingSize = pagingSize;
61
		size = -1;
66
		size = -1;
62
		modified = false;
67
//		modified = false;
63
		this.cache = database.getObjectCache();
68
		this.cache = database.getObjectCache();
64
		Integer id = cache.getId(owner);
69
		Integer id = cache.getId(owner);
65
		if(id==null)
70
		if(id==null)
Lines 71-77 Link Here
71
				//TODO add better error handling here
76
				//TODO add better error handling here
72
			}
77
			}
73
			if(id!=null)
78
			if(id!=null)
79
			{
80
				id = new Integer(id.intValue()+1);
81
			
74
				cache.add(owner, id);
82
				cache.add(owner, id);
83
			}
75
			else
84
			else
76
				cache.add(owner, new Integer(0));
85
				cache.add(owner, new Integer(0));
77
		}
86
		}
Lines 89-104 Link Here
89
		else
98
		else
90
			return resource.isInDatabase();
99
			return resource.isInDatabase();
91
	}
100
	}
92
93
	protected EObject[] getObjects(ReferenceQuery query) {
94
		EObject[] referenced = null;
95
		try {
96
			referenced = getInternalDatabase().getObjects(query);
97
		} catch (Exception e) {
98
			throw new DBCollectedExceptions(e);
99
		}
100
		return referenced;
101
	}
102
	
101
	
103
	/**
102
	/**
104
	 * @see org.eclipse.hyades.resources.getInternalDatabase().PagingList#getPagingSize()
103
	 * @see org.eclipse.hyades.resources.getInternalDatabase().PagingList#getPagingSize()
Lines 133-150 Link Here
133
		}
132
		}
134
		return database;
133
		return database;
135
	}
134
	}
136
	protected void addAdapter(EObject object) {
137
		if (object == null)
138
			return;
139
		DBResource resource = (DBResource) object.eResource();
140
		if (resource == null)
141
			return;
142
		EContentAdapter contentAdapter = resource.getContentAdapter();
143
		if (contentAdapter == null)
144
			return;
145
		if (!object.eAdapters().contains(contentAdapter))
146
			object.eAdapters().add(contentAdapter);
147
	}
148
	
135
	
149
	protected EStructuralFeature getFeatureByColumn() {
136
	protected EStructuralFeature getFeatureByColumn() {
150
		return getEStructuralFeature();
137
		return getEStructuralFeature();
Lines 163-170 Link Here
163
		}
150
		}
164
		return null;
151
		return null;
165
	}
152
	}
166
	protected void intiRS() {
153
	protected void initRS() {
167
		try {
154
		try {
155
			if(updateCount>0)
156
			{
157
				try {
158
					database.forceUpdates();
159
				} catch (Exception e) {
160
					throw new DBCollectedExceptions(e);
161
				}
162
				updateCount=0;
163
			}
164
168
			if(rs!=null)
165
			if(rs!=null)
169
				rs.close();
166
				rs.close();
170
			
167
			
Lines 175-181 Link Here
175
			if(getEStructuralFeature() instanceof EReference)
172
			if(getEStructuralFeature() instanceof EReference)
176
			{
173
			{
177
				query = factory.createReferenceQuery(idsTypes, (EReference)getEStructuralFeature(), getDBMap(), getJDBCHelper().getDatabaseType() , getEStructuralFeature().isOrdered());
174
				query = factory.createReferenceQuery(idsTypes, (EReference)getEStructuralFeature(), getDBMap(), getJDBCHelper().getDatabaseType() , getEStructuralFeature().isOrdered());
178
				
179
			}
175
			}
180
			else
176
			else
181
			{
177
			{
Lines 209-226 Link Here
209
			return null;
205
			return null;
210
		}
206
		}
211
	}
207
	}
212
//	protected void addCurrentPageToContainer() {
208
213
//		for (int i = 0,length =currentPage.size(); i < length; i++) {
214
//			if(currentPage.get(i)!=null && ((EObject)currentPage.get(i)).eContainer()==null)
215
//			{
216
//				InternalEObject elem = ((InternalEObject)currentPage.get(i));
217
//				if(getInverseEReference()!=null)
218
//					elem.eBasicSetContainer(owner,getInverseFeatureID(),null);
219
//				else
220
//					elem.eBasicSetContainer(owner,elem.eContainerFeatureID(),null);
221
//			}
222
//		}
223
//	}
224
	protected boolean useId_TYPE() {
209
	protected boolean useId_TYPE() {
225
		if(getDataType()==null)
210
		if(getDataType()==null)
226
			return true;
211
			return true;
Lines 241-245 Link Here
241
			}
226
			}
242
		}
227
		}
243
	}
228
	}
229
	protected Object delegateGet(int index) {
230
		if(updateCount>0)
231
		{
232
			try {
233
				database.forceUpdates();
234
			} catch (Exception e) {
235
				throw new DBCollectedExceptions(e);
236
			}
237
			updateCount=0;
238
		}
239
		return super.delegateGet(index);
240
	}
241
	protected void delegateAdd(Object object) {
242
		delegateAdd(size(), object);
243
	}
244
	
245
	
246
	protected void delegateAdd(int index, Object element) {
247
		if(element instanceof EObject)
248
		{
249
			DBResourceContentAdapter adapter = addAdapter((EObject)element);
250
			if(adapter!=null)
251
			{
252
				adapter.notifyChanged(createNotification(Notification.ADD, null, element, index, delegateIsEmpty()));
253
				addToPageIfLoaded(index,element);
254
			}
255
		}
256
		else
257
		{
258
			for (Iterator iterator = owner.eAdapters().iterator(); iterator.hasNext();) {
259
				Object adapter = (Object) iterator.next();
260
				if (adapter instanceof DBResourceContentAdapter) {
261
					((DBResourceContentAdapter)adapter).notifyChanged(createNotification(Notification.ADD, null, element, index, delegateIsEmpty()));
262
					addToPageIfLoaded(index,element);
263
					break;
264
				}
265
			}
266
		}
267
		delegateSize();
268
		size++;
269
		updateCount++;
270
	}
271
	
272
	protected void addToPageIfLoaded(int index, Object element) {
273
		if(index-currentIndex > 0 && index-currentIndex<pagingSize-1)
274
		{
275
			if(currentPage==null)
276
				currentPage = new ArrayList(pagingSize);
277
			currentPage.add(element);
278
			currentLength=currentPage.size();
279
			if(currentLength==pagingSize)
280
			{
281
				PageInfo pageInfo=new PageInfo(currentPage,currentIndex/pagingSize,currentLength);
282
				if(getFIFO().size()==FIFO_LIMIT)
283
					getFIFO().remove(0);
284
				getFIFO().add(pageInfo);
285
				currentPage=null;
286
			}
287
		}
288
		else
289
		{
290
			int pageIndex = index/pagingSize;
291
			pageIndex = pageIndex*pagingSize;
292
			
293
			PageInfo pageInfo = getPageByPageIndex(pageIndex);
294
			if(pageInfo==null)
295
			{
296
				List l = new ArrayList();
297
				l.add(element);
298
				pageInfo=new PageInfo(l,pageIndex*pagingSize,1);
299
				if(getFIFO().size()==FIFO_LIMIT)
300
					getFIFO().remove(0);
301
				getFIFO().add(pageInfo);
302
			}
303
		}
304
		if(rs!=null)
305
			try {
306
				rs.close();
307
				rs=null;
308
			} catch (SQLException e) {
309
				rs=null;
310
				throw new DBCollectedExceptions(e);
311
			}
312
	}
313
	
314
	protected PageInfo getPageByPageIndex(int pageIndex)
315
	{
316
		//find page
317
		for (int i = getFIFO().size(); i-->0;) {
318
			PageInfo pageInfo = (PageInfo)getFIFO().get(i);
319
			if(pageInfo.getIndex()==pageIndex )
320
			{
321
				return pageInfo;
322
			}
323
		}
324
		return null;
325
	}
326
	protected DBResourceContentAdapter addAdapter(EObject object) {
327
		if (object != null)
328
		{
329
			DBResource resource = (DBResource) object.eResource();
330
			if (resource != null)
331
			{
332
				EContentAdapter contentAdapter = resource.getContentAdapter();
333
				if (contentAdapter != null)
334
				{
335
					if (!object.eAdapters().contains(contentAdapter))
336
						object.eAdapters().add(contentAdapter);
337
					return (DBResourceContentAdapter)contentAdapter;
338
				}
339
			}
340
			for (Iterator iterator = owner.eAdapters().iterator(); iterator.hasNext();) {
341
				Object adapter = (Object) iterator.next();
342
				if (adapter instanceof DBResourceContentAdapter) {
343
					if (!object.eAdapters().contains(adapter))
344
						object.eAdapters().add(adapter);
345
					return (DBResourceContentAdapter)adapter;
346
				}
347
			}
348
		}
349
		else
350
		{
351
			for (Iterator iterator = owner.eAdapters().iterator(); iterator.hasNext();) {
352
				Object adapter = (Object) iterator.next();
353
				if (adapter instanceof DBResourceContentAdapter) {
354
					return (DBResourceContentAdapter)adapter;
355
				}
356
			}
357
		}
358
		return null;
359
	}
360
	
361
	/*
362
	 * (non-Javadoc)
363
	 * 
364
	 * @see org.eclipse.emf.common.util.DelegatingEList#delegateClear()
365
	 */
366
	protected void delegateClear() {
367
		init(pagingSize);
368
		size=0;
369
	}
244
370
371
	
372
	public void set(Object newValue) {
373
		throw new UnsupportedOperationException();
374
	}
375
376
	public void unset() {
377
		throw new UnsupportedOperationException();
378
	}
379
	
245
} // DynamicPagingListImpl
380
} // DynamicPagingListImpl
(-)src/org/eclipse/hyades/resources/database/internal/impl/IndirectedList.java (-7 / +29 lines)
Lines 12-18 Link Here
12
package org.eclipse.hyades.resources.database.internal.impl;
12
package org.eclipse.hyades.resources.database.internal.impl;
13
import java.sql.ResultSet;
13
import java.sql.ResultSet;
14
import java.util.Collection;
14
import java.util.Collection;
15
import java.util.List;
16
15
17
import org.eclipse.emf.common.notify.NotificationChain;
16
import org.eclipse.emf.common.notify.NotificationChain;
18
import org.eclipse.emf.common.util.URI;
17
import org.eclipse.emf.common.util.URI;
Lines 24-29 Link Here
24
import org.eclipse.emf.ecore.InternalEObject;
23
import org.eclipse.emf.ecore.InternalEObject;
25
import org.eclipse.emf.ecore.resource.Resource;
24
import org.eclipse.emf.ecore.resource.Resource;
26
import org.eclipse.emf.ecore.resource.ResourceSet;
25
import org.eclipse.emf.ecore.resource.ResourceSet;
26
import org.eclipse.hyades.models.cbe.CBECommonBaseEvent;
27
import org.eclipse.hyades.models.hierarchy.HierarchyPackage;
27
import org.eclipse.hyades.models.hierarchy.extensions.ExtensionsPackage;
28
import org.eclipse.hyades.models.hierarchy.extensions.ExtensionsPackage;
28
import org.eclipse.hyades.models.hierarchy.extensions.Query;
29
import org.eclipse.hyades.models.hierarchy.extensions.Query;
29
import org.eclipse.hyades.models.hierarchy.extensions.SimpleOperand;
30
import org.eclipse.hyades.models.hierarchy.extensions.SimpleOperand;
Lines 89-95 Link Here
89
	protected EClass getOutputElementType() {
90
	protected EClass getOutputElementType() {
90
		return ((SimpleOperand) query.getOutputElements().get(getColumnPos())).getType();
91
		return ((SimpleOperand) query.getOutputElements().get(getColumnPos())).getType();
91
	}
92
	}
92
	protected void intiRS() {
93
	protected void initRS() {
93
		//TODO MS try to reinitialize rs here
94
		//TODO MS try to reinitialize rs here
94
	}
95
	}
95
	protected int getColumnPos() {
96
	protected int getColumnPos() {
Lines 110-115 Link Here
110
	protected Resource getResource() {
111
	protected Resource getResource() {
111
		return resourceSet.getResource(URI.createURI((String)query.getSources().get(0)).trimFragment(), false);
112
		return resourceSet.getResource(URI.createURI((String)query.getSources().get(0)).trimFragment(), false);
112
	}
113
	}
114
	
115
	protected int findContainerType(EObject o){
116
		if(o instanceof CBECommonBaseEvent)
117
			return dbMap.getClassId(HierarchyPackage.eINSTANCE.getTRCAgent());
118
		return -1;
119
	}
120
	
113
	protected void addCurrentPageToContainer() throws Exception{
121
	protected void addCurrentPageToContainer() throws Exception{
114
		if(currentPage==null || currentPage.size()==0 || !(eStructuralFeature instanceof EReference))
122
		if(currentPage==null || currentPage.size()==0 || !(eStructuralFeature instanceof EReference))
115
			return;
123
			return;
Lines 125-133 Link Here
125
				if(id!=null)
133
				if(id!=null)
126
				{
134
				{
127
					String p_p = cache.getP_P(id);
135
					String p_p = cache.getP_P(id);
128
					int start = p_p.lastIndexOf('/',p_p.length()-2) ==-1 ?  0 : p_p.lastIndexOf('/',p_p.length()-2);
136
					int preSlashIndex = p_p.lastIndexOf('/',p_p.length()-2);
129
					String sContainerId = p_p.substring(start,p_p.length()-1);
137
					
130
					Integer containerId = new Integer(sContainerId);
138
					String sContainerId = p_p.substring(preSlashIndex>0?preSlashIndex:0,p_p.length()-1);
139
					int cId = Integer.parseInt(sContainerId);
140
					if(idsTypes.getIds().indexOf(cId, 0)!=-1)
141
						continue;
142
143
					Integer containerId = new Integer(cId);
131
					InternalEObject container = (InternalEObject)cache.getObject(containerId);
144
					InternalEObject container = (InternalEObject)cache.getObject(containerId);
132
					if(container!=null)
145
					if(container!=null)
133
					{
146
					{
Lines 135-141 Link Here
135
						eObject.eBasicSetContainer(container,0, (NotificationChain)null);
148
						eObject.eBasicSetContainer(container,0, (NotificationChain)null);
136
						continue;
149
						continue;
137
					}
150
					}
138
					int type = dbMap.getClassId((EClass)((EObject)o).eClass().eContainingFeature().getEType());
151
					
152
					int type = findContainerType((EObject)o);
153
					
139
					idsTypes.add(Integer.parseInt(sContainerId), (short)type);
154
					idsTypes.add(Integer.parseInt(sContainerId), (short)type);
140
				}
155
				}
141
			}
156
			}
Lines 157-162 Link Here
157
			}
172
			}
158
173
159
			get.execute();
174
			get.execute();
175
			
160
			for (int i = 0,length = currentPage.size(); i < length; i++) {
176
			for (int i = 0,length = currentPage.size(); i < length; i++) {
161
				Object o = currentPage.get(i);
177
				Object o = currentPage.get(i);
162
				if(o!=null && o instanceof EObject)
178
				if(o!=null && o instanceof EObject)
Lines 168-174 Link Here
168
					if(id!=null)
184
					if(id!=null)
169
					{
185
					{
170
						String p_p = cache.getP_P(id);
186
						String p_p = cache.getP_P(id);
171
						String sContainerId = p_p.substring(p_p.lastIndexOf('/',p_p.length()-2),p_p.length()-1);
187
						int preSlashIndex = p_p.lastIndexOf('/',p_p.length()-2);
188
						
189
						String sContainerId = p_p.substring(preSlashIndex>0?preSlashIndex:0,p_p.length()-1);
172
						Integer containerId = new Integer(sContainerId);
190
						Integer containerId = new Integer(sContainerId);
173
						InternalEObject container = (InternalEObject)cache.getObject(containerId);
191
						InternalEObject container = (InternalEObject)cache.getObject(containerId);
174
						if(container!=null)
192
						if(container!=null)
Lines 183-188 Link Here
183
	}
201
	}
184
	protected void delegateClear() {
202
	protected void delegateClear() {
185
	}
203
	}
204
	
205
	public void clear() {
206
	}
207
	
186
	public NotificationChain inverseRemove(Object object, NotificationChain notifications) {
208
	public NotificationChain inverseRemove(Object object, NotificationChain notifications) {
187
		return notifications;
209
		return notifications;
188
	}
210
	}
(-)src/org/eclipse/hyades/resources/database/internal/impl/DBResourceContentAdapter.java (-1 / +3 lines)
Lines 155-167 Link Here
155
155
156
	protected void processAdd(Notification notification) {
156
	protected void processAdd(Notification notification) {
157
		if (notification.getFeature() == null)
157
		if (notification.getFeature() == null)
158
		{
158
			return;
159
			return;
160
		}
159
161
160
		EObject owner = (EObject) notification.getNotifier();
162
		EObject owner = (EObject) notification.getNotifier();
161
		EStructuralFeature feature = (EStructuralFeature) notification.getFeature();
163
		EStructuralFeature feature = (EStructuralFeature) notification.getFeature();
162
		if(feature.isTransient())
164
		if(feature.isTransient())
163
			return;
165
			return;
164
		if (owner.eGet(feature) instanceof PagingList)
166
		if (owner.eGet(feature) instanceof DynamicPagingListImpl)
165
			updateForPagingListAdd(notification, owner, (EReference) feature);
167
			updateForPagingListAdd(notification, owner, (EReference) feature);
166
		else if (feature.isMany() && resource.isInDatabase()) {
168
		else if (feature.isMany() && resource.isInDatabase()) {
167
			updateDatabase(notification, owner);
169
			updateDatabase(notification, owner);
(-)src/org/eclipse/hyades/resources/database/internal/impl/UpdateCommand.java (-1 / +3 lines)
Lines 214-221 Link Here
214
			{
214
			{
215
				Integer sourceId = getObjectId(source);
215
				Integer sourceId = getObjectId(source);
216
				Integer targetId = getObjectId(target);
216
				Integer targetId = getObjectId(target);
217
				
217
				if (sourceId == null || targetId == null) {
218
				if (sourceId == null || targetId == null) {
218
					delayed.add(notification);
219
					if(target!=null)//TODO MS - remove this hack, null cases should be handled also
220
						delayed.add(notification);
219
					continue;
221
					continue;
220
				}
222
				}
221
				if(!sourceToSourceType.containsKey(sourceId))
223
				if(!sourceToSourceType.containsKey(sourceId))
(-)src/org/eclipse/hyades/resources/database/internal/extensions/AddCommand.java (-1 / +2 lines)
Lines 334-341 Link Here
334
	}
334
	}
335
	protected void assignObjectsToIds(List objects) {
335
	protected void assignObjectsToIds(List objects) {
336
		for (int i = 0, l = objects.size(); i < l; i++) {
336
		for (int i = 0, l = objects.size(); i < l; i++) {
337
			Integer key = new Integer(++largestDatabaseId);
338
			Object object = objects.get(i);
337
			Object object = objects.get(i);
338
			Integer key = new Integer(++largestDatabaseId);
339
			
339
			objectsToKeys.put(object, key);
340
			objectsToKeys.put(object, key);
340
		}
341
		}
341
	}
342
	}
(-)src-hierarchy/org/eclipse/hyades/loaders/util/LoadersUtils.java (-1 / +1 lines)
Lines 730-736 Link Here
730
	 * @deprecated Use {@link ModelDebugger#logCallstackWithLimit(Throwable,int)} instead
730
	 * @deprecated Use {@link ModelDebugger#logCallstackWithLimit(Throwable,int)} instead
731
	 */
731
	 */
732
	public static void logCallstackWithLimit(Throwable e, final int limit) {
732
	public static void logCallstackWithLimit(Throwable e, final int limit) {
733
		ModelDebugger.logCallstackWithLimit(e, limit);
733
		ModelDebugger.logCallstackWithLimit(e, limit,System.out);
734
	}
734
	}
735
735
736
    /**
736
    /**
(-)src-hierarchy/org/eclipse/hyades/loaders/util/HierarchyLookupService.java (-2 / +2 lines)
Lines 60-70 Link Here
60
                return true;
60
                return true;
61
            }
61
            }
62
        } else if (type == AgentsContext.class) {
62
        } else if (type == AgentsContext.class) {
63
            if (((AgentsContext) object).getId() != null) {
63
//            if (((AgentsContext) object).getId() != null) {
64
                addOrRemove(typeMap, LoadersUtils.getLookUpKey(((AgentsContext) object).getId()), object, remove);
64
                addOrRemove(typeMap, LoadersUtils.getLookUpKey(((AgentsContext) object).getId()), object, remove);
65
65
66
                return true;
66
                return true;
67
            }
67
//            }
68
        } else if (type == AgentProxyContext.class) {
68
        } else if (type == AgentProxyContext.class) {
69
            AgentProxyContext c = (AgentProxyContext) object;
69
            AgentProxyContext c = (AgentProxyContext) object;
70
70
(-)src-hierarchy/org/eclipse/hyades/models/hierarchy/util/HierarchyXMIResourceImpl.java (-1 / +3 lines)
Lines 312-323 Link Here
312
		if ((context != null) && (context.getAgentProxy() != null)) {
312
		if ((context != null) && (context.getAgentProxy() != null)) {
313
			context.getAgentProxy().setAgent(null);
313
			context.getAgentProxy().setAgent(null);
314
		}
314
		}
315
		context=null;
315
		//        SaveUtil.removeDocument(this);
316
		//        SaveUtil.removeDocument(this);
316
	}
317
	}
317
318
318
	public void doShallowUnload() {
319
	public void doShallowUnload() {
319
		unloadLookupContext();
320
		unloadLookupContext();
320
		EMFUtil.unload(this);
321
		EMFUtil.unload(this);
322
		context=null;
321
		//        SaveUtil.removeDocument(this);
323
		//        SaveUtil.removeDocument(this);
322
	}
324
	}
323
325
Lines 491-497 Link Here
491
493
492
			LookupServiceExtensions.getInstance().deregister(context);
494
			LookupServiceExtensions.getInstance().deregister(context);
493
			LookupServiceExtensions.getInstance().deregister(null, HierarchyContext.class, getURI().toString());
495
			LookupServiceExtensions.getInstance().deregister(null, HierarchyContext.class, getURI().toString());
494
			context = null;
496
//			context = null;
495
		}
497
		}
496
	}
498
	}
497
499
(-)src-hierarchy/org/eclipse/hyades/models/hierarchy/util/PerfUtil.java (+3 lines)
Lines 105-111 Link Here
105
	}
105
	}
106
	public void printStatus(PrintStream out) {
106
	public void printStatus(PrintStream out) {
107
		if(debug)
107
		if(debug)
108
		{
108
			out.println(msg + ": deltaTime=" + getTime() + " - stopTime=" + stopTime + " - usedMemoryDelta=" + getUsedMemoryDelta() +" - freeMemoryDelta=" + getFreeMemoryDelta()+ " - totalMemoryDelta=" + getTotalMemoryDelta() + " - usedMemoryAfter=" + (stopTotMem-stopFreeMem)+ " - freeMemoryAfter=" + stopFreeMem +" - totalMemoryAfter=" + stopTotMem);
109
			out.println(msg + ": deltaTime=" + getTime() + " - stopTime=" + stopTime + " - usedMemoryDelta=" + getUsedMemoryDelta() +" - freeMemoryDelta=" + getFreeMemoryDelta()+ " - totalMemoryDelta=" + getTotalMemoryDelta() + " - usedMemoryAfter=" + (stopTotMem-stopFreeMem)+ " - freeMemoryAfter=" + stopFreeMem +" - totalMemoryAfter=" + stopTotMem);
110
			ModelDebugger.logCallstackWithLimit(new Throwable("PerfUtil"),ModelDebugger.INSTANCE.exceptionDepth,out);
111
		}
109
	}
112
	}
110
	/**
113
	/**
111
	 * @return
114
	 * @return
(-)src-utils/org/eclipse/hyades/models/util/ModelDebugger.java (-5 / +5 lines)
Lines 303-318 Link Here
303
		if(msg!=null)
303
		if(msg!=null)
304
			printStream.println(msg);
304
			printStream.println(msg);
305
		if (e != null) {
305
		if (e != null) {
306
			logCallstackWithLimit(e,10000);
306
			logCallstackWithLimit(e,10000,printStream);
307
		}
307
		}
308
		else
308
		else
309
		{
309
		{
310
			printStream.print("\tnull Throwable");
310
			printStream.print("\tnull Throwable");
311
			if(ModelDebugger.INSTANCE.exceptionDepth>0)
311
			if(ModelDebugger.INSTANCE.exceptionDepth>0)
312
				logCallstackWithLimit(new Throwable("LOG_CALL_STACK"),ModelDebugger.INSTANCE.exceptionDepth);
312
				logCallstackWithLimit(new Throwable("LOG_CALL_STACK"),ModelDebugger.INSTANCE.exceptionDepth,printStream);
313
		}
313
		}
314
	}
314
	}
315
	public static void logCallstackWithLimit(Throwable e, final int limit) {
315
	public static void logCallstackWithLimit(Throwable e, final int limit, PrintStream out) {
316
		StringWriter  stringWriter = new StringWriter (){
316
		StringWriter  stringWriter = new StringWriter (){
317
			public String toString() {
317
			public String toString() {
318
				StringBuffer buf = getBuffer();
318
				StringBuffer buf = getBuffer();
Lines 346-356 Link Here
346
			}
346
			}
347
		};
347
		};
348
		e.printStackTrace(new PrintWriter(stringWriter));
348
		e.printStackTrace(new PrintWriter(stringWriter));
349
		printStream.println(stringWriter.toString());
349
		out.println(stringWriter.toString());
350
	}
350
	}
351
	public static void log(String s) {
351
	public static void log(String s) {
352
		printStream.println(Thread.currentThread()+" - "+s);
352
		printStream.println(Thread.currentThread()+" - "+s);
353
		if(INSTANCE.exceptionDepth > 0 )
353
		if(INSTANCE.exceptionDepth > 0 )
354
			logCallstackWithLimit(new Throwable("LOG_CALL_STACK"),ModelDebugger.INSTANCE.exceptionDepth);
354
			logCallstackWithLimit(new Throwable("LOG_CALL_STACK"),ModelDebugger.INSTANCE.exceptionDepth,printStream);
355
	}
355
	}
356
}
356
}

Return to bug 157905