Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » [TENEO][EMF] Viewing problems in Linux and Windows
[TENEO][EMF] Viewing problems in Linux and Windows [message #431444] Thu, 09 July 2009 17:07 Go to next message
Waldi  is currently offline Waldi Friend
Messages: 60
Registered: July 2009
Member
This is a multi-part message in MIME format.
--------------030205000707090506000309
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 7bit

Hi,

i had the attached source for my service. My problem is on windows this
service works realy good and my navigation tree is displayed fine.

I work with 2 resources. (resJahr and resPerson) All things that are in
the second resource are not displayed in Linux.

On my navigation tree i use a AdapterFactoryContentProvider. Can this be
the problem?

Can someone take a look at my file. Please have a special look at
resJahr and resAlles.

If i change the things like in the TeneoLibraryPersistenceService2.java
its the same problem.

Thanks Waldi

--------------030205000707090506000309
Content-Type: text/x-java;
name="TeneoLibraryPersistenceService.java"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="TeneoLibraryPersistenceService.java"

package de.connection.service.teneo;

import java.io.IOException;
import java.util.Collections;
import java.util.Properties;

import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EPackage;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.teneo.PersistenceOptions;
import org.eclipse.emf.teneo.hibernate.HbDataStore;
import org.eclipse.emf.teneo.hibernate.HbHelper;
import org.eclipse.emf.teneo.hibernate.resource.HibernateResource;
import org.eclipse.emf.teneo.hibernate.resource.SessionController;
import org.hibernate.cfg.Environment;

import zlvp.*;

import de.connection.Activator;
import de.connection.service.BaseLibraryPersistenceService;

public abstract class TeneoLibraryPersistenceService extends BaseLibraryPersistenceService {

private Resource resAlles;
private Resource resPerson;
private Resource resAnrede;
private Resource resGeschlecht;
private Resource resJahr;
private SessionController sc;

public String getCategory() {
return "Teneo";
}

protected Resource doGetResource() {
if( resAlles == null ) {
initHibernate();
initResource();
}
return resJahr;
}

protected Resource doGetResourcePerson() {
return resPerson;
}

protected Resource doGetResourceGeschlecht() {
return resGeschlecht;
}

protected Resource doGetResourceAnrede() {
return resAnrede;
}

protected IStatus doSave() {
try {
sc.getSessionWrapper().beginTransaction();
resJahr.save(null);
resPerson.save(null);
sc.getSessionWrapper().commitTransaction();
return Status.OK_STATUS;
} catch (IOException e) {
return new Status(IStatus.ERROR,Activator.PLUGIN_ID,"Saveing failed",e);
}
// return Status.OK_STATUS;
}

protected IStatus doSavePerson() {
try {
resPerson.save(null);
return Status.OK_STATUS;
} catch (IOException e) {
return new Status(IStatus.ERROR,Activator.PLUGIN_ID,"Saveing failed",e);
}
// return Status.OK_STATUS;
}

protected IStatus doSaveAnrede() {
try {
resAnrede.save(null);
return Status.OK_STATUS;
} catch (IOException e) {
return new Status(IStatus.ERROR,Activator.PLUGIN_ID,"Saveing failed",e);
}
// return Status.OK_STATUS;
}

protected IStatus doSaveGeschlecht() {
try {
resGeschlecht.save(null);
return Status.OK_STATUS;
} catch (IOException e) {
return new Status(IStatus.ERROR,Activator.PLUGIN_ID,"Saveing failed",e);
}
// return Status.OK_STATUS;
}

private void initResource() {
String uriStr1 = "hibernate://?" + HibernateResource.DS_NAME_PARAM + "="
+ "zlvp&query1=FROM Jahr";

String uriStr2 = "hibernate://?" + HibernateResource.SESSION_CONTROLLER_PARAM + "="
+ "testsc&query1=FROM Person";

String uriStr3 = "hibernate://?" + HibernateResource.SESSION_CONTROLLER_PARAM + "="
+ "testsc&query1=FROM Geschlecht";

String uriStr4 = "hibernate://?" + HibernateResource.SESSION_CONTROLLER_PARAM + "="
+ "testsc&query1=FROM Anrede";

String uriStr5 = "hibernate://?" + HibernateResource.SESSION_CONTROLLER_PARAM + "="
+ "testsc&query1=FROM Jahr";

final URI uri1 = URI.createURI(uriStr1);
final URI uri2 = URI.createURI(uriStr2);
final URI uri3 = URI.createURI(uriStr3);
final URI uri4 = URI.createURI(uriStr4);
final URI uri5 = URI.createURI(uriStr5);

try {
resAlles = getResourceSet().createResource(uri1);
resPerson = getResourceSet().createResource(uri2);
resGeschlecht = getResourceSet().createResource(uri3);
resAnrede = getResourceSet().createResource(uri4);
resJahr = getResourceSet().createResource(uri5);
} catch (Exception e) {
e.printStackTrace();
}

if (resAlles != null) {
// load the resource domain
try {
sc.getSessionWrapper().beginTransaction();
resAlles.load(Collections.EMPTY_MAP);
resPerson.load(Collections.EMPTY_MAP);
resJahr.load(Collections.EMPTY_MAP);
sc.getSessionWrapper().commitTransaction();
} catch (IOException e) {
e.printStackTrace();
}
}

// if (resPerson != null) {
// // load the resource domain
// try {
// resPerson.load(Collections.EMPTY_MAP);
// } catch (IOException e) {
// e.printStackTrace();
// }
// }

if (resAnrede != null) {
// load the resource domain
try {
resAnrede.load(Collections.EMPTY_MAP);
} catch (IOException e) {
e.printStackTrace();
}
}

if (resGeschlecht != null) {
// load the resource domain
try {
resGeschlecht.load(Collections.EMPTY_MAP);
} catch (IOException e) {
e.printStackTrace();
}
}
}

private void initHibernate() {
sc = new SessionController();
// Set the database information, Environment is
// org.hibernate.cfg.Environment
final Properties props = new Properties();

props.setProperty(Environment.DRIVER, doGetDriver());
props.setProperty(Environment.USER, doGetUser());
props.setProperty(Environment.PASS, doGetPassword());
props.setProperty(Environment.URL, doGetUrl());
props.setProperty(Environment.DIALECT, doGetDialect());
props.setProperty(Environment.SHOW_SQL, "true");
props.setProperty(PersistenceOptions.INHERITANCE_MAPPING, "SINGLE_TABLE");

// HibernateResource

HbDataStore hbds = HbHelper.INSTANCE.createRegisterDataStore("zlvp");

// when creating a SessionController you have to pass your HbDataStore instance
sc.setHbDataStore(hbds);

// register the SessionController, the name is used in the uri of the resource
SessionController.registerSessionController("testsc", sc);

// sets its epackages stored in this datastore
hbds.setEPackages(new EPackage[] { ZlvpPackage.eINSTANCE });

// set the relational database to use and other properties
hbds.setProperties(props);

// initialize, also creates the database tables
hbds.initialize();
// System.out.println(hbds.getMappingXML());
}

protected abstract String doGetDriver();
protected abstract String doGetUser();
protected abstract String doGetPassword();
protected abstract String doGetUrl();
protected abstract String doGetDialect();
}

--------------030205000707090506000309
Content-Type: text/x-java;
name="TeneoLibraryPersistenceService2.java"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="TeneoLibraryPersistenceService2.java"

package de.connection.service.teneo;

import java.io.IOException;
import java.util.Collections;
import java.util.Properties;

import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EPackage;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.teneo.PersistenceOptions;
import org.eclipse.emf.teneo.hibernate.HbDataStore;
import org.eclipse.emf.teneo.hibernate.HbHelper;
import org.eclipse.emf.teneo.hibernate.resource.HibernateResource;
import org.eclipse.emf.teneo.hibernate.resource.SessionController;
import org.hibernate.cfg.Environment;

import zlvp.*;

import de.connection.Activator;
import de.connection.service.BaseLibraryPersistenceService;

public abstract class TeneoLibraryPersistenceService extends BaseLibraryPersistenceService {

private Resource resAlles;
private Resource resPerson;
private Resource resAnrede;
private Resource resGeschlecht;
private Resource resJahr;
private SessionController sc;

public String getCategory() {
return "Teneo";
}

protected Resource doGetResource() {
if( resAlles == null ) {
initHibernate();
initResource();
}
return resAlles;
}

protected Resource doGetResourcePerson() {
return resPerson;
}

protected Resource doGetResourceGeschlecht() {
return resGeschlecht;
}

protected Resource doGetResourceAnrede() {
return resAnrede;
}

protected IStatus doSave() {
try {
sc.getSessionWrapper().beginTransaction();
resAlles.save(null);
resPerson.save(null);
sc.getSessionWrapper().commitTransaction();
return Status.OK_STATUS;
} catch (IOException e) {
return new Status(IStatus.ERROR,Activator.PLUGIN_ID,"Saveing failed",e);
}
// return Status.OK_STATUS;
}

protected IStatus doSavePerson() {
try {
resPerson.save(null);
return Status.OK_STATUS;
} catch (IOException e) {
return new Status(IStatus.ERROR,Activator.PLUGIN_ID,"Saveing failed",e);
}
// return Status.OK_STATUS;
}

protected IStatus doSaveAnrede() {
try {
resAnrede.save(null);
return Status.OK_STATUS;
} catch (IOException e) {
return new Status(IStatus.ERROR,Activator.PLUGIN_ID,"Saveing failed",e);
}
// return Status.OK_STATUS;
}

protected IStatus doSaveGeschlecht() {
try {
resGeschlecht.save(null);
return Status.OK_STATUS;
} catch (IOException e) {
return new Status(IStatus.ERROR,Activator.PLUGIN_ID,"Saveing failed",e);
}
// return Status.OK_STATUS;
}

private void initResource() {
String uriStr1 = "hibernate://?" + HibernateResource.DS_NAME_PARAM + "="
+ "zlvp&query1=FROM Jahr";

String uriStr2 = "hibernate://?" + HibernateResource.SESSION_CONTROLLER_PARAM + "="
+ "testsc&query1=FROM Person";

String uriStr3 = "hibernate://?" + HibernateResource.SESSION_CONTROLLER_PARAM + "="
+ "testsc&query1=FROM Geschlecht";

String uriStr4 = "hibernate://?" + HibernateResource.SESSION_CONTROLLER_PARAM + "="
+ "testsc&query1=FROM Anrede";

String uriStr5 = "hibernate://?" + HibernateResource.SESSION_CONTROLLER_PARAM + "="
+ "testsc&query1=FROM Jahr";

final URI uri1 = URI.createURI(uriStr1);
final URI uri2 = URI.createURI(uriStr2);
final URI uri3 = URI.createURI(uriStr3);
final URI uri4 = URI.createURI(uriStr4);
final URI uri5 = URI.createURI(uriStr5);

try {
resAlles = getResourceSet().createResource(uri1);
resPerson = getResourceSet().createResource(uri2);
resGeschlecht = getResourceSet().createResource(uri3);
resAnrede = getResourceSet().createResource(uri4);
resJahr = getResourceSet().createResource(uri5);
} catch (Exception e) {
e.printStackTrace();
}

if (resAlles != null) {
// load the resource domain
try {
sc.getSessionWrapper().beginTransaction();
resAlles.load(Collections.EMPTY_MAP);
resPerson.load(Collections.EMPTY_MAP);
sc.getSessionWrapper().commitTransaction();
} catch (IOException e) {
e.printStackTrace();
}
}

// if (resPerson != null) {
// // load the resource domain
// try {
// resPerson.load(Collections.EMPTY_MAP);
// } catch (IOException e) {
// e.printStackTrace();
// }
// }

if (resAnrede != null) {
// load the resource domain
try {
resAnrede.load(Collections.EMPTY_MAP);
} catch (IOException e) {
e.printStackTrace();
}
}

if (resGeschlecht != null) {
// load the resource domain
try {
resGeschlecht.load(Collections.EMPTY_MAP);
} catch (IOException e) {
e.printStackTrace();
}
}
}

private void initHibernate() {
sc = new SessionController();
// Set the database information, Environment is
// org.hibernate.cfg.Environment
final Properties props = new Properties();

props.setProperty(Environment.DRIVER, doGetDriver());
props.setProperty(Environment.USER, doGetUser());
props.setProperty(Environment.PASS, doGetPassword());
props.setProperty(Environment.URL, doGetUrl());
props.setProperty(Environment.DIALECT, doGetDialect());
props.setProperty(Environment.SHOW_SQL, "true");
props.setProperty(PersistenceOptions.INHERITANCE_MAPPING, "SINGLE_TABLE");

// HibernateResource

HbDataStore hbds = HbHelper.INSTANCE.createRegisterDataStore("zlvp");

// when creating a SessionController you have to pass your HbDataStore instance
sc.setHbDataStore(hbds);

// register the SessionController, the name is used in the uri of the resource
SessionController.registerSessionController("testsc", sc);

// sets its epackages stored in this datastore
hbds.setEPackages(new EPackage[] { ZlvpPackage.eINSTANCE });

// set the relational database to use and other properties
hbds.setProperties(props);

// initialize, also creates the database tables
hbds.initialize();
// System.out.println(hbds.getMappingXML());
}

protected abstract String doGetDriver();
protected abstract String doGetUser();
protected abstract String doGetPassword();
protected abstract String doGetUrl();
protected abstract String doGetDialect();
}

--------------030205000707090506000309--
Re: [TENEO][EMF] Viewing problems in Linux and Windows [message #431445 is a reply to message #431444] Thu, 09 July 2009 17:35 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Waldi,
You say not-displayed, but did you debug down into the resPerson resource in case of linux? Is the resource contents
empty? Or is it more an issue on the UI side you think?

gr. Martin

Waldi Waldemar wrote:
> Hi,
>
> i had the attached source for my service. My problem is on windows this
> service works realy good and my navigation tree is displayed fine.
>
> I work with 2 resources. (resJahr and resPerson) All things that are in
> the second resource are not displayed in Linux.
>
> On my navigation tree i use a AdapterFactoryContentProvider. Can this be
> the problem?
>
> Can someone take a look at my file. Please have a special look at
> resJahr and resAlles.
>
> If i change the things like in the TeneoLibraryPersistenceService2.java
> its the same problem.
>
> Thanks Waldi


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
Re: [TENEO][EMF] Viewing problems in Linux and Windows [message #431448 is a reply to message #431445] Thu, 09 July 2009 18:46 Go to previous messageGo to next message
Waldi  is currently offline Waldi Friend
Messages: 60
Registered: July 2009
Member
Ok sorry. It was my faul. I check out a wrong version of the Model from
the SVN SORRY. It is boring. Forget it. Embarrassing (Red Head).

Hmm ok.... Now, if it no problem for you, I would ask another question:

I try this:

private void removeTeilnehmer(zlvp.Gruppe gruppe, Person teilnehmer){
Command cmdRemove = RemoveCommand.create(p.getEditingDomain(), gruppe,
ZlvpPackage.Literals.GRUPPE__TEILNEHMER, teilnehmer);
Command cmdAdd = new
AddCommand(p.getEditingDomain(),p.getResourcePerson().getCon tents(),teilnehmer);
if (cmdRemove.canExecute()) {
if (cmdAdd.canExecute())
{
p.getEditingDomain().getCommandStack().execute(cmdRemove);
p.getEditingDomain().getCommandStack().execute(cmdAdd);
}
}else{
System.out.println("Hat ned geklappt");
}
}

1Gruppe-N Persons (I had change my model)

But all my Persons get deleted in the database. But I would only delete
the association. How can I do it?

With a 1Group:NLeiter:1Persons the command work realy fine.

Sorry again for the circumstances.....

Martin Taal schrieb:
> Hi Waldi,
> You say not-displayed, but did you debug down into the resPerson
> resource in case of linux? Is the resource contents empty? Or is it more
> an issue on the UI side you think?
>
> gr. Martin
>
> Waldi Waldemar wrote:
>> Hi,
>>
>> i had the attached source for my service. My problem is on windows this
>> service works realy good and my navigation tree is displayed fine.
>>
>> I work with 2 resources. (resJahr and resPerson) All things that are
>> in the second resource are not displayed in Linux.
>>
>> On my navigation tree i use a AdapterFactoryContentProvider. Can this
>> be the problem?
>>
>> Can someone take a look at my file. Please have a special look at
>> resJahr and resAlles.
>>
>> If i change the things like in the
>> TeneoLibraryPersistenceService2.java its the same problem.
>>
>> Thanks Waldi
>
>
Re: [TENEO][EMF] Viewing problems in Linux and Windows [message #431454 is a reply to message #431448] Sat, 11 July 2009 05:57 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Waldi,
Sorry, I am not sure why but I had not yet answered your post....

I am not sure but I think Leiter-Person is a containment relation? Then Teneo will automatically map this as a delete
and orphan-delete cascade setting. You can see the hibernate mapping to check this.
If you don't want this then there are two options:
- set a OneToMany annotation with the specific cascade you want
- set the PersistenceOptions.CASCADE_POLICY_ON_CONTAINMENT (this is currently set to ALL, mening also orphan-delete)

This last option influences all containment relations.

gr. Martin

Waldi Waldemar wrote:
> Ok sorry. It was my faul. I check out a wrong version of the Model from
> the SVN SORRY. It is boring. Forget it. Embarrassing (Red Head).
>
> Hmm ok.... Now, if it no problem for you, I would ask another question:
>
> I try this:
>
> private void removeTeilnehmer(zlvp.Gruppe gruppe, Person teilnehmer){
> Command cmdRemove = RemoveCommand.create(p.getEditingDomain(),
> gruppe, ZlvpPackage.Literals.GRUPPE__TEILNEHMER, teilnehmer);
> Command cmdAdd = new
> AddCommand(p.getEditingDomain(),p.getResourcePerson().getCon tents(),teilnehmer);
>
> if (cmdRemove.canExecute()) {
> if (cmdAdd.canExecute())
> {
> p.getEditingDomain().getCommandStack().execute(cmdRemove);
> p.getEditingDomain().getCommandStack().execute(cmdAdd);
> }
> }else{
> System.out.println("Hat ned geklappt");
> }
> }
>
> 1Gruppe-N Persons (I had change my model)
>
> But all my Persons get deleted in the database. But I would only delete
> the association. How can I do it?
>
> With a 1Group:NLeiter:1Persons the command work realy fine.
>
> Sorry again for the circumstances.....
>
> Martin Taal schrieb:
>> Hi Waldi,
>> You say not-displayed, but did you debug down into the resPerson
>> resource in case of linux? Is the resource contents empty? Or is it
>> more an issue on the UI side you think?
>>
>> gr. Martin
>>
>> Waldi Waldemar wrote:
>>> Hi,
>>>
>>> i had the attached source for my service. My problem is on windows this
>>> service works realy good and my navigation tree is displayed fine.
>>>
>>> I work with 2 resources. (resJahr and resPerson) All things that are
>>> in the second resource are not displayed in Linux.
>>>
>>> On my navigation tree i use a AdapterFactoryContentProvider. Can this
>>> be the problem?
>>>
>>> Can someone take a look at my file. Please have a special look at
>>> resJahr and resAlles.
>>>
>>> If i change the things like in the
>>> TeneoLibraryPersistenceService2.java its the same problem.
>>>
>>> Thanks Waldi
>>
>>


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
Previous Topic:Re: EMF Migration - EDataType error
Next Topic:how to create a stand alone plugin foom EMF model
Goto Forum:
  


Current Time: Fri Apr 19 04:26:42 GMT 2024

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

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

Back to the top