Skip to content

Commit

Permalink
TEIIDDES-1518: Create interface for TeiidDataSource
Browse files Browse the repository at this point in the history
* Makes the codebase more flexible and easier to create a common spi
  • Loading branch information
Paul Richardson committed Dec 7, 2012
1 parent 6a153c5 commit fc9961b
Show file tree
Hide file tree
Showing 20 changed files with 272 additions and 179 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 @@ -357,7 +357,7 @@
type="org.teiid.designer.runtime.ui.views.content.ITeiidResourceNode">
</adapter>
<adapter
type="org.teiid.designer.runtime.TeiidDataSource">
type="org.teiid.designer.runtime.ITeiidDataSource">
</adapter>
<adapter
type="org.teiid.designer.runtime.ITeiidTranslator">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.dialogs.ElementTreeSelectionDialog;
import org.teiid.designer.runtime.DqpPlugin;
import org.teiid.designer.runtime.TeiidDataSource;
import org.teiid.designer.runtime.ITeiidDataSource;
import org.teiid.designer.runtime.TeiidServer;
import org.teiid.designer.runtime.ui.DqpUiConstants;
import org.teiid.designer.runtime.ui.views.TeiidServerContentProvider;
Expand All @@ -42,7 +42,7 @@ public class SelectJndiDataSourceDialog extends ElementTreeSelectionDialog imple

private Text dataSourceNameText;
private MessageLabel statusMessageLabel;
private TeiidDataSource selectedDataSource;
private ITeiidDataSource selectedDataSource;

