Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#1945 Make FeatureGrid attributes visibility selector counted when user exports grid data #7845

Conversation

alexander-fedorenko
Copy link
Contributor

Description

This PR suggests changes needed to make FeatureGrid attributes visibility selector counted when user exports grid data.

Please check if the PR fulfills these requirements

What kind of change does this PR introduce? (check one with "x", remove the others)

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Other... Please describe:

Issue

What is the current behavior?

#1945

What is the new behavior?
WFS export will properly use list of hidden attributes to load data only for visible columns.

Breaking change

Does this PR introduce a breaking change? (check one with "x", remove the other)

  • Yes, and I documented them in migration notes
  • No

Other useful information

- Keep geometry in exported file when custom propertyName value is passed to the request.
@alexander-fedorenko alexander-fedorenko force-pushed the 1945-property_selection_featuregrid_export branch from 15d00e5 to 14e9bd4 Compare February 8, 2022 22:05
@tdipisa tdipisa added tmp and removed tmp labels Feb 11, 2022
…m attributes list is passed to the action.

New observables to use for custom attributes list.
@alexander-fedorenko
Copy link
Contributor Author

Right now this feature is blocked by the limitation on GeoServer side. There are two WPS processes that can be used to achieve desired workflow when resulting layer data is filtered in a way that part of the attributes are removed from the output: "gs:Query" and "vec:Query". Both of them doing same things but first one is marked as deprecated.

"vec:Query" has following description: "Queries a feature collection using an optional filter and an optional list of attributes to include. Can also be used to convert feature collection format." The issue is that it doesn't accept list of attributes in any possible format.

  • Comma-separated list results into exception on process execution:

Process failed during execution java.lang.NullPointerException: PropertyDescriptor is null - did you request a property that does not exist? PropertyDescriptor is null - did you request a property that does not exist?

image

  • Passing each attribute name in a separate wps:Input tag makes process finish successfully, but in such case it take only one last attribute passed with the wps:Input tag. Resulting file contains only one attribute in this case.
...
    <wps:Input>
      <ows:Identifier>attribute</ows:Identifier>
      <wps:Data>
        <wps:LiteralData>STATE_ABBR</wps:LiteralData>
      </wps:Data>
    </wps:Input>
    <wps:Input>
      <ows:Identifier>attribute</ows:Identifier>
      <wps:Data>
        <wps:LiteralData>LAND_KM</wps:LiteralData>
      </wps:Data>
    </wps:Input>
...

@tdipisa
Copy link
Member

tdipisa commented Feb 14, 2022

@taba90 Can we have some assistance from you on this?

@tdipisa tdipisa requested a review from MV88 February 22, 2022 11:49
@MV88
Copy link
Contributor

MV88 commented Feb 24, 2022

@tdipisa i think @offtherailz is a more suitable person to review this
let me know your thoughts

@tdipisa
Copy link
Member

tdipisa commented Feb 25, 2022

@tdipisa i think @offtherailz is a more suitable person to review this let me know your thoughts

@MV88 this is in blocked for now, but ok.

@tdipisa tdipisa requested review from offtherailz and removed request for MV88 February 25, 2022 14:24
@offtherailz
Copy link
Member

offtherailz commented Feb 25, 2022

I did a few attempts and I guessed that the correct format for multi-attributes is this:

