Giter Club home page Giter Club logo

boem's Introduction

BOEM

Builder Of EMF Models

The aim of the BOEM library is to provide an API that eases the creation of EMF Model using XTend syntax. Using such syntax helps to:

  • Speed up the creation of tests
  • Improve the readability of the tests
  • Improve maintainability when the tested metamodel changes
  • Ease the creation of inter-connected models

It has been created and used in industrial project to ease the creation input for JUnit tests on the metamodel and business rules.

Installation

Install the feature BOEM Feature (fr.ibp.odv.boem.feature) from one of the following update sites:

1.0.0 Nightly Update Site

Usage

How to start

Create a BOEM factory

extension BoemFactory factory = new BoemFactory(YourMM.eINSTANCE)

Use the keyword extension in order to use all public methods from the BOEM factory anywhere in your class

Import static APIs

import static extension fr.ibp.odv.boem.lib.Boems.*

Examples

All the examples use the following metamodel: BOEM Test Metamodel

How to create an element

// Simple creation
val model = A.build [
  name = "AName"
].buildTree

How to add children

val model = A.build [
  name = "AName";

  // Single valued containment feature
  childNodeA = Node.build [
    name = "SingleChildName"
  ]

  // Adds one child
  childrenNodeA += Node.build [
    name = "ANodeName0"
  ]

  // Adds several children at once
  childrenNodeA += #[
    Node.build [
      name = "ANodeName1"
    ],
    Node.build [
      name = "ANodeName2"
    ]
  ]
].buildTree

How to add pointers to created objects

val model = B.build [
  name = "AName"

  // Adds one child with reference
    childrenNodeA += "id0" >> Node.build [
      name = "ANodeName0"
  ]
  // Adds several children at once with references
  childrenNodeA += #[
    "id1" >> Node.build [
      name = "ANodeName1"
    ],
    "id2" >> Node.build [
      name = "ANodeName2"
    ]
  ]

  // Adds several children at once with references
  childrenNodeB += #[
    "id3" >> Node.build [
      name = "ANodeName3"
    ],
    "id4" >> Node.build [
      name = "ANodeName4"
    ]
  ]
].buildTree

// Accessing node
assertEquals("ANodeName0", model.access(Node, "id0").name)
assertEquals("ANodeName1", model.access(Node, "id1").name)
assertEquals("ANodeName2", model.access(Node, "id2").name)

assertEquals(2, model.root.childrenNodeB.size)
assertEquals("ANodeName3", model.access(Node, "id3").name)
assertEquals("ANodeName4", model.access(Node, "id4").name)

You can even register an id provider against the BoemFactory. It will compute an id for each element (at build time) using your rules. For example:

extension BoemFactory factory = new BoemFactory(BoemTestPackage.eINSTANCE).registerIdProvider([
  if (it instanceof NamedElement) {
    return it.name
  }
  return null
])

//...

val model = B.build [
  name = "AName"
  // Adds one child with reference
  childrenNodeA += Node.build [
    name = "ANodeName0"
  ]
  // Adds several children at once with references
  childrenNodeA += #[
    Node.build [
      name = "ANodeName1"
    ],
    Node.build [
      name = "ANodeName2"
    ]
  ]

  // Adds several children at once with references
  childrenNodeB += #[
    Node.build [
      name = "ANodeName3"
    ],
    Node.build [
      name = "ANodeName4"
    ]
  ]
].buildTree

// Accessing node
assertEquals("ANodeName0", model.access(Node, "ANodeName0").name)
assertEquals("ANodeName1", model.access(Node, "ANodeName1").name)
assertEquals("ANodeName2", model.access(Node, "ANodeName2").name)

assertEquals(2, model.root.childrenNodeB.size)
assertEquals("ANodeName3", model.access(Node, "ANodeName3").name)
assertEquals("ANodeName4", model.access(Node, "ANodeName4").name)

You can also use a shorter syntax to access your elements

