Skip to content

Commit 3ad0c6a

Browse files
committed
0.3.4 リリース
1 parent 7f0eb69 commit 3ad0c6a

File tree

14 files changed

+234
-26
lines changed

14 files changed

+234
-26
lines changed
-98.5 KB
Binary file not shown.

pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<groupId>org.support-project</groupId>
55
<artifactId>knowledge</artifactId>
66
<packaging>war</packaging>
7-
<version>0.3.3</version>
7+
<version>0.3.4</version>
88
<name>webapp for knowledge</name>
99
<url>https://support-project.org/</url>
1010

@@ -17,7 +17,7 @@
1717
<dependency>
1818
<groupId>org.support-project</groupId>
1919
<artifactId>web</artifactId>
20-
<version>0.3.3</version>
20+
<version>0.3.4</version>
2121
</dependency>
2222

2323
<dependency>

src/main/java/org/support/project/knowledge/control/open/KnowledgeControl.java

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
import org.support.project.web.bean.LoginedUser;
2626
import org.support.project.web.boundary.Boundary;
2727
import org.support.project.web.common.HttpStatus;
28+
import org.support.project.web.dao.UsersDao;
29+
import org.support.project.web.entity.UsersEntity;
2830
import org.support.project.web.exception.InvalidParamException;
2931

