Skip to content

Commit

Permalink
TEIIDDES-1518: Confine the use of Translator class
Browse files Browse the repository at this point in the history
* Since the Translator class will be version dependent, confine its
  use to implementation classes of a teiid 8.0 client,
  ie. ExecutionAdmin and TeiidTranslator.

* Since TeiidTranslator wraps the version dependent Translator,
  the interface ITeiidTranslator is used externally.

* The PropertyDefinition class is also version dependent and forms
  part of the TeiidTranslator API. To address this a version
  independent TeiidPropertyDefinition rewraps all the values of the
  property definition.
  • Loading branch information
Paul Richardson committed Dec 7, 2012
1 parent 4c332b4 commit a47d329
Show file tree
Hide file tree
Showing 27 changed files with 518 additions and 310 deletions.
2 changes: 1 addition & 1 deletion plugins/org.teiid.designer.dqp.ui/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@
type="org.teiid.designer.runtime.TeiidDataSource">
</adapter>
<adapter
type="org.teiid.designer.runtime.TeiidTranslator">
type="org.teiid.designer.runtime.ITeiidTranslator">
</adapter>
<adapter
type="org.teiid.designer.runtime.ITeiidVdb">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.dialogs.ElementTreeSelectionDialog;
import org.teiid.designer.runtime.DqpPlugin;
import org.teiid.designer.runtime.ITeiidTranslator;
import org.teiid.designer.runtime.TeiidServer;
import org.teiid.designer.runtime.TeiidTranslator;
import org.teiid.designer.runtime.ui.DqpUiConstants;
import org.teiid.designer.runtime.ui.views.TeiidServerContentProvider;
import org.teiid.designer.runtime.ui.views.TeiidServerLabelProvider;
Expand All @@ -42,7 +42,7 @@ public class SelectTranslatorDialog extends ElementTreeSelectionDialog implement

private Text translatorNameText;
private MessageLabel statusMessageLabel;
private TeiidTranslator selectedTranslator;
private ITeiidTranslator selectedTranslator;

