Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » DTP » SQLModel doesn't use containment references ?
SQLModel doesn't use containment references ? [message #56856] Sun, 07 June 2009 12:17 Go to next message
Cédric Vidal is currently offline Cédric Vidal
Messages: 101
Registered: July 2009
Senior Member
Hi guys,

Well first of all, let me say DTP is an awesome framework and I'm
currently investigating building some tooling on it. I recently tried to
save a SQLModel Schema instance into a resource but was quite surprised
when I realized my resource contained only the Schema without it's
"content".

When I gave a look at the sqlmodel.ecore, I realized that there were no
references configured as containment, which is why my Schema content is
not serialized.

Is it possible to save a Schema instance ?

Kind regards,

Cédric Vidal
Re: SQLModel doesn't use containment references ? [message #56913 is a reply to message #56856] Tue, 09 June 2009 11:06 Go to previous messageGo to next message
Eclipse User
Originally posted by: brianf.sybase.com

Hi Cedric!

Very cool. Glad you're looking at using the framework.

It's pretty easy to get the serialized EMF model out of memory. Check out
the following code and see if it helps.

--Fitz

public Database getDatabaseForProfile (IConnectionProfile profile) {

IManagedConnection managedConnection =
((IConnectionProfile)profile).getManagedConnection(" org.eclipse.datatools.connectivity.sqm.core.connection.Conne ctionInfo ");//java.sql.Connection");

if (managedConnection != null)

{

try {

ConnectionInfo connectionInfo = (ConnectionInfo)
managedConnection.getConnection().getRawConnection();

if (connectionInfo != null) {

return connectionInfo.getSharedDatabase();

}

} catch (Exception e) {

e.printStackTrace();

}

}

return null;

}



public void cacheDatabase(IConnectionProfile profile) throws IOException {

Database database = getDatabaseForProfile(profile);

String fileName = "c:\\" + database.getName();

if(fileName == null) throw new IllegalStateException();

initConnectionDirectory(fileName);

OutputStream out = new FileOutputStream(new File(fileName + "//cache.xmi"));

Resource r = new XMIResourceImpl();

r.getContents().add(database);

ResourceUtil.resolveDanglingReferences(r);

Map options = new HashMap();

options.put(XMIResource.OPTION_ENCODING, "UTF-8"); //$NON-NLS-1$

r.save(out, options);

r.getContents().clear();

}


private void initConnectionDirectory(String name) {

File dir = new File(name);

if(!dir.exists()) {

dir.mkdirs();

}

}



"C
Re: SQLModel doesn't use containment references ? [message #56944 is a reply to message #56913] Sun, 14 June 2009 11:46 Go to previous messageGo to next message
Cédric Vidal is currently offline Cédric Vidal
Messages: 101
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------030409080509010202010300
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 8bit

Hi Brian,

Thanx for the feedback. But sadly, your solution didn't get me much
further. I added the ResourceUtil.resolveDanglingReferences(resource);
which resolved the DanglingHREFException that occured some times but the
content of the XMI resource is still quite empty:

<?xml version="1.0" encoding="ASCII"?>
<SQLSchema:Database
xmlns:SQLSchema="http:///org/eclipse/datatools/modelbase/sql/schema.ecore"
name="odatest" vendor="MySql" version="5.0" schemas="/1">
<eAnnotations source="ConnectionURI">
<details key="ConnectionKey" value="odatestmysql"/>
</eAnnotations>
</SQLSchema:Database>

I also attached a screenshot of the Data Source Explorer to get a better
idea of what I'm trying to dump.

What's more, you didn't mention the absence of containment references in
the SQLModel. I'm not an expert at EMF but AFAIK, only containment
referred elements are transitively serialized in a resource.

I don't see how it would be possible to dump a SQLModel otherwise.

The only solution I see right now is to transform the SQLModel into
another metamodel suitable for storage (with containment references).

Kind regards,

C
Re: SQLModel doesn't use containment references ? [message #56967 is a reply to message #56944] Tue, 16 June 2009 10:45 Go to previous messageGo to next message
Eclipse User
Originally posted by: brianf.sybase.com

Honestly Cedric, I'm not sure why that didn't work. It's worked great for me
in the past.

Can you send me the snippet of code you're using to get out the Database
once you have an IConnectionProfile reference? I'm guessing the profile was
connected before you ran this routine to cache it to XML...

One thing you can look at is the "Save Offline" functionality. This
essentially caches the EMF model on disk in the Eclipse workspace metadata
so it can peruse it without network access. You can try it with MySQL, but I
don't know for sure it works. I'd try it with Derby first.

Any additional details you could provide would be great. There is a
containment relationship there already... just sounds like the trick is to
get to the point where you're seeing the XML generated correctly.

--Fitz

"C
Re: SQLModel doesn't use containment references ? [message #511117 is a reply to message #56967] Fri, 29 January 2010 17:53 Go to previous messageGo to next message
Cédric Vidal is currently offline Cédric Vidal
Messages: 101
Registered: July 2009
Senior Member
Hi Brian,

I feel bad to only reply to you after such a long period. I had missed
your answer and stopped investigating that problem as it wasn't critical
for me at the time.

The thing is now, I get to face that challenge again :) So I've studied
the problem again with fresh eyes and above all a better understanding
of EMF internals.

So as far as I understand it, given that I use the following snippet of
code:

Database database = getDatabaseForProfile(profile);
URI uri = URI.createPlatformResourceURI("/ClassicModels/dump.xmi");
XMLResourceImpl resource = new XMLResourceImpl(uri);
resource.getContents().add(database);
ResourceUtil.resolveDanglingReferences(resource);
resource.save(null);

.... the problem is highlighted by the following stacktrace:

