Skip to content

Commit

Permalink
0.3.4 リリース
Browse files Browse the repository at this point in the history
  • Loading branch information
koda-masaru committed Jan 19, 2015
1 parent 7f0eb69 commit 3ad0c6a
Show file tree
Hide file tree
Showing 14 changed files with 234 additions and 26 deletions.
Binary file removed document/database/A5M2_knowledge.pdf
Binary file not shown.
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<groupId>org.support-project</groupId>
<artifactId>knowledge</artifactId>
<packaging>war</packaging>
<version>0.3.3</version>
<version>0.3.4</version>
<name>webapp for knowledge</name>
<url>https://support-project.org/</url>

Expand All @@ -17,7 +17,7 @@
<dependency>
<groupId>org.support-project</groupId>
<artifactId>web</artifactId>
<version>0.3.3</version>
<version>0.3.4</version>
</dependency>

<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
import org.support.project.web.bean.LoginedUser;
import org.support.project.web.boundary.Boundary;
import org.support.project.web.common.HttpStatus;
import org.support.project.web.dao.UsersDao;
import org.support.project.web.entity.UsersEntity;
import org.support.project.web.exception.InvalidParamException;

@DI(instance=Instance.Prototype)
Expand Down Expand Up @@ -122,6 +124,8 @@ public Boundary list() throws Exception {
LoginedUser loginedUser = super.getLoginedUser();
String keyword = getParam("keyword");
String tag = getParam("tag");
String user = getParam("user");


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

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



/**
* 検索画面を表示
* @return
*/
public Boundary search() {
return forward("search.jsp");
}
}


Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
Expand Down Expand Up @@ -291,6 +292,42 @@ public List<KnowledgesEntity> showKnowledgeOnTag(String tag, LoginedUser logined
return getKnowledgeDatas(list);
}

/**
* 指定ユーザのナレッジを取得
* @param userId
* @param loginedUser
* @param i
* @param pageLimit
* @return
* @throws Exception
*/
public Collection<? extends KnowledgesEntity> showKnowledgeOnUser(int targetUser, LoginedUser loginedUser, Integer offset, Integer limit) throws Exception {
SearchingValue searchingValue = new SearchingValue();
searchingValue.setOffset(offset);
searchingValue.setLimit(limit);

if (loginedUser != null && loginedUser.isAdmin()) {
//管理者の場合、ユーザのアクセス権を考慮しない

} else {
searchingValue.addUser(ALL_USER);
Integer userId = null;
if (loginedUser != null) {
userId = loginedUser.getLoginUser().getUserId();
searchingValue.addUser(userId);
}
}
searchingValue.setCreator(targetUser);

if (LOG.isDebugEnabled()) {
LOG.debug("search params:" + PropertyUtil.reflectionToString(searchingValue));
}
List<SearchResultValue> list = IndexLogic.get().search(searchingValue);

return getKnowledgeDatas(list);
}


