...
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
USING Progress.Lang.*. USING Consultingwerk.OERA.Context.IContextDatasetFactory FROM PROPATH. BLOCK-LEVEL ON ERROR UNDO, THROW. CLASS Test.TestContextDatasetFactory IMPLEMENTS IContextDatasetFactory: { Test/dsTestContext.i } /*------------------------------------------------------------------------------ Purpose: Factory method for the context dataset Notes: Returns the handle for the Context Dataset Initializes the Client Progress Version Number @return The handle of the context dataset instance ------------------------------------------------------------------------------*/ METHOD PUBLIC HANDLE CreateContextDataset (): IF NOT SESSION:REMOTE THEN DO: CREATE eSessionContext . ASSIGN eSessionContext.ClientProVersion = PROVERSION eSessionContext.ClientType = SESSION:CLIENT-TYPE . CREATE eSwatSessionContext . CREATE eTestSessionContext . END. RETURN DATASET dsTestContext:HANDLE . END METHOD. END CLASS. |
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
&SCOPED-DEFINE ACCESS {&ACCESS} &SCOPED-DEFINE REFERENCE-ONLY {&REFERENCE-ONLY} &SCOPED-DEFINE SUFFIX {&SUFFIX} &GLOBAL-DEFINE DATASET-NAME dsTestContext { Consultingwerk/OERA/Context/eContextProperties.i &NO-BEFORE=YES } { Consultingwerk/OERA/Context/eSessionContext.i &NO-BEFORE=YES } { Akioma/Swat/OERA/Context/eSwatSessionContext.i &NO-BEFORE=YES } { Test/eTestSessionContext.i &NO-BEFORE=YES } DEFINE {&ACCESS} DATASET dsTestContext{&SUFFIX} {&REFERENCE-ONLY} FOR eContextProperties{&SUFFIX}, eSessionContext{&SUFFIX}, eSwatSessionContext{&SUFFIX}, eTestSessionContext{&SUFFIX} . |
...
Next, a context wrapper class needs to be defined to provide access to the eTestSessionContext table fields.
For the SmartComponent Library session, the properties are available by accessing Consultingwerk.OERA.ContextWrapper.
For the SWAT session, the properties are available by accessing Akioma.Swat.OERA.Context.SwatContextWrapper.
A similar class should be implemented to provide strong-typed access to the custom session properties.
Both the SmartComponent Library and the SWAT context wrappers are separated into 2 different classes, the wrapper and the wrapper implementation (ex. Consultingwerk.OERA.ContextWrapper and Consultingwerk.OERA.ContextWrapperImpl), but this is not a requirement.
To simplify the implementation, we provide a base class for the implementation class: Akioma.Swat.OERA.Context.BaseContextWrapperImpl.
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
INTERFACE Test.ITestContextWrapper:
DEFINE PUBLIC PROPERTY TestProperty1 AS CHARACTER NO-UNDO
GET. SET.
??
DEFINE PUBLIC PROPERTY TestProperty2 AS CHARACTER NO-UNDO
GET. SET.
END INTERFACE. |
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
USING Progress.Lang.*. USING Akioma.Swat.OERA.Context.SwatContextWrapperTest.TestContextWrapper FROM PROPATH. BLOCK-LEVEL ON ERROR UNDO, THROW. CLASS Akioma.Swat.OERA.Context.SwatContextWrapperTest.TestContextWrapper: ?? DEFINE PUBLIC STATIC PROPERTY TestProperty1 AS CHARACTER NO-UNDO GET: RETURN SwatContextWrapperTestContextWrapper:GetContextWrapperImpl ():TestProperty1 . END GET . SET (arg AS CHARACTER): SwatContextWrapperTestContextWrapper:GetContextWrapperImpl ():TestProperty1 = arg . END . DEFINE PROTECTEDPUBLIC STATIC VARIABLEPROPERTY oContextWrapperInstanceTestProperty2 AS Test.ITestContextWrapperCHARACTER NO-UNDO. GET: DEFINE PUBLIC STATIC EVENT BeforeStoringContext SIGNATURE VOIDRETURN TestContextWrapper:GetContextWrapperImpl (e):TestProperty2 AS. Consultingwerk.EventArgs). END DEFINEGET PUBLIC. STATIC EVENT AfterRestoringContext SIGNATURE VOIDSET (earg AS Consultingwerk.EventArgsCHARACTER).: CONSTRUCTOR STATIC SwatContextWrapperTestContextWrapper:GetContextWrapperImpl ():TestProperty2 = arg . SwatContextWrapper:BeforeStoringContext:Subscribe(AssignFromSessionManager).END . SwatContextWrapper:AfterRestoringContext:Subscribe(AssignToSessionManager). END CONSTRUCTORDEFINE PROTECTED STATIC VARIABLE oContextWrapperInstance AS Test.ITestContextWrapper NO-UNDO. METHOD PROTECTED STATIC Test.ITestContextWrapper GetContextWrapperImpl (): IF VALID-OBJECT (oContextWrapperInstance) THEN RETURN oContextWrapperInstance. oContextWrapperInstance = {Consultingwerk/get-service.i Test.ITestContextWrapper "NEW Test.TestContextWrapperImpl ()" } . RETURN oContextWrapperInstance . END METHOD. END CLASS. |
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
USING Progress.Lang.*. USING Akioma.Swat.OERA.Context.ITestContextWrapper FROM PROPATH. USING Akioma.Swat.OERA.Context.BaseContextWrapperImpl FROM PROPATH. USING Akioma.Swat.SessionManager FROM PROPATH. BLOCK-LEVEL ON ERROR UNDO, THROW. CLASS Test.TestContextWrapperImpl INHERITS BaseContextWrapperImpl IMPLEMENTS ITestContextWrapper : DEFINE PUBLIC PROPERTY TestProperty1 AS CHARACTER NO-UNDO GET (): IF NOT IsValidateSessionContext ("Get":U) THEN RETURN ?. RETURN GetSessionContextField ("TestProperty1"):BUFFER-VALUE . END GET . SET (arg AS CHARACTER): IsValidateSessionContext ("Set":U). GetSessionContextField ("TestProperty1"):BUFFER-VALUE = arg . END SET. ?? DEFINE PUBLIC PROPERTY TestProperty2 AS CHARACTER NO-UNDO GET (): IF NOT IsValidateSessionContext ("Get":U) THEN RETURN ?. RETURN GetSessionContextField ("TestProperty2"):BUFFER-VALUE . END GET . SET (arg AS CHARACTER): IsValidateSessionContext ("Set":U). GetSessionContextField ("TestProperty2"):BUFFER-VALUE = arg . END SET. CONSTRUCTOR TestContextWrapperImpl(): SUPER(). THIS-OBJECT:ContextTableName = "eTestSessionContext". END CONSTRUCTOR. END CLASS. |