Conditional statement in HOCON configuration files - scala

I need to write a production.conf file for my play framework and scala application.
I have few requirements like
if <some_condition>, then username = <something_from_env>
else username = <something_else_from_env>.
I am currently using jinja2 template, which support this kind of statements. Is there a way to do the same with Play in hocon format?

Related

How can I decrypt the Triplestore files of an RDF4J database?

I am currently trying to read the files of an RDF4J triplestore from the universAAL platform and put them into an InfluxDB to merge the data from different smart living systems.
However, I have noticed that the individual index files of the Native repository are encrypted/unreadable (See image below).
Is there any experience from the community on how to get human readable content out of the RDF4J files (namespace, triples.prop, triples-cosp, triples-posc, triples-spoc, values.hash, values.dat, values.id) and merge them into another database?
The documentation of RDF4J did not help me here, so I could not create a decent export.
Encrypted File from Triplestore
The files are not encrypted, they're simply a binary format, optimized for efficient storage and retrieval, used by RDF4J's Native Store database implementation. They're not meant for direct manipulation.
The easiest way to convert them to readable RDF is to spin up a Native Store on top of them and then use the RDF4J API to query/export its data. Assuming you have a complete set of data files it should be as simple as something like this:
Repository rep = new SailRepository(new NativeStore(new File("/path/to/datafiles/");
try(RepositoryConnection conn = rep.getConnection()) {
conn.export(Rio.createWriter(RDFFormat.TURTLE, System.out));
}
finally {
rep.shutDown();
}
Obviously, replace System.out with a FileOutputstream if you want to write the data to file rather than the console. And change RDFFormat.TURTLE to something else if you want a different syntax format.

How to include application version number in HTML documentation genertated by Spring Rest Docs?

I would like to include application version number (version from build.gradle).
I see no way to pass some custom variables to ascidoc and use them in generated documentation. Is it possible?
Passing custom variables from gradle can be done using
asciidoctor {
attributes "build=${build}"
}
Then defined attribute may be refered in adoc file as {build}

Xml FIle generation using Rythm Template Engine

I am trying to generate an xml file using rythm template and wondering if there is a way to drop few tags based on business logic.
Eg: Discard #error_message tag in case of a successful method execution.
Please help!.
Use #if directive:
#ifNot(success) {
#error_message()
}

Reading values from a file txt or xml

I'm developing a simple bpel process that takes data from an external file (txt or xml).
In detail, i'm trying to develop a process that takes in input 2 strings (user and pass) and checks if they are in my "Account" file. If so, output return 'true', if not 'false'.
I'm using eclipse and i can't find anything that could help me. I read something about 'file adapter', but, in eclipse, palette view doesn't show this option. Any idea ?
There are two possibilities:
If your BPEL engine supports XPath 2.0, you can use the doc() function to load an XML document and look for certain entries.
doc("users.xml")/users/user[#id = $uid and #password = $password]
should return the user node where id and password attributes match the values stored in the BPEL variables $id and $password. You can place that expression in an if activity.
If your engine does not support XPath 2.0 and you need to stick to standard BPEL, you should write a simple Web service that performs the lookup. Use an invoke activity to call this Web service.

What is the best file parsing solution for converting files?

I am looking for the best solution for custom file parsing for our enterprise import routines. I want to basically change one file format into a standard file format and have one routine that imports that data into the database. I need to be able to create custom scripts for each client since its difficult to get the customer to comply with a standard or template format. I have looked at PowerShell and Iron Python to do this so far but I am not sure this is the route I want to go. I have also looked at some tools such as Talend which is a drag and drop style tool which may or may not give me what I want as far as flexibility. We are a .NET shop and have created custom code to do this in the past but I need something that is quicker to create then coding custom parsing functions each time we get a new file format in.
Depending on the complexity and variability of your work, you should consider an ETL tool like SSIS (SQL Server Integration Services).
Python is wonderful for this kind of thing. That's why we use. Each new customer transfer is a new adventure and Python gives us the flexibility to respond quickly.
Edit. All python scripts that read files are "custom file parsers". Without an actual example, it's not sensible to provide a detailed example.
with open( "some file", "r" ) as source:
for line in source:
process( line )
That's about all there is to a "custom file parser". If you're parsing .csv or .xml files, then Python has modules for that. If you're parsing fixed-format files, you'd use string slicing operations. If you're parsing other files (X12? JSON? YAML?) you'll need appropriate parsers.
Tab-Delim.
from collections import namedtuple
RecordLayout = namedtuple('RecordLayout',['field1','field2','field3',...])
def process( aLine ):
record = RecordLayout( aLine.split('\t') )
...
Fixed Layout.
from collections import namedtuple
RecordLayout = namedtuple('RecordLayout',['field1','field2','field3',...])
def process( aLine ):
fields = ( aLine[:10], aLine[10:20], aLine[20:30], ... )
record = RecordLayout( fields )
...