|
|
Re: Load HUTN as ecore model [message #1846928 is a reply to message #1846926] |
Sat, 09 October 2021 09:14 |
Frank Benoit Messages: 179 Registered: July 2009 |
Senior Member |
|
|
I try it like this, but the collection from allContents is empty:
static final ImPackage PCK = ImPackage.eINSTANCE;
protected EObject loadHutn(final String content) throws Exception {
final var ecoreResourceSet = new ResourceSetImpl();
ecoreResourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put(
PCK.getNsPrefix(),
new XMIResourceFactoryImpl());
ecoreResourceSet.getPackageRegistry().put(PCK.getNsURI(), PCK);
EObject result = null;
try (var inModel = new HutnModel("name.im", content)) {
inModel.load();
result = (EObject) inModel.allContents().iterator().next(); // java.util.NoSuchElementException here
inModel.dispose();
}
return result;
}
@Test
void testName() throws Exception {
loadHutn(String.format("""
@Spec {
metamodel "%s" {
nsUri: "%s"
}
}
ImModel {
}
""", PCK.getNsPrefix(), PCK.getNsURI()));
}
I expect, that it gives me 1 object back.
Also, when I try to put in child objects, I get parse errors.
Is the connection between my ImPackage and the HutnModel properly established?
[Updated on: Sat, 09 October 2021 09:15] Report message to a moderator
|
|
|
|
|
|
|
Re: Load HUTN as ecore model [message #1847366 is a reply to message #1847345] |
Mon, 25 October 2021 12:24 |
|
Hi Frank,
The code below should do the trick.
public static void main(String[] args) throws Exception {
EPackage.Registry.INSTANCE.put(ImPackage.eNS_URI, ImPackage.eINSTANCE);
HutnModel model = new HutnModel();
StringProperties properties = new StringProperties();
properties.put(HutnModel.PROPERTY_SOURCE_FILE, new File("model.hutn").getAbsolutePath());
properties.put(HutnModel.PROPERTY_READONLOAD, "true");
model.load(properties);
System.out.println(model.allContents());
}
I've also tweaked the HUTN source to add a container for the Project instance.
@Spec {
metamodel "Im" {
nsUri: "https://www.acme.com/im"
}
}
im {
Project {
name: "MyProject"
}
}
Best,
Dimitris
[Updated on: Mon, 25 October 2021 14:49] Report message to a moderator
|
|
|
|
|
Re: Load HUTN as ecore model [message #1847942 is a reply to message #1847941] |
Sun, 14 November 2021 19:08 |
|
Hi Frank,
The implementation of HUTN uses interpreted transformations and validation constraints under the hood so it's unlikely that it can get much faster without a substantial rewrite.
> Now for testing, I want to use HUTN, because it can specify the types precisely (which is missing in Flexmi?).
Could you please elaborate a bit on what you mean by "specify the types precisely"?
Best,
Dimitris
|
|
|
|
Powered by
FUDForum. Page generated in 0.06191 seconds