Connect disparate data sources with TopBraid Composer - sparql

I'm working on a proof of concept to explore how to connect SPARQL data from different data sources. I have two OWL classes, each from its own data model, representing information that I've extracted from two different systems. The data models look like:
Order: id, itemName, quantity
Item: id, name, unitPrice
What I would like to do is connect these two types together using the Order.itemName and Item.name fields, and create a new field on the Order class to store the total price for the order (order.quantity * item.unitPrice).
This would be pretty trivial to do with SPARQL, but we're looking at TopBraid Composer due to its graphical mapping capabilities. From my understanding, using a SPINMap we should be able to easily - and graphically - define the above property, but I'm having some problems getting things connected together.
I've been following the tutorial in the TBC Help under "Application Development Tools/SPIN/Ontology Mapping with SPINMap", but I'm having problems just trying to get a simple attribute mapped over. Based on that help document, on the Diagram tab I'm drawing a line from the Item Class to the Order class and selecting the changeNamespace function with an appropriate value. I then drew a line from the Item class to a new property on the Order class, totalPrice, and set the function to equals, just to see if I can get the property to show up. After running the inferences, I run a SPARQL query, and the totalPrice field is empty for all of my Order classes. I know this description was confusing - any idea what I should be doing to make this work?

Matt, in your second step are you using a property from the Item class to map to the Order class? That should work without any problems for the 'equals' template.
Check the Inferences tab in the middle-bottom row of tabs aster running inferences. This will show all materialized inferences and can be used to verift hat your SPINMap is doing what is desired.
Also look at Configure Inferencing to make sure the TopSPIN reasoner is chosen.

Related

adding Columns based on received Objects to Table, via Spring

Working in Spring, and using H2 for now.
So, I have these two classes/Entities with their repositories working fine if I keep it simple.
Brand, which simply has a name and a price;
and VendingMachine, which has a model and some other properties;
BUT I need to implement this:
Different VendingMachines sell different Brands, for which they have a stock. The Brands it sells are determined when you instantiate the class.
So my idea is that the table for VendingMachines fields should look something like that:
MODEL////ID/////MAXCAPACITY////MAXBRANDS///BRAND01////BRAND02///BRAND03...
Where all the BRAND columns are the different Brands the machine sells, assigned at its instantiation as said before. The value will be an Integer.
My original idea was to send this data to the #Entity via a HashMap(Brand, Integer) but I don't know how to make it work once it tries to fit it into the JpaRepository, or even if it is possible this way.
Probably missing some magic Annotation I don't know.
Thanks, hope my question was well explained for everyone.
Extract Brand as new table/entity(read about database normalization).
And after just do one-to-many relationship with that entities(VendingMachines and Brand). would look like that:
class Brand
...
#ManyToOne
#JoinColumn(name="machine_id")
private VendingMachines machines;

Binary Sankey Diagram in Tableau - Not All Activities Match The Corresponding Number of KPIs

How do I link my activities variable to only the corresponding KPIs variable?
Using guidance from a number of sources, but primarily the genius of Jeffery Shafer articulated through the SuperDataScience video, I built a Sankey Diagram for my work. For the most part it works, however, I have been trying to figure out how to adjust my Sankey Diagram model to line up each activity with ONLY the corresponding KPIs, but am having no luck.
The data structure looks like this:
You'll note I changed the binary value to "", 2 instead of 0, 1 as it makes visual calculations easier. For the "Viz" variable, I have "Activity" for the raw data set, then I copy/paste/replicate the data to mirror the data (required for the model) but with "KPI" for the mirrored data.
In the following image, you'll see my main issue is that the smallest represented activity still shows as corresponding to all KPIs when in fact it does not. I want activity to line up only with the corresponding KPIs as some activities don't correspond with all, or even any, KPIs.
Finally, here is the model very similar to what the above video link shows:
Can someone help provide insight into how I can adjust the model to fit activities linking only to corresponding KPIs? I appreciate any insight. Thanks!
I have a solution to the issue, thanks to a helpful Tableau support member named Anthony. It was in the data structure. The data was not structured to only associate "Activities" with their "KPI" values within Tableau's requirements, but every "Activities" value with every "KPI" value. As a result, to achieve the desired result, the data needs to be restructured to only contain a row for every valid "Activities" and "KPI" combination. See the visual below where data is removed to format properly:
-------------------------------------->
Once the table is restructured, the desired visual result should configure with the model. It works like a charm!
Good luck out there!

