Example usage for org.apache.commons.lang ArrayUtils isNotEmpty

List of usage examples for org.apache.commons.lang ArrayUtils isNotEmpty

Introduction

In this page you can find the example usage for org.apache.commons.lang ArrayUtils isNotEmpty.

Prototype

public static boolean isNotEmpty(boolean[] array) 

Source Link

Document

Checks if an array of primitive booleans is not empty or not null.

Usage

From source file:org.pentaho.metaverse.analyzer.kettle.step.httppost.HTTPPostExternalResourceConsumer.java

@Override
public Collection<IExternalResourceInfo> getResourcesFromRow(HTTPPOST httpClientInput, RowMetaInterface rowMeta,
        Object[] row) {/*from   ww  w  .  j a  v  a2  s . c  om*/
    Collection<IExternalResourceInfo> resources = new LinkedList<IExternalResourceInfo>();

    // For some reason the step doesn't return the StepMetaInterface directly, so go around it
    HTTPPOSTMeta meta = (HTTPPOSTMeta) httpClientInput.getStepMetaInterface();
    if (meta == null) {
        meta = (HTTPPOSTMeta) httpClientInput.getStepMeta().getStepMetaInterface();
    }
    if (meta != null) {
        try {
            String url;
            if (meta.isUrlInField()) {
                url = rowMeta.getString(row, meta.getUrlField(), null);
            } else {
                url = meta.getUrl();
            }
            if (!Const.isEmpty(url)) {
                WebServiceResourceInfo resourceInfo = (WebServiceResourceInfo) ExternalResourceInfoFactory
                        .createURLResource(url, true);

                if (ArrayUtils.isNotEmpty(meta.getArgumentField())) {
                    for (int i = 0; i < meta.getArgumentField().length; i++) {
                        String field = meta.getArgumentField()[i];
                        String label = meta.getArgumentParameter()[i];
                        resourceInfo.addHeader(label, rowMeta.getString(row, field, null));
                    }
                }

                if (ArrayUtils.isNotEmpty(meta.getQueryField())) {
                    for (int i = 0; i < meta.getQueryField().length; i++) {
                        String field = meta.getQueryField()[i];
                        String label = meta.getQueryParameter()[i];
                        resourceInfo.addParameter(label, rowMeta.getString(row, field, null));
                    }
                }

                resources.add(resourceInfo);
            }
        } catch (KettleException kve) {
            // TODO throw exception or ignore?
        }
    }
    return resources;
}

From source file:org.pentaho.metaverse.analyzer.kettle.step.httppost.HTTPPostStepAnalyzer.java

@Override
protected Set<StepField> getUsedFields(HTTPPOSTMeta stepMeta) {
    Set<StepField> usedFields = new HashSet<>();

    // add url field
    if (stepMeta.isUrlInField() && StringUtils.isNotEmpty(stepMeta.getUrlField())) {
        usedFields.addAll(createStepFields(stepMeta.getUrlField(), getInputs()));
    }/*  w ww . j  av  a 2 s. c o  m*/

    // add parameters as used fields
    String[] parameterFields = stepMeta.getQueryField();
    if (ArrayUtils.isNotEmpty(parameterFields)) {
        for (String paramField : parameterFields) {
            usedFields.addAll(createStepFields(paramField, getInputs()));
        }
    }

    // add headers as used fields
    String[] headerFields = stepMeta.getArgumentField();
    if (ArrayUtils.isNotEmpty(headerFields)) {
        for (String headerField : headerFields) {
            usedFields.addAll(createStepFields(headerField, getInputs()));
        }
    }
    return usedFields;
}

From source file:org.pentaho.metaverse.analyzer.kettle.step.rest.RestClientExternalResourceConsumer.java

@Override
public Collection<IExternalResourceInfo> getResourcesFromRow(Rest step, RowMetaInterface rowMeta,
        Object[] row) {/* w w w. j  a  v  a2  s.  c o  m*/
    Set<IExternalResourceInfo> resources = new HashSet<>();

    RestMeta meta = (RestMeta) step.getStepMetaInterface();
    if (meta == null) {
        meta = (RestMeta) step.getStepMeta().getStepMetaInterface();
    }

    if (meta != null) {
        String url;
        String method;
        String body;

        try {
            if (meta.isUrlInField()) {
                url = rowMeta.getString(row, meta.getUrlField(), null);
            } else {
                url = meta.getUrl();
            }
            if (StringUtils.isNotEmpty(url)) {
                WebServiceResourceInfo resourceInfo = createResourceInfo(url, meta);
                if (ArrayUtils.isNotEmpty(meta.getHeaderField())) {
                    for (int i = 0; i < meta.getHeaderField().length; i++) {
                        String field = meta.getHeaderField()[i];
                        String label = meta.getHeaderName()[i];
                        resourceInfo.addHeader(label, rowMeta.getString(row, field, null));
                    }
                }
                if (ArrayUtils.isNotEmpty(meta.getParameterField())) {
                    for (int i = 0; i < meta.getParameterField().length; i++) {
                        String field = meta.getParameterField()[i];
                        String label = meta.getParameterName()[i];
                        resourceInfo.addParameter(label, rowMeta.getString(row, field, null));
                    }
                }
                if (meta.isDynamicMethod()) {
                    method = rowMeta.getString(row, meta.getMethodFieldName(), null);
                    resourceInfo.setMethod(method);
                }

                if (StringUtils.isNotEmpty(meta.getBodyField())) {
                    body = rowMeta.getString(row, meta.getBodyField(), null);
                    resourceInfo.setBody(body);
                }

                resources.add(resourceInfo);
            }
        } catch (KettleValueException e) {
            // could not find a url on this row
            log.debug(e.getMessage(), e);
        }
    }
    return resources;
}

