Example usage for org.apache.commons.collections4 CollectionUtils isNotEmpty

List of usage examples for org.apache.commons.collections4 CollectionUtils isNotEmpty

Introduction

In this page you can find the example usage for org.apache.commons.collections4 CollectionUtils isNotEmpty.

Prototype

public static boolean isNotEmpty(final Collection<?> coll) 

Source Link

Document

Null-safe check if the specified collection is not empty.

Usage

From source file:org.finra.herd.tools.retention.exporter.RetentionExpirationExporterController.java

/**
 * Executes the retention expiration exporter workflow.
 *
 * @param namespace the namespace of business object data
 * @param businessObjectDefinitionName the business object definition name of business object data
 * @param localOutputFile the local output file
 * @param regServerAccessParamsDto the DTO for the parameters required to communicate with the registration server
 * @param udcServerHost the hostname of the UDC application server
 *
 * @throws Exception if any problems were encountered
 *//*from  w  w  w  . j  a v a 2s  .  com*/
void performRetentionExpirationExport(String namespace, String businessObjectDefinitionName,
        File localOutputFile, RegServerAccessParamsDto regServerAccessParamsDto, String udcServerHost)
        throws Exception {
    // Fail if local output file already exists.
    if (localOutputFile.exists()) {
        throw new IllegalArgumentException(String
                .format("The specified local output file \"%s\" already exists.", localOutputFile.toString()));
    }

    // Initialize the web client.
    retentionExpirationExporterWebClient.setRegServerAccessParamsDto(regServerAccessParamsDto);

    // Validate that specified business object definition exists.
    BusinessObjectDefinition businessObjectDefinition = retentionExpirationExporterWebClient
            .getBusinessObjectDefinition(namespace, businessObjectDefinitionName);

    // Get business object display name.
    String businessObjectDefinitionDisplayName = getBusinessObjectDefinitionDisplayName(
            businessObjectDefinition);

    // Create a search request for business object data with the filter on retention expiration option.
    BusinessObjectDataSearchKey businessObjectDataSearchKey = new BusinessObjectDataSearchKey();
    businessObjectDataSearchKey.setNamespace(namespace);
    businessObjectDataSearchKey.setBusinessObjectDefinitionName(businessObjectDefinitionName);
    businessObjectDataSearchKey.setFilterOnRetentionExpiration(true);
    List<BusinessObjectDataSearchKey> businessObjectDataSearchKeys = new ArrayList<>();
    businessObjectDataSearchKeys.add(businessObjectDataSearchKey);
    BusinessObjectDataSearchFilter businessObjectDataSearchFilter = new BusinessObjectDataSearchFilter(
            businessObjectDataSearchKeys);
    BusinessObjectDataSearchRequest request = new BusinessObjectDataSearchRequest(
            Collections.singletonList(businessObjectDataSearchFilter));

    // Create a result list for business object data.
    List<BusinessObjectData> businessObjectDataList = new ArrayList<>();

    // Fetch business object data from server until no records found.
    int pageNumber = 1;
    BusinessObjectDataSearchResult businessObjectDataSearchResult = retentionExpirationExporterWebClient
            .searchBusinessObjectData(request, pageNumber);
    while (CollectionUtils.isNotEmpty(businessObjectDataSearchResult.getBusinessObjectDataElements())) {
        LOGGER.info("Fetched {} business object data records from the registration server.",
                CollectionUtils.size(businessObjectDataSearchResult.getBusinessObjectDataElements()));
        businessObjectDataList.addAll(businessObjectDataSearchResult.getBusinessObjectDataElements());
        pageNumber++;
        businessObjectDataSearchResult = retentionExpirationExporterWebClient.searchBusinessObjectData(request,
                pageNumber);
    }

    // Write business object data to the output CSV file.
    writeToCsvFile(localOutputFile, businessObjectDefinition.getNamespace(),
            businessObjectDefinition.getBusinessObjectDefinitionName(), businessObjectDefinitionDisplayName,
            udcServerHost, businessObjectDataList);
}

From source file:org.finra.herd.tools.uploader.UploaderController.java

