Almost all systems has the need to export and import data. Since it is always very easy to hack something up that does the job – the solution is often to hack something up that does the job – and thus increase the entropy of your system. Not good in the long run.
The BoringPredictableServer has a declarative way to explain what you export and import at the modeling level so that you always are fully documented and never lose grip of what you have.
This solution – as so many others we have in borpred – make use of the ViewModels. Since the ViewModel constitutes a declarative way to transform your model it is very well suited for the job to explain the transformations from your model to a export file, and from an import file to your model.
Excel is a well known and easy to work with – so we assume your files will be in or transformable to Excel.
Defining a model to hold some data and a ViewModel that use some of that data.
I also define a small UI-ViewModel so that we enter some test data:
I tell BorPred to execute this model in slot A0:
I start WECPOF to enter some data:
I Visit the BorPredServer:
I export allinstances of the specific class in the specific format defined by the viewmodel:
I get the result as an open document spreadsheet:
I change the data a little:
I save this as Text – tab-separated , an then go back to borpredserver:
I point out the ViewModel to use when importing and also the file to use:
I then hit Refresh in the WECPOF app to view the imported data:
If I would like to update existing objects instead of creating new ones I need to supply the attribute we will use as key and make sure that this is the first column in the import file. Like this:
The excel import and export can be accessed as webservices thru the borpredserver:
So this was another little boring and predictable function that we added to BorPred. You should switch your EcoPersistenceServer to BorPred now – you might not jump with joy because of the switch but you remove a lot of boring and predictable tasks that you would otherwise need to spend time on.