public SelectTranslatorDialog( Shell parent ) {
super(parent, new TeiidServerLabelProvider(), new TeiidServerContentProvider(false, true, false));
Expand Down Expand Up @@ -123,11 +123,11 @@ public void selectionChanged( SelectionChangedEvent event ) {

Object firstElement = selection.getFirstElement();

if (!(firstElement instanceof TeiidTranslator)) {
if (!(firstElement instanceof ITeiidTranslator)) {
this.selectedTranslator = null;
this.translatorNameText.setText(UNDEFINED);
} else {
this.selectedTranslator = (TeiidTranslator)selection.getFirstElement();
this.selectedTranslator = (ITeiidTranslator)selection.getFirstElement();
this.translatorNameText.setText(selectedTranslator.getName());
}

Expand All @@ -139,7 +139,7 @@ private void updateOnSelection( Object selectedObject ) {
DqpUiConstants.PLUGIN_ID,
DqpUiConstants.UTIL.getString("SelectTranslatorDialog.okSelectionMessage")); //$NON-NLS-1$
if (selectedObject != null) {
if (!(selectedObject instanceof TeiidTranslator)) {
if (!(selectedObject instanceof ITeiidTranslator)) {
status = new Status(IStatus.ERROR,
DqpUiConstants.PLUGIN_ID,
DqpUiConstants.UTIL.getString("SelectTranslatorDialog.invalidSelectionMessage")); //$NON-NLS-1$
Expand All @@ -162,7 +162,7 @@ private void updateOnSelection( Object selectedObject ) {
*
* @return the TeiidTranslator. may return null
*/
public TeiidTranslator getSelectedTranslator() {
public ITeiidTranslator getSelectedTranslator() {
return this.selectedTranslator;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@
import org.teiid.designer.core.workspace.ModelWorkspaceException;
import org.teiid.designer.metamodels.core.ModelType;
import org.teiid.designer.runtime.DqpPlugin;
import org.teiid.designer.runtime.ITeiidTranslator;
import org.teiid.designer.runtime.TeiidDataSource;
import org.teiid.designer.runtime.TeiidPropertyDefinition;
import org.teiid.designer.runtime.TeiidServer;
import org.teiid.designer.runtime.TeiidTranslator;
import org.teiid.designer.runtime.connection.ModelConnectionMapper;
import org.teiid.designer.vdb.VdbModelEntry;
import org.teiid.designer.vdb.connections.SourceHandler;
Expand Down Expand Up @@ -188,7 +189,7 @@ public void run() {

SelectTranslatorDialog dialog = new SelectTranslatorDialog(Display.getCurrent().getActiveShell());

TeiidTranslator initialSelection = null;
ITeiidTranslator initialSelection = null;
TeiidServer defServer = getDefaultServer();
if (defServer != null && defServer.isConnected()) {
try {
Expand All @@ -205,8 +206,8 @@ public void run() {

if (dialog.getReturnCode() == Window.OK) {
Object result = dialog.getFirstResult();
if (result != null && result instanceof TeiidTranslator) {
vdbModelEntry.setTranslator(((TeiidTranslator)result).getName());
if (result != null && result instanceof ITeiidTranslator) {
vdbModelEntry.setTranslator(((ITeiidTranslator)result).getName());
}
}
}
Expand Down Expand Up @@ -268,12 +269,12 @@ public PropertyDefinition[] getTranslatorDefinitions( String translatorName ) {

if ((defaultServer != null) && defaultServer.isConnected()) {
try {
TeiidTranslator translator = defaultServer.getTranslator(translatorName);
ITeiidTranslator translator = defaultServer.getTranslator(translatorName);

if (translator != null) {
Collection<PropertyDefinition> props = new ArrayList<PropertyDefinition>();

for (org.teiid.adminapi.PropertyDefinition propDefn : translator.getPropertyDefinitions()) {
for (TeiidPropertyDefinition propDefn : translator.getPropertyDefinitions()) {
TranslatorProperty prop = new TranslatorProperty(propDefn.getPropertyTypeClassName());
prop.advanced = propDefn.isAdvanced();
prop.description = propDefn.getDescription();
Expand Down Expand Up @@ -328,7 +329,7 @@ public String[] getTranslatorTypes() {
TeiidServer defaultServer = getDefaultServer();

if ((defaultServer != null) && defaultServer.isConnected()) {
Collection<TeiidTranslator> translators = null;
Collection<ITeiidTranslator> translators = null;

try {
translators = defaultServer.getTranslators();
Expand All @@ -341,7 +342,7 @@ public String[] getTranslatorTypes() {
if (translators != null) {
Collection<String> translatorTypes = new ArrayList<String>();

for (TeiidTranslator translator : translators) {
for (ITeiidTranslator translator : translators) {
translatorTypes.add(translator.getName());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,11 @@
import org.teiid.designer.metamodels.relational.ProcedureParameter;
import org.teiid.designer.metamodels.webservice.Operation;
import org.teiid.designer.runtime.DqpPlugin;
import org.teiid.designer.runtime.ITeiidTranslator;
import org.teiid.designer.runtime.ITeiidVdb;
import org.teiid.designer.runtime.TeiidJdbcInfo;
import org.teiid.designer.runtime.TeiidServer;
import org.teiid.designer.runtime.TeiidServerManager;
import org.teiid.designer.runtime.TeiidTranslator;
import org.teiid.designer.runtime.preview.PreviewManager;
import org.teiid.designer.runtime.preview.jobs.TeiidPreviewVdbJob;
import org.teiid.designer.runtime.preview.jobs.WorkspacePreviewVdbJob;
Expand Down Expand Up @@ -198,7 +198,7 @@ public void run( final EObject eObject, final boolean planOnly ) {

String translatorName = helper.getTranslatorName(mr);
if( translatorName != null ) {
TeiidTranslator tt = null;
ITeiidTranslator tt = null;

try {
tt = getServerManager().getDefaultServer().getTranslator(translatorName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
package org.teiid.designer.runtime.ui.views;

import static org.teiid.designer.runtime.ui.DqpUiConstants.UTIL;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
Expand All @@ -23,10 +22,10 @@
import org.eclipse.ui.views.properties.IPropertySource;
import org.eclipse.ui.views.properties.PropertyDescriptor;
import org.eclipse.ui.views.properties.TextPropertyDescriptor;
import org.teiid.adminapi.PropertyDefinition;
import org.teiid.core.designer.util.CoreArgCheck;
import org.teiid.designer.runtime.ITeiidTranslator;
import org.teiid.designer.runtime.JDBCConnectionPropertyNames;
import org.teiid.designer.runtime.TeiidTranslator;
import org.teiid.designer.runtime.TeiidPropertyDefinition;
import org.teiid.designer.ui.common.util.WidgetFactory;


Expand All @@ -35,7 +34,7 @@
*/
public class ConnectionPropertySource implements IPropertySource {

private TeiidTranslator translator;
private ITeiidTranslator translator;
private final Properties initialValues;

private boolean isEditable = false;
Expand All @@ -44,7 +43,7 @@ public class ConnectionPropertySource implements IPropertySource {
/**
* @param connector the connector whose properties are being edited (never <code>null</code>)
*/
public ConnectionPropertySource( TeiidTranslator translator ) {
public ConnectionPropertySource( ITeiidTranslator translator ) {
this(translator.getProperties());
this.translator = translator;
}
Expand Down Expand Up @@ -75,11 +74,11 @@ public Object getEditableValue() {
@Override
public IPropertyDescriptor[] getPropertyDescriptors() {
IPropertyDescriptor[] result = new IPropertyDescriptor[0];
Collection<? extends PropertyDefinition> typeDefs = this.translator.getPropertyDefinitions();
Collection<TeiidPropertyDefinition> typeDefs = this.translator.getPropertyDefinitions();
boolean showExpertProps = this.provider.isShowingExpertProperties();
Collection<PropertyDescriptor> temp = new ArrayList<PropertyDescriptor>(typeDefs.size());

for (final PropertyDefinition propDefn : typeDefs) {
for (final TeiidPropertyDefinition propDefn : typeDefs) {
final String id = propDefn.getName();
String displayName = propDefn.getDisplayName();
//
Expand All @@ -99,7 +98,7 @@ public IPropertyDescriptor[] getPropertyDescriptors() {
}

// set validator
final TeiidTranslator validator = this.translator;
final ITeiidTranslator validator = this.translator;

descriptor.setValidator(new ICellEditorValidator() {
@Override
Expand Down Expand Up @@ -156,7 +155,7 @@ public Object getPropertyValue( Object id ) {
// return empty string
if (result.length() == 0) return result;

PropertyDefinition propDefn = this.translator.getPropertyDefinition(propName);
TeiidPropertyDefinition propDefn = this.translator.getPropertyDefinition(propName);

// if masked property don't return actual result
if (propDefn.isMasked()) {
Expand Down Expand Up @@ -187,7 +186,7 @@ public boolean isPropertySet( Object id ) {
*/
@Override
public void resetPropertyValue( Object id ) {
PropertyDefinition propDefn = ((PropertyDefinition)id);
TeiidPropertyDefinition propDefn = ((TeiidPropertyDefinition)id);
setPropertyValue(id, this.initialValues.getProperty(propDefn.getName()));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import org.teiid.designer.core.workspace.ModelResource;
import org.teiid.designer.core.workspace.ModelWorkspaceException;
import org.teiid.designer.core.workspace.ModelWorkspaceManager;
import org.teiid.designer.runtime.TeiidTranslator;
import org.teiid.designer.runtime.ITeiidTranslator;
import org.teiid.designer.runtime.TranslatorTemplate;
import org.teiid.designer.runtime.connection.SourceConnectionBinding;
import org.teiid.designer.runtime.ui.DqpUiConstants;
Expand Down Expand Up @@ -49,12 +49,12 @@ public void addPropertyChangeListener( IPropertyChangeListener listener ) {
@Override
public IPropertySource getPropertySource( Object object ) {
if (object instanceof TranslatorTemplate) {
ConnectionPropertySource source = new ConnectionPropertySource((TeiidTranslator)object);
ConnectionPropertySource source = new ConnectionPropertySource((TranslatorTemplate)object);
source.setEditable(this.connectorsEditable);
source.setProvider(this);
return source;
} else if (object instanceof TeiidTranslator) {
ConnectionPropertySource source = new ConnectionPropertySource(new TranslatorTemplate((TeiidTranslator)object));
} else if (object instanceof ITeiidTranslator) {
ConnectionPropertySource source = new ConnectionPropertySource(new TranslatorTemplate((ITeiidTranslator)object));
source.setEditable(this.connectorsEditable);
source.setProvider(this);
return source;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.teiid.designer.runtime.TeiidTranslator;
import org.teiid.designer.runtime.ITeiidTranslator;
import org.teiid.designer.runtime.ui.DqpUiConstants;

/**
Expand Down Expand Up @@ -53,8 +53,8 @@ protected String formatMessage(ISelection sel) {
return UTIL.getString("StatusBarUpdater.num_elements_selected", String.valueOf(nElements)); //$NON-NLS-1$
}
Object elem= selection.getFirstElement();
if (elem instanceof TeiidTranslator) {
return ((TeiidTranslator) elem).getName();
if (elem instanceof ITeiidTranslator) {
return ((ITeiidTranslator) elem).getName();
}

return elem.getClass().getName();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
import org.eclipse.ui.navigator.CommonDropAdapterAssistant;
import org.teiid.designer.core.ModelerCore;
import org.teiid.designer.core.workspace.ModelResource;
import org.teiid.designer.runtime.ITeiidTranslator;
import org.teiid.designer.runtime.TeiidServer;
import org.teiid.designer.runtime.TeiidTranslator;
import org.teiid.designer.runtime.ui.DqpUiConstants;
import org.teiid.designer.runtime.ui.actions.DeployVdbAction;
import org.teiid.designer.runtime.ui.server.RuntimeAssistant;
Expand All @@ -42,8 +42,8 @@ public class TeiidServerDropAdapterAssistant extends CommonDropAdapterAssistant
@Override
public IStatus validateDrop(Object target, int operation, TransferData transferType) {
currentTransfer = transferType;
if (RuntimeAssistant.adapt(target, TeiidTranslator.class) != null && currentTransfer != null

if (RuntimeAssistant.adapt(target, ITeiidTranslator.class) != null && currentTransfer != null
&& isSupportedType(currentTransfer)) {
// plugin cannot be loaded without the plugin data
return Status.OK_STATUS;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@
import org.eclipse.wst.server.core.util.ServerLifecycleAdapter;
import org.teiid.core.designer.util.I18nUtil;
import org.teiid.designer.runtime.DqpPlugin;
import org.teiid.designer.runtime.ITeiidTranslator;
import org.teiid.designer.runtime.ITeiidVdb;
import org.teiid.designer.runtime.TeiidDataSource;
import org.teiid.designer.runtime.TeiidServerManager;
import org.teiid.designer.runtime.TeiidTranslator;
import org.teiid.designer.runtime.adapter.TeiidServerAdapterUtil;
import org.teiid.designer.runtime.ui.DqpUiConstants;
import org.teiid.designer.runtime.ui.DqpUiPlugin;
Expand Down Expand Up @@ -85,7 +85,7 @@ public class TeiidView extends CommonNavigator implements DqpUiConstants {
*/
@Override
public boolean select( Viewer viewer, Object parentElement, Object element ) {
TeiidTranslator teiidTranslator = RuntimeAssistant.adapt(element, TeiidTranslator.class);
ITeiidTranslator teiidTranslator = RuntimeAssistant.adapt(element, ITeiidTranslator.class);
if (teiidTranslator != null)
return false;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
import org.eclipse.swt.graphics.Image;
import org.eclipse.wst.server.core.IServer;
import org.teiid.core.designer.util.I18nUtil;
import org.teiid.designer.runtime.ITeiidTranslator;
import org.teiid.designer.runtime.ITeiidVdb;
import org.teiid.designer.runtime.TeiidDataSource;
import org.teiid.designer.runtime.TeiidServer;
import org.teiid.designer.runtime.TeiidTranslator;
import org.teiid.designer.runtime.connection.SourceConnectionBinding;
import org.teiid.designer.runtime.ui.DqpUiConstants;
import org.teiid.designer.runtime.ui.DqpUiPlugin;
Expand Down Expand Up @@ -88,8 +88,8 @@ public String getName() {
return ((TeiidDataSource) value).getName();
}

if (value instanceof TeiidTranslator) {
return ((TeiidTranslator) value).getName();
if (value instanceof ITeiidTranslator) {
return ((ITeiidTranslator) value).getName();
}

if (value instanceof ITeiidVdb) {
Expand All @@ -113,8 +113,8 @@ public String toString() {
return ((TeiidDataSource) value).getName();
}

if (value instanceof TeiidTranslator) {
return ((TeiidTranslator) value).getName();
if (value instanceof ITeiidTranslator) {
return ((ITeiidTranslator) value).getName();
}

if (value instanceof ITeiidVdb) {
Expand Down Expand Up @@ -152,7 +152,7 @@ public String toString() {
* @return {@link Image}
*/
public Image getImage() {
if (value instanceof TeiidTranslator) {
if (value instanceof ITeiidTranslator) {
return DqpUiPlugin.getDefault().getAnImage(DqpUiConstants.Images.CONNECTOR_BINDING_ICON);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
import java.util.Collections;
import java.util.List;
import org.eclipse.wst.server.core.IServer;
import org.teiid.designer.runtime.ITeiidTranslator;
import org.teiid.designer.runtime.ITeiidVdb;
import org.teiid.designer.runtime.TeiidDataSource;
import org.teiid.designer.runtime.TeiidServer;
import org.teiid.designer.runtime.TeiidTranslator;
import org.teiid.designer.runtime.ui.DqpUiConstants;
import org.teiid.designer.runtime.ui.views.TeiidServerContentProvider;

Expand Down Expand Up @@ -139,7 +139,7 @@ public final void load() {

// hide translators related variables from other local variables
TRANSLATORS: {
Collection<TeiidTranslator> translators;
Collection<ITeiidTranslator> translators;

if (provider.isShowTranslators()) {
translators = teiidServer.getTranslators();
Expand Down

0 comments on commit a47d329

Please sign in to comment.