Versions Compared

Key

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

...

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.

Code Block
languagexmlruby
themeEmacs
titleUnique Constraint Violation Error
linenumberstrue
<DataModel#
DataModel(Name=: "VendorInfo">):
      <Sid Name=Sid(Name: "vendorId"/>)
      <String Name=String(Name: "vendorName"/>)
      <String Name=String(Name: "vendorCity"/>)
      <ReferenceReference cardinality=: "1..1", Name: name="thingCat", type=: "ThingCategory"/>
</DataModel>
<DataModel Name=)
DataModel(Name: "ThingCategory">):
      <Sid Name=Sid(Name: "thingCatID"/>)
      <String Name=String(Name: "catList", cardinality=: "1..n"/>)
</DataModel>


<!--# Let's Create few Thing Categories.
-->
<Query>Query: 
  DeleteAll: <DeleteAll>
    <ThingCategory>ThingCategory: 
     <thingCatID thingCatID(ne=: ""/>)
  Create: 
</ThingCategory>   </DeleteAll> ThingCategory: 
<Create>     <ThingCategory>       <catList>
        SensorscatList: "Sensors"
  Create: 
  </catList>     </ThingCategory>ThingCategory: 
  </Create>   <Create>     <ThingCategory>
      <catList>
        ActuatorscatList: "Actuators"
  Create: 
  </catList>  ThingCategory: 
 </ThingCategory>   </Create>   <Create>
    <ThingCategory>
      <catList>
        SensorscatList: "Sensors"
      </catList>
      <catList>
        ActuatorscatList: "Actuators"
      </catList>
      <catList>
        Gateways
      </catList>
    </ThingCategory>
  </Create>
</Query>


<!-- catList: "Gateways"


# Now create VendorInfo with ThingCategory SID Value
-->Query: <Query>
  <Create>Create: 
   <VendorInfo> VendorInfo: 
    <vendorId>         vendorAvendorId: "vendorA"
      </vendorId>
      <vendorName>
        PhidgetvendorName: "Phidget"
      </vendorName>
      <vendorCity>
        CalgaryvendorCity: "Calgary"
      </vendorCity>
      <thingCat>
        LOBF4FOGAAAX6AAAAGEWWHEH
      </thingCat>
    </VendorInfo>
  </Create>
</Query>


<!-- thingCat: "LOBF4FOGAAAX6AAAAGEWWHEH"

# Let's do a Find on VendorInfo with nested *
-->Query: <Query>
  <Find format=Find(format: "all", nested=: "*">):
    <VendorInfo>VendorInfo: 
     <vendorId vendorId(ne=: ""/>)

   </VendorInfo>
  </Find>
</Query>


<!-- # Response to the Find
-->
<Find Status=Find(Status: "Success", Format=: "all">):
    <Result>Result: 
       <VendorInfo VendorInfo(QName=: "Atomiton.Sensors.VendorInfo">):
             <vendorId>vendorA</vendorId>vendorId: "vendorA" 
           <thingCat thingCat(Known=: "LOBF4FOGAAAX6AAAAGEWWHEH", Version=: "1", Timestamp=: "1492540919704", DateTime=: "2017-04-18 11:41:59.704", QName=: "Atomiton.Sensors.VendorInfo.thingCat", FName=: "thingCat">):
                <Value QName=Value(QName: "Atomiton.Sensors.ThingCategory">):
                     <thingCatID>LOBF4FOGAAAX6AAAAGEWWHEH</thingCatID>thingCatID: "LOBF4FOGAAAX6AAAAGEWWHEH" 
                   <catList catList(Value=: "Sensors", Known=: "Sensors", Order=: "0x00", Version=: "1", Timestamp=: "1492540855750", DateTime=: "2017-04-18 11:40:55.75", QName=: "Atomiton.Sensors.ThingCategory.catList", FName=: "catList"/>)
                    <catList Value=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"/>)
                    <catList Value=catList(Value: "Gateways", Known=: "Gateways", Order=: "0x02", Version=: "1", Timestamp=: "1492540855751", DateTime=: "2017-04-18 11:40:55.751", QName=: "Atomiton.Sensors.ThingCategory.catList", FName=: "catList"/>)
                </Value>
            </thingCat>
            <vendorCity Value=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=vendorName(Value: "Phidget", Known=: "Phidget", Version=: "1", Timestamp=: "1492540919704", DateTime=: "2017-04-18 11:41:59.704", QName=: "Atomiton.Sensors.VendorInfo.vendorName", FName=: "vendorName"/>
        </VendorInfo>
    </Result>
</Find>)

Smart Reference

In case of simple references the find result can automatically return theĀ nested references (i.e. SIDs of other instances) can be automatically expanded into their referent instances.

...