<?xml version="1.0" encoding="UTF-8"?><wps:Execute version="1.0.0" service="WPS" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.opengis.net/wps/1.0.0" xmlns:wfs="http://www.opengis.net/wfs" xmlns:wps="http://www.opengis.net/wps/1.0.0" xmlns:ows="http://www.opengis.net/ows/1.1" xmlns:gml="http://www.opengis.net/gml" xmlns:ogc="http://www.opengis.net/ogc" xmlns:wcs="http://www.opengis.net/wcs/1.1.1" xmlns:xlink="http://www.w3.org/1999/xlink" xsi:schemaLocation="http://www.opengis.net/wps/1.0.0 http://schemas.opengis.net/wps/1.0.0/wpsAll.xsd">
  <ows:Identifier>vec:Query</ows:Identifier>
  <wps:DataInputs>
    <wps:Input>
      <ows:Identifier>features</ows:Identifier>
      <wps:Reference mimeType="text/xml" xlink:href="http://geoserver/wfs" method="POST">
        <wps:Body>
          <wfs:GetFeature service="WFS" version="1.0.0" outputFormat="GML2" xmlns:gs="https://gs-stable.geo-solutions.it/geoserver/geoserver">
            <wfs:Query typeName="gs:us_states"/>
          </wfs:GetFeature>
        </wps:Body>
      </wps:Reference>
    </wps:Input>
    <wps:Input>
      <ows:Identifier>attribute</ows:Identifier>
      <wps:Data>
        <wps:LiteralData>STATE_NAME</wps:LiteralData>
      </wps:Data>
    </wps:Input>
    <wps:Input>
      <ows:Identifier>attribute</ows:Identifier>
      <wps:Data>
        <wps:LiteralData>STATE_FIPS</wps:LiteralData>
      </wps:Data>
    </wps:Input>
    <wps:Input>
      <ows:Identifier>attribute</ows:Identifier>
      <wps:Data>
        <wps:LiteralData>WATER_KM</wps:LiteralData>
      </wps:Data>
    </wps:Input>
    <wps:Input>
      <ows:Identifier>attribute</ows:Identifier>
      <wps:Data>
        <wps:LiteralData>the_geom</wps:LiteralData>
      </wps:Data>
    </wps:Input>
  </wps:DataInputs>
  <wps:ResponseForm>
    <wps:RawDataOutput mimeType="text/xml; subtype=wfs-collection/1.0">
      <ows:Identifier>result</ows:Identifier>
    </wps:RawDataOutput>
  </wps:ResponseForm>
</wps:Execute>

In this case I receive (with default format).

 <gml:featureMember>
        <feature:us_states fid="us_states.1">
            <feature:STATE_NAME>Illinois</feature:STATE_NAME>
            <feature:STATE_FIPS>17</feature:STATE_FIPS>
            <feature:WATER_KM>1993.335</feature:WATER_KM>
<!-- geometry, not included because is too big, but it was present too -->
        </feature:us_states>
    </gml:featureMember>

This is the CURL you can use for test:

curl --location --request POST 'http://gs-stable.geo-solutions.it/geoserver/wfs' \
--header 'Content-Type: application/xml' \
--data-raw '<?xml version="1.0" encoding="UTF-8"?><wps:Execute version="1.0.0" service="WPS" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.opengis.net/wps/1.0.0" xmlns:wfs="http://www.opengis.net/wfs" xmlns:wps="http://www.opengis.net/wps/1.0.0" xmlns:ows="http://www.opengis.net/ows/1.1" xmlns:gml="http://www.opengis.net/gml" xmlns:ogc="http://www.opengis.net/ogc" xmlns:wcs="http://www.opengis.net/wcs/1.1.1" xmlns:xlink="http://www.w3.org/1999/xlink" xsi:schemaLocation="http://www.opengis.net/wps/1.0.0 http://schemas.opengis.net/wps/1.0.0/wpsAll.xsd">
  <ows:Identifier>vec:Query</ows:Identifier>
  <wps:DataInputs>
    <wps:Input>
      <ows:Identifier>features</ows:Identifier>
      <wps:Reference mimeType="text/xml" xlink:href="http://geoserver/wfs" method="POST">
        <wps:Body>
          <wfs:GetFeature service="WFS" version="1.0.0" outputFormat="GML2" xmlns:gs="https://gs-stable.geo-solutions.it/geoserver/geoserver">
            <wfs:Query typeName="gs:us_states"/>
          </wfs:GetFeature>
        </wps:Body>
      </wps:Reference>
    </wps:Input>
    <wps:Input>
      <ows:Identifier>attribute</ows:Identifier>
      <wps:Data>
        <wps:LiteralData>STATE_NAME</wps:LiteralData>
      </wps:Data>
    </wps:Input>
    <wps:Input>
      <ows:Identifier>attribute</ows:Identifier>
      <wps:Data>
        <wps:LiteralData>STATE_FIPS</wps:LiteralData>
      </wps:Data>
    </wps:Input>
    <wps:Input>
      <ows:Identifier>attribute</ows:Identifier>
      <wps:Data>
        <wps:LiteralData>WATER_KM</wps:LiteralData>
      </wps:Data>
    </wps:Input>
    <wps:Input>
      <ows:Identifier>attribute</ows:Identifier>
      <wps:Data>
        <wps:LiteralData>the_geom</wps:LiteralData>
      </wps:Data>
    </wps:Input>
  </wps:DataInputs>
  <wps:ResponseForm>
    <wps:RawDataOutput mimeType="text/xml; subtype=wfs-collection/1.0">
      <ows:Identifier>result</ows:Identifier>
    </wps:RawDataOutput>
  </wps:ResponseForm>