org.postgresql.util.PSQLException: La fonction
org.postgresql.jdbc3.Jdbc3DatabaseMetaData.getAttributes(Str ing,String,String,String)
n'est pas encore implémentée.
at org.postgresql.Driver.notImplemented(Driver.java:738)
at
org.postgresql.jdbc3.AbstractJdbc3DatabaseMetaData.getAttrib utes(AbstractJdbc3DatabaseMetaData.java:240)
at
org.eclipse.datatools.connectivity.sqm.loader.JDBCUDTAttribu teLoader.createResultSet(JDBCUDTAttributeLoader.java:212)
at
org.eclipse.datatools.connectivity.sqm.loader.JDBCUDTAttribu teLoader.loadAttributeDefinitions(JDBCUDTAttributeLoader.jav a:171)
at
org.eclipse.datatools.connectivity.sqm.core.rte.jdbc.JDBCStr ucturedUDT.loadAttributes(JDBCStructuredUDT.java:104)
at
org.eclipse.datatools.connectivity.sqm.core.rte.jdbc.JDBCStr ucturedUDT.getAttributes(JDBCStructuredUDT.java:73)
at
org.eclipse.datatools.modelbase.sql.datatypes.impl.Structure dUserDefinedTypeImpl.eGet(StructuredUserDefinedTypeImpl.java :341)
at
org.eclipse.emf.ecore.impl.BasicEObjectImpl.eGet(BasicEObjec tImpl.java:1013)
at
org.eclipse.emf.ecore.impl.BasicEObjectImpl.eGet(BasicEObjec tImpl.java:1005)
at
org.eclipse.emf.ecore.util.EContentsEList$FeatureIteratorImp l.hasNext(EContentsEList.java:409)
at java.util.AbstractCollection.toArray(AbstractCollection.java :126)
at java.util.LinkedList.addAll(LinkedList.java:269)
at java.util.LinkedList.addAll(LinkedList.java:247)
at
org.eclipse.datatools.connectivity.sqm.internal.core.Resourc eUtil.resolveDanglingReferencesInternal(ResourceUtil.java:57 )
at
org.eclipse.datatools.connectivity.sqm.internal.core.Resourc eUtil.resolveDanglingReferencesInternal(ResourceUtil.java:53 )
at
org.eclipse.datatools.connectivity.sqm.internal.core.Resourc eUtil.resolveDanglingReferencesInternal(ResourceUtil.java:53 )
at
org.eclipse.datatools.connectivity.sqm.internal.core.Resourc eUtil.resolveDanglingReferencesInternal(ResourceUtil.java:53 )
at
org.eclipse.datatools.connectivity.sqm.internal.core.Resourc eUtil.resolveDanglingReferences(ResourceUtil.java:33)
at
com.proxiad.test.dtpmodelbasetest.handlers.SampleHandler.exe cute(SampleHandler.java:71)

When calling ResourceUtil.resolveDanglingReferences, all cross
references are resolved but the problem is that for some features, the
underlying database driver doesn't support some JDBC functionalities
required for the resolution. In the case of PostgreSQL, getAttributes
and getSuperTypes are not supported.

So basically, resolving dangling references on a SQLModel requires that
the underlying database driver supports all JDBC functionalities which
is not always the case.

Whenever a functionality is not supported by the database driver, an
exception is raised and never catched thus interrupting the resolution
of dangling references.

I guess when you used that functionality successfully, you must have
been using a database whose driven supported all required functionalities.

Nevertheless, you mention that the DTP offline saving functionality uses
this technique to cache the model but I guess they must be using some
trick here to work around resolving dangling references whose resolution
depends on using a feature missing at the driver level.

I've had a look at the DTP code but I haven't been able to figure out
how they work around that.

Any suggestion or hint at where the "Save Offline" code source is would
be great.

Regards,

Cédric

Brian Fitzpatrick a écrit :
> Honestly Cedric, I'm not sure why that didn't work. It's worked great for me
> in the past.
>
> Can you send me the snippet of code you're using to get out the Database
> once you have an IConnectionProfile reference? I'm guessing the profile was
> connected before you ran this routine to cache it to XML...
>
> One thing you can look at is the "Save Offline" functionality. This
> essentially caches the EMF model on disk in the Eclipse workspace metadata
> so it can peruse it without network access. You can try it with MySQL, but I
> don't know for sure it works. I'd try it with Derby first.
>
> Any additional details you could provide would be great. There is a
> containment relationship there already... just sounds like the trick is to
> get to the point where you're seeing the XML generated correctly.
>
> --Fitz
>
> "Cédric Vidal" <c.vidal@proxiad.com> wrote in message
> news:h1360n$pps$1@build.eclipse.org...
>> Hi Brian,
>>
>> Thanx for the feedback. But sadly, your solution didn't get me much
>> further. I added the ResourceUtil.resolveDanglingReferences(resource);
>> which resolved the DanglingHREFException that occured some times but the
>> content of the XMI resource is still quite empty:
>>
>> <?xml version="1.0" encoding="ASCII"?>
>> <SQLSchema:Database
>> xmlns:SQLSchema="http:///org/eclipse/datatools/modelbase/sql/schema.ecore"
>> name="odatest" vendor="MySql" version="5.0" schemas="/1">
>> <eAnnotations source="ConnectionURI">
>> <details key="ConnectionKey" value="odatestmysql"/>
>> </eAnnotations>
>> </SQLSchema:Database>
>>
>> I also attached a screenshot of the Data Source Explorer to get a better
>> idea of what I'm trying to dump.
>>
>> What's more, you didn't mention the absence of containment references in
>> the SQLModel. I'm not an expert at EMF but AFAIK, only containment
>> referred elements are transitively serialized in a resource.
>>
>> I don't see how it would be possible to dump a SQLModel otherwise.
>>
>> The only solution I see right now is to transform the SQLModel into
>> another metamodel suitable for storage (with containment references).
>>
>> Kind regards,
>>
>> Cédric
>>
>> Brian Fitzpatrick a écrit :
>>> Hi Cedric!
>>>
>>> Very cool. Glad you're looking at using the framework.
>>>
>>> It's pretty easy to get the serialized EMF model out of memory. Check out
>>> the following code and see if it helps.
>>>
>>> --Fitz
>>>
>>> public Database getDatabaseForProfile (IConnectionProfile profile) {
>>>
>>> IManagedConnection managedConnection =
>>> ((IConnectionProfile)profile).getManagedConnection(" org.eclipse.datatools.connectivity.sqm.core.connection.Conne ctionInfo ");//java.sql.Connection");
>>>
>>> if (managedConnection != null)
>>>
>>> {
>>>
>>> try {
>>>
>>> ConnectionInfo connectionInfo = (ConnectionInfo)
>>> managedConnection.getConnection().getRawConnection();
>>>
>>> if (connectionInfo != null) {
>>>
>>> return connectionInfo.getSharedDatabase();
>>>
>>> }
>>>
>>> } catch (Exception e) {
>>>
>>> e.printStackTrace();
>>>
>>> }
>>>
>>> }
>>>
>>> return null;
>>>
>>> }
>>>
>>>
>>>
>>> public void cacheDatabase(IConnectionProfile profile) throws IOException
>>> {
>>>
>>> Database database = getDatabaseForProfile(profile);
>>>
>>> String fileName = "c:\\" + database.getName();
>>>
>>> if(fileName == null) throw new IllegalStateException();
>>>
>>> initConnectionDirectory(fileName);
>>>
>>> OutputStream out = new FileOutputStream(new File(fileName +
>>> "//cache.xmi"));
>>>
>>> Resource r = new XMIResourceImpl();
>>>
>>> r.getContents().add(database);
>>>
>>> ResourceUtil.resolveDanglingReferences(r);
>>>
>>> Map options = new HashMap();
>>>
>>> options.put(XMIResource.OPTION_ENCODING, "UTF-8"); //$NON-NLS-1$
>>>
>>> r.save(out, options);
>>>
>>> r.getContents().clear();
>>>
>>> }
>>>
>>>
>>> private void initConnectionDirectory(String name) {
>>>
>>> File dir = new File(name);
>>>
>>> if(!dir.exists()) {
>>>
>>> dir.mkdirs();
>>>
>>> }
>>>
>>> }
>>>
>>>
>>>
>>> "Cédric Vidal" <c.vidal@proxiad.com> wrote in message
>>> news:h0gp60$dqi$1@build.eclipse.org...
>>>> Hi guys,
>>>>
>>>> Well first of all, let me say DTP is an awesome framework and I'm
>>>> currently investigating building some tooling on it. I recently tried to
>>>> save a SQLModel Schema instance into a resource but was quite surprised
>>>> when I realized my resource contained only the Schema without it's
>>>> "content".
>>>>
>>>> When I gave a look at the sqlmodel.ecore, I realized that there were no
>>>> references configured as containment, which is why my Schema content is
>>>> not serialized.
>>>>
>>>> Is it possible to save a Schema instance ?
>>>>
>>>> Kind regards,
>>>>
>>>> Cédric Vidal
>>>
>>
>
>
Re: SQLModel doesn't use containment references ? [message #511118 is a reply to message #511117] Fri, 29 January 2010 18:39 Go to previous messageGo to next message
Cédric Vidal is currently offline Cédric Vidal
Messages: 101
Registered: July 2009
Senior Member
Actually, I just found the SaveOfflineAction and WorkOfflineAction !