From source file:org.pentaho.metaverse.analyzer.kettle.step.rest.RestClientStepAnalyzer.java

@Override
protected Set<StepField> getUsedFields(RestMeta stepMeta) {
    Set<StepField> usedFields = new HashSet<>();

    // add url field
    if (stepMeta.isUrlInField() && StringUtils.isNotEmpty(stepMeta.getUrlField())) {
        usedFields.addAll(createStepFields(stepMeta.getUrlField(), getInputs()));
    }/*from ww  w  .  j ava  2  s. c o  m*/

    // add method field
    if (stepMeta.isDynamicMethod() && StringUtils.isNotEmpty(stepMeta.getMethodFieldName())) {
        usedFields.addAll(createStepFields(stepMeta.getMethodFieldName(), getInputs()));
    }

    // add body field
    if (StringUtils.isNotEmpty(stepMeta.getBodyField())) {
        usedFields.addAll(createStepFields(stepMeta.getBodyField(), getInputs()));
    }

    // add parameters as used fields
    String[] parameterFields = stepMeta.getParameterField();
    if (ArrayUtils.isNotEmpty(parameterFields)) {
        for (String paramField : parameterFields) {
            usedFields.addAll(createStepFields(paramField, getInputs()));
        }
    }

    // add headers as used fields
    String[] headerFields = stepMeta.getHeaderField();
    if (ArrayUtils.isNotEmpty(headerFields)) {
        for (String headerField : headerFields) {
            usedFields.addAll(createStepFields(headerField, getInputs()));
        }
    }

    return usedFields;
}

From source file:org.piraso.ui.api.StackTraceFilterDialog.java

private void btnRemoveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnRemoveActionPerformed
    if (ArrayUtils.isNotEmpty(jtable.getSelectedRows())) {
        List<String> removed = new ArrayList<String>();
        for (int index : jtable.getSelectedRows()) {
            removed.add(String.valueOf(tableModel.getValueAt(index, 0)));
        }/*from w  w  w .j  a  va  2  s . c  om*/

        for (String regex : removed) {
            removeRegex(regex);
        }
    }

    refreshButtons();
}

From source file:org.piraso.ui.api.util.JTableUtils.java

public static void scrollTo(JTable[] tables, int rowNum) {
    if (ArrayUtils.isNotEmpty(tables)) {
        for (JTable table : tables) {
            if (table == null)
                continue;

            table.scrollRectToVisible(table.getCellRect(rowNum, 1, true));
        }/*from   w w w .  j a  v a  2 s. c o  m*/
    }
}

From source file:org.piraso.ui.api.WorkingSetDialog.java

private void btnRemoveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnRemoveActionPerformed
    if (ArrayUtils.isNotEmpty(jtable.getSelectedRows())) {
        List<String> removed = new ArrayList<String>();
        for (int index : jtable.getSelectedRows()) {
            removed.add(String.valueOf(tableModel.getValueAt(index, 0)));
        }//from w w  w  .j  a v  a  2s  .co m

        for (String workingSetName : removed) {
            removeWorkingSet(workingSetName);
        }
    }

    refreshButtons();
}

From source file:org.piraso.ui.base.ProfilesDialog.java

private void btnDisassociateActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnDisassociateActionPerformed
    if (ArrayUtils.isNotEmpty(jtable.getSelectedRows())) {
        List<String> removedMonitors = new ArrayList<String>();
        for (int index : jtable.getSelectedRows()) {
            removedMonitors.add(String.valueOf(tableModel.getValueAt(index, 0)));
        }// www.j av a 2 s . c om

        for (String monitorName : removedMonitors) {
            removeAssociatedMonitor(monitorName);
        }
    }

    refreshButtons();
}

From source file:org.piraso.ui.log4j.Log4jPreferenceDialog.java

private void btnRemoveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnRemoveActionPerformed
    if (ArrayUtils.isNotEmpty(jtable.getSelectedRows())) {
        List<String> removed = new ArrayList<String>();
        for (int index : jtable.getSelectedRows()) {
            removed.add(String.valueOf(tableModel.getValueAt(index, 0)));
        }//from  w ww  .j a v a 2  s  . com

        for (String logger : removed) {
            removeLogger(logger);
        }
    }

    refreshButtons();
}