public SelectJndiDataSourceDialog( Shell parent ) {
super(parent, new TeiidServerLabelProvider(), new TeiidServerContentProvider(false, false, true));
Expand Down Expand Up @@ -111,8 +111,8 @@ public boolean select( Viewer viewer,
public boolean select( Viewer viewer,
Object parentElement,
Object element ) {
if (element instanceof TeiidDataSource) {
String name = ((TeiidDataSource)element).getName();
if (element instanceof ITeiidDataSource) {
String name = ((ITeiidDataSource)element).getName();
return !name.startsWith(Vdb.PREVIEW_PREFIX);
}

Expand All @@ -135,11 +135,11 @@ public void selectionChanged( SelectionChangedEvent event ) {

Object firstElement = selection.getFirstElement();

if (!(firstElement instanceof TeiidDataSource)) {
if (!(firstElement instanceof ITeiidDataSource)) {
this.selectedDataSource = null;
this.dataSourceNameText.setText(UNDEFINED);
} else {
this.selectedDataSource = (TeiidDataSource)selection.getFirstElement();
this.selectedDataSource = (ITeiidDataSource)selection.getFirstElement();
this.dataSourceNameText.setText(selectedDataSource.getName());
}

Expand All @@ -151,7 +151,7 @@ private void updateOnSelection( Object selectedObject ) {
DqpUiConstants.PLUGIN_ID,
DqpUiConstants.UTIL.getString("SelectJndiDataSourceDialog.okSelectionMessage")); //$NON-NLS-1$
if (selectedObject != null) {
if (!(selectedObject instanceof TeiidDataSource)) {
if (!(selectedObject instanceof ITeiidDataSource)) {
status = new Status(IStatus.ERROR,
DqpUiConstants.PLUGIN_ID,
DqpUiConstants.UTIL.getString("SelectJndiDataSourceDialog.invalidSelectionMessage")); //$NON-NLS-1$
Expand All @@ -174,7 +174,7 @@ private void updateOnSelection( Object selectedObject ) {
*
* @return the TeiidDataSource. may return null
*/
public TeiidDataSource getSelectedTranslator() {
public ITeiidDataSource getSelectedTranslator() {
return this.selectedDataSource;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
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.ITeiidDataSource;
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.connection.ModelConnectionMapper;
Expand Down Expand Up @@ -141,7 +141,7 @@ public void run() {

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

TeiidDataSource initialSelection = null;
ITeiidDataSource initialSelection = null;
TeiidServer defServer = getDefaultServer();
if (defServer != null && defServer.isConnected()) {
try {
Expand All @@ -158,8 +158,8 @@ public void run() {

if (dialog.getReturnCode() == Window.OK) {
Object result = dialog.getFirstResult();
if (result != null && result instanceof TeiidDataSource) {
vdbModelEntry.setJndiName(((TeiidDataSource)result).getName());
if (result != null && result instanceof ITeiidDataSource) {
vdbModelEntry.setJndiName(((ITeiidDataSource)result).getName());
}
}
}
Expand Down Expand Up @@ -224,7 +224,7 @@ public String[] getDataSourceNames() {
TeiidServer defaultServer = getDefaultServer();

if ((defaultServer != null) && defaultServer.isConnected()) {
Collection<TeiidDataSource> dataSources = null;
Collection<ITeiidDataSource> dataSources = null;

try {
dataSources = defaultServer.getDataSources();
Expand All @@ -237,7 +237,7 @@ public String[] getDataSourceNames() {
if (dataSources != null) {
Collection<String> dataSourceNames = new ArrayList<String>();

for (TeiidDataSource dataSource : dataSources) {
for (ITeiidDataSource dataSource : dataSources) {
if (!dataSource.isPreview()) {
dataSourceNames.add(dataSource.getName());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import org.teiid.designer.core.util.StringUtilities;
import org.teiid.designer.metamodels.core.ModelType;
import org.teiid.designer.runtime.DqpPlugin;
import org.teiid.designer.runtime.TeiidDataSourceFactory;
import org.teiid.designer.runtime.TeiidServer;
import org.teiid.designer.vdb.TranslatorOverride;
import org.teiid.designer.vdb.Vdb;
Expand Down Expand Up @@ -234,7 +235,9 @@ public void run() {
if ((autoCreate || createOnServer) && (model != null)) {
monitor.subTask(UTIL.getString(PREFIX + "createModelDataSourceTask", modelName)); //$NON-NLS-1$

if (teiidServer.getOrCreateDataSource(model,
TeiidDataSourceFactory factory = new TeiidDataSourceFactory();
if (factory.createDataSource(teiidServer,
model,
jndiName,
false,
DqpPlugin.getInstance().getPasswordProvider()) == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@
import org.eclipse.ui.navigator.ICommonViewerSite;
import org.eclipse.ui.navigator.ICommonViewerWorkbenchSite;
import org.teiid.designer.runtime.DqpPlugin;
import org.teiid.designer.runtime.ITeiidDataSource;
import org.teiid.designer.runtime.ITeiidVdb;
import org.teiid.designer.runtime.PreferenceConstants;
import org.teiid.designer.runtime.TeiidDataSource;
import org.teiid.designer.runtime.TeiidServer;
import org.teiid.designer.runtime.TeiidServerManager;
import org.teiid.designer.runtime.preview.PreviewManager;
Expand Down Expand Up @@ -266,7 +266,7 @@ public void run() {
public void run() {
List<Object> selectedObjs = getSelectedObjects();
for (Object obj : selectedObjs) {
TeiidDataSource tds = RuntimeAssistant.adapt(obj, TeiidDataSource.class);
ITeiidDataSource tds = RuntimeAssistant.adapt(obj, ITeiidDataSource.class);
TeiidServer teiidServer = RuntimeAssistant.getServerFromSelection(selectionProvider.getSelection());

if (teiidServer != null && teiidServer.isConnected()) {
Expand Down Expand Up @@ -513,7 +513,7 @@ public void fillContextMenu(IMenuManager manager) {
manager.add(this.editServerAction);
manager.add(new Separator());

} else if (RuntimeAssistant.adapt(selection, TeiidDataSource.class) != null) {
} else if (RuntimeAssistant.adapt(selection, ITeiidDataSource.class) != null) {
manager.add(this.deleteDataSourceAction);
manager.add(new Separator());

Expand All @@ -533,7 +533,7 @@ public void fillContextMenu(IMenuManager manager) {
boolean allDataSources = true;

for (Object obj : selectedObjs) {
if (RuntimeAssistant.adapt(obj, TeiidDataSource.class) == null) {
if (RuntimeAssistant.adapt(obj, ITeiidDataSource.class) == null) {
allDataSources = false;
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@
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.ITeiidDataSource;
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.adapter.TeiidServerAdapterUtil;
import org.teiid.designer.runtime.ui.DqpUiConstants;
Expand Down Expand Up @@ -104,7 +104,7 @@ public boolean select( Viewer viewer, Object parentElement, Object element ) {
*/
@Override
public boolean select( Viewer viewer, Object parentElement, Object element ) {
TeiidDataSource dataSource = RuntimeAssistant.adapt(element, TeiidDataSource.class);
ITeiidDataSource dataSource = RuntimeAssistant.adapt(element, ITeiidDataSource.class);
if (dataSource != null && dataSource.isPreview())
return false;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
package org.teiid.designer.runtime.ui.views.content;

import java.util.Collection;
import org.teiid.designer.runtime.TeiidDataSource;
import org.teiid.designer.runtime.ITeiidDataSource;
import org.teiid.designer.runtime.ui.DqpUiConstants;

/**
* @since 8.0
*/
public class DataSourcesFolder extends AbstractTeiidFolder<TeiidDataSource> {
public class DataSourcesFolder extends AbstractTeiidFolder<ITeiidDataSource> {

private static final String DATA_SOURCES_FOLDER_NAME = DqpUiConstants.UTIL.getString(DataSourcesFolder.class.getSimpleName() + ".label"); //$NON-NLS-1$

Expand All @@ -24,7 +24,7 @@ public class DataSourcesFolder extends AbstractTeiidFolder<TeiidDataSource> {
* @param parentNode
* @param values
*/
public DataSourcesFolder(TeiidServerContainerNode parentNode, Collection<TeiidDataSource> values ) {
public DataSourcesFolder(TeiidServerContainerNode parentNode, Collection<ITeiidDataSource> values ) {
super(parentNode, values);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
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.ITeiidDataSource;
import org.teiid.designer.runtime.ITeiidTranslator;
import org.teiid.designer.runtime.ITeiidVdb;
import org.teiid.designer.runtime.TeiidDataSource;
Expand Down Expand Up @@ -81,11 +82,11 @@ public void dispose() {

@Override
public String getName() {
if (value instanceof TeiidDataSource) {
if (((TeiidDataSource) value).getDisplayName() != null) {
return ((TeiidDataSource) value).getDisplayName();
if (value instanceof ITeiidDataSource) {
if (((ITeiidDataSource) value).getDisplayName() != null) {
return ((ITeiidDataSource) value).getDisplayName();
}
return ((TeiidDataSource) value).getName();
return ((ITeiidDataSource) value).getName();
}

if (value instanceof ITeiidTranslator) {
Expand Down Expand Up @@ -156,7 +157,7 @@ public Image getImage() {
return DqpUiPlugin.getDefault().getAnImage(DqpUiConstants.Images.CONNECTOR_BINDING_ICON);
}

if (value instanceof TeiidDataSource) {
if (value instanceof ITeiidDataSource) {
return DqpUiPlugin.getDefault().getAnImage(DqpUiConstants.Images.CONNECTION_SOURCE_ICON);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
import java.util.Collections;
import java.util.List;
import org.eclipse.wst.server.core.IServer;
import org.teiid.designer.runtime.ITeiidDataSource;
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.ui.DqpUiConstants;
import org.teiid.designer.runtime.ui.views.TeiidServerContentProvider;
Expand Down Expand Up @@ -105,7 +105,7 @@ public final void load() {
try {
// hide Data Sources related variables from other local variables
DATA_SOURCES: {
Collection<TeiidDataSource> dataSources;
Collection<ITeiidDataSource> dataSources;

if (provider.isShowDataSources()) {
dataSources = new ArrayList(teiidServer.getDataSources());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
package org.teiid.designer.runtime.ui.views.content.adapter;

import org.eclipse.core.runtime.IAdapterFactory;
import org.teiid.designer.runtime.ITeiidDataSource;
import org.teiid.designer.runtime.ITeiidTranslator;
import org.teiid.designer.runtime.ITeiidVdb;
import org.teiid.designer.runtime.TeiidDataSource;
import org.teiid.designer.runtime.ui.views.content.ITeiidResourceNode;
import org.teiid.designer.runtime.ui.views.content.TeiidDataNode;

Expand All @@ -29,7 +29,7 @@ public Object getAdapter(Object adaptableObject, Class adapterType) {
if (ITeiidResourceNode.class == adapterType)
return adaptToTeiidResourceNode(teiidDataNode);

if (TeiidDataSource.class == adapterType ||
if (ITeiidDataSource.class == adapterType ||
ITeiidTranslator.class == adapterType ||
ITeiidVdb.class == adapterType) {

Expand Down Expand Up @@ -57,7 +57,7 @@ private Object adaptToTeiidResourceNode(TeiidDataNode teiidDataNode) {
@Override
public Class[] getAdapterList() {
return new Class[] { ITeiidResourceNode.class,
TeiidDataSource.class,
ITeiidDataSource.class,
ITeiidTranslator.class,
ITeiidVdb.class };
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
*/
public final class ExecutionConfigurationEvent {

public static ExecutionConfigurationEvent createAddDataSourceEvent( TeiidDataSource dataSource ) {
public static ExecutionConfigurationEvent createAddDataSourceEvent( ITeiidDataSource dataSource ) {
return new ExecutionConfigurationEvent(EventType.ADD, TargetType.DATA_SOURCE, dataSource);
}

Expand All @@ -32,7 +32,7 @@ public static ExecutionConfigurationEvent createDeployVDBEvent( String vdbName )
return new ExecutionConfigurationEvent(EventType.ADD, TargetType.VDB, vdbName);
}

public static ExecutionConfigurationEvent createRemoveDataSourceEvent( TeiidDataSource dataSource ) {
public static ExecutionConfigurationEvent createRemoveDataSourceEvent( ITeiidDataSource dataSource ) {
return new ExecutionConfigurationEvent(EventType.REMOVE, TargetType.DATA_SOURCE, dataSource);
}

Expand All @@ -53,7 +53,7 @@ public static ExecutionConfigurationEvent createUnDeployVDBEvent( String vdbName
return new ExecutionConfigurationEvent(EventType.REMOVE, TargetType.VDB, vdbName);
}

public static ExecutionConfigurationEvent createUpdateDataSourceEvent( TeiidDataSource dataSource ) {
public static ExecutionConfigurationEvent createUpdateDataSourceEvent( ITeiidDataSource dataSource ) {
return new ExecutionConfigurationEvent(EventType.UPDATE, TargetType.DATA_SOURCE, dataSource);
}

Expand Down Expand Up @@ -102,14 +102,14 @@ private ExecutionConfigurationEvent( TargetType targetType ) {
* @return the connector involved in the event
* @throws IllegalStateException if method is called for a server event
*/
public TeiidDataSource getDataSource() {
public ITeiidDataSource getDataSource() {
if (this.targetType != TargetType.DATA_SOURCE) {
throw new IllegalStateException(Util.getString("invalidTargetTypeForGetDataSourceMethod", //$NON-NLS-1$
this.targetType,
TargetType.DATA_SOURCE));
}

return (TeiidDataSource)this.target;
return (ITeiidDataSource)this.target;
}

/**
Expand Down

0 comments on commit fc9961b

Please sign in to comment.