Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
code_generator
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Christopher
code_generator
Commits
abb878c4
Verified
Commit
abb878c4
authored
6 years ago
by
Rico Bergmann
Browse files
Options
Downloads
Patches
Plain Diff
Make EcoreLoader independent of EcoreImporter
parent
6d423bcc
No related branches found
No related tags found
1 merge request
!3
Publish v0.1.1
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/scala/org/rosi_project/model_sync/generator/EcoreLoader.scala
+12
-4
12 additions, 4 deletions
...a/org/rosi_project/model_sync/generator/EcoreLoader.scala
with
12 additions
and
4 deletions
src/main/scala/org/rosi_project/model_sync/generator/EcoreLoader.scala
+
12
−
4
View file @
abb878c4
package
org.rosi_project.model_sync.generator
package
org.rosi_project.model_sync.generator
import
org.eclipse.emf.common.util.URI
import
org.eclipse.emf.ecore.resource.Resource
import
org.eclipse.emf.ecore.resource.impl.ResourceSetImpl
import
org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl
import
org.eclipse.emf.ecore.
{
EObject
,
EPackage
}
import
org.eclipse.emf.ecore.
{
EObject
,
EPackage
}
import
scroll.internal.ecore.ECoreImporter
/** Simple service to load an ECORE model from a file.
/** Simple service to load an ECORE model from a file.
*
*
* @author Rico Bergmann
* @author Rico Bergmann
*/
*/
class
EcoreLoader
extends
ECoreImporter
{
class
EcoreLoader
{
/** Fetches an ecore model from XML.
/** Fetches an ecore model from XML.
*
*
...
@@ -15,8 +18,13 @@ class EcoreLoader extends ECoreImporter {
...
@@ -15,8 +18,13 @@ class EcoreLoader extends ECoreImporter {
* @return the model described by the XML
* @return the model described by the XML
*/
*/
def
loadEcore
(
path
:
String
=
"assets/ttc17.ecore"
)
:
EPackage
=
{
def
loadEcore
(
path
:
String
=
"assets/ttc17.ecore"
)
:
EPackage
=
{
this
.
path
=
path
// see https://github.com/max-leuthaeuser/SCROLL/blob/dd269d5620257be1ea2f2044f398c090e9755fb3/core/src/main/scala/scroll/internal/ecore/ECoreImporter.scala
val
res
=
loadModel
()
require
(
null
!=
path
&&
path
.
nonEmpty
)
val
resourceSet
=
new
ResourceSetImpl
()
val
_
=
resourceSet
.
getResourceFactoryRegistry
.
getExtensionToFactoryMap
.
put
(
Resource
.
Factory
.
Registry
.
DEFAULT_EXTENSION
,
new
XMIResourceFactoryImpl
())
val
res
=
resourceSet
.
getResource
(
URI
.
createFileURI
(
path
),
true
)
require
(
null
!=
res
)
require
(!
res
.
getContents
.
isEmpty
)
res
.
getContents
.
toArray
(
new
Array
[
EObject
](
0
)).
toList
.
find
(
_
.
isInstanceOf
[
EPackage
]).
map
((
p
:
EObject
)
=>
p
.
asInstanceOf
[
EPackage
]).
orNull
res
.
getContents
.
toArray
(
new
Array
[
EObject
](
0
)).
toList
.
find
(
_
.
isInstanceOf
[
EPackage
]).
map
((
p
:
EObject
)
=>
p
.
asInstanceOf
[
EPackage
]).
orNull
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment