Rev 1716 | Rev 1725 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1714 | jmachado | 1 | <%@ page import="jomm.dao.DaoException" %> |
1675 | jmachado | 2 | <%@ page import="jomm.dao.impl.AbstractDao" %> |
3 | <%@ page import="org.hibernate.Criteria" %> |
||
4 | <%@ page import="org.hibernate.criterion.Criterion" %> |
||
1692 | jmachado | 5 | |
1714 | jmachado | 6 | <%@ page import="org.hibernate.criterion.Order" %> |
1675 | jmachado | 7 | <%@ page import="static org.hibernate.criterion.Restrictions.eq" %> |
8 | <%@ page import="static org.hibernate.criterion.Restrictions.or" %> |
||
1714 | jmachado | 9 | <%@ page import="pt.estgp.estgweb.domain.RepositoryDocument" %> |
10 | <%@ page import="pt.estgp.estgweb.domain.RepositoryDocumentCollection" %> |
||
11 | <%@ page import="pt.estgp.estgweb.domain.RepositoryDocumentInterfaceImpl" %> |
||
1692 | jmachado | 12 | <%@ page import="pt.estgp.estgweb.domain.dao.DaoFactory" %> |
1714 | jmachado | 13 | <%@ page import="pt.estgp.estgweb.services.data.repositorydocuments.interfaces.InterfaceBlock" %> |
1692 | jmachado | 14 | <%@ page import="pt.estgp.estgweb.services.data.repositorydocuments.interfaces.RepositoryInterface" %> |
1714 | jmachado | 15 | <%@ page import="java.util.List" %> |
1713 | jmachado | 16 | <%@ page import="static org.hibernate.criterion.Restrictions.le" %> |
17 | <%@ page import="static org.hibernate.criterion.Restrictions.*" %> |
||
1675 | jmachado | 18 | <%@ taglib uri="/WEB-INF/tlds/struts-html.tld" prefix="html" %> |
19 | <%@ taglib uri="/WEB-INF/tlds/struts-nested.tld" prefix="nested" %> |
||
20 | <%@ taglib uri="/WEB-INF/tlds/struts-logic.tld" prefix="logic" %> |
||
21 | <%@ taglib uri="/WEB-INF/tlds/struts-bean.tld" prefix="bean" %> |
||
22 | <%@ taglib uri="/WEB-INF/tlds/struts-tiles.tld" prefix="tiles" %> |
||
23 | <%@ taglib tagdir="/WEB-INF/tags" prefix="bacoTags" %> |
||
1714 | jmachado | 24 | <%@ taglib prefix="baco" uri="http://www.estgp.pt/baco/" %> |
1675 | jmachado | 25 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> |
26 | <% |
||
1692 | jmachado | 27 | String slugOrId = (String) request.getAttribute("slug"); |
28 | AbstractDao.getCurrentSession().beginTransaction(); |
||
1675 | jmachado | 29 | |
1692 | jmachado | 30 | RepositoryDocumentInterfaceImpl repositoryDocumentInterface; |
31 | try{ |
||
32 | repositoryDocumentInterface = DaoFactory.getRepositoryDocumentInterfaceDaoImpl().findBySlug(slugOrId); |
||
33 | } |
||
34 | catch(DaoException e) |
||
35 | { |
||
36 | response.sendError(404); |
||
37 | return; |
||
38 | } |
||
39 | RepositoryInterface loadedConfig = repositoryDocumentInterface.getRepositoryInterface(); |
||
40 | request.setAttribute("loadedConfig",loadedConfig); |
||
1675 | jmachado | 41 | |
42 | |||
43 | |||
44 | %> |
||
1692 | jmachado | 45 | <%--<jsp:useBean id="loadedConfig" type="pt.estgp.estgweb.services.data.repositorydocuments.interfaces.RepositoryInterface" scope="request"/> |
46 | --%> |
||
1703 | jmachado | 47 | <script> |
1714 | jmachado | 48 | <% |
49 | String toReplaceContainer; |
||
50 | String newContainer; |
||
51 | |||
52 | if(loadedConfig.isContainerFluid()) |
||
53 | { |
||
54 | toReplaceContainer = "container"; |
||
55 | newContainer = "container-fluid"; |
||
56 | } |
||
57 | else |
||
58 | { |
||
59 | toReplaceContainer = "container-fluid"; |
||
60 | newContainer = "container"; |
||
61 | } |
||
62 | %> |
||
63 | |||
64 | $(document).ready(function() |
||
65 | { |
||
66 | var toReplaceContainer = "<%=toReplaceContainer%>"; |
||
67 | var newContainer = "<%=newContainer%>"; |
||
68 | var containerToReplace = $("." + toReplaceContainer); |
||
69 | var containerToUse = $("." + newContainer); |
||
70 | if(containerToReplace) |
||
71 | { |
||
72 | containerToReplace.removeClass(toReplaceContainer); |
||
73 | containerToReplace.addClass(newContainer); |
||
74 | } |
||
75 | else if(!containerToUse) |
||
76 | { |
||
77 | $(".repository-interface").wrap("<div class='" + newContainer + "'></div>") |
||
78 | } |
||
1703 | jmachado | 79 | }); |
1712 | jmachado | 80 | |
81 | |||
1714 | jmachado | 82 | /********************************** |
83 | * FUNCIONALIDADE DE PESQUISA |
||
84 | * *******************************/ |
||
85 | |||
86 | $.extend($.expr[':'], { |
||
1712 | jmachado | 87 | 'containsi': function(elem, i, match, array) |
88 | { |
||
89 | return (elem.textContent || elem.innerText || '').toLowerCase() |
||
90 | .indexOf((match[3] || "").toLowerCase()) >= 0; |
||
91 | } |
||
92 | }); |
||
93 | $(document).ready( |
||
94 | function(){ |
||
95 | |||
96 | $("#documentFilterInput").unbind("click"); |
||
97 | $('#documentFilterInput').bind("keypress", function(e) { |
||
98 | if (e.keyCode == 13) { |
||
99 | e.preventDefault(); |
||
100 | return false; |
||
101 | } |
||
102 | }); |
||
103 | $("#documentFilterInput").keyup( |
||
104 | function(){ |
||
105 | if($("#documentFilterInput").val()=="") |
||
106 | { |
||
107 | $(".repository-document").show(); |
||
108 | } |
||
109 | else |
||
110 | { |
||
111 | var fields = $("#documentFilterInput").val().split(" "); |
||
112 | |||
113 | $(".repository-document").show(); |
||
114 | $(".repository-document").each( |
||
115 | function() |
||
116 | { |
||
117 | for(var i = 0; i < fields.length; i++) |
||
118 | { |
||
119 | if($(this).find(" *:containsi('"+fields[i]+"')").length == 0) |
||
120 | { |
||
121 | $(this).hide(); |
||
122 | break; |
||
123 | } |
||
124 | } |
||
125 | } |
||
126 | ); |
||
127 | } |
||
128 | } |
||
129 | ); |
||
130 | } |
||
131 | ); |
||
132 | |||
1703 | jmachado | 133 | </script> |
1675 | jmachado | 134 | <style> |
135 | body |
||
136 | { |
||
137 | background-color: white !important; |
||
138 | } |
||
139 | </style> |
||
140 | |||
141 | |||
1703 | jmachado | 142 | <div class="repository-interface"> |
1675 | jmachado | 143 | |
1703 | jmachado | 144 | <div class="repository-intro repository-interface-intro"> |
145 | <logic:equal value="true" name="loadedConfig" property="showTitle"> |
||
1712 | jmachado | 146 | <div class="repository-title clearfix"> |
1703 | jmachado | 147 | ${loadedConfig.title} |
1712 | jmachado | 148 | |
149 | |||
150 | <span class="pull-right" style="font-size: 0.7em;display: inline-block"> |
||
151 | <input class="form-control" id="documentFilterInput" type="text" style="width: 200px"/> |
||
152 | </span> |
||
153 | <span class="pull-right" style="font-size: 0.7em;margin-right: 5px; margin-top: 5px"> |
||
154 | Pesquisar Nesta Página: |
||
155 | </span> |
||
156 | |||
157 | |||
1703 | jmachado | 158 | </div> |
159 | </logic:equal> |
||
160 | <logic:equal value="true" name="loadedConfig" property="showDescription"> |
||
161 | <div class="repository-description"> |
||
162 | ${loadedConfig.description} |
||
163 | </div> |
||
164 | </logic:equal> |
||
165 | </div> |
||
1675 | jmachado | 166 | |
1692 | jmachado | 167 | <nested:iterate id="interfaceRow" name="loadedConfig" property="rows" type="pt.estgp.estgweb.services.data.repositorydocuments.interfaces.InterfaceRow"> |
168 | <div class="row"> |
||
1703 | jmachado | 169 | <div class="repository-intro"> |
170 | <logic:equal value="true" name="interfaceRow" property="showTitle"> |
||
171 | <div class="repository-title"> |
||
172 | ${interfaceRow.title} |
||
173 | </div> |
||
174 | </logic:equal> |
||
175 | <logic:equal value="true" name="interfaceRow" property="showDescription"> |
||
176 | <div class="repository-description"> |
||
177 | ${interfaceRow.description} |
||
178 | </div> |
||
179 | </logic:equal> |
||
180 | </div> |
||
1692 | jmachado | 181 | <nested:iterate id="interfaceColumn" name="interfaceRow" property="columns" type="pt.estgp.estgweb.services.data.repositorydocuments.interfaces.InterfaceColumn"> |
1703 | jmachado | 182 | <div class="col-md-${interfaceColumn.cols} repository-column"> |
183 | <div class="repository-intro"> |
||
184 | <logic:equal value="true" name="interfaceColumn" property="showTitle"> |
||
185 | <div class="repository-title"> |
||
186 | <span class="btn-xs glyphicon glyphicon-bookmark"></span> |
||
1692 | jmachado | 187 | ${interfaceColumn.title} |
1703 | jmachado | 188 | </div> |
189 | </logic:equal> |
||
190 | <logic:equal value="true" name="interfaceColumn" property="showDescription"> |
||
191 | <div class="repository-description"> |
||
192 | ${interfaceColumn.description} |
||
193 | </div> |
||
194 | </logic:equal> |
||
195 | </div> |
||
1675 | jmachado | 196 | |
1714 | jmachado | 197 | |
1692 | jmachado | 198 | <nested:iterate id="interfaceBlock" name="interfaceColumn" property="blocks" type="pt.estgp.estgweb.services.data.repositorydocuments.interfaces.InterfaceBlock"> |
1714 | jmachado | 199 | <% |
200 | List<Long> collections = interfaceBlock.getCollectionIds(); |
||
201 | %> |
||
1703 | jmachado | 202 | <div class="repository-block"> |
203 | <div class="repository-intro"> |
||
204 | <logic:equal value="true" name="interfaceBlock" property="showTitle"> |
||
205 | <div class="repository-title"> |
||
206 | <span class="btn-xs glyphicon glyphicon-bookmark"></span> |
||
1692 | jmachado | 207 | ${interfaceBlock.title} |
1703 | jmachado | 208 | </div> |
209 | </logic:equal> |
||
1717 | jmachado | 210 | <baco:hasRole role="admin,all,repositoryDocs"> |
211 | <logic:notEmpty name="interfaceBlock" property="collectionIds"> |
||
212 | <% |
||
213 | if(collections != null && collections.size() == 1) |
||
214 | { |
||
215 | request.setAttribute("colToAdd",collections.get(0)); |
||
216 | %> |
||
217 | <html:link styleClass="btn btn-xs btn-success pull-right" action="/user/repositoryEditDocument?repositoryCollectionId=${colToAdd}" target="_blank"> |
||
218 | <span class="glyphicon glyphicon-plus"></span> |
||
219 | </html:link> |
||
220 | <% |
||
221 | } |
||
222 | %> |
||
223 | </logic:notEmpty> |
||
224 | </baco:hasRole> |
||
1703 | jmachado | 225 | <logic:equal value="true" name="interfaceBlock" property="showDescription"> |
226 | <div class="repository-description"> |
||
227 | ${interfaceBlock.description} |
||
228 | </div> |
||
229 | </logic:equal> |
||
230 | </div> |
||
231 | <%! |
||
232 | |||
233 | public Criterion getAllCollectionsClauses(Long collectionId) |
||
234 | { |
||
235 | Criterion c; |
||
236 | RepositoryDocumentCollection col = DaoFactory.getRepositoryDocumentCollectionDaoImpl().load(collectionId); |
||
237 | c = eq("collection.id",col.getId()); |
||
238 | if( col.getChilds() != null && col.getChilds().size() > 0) |
||
239 | { |
||
240 | for(RepositoryDocumentCollection child: col.getChilds()) |
||
241 | { |
||
242 | Criterion cChilds = getAllCollectionsClauses(child.getId()); |
||
243 | if(cChilds != null) |
||
244 | c = or(c,cChilds); |
||
245 | } |
||
246 | } |
||
247 | return c; |
||
248 | } |
||
249 | |||
250 | %> |
||
1675 | jmachado | 251 | <% |
1703 | jmachado | 252 | |
1692 | jmachado | 253 | |
254 | |||
1675 | jmachado | 255 | |
1703 | jmachado | 256 | |
1714 | jmachado | 257 | |
1703 | jmachado | 258 | if(!interfaceBlock.isTree()) |
1675 | jmachado | 259 | { |
1703 | jmachado | 260 | Criteria c = AbstractDao.getCurrentSession().createCriteria(RepositoryDocument.class); |
261 | Criterion clauses = null; |
||
262 | for(Long collection : collections) |
||
1675 | jmachado | 263 | { |
1703 | jmachado | 264 | Criterion clausesCol = getAllCollectionsClauses(collection); |
265 | if(clauses == null) |
||
266 | clauses = clausesCol; |
||
267 | else |
||
268 | { |
||
269 | clauses = or(clauses,clausesCol); |
||
270 | } |
||
1675 | jmachado | 271 | } |
1703 | jmachado | 272 | c.add(clauses); |
273 | c.add(eq("visible",true)); |
||
1711 | jmachado | 274 | if(interfaceBlock.getOrderBy() == InterfaceBlock.Order.publishDateAsc) |
275 | c.addOrder(Order.asc("publishDate")); |
||
276 | else if(interfaceBlock.getOrderBy() == InterfaceBlock.Order.publishDateDesc) |
||
277 | c.addOrder(Order.desc("publishDate")); |
||
278 | else if(interfaceBlock.getOrderBy() == InterfaceBlock.Order.saveDateAsc) |
||
279 | c.addOrder(Order.asc("saveDate")); |
||
280 | else if(interfaceBlock.getOrderBy() == InterfaceBlock.Order.saveDateDesc) |
||
281 | c.addOrder(Order.desc("saveDate")); |
||
282 | else if(interfaceBlock.getOrderBy() == InterfaceBlock.Order.updateDateAsc) |
||
283 | c.addOrder(Order.desc("updateDate")); |
||
284 | else if(interfaceBlock.getOrderBy() == InterfaceBlock.Order.updateDateDesc) |
||
285 | c.addOrder(Order.desc("updateDate")); |
||
286 | else if(interfaceBlock.getOrderBy() == InterfaceBlock.Order.title) |
||
287 | c.addOrder(Order.asc("title")); |
||
288 | |||
1713 | jmachado | 289 | if(interfaceBlock.getMaxPublishDate() != null && interfaceBlock.getMaxPublishDate().getTime() > 0) |
290 | { |
||
291 | c.add(le("publishDate", interfaceBlock.getMaxPublishDate())); |
||
292 | } |
||
293 | if(interfaceBlock.getMinPublishDate() != null && interfaceBlock.getMinPublishDate().getTime() > 0) |
||
294 | { |
||
295 | c.add(ge("publishDate", interfaceBlock.getMinPublishDate())); |
||
296 | } |
||
1703 | jmachado | 297 | List<RepositoryDocument> documents = c.list(); |
298 | request.setAttribute("documents",documents); |
||
299 | request.setAttribute("interfaceBlock",interfaceBlock); |
||
1692 | jmachado | 300 | |
1703 | jmachado | 301 | %> |
1711 | jmachado | 302 | <jsp:include page="showInterfaceDocsFragment.jsp"/> |
1703 | jmachado | 303 | <% |
304 | |||
305 | } |
||
306 | else |
||
307 | { |
||
308 | for(Long collection : collections) |
||
309 | { |
||
310 | RepositoryDocumentCollection col = DaoFactory.getRepositoryDocumentCollectionDaoImpl().get(collection); |
||
311 | for(RepositoryDocumentCollection child: col.getChilds()) |
||
312 | { |
||
313 | request.setAttribute("collection",child); |
||
314 | request.setAttribute("interfaceBlock",interfaceBlock); |
||
315 | %> |
||
1711 | jmachado | 316 | <jsp:include page="showInterfaceColFragment.jsp"/> |
1703 | jmachado | 317 | <% |
318 | } |
||
319 | } |
||
320 | } |
||
321 | %> |
||
1675 | jmachado | 322 | </div> |
1692 | jmachado | 323 | </nested:iterate> |
1675 | jmachado | 324 | |
1692 | jmachado | 325 | </div> |
326 | </nested:iterate> |
||
327 | </div> |
||
328 | </nested:iterate> |
||
329 | |||
1675 | jmachado | 330 | </div> |
331 | |||
332 | <% |
||
333 | AbstractDao.getCurrentSession().getTransaction().commit(); |
||
334 | %> |