Bug 327750 - MWE2 Writer cannot handle models without feature "name"
Summary: MWE2 Writer cannot handle models without feature "name"
Status: NEW
Alias: None
Product: EMFT
Classification: Modeling
Component: MWE (show other bugs)
Version: 1.0.1   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-10-14 06:11 EDT by Jens Von Pilgrim CLA
Modified: 2010-10-14 06:11 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jens Von Pilgrim CLA 2010-10-14 06:11:40 EDT
org.eclipse.emf.mwe.utils.Writer throws a NullPointerException if the model to be saved does not have a feature "name", i.e. if model.eClass().getEStructuralFeature("name") returns null.

This problem can be solved in case of a single model/resource by adding a new attribute "modelName", which can then be configured in the workflow. In case of multiple models/resources, this does not work. But it may help if the feature name is configurable, e.g.

String nameFeature = "name"; // default is ok
public void setNameFeature(String i_nameFeature) {
	nameFeature = i_nameFeature;
}
protected String getName(final EObject model) {
	return (String) model.eGet(model.eClass().getEStructuralFeature(nameFeature));
}

In this context it would be nice to change the visibility of createResourceName and getName to protected, in order to simplify subclassing of the writer class (why are these methods declared private, anyway).

Related bugs (concerning Writer extension):
https://bugs.eclipse.org/bugs/show_bug.cgi?id=290733 
    Writer: Make encoding and file extension user configureable options
https://bugs.eclipse.org/bugs/show_bug.cgi?id=310077
    EType reference of EReference serialization, relative paths do not resolve into absolute ones

Jens