Rev 1755 | Rev 1758 | 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 | |||
1755 | jmachado | 96 | |
97 | $('.repository-interface .collapse') |
||
1756 | jmachado | 98 | .on('shown.bs.collapse', function(e) { |
99 | if ($(this).is(e.target)) { |
||
100 | $(this) |
||
101 | .parent().eq(0) |
||
1755 | jmachado | 102 | .find(".glyphicon-plus").eq(0) |
103 | .removeClass("glyphicon-plus") |
||
104 | .addClass("glyphicon-minus"); |
||
1756 | jmachado | 105 | } |
1755 | jmachado | 106 | }) |
1756 | jmachado | 107 | .on('hidden.bs.collapse', function(e) { |
108 | if ($(this).is(e.target)) { |
||
109 | $(this) |
||
110 | .parent().eq(0) |
||
111 | .find(".glyphicon-minus").eq(0) |
||
112 | .removeClass("glyphicon-minus") |
||
113 | .addClass("glyphicon-plus"); |
||
114 | } |
||
1755 | jmachado | 115 | }); |
116 | |||
117 | |||
118 | |||
1712 | jmachado | 119 | $("#documentFilterInput").unbind("click"); |
120 | $('#documentFilterInput').bind("keypress", function(e) { |
||
121 | if (e.keyCode == 13) { |
||
122 | e.preventDefault(); |
||
123 | return false; |
||
124 | } |
||
125 | }); |
||
126 | $("#documentFilterInput").keyup( |
||
127 | function(){ |
||
128 | if($("#documentFilterInput").val()=="") |
||
129 | { |
||
130 | $(".repository-document").show(); |
||
131 | } |
||
132 | else |
||
133 | { |
||
1755 | jmachado | 134 | $('.repository-interface .collapse').collapse('show'); |
1712 | jmachado | 135 | var fields = $("#documentFilterInput").val().split(" "); |
136 | |||
137 | $(".repository-document").show(); |
||
138 | $(".repository-document").each( |
||
139 | function() |
||
140 | { |
||
141 | for(var i = 0; i < fields.length; i++) |
||
142 | { |
||
143 | if($(this).find(" *:containsi('"+fields[i]+"')").length == 0) |
||
144 | { |
||
145 | $(this).hide(); |
||
146 | break; |
||
147 | } |
||
148 | } |
||
149 | } |
||
150 | ); |
||
151 | } |
||
152 | } |
||
153 | ); |
||
1755 | jmachado | 154 | |
155 | |||
1712 | jmachado | 156 | } |
157 | ); |
||
158 | |||
1755 | jmachado | 159 | function toogleId() |
160 | { |
||
161 | |||
162 | } |
||
163 | |||
1703 | jmachado | 164 | </script> |
1675 | jmachado | 165 | <style> |
166 | body |
||
167 | { |
||
168 | background-color: white !important; |
||
169 | } |
||
170 | </style> |
||
171 | |||
172 | |||
1703 | jmachado | 173 | <div class="repository-interface"> |
1675 | jmachado | 174 | |
1703 | jmachado | 175 | <div class="repository-intro repository-interface-intro"> |
176 | <logic:equal value="true" name="loadedConfig" property="showTitle"> |
||
1712 | jmachado | 177 | <div class="repository-title clearfix"> |
1703 | jmachado | 178 | ${loadedConfig.title} |
1712 | jmachado | 179 | |
180 | |||
181 | <span class="pull-right" style="font-size: 0.7em;display: inline-block"> |
||
182 | <input class="form-control" id="documentFilterInput" type="text" style="width: 200px"/> |
||
183 | </span> |
||
184 | <span class="pull-right" style="font-size: 0.7em;margin-right: 5px; margin-top: 5px"> |
||
185 | Pesquisar Nesta Página: |
||
186 | </span> |
||
187 | |||
188 | |||
1703 | jmachado | 189 | </div> |
190 | </logic:equal> |
||
191 | <logic:equal value="true" name="loadedConfig" property="showDescription"> |
||
192 | <div class="repository-description"> |
||
193 | ${loadedConfig.description} |
||
194 | </div> |
||
195 | </logic:equal> |
||
196 | </div> |
||
1675 | jmachado | 197 | |
1692 | jmachado | 198 | <nested:iterate id="interfaceRow" name="loadedConfig" property="rows" type="pt.estgp.estgweb.services.data.repositorydocuments.interfaces.InterfaceRow"> |
199 | <div class="row"> |
||
1703 | jmachado | 200 | <div class="repository-intro"> |
201 | <logic:equal value="true" name="interfaceRow" property="showTitle"> |
||
202 | <div class="repository-title"> |
||
203 | ${interfaceRow.title} |
||
204 | </div> |
||
205 | </logic:equal> |
||
206 | <logic:equal value="true" name="interfaceRow" property="showDescription"> |
||
207 | <div class="repository-description"> |
||
208 | ${interfaceRow.description} |
||
209 | </div> |
||
210 | </logic:equal> |
||
211 | </div> |
||
1692 | jmachado | 212 | <nested:iterate id="interfaceColumn" name="interfaceRow" property="columns" type="pt.estgp.estgweb.services.data.repositorydocuments.interfaces.InterfaceColumn"> |
1703 | jmachado | 213 | <div class="col-md-${interfaceColumn.cols} repository-column"> |
214 | <div class="repository-intro"> |
||
215 | <logic:equal value="true" name="interfaceColumn" property="showTitle"> |
||
216 | <div class="repository-title"> |
||
217 | <span class="btn-xs glyphicon glyphicon-bookmark"></span> |
||
1692 | jmachado | 218 | ${interfaceColumn.title} |
1703 | jmachado | 219 | </div> |
220 | </logic:equal> |
||
221 | <logic:equal value="true" name="interfaceColumn" property="showDescription"> |
||
222 | <div class="repository-description"> |
||
223 | ${interfaceColumn.description} |
||
224 | </div> |
||
225 | </logic:equal> |
||
226 | </div> |
||
1675 | jmachado | 227 | |
1714 | jmachado | 228 | |
1692 | jmachado | 229 | <nested:iterate id="interfaceBlock" name="interfaceColumn" property="blocks" type="pt.estgp.estgweb.services.data.repositorydocuments.interfaces.InterfaceBlock"> |
1714 | jmachado | 230 | <% |
231 | List<Long> collections = interfaceBlock.getCollectionIds(); |
||
232 | %> |
||
1755 | jmachado | 233 | |
234 | <% |
||
235 | |||
236 | String idChilds = "block_" + interfaceBlock.hashCode(); |
||
237 | |||
238 | |||
239 | //String toogleAttrs = interfaceBlock.isBrowseMinimizeMaximize() ? " data-toggle=\"collapse\" data-target=\"#" + idChilds + "\" " :""; |
||
240 | //String styleCol = interfaceBlock.isBrowseMinimizeMaximize() ? " style=\"cursor:hand; text-decoration:underline\" " :""; |
||
241 | |||
242 | String toogleAttrs = " data-toggle=\"collapse\" data-target=\"#" + idChilds + "\" " ; |
||
243 | String styleCol = " style=\"cursor:hand; text-decoration:underline\" "; |
||
244 | String folderIcon = !interfaceBlock.isTree() && interfaceBlock.isBrowseMinimizeMaximize() ? " glyphicon-plus " : " glyphicon-minus "; |
||
245 | |||
246 | |||
247 | %> |
||
1703 | jmachado | 248 | <div class="repository-block"> |
1755 | jmachado | 249 | <div class="repository-intro" <%=toogleAttrs%>> |
1703 | jmachado | 250 | <logic:equal value="true" name="interfaceBlock" property="showTitle"> |
1755 | jmachado | 251 | |
1703 | jmachado | 252 | <div class="repository-title"> |
1755 | jmachado | 253 | <span class="btn-xs glyphicon <%=folderIcon%>" style="margin-right: 5px"></span> |
1703 | jmachado | 254 | <span class="btn-xs glyphicon glyphicon-bookmark"></span> |
1755 | jmachado | 255 | <label <%=styleCol%>>${interfaceBlock.title}</label> |
1703 | jmachado | 256 | </div> |
257 | </logic:equal> |
||
1725 | jmachado | 258 | |
1717 | jmachado | 259 | <baco:hasRole role="admin,all,repositoryDocs"> |
260 | <logic:notEmpty name="interfaceBlock" property="collectionIds"> |
||
261 | <% |
||
1725 | jmachado | 262 | if(collections != null && collections.size() == 1 && !interfaceBlock.isTree()) |
1717 | jmachado | 263 | { |
264 | request.setAttribute("colToAdd",collections.get(0)); |
||
265 | %> |
||
266 | <html:link styleClass="btn btn-xs btn-success pull-right" action="/user/repositoryEditDocument?repositoryCollectionId=${colToAdd}" target="_blank"> |
||
267 | <span class="glyphicon glyphicon-plus"></span> |
||
268 | </html:link> |
||
269 | <% |
||
270 | } |
||
271 | %> |
||
272 | </logic:notEmpty> |
||
273 | </baco:hasRole> |
||
1703 | jmachado | 274 | <logic:equal value="true" name="interfaceBlock" property="showDescription"> |
275 | <div class="repository-description"> |
||
276 | ${interfaceBlock.description} |
||
277 | </div> |
||
278 | </logic:equal> |
||
279 | </div> |
||
1755 | jmachado | 280 | <div id="<%=idChilds%>" <%=!interfaceBlock.isTree() && interfaceBlock.isBrowseMinimizeMaximize() ? " class=\"repository-block-childs collapse\"" :" class=\"repository-block-childs collapse in \" "%>> |
1703 | jmachado | 281 | <%! |
282 | |||
283 | public Criterion getAllCollectionsClauses(Long collectionId) |
||
284 | { |
||
285 | Criterion c; |
||
286 | RepositoryDocumentCollection col = DaoFactory.getRepositoryDocumentCollectionDaoImpl().load(collectionId); |
||
287 | c = eq("collection.id",col.getId()); |
||
288 | if( col.getChilds() != null && col.getChilds().size() > 0) |
||
289 | { |
||
290 | for(RepositoryDocumentCollection child: col.getChilds()) |
||
291 | { |
||
292 | Criterion cChilds = getAllCollectionsClauses(child.getId()); |
||
293 | if(cChilds != null) |
||
294 | c = or(c,cChilds); |
||
295 | } |
||
296 | } |
||
297 | return c; |
||
298 | } |
||
299 | |||
1755 | jmachado | 300 | %> |
301 | <% |
||
1703 | jmachado | 302 | |
1692 | jmachado | 303 | |
304 | |||
1675 | jmachado | 305 | |
1703 | jmachado | 306 | |
1714 | jmachado | 307 | |
1755 | jmachado | 308 | if(!interfaceBlock.isTree()) |
1675 | jmachado | 309 | { |
1755 | jmachado | 310 | Criteria c = AbstractDao.getCurrentSession().createCriteria(RepositoryDocument.class); |
311 | Criterion clauses = null; |
||
312 | for(Long collection : collections) |
||
1703 | jmachado | 313 | { |
1755 | jmachado | 314 | Criterion clausesCol = getAllCollectionsClauses(collection); |
315 | if(clauses == null) |
||
316 | clauses = clausesCol; |
||
317 | else |
||
318 | { |
||
319 | clauses = or(clauses,clausesCol); |
||
320 | } |
||
1703 | jmachado | 321 | } |
1755 | jmachado | 322 | c.add(clauses); |
323 | c.add(eq("visible",true)); |
||
324 | if(interfaceBlock.getOrderBy() == InterfaceBlock.Order.publishDateAsc) |
||
325 | c.addOrder(Order.asc("publishDate")); |
||
326 | else if(interfaceBlock.getOrderBy() == InterfaceBlock.Order.publishDateDesc) |
||
327 | c.addOrder(Order.desc("publishDate")); |
||
328 | else if(interfaceBlock.getOrderBy() == InterfaceBlock.Order.saveDateAsc) |
||
329 | c.addOrder(Order.asc("saveDate")); |
||
330 | else if(interfaceBlock.getOrderBy() == InterfaceBlock.Order.saveDateDesc) |
||
331 | c.addOrder(Order.desc("saveDate")); |
||
332 | else if(interfaceBlock.getOrderBy() == InterfaceBlock.Order.updateDateAsc) |
||
333 | c.addOrder(Order.desc("updateDate")); |
||
334 | else if(interfaceBlock.getOrderBy() == InterfaceBlock.Order.updateDateDesc) |
||
335 | c.addOrder(Order.desc("updateDate")); |
||
336 | else if(interfaceBlock.getOrderBy() == InterfaceBlock.Order.title) |
||
337 | c.addOrder(Order.asc("title")); |
||
1711 | jmachado | 338 | |
1755 | jmachado | 339 | if(interfaceBlock.getMaxPublishDate() != null && interfaceBlock.getMaxPublishDate().getTime() > 0) |
340 | { |
||
341 | c.add(le("publishDate", interfaceBlock.getMaxPublishDate())); |
||
342 | } |
||
343 | if(interfaceBlock.getMinPublishDate() != null && interfaceBlock.getMinPublishDate().getTime() > 0) |
||
344 | { |
||
345 | c.add(ge("publishDate", interfaceBlock.getMinPublishDate())); |
||
346 | } |
||
347 | List<RepositoryDocument> documents = c.list(); |
||
348 | request.setAttribute("documents",documents); |
||
349 | request.setAttribute("interfaceBlock",interfaceBlock); |
||
1692 | jmachado | 350 | |
1755 | jmachado | 351 | %> |
352 | <jsp:include page="showInterfaceDocsFragment.jsp"/> |
||
353 | <% |
||
1703 | jmachado | 354 | |
1755 | jmachado | 355 | } |
356 | else |
||
1703 | jmachado | 357 | { |
1755 | jmachado | 358 | for(Long collection : collections) |
1703 | jmachado | 359 | { |
1755 | jmachado | 360 | RepositoryDocumentCollection col = DaoFactory.getRepositoryDocumentCollectionDaoImpl().get(collection); |
361 | for(RepositoryDocumentCollection child: col.getChilds()) |
||
362 | { |
||
363 | request.setAttribute("collection",child); |
||
364 | request.setAttribute("interfaceBlock",interfaceBlock); |
||
365 | %> |
||
366 | <jsp:include page="showInterfaceColFragment.jsp"/> |
||
367 | <% |
||
368 | } |
||
1703 | jmachado | 369 | } |
370 | } |
||
1755 | jmachado | 371 | %> |
372 | </div> |
||
1675 | jmachado | 373 | </div> |
1692 | jmachado | 374 | </nested:iterate> |
1675 | jmachado | 375 | |
1692 | jmachado | 376 | </div> |
377 | </nested:iterate> |
||
378 | </div> |
||
379 | </nested:iterate> |
||
380 | |||
1675 | jmachado | 381 | </div> |
382 | |||
383 | <% |
||
384 | AbstractDao.getCurrentSession().getTransaction().commit(); |
||
385 | %> |