/**
 * Handles the uploader logic regarding the latest business object data version if one exists.
 *
 * @param manifest the uploader input manifest
 * @param force if set, allows upload to proceed when the latest version of the business object data has UPLOADING status by invalidating that version
 *
 * @throws JAXBException if a JAXB error was encountered
 * @throws IOException if an I/O error was encountered
 * @throws URISyntaxException if a URI syntax error was encountered
 * @throws KeyStoreException if a key store exception occurs
 * @throws NoSuchAlgorithmException if a no such algorithm exception occurs
 * @throws KeyManagementException if key management exception
 *///www.  jav a2s  .  c o  m
private void checkLatestBusinessObjectDataVersion(UploaderInputManifestDto manifest, Boolean force)
        throws JAXBException, IOException, URISyntaxException, NoSuchAlgorithmException, KeyStoreException,
        KeyManagementException {
    // Retrieve all already registered versions for this business object data.
    BusinessObjectDataVersions businessObjectDataVersions = uploaderWebClient.getBusinessObjectDataVersions(
            new BusinessObjectDataKey(manifest.getNamespace(), manifest.getBusinessObjectDefinitionName(),
                    manifest.getBusinessObjectFormatUsage(), manifest.getBusinessObjectFormatFileType(),
                    Integer.valueOf(manifest.getBusinessObjectFormatVersion()), manifest.getPartitionValue(),
                    manifest.getSubPartitionValues(), null));

    // Check if the latest version of the business object data.
    if (CollectionUtils.isNotEmpty(businessObjectDataVersions.getBusinessObjectDataVersions())) {
        BusinessObjectDataVersion latestBusinessObjectDataVersion = businessObjectDataVersions
                .getBusinessObjectDataVersions()
                .get(businessObjectDataVersions.getBusinessObjectDataVersions().size() - 1);

        // Check if the latest version of the business object data is in UPLOADING state.
        if (BusinessObjectDataStatusEntity.UPLOADING.equals(latestBusinessObjectDataVersion.getStatus())) {
            LOGGER.info(String.format(
                    "Found the latest version of the business object data in UPLOADING state. businessObjectDataKey=%s",
                    jsonHelper.objectToJson(latestBusinessObjectDataVersion.getBusinessObjectDataKey())));

            if (force) {
                // If the "force" flag is set, change the status of the latest business object data version to INVALID.
                uploaderWebClient.updateBusinessObjectDataStatus(
                        latestBusinessObjectDataVersion.getBusinessObjectDataKey(),
                        BusinessObjectDataStatusEntity.INVALID);
            } else {
                // Fail the upload due to the status of the latest business object data version being UPLOADING.
                throw new IllegalArgumentException(String.format(
                        "Unable to register business object data because the latest business object data version is detected in UPLOADING state. "
                                + "Please use -force option to invalidate the latest business object version and allow upload to proceed. "
                                + "Business object data {%s}",
                        businessObjectDataHelper.businessObjectDataKeyToString(
                                latestBusinessObjectDataVersion.getBusinessObjectDataKey())));
            }
        }
    }
}

From source file:org.geoserver.qos.BaseQosXmlEncoder.java

public void encodeLimitedAreaRequestConstraint(String tag, Translator tx, LimitedAreaRequestConstraints arc) {
    tx.start(tag);//  ww w.ja va2 s .  c o m
    // <qos:AreaConstraint srsName="EPSG:3067">
    if (arc.getAreaConstraint() != null) {
        encodeAreaConstraint("qos:AreaConstraint", tx, arc.getAreaConstraint(), arc.getCrs());
    }
    // <qos:RequestParameterConstraint name="LayerName">
    if (CollectionUtils.isNotEmpty(arc.getLayerNames())) {
        encodeRequestParameterConstraint(tx, "LayerName", (Void) -> {
            arc.getLayerNames().forEach(x -> encodeOwsValue(tx, x));
        });
    }
    // <qos:RequestParameterConstraint name="CRS">
    if (StringUtils.isNotEmpty(arc.getCrs())) {
        encodeRequestParameterConstraint(tx, "CRS", (Void) -> {
            encodeOwsValue(tx, arc.getCrs());
        });
    }
    // <qos:RequestParameterConstraint name="OutputFormat">
    if (CollectionUtils.isNotEmpty(arc.getOutputFormat())) {
        encodeRequestParameterConstraint(tx, "OutputFormat", (Void) -> {
            arc.getOutputFormat().forEach(x -> encodeOwsValue(tx, x));
        });
    }
    // <qos:RequestParameterConstraint name="ImageWidth">
    OwsRange imgWidth = arc.getImageWidth();
    if (imgWidth != null && (StringUtils.isNotEmpty(imgWidth.getMinimunValue())
            || StringUtils.isNotEmpty(imgWidth.getMaximunValue()))) {
        encodeRequestParameterConstraint(tx, "ImageWidth", (Void) -> {
            encodeOwsRange(tx, imgWidth.getMinimunValue(), imgWidth.getMaximunValue());
        });
    }
    // <qos:RequestParameterConstraint name="ImageHeight">
    OwsRange imgHeight = arc.getImageHeight();
    if (imgHeight != null && (StringUtils.isNotEmpty(imgHeight.getMinimunValue())
            || StringUtils.isNotEmpty(imgHeight.getMaximunValue()))) {
        encodeRequestParameterConstraint(tx, "ImageHeight", (Void) -> {
            encodeOwsRange(tx, imgHeight.getMinimunValue(), imgHeight.getMaximunValue());
        });
    }
    tx.end(tag);
}