I just studied the sources used by the actions and I found my mistake
.... I was using a XMLResourceImpl instead of a XMIResourceImpl. Of
course the XMLResourceImpl couldn't store multiple root elements so I
ended up having nothing but the Database element serialized in the file ...

Using a XMIResourceImpl, error logs are still displayed but the model is
successfully stored on disk.

Better late than never ^^

Regards,

Cédric

Cédric Vidal a écrit :
> Hi Brian,
>
> I feel bad to only reply to you after such a long period. I had missed
> your answer and stopped investigating that problem as it wasn't critical
> for me at the time.
>
> The thing is now, I get to face that challenge again :) So I've studied
> the problem again with fresh eyes and above all a better understanding
> of EMF internals.
>
> So as far as I understand it, given that I use the following snippet of
> code:
>
> Database database = getDatabaseForProfile(profile);
> URI uri = URI.createPlatformResourceURI("/ClassicModels/dump.xmi");
> XMLResourceImpl resource = new XMLResourceImpl(uri);
> resource.getContents().add(database);
> ResourceUtil.resolveDanglingReferences(resource);
> resource.save(null);
>
> ... the problem is highlighted by the following stacktrace:
>
> org.postgresql.util.PSQLException: La fonction
> org.postgresql.jdbc3.Jdbc3DatabaseMetaData.getAttributes(Str ing,String,String,String)
> n'est pas encore implémentée.
> at org.postgresql.Driver.notImplemented(Driver.java:738)
> at
> org.postgresql.jdbc3.AbstractJdbc3DatabaseMetaData.getAttrib utes(AbstractJdbc3DatabaseMetaData.java:240)
>
> at
> org.eclipse.datatools.connectivity.sqm.loader.JDBCUDTAttribu teLoader.createResultSet(JDBCUDTAttributeLoader.java:212)
>
> at
> org.eclipse.datatools.connectivity.sqm.loader.JDBCUDTAttribu teLoader.loadAttributeDefinitions(JDBCUDTAttributeLoader.jav a:171)
>
> at
> org.eclipse.datatools.connectivity.sqm.core.rte.jdbc.JDBCStr ucturedUDT.loadAttributes(JDBCStructuredUDT.java:104)
>
> at
> org.eclipse.datatools.connectivity.sqm.core.rte.jdbc.JDBCStr ucturedUDT.getAttributes(JDBCStructuredUDT.java:73)
>
> at
> org.eclipse.datatools.modelbase.sql.datatypes.impl.Structure dUserDefinedTypeImpl.eGet(StructuredUserDefinedTypeImpl.java :341)
>
> at
> org.eclipse.emf.ecore.impl.BasicEObjectImpl.eGet(BasicEObjec tImpl.java:1013)
>
> at
> org.eclipse.emf.ecore.impl.BasicEObjectImpl.eGet(BasicEObjec tImpl.java:1005)
>
> at
> org.eclipse.emf.ecore.util.EContentsEList$FeatureIteratorImp l.hasNext(EContentsEList.java:409)
>
> at java.util.AbstractCollection.toArray(AbstractCollection.java :126)
> at java.util.LinkedList.addAll(LinkedList.java:269)
> at java.util.LinkedList.addAll(LinkedList.java:247)
> at
> org.eclipse.datatools.connectivity.sqm.internal.core.Resourc eUtil.resolveDanglingReferencesInternal(ResourceUtil.java:57 )
>
> at
> org.eclipse.datatools.connectivity.sqm.internal.core.Resourc eUtil.resolveDanglingReferencesInternal(ResourceUtil.java:53 )
>
> at
> org.eclipse.datatools.connectivity.sqm.internal.core.Resourc eUtil.resolveDanglingReferencesInternal(ResourceUtil.java:53 )
>
> at
> org.eclipse.datatools.connectivity.sqm.internal.core.Resourc eUtil.resolveDanglingReferencesInternal(ResourceUtil.java:53 )
>
> at
> org.eclipse.datatools.connectivity.sqm.internal.core.Resourc eUtil.resolveDanglingReferences(ResourceUtil.java:33)
>
> at
> com.proxiad.test.dtpmodelbasetest.handlers.SampleHandler.exe cute(SampleHandler.java:71)
>
>
> When calling ResourceUtil.resolveDanglingReferences, all cross
> references are resolved but the problem is that for some features, the
> underlying database driver doesn't support some JDBC functionalities
> required for the resolution. In the case of PostgreSQL, getAttributes
> and getSuperTypes are not supported.
>
> So basically, resolving dangling references on a SQLModel requires that
> the underlying database driver supports all JDBC functionalities which
> is not always the case.
>
> Whenever a functionality is not supported by the database driver, an
> exception is raised and never catched thus interrupting the resolution
> of dangling references.
>
> I guess when you used that functionality successfully, you must have
> been using a database whose driven supported all required functionalities.
>
> Nevertheless, you mention that the DTP offline saving functionality uses
> this technique to cache the model but I guess they must be using some
> trick here to work around resolving dangling references whose resolution
> depends on using a feature missing at the driver level.
>
> I've had a look at the DTP code but I haven't been able to figure out
> how they work around that.
>
> Any suggestion or hint at where the "Save Offline" code source is would
> be great.
>
> Regards,
>
> Cédric
>
> Brian Fitzpatrick a écrit :
>> Honestly Cedric, I'm not sure why that didn't work. It's worked great
>> for me in the past.
>>
>> Can you send me the snippet of code you're using to get out the
>> Database once you have an IConnectionProfile reference? I'm guessing
>> the profile was connected before you ran this routine to cache it to
>> XML...
>>
>> One thing you can look at is the "Save Offline" functionality. This
>> essentially caches the EMF model on disk in the Eclipse workspace
>> metadata so it can peruse it without network access. You can try it
>> with MySQL, but I don't know for sure it works. I'd try it with Derby
>> first.
>>
>> Any additional details you could provide would be great. There is a
>> containment relationship there already... just sounds like the trick
>> is to get to the point where you're seeing the XML generated correctly.
>>
>> --Fitz
>>
>> "Cédric Vidal" <c.vidal@proxiad.com> wrote in message
>> news:h1360n$pps$1@build.eclipse.org...
>>> Hi Brian,
>>>
>>> Thanx for the feedback. But sadly, your solution didn't get me much
>>> further. I added the ResourceUtil.resolveDanglingReferences(resource);
>>> which resolved the DanglingHREFException that occured some times but the
>>> content of the XMI resource is still quite empty:
>>>
>>> <?xml version="1.0" encoding="ASCII"?>
>>> <SQLSchema:Database
>>> xmlns:SQLSchema="http:///org/eclipse/datatools/modelbase/sql/schema.ecore"
>>>
>>> name="odatest" vendor="MySql" version="5.0" schemas="/1">
>>> <eAnnotations source="ConnectionURI">
>>> <details key="ConnectionKey" value="odatestmysql"/>
>>> </eAnnotations>
>>> </SQLSchema:Database>
>>>
>>> I also attached a screenshot of the Data Source Explorer to get a better
>>> idea of what I'm trying to dump.
>>>
>>> What's more, you didn't mention the absence of containment references in
>>> the SQLModel. I'm not an expert at EMF but AFAIK, only containment
>>> referred elements are transitively serialized in a resource.
>>>
>>> I don't see how it would be possible to dump a SQLModel otherwise.
>>>
>>> The only solution I see right now is to transform the SQLModel into
>>> another metamodel suitable for storage (with containment references).
>>>
>>> Kind regards,
>>>
>>> Cédric
>>>
>>> Brian Fitzpatrick a écrit :
>>>> Hi Cedric!
>>>>
>>>> Very cool. Glad you're looking at using the framework.
>>>>
>>>> It's pretty easy to get the serialized EMF model out of memory.
>>>> Check out
>>>> the following code and see if it helps.
>>>>
>>>> --Fitz
>>>>
>>>> public Database getDatabaseForProfile (IConnectionProfile profile) {
>>>>
>>>> IManagedConnection managedConnection =
>>>> ((IConnectionProfile)profile).getManagedConnection(" org.eclipse.datatools.connectivity.sqm.core.connection.Conne ctionInfo ");//java.sql.Connection");
>>>>
>>>>
>>>> if (managedConnection != null)
>>>>
>>>> {
>>>>
>>>> try {
>>>>
>>>> ConnectionInfo connectionInfo = (ConnectionInfo)
>>>> managedConnection.getConnection().getRawConnection();
>>>>
>>>> if (connectionInfo != null) {
>>>>
>>>> return connectionInfo.getSharedDatabase();
>>>>
>>>> }
>>>>
>>>> } catch (Exception e) {
>>>>
>>>> e.printStackTrace();
>>>>
>>>> }
>>>>
>>>> }
>>>>
>>>> return null;
>>>>
>>>> }
>>>>
>>>>
>>>>
>>>> public void cacheDatabase(IConnectionProfile profile) throws
>>>> IOException {
>>>>
>>>> Database database = getDatabaseForProfile(profile);
>>>>
>>>> String fileName = "c:\\" + database.getName();
>>>>
>>>> if(fileName == null) throw new IllegalStateException();
>>>>
>>>> initConnectionDirectory(fileName);
>>>>
>>>> OutputStream out = new FileOutputStream(new File(fileName +
>>>> "//cache.xmi"));
>>>>
>>>> Resource r = new XMIResourceImpl();
>>>>
>>>> r.getContents().add(database);
>>>>
>>>> ResourceUtil.resolveDanglingReferences(r);
>>>>
>>>> Map options = new HashMap();
>>>>
>>>> options.put(XMIResource.OPTION_ENCODING, "UTF-8"); //$NON-NLS-1$
>>>>
>>>> r.save(out, options);
>>>>
>>>> r.getContents().clear();
>>>>
>>>> }
>>>>
>>>>
>>>> private void initConnectionDirectory(String name) {
>>>>
>>>> File dir = new File(name);
>>>>
>>>> if(!dir.exists()) {
>>>>
>>>> dir.mkdirs();
>>>>
>>>> }
>>>>
>>>> }
>>>>
>>>>
>>>>
>>>> "Cédric Vidal" <c.vidal@proxiad.com> wrote in message
>>>> news:h0gp60$dqi$1@build.eclipse.org...
>>>>> Hi guys,
>>>>>
>>>>> Well first of all, let me say DTP is an awesome framework and I'm
>>>>> currently investigating building some tooling on it. I recently
>>>>> tried to
>>>>> save a SQLModel Schema instance into a resource but was quite
>>>>> surprised
>>>>> when I realized my resource contained only the Schema without it's
>>>>> "content".
>>>>>
>>>>> When I gave a look at the sqlmodel.ecore, I realized that there
>>>>> were no
>>>>> references configured as containment, which is why my Schema
>>>>> content is
>>>>> not serialized.
>>>>>
>>>>> Is it possible to save a Schema instance ?
>>>>>
>>>>> Kind regards,
>>>>>
>>>>> Cédric Vidal
>>>>
>>>
>>
>>
Re: SQLModel doesn't use containment references ? [message #511420 is a reply to message #511118] Mon, 01 February 2010 09:52 Go to previous message
Brian Fitzpatrick is currently offline Brian Fitzpatrick
Messages: 495
Registered: July 2009
Senior Member
Glad that worked for you! Thanks for keeping us posted on your progress!

