Skip to content

Feature/new fields query parameter #2

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

Closed
wants to merge 4 commits into from
Closed

Feature/new fields query parameter #2

wants to merge 4 commits into from

Conversation

SpeckiJ
Copy link

@SpeckiJ SpeckiJ commented Jul 24, 2017

Low-Level implementation of 52North/sensorweb-server-helgoland#169.

Elements are only added to the OutputObject if they are requested (or field parameter is missing).

Also contains smaller mvn checkstyle improvements.

TODO: Documentation (if low-level approach is approved)

@SpeckiJ
Copy link
Author

SpeckiJ commented Jul 24, 2017

Requires ridoo/series-rest-api#19

@ridoo
Copy link
Owner

ridoo commented Aug 14, 2017

@SpeckiJ could you go for a more streamlined version? Have a look at shutgun surgery to understand why.

What about adding

protected AbstractOutput(IoParameters parameters) {
    this.parameters = parameters;
}

protected boolean isSelectedOutput(String field) {
  return parameters == null || parameters.getFields().contains(field);
}

Not sure if a DbQuery.getParameters() is available wherever an AbstractOutput is created. However, It is worth to check, if you can easily make it available then. The aim is to reuse parameters within the output setters to decide to return null or the actual value (in case it has been requested by the client). For example:

public void setHref(String href) {
    this.href = isSelectedOutput(HREF) // HREF to be added
            ? href
            : null;
}

For sure this would require to adjust each setter. But there are advantages:

  1. It keeps selection within the actual POJOs (rather than business classes of different types)
  2. It is separated from SPI implementation
  3. As output selection is done within setter pattern it can be handled (and even more separated) later via AOP pointcuts

If you have further questions on this, please let me know.

@SpeckiJ SpeckiJ closed this Aug 18, 2017
@SpeckiJ SpeckiJ deleted the feature/new-fields-query-parameter branch September 26, 2017 16:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants