Skip to content

Commit

Permalink
[BACKLOG-5453] Add the field "webapp name" for Pentaho Data Service d…
Browse files Browse the repository at this point in the history
…atabase type (SWT Dialog)
  • Loading branch information
pavel-sakun committed Apr 11, 2016
1 parent 75de7bc commit 157ebb9
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
12 changes: 10 additions & 2 deletions dbdialog/src/org/pentaho/ui/database/event/DataHandler.java
Expand Up @@ -2,7 +2,7 @@
*
* Pentaho Data Integration
*
* Copyright (C) 2002-2015 by Pentaho : http://www.pentaho.com
* Copyright (C) 2002-2016 by Pentaho : http://www.pentaho.com
*
*******************************************************************************
*
Expand Down Expand Up @@ -88,6 +88,8 @@ public class DataHandler extends AbstractXulEventHandler {

// Kettle thin related
private static final String WEB_APPLICATION_NAME = "WEB_APPLICATION_NAME";
private static final String EXTRA_OPTION_WEB_APPLICATION_NAME = BaseDatabaseMeta.ATTRIBUTE_PREFIX_EXTRA_OPTION
+ "KettleThin.webappname";

// The connectionMap allows us to keep track of the connection
// type we are working with and the correlating database interface
Expand Down Expand Up @@ -786,6 +788,12 @@ private void setInfo( DatabaseMeta meta ) {
return;
}

if ( meta.getAttributes().containsKey( EXTRA_OPTION_WEB_APPLICATION_NAME ) ) {
meta.getAttributes().put( WEB_APPLICATION_NAME, meta.getAttributes().get( EXTRA_OPTION_WEB_APPLICATION_NAME ) );
meta.getAttributes().remove( EXTRA_OPTION_WEB_APPLICATION_NAME );
meta.setChanged();
}

getControls();

// Name:
Expand Down Expand Up @@ -1360,7 +1368,7 @@ private void setConnectionSpecificInfo( DatabaseMeta meta ) {
if ( webAppName != null ) {
if ( databaseMeta != null && databaseMeta.getAttributes().containsKey( WEB_APPLICATION_NAME ) ) {
webAppName.setValue( databaseMeta.getAttributes().getProperty( WEB_APPLICATION_NAME ) );
} else if ( databaseMeta == null || !databaseMeta.getExtraOptions().containsKey( "KettleThin.webappname" ) ) {
} else {
webAppName.setValue( "pentaho-di" );
}
}
Expand Down
Expand Up @@ -2,7 +2,7 @@
*
* Pentaho Data Integration
*
* Copyright (C) 2002-2015 by Pentaho : http://www.pentaho.com
* Copyright (C) 2002-2016 by Pentaho : http://www.pentaho.com
*
*******************************************************************************
*
Expand All @@ -25,6 +25,7 @@
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.pentaho.di.core.database.BaseDatabaseMeta;
import org.pentaho.di.core.database.DatabaseInterface;
import org.pentaho.di.core.database.DatabaseMeta;
import org.pentaho.di.core.logging.KettleLogStore;
Expand Down Expand Up @@ -233,13 +234,17 @@ public void testGetSetData() throws Exception {

DatabaseMeta dbMeta = mock( DatabaseMeta.class );
when( dbMeta.getAccessType() ).thenReturn( DatabaseMeta.TYPE_ACCESS_JNDI );
when( dbMeta.getAttributes() ).thenReturn( new Properties() );
Properties props = new Properties();
props.put( BaseDatabaseMeta.ATTRIBUTE_PREFIX_EXTRA_OPTION + "KettleThin.webappname", "foo" );
when( dbMeta.getAttributes() ).thenReturn( props );

when( accessBox.getSelectedItem() ).thenReturn( "JNDI" );
when( deckOptionsBox.getSelectedIndex() ).thenReturn( -1 );
dataHandler.setData( dbMeta );
assertEquals( dbMeta, dataHandler.getData() );
assertNotSame( initialDbMeta, dataHandler.getData() );
assertFalse( props.containsKey( BaseDatabaseMeta.ATTRIBUTE_PREFIX_EXTRA_OPTION + "KettleThin.webappname" ) );
assertTrue( props.get( "WEB_APPLICATION_NAME" ).equals( "foo" ) );

dataHandler.setData( null );
assertEquals( dbMeta, dataHandler.getData() );
Expand Down

0 comments on commit 157ebb9

Please sign in to comment.