Question about extending a persistent class and storage
I created a persistent class with all the associated classmethods that will be needed. I am going to use it as a temp storage for data.
Class tempPersistentClass As %Persistent
{
Property Name As %String;
Property Department As %String;
Property Title As %String;
ClassMethod GetItems(Output param) As %Status
{
//This class retrieves rows from $This and returns it as an output parameter to the caller
}
ClassMethod ProcessResponse(param) As %Status
{
// processes the param by doing the following
Depending on the returned values, move the data over to the correct extended table and delete the content from this table
}
}
At the same time, I created more persistent classes that extends the original class.
Class Customers Extends tempPersistentClass
{
}
Class Suppliers Extends temPersistentClass
{
}
I have a task that does the following:
1. Calls class method GetItems in tempPersistentClass and uses the output as part of an API request
2. Checks the API response and sends it back to the class method ProcessReponse in tempPersistentClass
I am aware that it would have been easier to create a single persistent table with just and indicator like "type". However, we currently have 14 of these types and each of them will potentially have millions of rows each with the possibility of adding more types. The question is, how do I separate the storage for the main table and the extensions? When I tried testing it, they contained the same values but I need them all separate from each other.
Comments
If I understand your questions correctly, you want to store Customers and Suppliers separately. If you don't need to store tempPersistentClass as well, you can just do the following:
Class tempPersistentClass
{...}
Class Customers Extends (%Persistent, tempPersistentClass)
{...}
Class Suppliers Extends (%Persistent, tempPersistentClass)
{...}In this case Customers and Suppliers will have their own globals (^CustomersD and ^SuppliersD) each and not use the storage from tempPersistentClass.
Hello Iryna,
Thanks for your reply. I do need to store tempPersistentClass as well but the values in this table gets moved to the other tables depending on the API response. The field values will also change depending on whether it's still in the tempPersistentClass table or moved to either Customers or Suppliers table. For example, a status property will have "new" while in tempPersistentClass and has "AA member" in the customer table.
In this case, create three classes as stated above. Compile them. Than change the superclass for tempPersistentClass to %Persistent and delete it from the other 2. This way you will still have the separate storage for the Customers and Suppliers, but you will also get the separate storage for temp class.
Or I think you can set up the storage for classes manually. but this will be harder.
I created the classes as stated then added %Persistent on tempPersistentClass and removed %Persistent from the Customers and Suppliers classes. Unfortunately, I am getting a compilation error saying DataLocation must be tempPersistentClass.
You can prevent classes extending %Persistent to have storage (an extent) by using the 'NoExtent' keyword.
Concrete classes will inherit properties and methods, and generate their own storage strategy block for them on compile.
Class AbstractPersistentClass Extends %Persistent [Abstract,NoExtent]
{
Property Name As %String;
Property Department As %String;
Property Title As %String;
}
Class Customers Extends AbstractPersistentClass
{ ... }
Class Suppliers Extends AbstractPersistentClass
{ ... }