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 obtained 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" :
{
"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-19T11:18:43.000Z",
"@isShortcut" : "0",
"@isLink" : "0",
"@hf" : "0",
"i" : "OBJ66",
"n" : "",
"k" : "66",
"c" : "1537",
"p" : "65",
"h" : "0",
"hasPrv" : "0",
"ic" : "0"
},
{
"@ts" : "2014-08-14T11:36:26.000Z",
"@isShortcut" : "0",
"@isLink" : "0",
"@hf" : "0",
"i" : "OBJ90",
"n" : "",
"k" : "90",
"c" : "1538",
"p" : "65",
"h" : "0",
"hasPrv" : "0",
"ic" : "0"
},
{
"@ts" : "2020-02-26T12:39:23.995Z",
"@isShortcut" : "0",
"@isLink" : "0",
"@hf" : "0",
"i" : "NEWFORM1",
"n" : "",
"k" : "176176",
"c" : "1538",
"p" : "65",
"h" : "0",
"hasPrv" : "0",
"ic" : "0"
},
{
"@ts" : "2020-02-26T12:39:25.401Z",
"@isShortcut" : "0",
"@isLink" : "0",
"@hf" : "0",
"i" : "NEWFORM2",
"n" : "",
"k" : "176177",
"c" : "1538",
"p" : "65",
"h" : "0",
"hasPrv" : "0",
"ic" : "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 operation execution
//Operation execution parameters
var tObject = new GetObjects()
{
//Specify obtained information
tArg = new GetObjectsArg()
{
//Get: keys, identifiers and class identifiers
//Sort by ascending 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
},
//Specify identifier of the object, which child objects are used in search
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: