How to display ecore Eclass names for content assist in Xtext editor after generating artifacts ? - dsl

Aim: To provide editor for configuring a pattern rule for Fruits.ecore
DSL Rule will some thing like this “A Grade” + Apple.name
Problem: With new instance of eclipse application I created a sample project and created a file with text.fruit within this editor I need to creat my new Fruit rule
EClass name and EStructural feature as my content assist
When I do Ctrl + Space my expectations to get list as content assist
Apple
Orange
Steps taken:
Created an xtext plug-in with extension .fruit as my fruit.xtext as dsl.
Using import statement in my “fruit.xtext” file
import “platform:/resource/com.emf.sample/model/Fruits.ecore” as ecore
Within fruit.xtext content assist of ecore works
Now generate Xtext artificats and run the application
Model for above scenario :
How to add external ecore as part of Content assist in Work Flow or Grammar of xtext editor ? Any sample examples or work around will help .
Thanks

Related

Using Protégé as Ontology Manager

I want to use Protégé as an ontology manager. The most basic feature would be to see all the ontology files I have in my repo together in a single opened instance of Protégé i.e. a unified view of all the schema I have in a specific folder. It will be like an Ontology library. Can I do this in Protégé?
I know I can merge all the files first and then see the output file in Protégé but I am looking for a better solution.
Thanks.

JUnit Test Class template not converted to Kotlin file in Kotlin project

If I open a Kotlin project and try to create my own template for JUnit Test Classes I get the generated template generated as a Java file instead of as a Kotlin file.
Is there any way to make this generation to happen as a Kotlin file?
I attached some images to easily show the issue I am facing.
The question marks on one of the images have to do because I don't know what that default parse function does. I tried to change it to #parse("File Header.kt") but that does not work.
The issue was I was trying to add kotlin code to the template.
All I had to do is create the template using Java code and it automatically gets generated in Java.
However, if anyone know a way to specifically use this feature using your own kotlin code instead of generated one, please let me know.

How to rename an existing Hybris extension

I am working on Hybris and I generated a new extension using hybris command (ant extgen) with default settings. During extension generation, I did not change default values like I let the project name to be "training". I started developing some code just for the sake of trying it but now I wrote quite a lot of code and instead of generating a new extension, I am trying to rename "training" to a new name which is more suitable for my project.
My question is - Is there any shortcut to rename "training" to a new name. By rename I don't mean standard intellij or eclipse module rename but also updating all extension specific properties which are referring to extension name "training". Is there any hybris ant command for it?
Here is the way I can think of.
You can declare your extension as a template for extgen and then generate a new extension based on it with a new name and structure.
Let me take training as your current extension which you want to convert to some other name. Below are the steps you need to perform.
Make sure your extension (training) is there in the localextensions.xml
Update extensioninfo.xml to mark the extension as a template by adding below meta tag
<meta key="extgen-template-extension" value="true"/>
Look like
<coremodule generated="true" manager="org.training.jalo.TrainingManager" packageroot="org.training"/>
<meta key="extgen-template-extension" value="true"/>
<webmodule jspcompile="false" webroot="/training"/>
Create an extgen.properties inside training extension/folder with below properties
Please note, If your current extension is with a different name then training in that case you need to change below values accordingly.
extgen.properties:
YEXTNAME_TOKEN=training
YMODULE_TOKEN=training
YMODULE_PACKAGE_ROOT=training
YMODULE_CLASS_PREFIX=training
YPACKAGE_TOKEN=org.training
YMANAGER_TOKEN=TrainingManager
YCLASSPREFIX_TOKEN=Training
YGENERATED_TOKEN=Generated
Run ant extgen and select your extension (training) from the given selection option and give the name and package the way you want when it prompt for it.
Now replace training extension with the newly created extension inside localextensions.xml
Test and patch wherever needed! :-)
I don't think so. It might also be easier just to create a new one and move the code into the new extension.
No it is not possible. The generated extension itself was created from a template where the word "training" is inserted into many places (class names, package names, configurations...) .
The other approach would be to look into the ext-template folder (6.7). There are all templates. Search for any token in the templates and make appropriate change in your generated extensions.
Depending on the amount of your extensions, it will also take some time... and you need to understand how extgen works, first.

Extracting Class Objects from Entity Framework

I have just started to investigate Microsoft's Entity Framework (EF) with a view to replacing our existing Linq2Sql data access library.
Whilst following some of the sample projects I came across the 'Add Code Generation Item' (context menu on the designer surface), specifically the 'EF 5.x DbContext Generator' template.
This template generates some nice simple (POCO) class objects for the model.
In my overall structure, I would like to extract/move these classes into a different project/assembly so that I can reference them from a generic repository i.e. I want to decouple the application's Data Access Layer from the EF entity data model.
Is this possible, or do I need to manually create a map for each class object (e.g. .ToDomainModel(), .FromDomainModel()).
Apologies if this is a stupid question - in my defence I am new to EF and also still getting to grips with the concept of the Data Driven Domain.
It is possible but you will lose part of the auto-magic. The auto-generated item is a T4 template. If you open it you will find somewhere at the beginning relative path to .edmx file. If you move the template you just need to update the path accordingly to point to the .edmx file you want to use for generation.
The disadvantage is that moving the template elsewhere will break automatic class regeneration when the .edmx file is saved (but I didn't searched for the solution so maybe it is possible to make it work). Because of that you must manually run custom tool (item in .tt file context menu) after each saved change to EDMX file.

Eclipse Helios can't create ECore from XSD if the xsds are in the workspace

I have a bunch of XSD files in a folder under an Empty EMF project. I select new generator model, and it asks for a model source. If I select the main xsd from the browser workspace option (from a folder in the empty emf project), the import does not work.
I get Error: XSD type reference blabla is unresolved Uri:platform/resource....
If I copy the workspace folder to some other location and browse that via Browser file system option, everything works just fine.
What am I doing wrong?
Just in case anybody comes across the same problem, one of the schemas included another xsd with xsd name written in lowercase letters. The clue was given in this thread in the Eclipse community forums: http://www.eclipse.org/forums/index.php/m/786530/#msg_786530

Resources