</wps:Execute>'

The result you said @alexander-fedorenko is probably the result of my first attempt, passing attributes this way

<wps:Data>
        <wps:LiteralData>STATE_NAME</wps:LiteralData>
        <wps:LiteralData>STATE_FIPS</wps:LiteralData>
      </wps:Data>
    </wps:Input> 

In this case I was receiving only STATE_FIPS.

Correct me if I'm wrong.

It doesn't seems to be possible to create this request in demo -> WPS request builder, I'm guessing this is a limitation or a bug of the current builder. Maybe @aaime knows more about it. Not sure.

Anyway generating the request like this should work.

@offtherailz
Copy link
Member

I should put this PR in draft, because it is not ready to be delivered, as far as I understood (and because it is blocked)

@offtherailz offtherailz marked this pull request as draft February 25, 2022 15:35
@offtherailz
Copy link
Member

offtherailz commented Feb 25, 2022 via email

@alexander-fedorenko
Copy link
Contributor Author

@offtherailz Thanks for reviewing.
You're right, your request (as well as mine in the last sample of the code) is correct.
The problem was in usage of geoJson format in the intermediate gs:Download process. In this case output is a FeatureCollection, coordinates are not the part of attributes list anymore, so vec:Query process cannot get them from the passed list and they are always ignored. I changed intermediate format to WFS collection and it works flawlessly. Please review :)

@offtherailz
Copy link
Member

offtherailz commented Feb 25, 2022

I tested it and I think that we should do it better. Download process has been created to manage big sets of data. With this solution I think you are downloading the data, then resending them to the service.
image

This is not optimal and for big data sets can be problematic. Anyway I think there is a way to optimize
by using process chaining.
I never used it but I think it can be the solution. Downloading and re-uploading the features to implement this features is not doable for the kind of dataset we need to manage with this tool.
I don't know if you can pass attributes directly in the first request or if you have to use chaining. I didn't studied the WPS Download process yet.
Take a look if you can find a solution without getting and sending the features to the process. If you need help, please ask

@alexander-fedorenko
Copy link
Contributor Author

alexander-fedorenko commented Feb 25, 2022

Switched vec:Query process to use process reference as an input instead of the WMS collection.
Chain will work in the following mode:
gs:DownloadEstimator -> result -> gs:Download -> reference -> vec:Query -> reference. Result can be downloaded by user on demand via widget.
@offtherailz

@alexander-fedorenko alexander-fedorenko marked this pull request as ready for review February 25, 2022 20:15
@alexander-fedorenko alexander-fedorenko changed the title #1945 Make FeatureGrid attributes visibility selector counted when user exports grid data [WIP] #1945 Make FeatureGrid attributes visibility selector counted when user exports grid data Feb 25, 2022
@tdipisa tdipisa removed the Blocked label Feb 28, 2022
@tdipisa tdipisa removed this from the 2022.01.00 milestone Mar 4, 2022
@tdipisa tdipisa added BackportNeeded Commits provided for an issue need to be backported to the milestone's stable branch Blocked labels Mar 7, 2022
@tdipisa tdipisa removed the Blocked label Mar 18, 2022
@tdipisa tdipisa requested review from MV88 and removed request for offtherailz March 28, 2022 14:58
Copy link
Contributor

@MV88 MV88 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please check a few comments

testing this locally with no wps (direct download it works)

