Starting using OSLO, “M” Language, Oslo Repository and Intellipad






image

Microsoft “OSLO” is Microsoft’s next generation of Modeling Platform, Tools and DSLs.


OSLO is basically composed by:


- “M” Language (For Data Modeling and Textual DSLs )


- QUADRANT (Visual Tool for Visual Modeling)


- Oslo Repository (Based on SQL Server. IT is the Oslo’s data store, for meta-data and data itself)


You can actually research about Microsoft OSLO using the published “Oslo” SDK January 2009 CTP. This is the version I’m using for this post.


Download - Microsoft "Oslo" SDK - January 2009 CTP (Refresh)


http://www.microsoft.com/downloads/details.aspx?FamilyID=f2f4544c-626c-44a3-8866-b2a9fe078956&displaylang=en


What I’m going to do in this post, is to play a bit with INTELLIPAD, “M” Language and OSLO Repository, so we can see what it is about.


Keep in midn that this post is about “DATA MODELING with OSLO and M-Language”, but in the future, we could potencially model anything with OSLO (Web Services, Workflows, Deployments, custom specific domains, etc.)


So, Intellipad is a very special text editor that comes with OSLO SDK, but as you can suppose (because of its name), it is kind of “intelligent”, I mean, it is Oslo Textual DSL oriented and aware. 😉


So, Intellipad gives you support for directly writing in “M” Language. At the end of the day, Intellipad lets you write and execute any TEXTUAL-DSL you have installed over Intellipad.


I’m going to use Intellipad to write simple “M” Language arbitrary data and we’ll see how Intellipad translates to specific languages like TSQL, etc.


Steps to do:


1.- Open Intellipad. You’ll see it like that:


clip_image002


2.- Select “M Mode” as current Intellipad mode:


clip_image004


3.- We’re going to create kind of a ‘Software Catalog’ or Library. It could be a Library about books, songs or whatever, but I chose to do it about Software products, ok?.


So we start typing the following M-code that you can copy&paste:







module OsloDemos


{


SoftwareCatalog


{


{ProductName = "Windows 7", Company = "Microsoft", Rating = 3},


{ProductName = "Windows Vista", Company = "Microsoft", Rating = 3},


{ProductName = "Visual Studio 2010", Company = "Microsoft", Rating = 3}


}


}


You’ll see it like that:


clip_image006


Nice, it is very simple and intuitive as we’re focusing just on the data I’m handling, right?. M-code with Data and metadata can be stored in Oslo Repository, but before doing so, I’m going to show you how this M-Mode DSL understands that code. I mean, Intellipad can actually translate that code to T-SQL (SQL Sentences for schema and data)…


4.- It is very easy to generate that T-SQL code, just change M Mode to “Generic T-SQL Preview”:


clip_image008


Then, we have another pane, to the right, where M runtime has translated our simple data code to T-SQL:


clip_image010


As you can see, it generates SQL Sentences in order to create the table and then INSERT sentences in order to insert that data. It is interesting that it guesses the data schema types depending on actual data. For instance, nvarchar(max) for ProductName, etc.


5.- We can even specify constraints or restrictions. For instance, I want to specify that we have an entity type called ‘Product’, and that my data within SoftwareCatalog is based on that entity.


We type the following, after our actual M code:





SoftwareCatalog : Product*;


type Product


{


ProductName : Text;


Company: Text;


Rating: Integer32;


}


Therefore, we’re explicitly declaring what and how is our data type.


We can even set restrictions, like field length, etc, like the following:





SoftwareCatalog : Product*;


type Product


{


ProductName : Text where value.Count <= 128;


Company: Text where value.Count <= 128;


Rating: Integer32;


}


You can check that it is changing the generated T-SQL, on the right side:


clip_image012


6.- Next step I want to show is “Compiling M-code”, so we can afterwards execute it and get that schema and definitions into OSLO Repository. J


So first of all, let’s save our M-code to a file, called “SoftwareCatalog.m”


And now, let’s compile it.


Open a Command-Prompt for Oslo Tools, and type the following:





m.exe SoftwareCatalog.m /p:image


You’ll see it like the following:


clip_image014


This tool (m.exe) compiles “M” code and generates an image file. In this case: “SoftwareCatalog.mx”.


7.- Next step is to deploy that compiled image file into the OSLO REPOSITORY (into SQL Server), using the mx.exe tool. Type the following:





mx.exe –i:SoftwareCatalog.mx –d Repository


After that, you’ll be able to see that data in the OSLO Repository, I mean, in the SQL Server database called “Repository” (when installing OSLO SDK you provided a specific SQL Server or SQL Express Server) and now we have a table called “OsloDemos. SoftwareCatalog”, where we can check even the model’s data:


clip_image016


8.- Of course, we’ve been doing this in a kind of low level way (TEXTUAL DSL called M Language, Intellipad and Command-line Tools), but you could do it also in a VISUAL way, using QUADRANT.


At this moment, we could also Access our data model in Oslo Repository using QUADRANT. Just DRAG & DROP “Quadrant—>Explorer-->Browse All --> OsloDemos. SoftwareCatalog” into the Quadrant’s design Surface. J



FINAL CONCLUSIONS


IMPORTANT:


Keep in midn that in this example we’ve been using Oslo, “M” Language and Intellipad to model data and data’s schema, BUT, this is just one way you can use OSLO. In fact, in the future we’ll be using OSLO for many more things like:


- Modeling a Web Service (WCF Services, etc.)


- Modeling Restful Clients (like using MUrl)


- Modeling WF Workflows


- Modeling Web Apps (ASP.NET)


- “Modeling your Specific Doman, whatever you want!”


- Etc.


So, in this post we’ve been using plain “M” Language for modeling data, but, it is just one of the possibilities!! 🙂

Comments (3)

  1. I wrote a post about Oslo and “M” Language and how you can use it to model data. But in that case, we

  2. I wrote a post about Oslo and “M” Language and how you can use it to model data. But in that case, we

  3. I wrote a post about Oslo and “M” Language and how you can use it to model data. But in that case, we

Skip to main content