[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.dtp] Re: SQLModel doesn't use containment references ?

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@xxxxxxxxxxx> wrote in message 
news:h1360n$pps$1@xxxxxxxxxxxxxxxxxxxx
> 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.ConnectionInfo");//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@xxxxxxxxxxx> wrote in message
>> news:h0gp60$dqi$1@xxxxxxxxxxxxxxxxxxxx
>>> 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
>>
>>
>
>