Git Product home page Git Product logo

emfjson-jackson's Introduction

EMF Binding for JSON. CircleCI

JSON binding for EMF (Eclipse Modeling Framework) models, that allows serialization and deserialization of EMF Resources in JSON.

This is how a model looks like in JSON format.

{
    "eClass" : "http://www.eclipse.org/emf/2002/Ecore#//EPackage",
    "name" : "model",
    "nsPrefix" : "model",
    "nsURI" : "http://www.example.org/model",
    "eClassifiers" : [
        {
            "eClass" : "http://www.eclipse.org/emf/2002/Ecore#//EClass",
            "name" : "Library"
        }
    ]
}

Documentation

Here

Installation

Builds are available for Maven users and Eclipse Plugins users.

Maven

Add the following dependency yo your POM file to use emfjson-jackson.

<dependency>
	<groupId>org.emfjson</groupId>
	<artifactId>emfjson-jackson</artifactId>
	<version>1.2.0</version>
</dependency>

Eclipse Update Manager

Use this update site http://ghillairet.github.io/p2

This update site contains the bundle and feature for emfjson-jackson and Jackson.

Jars

You can download the jars from Maven Central.

Dependencies

  • Java 8
  • EMF 2.19
  • Jackson 2.10

License

This software is distributed under the terms of the Eclipse Public License 1.0 - http://www.eclipse.org/legal/epl-v10.

Development

Development can be done with any Java IDE (Eclipse, IntelliJ, etc...), it does not require any special tooling except Maven.

The tests require some code to be generated from a Xcore model. This generated code is not included in this repository, but is generated when the sources are first build locally, see next section for details.

Building from sources

If you want to build from sources, you will need the Java 8 runtime installed on your system as well as Maven 3. First start by cloning this repository.

git clone https://github.com/emfjson/emfjson-jackson.git

Inside the folder emfjson-jackson, run the following maven command to build and install the project locally.

mvn clean install

This command will call the xtext:generate action that will generate the code from the Xcore model for the tests.

Running tests

The tests can be run with the maven command:

mvn clean test

Or run the class TestSuite from your IDE.

emfjson-jackson's People

Contributors

bryanhunt avatar bryanhuntnv avatar flaviodonze avatar ghillairet avatar hallvard avatar janhicken avatar petardp avatar tolland avatar vorburger avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

emfjson-jackson's Issues

Add support for serializing proxy attributes

Please add support for serializing attributes on proxy references. See XMLResource.OPTION_PROXY_ATTRIBUTES. This feature can give you a huge performance gain in certain situations.

EMFJson loads wrong json without throwing exception

Hi Guillaume,

I am facing another issue. Whenever I try to load an xml with wrong contents say (IP_Addrs instead of IP_Addr or Databases instead of Database) I get an exception

