use of org.talend.dq.writer.AElementPersistance in project tdq-studio-se by Talend.
the class UpdatePropertiesFileTask method saveObject.
private void saveObject(EMFUtil emfUtil, File file, URI uri, EObject eObject) {
ModelElement modelElement = (ModelElement) eObject;
AElementPersistance writer = ElementWriterFactory.getInstance().create(modelElement);
Property oldPropery = PropertyHelper.getProperty(modelElement);
if (writer != null) {
Property property = writer.initProperty(modelElement);
if (oldPropery != null) {
property.setId(oldPropery.getId());
property.setAuthor(oldPropery.getAuthor());
property.getItem().setState(oldPropery.getItem().getState());
}
String statePathStr = PropertyHelper.computePath(property, file);
property.getItem().getState().setPath(statePathStr);
URI propURI = uri.trimFileExtension().appendFileExtension(FactoriesUtil.PROPERTIES_EXTENSION);
Resource propResource = emfUtil.getResourceSet().createResource(propURI);
propResource.getContents().add(property);
propResource.getContents().add(property.getItem());
propResource.getContents().add(property.getItem().getState());
EMFUtil.saveResource(propResource);
} else {
// $NON-NLS-1$
log.warn(DefaultMessagesImpl.getString("UpdatePropertiesFileTask_5", modelElement.getName()));
}
}
Aggregations