Array of objects definition

Showing 1-2 of 2 messages
Array of objects definition tom 6/28/12 10:39 AM
How does one define an array of custom objects right in excel.  Trying to set mghpvthostnetworkthroughput as Range[] array.  

Datatype ProviderProfile
String id
String providername
String servicetype
Range[] host_networkthroughput
String wan_networkthroughput

Datatype Range
String id
double min
double max
double score

Data ProviderProfile providerProfiles
id ID mghpvt
providername Provider Name MGH
servicetype Service Type Private
host_networkthroughput HOST: Network Throughput mghpvthostnetworkthroughput
wan_networkthroughput WAN: Network Throughput  WAN: Network Throughput 

Data Range mghpvthostnetworkthroughput
id min max score
ID Min Max Score
Low 1 2 5
Med 3 4 7
High 5 6 10

The information contained in this e-mail message may be privileged and confidential information and is intended only for the use of the individual and/or entity identified in the alias address of this message. If the reader of this message is not the intended recipient, or an employee or agent responsible to deliver it to the intended recipient, you are hereby notified that you have received this in error and that any review, dissemination, distribution, or copying of this message is strictly prohibited. If you have received this message in error, please notify us immediately by telephone or return e-mail and delete the original message from your system.

Re: Array of objects definition support 6/28/12 1:46 PM

Tom,

Yes, you may use Range[] inside Datatype, but to initiate an array you cannot use a Data table but rather should use a Method. For example, in the standard sample project DataArrays we specified an array of customers:

We may add more tables for policies that use an array of customers:

Here we set customers for each policy inside the method "setPolicy". Of course you may use different arrays of customers for different policies.

If now from a Java you call

    engine.run("setPolicies");

it will produce:

Policy(id=0) {

  id=One

  customers={

    [0]=Name=Robinson Age=24 Gender=Female Marital Status=Married

    [1]=Name=Smith Age=19 Gender=Male Marital Status=Single

    }

  total=1000

}

Policy(id=0) {

  id=Two

  customers={

    [0]=Name=Robinson Age=24 Gender=Female Marital Status=Married

    [1]=Name=Smith Age=19 Gender=Male Marital Status=Single

    }

  total=1500

}

You also may look at sample projects DecisionAutoInsurance in the workspace "openrules.decisions" and "AutoInsurance" in "openrules.rules".

Hope, it helps.

Support