MPS Language for modelling remote database data

Is there any way to design a language that maps model directly onto existing remote database?

I want be able to perform actions (intentions?) that would read/insert/update/delete remote data (using java classes to access database). This also means that I should be able to update model from remote database (again, metadata could be read using my java classes).

Is it possible now in MPS?
8 comments
This would be possible using custom persistence.  Look at the docs here.  Be aware that there have been extensive changes to custom persistence in 3.0, so some reworking will be needed when that becomes available.

Could you explain your use case some more?  I'm working on a custom persistence solution for another use case (proprietary, unfortunately, so I can't share it), so I might be able to make some suggestions if I know more about what exactly you are trying to do.
0
We currently set up to use MPS to create new version of our software, and I'm in process of evaluating MPS's can-do's.

Here I mean an use case when system admin changes database structure via MPS, so we could store db structure in our language model on the one hand and have an actual database with the same structure on the another. To do the actual changes in database MPS is supposed to use our custom classes.
So in this case, I think, it is an addition to standard MPS storage, not a replacement.
0
Ok, I think I understand.  You want to have a DSL representing your data model, and when the structure of the model changes, you want to update the database using your own class library and I assume probably generate some other stuff for use on the client side (data transfer objects, etc.).  Is that it?

There are a lot of ways I can think of to do that, depending on how immediate you want the update to be.  An easy way would be either a custom action (added to one of the menus) or a make facet that calls your custom classes to update the database.  If you need immediate synchronization, that would be a little more difficult - intentions would probably work there.  Custom persistence would probably NOT be a good choice, since you probably only want to make the calls to update the database if the model is in a consistent state.

Are you using a traditional relational db or a document-oriented "nosql" db like MongoDB?  I ask because if you are using a relational db, I could see real problems with doing the schema updates on the fly without updating the client code to reflect the changes, whereas for many of the non-relational dbs that are popular now that wouldn't always be an issue.
0
Thanks for your answer. Now, after you mentioned it, I can see problems if I use rdbms.
In current version of our software we use Oracle DB, but now I think of possibility to move to NoSQL, so, as you wrote, it still will be possible to have instant updates of db schema while editing a model.

Is it possible to import custom classes as a model and use them in actions/intentions?
0
Yes it is.

  1. Module Properties of your language -> Design Time -> Libraries -> Add the jar containing your custom classes.
  2. In your intention/action press Ctrl+R (Import model that contains root) to import the classes.
0
Thanks!

And another question - is it possible to use smodel in custom classes?
0
You can use smodel as part of a solution, but AFAIK you can't use mps languages on their own outside of mps (full version or your own customized distribution) or IntelliJ with the mps plugins.

Keep in mind that mps is a language workbench, and is meant to be used primarily at analysis and development time.  The usual approach is to then generate the code for your application. I suppose it is possible to incorporate it into your runtime solution, using the IDEA platform as a base, but that is not a trivial task in most cases.  For the record, I've never dug into the IDEA platform that way, so I don't know first hand what is involved.  I have done a lot of Eclipse RCP development however, and that is IMO a better documented platform with a much bigger ecosystem, yet still presents quite a few challenges when developing a non-trivial app.  

My personal opinion is to use each platform for what it's intended for, and you'll save yourself a lot of headaches.  If you need to use the tools as part of your runtime solution, a better choice might be Eclipse EMF and Xtext.  EMF is rather unique in how it blurs the line between the tool side and the runtime.  The cost of this flexibility is that EMF is more limited, and there are things you can do with MPS that are either very difficult or just impossible with EMF.

That's just my observation, and if I'm wrong then anyone, feel free to correct me.
0
Ok, I think I got the idea. Using smodel outside MPS is useless until I have a way to restore an MPS model in my app (and even then I have nothing to do with it). And if I want my custom logic to be used inside MPS, there is no use to put it into library/stubs as I can always import any language into another.
0

Please sign in to leave a comment.