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.minilang.method.entityops;
19:
20: import java.util.List;
21: import java.util.Map;
22:
23: import org.ofbiz.entity.util.EntityUtil;
24: import org.ofbiz.minilang.SimpleMethod;
25: import org.ofbiz.minilang.method.ContextAccessor;
26: import org.ofbiz.minilang.method.MethodContext;
27: import org.ofbiz.minilang.method.MethodOperation;
28: import org.w3c.dom.Element;
29:
30: /**
31: * Uses the delegator to find entity values by anding the map fields
32: */
33: public class FilterListByAnd extends MethodOperation {
34:
35: ContextAccessor listAcsr;
36: ContextAccessor toListAcsr;
37: ContextAccessor mapAcsr;
38:
39: public FilterListByAnd(Element element, SimpleMethod simpleMethod) {
40: super (element, simpleMethod);
41: listAcsr = new ContextAccessor(element
42: .getAttribute("list-name"));
43: toListAcsr = new ContextAccessor(element
44: .getAttribute("to-list-name"), element
45: .getAttribute("list-name"));
46: mapAcsr = new ContextAccessor(element.getAttribute("map-name"));
47: }
48:
49: public boolean exec(MethodContext methodContext) {
50: Map theMap = null;
51:
52: if (!mapAcsr.isEmpty()) {
53: theMap = (Map) mapAcsr.get(methodContext);
54: }
55: toListAcsr.put(methodContext, EntityUtil.filterByAnd(
56: (List) listAcsr.get(methodContext), theMap));
57: return true;
58: }
59:
60: public String rawString() {
61: // TODO: something more than the empty tag
62: return "<filter-list-by-and/>";
63: }
64:
65: public String expandedString(MethodContext methodContext) {
66: // TODO: something more than a stub/dummy
67: return this.rawString();
68: }
69: }
|