Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

To do this, a custom Consultingwerk.OERA.Context.IContextDatasetFactory service will need to be implemented as below:

 

Code Block
titleSample: TestContextDatasetFactory
linenumberstrue
collapsetrue
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
titleSample: dsTestContext
linenumberstrue
collapsetrue
&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} 

    . 
Code Block
titleSample: eTestSessionContext
linenumberstrue
collapsetrue
DEFINE {&ACCESS} TEMP-TABLE eTestSessionContext{&SUFFIX} NO-UNDO {&REFERENCE-ONLY} &IF DEFINED (NO-BEFORE) EQ 0 &THEN BEFORE-TABLE eTestSessionContextBefore{&SUFFIX} &ENDIF
    
    FIELD TestProperty1 AS CHARACTER
    FIELD TestProperty2 AS CHARACTER
    .

 

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
USING Progress.Lang.*.
USING Akioma.Swat.OERA.Context.SwatContextWrapper FROM PROPATH.

BLOCK-LEVEL ON ERROR UNDO, THROW.

CLASS Akioma.Swat.OERA.Context.SwatContextWrapper: 
??
	DEFINE PUBLIC STATIC PROPERTY TestProperty1 AS CHARACTER NO-UNDO
    GET:
        RETURN SwatContextWrapper:GetContextWrapperImpl ():TestProperty1 .
    END GET .
    SET (arg AS CHARACTER):
        SwatContextWrapper:GetContextWrapperImpl ():TestProperty1 = arg .
    END .
    
    DEFINE PROTECTED STATIC VARIABLE oContextWrapperInstance AS Test.ITestContextWrapper NO-UNDO.
    
    DEFINE PUBLIC STATIC EVENT BeforeStoringContext SIGNATURE VOID (e AS Consultingwerk.EventArgs).
    DEFINE PUBLIC STATIC EVENT AfterRestoringContext SIGNATURE VOID (e AS Consultingwerk.EventArgs).
    
    CONSTRUCTOR STATIC SwatContextWrapper():
        SwatContextWrapper:BeforeStoringContext:Subscribe(AssignFromSessionManager).
        SwatContextWrapper:AfterRestoringContext:Subscribe(AssignToSessionManager).
    END CONSTRUCTOR.
    
    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
??