User bio
404 bio not found
Member since Nov 7, 2023
Replies:

Hello Alexander,

thank you for your response!

I have ran a similar test to you and identified that the problem isn't with the single %SerialObject property, but with the one that is a list of them.

Here's the code:

ClassMethod test()
{
	set tKP = ..%New()
	set tAddressSerial = ##class(HS.Message.AddUpdateHubRequest).%OpenId(21986071).Addresses.GetAt(1)
	zw tAddressSerial
	set tKP.IsSerial = 1
	set tKP.Serial = tAddressSerial
	w tKP.%Save()
}

ClassMethod test2()
{
	set tKP = ..%New()
	set tIdentifierSerial = ##class(HS.Message.AddUpdateHubRequest).%OpenId(21986071).Identifiers
	zw tIdentifierSerial
	set tKP.IsSerial = 1
	set tKP.IsList = 1
	set tSerial = tIdentifierSerial.GetNext(.tKey)
	for {
		if tKey="" {quit}
		do tKP.SerialList.Insert(tSerial)
		set tSerial = tIdentifierSerial.GetNext(.tKey)
	}
	w tKP.%Save()
}

The tXSerial variables are instances of classes that extend %SerialObject.

And here are the results:

HSROUTER>do ##class(HS.Local.CZ.OR.ROUTER.Service.Data.KeyProperty).test()
tAddressSerial=5@HS.Types.Address  ; <OREF>
+----------------- general information ---------------
|      oref value: 5
|      class name: HS.Types.Address
|           %%OID: $lb($lb("Fake Street","24","","52","","","","Townville","CZE","12345","","","HP","","A",""),"HS.Types.Address")
| reference count: 2
+----------------- attribute values ------------------
|               City = "Townville"
|            Country = ""
|             County = ""
|        Description = ""
|              POBox = ""
|         PostalCode = 12345
|           Precinct = ""
|        PrimaryFlag = ""
|              State = "CZE"
|             Status = "A"
|         StreetLine = "Fake Street"
|         StreetName = ""  <Get>
|       StreetNumber = "24"  <Get>
|         StreetType = 52  <Get>
|         UnitNumber = ""
|                Use = "HP"
+-----------------------------------------------------
1
HSROUTER>do ##class(HS.Local.CZ.OR.ROUTER.Service.Data.KeyProperty).test2()
tIdentifierSerial=2@%Collection.ListOfObj  ; <OREF>
+----------------- general information ---------------
|      oref value: 2
|      class name: %Collection.ListOfObj
| reference count: 3
+----------------- attribute values ------------------
|   ElementClassType = "serial"
|        ElementType = "HS.Types.Identifier"
|    LiteralBehavior = 0
|          (oidData) = ""
|       (oidData(1)) = $lb($lb("DS4","496228107","","PN","A",""))
|       (oidData(2)) = $lb($lb("111","496228107","","MB","A",""))
|         (orefData) = "2@%Collection.ListOfObj"
|        OrefStorage = 16393
|              Owner = 2
|           ReadOnly = ""
|            Storage = 16388
|     StreamLocation = ""
+--------------- calculated references ---------------
|               Size   <Get>
+-----------------------------------------------------
0 2Šx<METHOD DOES NOT EXIST>zSerialNewObject+1^HS.Local.CZ.OR.ROUTER.Service.Data.KeyProperty.1 *%New,%Library.SerialObject«
HSROUTERœJ$^zSerialNewObject+1^HS.Local.CZ.OR.ROUTER.Service.Data.KeyProperty.1 +1L$^zSerialGetSwizzled+2^HS.Local.CZ.OR.ROUTER.Service.Data.KeyProperty.1 +3G$^%AddToSaveSet+5^HS.Local.CZ.OR.ROUTER.Service.Data.KeyProperty.1 +16$^%BuildObjectGraph+1^%Library.RegisteredObject.1 +1?$^%Save+5^HS.Local.CZ.OR.ROUTER.Service.Data.KeyProperty.1 +1AD^ztest2+12^HS.Local.CZ.OR.ROUTER.Service.Data.KeyProperty.1 +X^@ +1

The whole purpose of the KeyProperty class is to be part of another class which is meant to replicate Ens.Request instances into memory and regenerate them later. We need this because even though the Ens.Request class is persistent, it is deleted during management data purges and there are some requests we need to keep/remake even after purge schedule. I have figured out saving literal and persistent properties, so now I need to figure out a way to do so with serial ones as well. This was the first and simplest impulse but there might be another obvious way to save any sort of serial object and retrieve it later.

Okay, with a bit of fiddling, that did the trick. I have attempted to set PrefixMappings in my previous solutions but it appears I did it wrong then.

Output:

HSROUTER>Set tPnRXML.PrefixMappings="ns urn:oasis:names:tc:ebxml-regrep:xsd:rs:3.0"
HSROUTER>w tPnRXML.EvaluateExpression("/XMLMessage/ContentStream/ns:RegistryResponse/ns:RegistryErrorList/ns:RegistryError","@errorCode",.tPnRResult)
1
HSROUTER>w tPnRResult.Size                                                      
0
HSROUTER>w tPnRXML.EvaluateExpression("/ContentStream/ns:RegistryResponse/ns:RegistryErrorList/ns:RegistryError","@errorCode",.tPnRResult)
1
HSROUTER>w tPnRResult.Size                                                      
0
HSROUTER>w tPnRXML.EvaluateExpression("/ns:RegistryResponse/ns:RegistryErrorList/ns:RegistryError","@errorCode",.tPnRResult)
1
HSROUTER>w tPnRResult.Size                                                     
1
HSROUTER>w tPnRResult.GetAt(1).Value                                           
XDSRegistryDeprecatedDocumentError

Thank you very much.

Output on my machine:

HSROUTER>w tPnRXML.EvaluateExpression("/XMLMessage/ContentStream/RegistryResponse/RegistryErrorList/RegistryError","@errorCode",.tPnRResult)
1
HSROUTER>set tErrorCode = tPnRResult.GetAt(1).Value                              
SET tErrorCode = tPnRResult.GetAt(1).Value
^
<INVALID OREF>
HSROUTER>w tPnRResult.Size                                                      
0

(tPnRXML was set higher)

I believe this is due to the XML Document being created from the ContentStream part of the Response body. However the simple solution of just removing the first (two) steps of the XPath doesn't help either.

HSROUTER>w tPnRXML.EvaluateExpression("/ContentStream/RegistryResponse/RegistryErrorList/RegistryError","@errorCode",.tPnRResult)
1
HSROUTER>w tPnRResult.Size                                                      
0
HSROUTER>w tPnRXML.EvaluateExpression("/RegistryResponse/RegistryErrorList/RegistryError","@errorCode",.tPnRResult)
1
HSROUTER>w tPnRResult.Size                                                      
0

This reveals the main reason I had to come ask for help here.

Certifications & Credly badges:
Jakub has no Certifications & Credly badges yet.
Global Masters badges:
Jakub has no Global Masters badges yet.
Followers:
Jakub has no followers yet.
Following:
Jakub has not followed anybody yet.