Skip to content

Commit

Permalink
Merge pull request #5 in PLUGINS/etl-plugin from etl-fix to release/3…
Browse files Browse the repository at this point in the history
….0/master

* commit 'fba0358b409a0653c9a1574adaef0ff9b3851744':
  etl fetch db / tables button fixed
  enable SubutaiExecutors
  etl fetch db / tables button fixed
  internal fix
  internal commit
  • Loading branch information
Salih Kardan committed Apr 9, 2015
2 parents ef6fc20 + fba0358 commit f914662
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 50 deletions.
3 changes: 2 additions & 1 deletion etl-impl/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>environment-manager-api</artifactId>
<artifactId>env-manager-api</artifactId>
<version>2.0.0</version>
</dependency>
<dependency>
<groupId>org.safehaus.subutai</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import java.util.UUID;
import java.util.concurrent.ExecutorService;

import com.vaadin.ui.*;
import org.safehaus.subutai.core.tracker.api.Tracker;
import org.safehaus.subutai.plugin.etl.api.ETL;
import org.safehaus.subutai.plugin.sqoop.api.DataSourceType;
Expand All @@ -14,18 +15,6 @@
import org.safehaus.subutai.plugin.sqoop.api.setting.ImportSetting;

import com.vaadin.data.Property;
import com.vaadin.ui.AbstractTextField;
import com.vaadin.ui.Alignment;
import com.vaadin.ui.Button;
import com.vaadin.ui.CheckBox;
import com.vaadin.ui.ComboBox;
import com.vaadin.ui.Component;
import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.Notification;
import com.vaadin.ui.ProgressBar;
import com.vaadin.ui.TabSheet;
import com.vaadin.ui.VerticalLayout;



public class ImportPanel extends ImportExportBase
Expand Down Expand Up @@ -267,7 +256,7 @@ public void onComplete()
HorizontalLayout dbLayout = new HorizontalLayout();
dbLayout.setSpacing( true );
dbLayout.addComponent( databases );
Button fetchDB = new Button( "Fetch" );
final Button fetchDB = new Button( "Fetch" );
fetchDB.addStyleName( "default" );
dbLayout.addComponent( fetchDB );
dbLayout.setComponentAlignment( fetchDB, Alignment.BOTTOM_CENTER );
Expand All @@ -291,46 +280,48 @@ public void buttonClick( final Button.ClickEvent clickEvent )
Notification.show( "Please enter your password!" );
return;
}
progressIconDB.setVisible( true );
executorService.execute( new Runnable()
{

progressIconDB.setVisible(true);
fetchDB.setEnabled(false);
executorService.execute(new Runnable() {
@Override
public void run()
{
public void run() {
databases.removeAllItems();
ImportSetting importSettings = makeSettings();
String databaseList = sqoop.fetchDatabases( importSettings );
ArrayList<String> dbItems = clearResult( databaseList );
if ( dbItems.isEmpty() ){
if ( dbItems.isEmpty() )
{

Notification.show( "Cannot fetch any database. Check your connection details !!!" );
progressIconDB.setVisible( false );
fetchDB.setEnabled(true);
return;
}
Notification.show( "Fetched " + dbItems.size() + " databases." );

for ( String dbItem : dbItems ){
databases.addItem( dbItem );
}
try
{
Thread.sleep( 2000 );
}
catch ( InterruptedException e )
Notification.show("Fetched " + dbItems.size() + " databases.");

for ( String dbItem : dbItems )
{
e.printStackTrace();
databases.addItem( dbItem );
}
progressIconDB.setVisible( false );
UI.getCurrent().access( new Runnable() {
@Override
public void run() {
fetchDB.setEnabled(true);
progressIconDB.setVisible( false );
}
});
}
} );
});
}
} );


HorizontalLayout tableLayout = new HorizontalLayout();
tableLayout.setSpacing( true );
tableLayout.addComponent( tables );
Button fetchTables = new Button( "Fetch" );
final Button fetchTables = new Button( "Fetch" );
fetchTables.addStyleName( "default" );
tableLayout.addComponent( fetchTables );
tableLayout.setComponentAlignment( fetchTables, Alignment.BOTTOM_CENTER );
Expand All @@ -353,15 +344,19 @@ public void buttonClick( final Button.ClickEvent clickEvent )
Notification.show( "Please enter your password!" );
return;
}
if ( databases.getValue() == null ){
Notification.show( "Please select database first!" );
return;
}
progressIconTable.setVisible( true );
executorService.execute( new Runnable()
{
fetchTables.setEnabled(false);

executorService.execute(new Runnable() {
@Override
public void run()
{
public void run() {
tables.removeAllItems();
ImportSetting importSettings = makeSettings();
String tableList = sqoop.fetchTables( importSettings );
String tableList = sqoop.fetchTables(importSettings);
ArrayList<String> tableItems = clearResult( tableList );
if ( tableItems.isEmpty() ){
Notification.show( "Cannot fetch any table. Check your connection details !!!" );
Expand All @@ -373,18 +368,16 @@ public void run()
for ( String tableItem : tableItems ){
tables.addItem( tableItem );
}
try
{
Thread.sleep( 2000 );
}
catch ( InterruptedException e )
{
e.printStackTrace();
}
progressIconTable.setVisible( false );
}
} );

UI.getCurrent().access( new Runnable() {
@Override
public void run() {
progressIconTable.setVisible(false);
fetchTables.setEnabled(true);
}
});
}
});
}
} );

Expand Down Expand Up @@ -504,6 +497,6 @@ boolean checkFields()
private boolean isChecked( CheckBox chb )
{
Object v = chb.getValue();
return v != null ? Boolean.parseBoolean( v.toString() ) : false;
return v != null && Boolean.parseBoolean( v.toString() );
}
}

0 comments on commit f914662

Please sign in to comment.