Search in sources :

Example 1 with Profile

use of com.google.api.services.analytics.model.Profile in project pentaho-kettle by pentaho.

the class GaInputStepDialog method readGaProfiles.

// Collect profile list from the GA service for the given authentication
// information
public void readGaProfiles() {
    try {
        Analytics analytics = getAnalytics();
        if (analytics == null) {
            return;
        }
        Analytics.Management.Profiles.List profiles = analytics.management().profiles().list("~all", "~all");
        Profiles profileList = profiles.execute();
        profileTableIds.clear();
        List<String> profileNames = new ArrayList<String>();
        for (Profile profile : profileList.getItems()) {
            String tableId = "ga:" + profile.getId();
            String profileName = tableId + " - profile: " + profile.getName();
            profileNames.add(profileName);
            profileTableIds.put(profileName, tableId);
        }
        // put the profiles to the combo box and select first one
        wGaProfile.setItems(profileNames.toArray(new String[profileNames.size()]));
        if (profileNames.size() > 0) {
            wGaProfile.select(0);
        }
    } catch (Exception e) {
        MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR);
        mb.setText(BaseMessages.getString(PKG, "GoogleAnalyticsDialog.AuthenticationFailure.DialogTitle"));
        mb.setMessage(BaseMessages.getString(PKG, "GoogleAnalyticsDialog.AuthenticationFailure.DialogMessage"));
        mb.open();
    }
}
Also used : Profiles(com.google.api.services.analytics.model.Profiles) ArrayList(java.util.ArrayList) Analytics(com.google.api.services.analytics.Analytics) Profile(com.google.api.services.analytics.model.Profile) GoogleJsonResponseException(com.google.api.client.googleapis.json.GoogleJsonResponseException) IOException(java.io.IOException) MessageBox(org.eclipse.swt.widgets.MessageBox)

Aggregations

GoogleJsonResponseException (com.google.api.client.googleapis.json.GoogleJsonResponseException)1 Analytics (com.google.api.services.analytics.Analytics)1 Profile (com.google.api.services.analytics.model.Profile)1 Profiles (com.google.api.services.analytics.model.Profiles)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 MessageBox (org.eclipse.swt.widgets.MessageBox)1