]> git.aero2k.de Git - tmp/jakarta-migration.git/blob
60a7f299c3111f902d8eb8313411e3539d6fb99e
[tmp/jakarta-migration.git] /
1 /**
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:
5
6  *  http://www.collectionspace.org
7  *  http://wiki.collectionspace.org
8
9  *  Copyright 2009 University of California at Berkeley
10
11  *  Licensed under the Educational Community License (ECL), Version 2.0.
12  *  You may not use this file except in compliance with this License.
13
14  *  You may obtain a copy of the ECL 2.0 License at
15
16  *  https://source.collectionspace.org/collection-space/LICENSE.txt
17
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.
23  *//**
24  *  This document is a part of the source code and related artifacts
25  *  for CollectionSpace, an open source collections management system
26  *  for museums and related institutions:
27
28  *  http://www.collectionspace.org
29  *  http://wiki.collectionspace.org
30
31  *  Copyright 2009 University of California at Berkeley
32
33  *  Licensed under the Educational Community License (ECL), Version 2.0.
34  *  You may not use this file except in compliance with this License.
35
36  *  You may obtain a copy of the ECL 2.0 License at
37
38  *  https://source.collectionspace.org/collection-space/LICENSE.txt
39
40  *  Unless required by applicable law or agreed to in writing, software
41  *  distributed under the License is distributed on an "AS IS" BASIS,
42  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
43  *  See the License for the specific language governing permissions and
44  *  limitations under the License.
45  */
46 /*
47  * To change this template, choose Tools | Templates
48  * and open the template in the editor.
49  */
50 package org.collectionspace.services.common.storage.jpa;
51
52 import java.util.List;
53 import org.collectionspace.services.common.document.DocumentFilter;
54 import org.collectionspace.services.common.context.ServiceContext;
55
56 /**
57  * JPA query specific document filter
58  */
59 public class JpaDocumentFilter extends DocumentFilter {
60         
61         public static final String Q_ASC = "asc"; 
62         public static final String Q_DESC = "desc"; 
63         public static final String JPA_ASC = " ASC"; 
64         public static final String JPA_DESC = " DESC"; 
65
66     public JpaDocumentFilter(ServiceContext ctx) {
67         super(ctx);
68     }
69
70     /**
71      * addTenant adds tenant id to the where clause
72      * @param append indicates if append to existing where clause
73      * @param paramList
74      * @return whereClause with tenant context
75      */
76     protected String addTenant(boolean append, List<ParamBinding> paramList) {
77         String whereClause = "";
78         if (!append) {
79             whereClause = " WHERE tenantId = :tenantId";
80         } else {
81             whereClause = " AND tenantId = :tenantId";
82         }
83         paramList.add(new ParamBinding("tenantId", getTenantId()));
84         return whereClause;
85     }
86
87         @Override
88         public boolean getPageSizeDirty() {
89                 // TODO Auto-generated method stub
90                 return false;
91         }
92 }