Below is the example of using the GetObjects operation to get the list of objects of the specified classes in the specified repository folder. Before the list is obtained, the repository tree is updated and the cache is cleared. Keys, identifiers, class and creation date identifiers are extracted for the objects. The list of objects is sorted by the object creation date in ascending order.
{
"GetObjects" :
{
"tParent" :
{
"id" : "S1!M!65"
},
"tFilter" :
{
"levels" : "-1",
"hideEmptyFolders" : "true",
"hideAllFolders" : "false",
"limit" : "-1",
"classes" :
{
"it" :
[
{
"k" : "1537"
},
{
"k" : "1538"
}
]
}
},
"tArg" :
{
"pattern" :
{
"sd" : "false",
"n" : "false",
"i" : "true",
"ts" : "false",
"ds" : "false",
"isShortcut" : "false"
},
"refresh" :
{
"all" : "true"
},
"orderBy" :
{
"asc" : "true",
"attribute" : "Timestamp"
}
}
}
}
{
"GetObjectsResult" :
{
"id" :
{
"id" : "S1!M!65"
},
"objects" :
{
"its" :
{
"d" :
[
{
"@ts" : "2012-01-19T17:18:43.000",
"@isLink" : "0",
"@hf" : "0",
"i" : "OBJ66",
"n" : "",
"k" : "66",
"c" : "1537",
"p" : "4294967295",
"h" : "0"
},
{
"@ts" : "2012-01-19T18:36:56.000",
"@isLink" : "0",
"@hf" : "0",
"i" : "OBJ90",
"n" : "",
"k" : "90",
"c" : "1538",
"p" : "4294967295",
"h" : "0"
},
{
"@ts" : "2013-12-05T17:36:26.000",
"@isLink" : "0",
"@hf" : "0",
"i" : "NEWFORM1",
"n" : "",
"k" : "8081",
"c" : "1538",
"p" : "4294967295",
"h" : "0"
},
{
"@ts" : "2013-12-05T17:36:28.000",
"@isLink" : "0",
"@hf" : "0",
"i" : "NEWFORM2",
"n" : "", "k" : "8082", "c" : "1538", "p" : "4294967295", "h" : "0" } ] } } } }
The GetObjectsByClass function specified below selects all the objects of the specified classes within the specified parent object. Hidden folders and various container objects are not searched. The repository connection moniker, parent object identifier and classes of the searched objects are sent as input parameters of the function. The result of the function is the collection of descriptions of the selected objects.
The example uses the FindObjectById function, which code is given in the Getting Object Description by Its Identifier example.
public static Ods GetObjectsByClass(MbId mb, string parent, OdClass[] classes)
{
var somClient = new SomPortTypeClient(); //Proxy object for executing operations
//Operation execution parameters
var tObject = new GetObjects()
{
//Determine extracted information
tArg = new GetObjectsArg()
{
//Extract: keys, identifiers and class identifiers
//Sort ascending by creation date
orderBy = new OdsOrderBy()
{
asc = true,
attribute = OdAttribute.Timestamp
},
pattern = new OdsPattern()
{
ds = false,
i = true,
isShortcut = false,
n = false,
ts = false
},
refresh = new MbRefresh()
{
all = true,
},
},
tFilter = new OdsFilt()
{
classes = classes,
limit = -1,
levels = -1,
hideAllFolders = false,
hideEmptyFolders = true
},
//Determine identifier of object among child objects of which search will be executed
tParent = new OdId()
{
id = mb.id + "!" + FindObjectById(mb, parent).k
}
};
//Get list of objects according to the specified selection parameters
var result = somClient.GetObjects(tObject);
return result.objects;
See also:
SOAP