KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > opencrx > kernel > workflow > SendAlert


1 /*
2  * ====================================================================
3  * Project: opencrx, http://www.opencrx.org/
4  * Name: $Id: SendAlert.java,v 1.9 2005/09/25 23:16:16 wfro Exp $
5  * Description: PrintConsole workflow
6  * Revision: $Revision: 1.9 $
7  * Owner: CRIXP AG, Switzerland, http://www.crixp.com
8  * Date: $Date: 2005/09/25 23:16:16 $
9  * ====================================================================
10  *
11  * This software is published under the BSD license
12  * as listed below.
13  *
14  * Copyright (c) 2004, CRIXP Corp., Switzerland
15  * All rights reserved.
16  *
17  * Redistribution and use in source and binary forms, with or without
18  * modification, are permitted provided that the following conditions
19  * are met:
20  *
21  * * Redistributions of source code must retain the above copyright
22  * notice, this list of conditions and the following disclaimer.
23  *
24  * * Redistributions in binary form must reproduce the above copyright
25  * notice, this list of conditions and the following disclaimer in
26  * the documentation and/or other materials provided with the
27  * distribution.
28  *
29  * * Neither the name of CRIXP Corp. nor the names of the contributors
30  * to openCRX may be used to endorse or promote products derived
31  * from this software without specific prior written permission
32  *
33  *
34  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
35  * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
36  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
37  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
38  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
39  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
40  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
41  * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
42  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
43  * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
44  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
45  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
46  * POSSIBILITY OF SUCH DAMAGE.
47  *
48  * ------------------
49  *
50  * This product includes software developed by the Apache Software
51  * Foundation (http://www.apache.org/).
52  *
53  * This product includes software developed by contributors to
54  * openMDX (http://www.openmdx.org/)
55  */

56 package org.opencrx.kernel.workflow;
57
58 import java.util.Iterator JavaDoc;
59 import java.util.Map JavaDoc;
60 import java.util.Map.Entry;
61
62 import org.opencrx.kernel.layer.application.OpenCrxKernel_1;
63 import org.opencrx.kernel.layer.application.SynchWorkflow_1_0;
64 import org.openmdx.base.exception.ServiceException;
65 import org.openmdx.compatibility.base.dataprovider.cci.DataproviderObject;
66 import org.openmdx.compatibility.base.dataprovider.cci.DataproviderObject_1_0;
67 import org.openmdx.compatibility.base.dataprovider.cci.RequestCollection;
68 import org.openmdx.compatibility.base.dataprovider.cci.ServiceHeader;
69 import org.openmdx.compatibility.base.naming.Path;
70
71 public class SendAlert
72     implements SynchWorkflow_1_0 {
73
74     /* (non-Javadoc)
75      * @see org.opencrx.kernel.layer.application.Workflow_1_0#execute(org.openmdx.compatibility.base.dataprovider.cci.ServiceHeader, org.openmdx.compatibility.base.dataprovider.cci.DataproviderObject_1_0, org.openmdx.compatibility.base.dataprovider.cci.DataproviderObject_1_0, org.opencrx.kernel.layer.application.OpenCrxKernel_1, org.openmdx.compatibility.base.dataprovider.cci.RequestCollection)
76      */

77     public void execute(
78         DataproviderObject_1_0 userHome,
79         Path targetObjectIdentity,
80         Map JavaDoc params,
81         Path wfProcessInstanceIdentity,
82         ServiceHeader header,
83         RequestCollection delegation,
84         OpenCrxKernel_1 plugin
85     ) throws ServiceException {
86         DataproviderObject sendAlertParams = new DataproviderObject(new Path(""));
87         sendAlertParams.values("toUsers").add(
88             userHome.path().getBase()
89         );
90         sendAlertParams.values("name").add("SendAlert notification");
91         String JavaDoc description = "";
92         for(
93             Iterator JavaDoc i = params.entrySet().iterator();
94             i.hasNext();
95         ) {
96             Entry e = (Entry)i.next();
97             description += e.getKey() + "=" + e.getValue() + "\n";
98         }
99         sendAlertParams.values("description").add(description);
100         sendAlertParams.values("importance").add(new Integer JavaDoc(5));
101         sendAlertParams.values("reference").add(targetObjectIdentity);
102         try {
103             plugin.sendAlert(
104                 header,
105                 targetObjectIdentity,
106                 sendAlertParams
107             );
108         }
109         catch(ServiceException e) {
110             System.out.println("can not execute workflow SendAlert. Reason " + e.getMessage());
111         }
112     }
113
114 }
115
116 //--- End of File -----------------------------------------------------------
117
Popular Tags