Buscar un objeto en un ListOfObj
Hola a todos.
Tengo un mensaje reponse que tiene una property del tipo %Collection.ListOfObj y necesito buscar un elemento en esta lista. Os lo explico.El mensaje Response tiene una colección del tipo LabCenter
{
{
<Data name="ListLabCenterDefaultData">
<Subscript>"ListLabCenter"</Subscript>
<Value name="1">
<Value>ListCenter</Value>
</Value>
</Data>
<DefaultData>ListLabCenterDefaultData</DefaultData>
<Type>%Library.CacheStorage</Type>
}
}
{
Property LabId As %String;
Property Center As %String;
Property Code As %String;
Storage Default
{
<Data name="LabCenter">
<Value name="1">
<Value>LabId</Value>
</Value>
<Value name="2">
<Value>Center</Value>
</Value>
<Value name="3">
<Value>Code</Value>
</Value>
</Data>
<State>LabCenterState</State>
<StreamLocation>^DKV.LaboCe4177.LabCenterC486S</StreamLocation>
<Type>%Library.CacheSerialState</Type>
}
}
Recupero el mensaje que quiero evaluar
> set obj=##class(ListLabCenter).%OpenId(1)
> zw obj
obj=<OBJECT REFERENCE>[2@ListLabCenter]
+----------------- general information ---------------
| oref value: 2
| class name: ListLabCenter
| %%OID: $lb("1","ListLabCenter")
| reference count: 2
+----------------- attribute values ------------------
| %Concurrency = 1 <Set>
+----------------- swizzled references ---------------
| i%ListCenter = ""
| i%ListCenter(1) = $lb($lb("A08829848","A088298480001",""))
| i%ListCenter(2) = $lb($lb("A08829848","A088298480002",""))
| i%ListCenter(3) = $lb($lb("A08829848","A088298480003",""))
| i%ListCenter(4) = $lb($lb("U66700196","U667001960002",""))
| i%ListCenter(5) = $lb($lb("U66700196","U667001960003",""))
| r%ListCenter = "1@%Collection.ListOfObj"
| r%ListCenter(1) = "3@LabCenter"
+-----------------------------------------------------
He de localizar un objeto en concreto, por lo que creo un objeto con los datos que quiero buscar
> set objFind = ##class(LabCenter).%New()
> set objFind.LabId="A08829848"
> set objFind.Center="A088298480003"
> zw objFind
objFind=<OBJECT REFERENCE>[5@LabCenter]
+----------------- general information ---------------
| oref value: 5
| class name: LabCenter
| reference count: 2
+----------------- attribute values ------------------
| Center = "A088298480003"
| Code = ""
| LabId = "A08829848"
+-----------------------------------------------------
He intentado hacer la búsqueda usando el comando $LISTFIND pero el objeto no es del tipo lista
> w $Listvalid(obj.ListCenter)
0
Luego pensé en utilizar el comando Find de %Collection.ListOfObj
pero me da un error si intento buscar el objecto
¿Cómo podría localizar el elemento que estoy buscando en esta colección? Quiero evitar usar un bucle y que revise uno a uno los elementos porque no se cuantos puedo llegar a tener.
Un saludo,
Francisco López