From source file:org.geoserver.qos.web.BaseLimitedConstraintsPanel.java

protected void initAllComponents() {
    selectLayerModal = new ModalWindow("selectLayerModal");
    add(selectLayerModal);/*from  w w w  .j a  va 2s  . com*/

    mainDiv = new WebMarkupContainer("mainDiv");
    mainDiv.setOutputMarkupId(true);
    add(mainDiv);

    innerConstraintsDiv = new WebMarkupContainer("innerConstraintsDiv") {
        @Override
        protected void onConfigure() {
            super.onConfigure();
            if (CollectionUtils.isNotEmpty(getSelectedLayers())) {
                this.setVisible(true);
            } else {
                this.setVisible(false);
            }
        }
    };
    innerConstraintsDiv.setOutputMarkupId(true);
    innerConstraintsDiv.setOutputMarkupPlaceholderTag(true);
    mainDiv.add(innerConstraintsDiv);

    initLayersComponents();
    initFormatsComponents();
    initBoundsComponent();
}

From source file:org.geoserver.qos.wfs.WfsQosXmlEncoder.java

@Override
public void encodeRepresentativeOperation(String tag, Translator tx, QosRepresentativeOperation repOp) {
    tx.start(tag);//from  w w w .  j a v  a 2  s.c om
    if (CollectionUtils.isNotEmpty(repOp.getGetFeatureOperations())) {
        repOp.getGetFeatureOperations().forEach(x -> {
            String gfoTag = QosSchema.QOS_WFS_PREFIX + ":GetFeatureOperation";
            encodeWfsGetFeatureOperation(gfoTag, tx, x);
        });
    }
    if (CollectionUtils.isNotEmpty(repOp.getQualityOfServiceStatements())) {
        repOp.getQualityOfServiceStatements().forEach(x -> {
            encodeQualityOfServiceStatement("qos:QualityOfServiceStatement", tx, x);
        });
    }
    tx.end(tag);
}

From source file:org.geoserver.qos.wfs.WfsQosXmlEncoder.java

public void encodeWfsGetFeatureOperation(String tag, Translator tx, WfsGetFeatureOperation gfOp) {
    tx.start(tag);// ww  w.  j  a  v  a 2s  .c  om
    // http method
    this.encodeHttpMethod(tx, gfOp.getHttpMethod());
    // List<WfsAdHocQueryConstraints>
    if (CollectionUtils.isNotEmpty(gfOp.getAdHocQueryConstraints())) {
        gfOp.getAdHocQueryConstraints().forEach(x -> {
            String adHocTag = QosSchema.QOS_WFS_PREFIX + ":AdHocQueryConstraints";
            encodeAdHocQueryConstraints(adHocTag, tx, x);
        });
    }
    tx.end(tag);
}

From source file:org.geoserver.qos.wfs.WfsQosXmlEncoder.java