--Fitz

Cédric Vidal wrote:
> Actually, I just found the SaveOfflineAction and WorkOfflineAction !
>
> I just studied the sources used by the actions and I found my mistake
> ... I was using a XMLResourceImpl instead of a XMIResourceImpl. Of
> course the XMLResourceImpl couldn't store multiple root elements so I
> ended up having nothing but the Database element serialized in the file ...
>
> Using a XMIResourceImpl, error logs are still displayed but the model is
> successfully stored on disk.
>
> Better late than never ^^
>
> Regards,
>
> Cédric
>
Re: SQLModel doesn't use containment references ? [message #595949 is a reply to message #56856] Tue, 09 June 2009 11:06 Go to previous message
Brian Fitzpatrick is currently offline Brian Fitzpatrick
Messages: 495
Registered: July 2009
Senior Member
Hi Cedric!

Very cool. Glad you're looking at using the framework.

It's pretty easy to get the serialized EMF model out of memory. Check out
the following code and see if it helps.

--Fitz

public Database getDatabaseForProfile (IConnectionProfile profile) {

IManagedConnection managedConnection =
((IConnectionProfile)profile).getManagedConnection(" org.eclipse.datatools.connectivity.sqm.core.connection.Conne ctionInfo ");//java.sql.Connection");

if (managedConnection != null)

{

try {

ConnectionInfo connectionInfo = (ConnectionInfo)
managedConnection.getConnection().getRawConnection();

if (connectionInfo != null) {

return connectionInfo.getSharedDatabase();

}

} catch (Exception e) {

e.printStackTrace();

}

}

return null;

}



