// 15 −6. P r o g r a m l i s t a : f o o t e r . html f i l e t a r t a l m a
Powered by B o n i t a S o f t Team
6 7
A login.jsp lap működése Ez a jsp lap gyakorlatilag egy tiszta Java program (a kinézetét a 15.1. ábra mutatja), a 39 sorok között az importok vannak. A 13. és 14. sorokban átvesszük az előző lapról kapott username és password értékeket. A 17. sorban egy erőforrásként töltjük be a jaas-standard.cfg file-t, ami tényleg a CLASSPATH -on van, hiszen a classes könyvtárba tettük. Sikeres esetben a jaasFile változó tartalmazza az erre a filera mutató URL-t. Mindez csak akkor fontos, ha a BonitaConstants.JAAS_PROPERTY környezeti változó még nincs beállítva, amely esetben ez a 19. sorban megtörténik. A lényeg az, hogy mire a 22. sorhoz érünk, ennek jó értékkel kell rendelkeznie, így az authLC security context-et ebben a sorban létrehozhatjuk. A 23 és 24 sor login() és logout()-ja csak arra jó, hogy hibás bejelentkezés esetén egy exception tud dobódni, 1 2 3 4 5 6 7 8 9 10 11 12
így ha ezen túljutunk, akkor a BonitaAuth-tal szemben sikeresen hitelesítettük magunkat. A 26-27 sor storeLC security context-je a BonitaStore-ral szemben hitelesít, azonban a 30. sor logout()-ja előtt egy nagyon fontos API művelethez szereztünk jogot, amennyiben idáig el tudtunk jutni. Mi ez? A korábban már említett AccessorUtil class getManagementAPI() metódusával egy managementAPI példányt szerzünk (28. sor) és első dolgunk lesz (29. sor) annak megvizsgálása, hogy van-e (az immár bejelentkezett) a user-nek admin joga. A 32-33 sorokban a HTTP session-re rátesszük a bejelentkezett user nevét és az admin jogosultság vizsgálatának eredményét. A 35. sor az így előkészített környezetet használva a home.jsp-re irányít minket. Viszont hiba esetén (nem tudtunk bejelentkezni) az index.jsp-re dob vissza az alkalmazás. Nézzük tehát a következő állomást, az home.jsp lapot!
// 15 −7. P r o g r a m l i s t a : a c t i o n s / l o g i n . j s p f i l e t a r t a l m a <%@ <%@ <%@ <%@ <%@ <%@ <%@
page page page page page page page
import=" o r g . ow2 . b o n i t a . u t i l . B o n i t a C o n s t a n t s " %> import=" o r g . ow2 . b o n i t a . u t i l . Misc "%> import=" o r g . ow2 . b o n i t a . u t i l . S i m p l e C a l l b a c k H a n d l e r "%> import=" j a v a x . s e c u r i t y . auth . l o g i n . LoginContext "%> import=" j a v a . n e t .URL"%> import=" o r g . ow2 . b o n i t a . f a c a d e . ManagementAPI"%> import=" o r g . ow2 . b o n i t a . u t i l . A c c e s s o r U t i l "%>
<% try {
137
Business Process Management 13 14 15 16 17 18 19 20 21 22 23 24 25 26
A Bonita API használata
f i n a l String username = r e q u e s t . ge tPa ram ete r ( " username " ) ; f i n a l String password = r e q u e s t . ge tPa ram ete r ( " password " ) ; i f ( System . g e t P r o p e r t y ( B o n i t a C o n s t a n t s .JAAS_PROPERTY) == n u l l ) { f i n a l URL j a a s F i l e = t h i s . g e t C l a s s ( ) . g e t C l a s s L o a d e r ( ) . g e t R e s o u r c e ( " j a a s −å standard . c fg " ) ; i f ( j a a s F i l e != n u l l ) { System . s e t P r o p e r t y ( B o n i t a C o n s t a n t s .JAAS_PROPERTY, j a a s F i l e . toURI ( ) . getPathå () ) ; } } f i n a l LoginContext authLC = new LoginContext ( " BonitaAuth " , new å S i m p l e C a l l b a c k H a n d l e r ( username , password ) ) ; authLC . l o g i n ( ) ; authLC . l o g o u t ( ) ; f i n a l LoginContext storeLC = new LoginContext ( " B o n i t a S t o r e " , new å S i m p l e C a l l b a c k H a n d l e r ( username , password ) ) ; storeLC . l o g i n ( ) ; f i n a l ManagementAPI managementAPI = A c c e s s o r U t i l . getManagementAPI ( ) ; f i n a l Boolean isAdmin =new Boolean ( managementAPI . isUserAdmin ( username ) ) ; storeLC . l o g o u t ( ) ;
27 28 29 30 31 32 r e q u e s t . g e t S e s s i o n ( ) . s e t A t t r i b u t e ( " username " , username ) ; 33 r e q u e s t . g e t S e s s i o n ( ) . s e t A t t r i b u t e ( " i s a d m i n " , isAdmin ) ; 34 35 r e s p o n s e . s e n d R e d i r e c t ( " . . / home . j s p " ) ; 36 } c a t c h ( E x c e p t i o n e ) { 37 e . printStackTrace () ; 38 Throwable t = e ; 39 w h i l e ( t . getCause ( ) != n u l l ) { 40 t = t . getCause ( ) ; 41 } 42 f i n a l String msg = " Unable ␣ t o ␣ l o g i n : ␣ " + t . getMessage ( ) ; 43 r e s p o n s e . s e n d R e d i r e c t ( " . . / i n d e x . j s p ?msg=" + msg ) ; 44 } 45 %>
A home.jsp lap működése
15.1. ábra. A login.jsp lap 138
A lap kinézetét a 15.2. ábra mutatja, ami a 158. Programlista alapján állt elő. A 18. sorig csak Java importok vannak. A 21-23 sorok között történik egy vizsgálat arra nézve, hogy az eddigiek beállították-e a user objektumot a http session-re. Amennyiben nem, úgy nincs jobb megoldás, szolgáltatni kell a bejelentkeztetésre alkalmas index.jsp lapot. Sikeres továbblépés esetén azt is megvizsgáljuk, hogy most admin
Business Process Management joggal használják-e ezt az alkalmazást. A 33-35 sorok között 3 üres listát hozunk létre: readyTaskList, doneTaskList, enabledProcesses. Ha a 37-38 sorok login() ellenőrzésén túl tudunk jutni, akkor az API-t használva feltöltjük ezeket a listákat, majd a 47. sorban (logout()) kilépünk a security context-ből. A megszerzett információk megjelenítéséről szól a lap további része, ezt látjuk az ábrán is. Nem okoz itt már gondot, hogy a logout() lefutott, hiszen az engine-től egyelőre több információt nem is várunk. Láthatjuk a 39. sortól, ahogy a különféle API komponenseket (esetünkben a QueryRuntimeAPI, QueryDefinitionAPI) milyen egyszerűen el tudjuk érni és használni a prcess intsance-októl egészen a taskok szintjéig lemenve. A továbbiakban ismertetett jsp lapok (intstances.jsp, processes.jsp, taskDetails.jsp) a most felépített felületen lévő linkekről hívhatóak, nézzük meg őket is! 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
A Bonita API használata
15.2. ábra. A home.jsp lap
// 15 −8. P r o g r a m l i s t a : home . j s p f i l e t a r t a l m a
<%@ page import=" j a v a x . s e c u r i t y . auth . l o g i n . LoginContext "%> <%@ page import=" o r g . ow2 . b o n i t a . f a c a d e . QueryRuntimeAPI"%> <%@ page import=" o r g . ow2 . b o n i t a . l i g h t . L i g h t P r o c e s s D e f i n i t i o n "%> <%@page import=" o r g . ow2 . b o n i t a . f a c a d e . d e f . majorElement . P r o c e s s D e f i n i t i o n "%> <%@ page import=" o r g . ow2 . b o n i t a . f a c a d e . uuid . P r o c e s s D e f i n i t i o n U U I D "%> <%@ page import=" o r g . ow2 . b o n i t a . u t i l . A c c e s s o r U t i l "%> <%@ page import=" o r g . ow2 . b o n i t a . u t i l . S i m p l e C a l l b a c k H a n d l e r "%> <%@page import=" j a v a . u t i l . L i s t "%> <%@page import=" j a v a . u t i l . C o l l e c t i o n s "%> <%@page import=" o r g . ow2 . b o n i t a . f a c a d e . runtime . A c t i v i t y S t a t e "%> <%@page import=" o r g . ow2 . b o n i t a . l i g h t . L i g h t T a s k I n s t a n c e "%> <%@page import=" j a v a . u t i l . C o l l e c t i o n "%> <%@page import=" o r g . ow2 . b o n i t a . f a c a d e . uuid . A c t i v i t y I n s t a n c e U U I D "%> <%@page import=" o r g . ow2 . b o n i t a . f a c a d e . Q u e r y D e f i n i t i o n A P I "%> <%@page import=" o r g . ow2 . b o n i t a . f a c a d e . d e f . majorElement . P r o c e s s D e f i n i t i o n . å P r o c e s s S t a t e "%> 18 <%@page import=" j a v a . u t i l . S e t "%> 19 20 <% 21 f i n a l Object usernameObject = r e q u e s t . g e t S e s s i o n ( ) . g e t A t t r i b u t e ( " username " ) ; 22 i f ( usernameObject == n u l l ) { 23 response . sendRedirect ( " index . jsp " ) ; 24 } 25 f i n a l String username = ( String ) usernameObject ; 26 27 f i n a l Object isAdminObject = r e q u e s t . g e t S e s s i o n ( ) . g e t A t t r i b u t e ( " i s a d m i n " ) ;
139
Business Process Management 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
A Bonita API használata
f i n a l b o o l e a n isAdmin = isAdminObject != n u l l && ( ( Boolean ) isAdminObject ) . å booleanValue ( ) ; f i n a l String msg = r e q u e s t . g etP ara met er ( "msg" ) ;
f i n a l i n t numberOfElementsToRetrive = 2 0 ; C o l l e c t i o n
r e a d y T a s k L i s t = C o l l e c t i o n s . emptyList ( ) ; C o l l e c t i o n d o n e T a s k L i s t = C o l l e c t i o n s . emptyList ( ) ; S e t e n a b l e d P r o c e s s e s = C o l l e c t i o n s . emptySet ( ) ; try { f i n a l LoginContext l o g i n C o n t e x t = new LoginContext ( " B o n i t a S t o r e " , new å S i m p l e C a l l b a c k H a n d l e r ( username , " " ) ) ; loginContext . login () ; f i n a l QueryRuntimeAPI queryRuntimeAPI = A c c e s s o r U t i l . getQueryRuntimeAPI ( ) ; f i n a l QueryDefinitionAPI queryDefinitionAPI = Ac c e s s o r U t i l . å getQueryDefinitionAPI () ; r e a d y T a s k L i s t = queryRuntimeAPI . g e t L i g h t T a s k L i s t ( A c t i v i t y S t a t e .READY) ; d o n e T a s k L i s t = queryRuntimeAPI . g e t L i g h t T a s k L i s t ( A c t i v i t y S t a t e . FINISHED) ; enabledProcesses = queryDefinitionAPI . getLightProcesses ( ProcessDefinition . å P r o c e s s S t a t e .ENABLED) ; loginContext . logout () ; } catch ( Exception e ) { e . printStackTrace () ; Throwable t = e ; w h i l e ( t . getCause ( ) != n u l l ) { t = t . getCause ( ) ; } f i n a l S t r i n g errorMsg = " E r r o r ␣ w h i l e ␣ l i s t i n g ␣ t a s k s : ␣ " + t . getMessage ( ) ; r e s p o n s e . s e n d R e d i r e c t ( " i n d e x . j s p ?msg=" + errorMsg ) ; } %> <j s p : i n c l u d e page=" h e a d e r . html " />
<%i f ( msg != n u l l ) {%> <%=msg %>
<%}%> L i s t o f t a s k s t o perform Name | P r o c e s s | A c t i o n s |
<% fo r ( L i g h t T a s k I n s t a n c e t a s k : r e a d y T a s k L i s t ) {
140
Business Process Management
f i n a l String l a b e l = t a s k . getDynamicLabel ( ) != n u l l ? t a s k . getDynamicLabel ( ) : å task . getActivityLabel () ; f i n a l String name = t a s k . getActivityName ( ) ; f i n a l String d i s p l a y = l a b e l != n u l l ? l a b e l : name ; f i n a l A c t i v i t y I n s t a n c e U U I D taskUUID = t a s k . getUUID ( ) ; f i n a l P r o c e s s D e f i n i t i o n U U I D processUUID = t a s k . g e t P r o c e s s D e f i n i t i o n U U I D ( ) ;
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125
A Bonita API használata
%> <%=d i s p l a y %> | <%=processUUID %> | ">D e t a i l s |
<%}%>
L i s t o f done t a s k s Name | P r o c e s s | A c t i o n s |
<% fo r ( L i g h t T a s k I n s t a n c e t a s k : d o n e T a s k L i s t ) { f i n a l String l a b e l = t a s k . getDynamicLabel ( ) != n u l l ? t a s k . getDynamicLabel ( ) : å task . getActivityLabel () ; f i n a l String name = t a s k . getActivityName ( ) ; f i n a l String d i s p l a y = l a b e l != n u l l ? l a b e l : name ; f i n a l A c t i v i t y I n s t a n c e U U I D taskUUID = t a s k . getUUID ( ) ; f i n a l P r o c e s s D e f i n i t i o n U U I D processUUID = t a s k . g e t P r o c e s s D e f i n i t i o n U U I D ( ) ; %> <%=d i s p l a y %> | <%=processUUID %> | ">D e t a i l s |
<%}%>
L i s t o f p r o c e s s e s Name | V e r s i o n | A c t i o n s |
<%
141
Business Process Management 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145
fo r ( L i g h t P r o c e s s D e f i n i t i o n p r o c e s s : e n a b l e d P r o c e s s e s ) { f i n a l P r o c e s s D e f i n i t i o n U U I D processUUID = p r o c e s s . getUUID ( ) ; %> <%=p r o c e s s . g e t L a b e l ( ) %> | <%=p r o c e s s . g e t V e r s i o n ( ) %> | ">C r e a t e a new i n s t a n c e  ;& nbsp ;& nbsp ; |
<%}%>
<%i f ( isAdmin ) {%> Manage p r o c e s s e s  ;& nbsp ;& nbsp ; Manage i n s t a n c e s  ;& nbsp ;& nbsp ; <%}%> <j s p : i n c l u d e page=" f o o t e r . html " />
Az apiCall.jsp lap szerepe A további 3 funkcionális jsp lap ismertetése előtt nézzük meg a actions/apiCall.jsp lapot, mert ez egy közös utility gyűjtemény a számukra, ezen keresztül használják a Bonita API-t (15-9. Programlista). A 26. sorig a már ismert előkészítő sorokat láthatjuk, azonban a 26-35 sorok között 2 nagyon érdekes, általánosan is használható technikát látunk, erre szeretnénk felhívni a figyelmet. A 26. sor back változója egy olyan jsp lap nevét tudja átvenni a kérést kezdeményező laptól, ahova az üzleti logika lefutása után a 167. sorban vissza tudjuk irányítani a válaszlap küldést. Itt tehát a működés az, hogy egy lap hívja ezt az apiCall.jsp lapot egy back paraméterrel, ahova 1 2 3 4 5 6 7 8
A Bonita API használata
a választ vissza lehet redirect-álni, természetesen az üzleti logika eredményével felszerelve. A másik érdekesség, hogy a 31. sorban lekért action paraméter vezérli azt, hogy az apiCall.jsp lap melyik részét kívánjuk használni. Az 52-54 sorok között a már ismert módon bejelentkezünk a security contex-be, hogy jogunk legyen az API használatára. A sok lehetséges action közül itt most nézzük az 56-62 sorok közötti archiveProcess-t (a többit mindenki nézze meg, mert mindegyikből sokat lehet tanulni). Az 58. sorból látható, hogy ekkor egy processUUID paraméterre is számítunk a HTTP session-ről. A 60-61 sorokban a ManagementAPI segítségével archiváljuk ennek a processUUID azonosítójú processnek az adatait.
// 15 −9. P r o g r a m l i s t a : a c t i o n s / a p i C a l l . j s p f i l e t a r t a l m a <%@page <%@page <%@page <%@page <%@page <%@page
142
import=" o r g . ow2 . b o n i t a . f a c a d e . uuid . A c t i v i t y I n s t a n c e U U I D "%> import=" o r g . ow2 . b o n i t a . u t i l . B u s i n e s s A r c h i v e F a c t o r y "%> import=" o r g . ow2 . b o n i t a . f a c a d e . d e f . majorElement . P r o c e s s D e f i n i t i o n "%> import=" o r g . ow2 . b o n i t a . f a c a d e . d e f . e l e m e n t . B u s i n e s s A r c h i v e "%> import=" j a v a . i o . FileNotFoundException "%> import=" j a v a . i o . F i l e "%>
Business Process Management 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
A Bonita API használata
<%@page import=" o r g . ow2 . b o n i t a . f a c a d e . uuid . ProcessInstanceUUID "%> <%@page import=" o r g . ow2 . b o n i t a . f a c a d e . RuntimeAPI"%> <%@page import=" j a v a . u t i l . HashSet "%> <%@page import=" j a v a . u t i l . S e t "%> <%@ page import=" j a v a x . s e c u r i t y . auth . l o g i n . LoginContext "%> <%@ <%@ <%@ <%@
page page page page
import=" o r g . ow2 . b o n i t a . f a c a d e . ManagementAPI"%> import=" o r g . ow2 . b o n i t a . f a c a d e . uuid . P r o c e s s D e f i n i t i o n U U I D "%> import=" o r g . ow2 . b o n i t a . u t i l . A c c e s s o r U t i l "%> import=" o r g . ow2 . b o n i t a . u t i l . S i m p l e C a l l b a c k H a n d l e r "%>
<% f i n a l Object isAdminObject = r e q u e s t . g e t S e s s i o n ( ) . g e t A t t r i b u t e ( " i s a d m i n " ) ; b o o l e a n isAdmin = f a l s e ; i f ( isAdminObject != n u l l && ( ( Boolean ) isAdminObject ) . b o o l e a n V a l u e ( ) ) { isAdmin = t r u e ; } f i n a l String back = r e q u e s t . ge tPar ame te r ( " back " ) ; i f ( back == n u l l ) { r e s p o n s e . s e n d R e d i r e c t ( " . . / home . j s p ?msg=No␣ r e t u r n ␣ page ␣was␣ s p e c i f i e d " ) ; } f i n a l String action = r e q u e s t . ge tPa ram et er ( " a c t i o n " ) ; i f ( action == n u l l ) { r e s p o n s e . s e n d R e d i r e c t ( " . . / " + back + " . j s p ?msg=N u l l ␣ a c t i o n " ) ; } f i n a l Set<String> adminOnlyActions = new HashSet<String>( ) ; adminOnlyActions . add ( " a r c h i v e P r o c e s s " ) ; adminOnlyActions . add ( " c a n c e l I n s t a n c e " ) ; adminOnlyActions . add ( " d e l e t e I n s t a n c e " ) ; adminOnlyActions . add ( " d e l e t e P r o c e s s " ) ; adminOnlyActions . add ( " d e p l o y P r o c e s s " ) ; adminOnlyActions . add ( " d i s a b l e P r o c e s s " ) ; adminOnlyActions . add ( " e n a b l e P r o c e s s " ) ; i f ( ! isAdmin && adminOnlyActions . c o n t a i n s ( a c t i o n ) ) { r e s p o n s e . s e n d R e d i r e c t ( " . . / home . j s p " ) ; } S t r i n g msg = n u l l ; S t r i n g errorMsg = n u l l ; try { f i n a l S t r i n g username = ( S t r i n g ) r e q u e s t . g e t S e s s i o n ( ) . g e t A t t r i b u t e ( " username "å ); f i n a l LoginContext l o g i n C o n t e x t = new LoginContext ( " B o n i t a S t o r e " , new å S i m p l e C a l l b a c k H a n d l e r ( username , " " ) ) ; loginContext . login () ; i f (" archiveProcess " . equals ( action ) ) { f i n a l S t r i n g processUUID = r e q u e s t . g etP ara me ter ( " processUUID " ) ;
143
Business Process Management 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
A Bonita API használata
errorMsg = " E r r o r ␣ w h i l e ␣ a r c h i v i n g ␣ p r o c e s s ␣ with ␣ uuid ␣ " + processUUID ; f i n a l ManagementAPI managementAPI = A c c e s s o r U t i l . getManagementAPI ( ) ; managementAPI . a r c h i v e ( new P r o c e s s D e f i n i t i o n U U I D ( processUUID ) ) ; msg = " P r o c e s s ␣ " + processUUID + " ␣ s u c c e s s f u l l y ␣ a r c h i v e d . " ; } e l s e i f (" cancelInstance " . equals ( action ) ) { f i n a l S t r i n g instanceUUID = r e q u e s t . g etP ara met er ( " instanceUUID " ) ; errorMsg = " E r r o r ␣ w h i l e ␣ c a n c e l i n g ␣ i n s t a n c e ␣ with ␣ uuid ␣ " + instanceUUID ; f i n a l RuntimeAPI runtimeAPI = A c c e s s o r U t i l . getRuntimeAPI ( ) ; runtimeAPI . c a n c e l P r o c e s s I n s t a n c e ( new ProcessInstanceUUID ( instanceUUID ) ) ; msg = " I n s t a n c e ␣ " + instanceUUID + " ␣was␣ s u c c e s s f u l l y ␣ c a n c e l e d . " ; } e l s e i f (" createInstance " . equals ( action ) ) { f i n a l S t r i n g processUUID = r e q u e s t . g etP ara me ter ( " processUUID " ) ; errorMsg = " E r r o r ␣ w h i l e ␣ c r e a t i n g ␣ a ␣new␣ i n s t a n c e ␣ o f ␣ p r o c e s s ␣ with ␣ uuid ␣ " + å processUUID ; f i n a l RuntimeAPI runtimeAPI = A c c e s s o r U t i l . getRuntimeAPI ( ) ; f i n a l ProcessInstanceUUID instanceUUID = runtimeAPI . i n s t a n t i a t e P r o c e s s ( new å P r o c e s s D e f i n i t i o n U U I D ( processUUID ) ) ; msg = "A␣new␣ i n s t a n c e ␣ o f ␣ p r o c e s s ␣ " + processUUID + " ␣was␣ s u c c e s s f u l l y ␣å c r e a t e d : ␣ " + instanceUUID ;
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105
} e l s e i f (" deleteInstance " . equals ( action ) ) { f i n a l S t r i n g instanceUUID = r e q u e s t . g etP ara met er ( " instanceUUID " ) ; errorMsg = " E r r o r ␣ w h i l e ␣ d e l e t e i n g ␣ i n s t a n c e ␣ with ␣ uuid ␣ " + instanceUUID ; f i n a l RuntimeAPI runtimeAPI = A c c e s s o r U t i l . getRuntimeAPI ( ) ; runtimeAPI . d e l e t e P r o c e s s I n s t a n c e ( new ProcessInstanceUUID ( instanceUUID ) ) ; msg = " I n s t a n c e ␣ " + instanceUUID + " ␣was␣ s u c c e s s f u l l y ␣ d e l e t e d . " ; } e l s e i f (" deleteProcess " . equals ( action ) ) { f i n a l S t r i n g processUUID = r e q u e s t . g etP ara me ter ( " processUUID " ) ; errorMsg = " E r r o r ␣ w h i l e ␣ d e l e t i n g ␣ p r o c e s s ␣ with ␣ uuid ␣ " + processUUID ; f i n a l ManagementAPI managementAPI = A c c e s s o r U t i l . getManagementAPI ( ) ; managementAPI . d e l e t e P r o c e s s ( new P r o c e s s D e f i n i t i o n U U I D ( processUUID ) ) ; msg = " P r o c e s s ␣ " + processUUID + " ␣ s u c c e s s f u l l y ␣ d e l e t e d . " ; } e l s e i f (" deployProcess " . equals ( action ) ) { f i n a l S t r i n g b a r F i l e = r e q u e s t . g etP ara met er ( " b a r F i l e " ) ; errorMsg = " E r r o r ␣ w h i l e ␣ d e p l o y i n g ␣ f i l e ␣ " + b a r F i l e ; f i n a l ManagementAPI managementAPI = A c c e s s o r U t i l . getManagementAPI ( ) ; f i n a l F i l e f i l e = new F i l e ( b a r F i l e ) ; i f (! f i l e . exists () ) { throw new FileNotFoundException ( b a r F i l e ) ; } f i n a l BusinessArchive businessArchive = BusinessArchiveFactory . å getBusinessArchive ( f i l e ) ; f i n a l P r o c e s s D e f i n i t i o n p r o c e s s = managementAPI . d e p l o y ( b u s i n e s s A r c h i v e ) ;
106
144
Business Process Management 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151
A Bonita API használata
msg = " P r o c e s s ␣ " + p r o c e s s . getUUID ( ) + " ␣ s u c c e s s f u l l y ␣ d e p l o y e d . " ; } e l s e i f (" disableProcess " . equals ( action ) ) { f i n a l S t r i n g processUUID = r e q u e s t . g etP ara met er ( " processUUID " ) ; errorMsg = " E r r o r ␣ w h i l e ␣ d i s a b e l i n g ␣ p r o c e s s ␣ with ␣ uuid ␣ " + processUUID ; f i n a l ManagementAPI managementAPI = A c c e s s o r U t i l . getManagementAPI ( ) ; managementAPI . d i s a b l e ( new P r o c e s s D e f i n i t i o n U U I D ( processUUID ) ) ; msg = " P r o c e s s ␣ " + processUUID + " ␣ s u c c e s s f u l l y ␣ d i s a b l e d . " ; } e l s e i f (" enableProcess " . equals ( action ) ) { f i n a l S t r i n g processUUID = r e q u e s t . g etP ara met er ( " processUUID " ) ; errorMsg = " E r r o r ␣ w h i l e ␣ e n a b e l i n g ␣ p r o c e s s ␣ with ␣ uuid ␣ " + processUUID ; f i n a l ManagementAPI managementAPI = A c c e s s o r U t i l . getManagementAPI ( ) ; managementAPI . e n a b l e ( new P r o c e s s D e f i n i t i o n U U I D ( processUUID ) ) ; msg = " P r o c e s s ␣ " + processUUID + " ␣ s u c c e s s f u l l y ␣ e n a b l e d . " ; } e l s e i f ( " executeTask " . equals ( a c t i o n ) ) { f i n a l S t r i n g taskUUID = r e q u e s t . g etP ara met er ( "taskUUID" ) ; errorMsg = " E r r o r ␣ w h i l e ␣ e x e c u t i n g ␣ t a s k ␣ with ␣ uuid ␣ " + taskUUID ; f i n a l RuntimeAPI runtimeAPI = A c c e s s o r U t i l . getRuntimeAPI ( ) ; runtimeAPI . e x e c u t e T a s k ( new A c t i v i t y I n s t a n c e U U I D ( taskUUID ) , t r u e ) ; msg = " Task ␣ " + taskUUID + " ␣was␣ s u c c e s s f u l l y ␣ e x e c u t e d . " ; } e l s e i f (" setActivityVariable " . equals ( action ) ) { f i n a l S t r i n g taskUUID = r e q u e s t . g etP ara met er ( "taskUUID" ) ; f i n a l S t r i n g variableName = r e q u e s t . g etP ara met er ( " variableName " ) ; f i n a l S t r i n g v a r i a b l e V a l u e = r e q u e s t . g etP ara met er ( " v a r i a b l e V a l u e " ) ; errorMsg = " E r r o r ␣ w h i l e ␣ u p d a t i n g ␣ v a r i a b l e ␣ with ␣name␣ " + variableName + " ␣å and␣ v a l u e ␣ " + v a r i a b l e V a l u e + " ␣on␣ t a s k ␣ " + taskUUID ; f i n a l RuntimeAPI runtimeAPI = A c c e s s o r U t i l . getRuntimeAPI ( ) ; runtimeAPI . s e t A c t i v i t y I n s t a n c e V a r i a b l e ( new A c t i v i t y I n s t a n c e U U I D ( taskUUID ) , å variableName , v a r i a b l e V a l u e ) ; msg = " V a r i a b l e ␣ " + variableName + " ␣was␣ s u c c e s s f u l l y ␣ updated ␣ with ␣ v a l u e ␣ " å + v a r i a b l e V a l u e + " ␣on␣ t a s k ␣ " + taskUUID + " . " ; } e l s e i f (" setProcessVariable " . equals ( action ) ) { f i n a l S t r i n g instanceUUID = r e q u e s t . g etP ara met er ( " instanceUUID " ) ; f i n a l S t r i n g variableName = r e q u e s t . g etP ara met er ( " variableName " ) ; f i n a l S t r i n g v a r i a b l e V a l u e = r e q u e s t . g etP ara met er ( " v a r i a b l e V a l u e " ) ; errorMsg = " E r r o r ␣ w h i l e ␣ u p d a t i n g ␣ v a r i a b l e ␣ with ␣name␣ " + variableName + " ␣å and␣ v a l u e ␣ " + v a r i a b l e V a l u e + " ␣on␣ i n s t a n c e ␣ " + instanceUUID ; f i n a l RuntimeAPI runtimeAPI = A c c e s s o r U t i l . getRuntimeAPI ( ) ; runtimeAPI . s e t P r o c e s s I n s t a n c e V a r i a b l e ( new ProcessInstanceUUID ( instanceUUID ) å , variableName , v a r i a b l e V a l u e ) ; msg = " V a r i a b l e ␣ " + variableName + " ␣was␣ s u c c e s s f u l l y ␣ updated ␣ with ␣ v a l u e ␣ " å + v a r i a b l e V a l u e + " ␣on␣ i n s t a n c e ␣ " + instanceUUID + " . " ;
152
145
Business Process Management
A Bonita API használata
153 } else { 154 r e s p o n s e . s e n d R e d i r e c t ( " . . / " + back + " . j s p ?msg=Unknown␣ a c t i o n : ␣ " + a c t i o n ) ; 155 } 156 157 158 loginContext . logout () ; 159 } catch ( Exception e ) { 160 e . printStackTrace () ; 161 Throwable t = e ; 162 w h i l e ( t . getCause ( ) != n u l l ) { 163 t = t . getCause ( ) ; 164 } 165 msg = errorMsg + " : ␣ " + t . getMessage ( ) ; 166 } 167 r e s p o n s e . s e n d R e d i r e c t ( " . . / " + back + " . j s p ?msg=" + msg ) ; 168 %> 1 // 15 −10. P r o g r a m l i s t a : a c t i o n s / l o g o u t . j s p f i l e t a r t a l m a 2 3 <% 4 r e q u e s t . g e t S e s s i o n ( ) . r e m o v e A t t r i b u t e ( " username " ) ; 5 r e q u e s t . g e t S e s s i o n ( ) . removeAttribute ( " isadmin " ) ; 6 response . sendRedirect ( " . . / index . jsp " ) ; 7 %>
A további jsp lapok A web alkalmazás további lapjai különféle funkciókat biztosítanak a felhasználó számára: • taskDetails.jsp (15-13. Programlista, 15.3. ábra): A kiválasztott feladat részleteit tekinthetjük meg, illetve, ha a task aktív, akkor azt változtathatjuk is. • processes.jsp (15-11. Programlista, 15.4. ábra): A folyamat mintákat tekinthetjük meg, illetve itt új folyamatot is létrehozhatunk, létezőt letilthatunk (azaz nem hozható létre ebből új instance) vagy törölhetünk. Ez az oldal még egy új Bonita folyamat (*.bar file) telepítését is támogatja. • instances.jsp (15-12. Programlista, 15.5. ábra): A folyamat példányok böngészését és menedzselését segíti. 146
15.3. ábra. A taskDetails.jsp lap kinézete
Business Process Management
15.4. ábra. A processes.jsp lap kinézete 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
A Bonita API használata
15.5. ábra. Az instances.jsp lap kinézete
// 15 −11. P r o g r a m l i s t a : p r o c e s s e s . j s p f i l e t a r t a l m a <%@ page import=" j a v a x . s e c u r i t y . auth . l o g i n . LoginContext "%> <%@ page import=" o r g . ow2 . b o n i t a . f a c a d e . Q u e r y D e f i n i t i o n A P I "%> <%@ page import=" o r g . ow2 . b o n i t a . l i g h t . L i g h t P r o c e s s D e f i n i t i o n "%> <%@page import=" o r g . ow2 . b o n i t a . f a c a d e . d e f . majorElement . P r o c e s s D e f i n i t i o n "%> <%@ page import=" o r g . ow2 . b o n i t a . f a c a d e . uuid . P r o c e s s D e f i n i t i o n U U I D "%> <%@ page import=" o r g . ow2 . b o n i t a . u t i l . A c c e s s o r U t i l "%> <%@ page import=" o r g . ow2 . b o n i t a . u t i l . S i m p l e C a l l b a c k H a n d l e r "%> <%@page import=" j a v a . u t i l . L i s t "%> <%@page import=" j a v a . u t i l . C o l l e c t i o n s "%> <% f i n a l Object isAdmin = r e q u e s t . g e t S e s s i o n ( ) . g e t A t t r i b u t e ( " i s a d m i n " ) ; i f ( isAdmin == n u l l | | ! ( ( Boolean ) isAdmin ) . b o o l e a n V a l u e ( ) ) { r e s p o n s e . s e n d R e d i r e c t ( "home . j s p " ) ; } f i n a l String msg = r e q u e s t . g etP ara met er ( "msg" ) ; f i n a l i n t numberOfElementsToRetrive = 2 0 ; L i s t j o u r n a l P r o c e s s e s = C o l l e c t i o n s . emptyList ( ) ; L i s t h i s t o r y P r o c e s s e s = C o l l e c t i o n s . emptyList ( ) ; try { f i n a l S t r i n g username = ( S t r i n g ) r e q u e s t . g e t S e s s i o n ( ) . g e t A t t r i b u t e ( " username " ) ; f i n a l LoginContext l o g i n C o n t e x t = new LoginContext ( " B o n i t a S t o r e " , new å S i m p l e C a l l b a c k H a n d l e r ( username , " " ) ) ; loginContext . login () ; f i n a l QueryDefinitionAPI journalQueryDefinitionAPI = A c c e s s o r U t i l . å
147
Business Process Management
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
A Bonita API használata
g e t Q u e r y D e f i n i t i o n A P I ( A c c e s s o r U t i l .QUERYLIST_JOURNAL_KEY) ; f i n a l QueryDefinitionAPI historyQueryDefinitionAPI = A c c e s s o r U t i l . å g e t Q u e r y D e f i n i t i o n A P I ( A c c e s s o r U t i l .QUERYLIST_HISTORY_KEY) ; journalProcesses = journalQueryDefinitionAPI . getLightProcesses (0 , å numberOfElementsToRetrive ) ; historyProcesses = historyQueryDefinitionAPI . getLightProcesses (0 , å numberOfElementsToRetrive ) ; loginContext . logout () ; } catch ( Exception e ) { e . printStackTrace () ; Throwable t = e ; w h i l e ( t . getCause ( ) != n u l l ) { t = t . getCause ( ) ; } f i n a l S t r i n g errorMsg = " E r r o r ␣ w h i l e ␣ l i s t i n g ␣ p r o c e s s e s : ␣ " + t . getMessage ( ) ; r e s p o n s e . s e n d R e d i r e c t ( "home . j s p ?msg=" + errorMsg ) ; } %>
<j s p : i n c l u d e page=" h e a d e r . html " />
<%i f ( msg != n u l l ) {%> <%=msg %>
<%}%>
L i s t o f j o u r n a l p r o c e s s e s (max : <%=numberOfElementsToRetrive %>) Name | V e r s i o n | A c t i o n s |
66 67 68 69 70 71 72 <% 73 fo r ( L i g h t P r o c e s s D e f i n i t i o n p r o c e s s : j o u r n a l P r o c e s s e s ) { 74 f i n a l P r o c e s s D e f i n i t i o n U U I D processUUID = p r o c e s s . getUUID ( ) ; 75 f i n a l ProcessDefinition . ProcessState state = process . getState () ;
148
Business Process Management 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92
A Bonita API használata
boolean isEnabled = true ; i f ( P r o c e s s D e f i n i t i o n . P r o c e s s S t a t e .DISABLED. e q u a l s ( s t a t e ) ) { isEnabled = f a l s e ; } %> <%=p r o c e s s . g e t L a b e l ( ) %> | <%=p r o c e s s . g e t V e r s i o n ( ) %> | <% i f ( i s E n a b l e d ) { %> ">C r e a t e a new i n s t a n c e  ;& nbsp ;& nbsp ; ">D i s a b l e  ;& nbsp ;& nbsp ; <%} e l s e {%> ">Enable  ;& nbsp ;& nbsp ; ">A r c h i v e  ;& nbsp ;& nbsp ; <%}%> ">D e l e t e  ;& nbsp ;& nbsp ; |
<%}%>
93 94 95 96 97 98
99 100 L i s t o f h i s t o r y p r o c e s s e s (max : <%=numberOfElementsToRetrive %>) 101 102 Name | 103 V e r s i o n | 104 A c t i o n s | 105
106 107 <% 108 fo r ( L i g h t P r o c e s s D e f i n i t i o n p r o c e s s : h i s t o r y P r o c e s s e s ) { 109 f i n a l P r o c e s s D e f i n i t i o n U U I D processUUID = p r o c e s s . getUUID ( ) ; 110 %> 111 112 113 <%=p r o c e s s . g e t L a b e l ( ) %> | 114 <%=p r o c e s s . g e t V e r s i o n ( ) %> | 115 116 ">D e l e t e  ;& nbsp ;& nbsp ; 117 | 118
119 <%}%> 120
149
Business Process Management 121 122 123 124 125
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
A Bonita API használata
Home  ;& nbsp ;& nbsp ; Manage i n s t a n c e s  ;& nbsp ;& nbsp ; <j s p : i n c l u d e page=" f o o t e r . html " />
// 15 −12. P r o g r a m l i s t a : i n s t a n c e s . j s p f i l e t a r t a l m a <%@ page import=" j a v a x . s e c u r i t y . auth . l o g i n . LoginContext "%> <%@ page import=" o r g . ow2 . b o n i t a . f a c a d e . QueryRuntimeAPI"%> <%@ page import=" o r g . ow2 . b o n i t a . l i g h t . L i g h t P r o c e s s I n s t a n c e "%> <%@ page import=" o r g . ow2 . b o n i t a . f a c a d e . uuid . P r o c e s s D e f i n i t i o n U U I D "%> <%@page import=" o r g . ow2 . b o n i t a . f a c a d e . uuid . ProcessInstanceUUID "%> <%@ page import=" o r g . ow2 . b o n i t a . u t i l . A c c e s s o r U t i l "%> <%@ page import=" o r g . ow2 . b o n i t a . u t i l . S i m p l e C a l l b a c k H a n d l e r "%> <%@page import=" j a v a . u t i l . L i s t "%> <%@page import=" j a v a . u t i l . C o l l e c t i o n s "%> <% f i n a l Object isAdmin = r e q u e s t . g e t S e s s i o n ( ) . g e t A t t r i b u t e ( " i s a d m i n " ) ; i f ( isAdmin == n u l l | | ! ( ( Boolean ) isAdmin ) . b o o l e a n V a l u e ( ) ) { r e s p o n s e . s e n d R e d i r e c t ( "home . j s p " ) ; } f i n a l String msg = r e q u e s t . g etP ara met er ( "msg" ) ; f i n a l i n t numberOfElementsToRetrive = 2 0 ; L i s t j o u r n a l I n s t a n c e s = C o l l e c t i o n s . emptyList ( ) ; L i s t h i s t o r y I n s t a n c e s = C o l l e c t i o n s . emptyList ( ) ; try { f i n a l S t r i n g username = ( S t r i n g ) r e q u e s t . g e t S e s s i o n ( ) . g e t A t t r i b u t e ( " username " ) ; f i n a l LoginContext l o g i n C o n t e x t = new LoginContext ( " B o n i t a S t o r e " , new å S i m p l e C a l l b a c k H a n d l e r ( username , " " ) ) ; loginContext . login () ; f i n a l QueryRuntimeAPI journalQueryRuntimeAPI = A c c e s s o r U t i l . getQueryRuntimeAPI ( å A c c e s s o r U t i l .QUERYLIST_JOURNAL_KEY) ; f i n a l QueryRuntimeAPI historyQueryRuntimeAPI = A c c e s s o r U t i l . getQueryRuntimeAPI ( å A c c e s s o r U t i l .QUERYLIST_HISTORY_KEY) ; j o u r n a l I n s t a n c e s = journalQueryRuntimeAPI . g e t L i g h t P r o c e s s I n s t a n c e s ( 0 , å numberOfElementsToRetrive ) ; h i s t o r y I n s t a n c e s = historyQueryRuntimeAPI . g e t L i g h t P r o c e s s I n s t a n c e s ( 0 , å numberOfElementsToRetrive ) ; loginContext . logout () ; } catch ( Exception e ) { e . printStackTrace () ; Throwable t = e ; w h i l e ( t . getCause ( ) != n u l l ) { t = t . getCause ( ) ;
150
Business Process Management 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
A Bonita API használata
} f i n a l S t r i n g errorMsg = " E r r o r ␣ w h i l e ␣ l i s t i n g ␣ i n s t a n c e s : ␣ " + t . getMessage ( ) ; r e s p o n s e . s e n d R e d i r e c t ( "home . j s p ?msg=" + errorMsg ) ; } %>
<j s p : i n c l u d e page=" h e a d e r . html " />
<%i f ( msg != n u l l ) {%> <%=msg %>
<%}%> L i s t o f j o u r n a l i n s t a n c e s (max : <%=numberOfElementsToRetrive %>) Name | V e r s i o n | I n s t a n c e number | A c t i o n s |
<% fo r ( L i g h t P r o c e s s I n s t a n c e i n s t a n c e : j o u r n a l I n s t a n c e s ) { f i n a l ProcessInstanceUUID instanceUUID = i n s t a n c e . getUUID ( ) ; f i n a l P r o c e s s D e f i n i t i o n U U I D processUUID = i n s t a n c e . g e t P r o c e s s D e f i n i t i o n U U I D ( ) ; f i n a l String processName = processUUID . getProcessName ( ) ; f i n a l String p r o c e s s V e r s i o n = processUUID . g e t P r o c e s s V e r s i o n ( ) ; f i n a l l o n g i n s t a n c e N b = instanceUUID . g e t I n s t a n c e N b ( ) ; %> <%=processName %> | <%=p r o c e s s V e r s i o n %> | <%=i n s t a n c e N b %> | ">Cancel  ; ">D e l e t e  ; |
<%}%>
81 82 83 84 85 86
87 88 L i s t o f h i s t o r y i n s t a n c e s (max : <%=numberOfElementsToRetrive %>)
151
Business Process Management 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
A Bonita API használata
Name | V e r s i o n | I n s t a n c e number | A c t i o n s |
<% fo r ( L i g h t P r o c e s s I n s t a n c e i n s t a n c e : h i s t o r y I n s t a n c e s ) { f i n a l ProcessInstanceUUID instanceUUID = i n s t a n c e . getUUID ( ) ; f i n a l P r o c e s s D e f i n i t i o n U U I D processUUID = i n s t a n c e . g e t P r o c e s s D e f i n i t i o n U U I D ( ) ; f i n a l String processName = processUUID . getProcessName ( ) ; f i n a l String p r o c e s s V e r s i o n = processUUID . g e t P r o c e s s V e r s i o n ( ) ; f i n a l l o n g i n s t a n c e N b = instanceUUID . g e t I n s t a n c e N b ( ) ; %> <%=processName %> | <%=p r o c e s s V e r s i o n %> | <%=i n s t a n c e N b %> | ">D e l e t e  ; |
<%}%>
Home  ;& nbsp ;& nbsp ; Manage p r o c e s s e s  ;& nbsp ;& nbsp ; <j s p : i n c l u d e page=" f o o t e r . html " />
// 15 −13. P r o g r a m l i s t a : t a s k D e t a i l s . j s p f i l e t a r t a l m a <%@page import=" o r g . ow2 . b o n i t a . f a c a d e . uuid . A c t i v i t y I n s t a n c e U U I D "%> <%@ page import=" j a v a x . s e c u r i t y . auth . l o g i n . LoginContext "%> <%@ page import=" o r g . ow2 . b o n i t a . f a c a d e . QueryRuntimeAPI"%> <%@ page import=" o r g . ow2 . b o n i t a . f a c a d e . uuid . ProcessInstanceUUID "%> <%@ page import=" o r g . ow2 . b o n i t a . u t i l . A c c e s s o r U t i l "%> <%@ page import=" o r g . ow2 . b o n i t a . u t i l . S i m p l e C a l l b a c k H a n d l e r "%> <%@page import=" o r g . ow2 . b o n i t a . f a c a d e . runtime . T a s k I n s t a n c e "%> <%@page import=" j a v a . u t i l . C o l l e c t i o n s "%> <%@page import=" j a v a . u t i l . Map"%> <%@page import=" o r g . ow2 . b o n i t a . f a c a d e . d e f . majorElement . A c t i v i t y D e f i n i t i o n "%> <%@page import=" o r g . ow2 . b o n i t a . f a c a d e . Q u e r y D e f i n i t i o n A P I "%> <%@page import=" j a v a . u t i l . S e t "%> <%@page import=" o r g . ow2 . b o n i t a . f a c a d e . d e f . majorElement . D a t a F i e l d D e f i n i t i o n "%> <%@page import=" j a v a . u t i l . HashMap"%> <%@page import=" o r g . ow2 . b o n i t a . f a c a d e . runtime . A c t i v i t y S t a t e "%> <%
152
Business Process Management 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
58 59 60 61 62 63
A Bonita API használata
f i n a l Object isAdminObject = r e q u e s t . g e t S e s s i o n ( ) . g e t A t t r i b u t e ( " i s a d m i n " ) ; f i n a l b o o l e a n isAdmin = isAdminObject != n u l l && ( ( Boolean ) isAdminObject ) . å booleanValue ( ) ; f i n a l String taskUUID = r e q u e s t . get Par ame ter ( "taskUUID" ) ; f i n a l String msg = r e q u e s t . g etP ara met er ( "msg" ) ; TaskInstance task = n u l l ; ProcessInstanceUUID instanceUUID = n u l l ; Map<String , String> l o c a l D a t a f i e l d s T y p e s = new HashMap<String , String>( ) ; Map<String , String> g l o b a l D a t a f i e l d s T y p e s = new HashMap<String , String>( ) ; Map<String , Object> l o c a l V a r i a b l e s = C o l l e c t i o n s . emptyMap ( ) ; Map<String , Object> g l o b a l V a r i a b l e s = C o l l e c t i o n s . emptyMap ( ) ; S t r i n g candidates = "" ; b o o l e a n isReady = f a l s e ; try { f i n a l S t r i n g username = ( S t r i n g ) r e q u e s t . g e t S e s s i o n ( ) . g e t A t t r i b u t e ( " username " ) ; f i n a l LoginContext l o g i n C o n t e x t = new LoginContext ( " B o n i t a S t o r e " , new å S i m p l e C a l l b a c k H a n d l e r ( username , " " ) ) ; loginContext . login () ; f i n a l A c t i v i t y I n s t a n c e U U I D a c t i v i t y I n s t a n c e U U I D = new A c t i v i t y I n s t a n c e U U I D ( å taskUUID ) ; instanceUUID = a c t i v i t y I n s t a n c e U U I D . g e t P r o c e s s I n s t a n c e U U I D ( ) ; f i n a l QueryRuntimeAPI queryRuntimeAPI = A c c e s s o r U t i l . getQueryRuntimeAPI ( ) ; f i n a l QueryDefinitionAPI queryDefinitionAPI = Ac c e s s o r U t i l . å getQueryDefinitionAPI () ; t a s k = queryRuntimeAPI . getTask ( a c t i v i t y I n s t a n c e U U I D ) ; isReady = A c t i v i t y S t a t e .READY. e q u a l s ( t a s k . g e t S t a t e ( ) ) ; l o c a l V a r i a b l e s = t a s k . getLastKnownVariableValues ( ) ; i f ( ! t a s k . g e t T a s k C a n d i d a t e s ( ) . isEmpty ( ) ) { f o r ( S t r i n g candidate : task . getTaskCandidates ( ) ) { c a n d i d a t e s += c a n d i d a t e + " , " ; } candidates = candidates . s u b s t r i n g (0 , candidates . length ( ) − 1) ; } g l o b a l V a r i a b l e s = queryRuntimeAPI . g e t P r o c e s s I n s t a n c e V a r i a b l e s ( instanceUUID ) ; f i n a l A c t i v i t y D e f i n i t i o n a c t i v i t y D e f i n i t i o n = queryDefinitionAPI . å g e t P r o c e s s A c t i v i t y ( instanceUUID . g e t P r o c e s s D e f i n i t i o n U U I D ( ) , å a c t i v i t y I n s t a n c e U U I D . getActivityName ( ) ) ; f i n a l S e t l o c a l D a t a f i e l d s = a c t i v i t y D e f i n i t i o n . å getDataFields () ; for ( DataFieldDefinition dataFieldDefinition : localDatafields ) { l o c a l D a t a f i e l d s T y p e s . put ( d a t a F i e l d D e f i n i t i o n . getName ( ) , d a t a F i e l d D e f i n i t i o n . å getDataTypeClassName ( ) ) ; } f i n a l S e t g l o b a l D a t a f i e l d s = q u e r y D e f i n i t i o n A P I . å
153
Business Process Management
64 65 66 67 68 69 70 71 72 73 74 75
A Bonita API használata
getProcessDataFields ( a c t i v i t y D e f i n i t i o n . getProcessDefinitionUUID () ) ; for ( DataFieldDefinition dataFieldDefinition : globalDatafields ) { g l o b a l D a t a f i e l d s T y p e s . put ( d a t a F i e l d D e f i n i t i o n . getName ( ) , d a t a F i e l d D e f i n i t i o n . å getDataTypeClassName ( ) ) ; }
loginContext . logout () ; } catch ( Exception e ) { e . printStackTrace () ; Throwable t = e ; w h i l e ( t . getCause ( ) != n u l l ) { t = t . getCause ( ) ; } f i n a l S t r i n g errorMsg = " E r r o r ␣ w h i l e ␣ g e t t i n g ␣ d e t a i l s ␣ o f ␣ t a s k ␣ with ␣ uuid ␣ " + å taskUUID + " : ␣ " + t . getMessage ( ) ; 76 r e s p o n s e . s e n d R e d i r e c t ( "home . j s p ?msg=" + errorMsg ) ; 77 } 78 %> 79 80 81 <j s p : i n c l u d e page=" h e a d e r . html " /> 82
83 84 <%i f ( msg != n u l l ) {%> 85 <%=msg %>
86 <%}%> 87 88 89 Task p r o p e r t i e s 90 91 Name | 92 Value | 93
94 95 Name | <%=t a s k . getActivityName ( ) %> |
96 L ab el | <%=t a s k . g e t A c t i v i t y L a b e l ( ) %> |
97 Dynamic l a b e l | <%=t a s k . getDynamicLabel ( ) %> |
98 D e s c r i p t i o n | <%=t a s k . g e t A c t i v i t y D e s c r i p t i o n ( ) %> |
99 Dynamic l a b e l | <%=t a s k . g e t D y n a m i c D e s c r i p t i o n ( ) %> |
100 C r e a t i o n d a t e | <%=t a s k . g e t C r e a t e d D a t e ( ) %> |
101 Ready d a t e | <%=t a s k . getReadyDate ( ) %> |
102 S t a r t e d d a t e | <%=t a s k . g e t S t a r t e d D a t e ( ) %> |
103 S t a r t e d by | <%=t a s k . g e t S t a r t e d B y ( ) %> |
104 Ended d a t e | <%=t a s k . getEndedDate ( ) %> |
105 S t a r t e d by | <%=t a s k . getEndedBy ( ) %> |
106 Expected end d a t e | <%=t a s k . getExpectedEndDate ( ) %> |
107 P r i o r i t y | <%=t a s k . g e t P r i o r i t y ( ) %> |
108 S t a t e | <%=t a s k . g e t S t a t e ( ) %> |
109 A s s i g n e d u s e r | <%=t a s k . getTaskUser ( ) %> |
110 C a n d i d a t e s | <%=c a n d i d a t e s %> |
111 Task UUID | <%=t a s k . getUUID ( )%> |
112 P r o c e s s I n s t a n c e UUID | <%=t a s k . g e t P r o c e s s I n s t a n c e U U I D ( )%> |
154
Business Process Management
A Bonita API használata
113 P r o c e s s D e f i n i t i o n UUID | <%=t a s k . g e t P r o c e s s D e f i n i t i o n U U I D ( )%> | <å /TR> 114
A c t i v i t y D e f i n i t i o n UUID | <%=t a s k . g e t A c t i v i t y D e f i n i t i o n U U I D ( )%> |
115 116
117 118
119 120 L i s t o f l o c a l v a r i a b l e s 121 122 Name | 123 Value | 124 Type | 125 Action | 126
127 128 <% 129 fo r (Map. Entry<String , Object> v a r i a b l e : l o c a l V a r i a b l e s . e n t r y S e t ( ) ) { 130 f i n a l S t r i n g variableName = v a r i a b l e . getKey ( ) ; 131 f i n a l Object v a r i a b l e V a l u e = v a r i a b l e . g e t V a l u e ( ) ; 132 f i n a l S t r i n g type = l o c a l D a t a f i e l d s T y p e s . g e t ( variableName ) ; 133 %> 134 135 <%=variableName %> | 136 <%=v a r i a b l e V a l u e %> | 137 <%=type %> | 138 139 140 <%i f ( isReady ) {%> 141 149 <%}%> 150 | 151
152 <%}%> 153
154 155
156 157 L i s t o f g l o b a l v a r i a b l e s 158 159 Name | 160 Value | 161 Type |
155
Business Process Management
A Bonita API használata
162 Action | 163
164 <% 165 fo r (Map. Entry<String , Object> v a r i a b l e : g l o b a l V a r i a b l e s . e n t r y S e t ( ) ) { 166 f i n a l S t r i n g variableName = v a r i a b l e . getKey ( ) ; 167 f i n a l Object v a r i a b l e V a l u e = v a r i a b l e . g e t V a l u e ( ) ; 168 f i n a l S t r i n g type = g l o b a l D a t a f i e l d s T y p e s . g e t ( variableName ) ; 169 %> 170 171 <%=variableName %> | 172 <%=v a r i a b l e V a l u e %> | 173 <%=type %> | 174 175 <%i f ( isReady ) {%> 176 184 <%}%> 185 | 186
187 188 <%}%> 189
190
191 <%i f ( isReady ) {%> 192 ">Execute t h i s t a s k  ; 193 <%}%> 194 195 196
197 Home  ;& nbsp ;& nbsp ; 198 <%i f ( isAdmin ) {%> 199 Manage p r o c e s s e s  ;& nbsp ;& nbsp ; 200 Manage i n s t a n c e s  ;& nbsp ;& nbsp ; 201 <%}%> 202 203 <j s p : i n c l u d e page=" f o o t e r . html " />
156