public void encodeAdHocQueryConstraints(String tag, Translator tx, WfsAdHocQueryConstraints adHoc) {
    tx.start(tag);//from ww w . ja v a  2  s.co m
    // <qos:AreaConstraint srsName="urn:ogc:def:crs:EPSG::4258">
    if (adHoc.getAreaConstraint() != null) {
        encodeAreaConstraint("qos:AreaConstraint", tx, adHoc.getAreaConstraint(), toWfsCrs(adHoc.getCrs()));
    }
    // <qos-wfs:TypeNames>ad:Address</qos-wfs:TypeNames>
    if (CollectionUtils.isNotEmpty(adHoc.getTypeNames())) {
        String typesTag = QosSchema.QOS_WFS_PREFIX + ":TypeNames";
        for (String ti : adHoc.getTypeNames()) {
            tx.start(typesTag);
            tx.chars(ti);
            tx.end(typesTag);
        }
    }
    // <qos:RequestParameterConstraint name="CRS">
    if (StringUtils.isNotEmpty(adHoc.getCrs())) {
        encodeRequestParameterConstraint(tx, "CRS", (Void) -> {
            encodeOwsValue(tx, toWfsCrs(adHoc.getCrs()));
        });
    }
    // <qos:RequestParameterConstraint name="OutputFormat">
    if (CollectionUtils.isNotEmpty(adHoc.getOutputFormat())) {
        encodeRequestParameterConstraint(tx, "OutputFormat", (Void) -> {
            adHoc.getOutputFormat().forEach(x -> encodeOwsValue(tx, x));
        });
    }
    // <qos:RequestParameterConstraint name="ImageWidth">
    //        OwsRange imgWidth = adHoc.getImageWidth();
    //        if (imgWidth != null
    //                && (StringUtils.isNotEmpty(imgWidth.getMinimunValue())
    //                        || StringUtils.isNotEmpty(imgWidth.getMaximunValue()))) {
    //            encodeRequestParameterConstraint(
    //                    tx,
    //                    "ImageWidth",
    //                    (Void) -> {
    //                        encodeOwsRange(tx, imgWidth.getMinimunValue(),
    // imgWidth.getMaximunValue());
    //                    });
    //        }
    // <qos:RequestParameterConstraint name="ImageHeight">
    //        OwsRange imgHeight = adHoc.getImageHeight();
    //        if (imgHeight != null
    //                && (StringUtils.isNotEmpty(imgHeight.getMinimunValue())
    //                        || StringUtils.isNotEmpty(imgHeight.getMaximunValue()))) {
    //            encodeRequestParameterConstraint(
    //                    tx,
    //                    "ImageHeight",
    //                    (Void) -> {
    //                        encodeOwsRange(
    //                                tx, imgHeight.getMinimunValue(),
    // imgHeight.getMaximunValue());
    //                    });
    //        }
    // <qos:RequestParameterConstraint name="Count">
    if (adHoc.getCount() != null) {
        encodeRequestParameterConstraint(tx, "Count", (Void) -> {
            encodeOwsValue(tx, adHoc.getCount().toString());
        });
    }
    // <qos:RequestParameterConstraint name="ResolveReferences">
    if (StringUtils.isNotEmpty(adHoc.getResolveReferences())) {
        encodeRequestParameterConstraint(tx, "ResolveReferences", (Void) -> {
            encodeOwsValue(tx, adHoc.getResolveReferences());
        });
    }

    tx.end(tag);
}

From source file:org.geoserver.qos.wms.WmsQosXmlEncoder.java

@Override
public void encodeRepresentativeOperation(String tag, Translator tx, QosRepresentativeOperation repOp) {
    tx.start(tag);/*from   w  w w.j av  a 2 s .c om*/
    // GetMapOperations
    if (CollectionUtils.isNotEmpty(repOp.getGetMapOperations())) {
        repOp.getGetMapOperations()
                .forEach(x -> encodeWmsOperation(servicePrefix + ":" + "GetMapOperation", tx, x));
    }
    // GetFeatureInfoOperations
    // repOp.getGetFeatureInfoOperations()
    if (CollectionUtils.isNotEmpty(repOp.getGetFeatureInfoOperations())) {
        repOp.getGetFeatureInfoOperations()
                .forEach(x -> encodeWmsOperation(servicePrefix + ":" + "GetFeatureInfoOperation", tx, x));
    }
    // translate statements:
    if (CollectionUtils.isNotEmpty(repOp.getQualityOfServiceStatements()))
        repOp.getQualityOfServiceStatements().forEach(x -> {
            encodeQualityOfServiceStatement(QosSchema.QOS_PREFIX + ":" + QOS_STATEMENT_TAG, tx, x);
        });
    tx.end(tag);
}