public void cacheDatabase(IConnectionProfile profile) throws IOException {

Database database = getDatabaseForProfile(profile);

String fileName = "c:\\" + database.getName();

if(fileName == null) throw new IllegalStateException();

initConnectionDirectory(fileName);

OutputStream out = new FileOutputStream(new File(fileName + "//cache.xmi"));

Resource r = new XMIResourceImpl();

r.getContents().add(database);

ResourceUtil.resolveDanglingReferences(r);

Map options = new HashMap();

options.put(XMIResource.OPTION_ENCODING, "UTF-8"); //$NON-NLS-1$

r.save(out, options);

r.getContents().clear();

}


private void initConnectionDirectory(String name) {

File dir = new File(name);

if(!dir.exists()) {

dir.mkdirs();

}

}



"C
Re: SQLModel doesn't use containment references ? [message #595956 is a reply to message #56913] Sun, 14 June 2009 11:46 Go to previous message
Cédric Vidal is currently offline Cédric Vidal
Messages: 101
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------030409080509010202010300
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 8bit

Hi Brian,

Thanx for the feedback. But sadly, your solution didn't get me much
further. I added the ResourceUtil.resolveDanglingReferences(resource);
which resolved the DanglingHREFException that occured some times but the
content of the XMI resource is still quite empty:

<?xml version="1.0" encoding="ASCII"?>
<SQLSchema:Database
xmlns:SQLSchema="http:///org/eclipse/datatools/modelbase/sql/schema.ecore"
name="odatest" vendor="MySql" version="5.0" schemas="/1">
<eAnnotations source="ConnectionURI">
<details key="ConnectionKey" value="odatestmysql"/>
</eAnnotations>
</SQLSchema:Database>

I also attached a screenshot of the Data Source Explorer to get a better
idea of what I'm trying to dump.

What's more, you didn't mention the absence of containment references in
the SQLModel. I'm not an expert at EMF but AFAIK, only containment
referred elements are transitively serialized in a resource.

I don't see how it would be possible to dump a SQLModel otherwise.

The only solution I see right now is to transform the SQLModel into
another metamodel suitable for storage (with containment references).

Kind regards,

C
Re: SQLModel doesn't use containment references ? [message #595963 is a reply to message #56944] Tue, 16 June 2009 10:45 Go to previous message
Brian Fitzpatrick is currently offline Brian Fitzpatrick
Messages: 495
Registered: July 2009
Senior Member
Honestly Cedric, I'm not sure why that didn't work. It's worked great for me
in the past.

Can you send me the snippet of code you're using to get out the Database
once you have an IConnectionProfile reference? I'm guessing the profile was
connected before you ran this routine to cache it to XML...

One thing you can look at is the "Save Offline" functionality. This
essentially caches the EMF model on disk in the Eclipse workspace metadata
so it can peruse it without network access. You can try it with MySQL, but I
don't know for sure it works. I'd try it with Derby first.

Any additional details you could provide would be great. There is a
containment relationship there already... just sounds like the trick is to
get to the point where you're seeing the XML generated correctly.

--Fitz

"C
Re: SQLModel doesn't use containment references ? [message #597136 is a reply to message #56967] Fri, 29 January 2010 17:53 Go to previous message
Cédric Vidal is currently offline Cédric Vidal
Messages: 101
Registered: July 2009
Senior Member
Hi Brian,

I feel bad to only reply to you after such a long period. I had missed
your answer and stopped investigating that problem as it wasn't critical
for me at the time.

The thing is now, I get to face that challenge again :) So I've studied
the problem again with fresh eyes and above all a better understanding
of EMF internals.

So as far as I understand it, given that I use the following snippet of
code:

Database database = getDatabaseForProfile(profile);
URI uri = URI.createPlatformResourceURI("/ClassicModels/dump.xmi");
XMLResourceImpl resource = new XMLResourceImpl(uri);
resource.getContents().add(database);
ResourceUtil.resolveDanglingReferences(resource);
resource.save(null);

.... the problem is highlighted by the following stacktrace:

org.postgresql.util.PSQLException: La fonction
org.postgresql.jdbc3.Jdbc3DatabaseMetaData.getAttributes(Str ing,String,String,String)
n'est pas encore implémentée.
at org.postgresql.Driver.notImplemented(Driver.java:738)
at
org.postgresql.jdbc3.AbstractJdbc3DatabaseMetaData.getAttrib utes(AbstractJdbc3DatabaseMetaData.java:240)
at
org.eclipse.datatools.connectivity.sqm.loader.JDBCUDTAttribu teLoader.createResultSet(JDBCUDTAttributeLoader.java:212)
at
org.eclipse.datatools.connectivity.sqm.loader.JDBCUDTAttribu teLoader.loadAttributeDefinitions(JDBCUDTAttributeLoader.jav a:171)
at
org.eclipse.datatools.connectivity.sqm.core.rte.jdbc.JDBCStr ucturedUDT.loadAttributes(JDBCStructuredUDT.java:104)
at
org.eclipse.datatools.connectivity.sqm.core.rte.jdbc.JDBCStr ucturedUDT.getAttributes(JDBCStructuredUDT.java:73)
at
org.eclipse.datatools.modelbase.sql.datatypes.impl.Structure dUserDefinedTypeImpl.eGet(StructuredUserDefinedTypeImpl.java :341)
at
org.eclipse.emf.ecore.impl.BasicEObjectImpl.eGet(BasicEObjec tImpl.java:1013)
at
org.eclipse.emf.ecore.impl.BasicEObjectImpl.eGet(BasicEObjec tImpl.java:1005)
at
org.eclipse.emf.ecore.util.EContentsEList$FeatureIteratorImp l.hasNext(EContentsEList.java:409)
at java.util.AbstractCollection.toArray(AbstractCollection.java :126)
at java.util.LinkedList.addAll(LinkedList.java:269)
at java.util.LinkedList.addAll(LinkedList.java:247)
at
org.eclipse.datatools.connectivity.sqm.internal.core.Resourc eUtil.resolveDanglingReferencesInternal(ResourceUtil.java:57 )
at
org.eclipse.datatools.connectivity.sqm.internal.core.Resourc eUtil.resolveDanglingReferencesInternal(ResourceUtil.java:53 )
at
org.eclipse.datatools.connectivity.sqm.internal.core.Resourc eUtil.resolveDanglingReferencesInternal(ResourceUtil.java:53 )
at
org.eclipse.datatools.connectivity.sqm.internal.core.Resourc eUtil.resolveDanglingReferencesInternal(ResourceUtil.java:53 )
at
org.eclipse.datatools.connectivity.sqm.internal.core.Resourc eUtil.resolveDanglingReferences(ResourceUtil.java:33)
at
com.proxiad.test.dtpmodelbasetest.handlers.SampleHandler.exe cute(SampleHandler.java:71)

