Skip to content

Commit

Permalink
TEIIDDES-1899 Teiid Connection Importer should set translator on impo…
Browse files Browse the repository at this point in the history
…rted model
  • Loading branch information
mdrillin committed Oct 31, 2013
1 parent 7d0c71d commit 486dc1e
Showing 1 changed file with 34 additions and 0 deletions.
Expand Up @@ -30,6 +30,7 @@
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.teiid.core.designer.CoreModelerPlugin;
import org.teiid.core.designer.util.CoreStringUtil;
import org.teiid.designer.core.ModelerCore;
import org.teiid.designer.core.workspace.ModelResource;
Expand Down Expand Up @@ -238,6 +239,35 @@ public IStatus undeployDynamicVdb() {
// }
// }

/**
* Inject the translator name into the target model annotation.
* @param monitor the progress monitor
*/
private boolean injectTranslatorIntoTarget(final IProgressMonitor monitor) {
if( this.targetModelLocation == null ) {
return false;
}

IPath modelPath = new Path(targetModelLocation.toOSString()).append(this.targetModelName);
if( !modelPath.toString().toUpperCase().endsWith(".XMI")) { //$NON-NLS-1$
modelPath = modelPath.addFileExtension("xmi"); //$NON-NLS-1$
}

IResource targetModel = ModelerCore.getWorkspace().getRoot().getFile(modelPath);
ModelResource targetModelResc = ModelUtilities.getModelResourceForIFile((IFile)targetModel, false);
if( targetModelResc!=null && this.translatorName!=null) {
connectionInfoHelper.setTranslatorName(targetModelResc, this.translatorName);
try {
targetModelResc.save(monitor, false);
} catch (Exception error) {
throw CoreModelerPlugin.toRuntimeException(error);
}
return true;
}

return false;
}

/**
* Return the schema DDL for the currently deployed dynamic import VDB
* @return the schema DDL
Expand Down Expand Up @@ -644,6 +674,10 @@ public void run( final IProgressMonitor monitor ) {
monitor.beginTask(Messages.TeiidImportManager_ImportingMsg, 100);
monitor.worked(50);
ddlImporter.save(monitor, 50);
// Inject translator name into target
if(translatorName!=null) {
injectTranslatorIntoTarget(monitor);
}
monitor.done();
}
});
Expand Down

0 comments on commit 486dc1e

Please sign in to comment.