Rev 1703 | Rev 1712 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1675 | jmachado | 1 | <%@ page import="jomm.dao.impl.AbstractDao" %> |
2 | <%@ page import="org.hibernate.Criteria" %> |
||
3 | <%@ page import="org.hibernate.criterion.Criterion" %> |
||
4 | <%@ page import="pt.estgp.estgweb.domain.RepositoryDocument" %> |
||
1692 | jmachado | 5 | |
1675 | jmachado | 6 | <%@ page import="java.util.List" %> |
7 | <%@ page import="static org.hibernate.criterion.Restrictions.eq" %> |
||
8 | <%@ page import="static org.hibernate.criterion.Restrictions.or" %> |
||
9 | <%@ page import="org.hibernate.criterion.Order" %> |
||
1692 | jmachado | 10 | <%@ page import="pt.estgp.estgweb.domain.dao.DaoFactory" %> |
11 | <%@ page import="pt.estgp.estgweb.domain.RepositoryDocumentInterfaceImpl" %> |
||
12 | <%@ page import="jomm.dao.DaoException" %> |
||
13 | <%@ page import="pt.estgp.estgweb.services.data.repositorydocuments.interfaces.RepositoryInterface" %> |
||
1703 | jmachado | 14 | <%@ page import="pt.estgp.estgweb.domain.RepositoryDocumentCollection" %> |
15 | <%@ page import="org.hibernate.mapping.Collection" %> |
||
1711 | jmachado | 16 | <%@ page import="pt.estgp.estgweb.services.data.repositorydocuments.interfaces.InterfaceBlock" %> |
1675 | jmachado | 17 | <%@ taglib uri="/WEB-INF/tlds/struts-html.tld" prefix="html" %> |
18 | <%@ taglib uri="/WEB-INF/tlds/struts-nested.tld" prefix="nested" %> |
||
19 | <%@ taglib uri="/WEB-INF/tlds/struts-logic.tld" prefix="logic" %> |
||
20 | <%@ taglib uri="/WEB-INF/tlds/struts-bean.tld" prefix="bean" %> |
||
21 | <%@ taglib uri="/WEB-INF/tlds/struts-tiles.tld" prefix="tiles" %> |
||
22 | <%@ taglib tagdir="/WEB-INF/tags" prefix="bacoTags" %> |
||
23 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> |
||
24 | <% |
||
1692 | jmachado | 25 | String slugOrId = (String) request.getAttribute("slug"); |
26 | AbstractDao.getCurrentSession().beginTransaction(); |
||
1675 | jmachado | 27 | |
1692 | jmachado | 28 | RepositoryDocumentInterfaceImpl repositoryDocumentInterface; |
29 | try{ |
||
30 | repositoryDocumentInterface = DaoFactory.getRepositoryDocumentInterfaceDaoImpl().findBySlug(slugOrId); |
||
31 | } |
||
32 | catch(DaoException e) |
||
33 | { |
||
34 | response.sendError(404); |
||
35 | return; |
||
36 | } |
||
37 | RepositoryInterface loadedConfig = repositoryDocumentInterface.getRepositoryInterface(); |
||
38 | request.setAttribute("loadedConfig",loadedConfig); |
||
1675 | jmachado | 39 | |
40 | |||
41 | |||
42 | %> |
||
1692 | jmachado | 43 | <%--<jsp:useBean id="loadedConfig" type="pt.estgp.estgweb.services.data.repositorydocuments.interfaces.RepositoryInterface" scope="request"/> |
44 | --%> |
||
1703 | jmachado | 45 | <script> |
46 | $(document).ready(function(){ |
||
47 | //var container = $(".container") |
||
48 | //container.removeClass("container"); |
||
49 | //container.addClass("container-fluid"); |
||
50 | }); |
||
51 | </script> |
||
1675 | jmachado | 52 | <style> |
53 | body |
||
54 | { |
||
55 | background-color: white !important; |
||
56 | } |
||
57 | </style> |
||
58 | |||
59 | |||
1703 | jmachado | 60 | <div class="repository-interface"> |
1675 | jmachado | 61 | |
1703 | jmachado | 62 | <div class="repository-intro repository-interface-intro"> |
63 | <logic:equal value="true" name="loadedConfig" property="showTitle"> |
||
64 | <div class="repository-title"> |
||
65 | ${loadedConfig.title} |
||
66 | </div> |
||
67 | </logic:equal> |
||
68 | <logic:equal value="true" name="loadedConfig" property="showDescription"> |
||
69 | <div class="repository-description"> |
||
70 | ${loadedConfig.description} |
||
71 | </div> |
||
72 | </logic:equal> |
||
73 | </div> |
||
1675 | jmachado | 74 | |
1692 | jmachado | 75 | <nested:iterate id="interfaceRow" name="loadedConfig" property="rows" type="pt.estgp.estgweb.services.data.repositorydocuments.interfaces.InterfaceRow"> |
76 | <div class="row"> |
||
1703 | jmachado | 77 | <div class="repository-intro"> |
78 | <logic:equal value="true" name="interfaceRow" property="showTitle"> |
||
79 | <div class="repository-title"> |
||
80 | ${interfaceRow.title} |
||
81 | </div> |
||
82 | </logic:equal> |
||
83 | <logic:equal value="true" name="interfaceRow" property="showDescription"> |
||
84 | <div class="repository-description"> |
||
85 | ${interfaceRow.description} |
||
86 | </div> |
||
87 | </logic:equal> |
||
88 | </div> |
||
1692 | jmachado | 89 | <nested:iterate id="interfaceColumn" name="interfaceRow" property="columns" type="pt.estgp.estgweb.services.data.repositorydocuments.interfaces.InterfaceColumn"> |
1703 | jmachado | 90 | <div class="col-md-${interfaceColumn.cols} repository-column"> |
91 | <div class="repository-intro"> |
||
92 | <logic:equal value="true" name="interfaceColumn" property="showTitle"> |
||
93 | <div class="repository-title"> |
||
94 | <span class="btn-xs glyphicon glyphicon-bookmark"></span> |
||
1692 | jmachado | 95 | ${interfaceColumn.title} |
1703 | jmachado | 96 | </div> |
97 | </logic:equal> |
||
98 | <logic:equal value="true" name="interfaceColumn" property="showDescription"> |
||
99 | <div class="repository-description"> |
||
100 | ${interfaceColumn.description} |
||
101 | </div> |
||
102 | </logic:equal> |
||
103 | </div> |
||
1675 | jmachado | 104 | |
1692 | jmachado | 105 | <nested:iterate id="interfaceBlock" name="interfaceColumn" property="blocks" type="pt.estgp.estgweb.services.data.repositorydocuments.interfaces.InterfaceBlock"> |
1703 | jmachado | 106 | <div class="repository-block"> |
107 | <div class="repository-intro"> |
||
108 | <logic:equal value="true" name="interfaceBlock" property="showTitle"> |
||
109 | <div class="repository-title"> |
||
110 | <span class="btn-xs glyphicon glyphicon-bookmark"></span> |
||
1692 | jmachado | 111 | ${interfaceBlock.title} |
1703 | jmachado | 112 | </div> |
113 | </logic:equal> |
||
114 | <logic:equal value="true" name="interfaceBlock" property="showDescription"> |
||
115 | <div class="repository-description"> |
||
116 | ${interfaceBlock.description} |
||
117 | </div> |
||
118 | </logic:equal> |
||
119 | </div> |
||
120 | <%! |
||
121 | |||
122 | public Criterion getAllCollectionsClauses(Long collectionId) |
||
123 | { |
||
124 | Criterion c; |
||
125 | RepositoryDocumentCollection col = DaoFactory.getRepositoryDocumentCollectionDaoImpl().load(collectionId); |
||
126 | c = eq("collection.id",col.getId()); |
||
127 | if( col.getChilds() != null && col.getChilds().size() > 0) |
||
128 | { |
||
129 | for(RepositoryDocumentCollection child: col.getChilds()) |
||
130 | { |
||
131 | Criterion cChilds = getAllCollectionsClauses(child.getId()); |
||
132 | if(cChilds != null) |
||
133 | c = or(c,cChilds); |
||
134 | } |
||
135 | } |
||
136 | return c; |
||
137 | } |
||
138 | |||
139 | %> |
||
1675 | jmachado | 140 | <% |
1703 | jmachado | 141 | |
1692 | jmachado | 142 | List<Long> collections = interfaceBlock.getCollectionIds(); |
143 | |||
144 | |||
1675 | jmachado | 145 | |
1703 | jmachado | 146 | |
147 | if(!interfaceBlock.isTree()) |
||
1675 | jmachado | 148 | { |
1703 | jmachado | 149 | Criteria c = AbstractDao.getCurrentSession().createCriteria(RepositoryDocument.class); |
150 | Criterion clauses = null; |
||
151 | for(Long collection : collections) |
||
1675 | jmachado | 152 | { |
1703 | jmachado | 153 | Criterion clausesCol = getAllCollectionsClauses(collection); |
154 | if(clauses == null) |
||
155 | clauses = clausesCol; |
||
156 | else |
||
157 | { |
||
158 | clauses = or(clauses,clausesCol); |
||
159 | } |
||
1675 | jmachado | 160 | } |
1703 | jmachado | 161 | c.add(clauses); |
162 | c.add(eq("visible",true)); |
||
1711 | jmachado | 163 | if(interfaceBlock.getOrderBy() == InterfaceBlock.Order.publishDateAsc) |
164 | c.addOrder(Order.asc("publishDate")); |
||
165 | else if(interfaceBlock.getOrderBy() == InterfaceBlock.Order.publishDateDesc) |
||
166 | c.addOrder(Order.desc("publishDate")); |
||
167 | else if(interfaceBlock.getOrderBy() == InterfaceBlock.Order.saveDateAsc) |
||
168 | c.addOrder(Order.asc("saveDate")); |
||
169 | else if(interfaceBlock.getOrderBy() == InterfaceBlock.Order.saveDateDesc) |
||
170 | c.addOrder(Order.desc("saveDate")); |
||
171 | else if(interfaceBlock.getOrderBy() == InterfaceBlock.Order.updateDateAsc) |
||
172 | c.addOrder(Order.desc("updateDate")); |
||
173 | else if(interfaceBlock.getOrderBy() == InterfaceBlock.Order.updateDateDesc) |
||
174 | c.addOrder(Order.desc("updateDate")); |
||
175 | else if(interfaceBlock.getOrderBy() == InterfaceBlock.Order.title) |
||
176 | c.addOrder(Order.asc("title")); |
||
177 | |||
1703 | jmachado | 178 | List<RepositoryDocument> documents = c.list(); |
179 | request.setAttribute("documents",documents); |
||
180 | request.setAttribute("interfaceBlock",interfaceBlock); |
||
1692 | jmachado | 181 | |
1703 | jmachado | 182 | %> |
1711 | jmachado | 183 | <jsp:include page="showInterfaceDocsFragment.jsp"/> |
1703 | jmachado | 184 | <% |
185 | |||
186 | } |
||
187 | else |
||
188 | { |
||
189 | for(Long collection : collections) |
||
190 | { |
||
191 | RepositoryDocumentCollection col = DaoFactory.getRepositoryDocumentCollectionDaoImpl().get(collection); |
||
192 | for(RepositoryDocumentCollection child: col.getChilds()) |
||
193 | { |
||
194 | request.setAttribute("collection",child); |
||
195 | request.setAttribute("interfaceBlock",interfaceBlock); |
||
196 | %> |
||
1711 | jmachado | 197 | <jsp:include page="showInterfaceColFragment.jsp"/> |
1703 | jmachado | 198 | <% |
199 | } |
||
200 | } |
||
201 | } |
||
202 | %> |
||
1675 | jmachado | 203 | </div> |
1692 | jmachado | 204 | </nested:iterate> |
1675 | jmachado | 205 | |
1692 | jmachado | 206 | </div> |
207 | </nested:iterate> |
||
208 | </div> |
||
209 | </nested:iterate> |
||
210 | |||
1675 | jmachado | 211 | </div> |
212 | |||
213 | <% |
||
214 | AbstractDao.getCurrentSession().getTransaction().commit(); |
||
215 | %> |