Code Monkey home page Code Monkey logo

ecore.js's Introduction

ecore.js's People

Contributors

cfi-aschneider avatar cfi-dphillips avatar dslmeinte avatar ghillairet avatar jperiodlangley avatar mortonfox avatar nicolas-hili avatar vsimko 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ecore.js's Issues

EAnnotation support

Hi,
It seems that EAnnotation is not supported.
Do you plan to add it?
Thanks

Missing Support for Generics

As a test we loaded Ecore.ecore and discovered a number of issues. The main issue among these appears to be a lack of support for generics. That is, the follow cannot be loaded:

  1. eGenericType
  2. eTypeParameters
  3. eTypeArguments

There are a number of attributes which are not parsed as well but those can be put forth as a separate issue.

Parsing Multiple Instances in an XMI File

The XMI parser fails to parse an XMI file that contains multiple instances in the same resource. The parser returns TypeError: Cannot read property 'eClass' of undefined in 'onopentag'. This is essentially the XMI version of Pull Request #4. We have constructed a potential solution and will submit after testing is complete.

XML serialization

Hi,
After of the support of EAnnotation, could you also add the XML serialization/unserialization (EMF created from XSD)?
It is very useful when one could not use XMI.
Thanks

How to send an emfobject via server ?

Hi,

Am using Xtext + Xtend and have implemented a DSL with code generation.
I want to post an emfObject from Xtend to a Javascript server.
Can you please let me know how to do this ?

Deployed version of github.io outdated

Hey together, the deployed version of the site on github.io has syntax errors. Those seem to be fixed in the version in the repo. Could you please redeploy the github.io site, so the correct version is deployed?

Example:

grafik

Missing Some Standard XMI Attributes

The parser skips a few attributes that seem to be used in many EMF xmi files such as "xmi:id" and "href". Do you have any suggestions on how to get this loaded for instance of models?

how remove single ereference instance

The model design like below:

<eClassifiers xsi:type="ecore:EClass" name="Node">
   <eStructuralFeatures xsi:type="ecore:EReference" name="properties" eType="#//Property"
       containment="true"/>
 </eClassifiers>
 <eClassifiers xsi:type="ecore:EClass" name="Property">
   <eStructuralFeatures xsi:type="ecore:EAttribute" name="name" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
   <eStructuralFeatures xsi:type="ecore:EAttribute" name="type" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
 </eClassifiers>``

one Node has one property

I use
node.set("properties", property) to set a property instance to node

but how delete the property instance or how set null to the node.properties

How to copy an EObject?

Hi!

I have to duplicate an EObject (only the EObject: not the EObjects it contains) in one of my functions.
Can you please explain how to proceed or give an example?

XMI Deserialization

The deserialization of a ecore metamodel (.ecore file) doesn't work.
I have an error at Ecore.js (ligne 1882, col. 32) TypeError: eObject is undefined

var resourceSet = Ecore.ResourceSet.create();
var resource = resourceSet.create({ uri: '/library' });
var metaModel="<ecore:EPackage xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI\" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance\" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore\" name="ecoreEvaluation" nsURI="http://www.example.org/ecoreEvaluation\" nsPrefix="ecoreEvaluation">
..../ecore:EPackage"
resource.parse(metaModel,Ecore.XMI);

Reading Ecore model

I'm trying to read an Ecore model

var Ecore = require('ecore');
var fs = require('fs');

var resourceSet = Ecore.ResourceSet.create();
var resource = resourceSet.create({uri : '/machin'});
var metamodel = fs.readFileSync('MyMetaModel.ecore', 'utf8');

resource.parse(metamodel, Ecore.XMI);

and I get this message

<?xml version="1.0" encoding="UTF-8"?>
^

SyntaxError: Unexpected token <
    at Object.parse (native)
    at Object.Ecore.JSON.parse (/home/julien/tmp/test/node_modules/ecore/dist/ecore.js:1679:25)
    at Ecore.Resource.Ecore.EClass.create.eOperations._ [as parse] (/home/julien/tmp/test/node_modules/ecore/dist/ecore.js:1970:32)
    at Object.<anonymous> (/home/julien/tmp/test/test.js:183:10)
    at Module._compile (module.js:425:26)
    at Object.Module._extensions..js (module.js:432:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:313:12)
    at Function.Module.runMain (module.js:457:10)
    at startup (node.js:138:18)

It seems that the parser is not taking into account the Ecore.XMI parameter.

Am I doing something wrong ? Any suggestion ?

Reflexive Relationships Not Handled Correctly For Concrete Superclasses

While doing a load of an XMI instance file that conforms to an XMI ecore, when the class has a reflexive relationship, is not abstract, and there are subclasses:

  1. The Ecore.XMI.parse getClassURIFromFeatureType function fails to detect the subclasses and treats them as if they are the superclass.
  2. When this situation is resolved, the Ecore.XMI.to function fails to insert the xsi:type attributes for the subclasses when emitting XMI from the loaded model instance.

We have identified a potential fix for consideration and will submit a pull request after we finish updating the test cases and check for any other side effects.

XMI Parsing Attribute that is Stored as an Element

When trying to parse an XMI instance file that contains an eObject attribute that is stored as an XMI element, the parser attempts to create a reference instead of detecting that the XMI element is an eObject attribute. For instance, the following XMI:

<?xml version="1.0" encoding="UTF-8"?>
<TestModel:Simple xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:TestModel="http://www.example.org/TestModel" name="stringTest" newString="A string."/>

could be stored as

<?xml version="1.0" encoding="UTF-8"?>
<TestModel:Simple xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:TestModel="http://www.example.org/TestModel" name="stringTest">
  <newString>A string.</newString>
</TestModel:Simple>

