Creating a New SDO
This guide explains how to create a new SDO object in Content Server 16.
Outline
Create a New OScript Object
The first step is to create a new OScript object. Typically, you will create the object in the same OSpace as the service it will primarily be used with. Also, you should create all SDO objects for your service in the same package (typically this package will be named ServiceDataObject).
-
First, right-click your ServiceDataObject package from the OScript Explorer view and select New Object. The Source Folder and Package fields should be pre-filled based on your selection.
-
Enter a name for your SDO in the Object name field.
-
Enter the name of the Parent object or select it using the Browse... dialog. In most cases the parent object can be the core
SERVICE::ServiceDataObject
object.
Override SDO Features
Once your object is created, the next step is to override the core SDO features to represent your SDO.
-
First, open your object from the OScript Explorer.
-
Open the Source menu and select Override Features.
-
Select the following features in the Override Features dialog:
- fEnabled
- fNamespace
- fSDODescription
- isAbstract
- isEnum
- properties
Select OK.
-
Change the value of the
fEnabled
feature toTRUE
. This will make sure your SDO is added to the Service Registry at startup. -
Change the value of the
fNamespace
feature to the namespace of your service. -
Change the value of the
fSDODescription
feature to a description of your SDO. -
Change the value of the
isAbstract
feature toFALSE
.NOTE
This feature is currently not used for anything. However, the future intent of this feature is to provide additional functionality for "abstract" SDOs. An example of an SDO where this is set to
TRUE
is theMemberService::ServiceDataObject::Member
object. This object defines the base properties for the User, Group and Domain SDOs but the Member object itself should not be used. -
Change the value of the
isEnum
feature toFALSE
. This should already be the default value. -
Change the type of the
properties
feature to anAssoc
type if it isn't already.
Define SDO Properties
Finally, you need to define the properties of your SDO. The properties
feature will contain the name, description and type information for each property. The format of each property in the properties
feature is the following:
"f<PropertyName>" : Assoc{ "typeName" : "<propertyType>", "description" : "<propertyDescription>", "namespace" : <"propertyNamespace" or Undefined>, "isSDO" : <TRUE or FALSE>, "isArray" : <TRUE or FALSE>, "isNillable" : <TRUE or FALSE>, "isEnum" : <TRUE or FALSE>, "isReadOnly" : <TRUE or FALSE> }
- typeName
- A String value containing the data type of the property. This can be one of the core types (Boolean, Date, Integer, Long, Real, String) or it can be the name of another SDO.
- description
- A String value containing the description of the property.
- namespace
- A String value containing the namespace of the SDO or Enum SDO if the property is an SDO or an Enum. If the property is not an SDO or Enum then this value should be Undefined.
- isSDO
- A Boolean value indicating whether the property is an SDO.
- isArray
- A Boolean value indicating whether the property is an array (or a list) of values.
- isNillable
- A Boolean value indicating whether the property value can be null or Undefined.
- isEnum
- A Boolean value indicating whether the property is an Enum. Note that an Enum is special type of SDO.
- isReadOnly
- A Boolean value indicating whether the property is read-only or not. This is currently not used for anything, but may be used in the future to enforce that the value is read-only.
You also need to define each property in your OScript object. Take a look at the following example of a complete SDO object showing various different property types:
package SERVICE::ServiceDataObject public Object MyTestSDO inherits SERVICE::ServiceDataObject override Boolean fEnabled = TRUE override Boolean isEnum = FALSE override Boolean isAbstract = FALSE override String fNamespace = "TestNamespace" override String fSDODescription = "This is a test SDO with various property types." override Assoc properties = Assoc{ "fTestBoolean" : Assoc{ "typeName" : "Boolean", "description" : "a Boolean.", "namespace" : Undefined, "isSDO" : FALSE, "isArray" : FALSE, "isNillable" : FALSE, "isEnum" : FALSE, "isReadOnly" : FALSE }, "fTestDate" : Assoc{ "typeName" : "Date", "description" : "a Date.", "namespace" : Undefined, "isSDO" : FALSE, "isArray" : FALSE, "isNillable" : FALSE, "isEnum" : FALSE, "isReadOnly" : FALSE }, "fTestInteger" : Assoc{ "typeName" : "Integer", "description" : "an Integer.", "namespace" : Undefined, "isSDO" : FALSE, "isArray" : FALSE, "isNillable" : FALSE, "isEnum" : FALSE, "isReadOnly" : FALSE }, "fTestLong" : Assoc{ "typeName" : "Long", "description" : "a Long.", "namespace" : Undefined, "isSDO" : FALSE, "isArray" : FALSE, "isNillable" : FALSE, "isEnum" : FALSE, "isReadOnly" : FALSE }, "fTestReal" : Assoc{ "typeName" : "Real", "description" : "a Real.", "namespace" : Undefined, "isSDO" : FALSE, "isArray" : FALSE, "isNillable" : FALSE, "isEnum" : FALSE, "isReadOnly" : FALSE }, "fTestString" : Assoc{ "typeName" : "String", "description" : "a String.", "namespace" : Undefined, "isSDO" : FALSE, "isArray" : FALSE, "isNillable" : FALSE, "isEnum" : FALSE, "isReadOnly" : FALSE }, "fTestList" : Assoc{ "typeName" : "String", "description" : "a list of Strings.", "namespace" : Undefined, "isSDO" : FALSE, "isArray" : TRUE, "isNillable" : TRUE, "isEnum" : FALSE, "isReadOnly" : FALSE }, "fTestSDO" : Assoc{ "typeName" : "Node", "description" : "an SDO.", "namespace" : "DocMan", "isSDO" : TRUE, "isArray" : FALSE, "isNillable" : FALSE, "isEnum" : FALSE, "isReadOnly" : FALSE }, "fTestEnum" : Assoc{ "typeName" : "SearchColumn", "description" : "an enum.", "namespace" : "MemberService", "isSDO" : TRUE, "isArray" : FALSE, "isNillable" : FALSE, "isEnum" : TRUE, "isReadOnly" : FALSE }, "fTestNillable" : Assoc{ "typeName" : "Integer", "description" : "a nillable Integer.", "namespace" : Undefined, "isSDO" : FALSE, "isArray" : FALSE, "isNillable" : TRUE, "isEnum" : FALSE, "isReadOnly" : FALSE } } public Boolean fTestBoolean public Date fTestDate public Integer fTestInteger public Integer fTestLong public Real fTestReal public String fTestString public List fTestList public Object fTestSDO public Object fTestEnum public Integer fTestNillable = Undefined end
Type Reference
The following table shows the various native types that can be created and the corresponding type in OScript, C# and Java.
typeName | isArray | isNillable | OScript Type | C# Type | Java Type |
---|---|---|---|---|---|
Boolean | ✘ | ✘ | Boolean | bool | boolean |
Boolean | ✘ | ✔ | Boolean | bool? | Boolean |
Boolean | ✔ | ✘ | List | bool[] | boolean[] |
Boolean | ✔ | ✔ | List | bool?[] | Boolean[] |
Date | ✘ | ✘ | Date | DateTime | Date |
Date | ✘ | ✔ | Date | DateTime? | Date |
Date | ✔ | ✘ | List | DateTime[] | Date[] |
Date | ✔ | ✔ | List | DateTime?[] | Date[] |
Integer | ✘ | ✘ | Integer | int | int |
Integer | ✘ | ✔ | Integer | int? | Integer |
Integer | ✔ | ✘ | List | int[] | int[] |
Integer | ✔ | ✔ | List | int?[] | Integer[] |
Long | ✘ | ✘ | Integer | long | long |
Long | ✘ | ✔ | Long | long? | Long |
Long | ✔ | ✘ | List | long[] | long[] |
Long | ✔ | ✔ | List | long?[] | Long[] |
Real | ✘ | ✘ | Real | double | double |
Real | ✘ | ✔ | Real | double? | Double |
Real | ✔ | ✘ | List | double[] | double[] |
Real | ✔ | ✔ | List | double?[] | Double[] |
String | ✘ | ✘ | String | string | String |
String | ✘ | ✔ | String | string | String |
String | ✔ | ✘ | List | string[] | String[] |
String | ✔ | ✔ | List | string[] | String[] |