01: /*******************************************************************************
02: * Licensed to the Apache Software Foundation (ASF) under one
03: * or more contributor license agreements. See the NOTICE file
04: * distributed with this work for additional information
05: * regarding copyright ownership. The ASF licenses this file
06: * to you under the Apache License, Version 2.0 (the
07: * "License"); you may not use this file except in compliance
08: * with the License. You may obtain a copy of the License at
09: *
10: * http://www.apache.org/licenses/LICENSE-2.0
11: *
12: * Unless required by applicable law or agreed to in writing,
13: * software distributed under the License is distributed on an
14: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15: * KIND, either express or implied. See the License for the
16: * specific language governing permissions and limitations
17: * under the License.
18: *******************************************************************************/package org.ofbiz.shark.requester;
19:
20: import java.util.Map;
21:
22: import org.ofbiz.entity.GenericValue;
23: import org.ofbiz.service.GenericRequester;
24: import org.ofbiz.service.ModelService;
25:
26: import org.enhydra.shark.api.SharkTransaction;
27: import org.enhydra.shark.api.client.wfbase.BaseException;
28: import org.enhydra.shark.api.client.wfmodel.InvalidPerformer;
29: import org.enhydra.shark.api.client.wfmodel.WfEventAudit;
30:
31: public class SimpleRequester extends AbstractRequester {
32:
33: public static final String module = SimpleRequester.class.getName();
34: protected GenericRequester req = null;
35: protected ModelService model = null;
36:
37: // new requester
38: public SimpleRequester(GenericValue userLogin, ModelService model,
39: GenericRequester req) {
40: super (userLogin);
41: this .model = model;
42: this .setServiceRequester(req);
43:
44: }
45:
46: public SimpleRequester(GenericValue userLogin, ModelService model) {
47: this (userLogin, model, null);
48: }
49:
50: // -------------------
51: // WfRequester methods
52: // -------------------
53:
54: public void receive_event(WfEventAudit event) throws BaseException,
55: InvalidPerformer {
56: if (this .req != null) {
57: Map out = model.makeValid(this .getWRD(event, null),
58: ModelService.OUT_PARAM);
59: req.receiveResult(out);
60: }
61: }
62:
63: public void receive_event(SharkTransaction sharkTransaction,
64: WfEventAudit event) throws BaseException, InvalidPerformer {
65: this .receive_event(event);
66: }
67:
68: // -------------
69: // local methods
70: // -------------
71:
72: public void setServiceRequester(GenericRequester req) {
73: this .req = req;
74: }
75:
76: public GenericRequester getServiceRequester() {
77: return this.req;
78: }
79: }
|