val model = A.build [
  name = "AName"
  childrenNodeA += "id1" >> Node.build [
    name = "ANode"
  ]
].buildTree

val target = model.access(Node, "id1");
val target2 = ("id1" => model) as Node
assertTrue(target2 == target)
val target3 = model.access("id1")
assertTrue(target3 == target)
assertTrue(target == "id1" => model)

How to create references

val it = A.build [
  name = "AName"
  autoContainementA += "id0" >> B.build [
    referenceNodeA = Node.buildRef("id1")
  ]
  childrenNodeA += "id1" >> Node.build [
    name = "ANode"
  ]
].buildTree

or with a shorter syntax

val it = A.build [
  name = "AName"
  autoContainementA += "id0" >> B.build [
    referenceNodeA = Node << "id1"
  ]
  childrenNodeA += "id1" >> Node.build [
    name = "ANode"
  ]
].buildTree

How to update an element

val model = A.build [
  autoContainementA += "B" >> B.build [
    autoContainementA += "D" >> C.build
  ]
].buildTree

assertEquals(null, model.root.name)
assertEquals(null, model.access(NamedElement, "B").name)
assertEquals(null, model.access(A, "C").name)

model.update [
  name = "NameA"
  autoContainementA.get(0).with [
    name = "NameB"
    autoContainementA.get(0).with [
      name = "NameD"
    ]
  ]
]

assertEquals("NameA", model.root.name)
assertEquals("NameB", model.access(B, "B").name)
assertEquals("NameC", model.access(C, "C").name)

model.access(B, "B").name = "NameB2"
model.access(C, "C").name = "NameB2"

assertEquals("NameB2", model.access(B, "B").name)
assertEquals("NameC2", model.access(C, "C").name)

Presentations

Contributing

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request 😃

License

Eclipse Public License - v 1.0
Contribution guidelines for this project

boem's People

Contributors

adaussy avatar jacobgeisel avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

boem's Issues

Refactor poms

create a container pom for more effective maven builds

Error when installing boem

I'm using Eclipse Oxygen.3a Release (4.7.3a).

When I tried to install boem feature from https://dl.bintray.com/i-bp/boem/

I got:

An error occurred while collecting items to be installed
session context was:(profile=epp.package.jee, phase=org.eclipse.equinox.internal.p2.engine.phases.Collect, operand=, action=).
Problems downloading artifact: org.eclipse.update.feature,fr.ibp.odv.boem.feature,1.0.0.v20180612-0844.
MD5 hash is not as expected. Expected: 7bcdff93460cf0a9ec2d72675abbf8b7 and found 5a9c59cf2e77bc93a9983dc3f8d4d8a2.
Problems downloading artifact: osgi.bundle,fr.ibp.odv.boem.lib,1.0.0.v20180612-0844.
MD5 hash is not as expected. Expected: 2933341d446c65f6d29cd162921bc398 and found f9cdd24b18b34c96caa51a63c7b23231.

Code folding lambda

On the 'What's Next' slide of the BOEM Project Presentation on the EclipseCon France 2018 you mentioned that you are missing the code folding functionality of Xtend lambda expressions.

This feature is already supported by the Xtend IDE in version 2.13 and above: eclipse/xtext-xtend#279

Would you please give it a try with the Xtend IDE 2.13 (or even 2.14) and conform that the functionality is working on your use case?

Publish documentation

  • rename doc folder to docs to be able to use it as gh-pages folder
  • create documentation

Updating the Xtext Community Website

Hello BOEM team,

The Xtext team would like to update the Xtext community website listing all the cool projects people are building around Xtext/Xtend.

See also the corresponding GitHub issue and Bugzilla ticket.

If you are interested that the BOEM project is listed there, please provide the following information as a comment to this issue:

<tr>
	<td><a href="project_link">project_name</a></td>
	<td>project_description_max_2_sentences</td>
	<td>license</td>
	<td>category</td>
	<td>author(s)</td>
</tr>

We will then update the Xtext community website and get it online as soon as possible.

Thanks!
Tamás

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.