From source file:org.geoserver.qos.wms.WmsQosXmlEncoder.java

public void encodeWmsOperation(String tag, Translator tx, QosWMSOperation wmsop) {
    tx.start(tag);//from   www . ja  va 2 s  .  c o m
    // encode method: <ows:DCP> <ows:HTTP> <ows:Get></ows:Get>
    if (StringUtils.isNotEmpty(wmsop.getHttpMethod())) {
        encodeHttpMethod(tx, wmsop.getHttpMethod());
    }
    // <qos-wms:RequestOption>
    if (CollectionUtils.isNotEmpty(wmsop.getRequestOptions())) {
        // LimitedAreaRequestConstraints -> qos-wms:RequestOption
        wmsop.getRequestOptions().forEach(
                x -> encodeLimitedAreaRequestConstraint(QosSchema.QOS_WMS_PREFIX + ":RequestOption", tx, x));
    }
    tx.end(tag);
}

From source file:org.geoserver.web.demo.MapPreviewPage.java

/** Builds a select that reacts like a menu, fully javascript based, for wms outputs */
private Component buildJSWMSSelect(String id, List<String> wmsOutputFormats, List<String> wfsOutputFormats,
        PreviewLayer layer) {/*from  w  ww . j a  va2 s.c  o  m*/
    Fragment f = new Fragment(id, "menuFragment", MapPreviewPage.this);
    WebMarkupContainer menu = new WebMarkupContainer("menu");

    WebMarkupContainer wmsFormatsGroup = new WebMarkupContainer("wms");
    RepeatingView wmsFormats = new RepeatingView("wmsFormats");
    for (int i = 0; i < wmsOutputFormats.size(); i++) {
        String wmsOutputFormat = wmsOutputFormats.get(i);
        String label = translateFormat("format.wms.", wmsOutputFormat);
        // build option with text and value
        Label format = new Label(i + "", label);
        format.add(new AttributeModifier("value", new Model<String>(ResponseUtils.urlEncode(wmsOutputFormat))));
        wmsFormats.add(format);
    }
    wmsFormatsGroup.add(wmsFormats);
    wmsFormatsGroup.setVisible(CollectionUtils.isNotEmpty(wmsOutputFormats));
    menu.add(wmsFormatsGroup);

    // the vector ones, it depends, we might have to hide them
    boolean vector = layer.groupInfo == null && (layer.layerInfo.getType() == PublishedType.VECTOR
            || layer.layerInfo.getType() == PublishedType.REMOTE);
    WebMarkupContainer wfsFormatsGroup = new WebMarkupContainer("wfs");
    RepeatingView wfsFormats = new RepeatingView("wfsFormats");
    if (vector) {
        for (int i = 0; i < wfsOutputFormats.size(); i++) {
            String wfsOutputFormat = wfsOutputFormats.get(i);
            String label = translateFormat("format.wfs.", wfsOutputFormat);
            // build option with text and value
            Label format = new Label(i + "", label);
            format.add(new AttributeModifier("value",
                    new Model<String>(ResponseUtils.urlEncode(wfsOutputFormat))));
            wfsFormats.add(format);
        }
    }
    wfsFormatsGroup.add(wfsFormats);
    wfsFormatsGroup.setVisible(CollectionUtils.isNotEmpty(wfsOutputFormats));
    menu.add(wfsFormatsGroup);

    // build the wms request, redirect to it in a new window, reset the selection
    String wmsUrl = "'" + layer.getWmsLink() + "&format=' + this.options[this.selectedIndex].value";
    String wfsUrl = "'" + layer.buildWfsLink() + getMaxFeatures()
            + "&outputFormat=' + this.options[this.selectedIndex].value";
    String choice = "(this.options[this.selectedIndex].parentNode.label == 'WMS') ? " + wmsUrl + " : " + wfsUrl;
    menu.add(new AttributeAppender("onchange",
            new Model<String>("window.open(" + choice + ");this.selectedIndex=0"), ";"));
    f.add(menu);
    return f;
}