2 * This document is a part of the source code and related artifacts
3 * for CollectionSpace, an open source collections management system
4 * for museums and related institutions:
6 * http://www.collectionspace.org
7 * http://wiki.collectionspace.org
9 * Copyright 2009 University of California at Berkeley
11 * Licensed under the Educational Community License (ECL), Version 2.0.
12 * You may not use this file except in compliance with this License.
14 * You may obtain a copy of the ECL 2.0 License at
16 * https://source.collectionspace.org/collection-space/LICENSE.txt
18 * Unless required by applicable law or agreed to in writing, software
19 * distributed under the License is distributed on an "AS IS" BASIS,
20 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21 * See the License for the specific language governing permissions and
22 * limitations under the License.
26 package org.collectionspace.services.authorization.storage;
28 import java.util.ArrayList;
29 import java.util.List;
30 import org.collectionspace.services.common.storage.jpa.JpaDocumentFilter;
31 import org.slf4j.Logger;
32 import org.slf4j.LoggerFactory;
35 * PermissionJpaFilter is to build where clause for role queries
38 public class PermissionJpaFilter extends JpaDocumentFilter {
40 private final Logger logger = LoggerFactory.getLogger(PermissionJpaFilter.class);
43 public List<ParamBinding> buildWhereForSearch(StringBuilder queryStrBldr) {
45 List<ParamBinding> paramList = new ArrayList<ParamBinding>();
46 boolean hasWhere = false;
49 String resName = null;
50 List<String> rn = getQueryParam(PermissionStorageConstants.Q_RESOURCE_NAME);
54 if (null != resName && !resName.isEmpty()) {
56 queryStrBldr.append(" WHERE");
57 queryStrBldr.append(" UPPER(a." + PermissionStorageConstants.RESOURCE_NAME + ")");
58 queryStrBldr.append(" LIKE");
59 queryStrBldr.append(" :" + PermissionStorageConstants.Q_RESOURCE_NAME);
60 paramList.add(new ParamBinding(PermissionStorageConstants.Q_RESOURCE_NAME, "%"
61 + resName.toUpperCase() + "%"));
64 if (logger.isDebugEnabled()) {
65 String query = queryStrBldr.toString();
66 logger.debug("query=" + query);
73 public List<ParamBinding> buildWhere(StringBuilder queryStrBldr) {
74 return new ArrayList<ParamBinding>();