-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
IllegalArgumentException when trying to store a model #11
Comments
Serialization to XMI and XML works without modification. |
I am not sure whether this issue is directly related to emftriple, see https://www.eclipse.org/forums/index.php/t/128219/ But as I said, serialization to XMI and XML works. |
More likely because not all EMF features are supported in emftriple, FeatureMaps may be one that are not. |
Thank you for your reply. I might implement this. Maybe you can point me to the right direction, where to start? |
During serialization, check that an attribute is a feature map, and then handle that case, maybe like it is done there https://github.com/ghillairet/emfjson/blob/master/emfjson-jackson/src/main/java/org/emfjson/jackson/databind/ser/EObjectSerializer.java#L124 |
Thank you for that hint. BTW the feature map is treated as an EReference. |
Implementing it was easier said than done. I am having trouble implementing this. This is what I have so far, but it's neither correct nor complete: In Extensions.xtend: def add(Model graph, EObject eObject, EAttribute feature, Object value, ValueFactory factory) {
if (feature.getEAttributeType().getName().equals("EFeatureMapEntry")) {
writeFeatureMap(graph, feature, eObject, factory)
} else {
if (value instanceof FeatureEList) {
// TODO
} else
graph.add(eObject.toURI, feature.toURI, value.toLiteral(feature, factory))
}
}
def writeFeatureMap(Model graph, EAttribute attribute, EObject owner, ValueFactory factory) {
val features = featureMaps(owner, attribute);
features.forEach[
val value = owner.eGet(it as EStructuralFeature);
if (it instanceof EAttribute) {
graph.add(owner, it, value, factory)
} else {
val reference = it as EReference;
if (reference.isContainment()) {
reference.eContents.forEach[
graph.add(owner, reference, it as EObject) // FIXME
]
} else {
graph.add(owner, reference, value as EObject)
}
}
]
}
static def featureMaps(EObject owner, EAttribute attribute) {
val featureMap = owner.eGet(attribute) as FeatureMap.Internal;
val iterator = featureMap.basicIterator();
val features = new LinkedHashSet();
while (iterator.hasNext()) {
features.add(iterator.next().getEStructuralFeature());
}
return features;
} |
Is there anything done? I stranded here because of the same reason. Pleeeeaaase help me :) |
I have a rather complex Ecore model which I'm trying to serialize to RDF with emftriple.
The storage method is according to the one found in the the README.
Upon calling
resource.getContents().add(model);
I get the following exception:Exception in thread "main" java.lang.IllegalArgumentException: The datatype 'EFeatureMapEntry' is not a valid classifier
at org.eclipse.emf.ecore.impl.EcoreFactoryImpl.convertToString(EcoreFactoryImpl.java:221)
at org.eclipse.emf.ecore.util.EcoreUtil.convertToString(EcoreUtil.java:3495)
at org.eclipselabs.emftriple.sesame.map.Extensions.toLiteral(Extensions.java:48)
at org.eclipselabs.emftriple.sesame.map.Extensions.add(Extensions.java:58)
at org.eclipselabs.emftriple.sesame.map.Serializer$5.apply(Serializer.java:114)
at org.eclipse.xtext.xbase.lib.IteratorExtensions.forEach(IteratorExtensions.java:362)
at org.eclipse.xtext.xbase.lib.IterableExtensions.forEach(IterableExtensions.java:331)
at org.eclipselabs.emftriple.sesame.map.Serializer.serialize(Serializer.java:117)
at org.eclipselabs.emftriple.sesame.map.Serializer.access$0(Serializer.java:86)
at org.eclipselabs.emftriple.sesame.map.Serializer$3.apply(Serializer.java:56)
at org.eclipselabs.emftriple.sesame.map.Serializer$3.apply(Serializer.java:1)
at org.eclipse.xtext.xbase.lib.IteratorExtensions.forEach(IteratorExtensions.java:362)
at org.eclipse.xtext.xbase.lib.IterableExtensions.forEach(IterableExtensions.java:331)
at org.eclipselabs.emftriple.sesame.map.Serializer.to(Serializer.java:59)
at org.eclipselabs.emftriple.sesame.map.Serializer.serializeOne(Serializer.java:173)
at org.eclipselabs.emftriple.sesame.map.Serializer.serialize(Serializer.java:160)
at org.eclipselabs.emftriple.sesame.map.Serializer.access$1(Serializer.java:127)
at org.eclipselabs.emftriple.sesame.map.Serializer$4.apply(Serializer.java:64)
at org.eclipselabs.emftriple.sesame.map.Serializer$4.apply(Serializer.java:1)
at org.eclipse.xtext.xbase.lib.IteratorExtensions.forEach(IteratorExtensions.java:362)
at org.eclipse.xtext.xbase.lib.IterableExtensions.forEach(IterableExtensions.java:331)
at org.eclipselabs.emftriple.sesame.map.Serializer.to(Serializer.java:67)
at org.eclipselabs.emftriple.sesame.map.Serializer$2.apply(Serializer.java:39)
at org.eclipselabs.emftriple.sesame.map.Serializer$2.apply(Serializer.java:1)
at org.eclipse.xtext.xbase.lib.IteratorExtensions.forEach(IteratorExtensions.java:362)
at org.eclipse.xtext.xbase.lib.IterableExtensions.forEach(IterableExtensions.java:331)
at org.eclipselabs.emftriple.sesame.map.Serializer.to(Serializer.java:42)
at org.eclipselabs.emftriple.sesame.map.EObjectMapper.to(EObjectMapper.java:37)
at org.eclipselabs.emftriple.sesame.map.EObjectMapper.to(EObjectMapper.java:19)
at org.eclipselabs.emftriple.sesame.resource.RDFResource.doSave(RDFResource.java:60)
at org.eclipse.emf.ecore.resource.impl.ResourceImpl.save(ResourceImpl.java:1430)
at org.eclipse.emf.ecore.resource.impl.ResourceImpl.save(ResourceImpl.java:999)
at Model2RDF.saveModel(Model2RDF.java:76)
at Model2RDF.main(Model2RDF.java:39)
The text was updated successfully, but these errors were encountered: