Search in sources :

Example 1 with Segments

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

the class GaInputStepDialog method readGaSegments.

// Collect segment list from the GA service for the given authentication information
public void readGaSegments() {
    try {
        Analytics analytics = getAnalytics();
        if (analytics == null) {
            return;
        }
        Segments segments = analytics.management().segments().list().execute();
        ArrayList<String> segmentNames = new ArrayList<String>(20);
        segmentIds.clear();
        for (Segment segmentEntry : segments.getItems()) {
            segmentNames.add(segmentEntry.getName());
            segmentIds.put(segmentEntry.getName(), "gaid::" + segmentEntry.getId());
        }
        // put the segments to the combo box and select first one
        wQuSegment.setItems(segmentNames.toArray(new String[segmentNames.size()]));
        if (segmentNames.size() > 0) {
            wQuSegment.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 : ArrayList(java.util.ArrayList) Segments(com.google.api.services.analytics.model.Segments) Analytics(com.google.api.services.analytics.Analytics) Segment(com.google.api.services.analytics.model.Segment) 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 Segment (com.google.api.services.analytics.model.Segment)1 Segments (com.google.api.services.analytics.model.Segments)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 MessageBox (org.eclipse.swt.widgets.MessageBox)1