Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » [Teneo] Delete Model and unset all CrossReferences
[Teneo] Delete Model and unset all CrossReferences [message #1228945] Wed, 08 January 2014 11:48 Go to next message
Jürgen Weinberger is currently offline Jürgen WeinbergerFriend
Messages: 42
Registered: August 2012
Member
Hi! I am still new to Teneo Smile and couldn't find anything usefull on the net. But people must have this problem too.

I want to unset (nullify) crossreferences of a model on delete.

With a xmi-resources this is easy
	private void unsetCrossReferences(EObject model) {
		Collection<Setting> find = EcoreUtil.UsageCrossReferencer.find(model, getEditingDomain().getResourceSet());
		for(Setting setting : find) { setting.unset(); }			
	}


I found in the web that with teneo one should use the HbDataStore:
Object[] 
HbDataStore hbDataStore
..
Object[] objects = hbDataStore.getCrossReferencers(getHibernateSession(), eObject);


This also works fine and i get all the referenced EObjects, but now i am stuck.
How do i unset/nullify the correct references in these eObjects?
Is there a way to get the "EStructuralFeature.Setting" from this EObjects to unset them?

Sure i could also manualy remove the references in the concrete objects but i am looking for a more generic way like the xmi - approach.

Is this possible and a correct approach? Does anybody now of some samples? This should be a common problem i think.

Thanks in advanced
and best regards weinma
Re: [Teneo] Delete Model and unset all CrossReferences [message #1228960 is a reply to message #1228945] Wed, 08 January 2014 12:22 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33107
Registered: July 2009
Senior Member
Jürgen,

The setting.unset call does the same thing as
eObject.eUnset(eStructuralFeature). And yes, you can get a Setting
object by casting to InternalEObject and using the eSetting method.


On 08/01/2014 12:48 PM, Jürgen Weinberger wrote:
> Hi! I am still new to Teneo :) and couldn't find anything usefull on
> the net. But people must have this problem too.
>
> I want to unset (nullify) crossreferences of a model on delete.
>
> With a xmi-resources this is easy
>
> private void unsetCrossReferences(EObject model) {
> Collection<Setting> find =
> EcoreUtil.UsageCrossReferencer.find(model,
> getEditingDomain().getResourceSet());
> for(Setting setting : find) { setting.unset(); }
> }
>
>
> I found in the web that with teneo one should use the HbDataStore:
>
> Object[] HbDataStore hbDataStore
> .
> Object[] objects =
> hbDataStore.getCrossReferencers(getHibernateSession(), eObject);
>
>
> This also works fine and i get all the referenced EObjects, but now i
> am stuck.
> How do i unset/nullify the correct references in these eObjects? Is
> there a way to get the "EStructuralFeature.Setting" from this EObjects
> to unset them?
>
> Sure i could also manualy remove the references in the concrete
> objects but i am looking for a more generic way like the xmi - approach.
>
> Is this possible and a correct approach? Does anybody now of some
> samples? This should be a common problem i think.
>
> Thanks in advanced
> and best regards weinma


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: [Teneo] Delete Model and unset all CrossReferences [message #1229023 is a reply to message #1228945] Wed, 08 January 2014 15:05 Go to previous messageGo to next message
Jürgen Weinberger is currently offline Jürgen WeinbergerFriend
Messages: 42
Registered: August 2012
Member
Hi!

Thanks for the answer! I think eObject.unset() would do the trick.

Can you just point me in the right direction? I would need to know which StructuralFeature contains the referenced EObject to unset it.
Is this even possible ?

Thanks again!
best regards
Re: [Teneo] Delete Model and unset all CrossReferences [message #1229033 is a reply to message #1229023] Wed, 08 January 2014 15:22 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33107
Registered: July 2009
Senior Member
Jürgen,

What are you trying to do? Eliminate all references to some object?
Perhaps org.eclipse.emf.ecore.util.EcoreUtil.delete(EObject, boolean)
does what you need or at least will give you the idea of how to
implement what you need.


On 08/01/2014 4:05 PM, Jürgen Weinberger wrote:
> Hi!
>
> Thanks for the answer! I think eObject.unset() would do the trick.
>
> Can you just point me in the right direction? I would need to know
> which StructuralFeature contains the referenced EObject to unset it.
> Is this even possible ?
>
> Thanks again!
> best regards


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:[Teneo] Delete Model and unset all CrossReferences
Next Topic:[Teneo] Delete Database for Unit Tests
Goto Forum:
  


Current Time: Tue Mar 19 08:40:01 GMT 2024

Powered by FUDForum. Page generated in 0.02151 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top