org.eclipse.emf.ecore.resource.impl.ResourceSetImpl$1DiagnosticWrappedException: org.eclipse.emf.ecore.xmi.FeatureNotFoundException: Feature 'Databases' not found. (file:///D:/SampleEMFProject/src/test/java/com/sample/emf/test/resources/wrong.xml, 2, 125)
or
org.eclipse.emf.ecore.resource.impl.ResourceSetImpl$1DiagnosticWrappedException: org.eclipse.emf.ecore.xmi.FeatureNotFoundException: Feature 'IP_Addrs' not found. (file:///D:/SampleEMFProject/src/test/java/com/sample/emf/test/resources/wrong.xml, 2, 125)

I tried loading a json instance with wrong information (Databases instead of Database) as shown below:

{
"eClass": "http://com.example.jndisample#//Server",
"IP_Addr" : "SAMPLE_VALUE",
"Port_Number" : 0,
"Databases" : [ {
"eClass": "http://com.example.jndisample#//Database",
"Database_Name" : "SAMPLE_VALUE",
"Username" : "SAMPLE_VALUE",
"Password" : "SAMPLE_VALUE",
"Schema" : {
"eClass": "http://com.example.jndisample#//Schema",
"Schema_Name" : "SAMPLE_VALUE",
"Table" : [ {
"eClass": "http://com.example.jndisample#//Table",
"Table_Name" : "SAMPLE_VALUE",
"Table_Number" : 0.0,
"Has_Fk" : true,
"List_Col" : "SAMPLE_VALUE"
} ]
}
} ]
}

A null pointer exception occurred instead of throwing an emf sort of exception as in the case of xml as shown above.

Next I gave another try with different incorrect values (IP_Addrs instead of IP_Addr).

{
"eClass": "http://com.example.jndisample#//Server",
"IP_Addrs" : "SAMPLE_VALUE",
"Port_Number" : 0,
"Database" : [ {
"eClass": "http://com.example.jndisample#//Database",
"Database_Name" : "SAMPLE_VALUE",
"Username" : "SAMPLE_VALUE",
"Password" : "SAMPLE_VALUE",
"Schema" : {
"eClass": "http://com.example.jndisample#//Schema",
"Schema_Name" : "SAMPLE_VALUE",
"Table" : [ {
"eClass": "http://com.example.jndisample#//Table",
"Table_Name" : "SAMPLE_VALUE",
"Table_Number" : 0.0,
"Has_Fk" : true,
"List_Col" : "SAMPLE_VALUE"
} ]
}
} ]
}

Here no exception was thrown and the json was loaded. But when I tried to read the value of the attribute, it returned null.

This is to ensure that the instance does not have any incorrect information. I would not want to load an incorrect json.

The ecore xmi as json and the code to retrieve instance value is the same as in #48

Am I missing out some additional information? Kindly advise.

Regards,
Bonny.

Attributes that not setted (with default value)

Hi,
Is it posible to say emfjson do not serialize attributes, that not setted.

In my case I have a stereotype with attribute "messageCasting" (enum type) that not setted. When I serialize this eobject I get json, where attribute is present and setted default value (may be not default, but first in list):

    "messageCasting": {
      "eClass": "http://www.eclipse.org/emf/2002/Ecore#//EEnumLiteral",
      "_id": "_Z1gTXCR_EeW-eZ1ZLTAX7g",
      "name": "UNICAST"
    }

"name": "UNICAST" - It is default value

Assignment of non containment references fails during loading from json

Loading of the following json will resolve objects references correctly,

{
"eClass": "http://www.eclipselabs.org/emfjson/junit#//Node",
"label": "root",
"target": {
    "$ref": "#//@child.1/@child.0"
},
"child": [
    {
        "eClass": "http://www.eclipselabs.org/emfjson/junit#//Node",
        "label": "n1"
    },
    {
        "eClass": "http://www.eclipselabs.org/emfjson/junit#//Node",
        "label": "n2",
        "child": [
            {
                "eClass": "http://www.eclipselabs.org/emfjson/junit#//Node",
                "label": "n12"
            }
        ]
    }
]
}

while this one will fail:

{
"eClass": "http://www.eclipselabs.org/emfjson/junit#//Node",
"label": "root",
"target": {
    "$ref": "#//@child.1/@child.0"
},
"child": [
    {
        "eClass": "http://www.eclipselabs.org/emfjson/junit#//Node",
        "label": "n1"
    },
    {
        "eClass": "http://www.eclipselabs.org/emfjson/junit#//Node",
        "label": "n2",
        "child": [
            {
                "eClass": "http://www.eclipselabs.org/emfjson/junit#//Node",
                "label": "n12",
                "target":{
                    "$ref": "#/@child.1"
                }
            }
        ]
    }
]
}

XMI:UID to JSON?

Hi ghillairet,

First of all, thanks for your great work. I'm trying to persist in json format some models that i have in xmi format, so i basically put the contents of the XMI resource in your Json resource. And this is what is happening:

from my XMI fragment:

<views xmi:id="_e7ueQZdiEeS7gJfuiwqSVw"
      name="Business Function"
      composedFrom="_9svCcJdkEeSMX_UyBNZKBw //@models.1">
    <governedBy
        href="archimate.lib.ead#_5E8HAJdbEeSCOqTm_c7kWw"/>
</views>

this is the generated Json fragment:

"views" : [ {
    "name" : "Business Function",
    "governedBy" : {
      "$ref" : "platform:/plugin/mydomain.ead/examples/ead/archimate.lib.ead#_5E8HAJdbEeSCOqTm_c7kWw",
      "eClass" : "http://mydomain.com/1.0/ead#//ArchitectureViewpoint"
    },
    "composedFrom" : [ {
      "$ref" : "//@models.1",
      "eClass" : "http://mydomain.com/1.0/ead#//ArchitectureModel"
    } ]
  } ]

So, i can't access to the xmi:id="_e7ueQZdiEeS7gJfuiwqSVw" property in the json format... and when i try to get the EObject with the urifragment jsonResource.getEObject("_e7ueQZdiEeS7gJfuiwqSVw") i get null Object. Obviously when i try it with the xmiResource i can get the EObject correctly. I suspect that it happens because the property xmi:id is a particular functionallity of the xmi format wich EMF uses (in benefit) for locate and persist models. So, is there anyway to include the xmi:id property in my generated json? Am i missing something in the instantiation of the json Resource?

Thank you very much for your time and your work!

Kind regards.

NPE when reference eClass nsURI is package name

When using xcore to generate your EMF model, the nsURI defaults to the package name which means that the URI for an EClass looks like my.package#//MyType. This causes an NPE when processing a reference to an EClass.

You can work around this problem by setting:

@ecore(nsURI="http://package")

in the xcore file.

Reading non-containment references from JSON can produce null objects

If you happen to process a non-containment reference to an object that is part of a containment reference that you haven't processed yet, the non-containment reference will not find the referenced object.

I believe the solution to this problem is to change the algorithm to make two passes. The first pass processes only containment references, and the second pass processes non-containment references.

Here is a trivial example:

{
  "eClass" : "http://www.eclipselabs.org/model#//Parent",
  "nonContainmentRef" : { "$ref" : "//@children.0" },
  "children" : [{ "eClass" : "http://www.eclipselabs.org/model#//Child", "name" : "Child 1" }]
}

EEnum Serialization

I've tried this great tool but I found an error about EEnum Serialization.
EEnum attribute will not be serialized if it has the default value 0.

And I found the reason:

In EAttributeSerializer.java there is:

static boolean isCandidate(EObject eObject, EAttribute eAttribute) {
    return eObject.eIsSet(eAttribute) && !eAttribute.isDerived() && 
            !eAttribute.isTransient() && !eAttribute.isUnsettable();
}

If an EEnum object has the default value 0, eObject.eIsSet will return false. (if the object has a non-default value, it becomes true).

You can test it by User.sex in the test model.

I fixed it with

static boolean isCandidate(EObject eObject, EAttribute eAttribute) {
    return (eObject.eIsSet(eAttribute) || eAttribute.getEType() instanceof EEnum) && !eAttribute.isDerived() && 
            !eAttribute.isTransient() && !eAttribute.isUnsettable();
}

but it is related with some test cases and I'm not sure whether this fix is the best way.
I report this to you and I appreciate your updates on this.

More flexibility for the eClass field order

Uppon loading of a json content I can't guarantee the order in which the attributes are listed in the json. This leads to a problem on loading of the resource, because EMFJson skips the attributes and references until it gets the eClass field (in case it doesn't know the correct type in advance).

The following test snippets reproduce this behaviour. Note that you have to register ´EPackage.Registry.INSTANCE.put(EcorePackage.eNS_URI, EcorePackage.eINSTANCE);` in the org.emfjson.jackson.junit.support.TestSupport class to make the snippets work.

@Test
def testLoadWithEClassLast() throws IOException {
    val data ='''
        {
            "name" : "A",
            "eClass" : "http://www.eclipse.org/emf/2002/Ecore#//EClass"
        }
    '''

    val resource = resourceSet.createResource(URI.createURI("tests/test.json"))
    resource.load(new ByteArrayInputStream(data.bytes), options)

    assertFalse(resource.contents.empty)

    val eClass = resource.contents.get(0) as EClass

    assertNotNull(eClass)
    assertEquals(eClass.getName(),"A")
}

This test shows that the name attribute gets lost.

In case of an list this also results in a NullPointer.

@Test
def testLoadWithFeaturesEClassLast() throws IOException {

    val data ='''
        {
            "name" : "A",
            "eStructuralFeatures" : [ {
                "name" : "text",
                "eType" : {
                    "$ref" : "http://www.eclipse.org/emf/2002/Ecore#//EString"
                },
                "eClass" : "http://www.eclipse.org/emf/2002/Ecore#//EAttribute"
            }],
            "eClass" : "http://www.eclipse.org/emf/2002/Ecore#//EClass"
        }
    '''

    val resource = resourceSet.createResource(URI.createURI("tests/test.json"))
    resource.load(new ByteArrayInputStream(data.bytes), options)

    assertFalse(resource.contents.empty)

    val eClass = resource.contents.get(0) as EClass
    eClass.assertFeatures
}

Would it be possible to adapt the StreamReader class to deal with json content with the eClass not garantueed to be the first field?

Thanks and regards,
Michael

Deserialization of a JSON into an EMF Object Type inheriting from "org.eclipse.emf.ecore.xml.type.AnyType" is not working

I have an EClass which inherits from "org.eclipse.emf.ecore.xml.type.AnyType". When I serialize it to JSON, it works well.

However, when the same JSON is de-serialized into EMF Object, it is not working. Since the attribute is multi-valued, I am getting an emtpy list instead of populated object while saving it into a EMF Resource.

How can we handle De-serialization of an EMF Object inheriting from AnyType.

Consider using the eClass URI for the "type"

When I started working on supporting POST to create a new EMF object from JSON, it occurred to me that you must be using the "type" field to determine the EMF eClass. When I do a GET, the "type" comes back as the eClass name which is arguably non-deterministic when locating the eClass to use when creating a new instance. I would recommend considering the use of the eClass URI as the value for the "type" field. This is what we are doing in MongoEMF and it seems to work quite well.

duplicate item from JSON to EMF

the case is occur in "conclusion" and "condition" element

read from JSON, the EMF item duplicated, but the element is fine in JSON
du

read from xml, the EMF item is fine
du_r

this element definition
du_emf

GWT Support

EMFJs should provide a bundle that could be use on the client side of a GWT application. This could be use with the EMF GWT port. Usages could be:

  • Load JSON data from HTTP server by GWT client,
  • Use JSON serialization for server - client data transfer instead of the Binary format used by EMF-GWT.

EMFJs currently relies on Jackson from JSON de/serialization. Jackson at the moment does not provide a GWT port. The EMFJs GWT port could rather use the GWT.JSON module for JSON de/serialization.

Collection<Resource> deserialization behaviour

I find that deserialization of Resource collection is not correct. My code:

    @RequestMapping(value = "/packagesDi", method = RequestMethod.GET)
    @ResponseBody
    public Collection<Resource> getPackagesDi(){
        ...
        return Arrays.asList(resource, resourceDi);
    }

    @RequestMapping(value = "/packagesDi", method = RequestMethod.POST)
    @ResponseBody
    public void setPackagesDi(@RequestBody List<Resource> resources){
        ...
    }

I'm trying to POST json from first method to second and get List of 2 Resource, but both resources is the same object.
First transmitted resource contains 168 eobjects and 30 contents and second contains 54 eobject and 1 content.
Recieved resource contains 222 eobject and 31 contents.

Issues with JSON generated with subpackages

<ecore:EPackage xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="com.example.test" nsURI="http://www.example.com/test/" nsPrefix="com.example.test">
<eSubpackages name="com.example.test.model" nsURI="http://www.example.com/test/model" nsPrefix="com.example.test.model">
<eClassifiers xsi:type="ecore:EClass" name="Object1" instanceClassName="com.example.test.model.Object1" eSuperTypes="//com.example.test.model/Object1">
<eStructuralFeatures xsi:type="ecore:EReference" name="Object2" upperBound="-1" eType="/com.example.test.model/Object2">
</eStructuralFeatures>
</eClassifiers>
</eSubpackages>
</ecore:EPackage>

The above definition will cause cases as follow.

"eType":{"$ref":"http://www.eclipse.org/emf/2002/Ecore#//com.example.test.model/Object2"

and

"eSuperTypes":[{"$ref":"http://www.eclipse.org/emf/2002/Ecore#///com.example.test.model/Object1"

The packages and subpackages of the xml is generated using the ecore editor in Eclipse

Add support for json referencing

Json referencing as described in dojo documentation [1] offers a way to link json objects. The reference is done via
a property named '$ref' with value the referenced object's id.
EmfJs will support json referencing a la dojo to serialize references between objects. For example two emf objects of
type User are linked by a non containment reference friends like this u1:User -friends-> u2:User have to be translated in
the following json:
[ {"id": 1, friends:{"$ref" : 2}}, {"id": 2} ]

Also this json referencing format will be use to create emf objects reference during parsing of json data.

[1] http://www.sitepen.com/blog/2008/06/17/json-referencing-in-dojo/

Support for dynamic properties

This feature would provide support for loading/serializing Object specific properties with no direct mapping in corresponding EClass.
For example if we have the following EClass:

class User {
  attr String[1] name;
} 

and following JSON Object:

{
    name: 'Randy',
    'specific-property': 'some-value'
}

The property name is mapped to the EAttribute name but the second property does have any equivalent and is
specific to this object.

A way to keep this information is to defined a Map.Entry in the EClass as this:

class User {
  attr String[1] name;
  @JSON(dynamicMap="true")
  val ecore.EStringToStringMapEntry[*] entries;
}

This one is annotated with the @JSON annotation and have for key dynamicMap sets to true, it's name is arbitrary. This MapEntry will be use to store the Object dynamic properties, that could be access like this:

eObject.getEntries().get('specific-property') -> 'some-value'

attribute serialization

Hi,

I have a problen with json serialization of ecore model. I'm trying to create .uml and .json (with emfjson) files like this:

ResourceSet umlResourceSet;

    @Before
    public void prepare(){
        umlResourceSet = new ResourceSetImpl();
        umlResourceSet.setURIConverter(URIConverter.INSTANCE);
        umlResourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("json", new JsonResourceFactoryCit());
        umlResourceSet.getPackageRegistry().put(EcorePackage.eNS_URI, EcorePackage.eINSTANCE);
        UMLResourcesUtil.init(umlResourceSet);
    }

    @Test
    public void test(){
        List<EObject> eObjects = new ArrayList<>();
        List<String> useCaseNames = Arrays.asList("Кредитовый перевод",
                "Инициирование кредитового перевода", "Коммерческий платеж",
                "Налоговый платеж", "Валютный платеж", "Межбанковский перевод", "Уведомление кредитора");
        List<String> actorNames = Arrays.asList("Дебитор", "Банк дебитора", "Банк-посредник",
                "Кредитор", "Банк кредитора");
        Map<String, UseCase> useCaseList = new HashMap<>();
        useCaseNames.stream().forEach(n -> {
            UseCase uc = UMLFactory.eINSTANCE.createUseCase();
            uc.setName(n);
            useCaseList.put(n, uc);
        });
        org.eclipse.uml2.uml.Package p = UMLFactoryImpl.init().createPackage();
        eObjects.add(p);
        Resource primitiveLib = umlResourceSet.getResource(URI.createURI(UMLResource.UML_PRIMITIVE_TYPES_LIBRARY_URI), true);
        Package primitiveLibPackage = (Package) EcoreUtil.getObjectByType(primitiveLib.getContents(), UMLPackage.Literals.PACKAGE);
        p.createPackageImport(primitiveLibPackage);
        p.setName("NPModel");
        Resource profileLib = umlResourceSet.getResource(URI.createURI("model/ISO20022Profile.profile.uml"), true);
        Package isoP = (Package) EcoreUtil.getObjectByType(profileLib.getContents(), UMLPackage.Literals.PACKAGE);
        p.applyProfile(isoP.containingProfile());
        actorNames.stream().forEach(n -> p.createPackagedElement(n, UMLFactoryImpl.getPackage().getActor()));
        isoP.containingProfile().getOwnedStereotypes().stream()
                .filter(s -> s.getName().contains("BusinessRole")).findFirst().ifPresent(st -> {
            NamedElement el = p.getPackagedElement("Банк дебитора");
            eObjects.add(el.applyStereotype(st));
        });
        useCaseList.forEach((n, uc) -> p.getPackagedElements().add(uc));
        Resource resource = umlResourceSet.createResource(URI.createURI("test.uml"));
        resource.getContents().addAll(eObjects);
        try {
            resource.save(null);
        } catch (IOException e) {
            e.printStackTrace();
        }
        Resource resourceJSON = umlResourceSet.createResource(URI.createURI("test.json"));
        resourceJSON.getContents().addAll(eObjects);
        try {
            resourceJSON.save(null);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

Created .uml is right:

<?xml version="1.0" encoding="UTF-8"?>
<xmi:XMI xmi:version="20131001" xmlns:xmi="http://www.omg.org/spec/XMI/20131001" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ISO20022Profile="http:///schemas/ISO20022Profile/_Z1baoCR_EeW-eZ1ZLTAX7g/50" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" xmlns:uml="http://www.eclipse.org/uml2/5.0.0/UML" xsi:schemaLocation="http:///schemas/ISO20022Profile/_Z1baoCR_EeW-eZ1ZLTAX7g/50 model/ISO20022Profile.profile.uml#_Z1fsECR_EeW-eZ1ZLTAX7g">
  <uml:Package xmi:id="_eJYk0CquEeWRmPUlcrfDwQ" name="NPModel">
    <packageImport xmi:id="_eJYk0SquEeWRmPUlcrfDwQ">
      <importedPackage xmi:type="uml:Model" href="pathmap://UML_LIBRARIES/UMLPrimitiveTypes.library.uml#_0"/>
    </packageImport>
    <packagedElement xmi:type="uml:Actor" xmi:id="_eJYk0iquEeWRmPUlcrfDwQ" name="Дебитор"/>
    <packagedElement xmi:type="uml:Actor" xmi:id="_eJYk0yquEeWRmPUlcrfDwQ" name="Банк дебитора"/>
    <packagedElement xmi:type="uml:Actor" xmi:id="_eJYk1CquEeWRmPUlcrfDwQ" name="Банк-посредник"/>
    <packagedElement xmi:type="uml:Actor" xmi:id="_eJYk1SquEeWRmPUlcrfDwQ" name="Кредитор"/>
    <packagedElement xmi:type="uml:Actor" xmi:id="_eJYk1iquEeWRmPUlcrfDwQ" name="Банк кредитора"/>
    <packagedElement xmi:type="uml:UseCase" xmi:id="_eJYk1yquEeWRmPUlcrfDwQ" name="Инициирование кредитового перевода"/>
    <packagedElement xmi:type="uml:UseCase" xmi:id="_eJYk2CquEeWRmPUlcrfDwQ" name="Межбанковский перевод"/>
    <packagedElement xmi:type="uml:UseCase" xmi:id="_eJYk2SquEeWRmPUlcrfDwQ" name="Коммерческий платеж"/>
    <packagedElement xmi:type="uml:UseCase" xmi:id="_eJZL4CquEeWRmPUlcrfDwQ" name="Уведомление кредитора"/>
    <packagedElement xmi:type="uml:UseCase" xmi:id="_eJZL4SquEeWRmPUlcrfDwQ" name="Кредитовый перевод"/>
    <packagedElement xmi:type="uml:UseCase" xmi:id="_eJZL4iquEeWRmPUlcrfDwQ" name="Налоговый платеж"/>
    <packagedElement xmi:type="uml:UseCase" xmi:id="_eJZL4yquEeWRmPUlcrfDwQ" name="Валютный платеж"/>
    <profileApplication xmi:id="_eJZL5CquEeWRmPUlcrfDwQ">
      <eAnnotations xmi:id="_eJZL5SquEeWRmPUlcrfDwQ" source="http://www.eclipse.org/uml2/2.0.0/UML">
        <references xmi:type="ecore:EPackage" href="model/ISO20022Profile.profile.uml#_Z1fsECR_EeW-eZ1ZLTAX7g"/>
      </eAnnotations>
      <appliedProfile href="model/ISO20022Profile.profile.uml#_rspygA6UEeWHY4KRRC3kUQ"/>
    </profileApplication>
  </uml:Package>
  <ISO20022Profile:BusinessRole xmi:id="_eJZL5iquEeWRmPUlcrfDwQ" base_NamedElement="_eJYk0yquEeWRmPUlcrfDwQ" base_Actor="_eJYk0yquEeWRmPUlcrfDwQ"/>
</xmi:XMI>

But .json is not, there no attributes (in this case "name" attribute):

[
  {
    "eClass": "http://www.eclipse.org/uml2/5.0.0/UML#//Package",
    "_id": "_ezM94CquEeWRmPUlcrfDwQ",
    "packageImport": [
      {
        "eClass": "http://www.eclipse.org/uml2/5.0.0/UML#//PackageImport",
        "_id": "_ezM94SquEeWRmPUlcrfDwQ",
        "visibility": "public",
        "importedPackage": {
          "$ref": "pathmap://UML_LIBRARIES/UMLPrimitiveTypes.library.uml#_0"
        },
        "importingNamespace": {
          "$ref": "_ezM94CquEeWRmPUlcrfDwQ"
        }
      }
    ],
    "packagedElement": [
      {
        "eClass": "http://www.eclipse.org/uml2/5.0.0/UML#//Actor",
        "_id": "_ezM94iquEeWRmPUlcrfDwQ"
      },
      {
        "eClass": "http://www.eclipse.org/uml2/5.0.0/UML#//Actor",
        "_id": "_ezM94yquEeWRmPUlcrfDwQ"
      },
      {
        "eClass": "http://www.eclipse.org/uml2/5.0.0/UML#//Actor",
        "_id": "_ezM95CquEeWRmPUlcrfDwQ"
      },
      {
        "eClass": "http://www.eclipse.org/uml2/5.0.0/UML#//Actor",
        "_id": "_ezM95SquEeWRmPUlcrfDwQ"
      },
      {
        "eClass": "http://www.eclipse.org/uml2/5.0.0/UML#//Actor",
        "_id": "_ezM95iquEeWRmPUlcrfDwQ"
      },
      {
        "eClass": "http://www.eclipse.org/uml2/5.0.0/UML#//UseCase",
        "_id": "_ezM95yquEeWRmPUlcrfDwQ"
      },
      {
        "eClass": "http://www.eclipse.org/uml2/5.0.0/UML#//UseCase",
        "_id": "_ezM96CquEeWRmPUlcrfDwQ"
      },
      {
        "eClass": "http://www.eclipse.org/uml2/5.0.0/UML#//UseCase",
        "_id": "_ezM96SquEeWRmPUlcrfDwQ"
      },
      {
        "eClass": "http://www.eclipse.org/uml2/5.0.0/UML#//UseCase",
        "_id": "_ezM96iquEeWRmPUlcrfDwQ"
      },
      {
        "eClass": "http://www.eclipse.org/uml2/5.0.0/UML#//UseCase",
        "_id": "_ezM96yquEeWRmPUlcrfDwQ"
      },
      {
        "eClass": "http://www.eclipse.org/uml2/5.0.0/UML#//UseCase",
        "_id": "_ezM97CquEeWRmPUlcrfDwQ"
      },
      {
        "eClass": "http://www.eclipse.org/uml2/5.0.0/UML#//UseCase",
        "_id": "_ezM97SquEeWRmPUlcrfDwQ"
      }
    ],
    "profileApplication": [
      {
        "eClass": "http://www.eclipse.org/uml2/5.0.0/UML#//ProfileApplication",
        "_id": "_ezM97iquEeWRmPUlcrfDwQ",
        "eAnnotations": [
          {
            "eClass": "http://www.eclipse.org/emf/2002/Ecore#//EAnnotation",
            "_id": "_ezM97yquEeWRmPUlcrfDwQ",
            "source": "http://www.eclipse.org/uml2/2.0.0/UML",
            "references": [
              {
                "$ref": "model/ISO20022Profile.profile.uml#_Z1fsECR_EeW-eZ1ZLTAX7g"
              }
            ]
          }
        ],
        "appliedProfile": {
          "$ref": "model/ISO20022Profile.profile.uml#_rspygA6UEeWHY4KRRC3kUQ"
        },
        "applyingPackage": {
          "$ref": "_ezM94CquEeWRmPUlcrfDwQ"
        }
      }
    ]
  },
  {
    "eClass": "model/ISO20022Profile.profile.uml#_Z1hhpyR_EeW-eZ1ZLTAX7g",
    "_id": "_ezNk8CquEeWRmPUlcrfDwQ",
    "registrationStatus": "PROVISIONALLY_REGISTERED ",
    "base_NamedElement": {
      "$ref": "_ezM94yquEeWRmPUlcrfDwQ"
    },
    "base_Actor": {
      "$ref": "_ezM94yquEeWRmPUlcrfDwQ"
    }
  }
]

What happen? What I should do?

Add support for EStringToStringMapEntry

Add support for Map entries.

A model class such as:

class ObjectWithMap {
  val ecore.EStringToStringMapEntry[*] entries;
}

should have its instances serialized as this:

{
    "entries": {
        "key1":"v1",
         "key2":"v2"
    }
}

JsResourceImpl needs to read from InputStream on load()

When using JsResourceImpl with Restlet, the data comes from an InputStream which is passed to Resource.load(inputStream, options). JsResourceImpl needs to read from that input stream instead of opening it's own input stream based on the URI. I committed my experimental code to eTrack master if you need an example.

Cross-document containment is not handled correctly for arrays of references

When given an array of containment references to objects contained in another resource, the array is processed during fillEContainment instead of fillEReference.
(containment = true, resolveProxies = true)

Small example..
The following is stored in resource - toys
{ "_id" : 1, "eClass" : "Toy", "name" : "Buzz", }
And this object is in resource - boxes
{ "eClass" : "Box", "crossDocContainmentRefs" : { [ {"eClass" : "Toy", "$ref" : "../toys/1"} ]} }

Unable to load resource from json file

Hi,

I have an ecore model defined. Later when I try to load an instance from a json file, it fails to do so. Kindly have a look at the model definition and the instance.

Model

{
  "eClass" : "http://www.eclipse.org/emf/2002/Ecore#//EPackage",
  "name" : "JNDISamplePackage",
  "nsURI" : "http://com.sample.jndisample",
  "nsPrefix" : "JNDISample",
  "eClassifiers" : [ {
    "eClass" : "http://www.eclipse.org/emf/2002/Ecore#//EClass",
    "name" : "Server",
    "eStructuralFeatures" : [ {
      "eClass" : "http://www.eclipse.org/emf/2002/Ecore#//EAttribute",
      "name" : "IP_Addr",
      "eType" : {
        "$ref" : "http://www.eclipse.org/emf/2002/Ecore#//EString",
        "eClass" : "http://www.eclipse.org/emf/2002/Ecore#//EDataType"
      }
    }, {
      "eClass" : "http://www.eclipse.org/emf/2002/Ecore#//EAttribute",
      "name" : "Port_Number",
      "eType" : {
        "$ref" : "http://www.eclipse.org/emf/2002/Ecore#//EIntegerObject",
        "eClass" : "http://www.eclipse.org/emf/2002/Ecore#//EDataType"
      }
    }, {
      "eClass" : "http://www.eclipse.org/emf/2002/Ecore#//EAttribute",
      "name" : "Mac_Addr",
      "eType" : {
        "$ref" : "http://www.eclipse.org/emf/2002/Ecore#//EString",
        "eClass" : "http://www.eclipse.org/emf/2002/Ecore#//EDataType"
      }
    }, {
      "eClass" : "http://www.eclipse.org/emf/2002/Ecore#//EReference",
      "name" : "Database",
      "upperBound" : -1,
      "containment" : true,
      "eType" : {
        "$ref" : "//Database",
        "eClass" : "http://www.eclipse.org/emf/2002/Ecore#//EClass"
      }
    } ]
  }, {
    "eClass" : "http://www.eclipse.org/emf/2002/Ecore#//EClass",
    "name" : "Database",
    "eStructuralFeatures" : [ {
      "eClass" : "http://www.eclipse.org/emf/2002/Ecore#//EAttribute",
      "name" : "Database_Name",
      "eType" : {
        "$ref" : "http://www.eclipse.org/emf/2002/Ecore#//EString",
        "eClass" : "http://www.eclipse.org/emf/2002/Ecore#//EDataType"
      }
    }, {
      "eClass" : "http://www.eclipse.org/emf/2002/Ecore#//EAttribute",
      "name" : "Username",
      "eType" : {
        "$ref" : "http://www.eclipse.org/emf/2002/Ecore#//EString",
        "eClass" : "http://www.eclipse.org/emf/2002/Ecore#//EDataType"
      }
    }, {
      "eClass" : "http://www.eclipse.org/emf/2002/Ecore#//EAttribute",
      "name" : "Password",
      "eType" : {
        "$ref" : "http://www.eclipse.org/emf/2002/Ecore#//EString",
        "eClass" : "http://www.eclipse.org/emf/2002/Ecore#//EDataType"
      }
    }, {
      "eClass" : "http://www.eclipse.org/emf/2002/Ecore#//EReference",
      "name" : "Schema",
      "containment" : true,
      "eType" : {
        "$ref" : "//Schema",
        "eClass" : "http://www.eclipse.org/emf/2002/Ecore#//EClass"
      }
    } ]
  }, {
    "eClass" : "http://www.eclipse.org/emf/2002/Ecore#//EClass",
    "name" : "Schema",
    "eStructuralFeatures" : [ {
      "eClass" : "http://www.eclipse.org/emf/2002/Ecore#//EAttribute",
      "name" : "Schema_Name",
      "eType" : {
        "$ref" : "http://www.eclipse.org/emf/2002/Ecore#//EString",
        "eClass" : "http://www.eclipse.org/emf/2002/Ecore#//EDataType"
      }
    } ]
  } ]
}

Instance

[ {
  "IP_Addr" : "SAMPLE_VALUE",
  "Port_Number" : 0,
  "Mac_Addr" : "SAMPLE_VALUE",
  "Database" : [ {
    "Database_Name" : "SAMPLE_VALUE",
    "Username" : "SAMPLE_VALUE",
    "Password" : "SAMPLE_VALUE",
    "Schema" : {
      "Schema_Name" : "SAMPLE_VALUE"
    }
  } ]
}, {
  "Database_Name" : "SAMPLE_VALUE",
  "Username" : "SAMPLE_VALUE",
  "Password" : "SAMPLE_VALUE",
  "Schema" : {
    "Schema_Name" : "SAMPLE_VALUE"
  }
}, {
  "Schema_Name" : "SAMPLE_VALUE"
} ]

Kindly find the steps used to load the instance

  1. I get the corresponding EPackage of model.(ePack)
  2. ResourceSet metaResourceSet = new ResourceSetImpl();
  3. metaResourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("*", new JsonResourceFactory());
  4. metaResourceSet.getPackageRegistry().put(ePack.getNsURI(), ePack);
  5. Resource res = metaResourceSet.getResource(URI.createFileURI("<path_instance>/instance.json"),true);
  6. res.getContents().size() is zero.

Hence I cannot use it further.

The same works perfectly in the case of XML(using XMLResourceset and all).

I just started working with emf and am new to it. Kindly help.

error on type ENUM convert json to EMF

java.lang.IllegalArgumentException: The value 'RULEASCOLUMN' is not a valid enumerator of 'DecisionTableOrientation'
at DMN.impl.DMNFactoryImpl.createDecisionTableOrientationFromString(DMNFactoryImpl.java:405)
at DMN.impl.DMNFactoryImpl.createFromString(DMNFactoryImpl.java:101)
at org.eclipse.emf.ecore.util.EcoreUtil.createFromString(EcoreUtil.java:3352)
at org.eclipselabs.emfjson.map.EAtttributeDeserializer.deSerializeValue(EAtttributeDeserializer.java:86)
at org.eclipselabs.emfjson.map.EAtttributeDeserializer.deSerialize(EAtttributeDeserializer.java:69)
at org.eclipselabs.emfjson.map.Deserializer.from(Deserializer.java:71)
at org.eclipselabs.emfjson.map.EReferenceDeserializer.createContainedObject(EReferenceDeserializer.java:107)
at org.eclipselabs.emfjson.map.EReferenceDeserializer.deSerializeContainment(EReferenceDeserializer.java:86)
at org.eclipselabs.emfjson.map.EReferenceDeserializer.deSerialize(EReferenceDeserializer.java:59)
at org.eclipselabs.emfjson.map.Deserializer.from(Deserializer.java:72)
at org.eclipselabs.emfjson.map.EReferenceDeserializer.createContainedObject(EReferenceDeserializer.java:107)
at org.eclipselabs.emfjson.map.EReferenceDeserializer.deSerializeContainment(EReferenceDeserializer.java:74)
at org.eclipselabs.emfjson.map.EReferenceDeserializer.deSerialize(EReferenceDeserializer.java:59)
at org.eclipselabs.emfjson.map.Deserializer.from(Deserializer.java:72)
at org.eclipselabs.emfjson.map.EObjectMapper.from(EObjectMapper.java:105)
at org.eclipselabs.emfjson.map.EObjectMapper.from(EObjectMapper.java:96)
at org.eclipselabs.emfjson.map.EObjectMapper.from(EObjectMapper.java:71)
at org.eclipselabs.emfjson.resource.JsResourceImpl.doLoad(JsResourceImpl.java:49)
at org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(ResourceImpl.java:1518)
at org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(ResourceImpl.java:1297)
at com.founder.fix.test.FigureBuilderDMNTest.readWriteFigureEnum(FigureBuilderDMNTest.java:127)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)

Wiki page for EMFJs ModelGen

EMFJs provides a plugin for the generation of Ecore models from JSON data. This plugin should be documented in the Wiki.

Provide a UI plugin for CouchDB

This plugin should provide a basic View that list current models in a given CouchDB database.
Possible features:

  • User should be able to add a model in the couchdb database
  • User should be able to open models from couchdb in the default tree editor
  • User should be able to delete models from couchdb
  • ...

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.