ECOBU ;BP/CMF - Utility Object ;8/21/2015
;;2.0;EVENT CAPTURE;**100,129**;8 May 96;Build 7
;@author - Chris Flegel
;@date - 17 May 2009
;@version - 1.0
;;
Q
;; private methods
HANDLERS(RESULT,HANDLE,METHOD,PARAMS) ;;
; find & execute handlers
N PROPERTY,HANDLES,FOUND,HANDLER,EXECUTER
S RESULT="-1^Invalid method"
I $E(METHOD,1,3)="Get" D
.D PARSE("Get",METHOD)
.S PARAMS=PROPERTY_"."_PARAMS
.S METHOD="Get"
.Q
I $E(METHOD,1,3)="Set" D
.D PARSE("Set",METHOD)
.S PARAMS=PROPERTY_"."_PARAMS
.S METHOD="Set"
.Q
I $E(METHOD,1,4)="Show" D
.D PARSE("Show",METHOD)
.S PARAMS=PROPERTY_"."_PARAMS
.S METHOD="Show"
.Q
D METHOD(.HANDLER,HANDLE_".Methods.Find1."_METHOD)
D METHOD^ECOBM(.EXECUTER,HANDLER_".GetHandler")
I $G(EXECUTER)="" Q ;EC*129
I ($P(EXECUTER,"^")=0)!($P(EXECUTER,"^")=-1) Q ;EC*129
D @EXECUTER
Q
;;
OBM(RESULT,ARGUMENT) ;shortcut to method class
D METHOD^ECOBM(.RESULT,ARGUMENT) Q
;;
OBP(RESULT,ARGUMENT) ;shortcut to property class
D METHOD^ECOBP(.RESULT,ARGUMENT) Q
;;
OB2(RESULT,ARGUMENT) ;shortcut to utility class
D METHOD^ECOB2(.RESULT,ARGUMENT) Q
;;
ECOB30(RESULT,HANDLE,PARAMS) ;handler for collect object
N CHILD
D GET^ECOB(.CHILD,HANDLE,"Pu","Collect")
D METHOD^ECOB30(.RESULT,CHILD_"."_PARAMS)
Q
;;
ECOBL(RESULT,HANDLE,METHOD,PARAMS) ;handler for simple list
N CHILD
D GET^ECOB(.CHILD,HANDLE,"Pu",METHOD)
D METHOD^ECOBL(.RESULT,CHILD_"."_PARAMS)
Q
;;
ECOBMC(RESULT,HANDLE,PARAMS) ;handler for method collection
N CHILD
D GET^ECOB(.CHILD,HANDLE,"Pu","Methods")
D METHOD^ECOBMC(.RESULT,CHILD_"."_PARAMS)
Q
;;
ECOBPC(RESULT,HANDLE,PARAMS) ;handler for property collection
N CHILD
D GET^ECOB(.CHILD,HANDLE,"Pu","Properties")
D METHOD^ECOBPC(.RESULT,CHILD_"."_PARAMS)
Q
;;
ECOBM(RESULT,HANDLE,PARAMS) ;; pass-through
D OBM(.RESULT,HANDLE_"."_PARAMS) Q
;;
ECOB2(RESULT,HANDLE,PARAMS) ;; pass-through
D OB2(.RESULT,HANDLE_"."_PARAMS) Q
;;
ECOBP(RESULT,HANDLE,PARAMS) ; pass-through
D OBP(.RESULT,HANDLE_"."_PARAMS) Q
;;
DIAGHDR(VALUE,WIDTH) ;;
N I,J
S J=WIDTH-$L(VALUE)-1
W !," "_VALUE_" "
F J=1:1:J W "-"
W "+"
Q
DIAGSGMT(VALUE,WIDTH) ;;
N I,J,OUT,FILL
S J=WIDTH-$L(VALUE)
S OUT=" + "_VALUE_" "
S FILL=""
F J=1:1:J S FILL=FILL_"-"
S OUT=$E(OUT_FILL,1,WIDTH)_" |"
W !,OUT
Q
DIAGATTR(VALUE,WIDTH) ;;
N I,J,OUT,FILL
S J=WIDTH-$L(VALUE)
S OUT=" | * "_VALUE
D:$L(VALUE)<WIDTH
.S FILL=""
.F J=1:1:J S FILL=FILL_" "
.S OUT=$E(OUT_FILL,1,WIDTH)_" |"
.Q
W !,OUT
Q
DIAGFTR(WIDTH) ;;
N I,J,OUT,FILL
S J=WIDTH
S OUT=" + "
S FILL=""
F J=1:1:J S FILL=FILL_"-"
S OUT=$E(OUT_FILL,1,J)_" +"
W !,OUT
Q
;;
;;protected methods
CLASS(RESULT,HANDLE,PARAMS) ;handler for class info display
N JUSTIFY,OFFSET,X,METH,PROP,ITEM
D PARSE("Offset",PARAMS)
D SHOW^ECOB(.X,HANDLE,"Pu","_class",JUSTIFY)
;;
D SHOW^ECOB(.X,HANDLE,"Pu","Methods",JUSTIFY)
D METHOD(.X,HANDLE_".Methods.Info."_OFFSET)
D SHOW^ECOB(.X,HANDLE,"Pu","Methods",JUSTIFY_"/")
;;
D SHOW^ECOB(.X,HANDLE,"Pu","Properties",JUSTIFY)
D METHOD(.X,HANDLE_".Properties.Info."_OFFSET)
D SHOW^ECOB(.X,HANDLE,"Pu","Properties",JUSTIFY_"/")
;;
D SHOW^ECOB(.X,HANDLE,"Pu","Root",JUSTIFY)
D METHOD(.X,HANDLE_".Root.Info."_OFFSET)
D SHOW^ECOB(.X,HANDLE,"Pu","Root",JUSTIFY_"/")
;;
D SHOW^ECOB(.X,HANDLE,"Pu","_class",JUSTIFY_"/")
S RESULT=1
Q
;;
CLEAR(RESULT,HANDLE,PARAMS) ; restore object to default state
N PROPERTY,DEFAULT,X
D METHOD(.PROPERTY,HANDLE_".Properties.First")
F Q:PROPERTY="-1^End of list" D
.D OBP(.DEFAULT,PROPERTY_".GetDefaultValue")
.D OBP(.X,PROPERTY_".SetValue."_DEFAULT)
.D METHOD(.PROPERTY,HANDLE_".Properties.Next")
S RESULT=1
Q
;
DIAGRAM(RESULT,HANDLE,PARAMS) ; draw class diagram
N CLASS,X,WIDTH,METHOD,PROPERTY,EXTEND,COLLECT,NAME
D GET^ECOB(.CLASS,HANDLE,"Pu","_class")
S X=$L(CLASS)+2
S WIDTH=$S(X<20:20,X<40:40,X<60:60,1:70)
D DIAGHDR(CLASS,WIDTH)
;;
D DIAGSGMT("Methods",WIDTH)
D METHOD(.METHOD,HANDLE_".Methods.First")
F Q:METHOD="-1^End of list" D
.D OBM(.NAME,METHOD_".GetName")
.D DIAGATTR(NAME,WIDTH)
.D METHOD(.METHOD,HANDLE_".Methods.Next")
.Q
;;
D DIAGSGMT("Properties",WIDTH)
D METHOD(.PROPERTY,HANDLE_".Properties.First")
F Q:PROPERTY="-1^End of list" D
.D OBP(.NAME,PROPERTY_".GetName")
.D DIAGATTR(NAME,WIDTH)
.D METHOD(.PROPERTY,HANDLE_".Properties.Next")
.Q
;;
D DIAGSGMT("Extends",WIDTH)
D METHOD(.EXTEND,HANDLE_".Root.First")
F Q:EXTEND="-1^End of list" D
.D:EXTEND'=CLASS DIAGATTR(EXTEND,WIDTH)
.D METHOD(.EXTEND,HANDLE_".Root.Next")
.Q
D DIAGFTR(WIDTH)
S RESULT=1
Q
;
GET(RESULT,HANDLE,METHOD,PARAMS) ;
N PROPERTY,PROP
S RESULT="-1^Invalid property"
S PROPERTY=$P(PARAMS,".")
D METHOD(.PROP,HANDLE_".Properties.Find1."_PROPERTY)
D:PROP'="" OBP(.RESULT,PROP_".GetValue")
Q
;;
INFO(RESULT,HANDLE,PARAMS) ;handler for business info display
N JUSTIFY,OFFSET,PROPERTY
D PARSE("Offset",PARAMS)
W !,$J("Name : ",JUSTIFY),"Value"
W !,$J("-----|-",JUSTIFY),"-----"
D METHOD(.PROPERTY,HANDLE_".Properties.First")
F Q:PROPERTY="-1^End of list" D
.D OBP(.NAME,PROPERTY_".GetName")
.D METHOD(.RESULT,HANDLE_".Show"_NAME_"."_JUSTIFY)
.D METHOD(.PROPERTY,HANDLE_".Properties.Next")
.Q
S RESULT=1
;;
PARSE(PARSE,VALUE) ;
I PARSE="Get" D Q
.S PROPERTY=$P(VALUE,".",1)
.S PROPERTY=$P(PROPERTY,"Get",2)
.Q
I PARSE="Handle" D Q
.S HANDLE=$P(VALUE,".")
.Q
I PARSE="Handle1" D Q
.S NAME=$P(VALUE,".",1)
.S COUNT=$P(VALUE,".",2)
.Q
I PARSE="Justify" D Q
.S JUSTIFY=$S(+VALUE:+VALUE,1:0)
.Q
I PARSE="Method" D Q
.S METHOD=$P(VALUE,".",2)
.Q
I PARSE="Offset" D Q
.S JUSTIFY=$S(+VALUE:+VALUE,1:0)
.S OFFSET=JUSTIFY+5
.Q
I PARSE="Params" D Q
.S PARAMS=$P(VALUE,".",3,99)
.Q
I PARSE="Set" D Q
.S PROPERTY=$P(VALUE,".",1)
.S PROPERTY=$P(PROPERTY,"Set",2)
.S VALUE=$P(VALUE,".",2)
.Q
I PARSE="Show" D Q
.S PROPERTY=$P(VALUE,".",1)
.S PROPERTY=$P(PROPERTY,"Show",2)
.Q
Q
;
SET(RESULT,HANDLE,METHOD,PARAMS) ;
N PROPERTY,PROP
S RESULT="-1^Invalid property"
S PROPERTY=$P(PARAMS,".")
S PARAMS=$P(PARAMS,".",2,99)
D METHOD(.PROP,HANDLE_".Properties.Find1."_PROPERTY)
D:PROP'="" OBP(.RESULT,PROP_".SetValue."_PARAMS)
Q
;
SHOW(RESULT,HANDLE,METHOD,PARAMS) ; show a property
N JUSTIFY,PROPERTY
S PROPERTY=$P(PARAMS,".")
S PARAMS=$P(PARAMS,".",2,99)
D METHOD(.RESULT,HANDLE_".Get"_PROPERTY)
Q:RESULT="-1^Invalid property"
S JUSTIFY=$S(+PARAMS:+PARAMS,1:0)
W !,$J("<"_PROPERTY_"> : ",JUSTIFY),RESULT
Q
;;
;; public methods
CREATE(NAME) ;
; call parent first
N HANDLE,CHILD,METHOD,PROPERTY,X
S HANDLE=$$CREATE^ECOB(NAME)
D SELF^ECOB(.RESULT,HANDLE,"EC OBU UTILITY","Utility","METHOD^ECOBU(.RESULT,ARGUMENT)","ECOB")
;;
S CHILD=$$CREATE^ECOB30(NAME)
D COLLECT^ECOB(HANDLE,CHILD,"Pu","Collect")
D METHOD^ECOB30(.X,CHILD_".SetCollector."_HANDLE)
;;
S CHILD=$$CREATE^ECOBMC(NAME)
D COLLECT^ECOB(HANDLE,CHILD,"Pu","Methods")
;; default ClassDiagram method
D METHOD(.METHOD,HANDLE_".Methods.Add.ClassDiagram")
D OBM(.X,METHOD_".SetAddedByClass.Utility")
D OBM(.X,METHOD_".SetDescription.Displays diagram of the class.")
D OBM(.X,METHOD_".SetHandler.DIAGRAM^ECOBU(.RESULT,HANDLE,PARAMS)")
D OBM(.X,METHOD_".SetParams.")
D OBM(.X,METHOD_".SetReturns.1")
;;
;; default ClassInfo method
D METHOD(.METHOD,HANDLE_".Methods.Add.ClassInfo")
D OBM(.X,METHOD_".SetAddedByClass.Utility")
D OBM(.X,METHOD_".SetDescription.Displays information about the class.")
D OBM(.X,METHOD_".SetHandler.CLASS^ECOBU(.RESULT,HANDLE,PARAMS)")
D OBM(.X,METHOD_".SetParams.[Justify]")
D OBM(.X,METHOD_".SetReturns.1")
;; default Clear method
D METHOD(.METHOD,HANDLE_".Methods.Add.Clear")
D OBM(.X,METHOD_".SetAddedByClass.Utility")
D OBM(.X,METHOD_".SetDescription.Restores public attributes to default state.")
D OBM(.X,METHOD_".SetHandler.CLEAR^ECOBU(.RESULT,HANDLE,PARAMS)")
D OBM(.X,METHOD_".SetParams.")
D OBM(.X,METHOD_".SetReturns.1")
;; default Get method
D METHOD(.METHOD,HANDLE_".Methods.Add.Get")
D OBM(.X,METHOD_".SetAddedByClass.Utility")
D OBM(.X,METHOD_".SetDescription.Gets a property value.")
D OBM(.X,METHOD_".SetHandler.GET^ECOBU(.RESULT,HANDLE,METHOD,PARAMS)")
D OBM(.X,METHOD_".SetParams.Get[propertyName]")
D OBM(.X,METHOD_".SetReturns.Property.Value")
;; default Set method
D METHOD(.METHOD,HANDLE_".Methods.Add.Set")
D OBM(.X,METHOD_".SetAddedByClass.Utility")
D OBM(.X,METHOD_".SetDescription.Sets a property value.")
D OBM(.X,METHOD_".SetHandler.SET^ECOBU(.RESULT,HANDLE,METHOD,PARAMS)")
D OBM(.X,METHOD_".SetParams.Set[propertyName].[Value]")
D OBM(.X,METHOD_".SetReturns.1 if successful, -1 otherwise")
;;
D METHOD(.METHOD,HANDLE_".Methods.Add.Show")
D OBM(.X,METHOD_".SetAddedByClass.Utility")
D OBM(.X,METHOD_".SetDescription.Displays a property value.")
D OBM(.X,METHOD_".SetHandler.SHOW^ECOBU(.RESULT,HANDLE,METHOD,PARAMS)")
D OBM(.X,METHOD_".SetParams.[Justify]")
D OBM(.X,METHOD_".SetReturns.[Property.Name] : [Property.Value]")
;;
D METHOD(.METHOD,HANDLE_".Methods.Add.Info")
D OBM(.X,METHOD_".SetAddedByClass.Utility")
D OBM(.X,METHOD_".SetDescription.Displays business information.")
D OBM(.X,METHOD_".SetHandler.INFO^ECOBU(.RESULT,HANDLE,PARAMS)")
D OBM(.X,METHOD_".SetParams.[Justify]")
D OBM(.X,METHOD_".SetReturns.1")
;;
S CHILD=$$CREATE^ECOBPC(NAME)
D COLLECT^ECOB(HANDLE,CHILD,"Pu","Properties")
;;
D METHOD(.PROPERTY,HANDLE_".Properties.Add._this")
D OBP(.X,PROPERTY_".SetAddedByClass.Utility")
D OBP(.X,PROPERTY_".SetValue."_HANDLE)
D OBP(.X,PROPERTY_".SetDefaultValue."_HANDLE)
;;
S CHILD=$$CREATE^ECOBL(NAME)
D COLLECT^ECOB(HANDLE,CHILD,"Pu","Root")
;;
D METHOD(.X,HANDLE_".Root.Add.EC BASE")
D METHOD(.X,HANDLE_".Root.Add.EC OBU UTILITY")
; complex properties last
Q HANDLE
;;
DESTROY(HANDLE) ;
; call parent last
N CHILD
D GET^ECOB(.CHILD,HANDLE,"Pu","Collect")
D DESTROY^ECOB30(CHILD)
D GET^ECOB(.CHILD,HANDLE,"Pu","Methods")
D DESTROY^ECOBMC(CHILD)
D GET^ECOB(.CHILD,HANDLE,"Pu","Properties")
D DESTROY^ECOBPC(CHILD)
D GET^ECOB(.CHILD,HANDLE,"Pu","Root")
D DESTROY^ECOBL(CHILD)
Q $$DESTROY^ECOB(HANDLE)
;;
FUNCTION(HANDLE,ARGUMENT) ;
; argument=method.(additional.params....)
N RESULT
D METHOD(.RESULT,HANDLE_"."_ARGUMENT)
Q RESULT
;
OUT(HANDLE,ARGUMENT) ;
; argument=method.(additional.params....)
N RESULT
D METHOD(.RESULT,HANDLE_"."_ARGUMENT)
Q RESULT
;
METHOD(RESULT,ARGUMENT) ;
; argument=handle.method.(additional.params...)
N HANDLE,METHOD,PARAMS
D PARSE("Handle",ARGUMENT)
I $G(HANDLE)'="",'$D(@HANDLE) S RESULT="-1^No data at handle: "_HANDLE_"." Q ;EC*129 - JAM
D PARSE("Method",ARGUMENT)
D PARSE("Params",ARGUMENT)
I METHOD="Collect" D ECOB30(.RESULT,HANDLE,PARAMS) Q
I METHOD="Methods" D ECOBMC(.RESULT,HANDLE,PARAMS) Q
I METHOD="Properties" D ECOBPC(.RESULT,HANDLE,PARAMS) Q
I METHOD="Root" D ECOBL(.RESULT,HANDLE,METHOD,PARAMS) Q
I METHOD="mf" D ECOBM(.RESULT,HANDLE,PARAMS) Q
I METHOD="of" D ECOB2(.RESULT,HANDLE,PARAMS) Q
I METHOD="pf" D ECOBP(.RESULT,HANDLE,PARAMS) Q
D HANDLERS(.RESULT,HANDLE,METHOD,PARAMS) Q
;;
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HECOBU 11353 printed Dec 13, 2024@01:58:08 Page 2
ECOBU ;BP/CMF - Utility Object ;8/21/2015
+1 ;;2.0;EVENT CAPTURE;**100,129**;8 May 96;Build 7
+2 ;@author - Chris Flegel
+3 ;@date - 17 May 2009
+4 ;@version - 1.0
+5 ;;
+6 QUIT
+7 ;; private methods
HANDLERS(RESULT,HANDLE,METHOD,PARAMS) ;;
+1 ; find & execute handlers
+2 NEW PROPERTY,HANDLES,FOUND,HANDLER,EXECUTER
+3 SET RESULT="-1^Invalid method"
+4 IF $EXTRACT(METHOD,1,3)="Get"
Begin DoDot:1
+5 DO PARSE("Get",METHOD)
+6 SET PARAMS=PROPERTY_"."_PARAMS
+7 SET METHOD="Get"
+8 QUIT
End DoDot:1
+9 IF $EXTRACT(METHOD,1,3)="Set"
Begin DoDot:1
+10 DO PARSE("Set",METHOD)
+11 SET PARAMS=PROPERTY_"."_PARAMS
+12 SET METHOD="Set"
+13 QUIT
End DoDot:1
+14 IF $EXTRACT(METHOD,1,4)="Show"
Begin DoDot:1
+15 DO PARSE("Show",METHOD)
+16 SET PARAMS=PROPERTY_"."_PARAMS
+17 SET METHOD="Show"
+18 QUIT
End DoDot:1
+19 DO METHOD(.HANDLER,HANDLE_".Methods.Find1."_METHOD)
+20 DO METHOD^ECOBM(.EXECUTER,HANDLER_".GetHandler")
+21 ;EC*129
IF $GET(EXECUTER)=""
QUIT
+22 ;EC*129
IF ($PIECE(EXECUTER,"^")=0)!($PIECE(EXECUTER,"^")=-1)
QUIT
+23 DO @EXECUTER
+24 QUIT
+25 ;;
OBM(RESULT,ARGUMENT) ;shortcut to method class
+1 DO METHOD^ECOBM(.RESULT,ARGUMENT)
QUIT
+2 ;;
OBP(RESULT,ARGUMENT) ;shortcut to property class
+1 DO METHOD^ECOBP(.RESULT,ARGUMENT)
QUIT
+2 ;;
OB2(RESULT,ARGUMENT) ;shortcut to utility class
+1 DO METHOD^ECOB2(.RESULT,ARGUMENT)
QUIT
+2 ;;
ECOB30(RESULT,HANDLE,PARAMS) ;handler for collect object
+1 NEW CHILD
+2 DO GET^ECOB(.CHILD,HANDLE,"Pu","Collect")
+3 DO METHOD^ECOB30(.RESULT,CHILD_"."_PARAMS)
+4 QUIT
+5 ;;
ECOBL(RESULT,HANDLE,METHOD,PARAMS) ;handler for simple list
+1 NEW CHILD
+2 DO GET^ECOB(.CHILD,HANDLE,"Pu",METHOD)
+3 DO METHOD^ECOBL(.RESULT,CHILD_"."_PARAMS)
+4 QUIT
+5 ;;
ECOBMC(RESULT,HANDLE,PARAMS) ;handler for method collection
+1 NEW CHILD
+2 DO GET^ECOB(.CHILD,HANDLE,"Pu","Methods")
+3 DO METHOD^ECOBMC(.RESULT,CHILD_"."_PARAMS)
+4 QUIT
+5 ;;
ECOBPC(RESULT,HANDLE,PARAMS) ;handler for property collection
+1 NEW CHILD
+2 DO GET^ECOB(.CHILD,HANDLE,"Pu","Properties")
+3 DO METHOD^ECOBPC(.RESULT,CHILD_"."_PARAMS)
+4 QUIT
+5 ;;
ECOBM(RESULT,HANDLE,PARAMS) ;; pass-through
+1 DO OBM(.RESULT,HANDLE_"."_PARAMS)
QUIT
+2 ;;
ECOB2(RESULT,HANDLE,PARAMS) ;; pass-through
+1 DO OB2(.RESULT,HANDLE_"."_PARAMS)
QUIT
+2 ;;
ECOBP(RESULT,HANDLE,PARAMS) ; pass-through
+1 DO OBP(.RESULT,HANDLE_"."_PARAMS)
QUIT
+2 ;;
DIAGHDR(VALUE,WIDTH) ;;
+1 NEW I,J
+2 SET J=WIDTH-$LENGTH(VALUE)-1
+3 WRITE !," "_VALUE_" "
+4 FOR J=1:1:J
WRITE "-"
+5 WRITE "+"
+6 QUIT
DIAGSGMT(VALUE,WIDTH) ;;
+1 NEW I,J,OUT,FILL
+2 SET J=WIDTH-$LENGTH(VALUE)
+3 SET OUT=" + "_VALUE_" "
+4 SET FILL=""
+5 FOR J=1:1:J
SET FILL=FILL_"-"
+6 SET OUT=$EXTRACT(OUT_FILL,1,WIDTH)_" |"
+7 WRITE !,OUT
+8 QUIT
DIAGATTR(VALUE,WIDTH) ;;
+1 NEW I,J,OUT,FILL
+2 SET J=WIDTH-$LENGTH(VALUE)
+3 SET OUT=" | * "_VALUE
+4 if $LENGTH(VALUE)<WIDTH
Begin DoDot:1
+5 SET FILL=""
+6 FOR J=1:1:J
SET FILL=FILL_" "
+7 SET OUT=$EXTRACT(OUT_FILL,1,WIDTH)_" |"
+8 QUIT
End DoDot:1
+9 WRITE !,OUT
+10 QUIT
DIAGFTR(WIDTH) ;;
+1 NEW I,J,OUT,FILL
+2 SET J=WIDTH
+3 SET OUT=" + "
+4 SET FILL=""
+5 FOR J=1:1:J
SET FILL=FILL_"-"
+6 SET OUT=$EXTRACT(OUT_FILL,1,J)_" +"
+7 WRITE !,OUT
+8 QUIT
+9 ;;
+10 ;;protected methods
CLASS(RESULT,HANDLE,PARAMS) ;handler for class info display
+1 NEW JUSTIFY,OFFSET,X,METH,PROP,ITEM
+2 DO PARSE("Offset",PARAMS)
+3 DO SHOW^ECOB(.X,HANDLE,"Pu","_class",JUSTIFY)
+4 ;;
+5 DO SHOW^ECOB(.X,HANDLE,"Pu","Methods",JUSTIFY)
+6 DO METHOD(.X,HANDLE_".Methods.Info."_OFFSET)
+7 DO SHOW^ECOB(.X,HANDLE,"Pu","Methods",JUSTIFY_"/")
+8 ;;
+9 DO SHOW^ECOB(.X,HANDLE,"Pu","Properties",JUSTIFY)
+10 DO METHOD(.X,HANDLE_".Properties.Info."_OFFSET)
+11 DO SHOW^ECOB(.X,HANDLE,"Pu","Properties",JUSTIFY_"/")
+12 ;;
+13 DO SHOW^ECOB(.X,HANDLE,"Pu","Root",JUSTIFY)
+14 DO METHOD(.X,HANDLE_".Root.Info."_OFFSET)
+15 DO SHOW^ECOB(.X,HANDLE,"Pu","Root",JUSTIFY_"/")
+16 ;;
+17 DO SHOW^ECOB(.X,HANDLE,"Pu","_class",JUSTIFY_"/")
+18 SET RESULT=1
+19 QUIT
+20 ;;
CLEAR(RESULT,HANDLE,PARAMS) ; restore object to default state
+1 NEW PROPERTY,DEFAULT,X
+2 DO METHOD(.PROPERTY,HANDLE_".Properties.First")
+3 FOR
if PROPERTY="-1^End of list"
QUIT
Begin DoDot:1
+4 DO OBP(.DEFAULT,PROPERTY_".GetDefaultValue")
+5 DO OBP(.X,PROPERTY_".SetValue."_DEFAULT)
+6 DO METHOD(.PROPERTY,HANDLE_".Properties.Next")
End DoDot:1
+7 SET RESULT=1
+8 QUIT
+9 ;
DIAGRAM(RESULT,HANDLE,PARAMS) ; draw class diagram
+1 NEW CLASS,X,WIDTH,METHOD,PROPERTY,EXTEND,COLLECT,NAME
+2 DO GET^ECOB(.CLASS,HANDLE,"Pu","_class")
+3 SET X=$LENGTH(CLASS)+2
+4 SET WIDTH=$SELECT(X<20:20,X<40:40,X<60:60,1:70)
+5 DO DIAGHDR(CLASS,WIDTH)
+6 ;;
+7 DO DIAGSGMT("Methods",WIDTH)
+8 DO METHOD(.METHOD,HANDLE_".Methods.First")
+9 FOR
if METHOD="-1^End of list"
QUIT
Begin DoDot:1
+10 DO OBM(.NAME,METHOD_".GetName")
+11 DO DIAGATTR(NAME,WIDTH)
+12 DO METHOD(.METHOD,HANDLE_".Methods.Next")
+13 QUIT
End DoDot:1
+14 ;;
+15 DO DIAGSGMT("Properties",WIDTH)
+16 DO METHOD(.PROPERTY,HANDLE_".Properties.First")
+17 FOR
if PROPERTY="-1^End of list"
QUIT
Begin DoDot:1
+18 DO OBP(.NAME,PROPERTY_".GetName")
+19 DO DIAGATTR(NAME,WIDTH)
+20 DO METHOD(.PROPERTY,HANDLE_".Properties.Next")
+21 QUIT
End DoDot:1
+22 ;;
+23 DO DIAGSGMT("Extends",WIDTH)
+24 DO METHOD(.EXTEND,HANDLE_".Root.First")
+25 FOR
if EXTEND="-1^End of list"
QUIT
Begin DoDot:1
+26 if EXTEND'=CLASS
DO DIAGATTR(EXTEND,WIDTH)
+27 DO METHOD(.EXTEND,HANDLE_".Root.Next")
+28 QUIT
End DoDot:1
+29 DO DIAGFTR(WIDTH)
+30 SET RESULT=1
+31 QUIT
+32 ;
GET(RESULT,HANDLE,METHOD,PARAMS) ;
+1 NEW PROPERTY,PROP
+2 SET RESULT="-1^Invalid property"
+3 SET PROPERTY=$PIECE(PARAMS,".")
+4 DO METHOD(.PROP,HANDLE_".Properties.Find1."_PROPERTY)
+5 if PROP'=""
DO OBP(.RESULT,PROP_".GetValue")
+6 QUIT
+7 ;;
INFO(RESULT,HANDLE,PARAMS) ;handler for business info display
+1 NEW JUSTIFY,OFFSET,PROPERTY
+2 DO PARSE("Offset",PARAMS)
+3 WRITE !,$JUSTIFY("Name : ",JUSTIFY),"Value"
+4 WRITE !,$JUSTIFY("-----|-",JUSTIFY),"-----"
+5 DO METHOD(.PROPERTY,HANDLE_".Properties.First")
+6 FOR
if PROPERTY="-1^End of list"
QUIT
Begin DoDot:1
+7 DO OBP(.NAME,PROPERTY_".GetName")
+8 DO METHOD(.RESULT,HANDLE_".Show"_NAME_"."_JUSTIFY)
+9 DO METHOD(.PROPERTY,HANDLE_".Properties.Next")
+10 QUIT
End DoDot:1
+11 SET RESULT=1
+12 ;;
PARSE(PARSE,VALUE) ;
+1 IF PARSE="Get"
Begin DoDot:1
+2 SET PROPERTY=$PIECE(VALUE,".",1)
+3 SET PROPERTY=$PIECE(PROPERTY,"Get",2)
+4 QUIT
End DoDot:1
QUIT
+5 IF PARSE="Handle"
Begin DoDot:1
+6 SET HANDLE=$PIECE(VALUE,".")
+7 QUIT
End DoDot:1
QUIT
+8 IF PARSE="Handle1"
Begin DoDot:1
+9 SET NAME=$PIECE(VALUE,".",1)
+10 SET COUNT=$PIECE(VALUE,".",2)
+11 QUIT
End DoDot:1
QUIT
+12 IF PARSE="Justify"
Begin DoDot:1
+13 SET JUSTIFY=$SELECT(+VALUE:+VALUE,1:0)
+14 QUIT
End DoDot:1
QUIT
+15 IF PARSE="Method"
Begin DoDot:1
+16 SET METHOD=$PIECE(VALUE,".",2)
+17 QUIT
End DoDot:1
QUIT
+18 IF PARSE="Offset"
Begin DoDot:1
+19 SET JUSTIFY=$SELECT(+VALUE:+VALUE,1:0)
+20 SET OFFSET=JUSTIFY+5
+21 QUIT
End DoDot:1
QUIT
+22 IF PARSE="Params"
Begin DoDot:1
+23 SET PARAMS=$PIECE(VALUE,".",3,99)
+24 QUIT
End DoDot:1
QUIT
+25 IF PARSE="Set"
Begin DoDot:1
+26 SET PROPERTY=$PIECE(VALUE,".",1)
+27 SET PROPERTY=$PIECE(PROPERTY,"Set",2)
+28 SET VALUE=$PIECE(VALUE,".",2)
+29 QUIT
End DoDot:1
QUIT
+30 IF PARSE="Show"
Begin DoDot:1
+31 SET PROPERTY=$PIECE(VALUE,".",1)
+32 SET PROPERTY=$PIECE(PROPERTY,"Show",2)
+33 QUIT
End DoDot:1
QUIT
+34 QUIT
+35 ;
SET(RESULT,HANDLE,METHOD,PARAMS) ;
+1 NEW PROPERTY,PROP
+2 SET RESULT="-1^Invalid property"
+3 SET PROPERTY=$PIECE(PARAMS,".")
+4 SET PARAMS=$PIECE(PARAMS,".",2,99)
+5 DO METHOD(.PROP,HANDLE_".Properties.Find1."_PROPERTY)
+6 if PROP'=""
DO OBP(.RESULT,PROP_".SetValue."_PARAMS)
+7 QUIT
+8 ;
SHOW(RESULT,HANDLE,METHOD,PARAMS) ; show a property
+1 NEW JUSTIFY,PROPERTY
+2 SET PROPERTY=$PIECE(PARAMS,".")
+3 SET PARAMS=$PIECE(PARAMS,".",2,99)
+4 DO METHOD(.RESULT,HANDLE_".Get"_PROPERTY)
+5 if RESULT="-1^Invalid property"
QUIT
+6 SET JUSTIFY=$SELECT(+PARAMS:+PARAMS,1:0)
+7 WRITE !,$JUSTIFY("<"_PROPERTY_"> : ",JUSTIFY),RESULT
+8 QUIT
+9 ;;
+10 ;; public methods
CREATE(NAME) ;
+1 ; call parent first
+2 NEW HANDLE,CHILD,METHOD,PROPERTY,X
+3 SET HANDLE=$$CREATE^ECOB(NAME)
+4 DO SELF^ECOB(.RESULT,HANDLE,"EC OBU UTILITY","Utility","METHOD^ECOBU(.RESULT,ARGUMENT)","ECOB")
+5 ;;
+6 SET CHILD=$$CREATE^ECOB30(NAME)
+7 DO COLLECT^ECOB(HANDLE,CHILD,"Pu","Collect")
+8 DO METHOD^ECOB30(.X,CHILD_".SetCollector."_HANDLE)
+9 ;;
+10 SET CHILD=$$CREATE^ECOBMC(NAME)
+11 DO COLLECT^ECOB(HANDLE,CHILD,"Pu","Methods")
+12 ;; default ClassDiagram method
+13 DO METHOD(.METHOD,HANDLE_".Methods.Add.ClassDiagram")
+14 DO OBM(.X,METHOD_".SetAddedByClass.Utility")
+15 DO OBM(.X,METHOD_".SetDescription.Displays diagram of the class.")
+16 DO OBM(.X,METHOD_".SetHandler.DIAGRAM^ECOBU(.RESULT,HANDLE,PARAMS)")
+17 DO OBM(.X,METHOD_".SetParams.")
+18 DO OBM(.X,METHOD_".SetReturns.1")
+19 ;;
+20 ;; default ClassInfo method
+21 DO METHOD(.METHOD,HANDLE_".Methods.Add.ClassInfo")
+22 DO OBM(.X,METHOD_".SetAddedByClass.Utility")
+23 DO OBM(.X,METHOD_".SetDescription.Displays information about the class.")
+24 DO OBM(.X,METHOD_".SetHandler.CLASS^ECOBU(.RESULT,HANDLE,PARAMS)")
+25 DO OBM(.X,METHOD_".SetParams.[Justify]")
+26 DO OBM(.X,METHOD_".SetReturns.1")
+27 ;; default Clear method
+28 DO METHOD(.METHOD,HANDLE_".Methods.Add.Clear")
+29 DO OBM(.X,METHOD_".SetAddedByClass.Utility")
+30 DO OBM(.X,METHOD_".SetDescription.Restores public attributes to default state.")
+31 DO OBM(.X,METHOD_".SetHandler.CLEAR^ECOBU(.RESULT,HANDLE,PARAMS)")
+32 DO OBM(.X,METHOD_".SetParams.")
+33 DO OBM(.X,METHOD_".SetReturns.1")
+34 ;; default Get method
+35 DO METHOD(.METHOD,HANDLE_".Methods.Add.Get")
+36 DO OBM(.X,METHOD_".SetAddedByClass.Utility")
+37 DO OBM(.X,METHOD_".SetDescription.Gets a property value.")
+38 DO OBM(.X,METHOD_".SetHandler.GET^ECOBU(.RESULT,HANDLE,METHOD,PARAMS)")
+39 DO OBM(.X,METHOD_".SetParams.Get[propertyName]")
+40 DO OBM(.X,METHOD_".SetReturns.Property.Value")
+41 ;; default Set method
+42 DO METHOD(.METHOD,HANDLE_".Methods.Add.Set")
+43 DO OBM(.X,METHOD_".SetAddedByClass.Utility")
+44 DO OBM(.X,METHOD_".SetDescription.Sets a property value.")
+45 DO OBM(.X,METHOD_".SetHandler.SET^ECOBU(.RESULT,HANDLE,METHOD,PARAMS)")
+46 DO OBM(.X,METHOD_".SetParams.Set[propertyName].[Value]")
+47 DO OBM(.X,METHOD_".SetReturns.1 if successful, -1 otherwise")
+48 ;;
+49 DO METHOD(.METHOD,HANDLE_".Methods.Add.Show")
+50 DO OBM(.X,METHOD_".SetAddedByClass.Utility")
+51 DO OBM(.X,METHOD_".SetDescription.Displays a property value.")
+52 DO OBM(.X,METHOD_".SetHandler.SHOW^ECOBU(.RESULT,HANDLE,METHOD,PARAMS)")
+53 DO OBM(.X,METHOD_".SetParams.[Justify]")
+54 DO OBM(.X,METHOD_".SetReturns.[Property.Name] : [Property.Value]")
+55 ;;
+56 DO METHOD(.METHOD,HANDLE_".Methods.Add.Info")
+57 DO OBM(.X,METHOD_".SetAddedByClass.Utility")
+58 DO OBM(.X,METHOD_".SetDescription.Displays business information.")
+59 DO OBM(.X,METHOD_".SetHandler.INFO^ECOBU(.RESULT,HANDLE,PARAMS)")
+60 DO OBM(.X,METHOD_".SetParams.[Justify]")
+61 DO OBM(.X,METHOD_".SetReturns.1")
+62 ;;
+63 SET CHILD=$$CREATE^ECOBPC(NAME)
+64 DO COLLECT^ECOB(HANDLE,CHILD,"Pu","Properties")
+65 ;;
+66 DO METHOD(.PROPERTY,HANDLE_".Properties.Add._this")
+67 DO OBP(.X,PROPERTY_".SetAddedByClass.Utility")
+68 DO OBP(.X,PROPERTY_".SetValue."_HANDLE)
+69 DO OBP(.X,PROPERTY_".SetDefaultValue."_HANDLE)
+70 ;;
+71 SET CHILD=$$CREATE^ECOBL(NAME)
+72 DO COLLECT^ECOB(HANDLE,CHILD,"Pu","Root")
+73 ;;
+74 DO METHOD(.X,HANDLE_".Root.Add.EC BASE")
+75 DO METHOD(.X,HANDLE_".Root.Add.EC OBU UTILITY")
+76 ; complex properties last
+77 QUIT HANDLE
+78 ;;
DESTROY(HANDLE) ;
+1 ; call parent last
+2 NEW CHILD
+3 DO GET^ECOB(.CHILD,HANDLE,"Pu","Collect")
+4 DO DESTROY^ECOB30(CHILD)
+5 DO GET^ECOB(.CHILD,HANDLE,"Pu","Methods")
+6 DO DESTROY^ECOBMC(CHILD)
+7 DO GET^ECOB(.CHILD,HANDLE,"Pu","Properties")
+8 DO DESTROY^ECOBPC(CHILD)
+9 DO GET^ECOB(.CHILD,HANDLE,"Pu","Root")
+10 DO DESTROY^ECOBL(CHILD)
+11 QUIT $$DESTROY^ECOB(HANDLE)
+12 ;;
FUNCTION(HANDLE,ARGUMENT) ;
+1 ; argument=method.(additional.params....)
+2 NEW RESULT
+3 DO METHOD(.RESULT,HANDLE_"."_ARGUMENT)
+4 QUIT RESULT
+5 ;
OUT(HANDLE,ARGUMENT) ;
+1 ; argument=method.(additional.params....)
+2 NEW RESULT
+3 DO METHOD(.RESULT,HANDLE_"."_ARGUMENT)
+4 QUIT RESULT
+5 ;
METHOD(RESULT,ARGUMENT) ;
+1 ; argument=handle.method.(additional.params...)
+2 NEW HANDLE,METHOD,PARAMS
+3 DO PARSE("Handle",ARGUMENT)
+4 ;EC*129 - JAM
IF $GET(HANDLE)'=""
IF '$DATA(@HANDLE)
SET RESULT="-1^No data at handle: "_HANDLE_"."
QUIT
+5 DO PARSE("Method",ARGUMENT)
+6 DO PARSE("Params",ARGUMENT)
+7 IF METHOD="Collect"
DO ECOB30(.RESULT,HANDLE,PARAMS)
QUIT
+8 IF METHOD="Methods"
DO ECOBMC(.RESULT,HANDLE,PARAMS)
QUIT
+9 IF METHOD="Properties"
DO ECOBPC(.RESULT,HANDLE,PARAMS)
QUIT
+10 IF METHOD="Root"
DO ECOBL(.RESULT,HANDLE,METHOD,PARAMS)
QUIT
+11 IF METHOD="mf"
DO ECOBM(.RESULT,HANDLE,PARAMS)
QUIT
+12 IF METHOD="of"
DO ECOB2(.RESULT,HANDLE,PARAMS)
QUIT
+13 IF METHOD="pf"
DO ECOBP(.RESULT,HANDLE,PARAMS)
QUIT
+14 DO HANDLERS(.RESULT,HANDLE,METHOD,PARAMS)
QUIT
+15 ;;