Add Confound support for the TURF file format.

Description

Confound in v0.6.0 is getting support for pluggable file formats. Look at the config-file-format-properties and config-file-format-properties-provider subprojects to see how this works. Basically you just need to implement ConfigurationFileFormat for the file format itself, and then provide a META-INF/services/io.confound.config.file.ConfigurationFileFormat file to point to the file format implementation class.

Confound needs to support the TURF file format, either in v0.6.0 or v0.7.0. TURF support is very, very new, but is available in the urf/turf subproject. Compared to the SURF parser, the TURF parser is much more flexible, being able to parse URF statements to a variety of formats, but (as you can see in TurfParserSurfTest) you can parse TURF into a graph similar to the SURF graph (except that it will use e.g. UrfObject instead of SurfObject) using something like this:

This is a very early version of the parser, so let me know if you run into any bugs.

Here is an outline of what needs to be done to complete this task:

  • Create a confound/config-file-format-turf subproject.

  • Create a TurfConfiguration class that extends AbstractObjectConfiguration. You'll pass it the parsed object graph. Override findParameterImpl(@Nonnull final String key) to return whatever object it looks up in the graph. Everything else (conversion, etc.) is/should be/will be taken care of. The key should be considered hierarchical like the Apache Commons Configuration stuff. In other words, example.foo.bar would start at the root; find an example property if the root is a resource description; then if that value is a map look up the foo key, and if that value is a resource find the bar property, etc.

  • Create a TurfConfigurationFileFormat class that supports the .turf extension, uses the TURF parser to parser the file, and stores the graph in the TurfConfiguration.

  • Create a confound/config-file-format-turf-provider subproject. (These will be two separate subprojects as before, so that people can use the file format without necessarily including it as a Csar provider to automatically support that format.)

  • Add a META-INF//services/io.confound.config.file.ConfigurationFileFormat indicating the TurfConfigurationFileFormat class.

Environment

None

Activity

Show:
Garret Wilson
October 14, 2018, 11:23 PM

Perhaps the trickiest part of all this is implementing findParameterImpl(@Nonnull final String key) to be hierarchical. Eventually we may have a class to help with that, but in the meantime you can just code some specific logic for it. You could do this iteratively within the method, but I might instead create a separate recursive method findParameterImpl(Object object, List<String> keyComponents), which looks at the remaining key components and calls itself with the next level down (using a sublist to discard the next key component) until you are out of key components, at which case you would return the object you found. (Again, maybe we can make some more general algorithm later.) Then the main findParameterImpl(@Nonnull final String key) method would just split the key on . and pass the root object and the list to the other, recursive method.

Magno Nascimento
October 17, 2018, 10:03 AM
Edited

, I'm having trouble to install TURF project because of a JUnit test failing:

testHandleToTag:

This test is in urf-spec, one of the dependencies of urf-turf. Did you change it recently?

Garret Wilson
October 17, 2018, 2:51 PM

The initial TURF parser only supports the SURF syntax subset for now, but I didn't realize a test was failing. It's probably best if I look into it. I'll assign this task, and I've assigned you instead.

Garret Wilson
October 18, 2018, 4:13 PM

Interesting. Well of course Handle.toTag() wouldn't work; it has a comment that says so:

I think what happened is that when I finally got the first TURF parsing to work, I was tired and just relieved to get it working that I left it and forgot that I hadn't tidied up all the tests. Sorry to send you something that wasn't working, .

Anyway, I'll take care of this. I'm excited to get back to it.

Garret Wilson
October 21, 2018, 9:52 PM

I'm reopening this to add support for hierarchical keys.

Fixed

Assignee

Garret Wilson

Reporter

Garret Wilson

Labels

None

Fix versions

Due date

2018/10/22

Priority

Critical
Configure