]> git.aero2k.de Git - tmp/jakarta-migration.git/blob
b210545116f861167d39376ccc7c3a93617d5f99
[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 package org.collectionspace.services.movement.nuxeo;
25
26 import javax.ws.rs.core.MultivaluedMap;
27
28 import org.collectionspace.services.client.IQueryManager;
29 import org.collectionspace.services.movement.MovementResource;
30 import org.collectionspace.services.movement.MovementsCommon;
31 import org.collectionspace.services.nuxeo.client.java.DocHandlerBase;
32 import org.slf4j.Logger;
33 import org.slf4j.LoggerFactory;
34
35 /**
36  * The Class MovementDocumentModelHandler.
37  *
38  * $LastChangedRevision$
39  * $LastChangedDate$
40  */
41 public class MovementDocumentModelHandler
42         extends DocHandlerBase<MovementsCommon> {
43
44     final Logger logger = LoggerFactory.getLogger(MovementDocumentModelHandler.class);
45         
46     /**
47      * Creates the CMIS query from the service context.  Each document handler is responsible for returning a valid CMIS query using the
48      * information in the current service context -which includes things like the query parameters, etc.
49      */
50     @Override
51     public String getCMISQuery() {
52         String result = null;
53         
54         String subjectCsid = (String)getServiceContext().getQueryParams().get(IQueryManager.SEARCH_RELATED_TO_CSID_SUBJECT);
55         
56         //
57         // For Debugging purposes only
58         //
59         String cmis_movement = System.getenv("CMIS_MOVEMENT");
60
61         if (cmis_movement != null && !cmis_movement.isEmpty()) {
62                 result = cmis_movement;
63         } else {
64                 result = "SELECT M.cmis:name, M.dc:title, R.dc:title, R.relations_common:subjectCsid "
65                                 + "FROM Movement M JOIN Relation R ON R.relations_common:objectCsid = M.cmis:name "
66                                 + "WHERE R.relations_common:subjectCsid = "
67                                 + "'" + subjectCsid + "'";
68         }
69         
70         if (logger.isDebugEnabled() == true) {
71                 logger.debug("The CMIS query for the Movement service is: " + result);
72         }
73         
74         return result;
75     }
76         
77 }
78