web/client/epics/layerdownload.js Outdated Show resolved Hide resolved
web/client/selectors/featuregrid.js Outdated Show resolved Hide resolved
* @param {object} customAttributesSettings object containing information about deactivated attributes, see getCustomAttributesSettings
* @returns undefined|array
*/
export const getAttributesList = (attributes, customAttributesSettings) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can this be unit tested?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added test with different scenarios.

Added unit test for "getAttributesList" function
@alexander-fedorenko alexander-fedorenko requested a review from MV88 April 6, 2022 21:55
@alexander-fedorenko
Copy link
Contributor Author

alexander-fedorenko commented Apr 6, 2022

Please skip this problem with readthedocs, I just don't want to merge master back to this branch cause I'm not sure it won't mess up with the changelog of PR. This issue was fixed on master afaik by you @MV88
Please re-review and let me know if the problem with locale availability is still occurs for that tooltip.

@MV88 MV88 merged commit f62a9f3 into geosolutions-it:master Apr 7, 2022
@MV88
Copy link
Contributor

MV88 commented Apr 7, 2022

@ElenaGallo please test DEV

@ElenaGallo
Copy link
Contributor

@alexander-fedorenko sometime it is not possible to download data, in any format and it always happens if I select the attributes I want to export. See the gif attached:

download.mov
download2.mov

@tdipisa
Copy link
Member

tdipisa commented Apr 20, 2022

@alexander-fedorenko @ElenaGallo we are too close to the release, therefore I'm going move to the next one (2022.01.02).

@alexander-fedorenko
Copy link
Contributor Author

@ElenaGallo I tried to reproduce problems you had, unfortunately I was not able to do so. As per the screencasts you've shared it really looks like there was some problem with GeoServer running process on any step during file generation. It didn't return meaningful error message in your case, so the only way to trace the error is to reproduce error one more time and check GeoServer logs, or catch a period when problem appears and debug it locally with configured proxy to the dev instance of GeoServer.

@ElenaGallo
Copy link
Contributor

Hi @alexander-fedorenko, this issue has been fixed here so I move this pr to test.

@tdipisa
Copy link
Member

tdipisa commented May 25, 2022

@ElenaGallo let us know if we can backport to 2022.01.xx.

@ElenaGallo
Copy link
Contributor

Test passed, @alexander-fedorenko please backport to 2022.01.xx. Thanks

alexander-fedorenko added a commit to alexander-fedorenko/MapStore2 that referenced this pull request May 26, 2022
…counted when user exports grid data (geosolutions-it#7845)

* geosolutions-it#1945 FeatureGrid layer data export will exclude hidden attributes.

* Added tooltips in few places

* - Keep attributes list undefined if no attribute is excluded.
- Keep geometry in exported file when custom propertyName value is passed to the request.

* Update for WPS export: using custom flow if layer is vector and custom attributes list is passed to the action.

New observables to use for custom attributes list.

* Minor changes required to make geometry properly exported when it's included into attributes list.

* Using process reference to get results of gs:Download as an input for vec:Query

* Minor corrections: selector name, variable name
Added unit test for "getAttributesList" function

(cherry picked from commit f62a9f3)
@alexander-fedorenko alexander-fedorenko removed the BackportNeeded Commits provided for an issue need to be backported to the milestone's stable branch label May 26, 2022
tdipisa pushed a commit that referenced this pull request May 26, 2022
…er exports grid data (#7845) (#8232)

* #1945 FeatureGrid layer data export will exclude hidden attributes.

* Added tooltips in few places

* - Keep attributes list undefined if no attribute is excluded.
- Keep geometry in exported file when custom propertyName value is passed to the request.

* Update for WPS export: using custom flow if layer is vector and custom attributes list is passed to the action.

New observables to use for custom attributes list.

* Minor changes required to make geometry properly exported when it's included into attributes list.

* Using process reference to get results of gs:Download as an input for vec:Query

* Minor corrections: selector name, variable name
Added unit test for "getAttributesList" function

(cherry picked from commit f62a9f3)
@MV88 MV88 added this to the v2022.01.02 milestone Jun 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants