OpenId generic naming rule attribute

For each object, you must specify attributes, and define a naming rule that indicates which of these attributes provide a unique value. The naming rules vary depending on the hierarchy type. The new generic types that are stored in the simple package, are stored with the use of the same naming rules as in the old CDM. Objects that inherit from the SStandaloneObject type are stored with the openId attribute. Objects that inherit from the SContextualObject type are stored with the context and scopedId attributes.

Both openId and scopedId attributes are of the string type in a database, but on the API level they are of a new Java type OpenId. As a result, those attributes have a specific format, aligned with the OpenId schema. The OpenId type contains methods to easily construct any meaningful string that represents a value of a naming rule. The values that are specified in the openId attribute are the source for GUID calculation.

Examples

Example 1
For servers, naming rule is usually based on two attributes. They are the primary service access point that is created from the server's primary IP address, and a port, on which this service listens on. The openId attribute is specified in the following way:
id = OpenId().addId('IP' , seed.getPrimaryIpAddress().getStringNotation()).addId('port' , str(seed.getPort()))
Example 2
In Common Data Model, the old ComputerSystem type has a naming rule based on the manufacturer, model, and serialNumber attributes. These three attributes are defined in the class explicitly and when values are set for them, a ComputerSystem object can be stored.
LinuxUnitaryComputerSystem cs = ModelFactory.newInstance(LinuxUnitaryComputerSystem.class);
cs.setManufacturer("RedHat");
cs.setModel("Linux");
cs.setSerialNumber("as00123012");
Then an object with the following attribute map is stored in the persistence layer :
manufacturer -> RedHat
serialNumber -> as00123012
isPlaceholder -> false
model -> Linux
In the new Simplified Model, storing objects of the simplified SComputerSystem type with the same values looks the same. However, if there is another naming rule attribute available for the particular computer system, for example an id that a cluster assigns to every physical computer system that it manages, and such naming rule attribute is not defined in the model, it can be extended with the use of the OpenId type. When the attribute is extended, it is not only stored but it also uniquely represents the computer system. The OpenId type is used in the following way:
SComputerSystem scs = ModelFactory.newInstance(SComputerSystem.class);
scs.setHierarchyDomain("sys.unix.linux");
scs.setHierarchyType("RedHat");
scs.setManufacturer("RedHat");
scs.setModel("Linux");
scs.setSerialNumber("as00123012");
OpenId id = new OpenId();
id.addId("clusterInternalId", "66");
scs.setOpenId(id);
Example 3
The OpenId type can also be set in the following way:
scs.setOpenId(new OpenId().addId("clusterInternalId", "66"));
The following attribute map is stored:
manufacturer -> RedHat
serialNumber -> as00123012
model -> LinuxhierarchyType -> RedHat
isPlaceholder -> false
hierarchyDomain -> sys.unix.linux
openId -> <openId><id><name>clusterinternalid</name><value>66</value></id></openId>
Example 4
Adding a function to this simplified computer system is very similar. The following example shows how to create the OpenId attribute from values that are already set for the simplified class attributes:
SFunction sf = ModelFactory.newInstance(SFunction.class);
sf.setName("Cisco Firewall");
sf.setHierarchyDomain("function.net.firewall");
sf.setHierarchyType("Cisco");

OpenId fid = new OpenId(sf);
fid.addId("name", null);
fid.addId("type", "firewall");
sf.setScopedId(fid);
sf.setProvider(scs);
The following attribute map is stored:
hierarchyType -> Cisco
isPlaceholder -> false
provider -> {hierarchyType=RedHat;hierarchyDomain=sys.unix.linux;isPlaceholder=false;openId=<openId><id><name>clusterinternalid</name><value>66</value></id></openId>;}
hierarchyDomain -> function.net.firewall
name -> Cisco Firewall
scopedId -> <openId><id><name>name</name><value>Cisco Firewall</value></id><id><name>type</name><value>firewall</value></id></openId>
Example 5
To easily create one simple id without any distinction for particular attributes inside, set the attribute in the following way:
OpenId fid = new OpenId(sf);
sf.setProvider(scs);
sf.setScopedId(new OpenId().addId("id19921"));
The following attribute map is stored:
hierarchyType -> Cisco
isPlaceholder -> false
provider -> {hierarchyType=RedHat;hierarchyDomain=sys.unix.linux;isPlaceholder=false;openId=<openId><id><name>clusterinternalid</name><value>66</value></id></openId>;}
hierarchyDomain -> function.net.firewall
name -> Cisco Firewall
scopedId -> <openId><id><name>id</name><value>id19921</value></id></openId>