Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 355787 - [DB] Complete core mappings for Ecore data types
Summary: [DB] Complete core mappings for Ecore data types
Status: CLOSED FIXED
Alias: None
Product: EMF
Classification: Modeling
Component: cdo.db (show other bugs)
Version: 4.2   Edit
Hardware: All All
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: Eike Stepper CLA
QA Contact: Eike Stepper CLA
URL:
Whiteboard: Appealing to a Broader Community
Keywords:
Depends on:
Blocks:
 
Reported: 2011-08-25 00:25 EDT by Eike Stepper CLA
Modified: 2013-06-27 03:31 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Eike Stepper CLA 2011-08-25 00:25:40 EDT
Some type mappings are missing, e.g., for EJavaClass
Comment 1 Eike Stepper CLA 2012-08-14 22:55:56 EDT
Moving all open issues to 4.2. Open bugs can be ported to 4.1 maintenance after they've been fixed in master.
Comment 2 Christian Damus CLA 2012-09-08 19:09:20 EDT
This bug was raised to follow up a discussion on the newsgroup:

http://www.eclipse.org/forums/index.php/m/717956/#msg_717956

The same problem happens for attributes of type EJavaObject.  There are a few of these in the EMF Facet models that Papyrus uses and would need to be persisted in a CDO Repository if and when it implements support for sharing models via CDO.

I see that this item is marked as an enhancement.  It was admitted in the newsgroup discussion as a regression from the 3.0 release.  Shouldn't that at least make the severity "normal"?
Comment 3 Eike Stepper CLA 2012-09-19 05:46:27 EDT
I added these test cases to AttributeTest:

  /**
   * Bug 355787.
   */
  public void testJavaClass() throws Exception
  {
    CDOSession session = openSession();
    CDOTransaction transaction = session.openTransaction();
    CDOResource resource = transaction.createResource(getResourcePath("/my/resource"));
    resource.getContents().add(createClassWithJavaClassAttribute(CDOTransaction.class));
    resource.getContents().add(createClassWithJavaClassAttribute(boolean.class));
    resource.getContents().add(createClassWithJavaClassAttribute(byte.class));
    resource.getContents().add(createClassWithJavaClassAttribute(char.class));
    resource.getContents().add(createClassWithJavaClassAttribute(double.class));
    resource.getContents().add(createClassWithJavaClassAttribute(float.class));
    resource.getContents().add(createClassWithJavaClassAttribute(int.class));
    resource.getContents().add(createClassWithJavaClassAttribute(long.class));
    resource.getContents().add(createClassWithJavaClassAttribute(short.class));
    transaction.commit();
    session.close();

    session = openSession();
    transaction = session.openTransaction();
    resource = transaction.getResource(getResourcePath("/my/resource"));
    EList<EObject> contents = resource.getContents();
    assertEquals(CDOTransaction.class, ((ClassWithJavaClassAttribute)contents.get(0)).getJavaClass());
    assertEquals(boolean.class, ((ClassWithJavaClassAttribute)contents.get(1)).getJavaClass());
    assertEquals(byte.class, ((ClassWithJavaClassAttribute)contents.get(2)).getJavaClass());
    assertEquals(char.class, ((ClassWithJavaClassAttribute)contents.get(3)).getJavaClass());
    assertEquals(double.class, ((ClassWithJavaClassAttribute)contents.get(4)).getJavaClass());
    assertEquals(float.class, ((ClassWithJavaClassAttribute)contents.get(5)).getJavaClass());
    assertEquals(int.class, ((ClassWithJavaClassAttribute)contents.get(6)).getJavaClass());
    assertEquals(long.class, ((ClassWithJavaClassAttribute)contents.get(7)).getJavaClass());
    assertEquals(short.class, ((ClassWithJavaClassAttribute)contents.get(8)).getJavaClass());
  }

  private ClassWithJavaClassAttribute createClassWithJavaClassAttribute(Class<?> javaClass)
  {
    ClassWithJavaClassAttribute object = getModel3Factory().createClassWithJavaClassAttribute();
    object.setJavaClass(javaClass);
    return object;
  }

  /**
   * Bug 355787.
   */
  public void testJavaObject() throws Exception
  {
    Map<String, Number> salaries = new HashMap<String, Number>();
    salaries.put("Eike", 5000);
    salaries.put("Martin", 6000.99);
    salaries.put("Ed", 7000f);

    CDOSession session = openSession();
    CDOTransaction transaction = session.openTransaction();
    CDOResource resource = transaction.createResource(getResourcePath("/my/resource"));
    resource.getContents().add(createClassWithJavaObjectAttribute(salaries));
    transaction.commit();
    session.close();

    session = openSession();
    transaction = session.openTransaction();
    resource = transaction.getResource(getResourcePath("/my/resource"));
    EList<EObject> contents = resource.getContents();
    assertEquals(salaries, ((ClassWithJavaObjectAttribute)contents.get(0)).getJavaObject());
  }

  private ClassWithJavaObjectAttribute createClassWithJavaObjectAttribute(Object javaObject)
  {
    ClassWithJavaObjectAttribute object = getModel3Factory().createClassWithJavaObjectAttribute();
    object.setJavaObject(javaObject);
    return object;
  }
  
  Working on support for EJavaClass and EJavaObject now...
Comment 4 Christian Damus CLA 2012-10-29 08:29:21 EDT
I see that the new tests for EJavaClass and EJavaObject are integrated into the test suite and pass.  Does that mean that this bug is fixed?  If so, why is it in assigned state?  Is there anything left to be done?
Comment 5 Eike Stepper CLA 2012-10-29 15:21:08 EDT
I added:

org.eclipse.emf.cdo.common.model.CDOType.JAVA_CLASS
org.eclipse.emf.cdo.common.model.CDOType.JAVA_OBJECT

org.eclipse.emf.cdo.server.internal.db.mapping.CoreTypeMappings.TMJavaClass (maps to VARCHAR)
org.eclipse.emf.cdo.server.internal.db.mapping.CoreTypeMappings.TMJavaObject (maps to BLOB)

All tests are passing now.
commit e1ffd285ca47297325024e329de6546b4993f376
Comment 6 Eike Stepper CLA 2012-10-29 15:22:39 EDT
(In reply to comment #4)
> I see that the new tests for EJavaClass and EJavaObject are integrated into the
> test suite and pass.  Does that mean that this bug is fixed?  If so, why is it
> in assigned state?  Is there anything left to be done?

Strange. Now that I looked at this Mylyn task again, I even had the final resolution comment in place locally, just not submitted it. I can't imagine of another reason than just having forgotten about it. Thanks for the ping ;-)
Comment 7 Eike Stepper CLA 2013-06-27 03:31:02 EDT
Available in R20130613-1157 (4.2)