/**
* 全文検索エンジンの結果を元に、DBからデータを取得し、
* さらにアクセス権のチェックなどを行う
Expand Down Expand Up @@ -545,7 +582,13 @@ public void addViewHistory(Long knowledgeId, LoginedUser loginedUser) {
}
historiesDao.insert(historiesEntity);
}


/**
* いいね!を追加
* @param knowledgeId
* @param loginedUser
* @return
*/
public Long addLike(Long knowledgeId, LoginedUser loginedUser) {
LikesDao likesDao = LikesDao.get();
LikesEntity likesEntity = new LikesEntity();
Expand All @@ -556,4 +599,5 @@ public Long addLike(Long knowledgeId, LoginedUser loginedUser) {
return count;
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ public class SearchingValue {
/** 読み出し件数 */
private int limit = LIMIT;

/** 作成者 */
private Integer creator;


/**
* コンストラクタ
*/
Expand Down Expand Up @@ -163,6 +167,24 @@ public void setLimit(int limit) {
this.limit = limit;
}

/**
* @return the creator
*/
public String getCreator() {
if (creator != null) {
return StringUtils.zeroPadding(creator, ID_ZEROPADDING_DIGIT);
}
return "";
}

/**
* @param creator the creator to set
*/
public void setCreator(Integer creator) {
this.creator = creator;
}





Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,12 @@ private Query structQuery(final SearchingValue value) throws ParseException {
Query query = queryParser.parse(value.getGroups());
container.add(query, BooleanClause.Occur.MUST);
}
if (StringUtils.isNotEmpty(value.getCreator())) {
QueryParser queryParser = new QueryParser(Version.LUCENE_4_10_2, FIELD_LABEL_CREATE_USER, analyzer);
queryParser.setDefaultOperator(Operator.OR);
Query query = queryParser.parse(value.getCreator());
container.add(query, BooleanClause.Occur.MUST);
}
return container;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="<%= request.getContextPath() %><%= top %>" style="cursor: pointer;">
<i class="fa fa-book"></i>&nbsp;Knowledge
<i class="fa fa-book"></i>&nbsp;Knowledge <span style="font-size: 8pt;">0.3.4</span>
</a>
</div>
<div class="navbar-collapse collapse">
Expand Down Expand Up @@ -65,6 +65,12 @@
<i class="fa fa-smile-o"></i>&nbsp;My Account
</a>
</li>
<li>
<a href="<%= request.getContextPath() %>/open.knowledge/list?user=<%= jspUtil.id() %>" >
<i class="fa fa-male"></i>&nbsp;My Knowledges
</a>
</li>

<li class="divider"></li>
<li id="tabLogout">
<a href="<%= request.getContextPath() %>/signout" style="cursor: pointer;">
Expand Down
62 changes: 53 additions & 9 deletions src/main/webapp/WEB-INF/views/open/knowledge/list.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -37,20 +37,38 @@
</div>
</c:if>

<c:if test="${!empty selectedUser}">
<div class="row">
<div class="col-sm-12 selected_tag">
<a class="text-primary"
href="<%= request.getContextPath() %>/open.knowledge/list?user=${selectedUser.userId}" >
<i class="fa fa-user"></i>&nbsp;${selectedUser.userName}
</a>
<a class="text-primary"
href="<%= request.getContextPath() %>/open.knowledge/list" >
<i class="fa fa-times-circle"></i>&nbsp;
</a>
</div>
</div>
</c:if>




<nav>
<ul class="pager">
<li class="previous">
<a href="<%= request.getContextPath() %>/open.knowledge/list/${previous}?keyword=<%= jspUtil.out("keyword") %>&tag=${tag}">
<a href="<%= request.getContextPath() %>/open.knowledge/list/${previous}?keyword=<%= jspUtil.out("keyword") %>&tag=${tag}&user=${user}">
<span aria-hidden="true">&larr;</span>Previous
</a>
</li>
<li>
<a href="<%= request.getContextPath() %>/protect.knowledge/view_add?offset=${offset}&keyword=<%= jspUtil.out("keyword") %>&tag=${tag}" style="cursor: pointer;">
<a href="<%= request.getContextPath() %>/protect.knowledge/view_add?offset=${offset}&keyword=<%= jspUtil.out("keyword") %>&tag=${tag}&user=${user}" style="cursor: pointer;">
<i class="fa fa-plus-circle"></i>&nbsp;New Knowledge
</a>
</li>
<li class="next">
<a href="<%= request.getContextPath() %>/open.knowledge/list/${next}?keyword=<%= jspUtil.out("keyword") %>&tag=${tag}">
<a href="<%= request.getContextPath() %>/open.knowledge/list/${next}?keyword=<%= jspUtil.out("keyword") %>&tag=${tag}&user=${user}">
Next <span aria-hidden="true">&rarr;</span>
</a>
</li>
Expand All @@ -65,7 +83,7 @@

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

<div class="col-sm-12 col-md-4">
<h5>- Popular Tags - </h5>
<h5>- <i class="fa fa-bolt"></i>&nbsp;Menu - </h5>
<div class="list-group">
<a class="list-group-item "
href="<%= request.getContextPath() %>/open.knowledge/list" >
<i class="fa fa-list-alt"></i>&nbsp;All Knowledges
</a>
<% if (!"".equals(jspUtil.id())) { %>
<a class="list-group-item "
href="<%= request.getContextPath() %>/open.knowledge/list?user=<%= jspUtil.id() %>" >
<i class="fa fa-male"></i>&nbsp;My Knowledges
</a>
<% } %>
<a class="list-group-item "
href="<%= request.getContextPath() %>/open.knowledge/search" >
<i class="glyphicon glyphicon-search"></i>&nbsp;Search Knowledges
</a>
<a class="list-group-item "
href="<%= request.getContextPath() %>/protect.knowledge/view_add?offset=${offset}&keyword=<%= jspUtil.out("keyword") %>&tag=${tag}&user=${user}"
style="cursor: pointer;">
<i class="fa fa-plus-circle"></i>&nbsp;New Knowledge
</a>


</div>
<br/>

<h5>- <i class="fa fa-tags"></i>&nbsp;Popular Tags - </h5>

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

<h5>- History - </h5>
<h5>- <i class="fa fa-history"></i>&nbsp;History - </h5>
<div class="list-group">
<c:forEach var="history" items="${histories}">
<a href="<%= request.getContextPath() %>/open.knowledge/view/${history.knowledgeId}?offset=${offset}&keyword=<%= jspUtil.out("keyword") %>"
Expand All @@ -145,17 +189,17 @@
<nav>
<ul class="pager">
<li class="previous">
<a href="<%= request.getContextPath() %>/open.knowledge/list/${previous}?keyword=<%= jspUtil.out("keyword") %>&tag=${tag}">
<a href="<%= request.getContextPath() %>/open.knowledge/list/${previous}?keyword=<%= jspUtil.out("keyword") %>&tag=${tag}&user=${user}">
<span aria-hidden="true">&larr;</span>Previous
</a>
</li>
<li>
<a href="<%= request.getContextPath() %>/protect.knowledge/view_add?offset=${offset}&keyword=<%= jspUtil.out("keyword") %>&tag=${tag}" style="cursor: pointer;">
<a href="<%= request.getContextPath() %>/protect.knowledge/view_add?offset=${offset}&keyword=<%= jspUtil.out("keyword") %>&tag=${tag}&user=${user}" style="cursor: pointer;">
<i class="fa fa-plus-circle"></i>&nbsp;New Knowledge
</a>
</li>
<li class="next">
<a href="<%= request.getContextPath() %>/open.knowledge/list/${next}?keyword=<%= jspUtil.out("keyword") %>&tag=${tag}">
<a href="<%= request.getContextPath() %>/open.knowledge/list/${next}?keyword=<%= jspUtil.out("keyword") %>&tag=${tag}&user=${user}">
Next <span aria-hidden="true">&rarr;</span>
</a>
</li>
Expand Down
51 changes: 51 additions & 0 deletions src/main/webapp/WEB-INF/views/open/knowledge/search.jsp
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<%@page import="org.support.project.web.util.JspUtil"%>
<%@page pageEncoding="UTF-8" isELIgnored="false" session="false"
errorPage="/WEB-INF/views/commons/errors/jsp_error.jsp"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>

<%
String top = "/open.knowledge/list";
%>
<%
JspUtil jspUtil = new JspUtil(request, pageContext);
%>

<c:import url="/WEB-INF/views/commons/layout/layoutMain.jsp">

<c:param name="PARAM_HEAD">
</c:param>

<c:param name="PARAM_SCRIPTS">
</c:param>

<c:param name="PARAM_CONTENT">

<h3>Search Knowledge</h3>

<div class="row">
<br/>
<div class="col-sm-12 col-md-8">
<form role="search" action="<%=request.getContextPath()%><%=top%>">
<div class="input-group">
<div class="input-group-addon"><i class="fa fa-pencil-square-o"></i></div>
<input type="text" class="form-control" placeholder="Search Keyword"
name="keyword" id="keyword" value="<%=jspUtil.out("keyword")%>" />
<div class="input-group-btn">
</div>
</div>
<br/>
<button class="btn btn-primary" type="submit">
<i class="glyphicon glyphicon-search"></i>&nbsp;Search
</button>
<a href="<%= request.getContextPath() %>/open.knowledge/list/${offset}?keyword=${keyword}&tag=${tag}&user=${user}"
class="btn btn-success" role="button"><i class="fa fa-list-ul"></i>&nbsp;一覧へ戻る</a>
</form>
</div>
</div>

</c:param>

</c:import>

Loading

0 comments on commit 3ad0c6a

Please sign in to comment.