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

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