Skip to content

Commit

Permalink
Merge pull request #322 from johnathonlee/8.3.x
Browse files Browse the repository at this point in the history
(BZ1023216) TEIIDDES-1901 Added datasource JNDI name to TeiidConnection ...
  • Loading branch information
blafond committed Apr 9, 2014
2 parents eff7d20 + 61308bf commit a24867c
Show file tree
Hide file tree
Showing 9 changed files with 97 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,19 @@ public void dispose() {
@Override
public String getName() {
if (value instanceof ITeiidDataSource) {
String nodeName = null;
if (((ITeiidDataSource) value).getDisplayName() != null) {
return ((ITeiidDataSource) value).getDisplayName();
nodeName = ((ITeiidDataSource) value).getDisplayName();
}
return ((ITeiidDataSource) value).getName();
nodeName = ((ITeiidDataSource) value).getName();

String jndiName = ((ITeiidDataSource)value).getPropertyValue("jndi-name"); //$NON-NLS-1$
if(jndiName!=null && !jndiName.isEmpty()) {
nodeName += " [JNDI: " + jndiName + "]"; //$NON-NLS-1$ //$NON-NLS-2$
} else {
nodeName += " [JNDI: java:/" + nodeName + "]"; //$NON-NLS-1$ //$NON-NLS-2$
}
return nodeName;
}

if (value instanceof ITeiidTranslator) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public class Messages extends NLS {
public static String errorNameInvalid;

public static String createDataSourcePanel_name;
public static String createDataSourcePanel_jndiName;
public static String createDataSourcePanel_driver;
public static String createDataSourcePanel_driversGroupTxt;
public static String createDataSourcePanel_dataSourcePropertiesGroupTxt;
Expand Down Expand Up @@ -57,6 +58,7 @@ public class Messages extends NLS {
public static String dataSourcePanel_editButtonTooltip;
public static String dataSourcePanel_copyButtonTooltip;
public static String dataSourcePanel_nameColText;
public static String dataSourcePanel_jndiNameColText;
public static String dataSourcePanel_typeColText;
public static String dataSourcePanel_createErrorTitle;
public static String dataSourcePanel_deleteErrorTitle;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ createDataSourcePanelOk=Click OK to accept and create the data source
createDataSourcePanelErrorNameEmpty=Enter a name for the data source
createDataSourcePanelErrorNameExists=The name already exists and cannot be reused
createDataSourcePanel_name=Name:
createDataSourcePanel_jndiName=JNDI Name:
createDataSourcePanel_driver=Driver:
createDataSourcePanel_driversGroupTxt=Available Drivers
createDataSourcePanel_dataSourcePropertiesGroupTxt=Data Source Properties
Expand All @@ -48,6 +49,7 @@ dataSourcePanel_deleteButtonTooltip=Delete the DataSource
dataSourcePanel_editButtonTooltip=Edit the DataSource
dataSourcePanel_copyButtonTooltip=Copy the DataSource using a different name
dataSourcePanel_nameColText=DataSource
dataSourcePanel_jndiNameColText=JNDI Name
dataSourcePanel_typeColText=Driver
dataSourcePanel_createErrorTitle=Error Creating DataSource
dataSourcePanel_deleteErrorTitle=Error Deleting DataSource
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ public class DataSourceItem extends Object implements Serializable {

private static final long serialVersionUID = 1L;
private String name;
private String jndiName;
private String driver;

/**
Expand All @@ -33,6 +34,22 @@ public void setName(String name) {
this.name = name;
}

/**
* Get the DataSource jndi name
* @return the dataSource jndi name
*/
public String getJndiName() {
return jndiName;
}

/**
* Set the DataSource jndi name
* @param jndiName the dataSource jndi name
*/
public void setJndiName(String jndiName) {
this.jndiName = jndiName;
}

/**
* Get the DataSource driver (jar or rar)
* @return the dataSource driver
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ public void run( IProgressMonitor monitor ) throws InvocationTargetException {
try {
// Get properties for the source to copy
Properties dsProps = teiidImportServer.getDataSourceProperties(dataSourceToCopyName);
dsProps.remove("jndi-name"); //$NON-NLS-1$
// Create source with the new name
teiidImportServer.getOrCreateDataSource(newDataSourceName, newDataSourceName, dataSourceToCopyDriver, dsProps);
} catch (Throwable e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,12 +159,17 @@ public int compare( Viewer viewer,
// create columns
TableViewerColumn column = new TableViewerColumn(this.dataSourcesViewer, SWT.LEFT);
column.getColumn().setText(Messages.dataSourcePanel_nameColText);
column.setLabelProvider(new DataSourceLabelProvider(true));
column.setLabelProvider(new DataSourceLabelProvider(0));
column.getColumn().pack();

column = new TableViewerColumn(this.dataSourcesViewer, SWT.LEFT);
column.getColumn().setText(Messages.dataSourcePanel_jndiNameColText);
column.setLabelProvider(new DataSourceLabelProvider(1));
column.getColumn().pack();

column = new TableViewerColumn(this.dataSourcesViewer, SWT.LEFT);
column.getColumn().setText(Messages.dataSourcePanel_typeColText);
column.setLabelProvider(new DataSourceLabelProvider(false));
column.setLabelProvider(new DataSourceLabelProvider(2));
column.getColumn().pack();

this.dataSourcesViewer.addSelectionChangedListener(new ISelectionChangedListener() {
Expand Down Expand Up @@ -468,6 +473,15 @@ private void refreshDataSourceList( ) {
// Name
String name = dataSource.getName();
dsObj.setName(name);

String sourceJndiName = dataSource.getPropertyValue("jndi-name"); //$NON-NLS-1$
if(sourceJndiName!=null) {
dsObj.setJndiName(sourceJndiName);
// The jndi property may not be present if the source was just created. Use the default name.
} else {
dsObj.setJndiName("java:/"+name); //$NON-NLS-1$
}

// Driver name
String dsDriver = dataSourceManager.getDataSourceDriver(name);
dsObj.setDriver(dsDriver);
Expand All @@ -487,6 +501,15 @@ public String getSelectedDataSourceName() {
return (selectedDS==null) ? null : selectedDS.getName();
}

/**
* Get the currently selected DataSource JNDI Name
* @return the selected dataSource JNDI name
*/
public String getSelectedDataSourceJndiName() {
DataSourceItem selectedDS = getSelectedDataSource();
return (selectedDS==null) ? null : selectedDS.getJndiName();
}

/**
* Get the currently selected DataSource driver name
* @return the selected dataSource driver
Expand Down Expand Up @@ -564,10 +587,14 @@ public void refresh() {
*/
class DataSourceLabelProvider extends ColumnLabelProvider {

private final boolean nameColumn;
public int NAME_COL = 0;
public int JNDI_COL = 1;
public int DRIVER_COL = 2;

private int cType;

public DataSourceLabelProvider( boolean nameColumn ) {
this.nameColumn = nameColumn;
public DataSourceLabelProvider( int colType ) {
this.cType = colType;
}

/**
Expand All @@ -589,8 +616,10 @@ public Image getImage( Object element ) {
public String getText( Object element ) {
DataSourceItem dataSourceItem = (DataSourceItem)element;

if (this.nameColumn) {
if (this.cType == NAME_COL) {
return dataSourceItem.getName();
} else if(this.cType == JNDI_COL) {
return dataSourceItem.getJndiName();
} else {
return dataSourceItem.getDriver();
}
Expand All @@ -605,8 +634,10 @@ public String getText( Object element ) {
public String getToolTipText( Object element ) {
DataSourceItem dataSourceItem = (DataSourceItem)element;

if (this.nameColumn) {
if (this.cType == NAME_COL) {
return dataSourceItem.getName();
} else if(this.cType == JNDI_COL) {
return dataSourceItem.getJndiName();
} else {
return Messages.dataSourcePanel_driverTooltipPrefix+dataSourceItem.getName();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ private void setThisPageComplete( String message, int severity) {
@Override
public void selectionChanged(String selectedSourceName) {
importManager.setDataSourceName(this.dataSourcePanel.getSelectedDataSourceName());
importManager.setDataSourceJndiName(this.dataSourcePanel.getSelectedDataSourceJndiName());
importManager.setDataSourceDriverName(this.dataSourcePanel.getSelectedDataSourceDriver());
importManager.setDataSourceProperties(this.propertiesPanel.getDataSourceProperties());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -689,8 +689,8 @@ class ShowVdbXmlDialog extends Dialog {

/**<p>
* </p>
* @param parent
* @param title
* @param shell the shell
* @param theXmlText the xml text
* @since 4.0
*/
public ShowVdbXmlDialog(final Shell shell, final String theXmlText) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ public class TeiidImportManager implements ITeiidImportServer, UiConstants {
private String targetModelName = null;
private String translatorName = null;
private String dataSourceName = null;
private String dataSourceJndiName = null;
private String dataSourceDriverName = null;
private Properties dataSourceProps = null;
private Map<String,String> optionalImportProps = new HashMap<String,String>();
Expand All @@ -97,13 +98,29 @@ public void setDataSourceName(String dsName) {
}

/**
* Get the current Connection name
* @return the Connection name
* Get the current DataSource name
* @return the DataSource name
*/
public String getDataSourceName() {
return this.dataSourceName;
}

/**
* Set the data source JNDI name
* @param dsJndiName the data source JDNI name
*/
public void setDataSourceJndiName(String dsJndiName) {
this.dataSourceJndiName = dsJndiName;
}

/**
* Get the current DataSource jndi name
* @return the jndi name
*/
public String getDataSourceJndiName() {
return this.dataSourceJndiName;
}

/**
* Set the DataSource driver name. Whenever it's reset, set deployment status to invalid so that user
* must reValidate
Expand Down Expand Up @@ -241,6 +258,10 @@ public void run( IProgressMonitor monitor ) throws InvocationTargetException {
return vdbDeploymentStatus;
}

/**
* Get the DynamicVdb xml string
* @return the xml string
*/
public String getDynamicVdbString() {
return getServerImportManager().createDynamicVdbString(IMPORT_VDB_NAME, dataSourceName, translatorName, getOptionalImportProps());
}
Expand Down

0 comments on commit a24867c

Please sign in to comment.