when the second variant is used the parser attempts to create an element and throws the following exception:

/home/user/git/ecore.js/dist/ecore.xmi.js:291
    var eOperations = eClass.get('eOperations').array();
                                               ^

TypeError: Cannot read property 'array' of undefined
    at eAllOperations (/home/user/git/ecore.js/dist/ecore.xmi.js:291:48)
    at initOperations (/home/user/git/ecore.js/dist/ecore.xmi.js:308:23)
    at new EObject (/home/user/git/ecore.js/dist/ecore.xmi.js:188:5)
    at Object.Ecore.create (/home/user/git/ecore.js/dist/ecore.xmi.js:76:19)
    at Object.parser.onopentag (/home/user/git/ecore.js/dist/ecore.xmi.js:2640:55)
    at emit (/home/user/git/ecore.js/node_modules/sax/lib/sax.js:640:35)
    at emitNode (/home/user/git/ecore.js/node_modules/sax/lib/sax.js:645:5)
    at openTag (/home/user/git/ecore.js/node_modules/sax/lib/sax.js:841:5)
    at Object.write (/home/user/git/ecore.js/node_modules/sax/lib/sax.js:1291:15)
    at Object.Ecore.XMI.parse (/home/user/git/ecore.js/dist/ecore.xmi.js:2730:16)

How to associate EObjects with a package

Hi

The documentation on http://emfjson.org/ecore.js/ is really useful.

However, unless I am overlooking something, it shows how to create a package, and how to create various EObjects - but not how to add the EObjects to a package.
Eg, how does one add the Library object to the LibraryPackage?

Can someone please describe how to do this?

Thanks

Parsing invalid model/instance XMI

Two cases of parsing invalid models/instance XMI were not being caught:

  1. An invalid eSuperType in a ecore model file is parsed and discarded silently.
  2. An invalid xsi:type of a child in an instance is also parsed and discarded silently.

Initial error throws have been added to our repo in the resolve references and parse routines that detect the undefined items which cause silent discarding. Related tests have also been added.

Ecore.JSON Returns References Instead of Nested Objects

It appears that contained instances of a nested relation are displayed as references when calling resource.to(Ecore.JSON) instead of being displayed inline. The problem appears to be caused by the feature.get('containment') returning the string "true" instead of the boolean true in resource.js in the processFeature nested function of Ecore.JSON.to.

To demonstrate the problem, type:
git clone https://github.com/CohesionForce/ecore.js.git
cd ecore.js
npm install
grunt build
cd examples/xmi_node
node simpleTest.js TestModel.ecore test2.testmodel

You will recieve the following output:

::: JSON Dump of test2.testmodel
{ eClass: 'uri-TestModel.ecore#//Simple',
name: 'SimpleTest',
info:
[ { '$ref': '//@info.0', eClass: 'uri-TestModel.ecore#//Info' },
{ '$ref': '//@info.1', eClass: 'uri-TestModel.ecore#//Info' },
{ '$ref': '//@info.2', eClass: 'uri-TestModel.ecore#//Info' } ] }

Instead of the expected:

::: JSON Dump of test2.testmodel
{ eClass: 'uri-TestModel.ecore#//Simple',
name: 'SimpleTest',
info:
[ { eClass: 'uri-TestModel.ecore#//Info',
value: '1',
name: 'Info 1' },
{ eClass: 'uri-TestModel.ecore#//Info',
value: '2',
subInfo:
[ { eClass: 'uri-TestModel.ecore#//SubordinateInfo',
name: 'Sub 2-1' },
{ eClass: 'uri-TestModel.ecore#//SubordinateInfo',
test: 'true',
name: 'Sub 2-2' },
{ eClass: 'uri-TestModel.ecore#//SubordinateInfo',
name: 'Sub 2-3' } ],
name: 'Info 2' },
{ eClass: 'uri-TestModel.ecore#//Info',
value: '3',
name: 'Info 3' } ] }

Inefficient Whitespace Regex in xmi.js

The regex wsexp = / *(.*) +\n/g is very slow if there are attributes that have a large amount of white space (>500 spaces) somewhere between ">" and "<".

Minor node.js packaging issue for ecore.xmi

When using the XMI variant of ecore.js with node.js, the require directive looks like ecore = require('ecore/dist/ecore.xmi'); in place of the usual ecore = require('ecore');

It would be better to support symetrically ecore = require('ecore.xmi');

typescript migration planned?

Hello,

first of all i want to thank you for such a wonderful project, great job. I am new to javascript development and as a native java developer i would really appreciate a typescript version of this framework. Are there any plans for converting ecore.js to typescript?

I am looking forward to hearing from you. Thank you in advance.

Best reagrds
Mehmet

Strategy for serializing Annotations?

I'm trying to use emfjson to serialize an ECore model which contains annotations to json and want to deserialize it using ecore.js. Unfortunately the key/value of the details are null after deserialization.

When checking, it looks like that:
EMFJson uses this format to serialize Annotations (copied from AnntationTest expectation):

        {"eClass":"http://www.eclipse.org/emf/2002/Ecore#//EClass","name":"Foo","eAnnotations": 
       [{"source":"source","details":{"displayName":"value"}}]}

ecore.js however serializes and deserializes like that:

details: [
{
eClass:"http://atest.com#//EStringToStringMapEntry"
key:"key1"
value:"value1"
}
]

Are there any options to customize that? What would be the suggested format? The EMFJson format?

Flag for Continue on Parse Error

While it is useful for it to throw an error for undefined eClasses during XMI parsing, it is also useful to be able to toggle this behavior to enable loading of troublesome files for debugging purposes.

I will be pushing a change to our repo momentarily that adds such a toggle and implements it in simpleTest.js.

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.