From source file:org.sakaiproject.memory.impl.SakaiCacheManagerFactoryBean.java

/**
 * This is the init method//from   ww  w . j a v  a  2  s.  com
 * If using Terracotta, enable caching via sakai.properties and ensure the Terracotta server is reachable
 * Use '-Dcom.tc.tc.config.total.timeout=10000' to specify how long we should try to connect to the TC server
 */
public void afterPropertiesSet() throws IOException {
    logger.info("Initializing EhCache CacheManager");
    InputStream is = (this.configLocation != null ? this.configLocation.getInputStream() : null);
    if (this.cacheEnabled == null) {
        this.cacheEnabled = serverConfigurationService.getBoolean("memory.cluster.enabled", false);
    }

    try {
        Configuration configuration = (is != null) ? ConfigurationFactory.parseConfiguration(is)
                : ConfigurationFactory.parseConfiguration();
        configuration.setName(this.cacheManagerName);
        // force the sizeof calculations to not generate lots of warnings OR degrade server performance
        configuration.getSizeOfPolicyConfiguration()
                .maxDepthExceededBehavior(SizeOfPolicyConfiguration.MaxDepthExceededBehavior.ABORT);
        configuration.getSizeOfPolicyConfiguration().maxDepth(100);

        // Setup the Terracotta cluster config
        TerracottaClientConfiguration terracottaConfig = new TerracottaClientConfiguration();

        // use Terracotta server if running and available
        if (this.cacheEnabled) {
            logger.info("Attempting to load cluster caching using Terracotta at: " + serverConfigurationService
                    .getString("memory.cluster.server.urls", DEFAULT_CACHE_SERVER_URL) + ".");
            // set the URL to the server
            String[] serverUrls = serverConfigurationService.getStrings("memory.cluster.server.urls");
            // create comma-separated string of URLs
            String serverUrlsString = StringUtils.join(serverUrls, ",");
            terracottaConfig.setUrl(serverUrlsString);
            terracottaConfig.setRejoin(true);
            configuration.addTerracottaConfig(terracottaConfig);

            // retrieve the names of all caches that will be managed by Terracotta and create cache configurations for them
            String[] caches = serverConfigurationService.getStrings("memory.cluster.names");
            if (ArrayUtils.isNotEmpty(caches)) {
                for (String cacheName : caches) {
                    CacheConfiguration cacheConfiguration = this.createClusterCacheConfiguration(cacheName);
                    if (cacheConfiguration != null) {
                        configuration.addCache(cacheConfiguration);
                    }
                }
            }

            // create new cache manager with the above configuration
            if (this.shared) {
                this.cacheManager = (CacheManager) ReflectionUtils.invokeMethod(createWithConfiguration, null,
                        configuration);
            } else {
                this.cacheManager = new CacheManager(configuration);
            }
        } else {
            // This block contains the original code from org/springframework/cache/ehcache/EhCacheManagerFactoryBean.java
            // A bit convoluted for EhCache 1.x/2.0 compatibility.
            // To be much simpler once we require EhCache 2.1+
            logger.info("Attempting to load default cluster caching.");
            configuration.addTerracottaConfig(terracottaConfig);
            if (this.cacheManagerName != null) {
                if (this.shared && createWithConfiguration == null) {
                    // No CacheManager.create(Configuration) method available before EhCache 2.1;
                    // can only set CacheManager name after creation.
                    this.cacheManager = (is != null ? CacheManager.create(is) : CacheManager.create());
                    this.cacheManager.setName(this.cacheManagerName);
                } else {
                    configuration.setName(this.cacheManagerName);
                    if (this.shared) {
                        this.cacheManager = (CacheManager) ReflectionUtils.invokeMethod(createWithConfiguration,
                                null, configuration);
                    } else {
                        this.cacheManager = new CacheManager(configuration);
                    }
                }
            } else if (this.shared) {
                // For strict backwards compatibility: use simplest possible constructors...
                this.cacheManager = (is != null ? CacheManager.create(is) : CacheManager.create());
            } else {
                this.cacheManager = (is != null ? new CacheManager(is) : new CacheManager());
            }
        }
    } catch (CacheException ce) {
        // this is thrown if we can't connect to the Terracotta server on initialization
        if (this.cacheEnabled && this.cacheManager == null) {
            logger.error(
                    "You have cluster caching enabled in sakai.properties, but do not have a Terracotta server running at "
                            + serverConfigurationService.getString("memory.cluster.server.urls",
                                    DEFAULT_CACHE_SERVER_URL)
                            + ". Please ensure the server is running and available.",
                    ce);
            // use the default cache instead
            this.cacheEnabled = false;
            afterPropertiesSet();
        } else {
            logger.error("An error occurred while creating the cache manager: ", ce);
        }
    } finally {
        if (is != null) {
            is.close();
        }
    }
}