use of org.talend.dq.helper.resourcehelper.ResourceFileMap in project tdq-studio-se by Talend.
the class UpdatePropertiesFileTask method doExecute.
/*
* (non-Javadoc)
*
* @see org.talend.dataprofiler.core.migration.AMigrationTask#doExecute()
*/
@Override
protected boolean doExecute() throws Exception {
boolean ok = true;
EMFUtil emfUtil = new EMFUtil();
for (File file : fileList) {
if (file.isFile()) {
URI uri = URI.createFileURI(file.getAbsolutePath());
if (log.isDebugEnabled()) {
// $NON-NLS-1$
log.debug("---------Translate " + uri.toString());
}
EObject eObject = null;
try {
Resource resource = emfUtil.getResourceSet().getResource(uri, true);
ResourceFileMap resourceFileMap = ModelElementFileFactory.getResourceFileMap(uri.fileExtension());
if (resourceFileMap != null) {
eObject = resourceFileMap.getModelElement(resource);
}
} catch (Exception e) {
// $NON-NLS-1$
log.warn(DefaultMessagesImpl.getString("UpdatePropertiesFileTask_2", file.getAbsolutePath()), e);
ok = false;
}
if (eObject != null) {
if (eObject instanceof ModelElement) {
try {
saveObject(emfUtil, file, uri, eObject);
} catch (Exception e) {
// $NON-NLS-1$
log.error(DefaultMessagesImpl.getString("UpdatePropertiesFileTask_3", eObject, file, uri), e);
ok = false;
}
} else {
// $NON-NLS-1$
log.warn(DefaultMessagesImpl.getString("UpdatePropertiesFileTask_4", eObject.toString()));
ok = false;
}
}
}
}
emfUtil = null;
return ok;
}
Aggregations