3032
@DI(instance=Instance.Prototype)
@@ -122,6 +124,8 @@ public Boundary list() throws Exception {
122124
LoginedUser loginedUser = super.getLoginedUser();
123125
String keyword = getParam("keyword");
124126
String tag = getParam("tag");
127+
String user = getParam("user");
128+
125129

126130
List<KnowledgesEntity> knowledges = new ArrayList<>();
127131

@@ -131,6 +135,14 @@ public Boundary list() throws Exception {
131135
knowledges.addAll(knowledgeLogic.showKnowledgeOnTag(tag, loginedUser, offset * PAGE_LIMIT, PAGE_LIMIT));
132136
TagsEntity tagsEntity = tagsDao.selectOnKey(new Integer(tag));
133137
setAttribute("selectedTag", tagsEntity);
138+
} else if (StringUtils.isNotEmpty(user) && StringUtils.isInteger(user)) {
139+
// ユーザを選択している
140+
LOG.trace("show on User");
141+
int userId = Integer.parseInt(user);
142+
knowledges.addAll(knowledgeLogic.showKnowledgeOnUser(userId, loginedUser, offset * PAGE_LIMIT, PAGE_LIMIT));
143+
UsersEntity usersEntity = UsersDao.get().selectOnKey(userId);
144+
usersEntity.setPassword("");
145+
setAttribute("selectedUser", usersEntity);
134146
} else {
135147
// その他
136148
LOG.trace("search");
@@ -216,8 +228,13 @@ public Boundary escape(KnowledgesEntity entity) {
216228
return super.send(entity);
217229
}
218230

219-
220-
231+
/**
232+
* 検索画面を表示
233+
* @return
234+
*/
235+
public Boundary search() {
236+
return forward("search.jsp");
237+
}
221238
}
222239

223240

src/main/java/org/support/project/knowledge/logic/KnowledgeLogic.java

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import java.sql.Timestamp;
44
import java.util.ArrayList;
5+
import java.util.Collection;
56
import java.util.Date;
67
import java.util.HashMap;
78
import java.util.List;
@@ -291,6 +292,42 @@ public List<KnowledgesEntity> showKnowledgeOnTag(String tag, LoginedUser logined
291292
return getKnowledgeDatas(list);
292293
}
293294

295+
/**
296+
* 指定ユーザのナレッジを取得
297+
* @param userId
298+
* @param loginedUser
299+
* @param i
300+
* @param pageLimit
301+
* @return
302+
* @throws Exception
303+
*/
304+
public Collection<? extends KnowledgesEntity> showKnowledgeOnUser(int targetUser, LoginedUser loginedUser, Integer offset, Integer limit) throws Exception {
305+
SearchingValue searchingValue = new SearchingValue();
306+
searchingValue.setOffset(offset);
307+
searchingValue.setLimit(limit);
308+
309+
if (loginedUser != null && loginedUser.isAdmin()) {
310+
//管理者の場合、ユーザのアクセス権を考慮しない
311+
312+
} else {
313+
searchingValue.addUser(ALL_USER);
314+
Integer userId = null;
315+
if (loginedUser != null) {
316+
userId = loginedUser.getLoginUser().getUserId();
317+
searchingValue.addUser(userId);
318+
}
319+
}
320+
searchingValue.setCreator(targetUser);
321+
322+
if (LOG.isDebugEnabled()) {
323+
LOG.debug("search params:" + PropertyUtil.reflectionToString(searchingValue));
324+
}
325+
List<SearchResultValue> list = IndexLogic.get().search(searchingValue);
326+
327+
return getKnowledgeDatas(list);
328+
}
329+
330+
294331
/**
295332
* 全文検索エンジンの結果を元に、DBからデータを取得し、
296333
* さらにアクセス権のチェックなどを行う
@@ -545,7 +582,13 @@ public void addViewHistory(Long knowledgeId, LoginedUser loginedUser) {
545582
}
546583
historiesDao.insert(historiesEntity);
547584
}
548-
585+
586+
/**
587+
* いいね!を追加
588+
* @param knowledgeId
589+
* @param loginedUser
590+
* @return
591+
*/
549592
public Long addLike(Long knowledgeId, LoginedUser loginedUser) {
550593
LikesDao likesDao = LikesDao.get();
551594
LikesEntity likesEntity = new LikesEntity();
@@ -556,4 +599,5 @@ public Long addLike(Long knowledgeId, LoginedUser loginedUser) {
556599
return count;
557600
}
558601

602+
559603
}

src/main/java/org/support/project/knowledge/searcher/SearchingValue.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ public class SearchingValue {
3131
/** 読み出し件数 */
3232
private int limit = LIMIT;
3333

34+
/** 作成者 */
35+
private Integer creator;
36+
37+
3438
/**
3539
* コンストラクタ
3640
*/
@@ -163,6 +167,24 @@ public void setLimit(int limit) {
163167
this.limit = limit;
164168
}
165169

170+
/**
171+
* @return the creator
172+
*/
173+
public String getCreator() {
174+
if (creator != null) {
175+
return StringUtils.zeroPadding(creator, ID_ZEROPADDING_DIGIT);
176+
}
177+
return "";
178+
}
179+
180+
/**
181+
* @param creator the creator to set
182+
*/
183+
public void setCreator(Integer creator) {
184+
this.creator = creator;
185+
}
186+
187+
166188

167189

168190

src/main/java/org/support/project/knowledge/searcher/impl/LuceneSearcher.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,12 @@ private Query structQuery(final SearchingValue value) throws ParseException {
188188
Query query = queryParser.parse(value.getGroups());
189189
container.add(query, BooleanClause.Occur.MUST);
190190
}
191+
if (StringUtils.isNotEmpty(value.getCreator())) {
192+
QueryParser queryParser = new QueryParser(Version.LUCENE_4_10_2, FIELD_LABEL_CREATE_USER, analyzer);
193+
queryParser.setDefaultOperator(Operator.OR);
194+
Query query = queryParser.parse(value.getCreator());
195+
container.add(query, BooleanClause.Occur.MUST);
196+
}
191197
return container;
192198
}
193199

src/main/webapp/WEB-INF/views/commons/layout/commonNavbar.jsp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
<span class="icon-bar"></span>
1818
</button>
1919
<a class="navbar-brand" href="<%= request.getContextPath() %><%= top %>" style="cursor: pointer;">
20-
<i class="fa fa-book"></i>&nbsp;Knowledge
20+
<i class="fa fa-book"></i>&nbsp;Knowledge <span style="font-size: 8pt;">0.3.4</span>
2121
</a>
2222
</div>
2323
<div class="navbar-collapse collapse">
@@ -65,6 +65,12 @@
6565
<i class="fa fa-smile-o"></i>&nbsp;My Account
6666
</a>
6767
</li>
68+
<li>
69+
<a href="<%= request.getContextPath() %>/open.knowledge/list?user=<%= jspUtil.id() %>" >
70+
<i class="fa fa-male"></i>&nbsp;My Knowledges
71+
</a>
72+
</li>
73+
6874
<li class="divider"></li>
6975
<li id="tabLogout">
7076
<a href="<%= request.getContextPath() %>/signout" style="cursor: pointer;">

src/main/webapp/WEB-INF/views/open/knowledge/list.jsp

Lines changed: 53 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,20 +37,38 @@
3737
</div>
3838
</c:if>
3939

40+
<c:if test="${!empty selectedUser}">
41+
<div class="row">
42+
<div class="col-sm-12 selected_tag">
43+
<a class="text-primary"
44+
href="<%= request.getContextPath() %>/open.knowledge/list?user=${selectedUser.userId}" >
45+
<i class="fa fa-user"></i>&nbsp;${selectedUser.userName}
46+
</a>
47+
<a class="text-primary"
48+
href="<%= request.getContextPath() %>/open.knowledge/list" >
49+
<i class="fa fa-times-circle"></i>&nbsp;
50+
</a>
51+
</div>
52+
</div>
53+
</c:if>
54+
55+
56+
57+
4058
<nav>
4159
<ul class="pager">
4260
<li class="previous">
43-
<a href="<%= request.getContextPath() %>/open.knowledge/list/${previous}?keyword=<%= jspUtil.out("keyword") %>&tag=${tag}">
61+
<a href="<%= request.getContextPath() %>/open.knowledge/list/${previous}?keyword=<%= jspUtil.out("keyword") %>&tag=${tag}&user=${user}">
4462
<span aria-hidden="true">&larr;</span>Previous
4563
</a>
4664
</li>
4765
<li>
48-
<a href="<%= request.getContextPath() %>/protect.knowledge/view_add?offset=${offset}&keyword=<%= jspUtil.out("keyword") %>&tag=${tag}" style="cursor: pointer;">
66+
<a href="<%= request.getContextPath() %>/protect.knowledge/view_add?offset=${offset}&keyword=<%= jspUtil.out("keyword") %>&tag=${tag}&user=${user}" style="cursor: pointer;">
4967
<i class="fa fa-plus-circle"></i>&nbsp;New Knowledge
5068
</a>
5169
</li>
5270
<li class="next">
53-
<a href="<%= request.getContextPath() %>/open.knowledge/list/${next}?keyword=<%= jspUtil.out("keyword") %>&tag=${tag}">
71+
<a href="<%= request.getContextPath() %>/open.knowledge/list/${next}?keyword=<%= jspUtil.out("keyword") %>&tag=${tag}&user=${user}">
5472
Next <span aria-hidden="true">&rarr;</span>
5573
</a>
5674
</li>
@@ -65,7 +83,7 @@
6583

6684
<c:forEach var="knowledge" items="${knowledges}" varStatus="status">
6785
<div class="thumbnail"
68-
onclick="showKnowledge('<%= request.getContextPath() %>/open.knowledge/view/${knowledge.knowledgeId}', '${offset}', '<%= jspUtil.out("keyword") %>', '${tag}');">
86+
onclick="showKnowledge('<%= request.getContextPath() %>/open.knowledge/view/${knowledge.knowledgeId}', '${offset}', '<%= jspUtil.out("keyword") %>', '${tag}', '${user}');">
6987
<div class="discription"><i class="fa fa-check-square-o"></i>&nbsp;show!</div>
7088
<div class="caption">
7189
<h4>[${knowledge.knowledgeId}]&nbsp;${knowledge.title}</h4>
@@ -103,7 +121,33 @@
103121
</div>
104122

105123
<div class="col-sm-12 col-md-4">
106-
<h5>- Popular Tags - </h5>
124+
<h5>- <i class="fa fa-bolt"></i>&nbsp;Menu - </h5>
125+
<div class="list-group">
126+
<a class="list-group-item "
127+
href="<%= request.getContextPath() %>/open.knowledge/list" >
128+
<i class="fa fa-list-alt"></i>&nbsp;All Knowledges
129+
</a>
130+
<% if (!"".equals(jspUtil.id())) { %>
131+
<a class="list-group-item "
132+
href="<%= request.getContextPath() %>/open.knowledge/list?user=<%= jspUtil.id() %>" >
133+
<i class="fa fa-male"></i>&nbsp;My Knowledges
134+
</a>
135+
<% } %>
136+
<a class="list-group-item "
137+
href="<%= request.getContextPath() %>/open.knowledge/search" >
138+
<i class="glyphicon glyphicon-search"></i>&nbsp;Search Knowledges
139+
</a>
140+
<a class="list-group-item "
141+
href="<%= request.getContextPath() %>/protect.knowledge/view_add?offset=${offset}&keyword=<%= jspUtil.out("keyword") %>&tag=${tag}&user=${user}"
142+
style="cursor: pointer;">
143+
<i class="fa fa-plus-circle"></i>&nbsp;New Knowledge
144+
</a>
145+
146+
147+
</div>
148+
<br/>
149+
150+
<h5>- <i class="fa fa-tags"></i>&nbsp;Popular Tags - </h5>
107151

108152
<div class="list-group">
109153
<c:forEach var="tag" items="${tags}">
@@ -120,7 +164,7 @@
120164
</a>&nbsp;&nbsp;&nbsp;
121165
</div>
122166

123-
<h5>- History - </h5>
167+
<h5>- <i class="fa fa-history"></i>&nbsp;History - </h5>
124168
<div class="list-group">
125169
<c:forEach var="history" items="${histories}">
126170
<a href="<%= request.getContextPath() %>/open.knowledge/view/${history.knowledgeId}?offset=${offset}&keyword=<%= jspUtil.out("keyword") %>"
@@ -145,17 +189,17 @@
145189
<nav>
146190
<ul class="pager">
147191
<li class="previous">
148-
<a href="<%= request.getContextPath() %>/open.knowledge/list/${previous}?keyword=<%= jspUtil.out("keyword") %>&tag=${tag}">
192+
<a href="<%= request.getContextPath() %>/open.knowledge/list/${previous}?keyword=<%= jspUtil.out("keyword") %>&tag=${tag}&user=${user}">
149193
<span aria-hidden="true">&larr;</span>Previous
150194
</a>
151195
</li>
152196
<li>
153-
<a href="<%= request.getContextPath() %>/protect.knowledge/view_add?offset=${offset}&keyword=<%= jspUtil.out("keyword") %>&tag=${tag}" style="cursor: pointer;">
197+
<a href="<%= request.getContextPath() %>/protect.knowledge/view_add?offset=${offset}&keyword=<%= jspUtil.out("keyword") %>&tag=${tag}&user=${user}" style="cursor: pointer;">
154198
<i class="fa fa-plus-circle"></i>&nbsp;New Knowledge
155199
</a>
156200
</li>
157201
<li class="next">
158-
<a href="<%= request.getContextPath() %>/open.knowledge/list/${next}?keyword=<%= jspUtil.out("keyword") %>&tag=${tag}">
202+
<a href="<%= request.getContextPath() %>/open.knowledge/list/${next}?keyword=<%= jspUtil.out("keyword") %>&tag=${tag}&user=${user}">
159203
Next <span aria-hidden="true">&rarr;</span>
160204
</a>
161205
</li>
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<%@page import="org.support.project.web.util.JspUtil"%>
2+
<%@page pageEncoding="UTF-8" isELIgnored="false" session="false"
3+
errorPage="/WEB-INF/views/commons/errors/jsp_error.jsp"%>
4+
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
5+
<%@taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
6+
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
7+
8+
<%
9+
String top = "/open.knowledge/list";
10+
%>
11+
<%
12+
JspUtil jspUtil = new JspUtil(request, pageContext);
13+
%>
14+
15+
<c:import url="/WEB-INF/views/commons/layout/layoutMain.jsp">
16+
17+
<c:param name="PARAM_HEAD">
18+
</c:param>
19+
20+
<c:param name="PARAM_SCRIPTS">
21+
</c:param>
22+
23+
<c:param name="PARAM_CONTENT">
24+
25+
<h3>Search Knowledge</h3>
26+
27+
<div class="row">
28+
<br/>
29+
<div class="col-sm-12 col-md-8">
30+
<form role="search" action="<%=request.getContextPath()%><%=top%>">
31+
<div class="input-group">
32+
<div class="input-group-addon"><i class="fa fa-pencil-square-o"></i></div>
33+
<input type="text" class="form-control" placeholder="Search Keyword"
34+
name="keyword" id="keyword" value="<%=jspUtil.out("keyword")%>" />
35+
<div class="input-group-btn">
36+
</div>
37+
</div>
38+
<br/>
39+
<button class="btn btn-primary" type="submit">
40+
<i class="glyphicon glyphicon-search"></i>&nbsp;Search
41+
</button>
42+
<a href="<%= request.getContextPath() %>/open.knowledge/list/${offset}?keyword=${keyword}&tag=${tag}&user=${user}"
43+
class="btn btn-success" role="button"><i class="fa fa-list-ul"></i>&nbsp;一覧へ戻る</a>
44+
</form>
45+
</div>
46+
</div>
47+
48+
</c:param>
49+
50+
</c:import>
51+

0 commit comments

Comments
 (0)