Querying VantagePoint EMI model items by type name using IronRuby

by Klaus Graefensteiner 8. September 2010 22:41

Hello IronRuby

I am currently reading the Pickaxe book to get up to speed with Ruby 1.9. Ruby doesn’t have a convincing Microsoft .NET integration story, but fortunately there is a Ruby language implementation in .NET called IronRuby. In this blog post I demonstrate how to integrate IronRuby with the VantagePoint EMI .NET API.

IronRuby = Ruby + .NET (DLR).

This is a very powerful combination. IronRuby runs on Silverlight and on the Windows 7 phone OS!

Querying Model Items of a certain ItemType with IronRuby

ManagerTypeRepository

Figure 1: Getting all item instances of type Core.Template.Report

Of course all techniques described in this blog post still apply. Use .NET Reflector to discover and experiment with the VantagePoint API. One of the .NET types that provides most of the item specific attributes is the ItemInfo object.

ItemInfoInReflector

Figure 2: ItemInfo object

IronRuby Script

Here is the IronRuby script that queries Report Template items and prints them out.

load_assembly "Dataworks.MI.Core"
load_assembly "Dataworks.MI.Core.Client"

DataWorks::MI::Core.class
DataWorks::MI::Core::Client::Globals.Version
DataWorks::MI::Core::Client::Globals.Initialize

itemsQuery = DataWorks::MI::Core::Query::ItemsQuery.new

itemType = DataWorks::MI::Core::TypeRepository.Instance.ItemTypes["Core.Template.Report"]

itemTypeFilter = DataWorks::MI::Core::Query::ItemTypeFilter.new(itemType)

itemsQuery.ItemTypeFilter = itemTypeFilter

reportItems = DataWorks::MI::Core::Query::QueryProvider.Instance.QueryItems(itemsQuery)

reportItems.each { |reportItem| puts "#{reportItem.name}" }

reportItems.each { |reportItem| puts "#{reportItem.FullyQualifiedName}" }

Helpful tip for loading the right assemblies

IronRuby provides the ability to load strongly typed assemblies from the Global Assembly Cache (GAC). To get these strongly typed names you can use the gacutil /l to list the assemblies in the GAC and copy and past the strong names of the assemblies that you are trying to load with IronRuby.

Download

The IronRuby script can be downloaded here: QueryReportTemplateItemsToCreatePageWithReportLinks.zip

Ausblick

IronRuby is still in the early stages, but it will be my favorite Ruby implementation on the Windows Platform. No doubt about it!

Tags: , , ,

IronRuby | VantagePoint | EMI | Ruby

About Klaus Graefensteiner

I like the programming of machines.

Add to Google Reader or Homepage

LinkedIn FacebookTwitter View Klaus Graefensteiner's profile on Technorati
Klaus Graefensteiner

Klaus Graefensteiner
works as Developer In Test and is founder of the PowerShell Unit Testing Framework PSUnit. More...

Open Source Projects

PSUnit is a Unit Testing framwork for PowerShell. It is designed for simplicity and hosted by Codeplex.
BlogShell is The tool for lazy developers who like to automate the composition of blog content during the writing of a blog post. It is hosted by CodePlex.

Administration

About

Powered by:
BlogEngine.Net
Version: 1.6.1.0

License:
Creative Commons License

Copyright:
© Copyright 2012, Klaus Graefensteiner.

Disclaimer:
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

Theme design:
This blog theme was designed and is copyrighted 2012 by Klaus Graefensteiner

Rendertime:
Page rendered at 2/5/2012 9:43:14 PM (PST Pacific Standard Time UTC DST -7)