Cross model fetched properties

How do I implement cross-model fetched properties in a core data model? Simply put, let's say I have two models -- a CompanyStructure model that describes departmental hierarchy, and a Employee model that describes all employees. How would I set an employee's department as a fetched property?
I found a similar question asked here. It's a good description of the problem I'm facing:
When I setup a fetched property for state in my document entity (in
Xcode modeller) it needs the destination set – however, the
destination popup only shows entities in the current model. What I
want (I think) is a predicate something like:
State.id == $FETCH_SOURCE.state_id
in order to relate the document entity to the globally defined state
entity in the other model.
BTW, I don't know about $FETCH_SOURCE or $FETCH_ANYTHING_ELSE, so I don't really understand the code block in the quoted segment above. I do know that I can't set the entity for an employee's department fetched property because they're in separate models.
EDIT -- Merging the two data models into one is not an option.
Fetched properties are part of the model, so by definition they are not cross-model. If you want to refer to more than one model you have to do it in code. Also, the definition of the connection between the Employees and Departments can only be done within a model, unless you use your own UIDs and thus bypass the model metaphor.
They way I do similar tasks, I add additional .h and .m files to my classes, like ClassName+Additions.h and I declare "properties" as methods that can be called just like properties such as [smith department]. In these files, I can #include all the necessary classes from the other model and maintain separate managed object contexts.

Accommodating Dynamic Hierarchies in a Data Warehouse Model

I am building a data warehouse for the company's (which I am working for) core ERP application, for a particular client.
Most of the data in the source database, which is related to hierarchies in the data warehouse are in columns as shown below:
But traditionally the model to store dimension data according to my knowledge is as:
I could pivot the data and fit them in the model shown above. But the issue comes when a user introduces a new hierarchy value. Say for instance the user in the future decides to define a new level called Product Sub Category. Then my entire data warehouse model will collapse without a way to accommodate the new hierarchy level defined.
Do let me know a way to overcome this situation.
I hope my answer is clear enough. Just let me know if further details are needed.
Well, nothing should collapse -- the ETL should extract and load the data as always.
Here are a few options to consider:
Simply add one more column for the new hierarchy to the dimProduct.
Try using hierarchy helper table.
Consider adding path string attribute to the dimProduct.

WCF data services - Limiting related objects returned based on critera

I have an object graph consisting of a base employee object, and a set of related message objects.
I am able to return the employee objects based on search criteria on the employee properties (eg team) etc. However, if I expand on the messages, I get the full collection of messages back. I would like to be able to either take the top n messages (i.e. restrict to 10 most recent) or ideally use a date range on the message objects to limit how many are brought back.
So far I have not been able to figure out a way of doing this:
I get an error if I attempt to filter on properties on the message (&$filter=employee/message/StartDate gives an error ">No property 'StartDate' exists in type 'System.Data.Objects.DataClasses.EntityCollection`1).
Attempting to use Top on the message related object doesn't work either.
I have also tried using a WebGet extension that takes a string list of employee IDs. That works until the list gets too long, and then fails due to the URL getting too long (it might be possible to setup a paging mechanism on this approach)...
Unfortunately the UI control I am using requires the data to be in a fairly specific hierarchical shape, so I can't easily come at this from starting on the message side and working backwards.
Outside of making multiple calls does anyone know of a method to accomplish this with wcf data services?
Thanks!
M.
Looks like the only real way of doing this is in fact to reverse the direction of the query.
So instead of starting from the Employee, I go from the message side. You can filter back on the employee properties, and restrict on the Messages collection. Its not ideal, as it means iterating the collection on return to re-center it on the employee for what I am attempting to do, but it will work. The async nature of silverlight and rich client at least means while an extra iteration is required, it still appears to be reasonably fast.
Another interesting thing to note: the current version of odata/wcf data services does not support querying on properties of inherited classes, so I had to move the start/end date properties up to the base class in order to be able to restrict my search on them.
http://Site/Service.svc/Messages()?&$filter=Employee/OfficeName eq 'Toronto' and (year(StartDate) eq 2010 and month(StartDate) ge 9 )