]> git.aero2k.de Git - tmp/jakarta-migration.git/blob
bbf1deb94f07ce02187a3e3adaa8747667df46b1
[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.loanout.nuxeo;
25
26 import java.util.Iterator;
27 import java.util.List;
28
29 import org.collectionspace.services.LoanoutJAXBSchema;
30 import org.collectionspace.services.common.document.DocumentWrapper;
31 import org.collectionspace.services.loanout.LoansoutCommon;
32 import org.collectionspace.services.loanout.LoansoutCommonList;
33 import org.collectionspace.services.loanout.LoansoutCommonList.LoanoutListItem;
34 import org.collectionspace.services.nuxeo.client.java.RemoteDocumentModelHandlerImpl;
35 import org.collectionspace.services.nuxeo.util.NuxeoUtils;
36 import org.nuxeo.ecm.core.api.DocumentModel;
37 import org.nuxeo.ecm.core.api.DocumentModelList;
38 import org.slf4j.Logger;
39 import org.slf4j.LoggerFactory;
40
41 /**
42  * The Class LoanoutDocumentModelHandler.
43  */
44 public class LoanoutDocumentModelHandler
45         extends RemoteDocumentModelHandlerImpl<LoansoutCommon, LoansoutCommonList> {
46
47     /** The logger. */
48     private final Logger logger = LoggerFactory.getLogger(LoanoutDocumentModelHandler.class);
49     
50     /** The loanout. */
51     private LoansoutCommon loanout;
52     
53     /** The loanout list. */
54     private LoansoutCommonList loanoutList;
55
56
57     /**
58      * Gets the common part.
59      *
60      * @return the common part
61      */
62     @Override
63     public LoansoutCommon getCommonPart() {
64         return loanout;
65     }
66
67     /**
68      * Sets the common part.
69      *
70      * @param loanout the new common part
71      */
72     @Override
73     public void setCommonPart(LoansoutCommon loanout) {
74         this.loanout = loanout;
75     }
76
77     /**
78      * Gets the common part list.
79      *
80      * @return the common part list
81      */
82     @Override
83     public LoansoutCommonList getCommonPartList() {
84         return loanoutList;
85     }
86
87     /**
88      * Sets the common part list.
89      *
90      * @param loanoutList the new common part list
91      */
92     @Override
93     public void setCommonPartList(LoansoutCommonList loanoutList) {
94         this.loanoutList = loanoutList;
95     }
96
97     /**
98      * Extract common part.
99      *
100      * @param wrapDoc the wrap doc
101      * @return the loansout common
102      * @throws Exception the exception
103      */
104     @Override
105     public LoansoutCommon extractCommonPart(DocumentWrapper<DocumentModel> wrapDoc)
106             throws Exception {
107         throw new UnsupportedOperationException();
108     }
109
110     /**
111      * Fill common part.
112      *
113      * @param loanoutObject the loanout object
114      * @param wrapDoc the wrap doc
115      * @throws Exception the exception
116      */
117     @Override
118     public void fillCommonPart(LoansoutCommon loanoutObject, DocumentWrapper<DocumentModel> wrapDoc) throws Exception {
119         throw new UnsupportedOperationException();
120     }
121
122     /**
123      * Extract common part list.
124      *
125      * @param wrapDoc the wrap doc
126      * @return the loansout common list
127      * @throws Exception the exception
128      */
129     @Override
130     public LoansoutCommonList extractCommonPartList(DocumentWrapper<DocumentModelList> wrapDoc) throws Exception {
131         LoansoutCommonList coList = extractPagingInfo(new LoansoutCommonList(), wrapDoc);
132         List<LoansoutCommonList.LoanoutListItem> list = coList.getLoanoutListItem();
133         Iterator<DocumentModel> iter = wrapDoc.getWrappedObject().iterator();
134         while(iter.hasNext()){
135             DocumentModel docModel = iter.next();
136             LoanoutListItem ilistItem = new LoanoutListItem();
137             ilistItem.setLoanOutNumber((String) docModel.getProperty(getServiceContext().getCommonPartLabel(),
138                     LoanoutJAXBSchema.LOAN_OUT_NUMBER));
139             ilistItem.setLoanReturnDate((String) docModel.getProperty(getServiceContext().getCommonPartLabel(),
140                     LoanoutJAXBSchema.LOAN_RETURN_DATE));
141             String id = NuxeoUtils.extractId(docModel.getPathAsString());
142             ilistItem.setUri(getServiceContextPath() + id);
143             ilistItem.setCsid(id);
144             list.add(ilistItem);
145         }
146
147         return coList;
148     }
149
150     /**
151      * Gets the q property.
152      *
153      * @param prop the prop
154      * @return the q property
155      */
156     @Override
157     public String getQProperty(String prop) {
158         return LoanoutConstants.NUXEO_SCHEMA_NAME + ":" + prop;
159     }
160  
161 }
162