How to determine if an object is an instance of a certain class in IBM Rules Designer/ODM? - rules

This may be an easy one, but I haven't found an easy way to determine in a rule that an object in working memory represented by an implemented interface is a specific class in IBM Rules Designer 8.8.1. For example, assuming HousingPeriod is an interface, if I have a definition that states:
definitions
set 'the housing period' to a housing period...
And I want to follow that with a where clause that further refines the collection of objects that implement HousingPeriod as one of a list of implementing classes, say CollegeHousingPeriod and InternshipHousingPeriod, how could I do that? Something like:
where this housing period is a college housing period
or
where any of the following is true:
- this housing period is a college housing period
- this housing period is an internship housing period,
doesn't seem to work. Thanks in advance for any help you can provide!

As far as I know there is no built in way to query the type of an object. Instead I see two possible ways to get the desired result:
Create a virtual BOM entry with a custom B2X-mapping for each of your implementing classes. In the B2X-Mapping, you implement the necessary Java code to compare the object type and return a boolean. Verbalization would be something like {1} is a college housing period. This obviously only works if you know the objects before and there are not too many of them.
Option two is to not create different objects but to use a seperate attribute to distinguish housing period types. The verbalization would then be something like where the type of this housing period is college housing. With this approach you’d have to change the interface of your rules project, which might not be possible for you.

Related

Need a unique user/course ID variable in SCORM 1.2 package

I'm working on a project that requires a unique "enrollment" id inside a file inside a SCORM package. Something that works like this:
<script src="...?enrollmentid=1234567890"></script>
I have figured out that I should be able to obtain a student_id, but this is too broad an identifier for this use. The id I use must describe a single student/course enrollment uniquely, as a student could enroll in multiple courses, and a course could have multiple students enrolled.
The id could be a composite of other fields, like student_id + course id + enrollment date, but I can't see any way to get those sorts of details from the LMS either.
Is what I'm trying to do possible?
SCORM 1.2 or even 2004 did not unfortunately include things like enrollment date, course id, or SCO title/structure unless that was pumped in via Launch Data that comes by way of the imsmanifest.xml at author time. And these are things which you would need to provide.
cmi.core.student_id is the only unique value you'll get directly from SCORM. The LMS was not given a way to also include any Tier IDs or internals it used when it imported the course. And unless they (unreliably) place them in the launch parameters or you have a way of doing some probing with javascript (also unreliable) you'll need to consider some other options.
Launch Data cmi.launch_data would probably be the easiest way to gain access to any values you want to pass thru to the SCO but this relies heavily on the authoring process of the SCO and its imsmanifest.xml. Situations where there is a LCMS setup or some mechanism of a authoring tool could enable these capabilities.
I add this below the <title/> tag in the imsmanifest.xml:
<!-- Launch Data Example uses Querystring format name=value&name=value -->
<adlcp:dataFromLMS><![CDATA[name=value]]></adlcp:dataFromLMS>
When I state unreliable - I mean to hint that unless you can definitively state you know where this content is running, and the LMS will never change, you won't be able to obtain the info you want in any reliable way.

Market Basket Analysis - single model for variable number of features?

I am using Apriori to build a recommender system to go along with my company's application. Before going down this road, I'd like to confirm with someone that has more experience that I am on the right track. Any help is appreciated.
Let me try to explain the issue. Depending on the context of the user within the application, the features that impact the recommendations can vary. For example, imagine a shopping scenario. If I shop at HEB, I usually have a predefined grocery list so the items on that list would be good recommendations if I just told the app I was going to HEB. When I go to Home Depot though, I tend to shop by department, so power tools and the associated parts are good recommendations if I tell the app I'm at Home Depot and I am doing shopping for power tools.
You see that the number of features varies in the two scenarios. In the first, my recommendations depend solely on the store while in the second, they depend on the store and the department in which I'm shopping.
I am looking to use a single Apriori model that can handle this type of situation. Would that be considered a best practice or is it better to have different models, one for when we just list the store and another for when we list the store and the department? Given that Apriori is an unsupervised algorithm, I think it can be done with one model, but wanted to double check since I don't have a ton of experience.
It seems to me like you are talking about multi-level association rules. This is from the manual page of the aggregate function in arules:
Support for Item Hierarchies
Description:
Often an item hierarchy is available for datasets used for
association rule mining. For example in a supermarket dataset
items like "bread" and "beagle" might belong to the item group
(category) "baked goods."
I guess the higher-level categories would be your departments and stores. This will be able to find associations between items, departments and stores.

How to prevent duplicate code while doing microservice or soa ? or how to define the bounded context without duplicating the models?

Can somebody please refer me how do we separate out the models while separating out each service to run of their own? So basically a few of the models we have right now overlaps among services. I went through some of the procedures which ask to use canonical pattern, however I also got that we should not use canonical pattern.
One of the solution would be to keep all the models in a common place which we are doing right now. But its seems problematic for managing the services in the form of one repository per one service.
Duplicate models are also fine with me if I can find good logic for it.
Vertical slicing and domain decomposition leads to having each vertical slice have it's own well defined fields (not entities) that belong together (bounded context/business functions), defining a logical service boundary and decomposing the Service Boundary to Business Components and Autonomous Components (smallest unit of work).
Each component owns the data it modifies and is the only one in the system that can change the state of that data, you can have many copies of the data for readers but only one logical writer.
There for it makes more sense not to share these data models as they are internal to the component responsible for the data model's state (and is encapsulated).
Data readers can use view models and these are dictated more by the consumer then the producer, the view/read models hold the "real"/"current" state of the transactional data (which is private to the data modifier), read data can be updated by the data processor after any logical state change.
So it makes more sense to publish view/read models for read only consumers...
Check out Udi Dahan's video
Does that make sense?

How can I generate sequential data?

I am currently trying to figure out how to generate data with Nelmio Alice and Faker. Here is the model I need to fill:
Let's say we need to match persons and their insurance policies. One person can have only one active insurance policy at a given time. Each insurance policy belongs to a single person.
This means that all the insurance policies of one person must not overlap. So when generating the insurance policy entities I need some way to tell Alice to generate begin and end in such a way that the new object does not conflict with the already existing objects.
How would I go about doing that? From looking at the Alice documentation, I have only found that it is possible to make attributes of an object depend on other attributes of the same object, but not how to make them depend on attributes of objects that are already there.

Country-specific configuration

I'm preparing to work on an application that should support different countries, so I need support for:
currencies
numbers formatting (for prices etc.)
Switching locales will be based on http://jmsyst.com/bundles/JMSI18nRoutingBundle.
Now I need to store information about locale specific stuff like currency, currency divisor, precision etc + some other country specific data.
What is the best way of doing that in Symfony 2? I know there's a Money field type in SF2 forms, but I will need to display prices etc all over the app, so maybe there's a bundle or something that might help?
I don't want to store information like that in config "parameters", rather in a DB table maybe and use a number_format then, but maybe someone has better ideas?
I'd really appreciate any input here! :)
Edit
One more thing came to my mind, validation constraints may differ for each country, for example phone number might have different lenghts in DE and, for example, in UK. Is it possible to define constraints based on locale? Or do I have to create my own constraint and inside that check locale etc?
I stumbled over this bundle recently, might be what you're looking for:
https://github.com/craue/TwigExtensionsBundle

Resources