Skip to content

Commit

Permalink
dialog, credentials, meta and test updates for new fields. apache#3034
Browse files Browse the repository at this point in the history
  • Loading branch information
bamaer committed Aug 23, 2023
1 parent 31c6af4 commit fac9ae2
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 10 deletions.
3 changes: 3 additions & 0 deletions integration-tests/spreadsheet/0009-read-google-sheet.hpl
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ limitations under the License.
<method>none</method>
<schema_name/>
</partitioning>
<appName/>
<fields>
<field>
<INPUT_FIELDS>N</INPUT_FIELDS>
Expand Down Expand Up @@ -94,9 +95,11 @@ limitations under the License.
<type>0</type>
</field>
</fields>
<impersonation/>
<jsonCrendentialPath>/tmp/google-key-apache-hop-it.json</jsonCrendentialPath>
<sampleFields>100</sampleFields>
<spreadsheetKey>1uTxX_siSLikbHgZm6kSwUGFZlKDzTP0CnfY7TNaZgeE</spreadsheetKey>
<timeout>5</timeout>
<worksheetId>Sheet1</worksheetId>
<attributes/>
<GUI>
Expand Down
3 changes: 3 additions & 0 deletions integration-tests/spreadsheet/0010-write-google-sheet.hpl
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,11 @@ limitations under the License.
<CREATE>Y</CREATE>
<SHAREDOMAIN/>
<SHAREEMAIL/>
<appName/>
<impersonation/>
<jsonCredentialPath>/tmp/google-key-apache-hop-it.json</jsonCredentialPath>
<spreadsheetKey>1uTxX_siSLikbHgZm6kSwUGFZlKDzTP0CnfY7TNaZgeE</spreadsheetKey>
<timeout>5</timeout>
<worksheetId>Sheet2</worksheetId>
<attributes/>
<GUI>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import com.google.api.client.http.HttpRequestInitializer;
import com.google.api.client.http.*;

import org.apache.commons.lang.StringUtils;
import org.apache.hop.core.exception.HopFileException;
import org.apache.hop.core.vfs.HopVfs;

Expand Down Expand Up @@ -54,7 +55,7 @@ public static HttpCredentialsAdapter getCredentialsJson(String scope, String jso
if (in == null) {
throw new FileNotFoundException("Resource not found:" + jsonCredentialPath);
}
if(impersonation.isEmpty()){
if(StringUtils.isEmpty(impersonation)){
credential = GoogleCredentials.fromStream(in).createScoped(Collections.singleton(scope));
}else{
credential = GoogleCredentials.fromStream(in).createScoped(Collections.singleton(SQLAdminScopes.SQLSERVICE_ADMIN)).createDelegated(impersonation);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,6 @@ public String open() {
// Appname - Text
wAppname = new TextVar(variables, serviceAccountComposite, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wAppname);
// wAppname.addModifyListener(modifiedListener);
FormData appNameData = new FormData();
appNameData.top = new FormAttachment(wbPrivateKeyButton, margin);
appNameData.left = new FormAttachment(middle, 0);
Expand All @@ -215,7 +214,6 @@ public String open() {
// timeout - Text
wTimeout = new TextVar(variables, serviceAccountComposite, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wTimeout);
// wTimeout.addModifyListener(modifiedListener);
FormData timeoutData = new FormData();
timeoutData.top = new FormAttachment(appNameLabel, margin);
timeoutData.left = new FormAttachment(middle, 0);
Expand All @@ -235,7 +233,6 @@ public String open() {
// impersonation - Text
wImpersonation = new TextVar(variables,serviceAccountComposite, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wImpersonation);
// wImpersonation.addModifyListener(modifiedListener);
FormData impersonationData = new FormData();
impersonationData.top = new FormAttachment(wTimeout, margin);
impersonationData.left = new FormAttachment(middle, 0);
Expand All @@ -248,15 +245,15 @@ public String open() {
wbTestServiceAccount.setText(
BaseMessages.getString(PKG, "GoogleSheetsDialog.Button.TestConnection"));
FormData fdbTestServiceAccount = new FormData();
fdbTestServiceAccount.top = new FormAttachment(wbPrivateKeyButton, margin);
fdbTestServiceAccount.top = new FormAttachment(wImpersonation, margin);
fdbTestServiceAccount.left = new FormAttachment(0, 0);
wbTestServiceAccount.setLayoutData(fdbTestServiceAccount);
wbTestServiceAccount.addListener(SWT.Selection, e -> testServiceAccount());

wlTestServiceAccountInfo = new Label(serviceAccountComposite, SWT.LEFT);
props.setLook(wlTestServiceAccountInfo);
FormData fdlTestServiceAccountInfo = new FormData();
fdlTestServiceAccountInfo.top = new FormAttachment(wbPrivateKeyButton, margin);
fdlTestServiceAccountInfo.top = new FormAttachment(wImpersonation, margin);
fdlTestServiceAccountInfo.left = new FormAttachment(middle, 0);
fdlTestServiceAccountInfo.right = new FormAttachment(100, 0);
wlTestServiceAccountInfo.setLayoutData(fdlTestServiceAccountInfo);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ public void setDefault() {
this.spreadsheetKey = "";
this.worksheetId = "";
this.jsonCredentialPath = "client_secret.json";
this.timeout = "5";
this.impersonation = "";
this.sampleFields = 100;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,6 @@ public String open() {
// timeout - Text
wTimeout = new TextVar(variables,serviceAccountComposite, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wTimeout);
// wTimeout.addModifyListener(modifiedListener);
FormData timeoutData = new FormData();
timeoutData.top = new FormAttachment(appNameLabel, margin);
timeoutData.left = new FormAttachment(middle, 0);
Expand All @@ -246,7 +245,6 @@ public String open() {
// impersonation - Text
wImpersonation = new TextVar(variables, serviceAccountComposite, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wImpersonation);
// wImpersonation.addModifyListener(modifiedListener);
FormData impersonationData = new FormData();
impersonationData.top = new FormAttachment(wTimeout, margin);
impersonationData.left = new FormAttachment(middle, 0);
Expand All @@ -259,15 +257,15 @@ public String open() {
wbTestServiceAccount.setText(
BaseMessages.getString(PKG, "GoogleSheetsDialog.Button.TestConnection"));
FormData fdbTestServiceAccount = new FormData();
fdbTestServiceAccount.top = new FormAttachment(wbPrivateKey, margin);
fdbTestServiceAccount.top = new FormAttachment(wImpersonation, margin);
fdbTestServiceAccount.left = new FormAttachment(0, 0);
wbTestServiceAccount.setLayoutData(fdbTestServiceAccount);
wbTestServiceAccount.addListener(SWT.Selection, e -> testServiceAccount());

wlTestServiceAccountInfo = new Label(serviceAccountComposite, SWT.LEFT);
props.setLook(wlTestServiceAccountInfo);
FormData fdTestServiceAccountInfo = new FormData();
fdTestServiceAccountInfo.top = new FormAttachment(wbPrivateKey, margin);
fdTestServiceAccountInfo.top = new FormAttachment(wImpersonation, margin);
fdTestServiceAccountInfo.left = new FormAttachment(middle, 0);
fdTestServiceAccountInfo.right = new FormAttachment(100, 0);
wlTestServiceAccountInfo.setLayoutData(fdTestServiceAccountInfo);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ public void setDefault() {
this.shareEmail = "";
this.create = true;
this.append = false;
this.impersonation = "";
this.appName = "";
this.timeout = "5";
}

public String getJsonCredentialPath() {
Expand Down

0 comments on commit fac9ae2

Please sign in to comment.