Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Simple reference is defined using name and type modifier. The data associations between two models is automatically done via SID. 

Code Block
languagexmlruby
themeEmacs
titleSample Reference Attribute Definition
linenumberstrue
<Reference#
Reference(cardinality=: "1..1", name=: "reference name", type=: "name of model/def"/>)

In this example thingCat is a reference attribute of VendorInfo. thingCat References 1 (cardinality is 1) instance of ThingCategory. The value of thingCat must be the SID of the ThingCategory instance.

...

  • Find queries can be defined either as reference attribute values (i.e. find query content is stored as a string reference attribute value) or defined in the model like below. usageInfo is a smart reference attribute defined to contain all data in UsageInformation model for the given day's activity.

Code Block
languagexmlruby
themeEmacs
titleSmart Reference Defined during Model definition
linenumberstrue
<DataModel#
DataModel Name=: "SmartMeterUsageVendorInfo">):
      <SidSid Name=: "IdvendorId"/>)
      <StringString Name=: "dayActivityIdvendorName"/>)
      <DoubleString Name=: "totalEnergyConsumptionvendorCity"/>)
      Reference <Referencecardinality: Format="$ObjectFormat(xml)" Name="usageInfo" Type="SMeterUsageInformation">
  "1..1", name: "thingCat", type: "ThingCategory")
DataModel Name: "ThingCategory"):
     <Find> Sid Name: "thingCatID")
      String <UsageInformation>
  Name: "catList", cardinality: "1..n")


# Let's Create few Thing Categories.
Query: <actualUsageId>
  DeleteAll: 
          [:ID:]ThingCategory: 
      thingCatID(ne: "")
  Create: </actualUsageId>
    ThingCategory: 
    </UsageInformation>  catList: "Sensors"
   Create: 
</Find>    ThingCategory: 
 </Reference>     </DataModel>
<DataModel Name="SMeterUsageInformation">catList: "Actuators"
  Create: 
  <Sid Name="Id"/>
   ThingCategory: 
  <String Name="activityId"/>       <String Name="actualUsageId"/>catList: "Sensors"
      <DateTime Format="$SimpleDateFormat(yyyy-MM-dd'T'HH:mm:ss.SSS'Z')" Name="Timestamp"/>catList: "Actuators"
      <DoublecatList: Name="energyGateways"/>


# Now create VendorInfo <Double Name="load"/>
    </DataModel>


<!-- Find Query -->
<Query>
  <Find nested="*" format="order">
    <SmartMeterUsage>with ThingCategory SID Value
Query: 
  Create: 
    VendorInfo: 
      vendorId: <ID ne="vendorA"/>
    </SmartMeterUsage>   </Find>
</Query>vendorName: "Phidget"
   <!-- Find Result -->
<Find Status="Success" Format="order"> vendorCity: "Calgary"
     <Result> thingCat: "LOBF4FOGAAAX6AAAAGEWWHEH"


# Let's do a <SmartMeterUsage>Find on VendorInfo with nested *
Query: 
  Find(format: "all",  <Id>LPFSJ4C3AAAH6AAAAGU6SHHK</Id>nested: "*"):
    VendorInfo: 
      <totalEnergyConsumption Value="100.0"/>vendorId(ne: "")


# Response to the Find
Find(Status: "Success",    <usageInfo Order="0x00">Format: "all"):
    Result: 
        VendorInfo(QName:  <Value>"Atomiton.Sensors.VendorInfo"):
            vendorId: vendorA 
      <Id>LPFSJ4C3AAAX6AAAAHCPOI6Q</Id>      thingCat(Known: "LOBF4FOGAAAX6AAAAGEWWHEH", Version:             <load Value="30.0"/>
                    <Timestamp Value="1", Timestamp: "1492540919704", DateTime: "2017-04-14T0718 11:2441:5859.263Z704"/>,                     <actualUsageId Value="LPFSJ4C3AAAH6AAAAGU6SHHK"/>
                    <activityId Value="TestActivity"/>QName: "Atomiton.Sensors.VendorInfo.thingCat", FName: "thingCat"):
                    <energy Value="20.0"/>Value(QName: "Atomiton.Sensors.ThingCategory"):
                </Value>    thingCatID: "LOBF4FOGAAAX6AAAAGEWWHEH"
           <Value>         catList(Value: "Sensors", Known: "Sensors", Order: "0x00", Version:      <Id>LPFSJ4C4AAAH6AAAAEYSWQKW</Id>
                    <load Value="30.0"/>
                    <Timestamp Value="1", Timestamp: "1492540855750", DateTime: "2017-04-14T0718 11:2440:5855.265Z75"/>, QName:                    <actualUsageId Value="LPFSJ4C3AAAH6AAAAGU6SHHK"/>"Atomiton.Sensors.ThingCategory.catList", FName: "catList")
                    <activityId Value="TestActivity"/>
                    <energy Value="20.0"/>
 catList(Value: "Actuators", Known: "Actuators", Order: "0x01", Version: "1", Timestamp: "1492540855751", DateTime: "2017-04-18 11:40:55.751", QName: "Atomiton.Sensors.ThingCategory.catList", FName: "catList")
              </Value>      catList(Value: "Gateways", Known: "Gateways", Order: "0x02", Version:     <Value>
                    <Id>LPFSJ4C4AAAX6AAAAF4TIFYW</Id>
                    <load Value="30.0"/>
                    <Timestamp Value="1", Timestamp: "1492540855751", DateTime: "2017-04-14T0718 11:2440:5855.266Z751"/>, QName: "Atomiton.Sensors.ThingCategory.catList", FName: "catList")
                <actualUsageId Value="LPFSJ4C3AAAH6AAAAGU6SHHK"/>
                    <activityId Value="TestActivity"/>
                    <energy Value="20.0"/>
                </Value>
                <Value>
                    <Id>LPFSJ4C4AABH6AAAAGAQH5K5</Id>
                    <load Value="30.0"/>
                    <Timestamp Value="2017-04-14T07:24:58.266Z"/>
   vendorCity(Value: "Calgary", Known: "Calgary", Version: "1", Timestamp: "1492540919704", DateTime: "2017-04-18 11:41:59.704", QName: "Atomiton.Sensors.VendorInfo.vendorCity", FName: "vendorCity")
            vendorName(Value: "Phidget", Known:  <actualUsageId Value="LPFSJ4C3AAAH6AAAAGU6SHHK"/>
                    <activityId Value="TestActivity"/>
                    <energy Value="20.0"/>
                </Value>
            </usageInfo>
            <activityId Value="TestActivity"/>
        </SmartMeterUsage>
    </Result>
</Find>"Phidget", Version: "1", Timestamp: "1492540919704", DateTime: "2017-04-18 11:41:59.704", QName: "Atomiton.Sensors.VendorInfo.vendorName", FName: "vendorName")


Find result set with smart references

...