When calling ResourceUtil.resolveDanglingReferences, all cross
references are resolved but the problem is that for some features, the
underlying database driver doesn't support some JDBC functionalities
required for the resolution. In the case of PostgreSQL, getAttributes
and getSuperTypes are not supported.

So basically, resolving dangling references on a SQLModel requires that
the underlying database driver supports all JDBC functionalities which
is not always the case.

Whenever a functionality is not supported by the database driver, an
exception is raised and never catched thus interrupting the resolution
of dangling references.

I guess when you used that functionality successfully, you must have
been using a database whose driven supported all required functionalities.

Nevertheless, you mention that the DTP offline saving functionality uses
this technique to cache the model but I guess they must be using some
trick here to work around resolving dangling references whose resolution
depends on using a feature missing at the driver level.

I've had a look at the DTP code but I haven't been able to figure out
how they work around that.

Any suggestion or hint at where the "Save Offline" code source is would
be great.

Regards,

Cédric

Brian Fitzpatrick a écrit :
> Honestly Cedric, I'm not sure why that didn't work. It's worked great for me
> in the past.
>
> Can you send me the snippet of code you're using to get out the Database
> once you have an IConnectionProfile reference? I'm guessing the profile was
> connected before you ran this routine to cache it to XML...
>
> One thing you can look at is the "Save Offline" functionality. This
> essentially caches the EMF model on disk in the Eclipse workspace metadata
> so it can peruse it without network access. You can try it with MySQL, but I
> don't know for sure it works. I'd try it with Derby first.
>
> Any additional details you could provide would be great. There is a
> containment relationship there already... just sounds like the trick is to
> get to the point where you're seeing the XML generated correctly.
>
> --Fitz
>
> "Cédric Vidal" <c.vidal@proxiad.com> wrote in message
> news:h1360n$pps$1@build.eclipse.org...
>> Hi Brian,
>>
>> Thanx for the feedback. But sadly, your solution didn't get me much
>> further. I added the ResourceUtil.resolveDanglingReferences(resource);
>> which resolved the DanglingHREFException that occured some times but the
>> content of the XMI resource is still quite empty:
>>
>> <?xml version="1.0" encoding="ASCII"?>
>> <SQLSchema:Database
>> xmlns:SQLSchema="http:///org/eclipse/datatools/modelbase/sql/schema.ecore"
>> name="odatest" vendor="MySql" version="5.0" schemas="/1">
>> <eAnnotations source="ConnectionURI">
>> <details key="ConnectionKey" value="odatestmysql"/>
>> </eAnnotations>
>> </SQLSchema:Database>
>>
>> I also attached a screenshot of the Data Source Explorer to get a better
>> idea of what I'm trying to dump.
>>
>> What's more, you didn't mention the absence of containment references in
>> the SQLModel. I'm not an expert at EMF but AFAIK, only containment
>> referred elements are transitively serialized in a resource.
>>
>> I don't see how it would be possible to dump a SQLModel otherwise.
>>
>> The only solution I see right now is to transform the SQLModel into
>> another metamodel suitable for storage (with containment references).
>>
>> Kind regards,
>>
>> Cédric
>>
>> Brian Fitzpatrick a écrit :
>>> Hi Cedric!
>>>
>>> Very cool. Glad you're looking at using the framework.
>>>
>>> It's pretty easy to get the serialized EMF model out of memory. Check out
>>> the following code and see if it helps.
>>>
>>> --Fitz
>>>
>>> public Database getDatabaseForProfile (IConnectionProfile profile) {
>>>
>>> IManagedConnection managedConnection =
>>> ((IConnectionProfile)profile).getManagedConnection(" org.eclipse.datatools.connectivity.sqm.core.connection.Conne ctionInfo ");//java.sql.Connection");
>>>
>>> if (managedConnection != null)
>>>
>>> {
>>>
>>> try {
>>>
>>> ConnectionInfo connectionInfo = (ConnectionInfo)
>>> managedConnection.getConnection().getRawConnection();
>>>
>>> if (connectionInfo != null) {
>>>
>>> return connectionInfo.getSharedDatabase();
>>>
>>> }
>>>
>>> } catch (Exception e) {
>>>
>>> e.printStackTrace();
>>>
>>> }
>>>
>>> }
>>>
>>> return null;
>>>
>>> }
>>>
>>>
>>>
>>> public void cacheDatabase(IConnectionProfile profile) throws IOException
>>> {
>>>
>>> Database database = getDatabaseForProfile(profile);
>>>
>>> String fileName = "c:\\" + database.getName();
>>>
>>> if(fileName == null) throw new IllegalStateException();
>>>
>>> initConnectionDirectory(fileName);
>>>
>>> OutputStream out = new FileOutputStream(new File(fileName +
>>> "//cache.xmi"));
>>>
>>> Resource r = new XMIResourceImpl();
>>>
>>> r.getContents().add(database);
>>>
>>> ResourceUtil.resolveDanglingReferences(r);
>>>
>>> Map options = new HashMap();
>>>
>>> options.put(XMIResource.OPTION_ENCODING, "UTF-8"); //$NON-NLS-1$
>>>
>>> r.save(out, options);
>>>
>>> r.getContents().clear();
>>>
>>> }
>>>
>>>
>>> private void initConnectionDirectory(String name) {
>>>
>>> File dir = new File(name);
>>>
>>> if(!dir.exists()) {
>>>
>>> dir.mkdirs();
>>>
>>> }
>>>
>>> }
>>>
>>>
>>>
>>> "Cédric Vidal" <c.vidal@proxiad.com> wrote in message
>>> news:h0gp60$dqi$1@build.eclipse.org...
>>>> Hi guys,
>>>>
>>>> Well first of all, let me say DTP is an awesome framework and I'm
>>>> currently investigating building some tooling on it. I recently tried to
>>>> save a SQLModel Schema instance into a resource but was quite surprised
>>>> when I realized my resource contained only the Schema without it's
>>>> "content".
>>>>
>>>> When I gave a look at the sqlmodel.ecore, I realized that there were no
>>>> references configured as containment, which is why my Schema content is
>>>> not serialized.
>>>>
>>>> Is it possible to save a Schema instance ?
>>>>
>>>> Kind regards,
>>>>
>>>> Cédric Vidal
>>>
>>
>
>
Re: SQLModel doesn't use containment references ? [message #597143 is a reply to message #511117] Fri, 29 January 2010 18:39 Go to previous message
Cédric Vidal is currently offline Cédric Vidal
Messages: 101
Registered: July 2009
Senior Member
Actually, I just found the SaveOfflineAction and WorkOfflineAction !

