geocollections / geokogud

Geocollections of Estonia
http://geocollections.arendus.geokogud.info/
GNU Affero General Public License v3.0
4 stars 2 forks source link

Automate DTO generation #84

Closed Kotodevochka closed 7 years ago

Kotodevochka commented 7 years ago

As a java developer, I do not want to write a lot of boilerplate code, I want to just generate POJO classes (.java sources) from the existing API.

AC:

  1. DTOs are generated from the list of provided tables fields on API homepage https://api.arendus.geokogud.info/.
  2. Generation can be run from gradle as a task
Kotodevochka commented 7 years ago

Probably not worth doing it, requires same amount of effort, as manual migration of all existing DTOs to new structure.

Kotodevochka commented 7 years ago

Planned for iteration 3 I'll use https://github.com/forge/roaster library to generate necessary POJOs

Kotodevochka commented 7 years ago

The task is kind of finished, but the solution itself is very fragile:

  1. It depends on HTML structure https://api.arendus.geokogud.info/ since it fetches available fields for each table. As a fallback mechanism it is also possible to get tables with fields from appropriate .txt files in /resources folder, but developer should manually put there these files with fields list for each table.
  2. Naming conventions in API are not always followed (for example drillcore_image table and drillcoreimage field in other table) => this solution fails to properly handle it.
  3. Some fields can be Java keywords.

As an alternative there was a proposal from Olesja just to return Map<String, String> from the server and not to have any at all POJO files, since they are not really needed (anyway they are not used on the server) => will be implemented this way in the future.

Nevertheless, solution has been committed, but will soon be probably deleted as not used...