I just studied the sources used by the actions and I found my mistake
.... I was using a XMLResourceImpl instead of a XMIResourceImpl. Of
course the XMLResourceImpl couldn't store multiple root elements so I
ended up having nothing but the Database element serialized in the file ...

Using a XMIResourceImpl, error logs are still displayed but the model is
successfully stored on disk.

Better late than never ^^

Regards,

Cédric

Cédric Vidal a écrit :
> Hi Brian,
>
> I feel bad to only reply to you after such a long period. I had missed
> your answer and stopped investigating that problem as it wasn't critical
> for me at the time.
>
> The thing is now, I get to face that challenge again :) So I've studied
> the problem again with fresh eyes and above all a better understanding
> of EMF internals.
>
> So as far as I understand it, given that I use the following snippet of
> code:
>
> Database database = getDatabaseForProfile(profile);
> URI uri = URI.createPlatformResourceURI("/ClassicModels/dump.xmi");
> XMLResourceImpl resource = new XMLResourceImpl(uri);
> resource.getContents().add(database);
> ResourceUtil.resolveDanglingReferences(resource);
> resource.save(null);
>
> ... the problem is highlighted by the following stacktrace:
>
> org.postgresql.util.PSQLException: La fonction
> org.postgresql.jdbc3.Jdbc3DatabaseMetaData.getAttributes(Str ing,String,String,String)
> n'est pas encore implémentée.
> at org.postgresql.Driver.notImplemented(Driver.java:738)
> at
> org.postgresql.jdbc3.AbstractJdbc3DatabaseMetaData.getAttrib utes(AbstractJdbc3DatabaseMetaData.java:240)
>
> at
> org.eclipse.datatools.connectivity.sqm.loader.JDBCUDTAttribu teLoader.createResultSet(JDBCUDTAttributeLoader.java:212)
>
> at
> org.eclipse.datatools.connectivity.sqm.loader.JDBCUDTAttribu teLoader.loadAttributeDefinitions(JDBCUDTAttributeLoader.jav a:171)
>
> at
> org.eclipse.datatools.connectivity.sqm.core.rte.jdbc.JDBCStr ucturedUDT.loadAttributes(JDBCStructuredUDT.java:104)
>
> at
> org.eclipse.datatools.connectivity.sqm.core.rte.jdbc.JDBCStr ucturedUDT.getAttributes(JDBCStructuredUDT.java:73)
>
> at
> org.eclipse.datatools.modelbase.sql.datatypes.impl.Structure dUserDefinedTypeImpl.eGet(StructuredUserDefinedTypeImpl.java :341)
>
> at
> org.eclipse.emf.ecore.impl.BasicEObjectImpl.eGet(BasicEObjec tImpl.java:1013)
>
> at
> org.eclipse.emf.ecore.impl.BasicEObjectImpl.eGet(BasicEObjec tImpl.java:1005)
>
> at
> org.eclipse.emf.ecore.util.EContentsEList$FeatureIteratorImp l.hasNext(EContentsEList.java:409)
>
> at java.util.AbstractCollection.toArray(AbstractCollection.java :126)
> at java.util.LinkedList.addAll(LinkedList.java:269)
> at java.util.LinkedList.addAll(LinkedList.java:247)
> at
> org.eclipse.datatools.connectivity.sqm.internal.core.Resourc eUtil.resolveDanglingReferencesInternal(ResourceUtil.java:57 )
>
> at
> org.eclipse.datatools.connectivity.sqm.internal.core.Resourc eUtil.resolveDanglingReferencesInternal(ResourceUtil.java:53 )
>
> at
> org.eclipse.datatools.connectivity.sqm.internal.core.Resourc eUtil.resolveDanglingReferencesInternal(ResourceUtil.java:53 )
>
> at
> org.eclipse.datatools.connectivity.sqm.internal.core.Resourc eUtil.resolveDanglingReferencesInternal(ResourceUtil.java:53 )
>
> at
> org.eclipse.datatools.connectivity.sqm.internal.core.Resourc eUtil.resolveDanglingReferences(ResourceUtil.java:33)
>
> at
> com.proxiad.test.dtpmodelbasetest.handlers.SampleHandler.exe cute(SampleHandler.java:71)
>
>
> When calling ResourceUtil.resolveDanglingReferences, all cross
> references are resolved but the problem is that for some features, the
> underlying database driver doesn't support some JDBC functionalities
> required for the resolution. In the case of PostgreSQL, getAttributes
> and getSuperTypes are not supported.
>
> So basically, resolving dangling references on a SQLModel requires that
> the underlying database driver supports all JDBC functionalities which
> is not always the case.
>
> Whenever a functionality is not supported by the database driver, an
> exception is raised and never catched thus interrupting the resolution
> of dangling references.
>
> I guess when you used that functionality successfully, you must have
> been using a database whose driven supported all required functionalities.
>
> Nevertheless, you mention that the DTP offline saving functionality uses
> this technique to cache the model but I guess they must be using some
> trick here to work around resolving dangling references whose resolution
> depends on using a feature missing at the driver level.
>
> I've had a look at the DTP code but I haven't been able to figure out
> how they work around that.
>
> Any suggestion or hint at where the "Save Offline" code source is would
> be great.
>
> Regards,
>
> Cédric
>
> Brian Fitzpatrick a écrit :
>> Honestly Cedric, I'm not sure why that didn't work. It's worked great
>> for me in the past.
>>
>> Can you send me the snippet of code you're using to get out the
>> Database once you have an IConnectionProfile reference? I'm guessing
>> the profile was connected before you ran this routine to cache it to
>> XML...
>>
>> One thing you can look at is the "Save Offline" functionality. This
>> essentially caches the EMF model on disk in the Eclipse workspace
>> metadata so it can peruse it without network access. You can try it
>> with MySQL, but I don't know for sure it works. I'd try it with Derby
>> first.
>>
>> Any additional details you could provide would be great. There is a
>> containment relationship there already... just sounds like the trick
>> is to get to the point where you're seeing the XML generated correctly.
>>
>> --Fitz
>>
>> "Cédric Vidal" <c.vidal@proxiad.com> wrote in message
>> news:h1360n$pps$1@build.eclipse.org...
>>> Hi Brian,
>>>
>>> Thanx for the feedback. But sadly, your solution didn't get me much
>>> further. I added the ResourceUtil.resolveDanglingReferences(resource);
>>> which resolved the DanglingHREFException that occured some times but the
>>> content of the XMI resource is still quite empty:
>>>
>>> <?xml version="1.0" encoding="ASCII"?>
>>> <SQLSchema:Database
>>> xmlns:SQLSchema="http:///org/eclipse/datatools/modelbase/sql/schema.ecore"
>>>
>>> name="odatest" vendor="MySql" version="5.0" schemas="/1">
>>> <eAnnotations source="ConnectionURI">
>>> <details key="ConnectionKey" value="odatestmysql"/>
>>> </eAnnotations>
>>> </SQLSchema:Database>
>>>
>>> I also attached a screenshot of the Data Source Explorer to get a better
>>> idea of what I'm trying to dump.
>>>
>>> What's more, you didn't mention the absence of containment references in
>>> the SQLModel. I'm not an expert at EMF but AFAIK, only containment
>>> referred elements are transitively serialized in a resource.
>>>
>>> I don't see how it would be possible to dump a SQLModel otherwise.
>>>
>>> The only solution I see right now is to transform the SQLModel into
>>> another metamodel suitable for storage (with containment references).
>>>
>>> Kind regards,
>>>
>>> Cédric
>>>
>>> Brian Fitzpatrick a écrit :
>>>> Hi Cedric!
>>>>
>>>> Very cool. Glad you're looking at using the framework.
>>>>
>>>> It's pretty easy to get the serialized EMF model out of memory.
>>>> Check out
>>>> the following code and see if it helps.
>>>>
>>>> --Fitz
>>>>
>>>> public Database getDatabaseForProfile (IConnectionProfile profile) {
>>>>
>>>> IManagedConnection managedConnection =
>>>> ((IConnectionProfile)profile).getManagedConnection(" org.eclipse.datatools.connectivity.sqm.core.connection.Conne ctionInfo ");//java.sql.Connection");
>>>>
>>>>
>>>> if (managedConnection != null)
>>>>
>>>> {
>>>>
>>>> try {
>>>>
>>>> ConnectionInfo connectionInfo = (ConnectionInfo)
>>>> managedConnection.getConnection().getRawConnection();
>>>>
>>>> if (connectionInfo != null) {
>>>>
>>>> return connectionInfo.getSharedDatabase();
>>>>
>>>> }
>>>>
>>>> } catch (Exception e) {
>>>>
>>>> e.printStackTrace();
>>>>
>>>> }
>>>>
>>>> }
>>>>
>>>> return null;
>>>>
>>>> }
>>>>
>>>>
>>>>
>>>> public void cacheDatabase(IConnectionProfile profile) throws
>>>> IOException {
>>>>
>>>> Database database = getDatabaseForProfile(profile);
>>>>
>>>> String fileName = "c:\\" + database.getName();
>>>>
>>>> if(fileName == null) throw new IllegalStateException();
>>>>
>>>> initConnectionDirectory(fileName);
>>>>
>>>> OutputStream out = new FileOutputStream(new File(fileName +
>>>> "//cache.xmi"));
>>>>
>>>> Resource r = new XMIResourceImpl();
>>>>
>>>> r.getContents().add(database);
>>>>
>>>> ResourceUtil.resolveDanglingReferences(r);
>>>>
>>>> Map options = new HashMap();
>>>>
>>>> options.put(XMIResource.OPTION_ENCODING, "UTF-8"); //$NON-NLS-1$
>>>>
>>>> r.save(out, options);
>>>>
>>>> r.getContents().clear();
>>>>
>>>> }
>>>>
>>>>
>>>> private void initConnectionDirectory(String name) {
>>>>
>>>> File dir = new File(name);
>>>>
>>>> if(!dir.exists()) {
>>>>
>>>> dir.mkdirs();
>>>>
>>>> }
>>>>
>>>> }
>>>>
>>>>
>>>>
>>>> "Cédric Vidal" <c.vidal@proxiad.com> wrote in message
>>>> news:h0gp60$dqi$1@build.eclipse.org...
>>>>> Hi guys,
>>>>>
>>>>> Well first of all, let me say DTP is an awesome framework and I'm
>>>>> currently investigating building some tooling on it. I recently
>>>>> tried to
>>>>> save a SQLModel Schema instance into a resource but was quite
>>>>> surprised
>>>>> when I realized my resource contained only the Schema without it's
>>>>> "content".
>>>>>
>>>>> When I gave a look at the sqlmodel.ecore, I realized that there
>>>>> were no
>>>>> references configured as containment, which is why my Schema
>>>>> content is
>>>>> not serialized.
>>>>>
>>>>> Is it possible to save a Schema instance ?
>>>>>
>>>>> Kind regards,
>>>>>
>>>>> Cédric Vidal
>>>>
>>>
>>
>>
Re: SQLModel doesn't use containment references ? [message #597150 is a reply to message #511118] Mon, 01 February 2010 09:52 Go to previous message
Brian Fitzpatrick is currently offline Brian Fitzpatrick
Messages: 495
Registered: July 2009
Senior Member
Glad that worked for you! Thanks for keeping us posted on your progress!

--Fitz

Cédric Vidal wrote:
> Actually, I just found the SaveOfflineAction and WorkOfflineAction !
>
> I just studied the sources used by the actions and I found my mistake
> ... I was using a XMLResourceImpl instead of a XMIResourceImpl. Of
> course the XMLResourceImpl couldn't store multiple root elements so I
> ended up having nothing but the Database element serialized in the file ...
>
> Using a XMIResourceImpl, error logs are still displayed but the model is
> successfully stored on disk.
>
> Better late than never ^^
>
> Regards,
>
> Cédric
>
Previous Topic:Instead of Trigger Error
Next Topic:Datatools Install/Uninstall Problems
Goto Forum:
  


Current Time: Fri Aug 22 05:53:34 EDT 2014

Powered by FUDForum. Page generated in 0.03011 seconds