Skip to content

Commit

Permalink
0.3.3 リリース
Browse files Browse the repository at this point in the history
  • Loading branch information
koda-masaru committed Jan 13, 2015
1 parent f56f664 commit 7f0eb69
Show file tree
Hide file tree
Showing 14 changed files with 251 additions and 20 deletions.
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.2</version>
<version>0.3.3</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.2</version>
<version>0.3.3</version>
</dependency>

<dependency>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package org.support.project.knowledge.control.open;

import java.util.List;

import org.support.project.knowledge.control.Control;
import org.support.project.knowledge.dao.TagsDao;
import org.support.project.knowledge.entity.TagsEntity;
import org.support.project.web.boundary.Boundary;
import org.support.project.web.exception.InvalidParamException;

public class TagControl extends Control {
private static final int LIST_LIMIT = 20;

/**
* タグの一覧を表示
* (ページきりかえあり)
* @return
* @throws InvalidParamException
*/
public Boundary list() throws InvalidParamException {
Integer offset = super.getPathInteger(0);
int userId = super.getLoginUserId();

TagsDao tagsDao = TagsDao.get();
List<TagsEntity> tags;
if (super.getLoginedUser() != null && super.getLoginedUser().isAdmin()) {
tags = tagsDao.selectWithKnowledgeCountAdmin(offset * LIST_LIMIT, LIST_LIMIT);
} else {
tags = tagsDao.selectWithKnowledgeCount(userId, offset * LIST_LIMIT, LIST_LIMIT);
}
setAttribute("tags", tags);

int previous = offset -1;
if (previous < 0) {
previous = 0;
}
setAttribute("offset", offset);
setAttribute("previous", previous);
setAttribute("next", offset + 1);

return forward("list.jsp");
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ public Integer getNextId() {


public List<KnowledgesEntity> selectKnowledge(int offset, int limit, Integer userId) {
String sql = "SELECT * FROM KNOWLEDGES WHERE DELETE_FLAG = 0 ORDER BY UPDATE_DATETIME DESC Limit ? offset ?;";
// String sql = "SELECT * FROM KNOWLEDGES WHERE DELETE_FLAG = 0 ORDER BY UPDATE_DATETIME DESC Limit ? offset ?;";
String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/KnowledgesDao/KnowledgesDao_selectKnowledgeWithUserName.sql");
return executeQuery(sql, KnowledgesEntity.class, limit, offset);
}

Expand Down
23 changes: 23 additions & 0 deletions src/main/java/org/support/project/knowledge/dao/TagsDao.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import org.support.project.knowledge.dao.gen.GenTagsDao;
import org.support.project.knowledge.entity.TagsEntity;
import org.support.project.ormapping.common.SQLManager;
import org.support.project.web.bean.LoginedUser;

/**
* タグ
Expand Down Expand Up @@ -95,5 +96,27 @@ public List<TagsEntity> selectTagsWithCountOnUser(int userid, int offset, int li
String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/TagsDao/TagsDao_selectTagsWithCountOnUser.sql");
return executeQuery(sql, TagsEntity.class, userid, limit, offset);
}

/**
* タグの一覧と、それに紐づくナレッジの件数を取得
* @param offset
* @param loginedUser
* @return
*/
public List<TagsEntity> selectWithKnowledgeCount(int userId, int offset, int limit) {
String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/TagsDao/TagsDao_selectWithKnowledgeCount.sql");
return executeQuery(sql, TagsEntity.class, userId, limit, offset);
}
/**
* タグの一覧と、それに紐づくナレッジの件数を取得
* 管理者用で、ナレッジにアクセス可能かのアクセス権限チェックはしない
* @param offset
* @param limit
* @return
*/
public List<TagsEntity> selectWithKnowledgeCountAdmin(int offset, int limit) {
String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/TagsDao/TagsDao_selectWithKnowledgeCountAdmin.sql");
return executeQuery(sql, TagsEntity.class, limit, offset);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -453,12 +453,29 @@ public List<KnowledgesEntity> getKnowledges(List<String> ids, LoginedUser logine
//List<KnowledgesEntity> knowledgesEntities = knowledgesDao.selectKnowledges(knowledgeIds);
//アクセス権を考慮して取得
List<KnowledgesEntity> knowledgesEntities = new ArrayList<>();
List<String> addSuccess = new ArrayList<String>();
List<String> addFail = new ArrayList<String>();
for (Long integer : knowledgeIds) {
KnowledgesEntity entity = select(integer, loginedUser);
if (entity != null) {
addSuccess.add(integer.toString());
knowledgesEntities.add(entity);
} else {
addFail.add(integer.toString());
}
}
if (addSuccess.isEmpty()) {
LOG.debug("History: add success. [Empty]");
} else {
LOG.debug("History: add success. " + String.join(",", addSuccess.toArray(new String[0])));
}

if (addFail.isEmpty()) {
LOG.debug("History: add fail. [Empty]");
} else {
LOG.debug("History: add fail. " + String.join(",", addFail.toArray(new String[0])));
}

return knowledgesEntities;
}

Expand Down
10 changes: 9 additions & 1 deletion src/main/resources/log4j.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,17 @@
<level value="INFO" />
</category>

<category name="org.support.project.knowledge.bat">
<level value="INFO" />
</category>
<category name="org.support.project.knowledge.listener">
<level value="INFO" />
</category>


<!-- Root Logger: Other -->
<root>
<priority value="INFO" />
<priority value="DEBUG" />
<appender-ref ref="APP_STDOUT" />
</root>

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
SELECT
KNOWLEDGES.*
,USERS.USER_NAME AS INSERT_USER_NAME
FROM
KNOWLEDGES
LEFT OUTER JOIN USERS
ON USERS.USER_ID = KNOWLEDGES.INSERT_USER
WHERE
KNOWLEDGES.DELETE_FLAG = 0
ORDER BY UPDATE_DATETIME DESC
LIMIT ? OFFSET ?

Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
SELECT TAGS.*, COUNT(KNOWLEDGE_TAGS.KNOWLEDGE_ID) AS KNOWLEDGE_COUNT FROM TAGS
INNER JOIN KNOWLEDGE_TAGS ON (TAGS.TAG_ID = KNOWLEDGE_TAGS.TAG_ID)
WHERE EXISTS (
SELECT KNOWLEDGES.KNOWLEDGE_ID FROM KNOWLEDGES
INNER JOIN KNOWLEDGE_USERS ON (KNOWLEDGES.KNOWLEDGE_ID = KNOWLEDGE_USERS.KNOWLEDGE_ID)
WHERE KNOWLEDGE_TAGS.KNOWLEDGE_ID = KNOWLEDGES.KNOWLEDGE_ID
AND KNOWLEDGES.DELETE_FLAG = 0
AND KNOWLEDGE_USERS.USER_ID IN (0,?)

)
AND TAGS.DELETE_FLAG = 0
GROUP BY TAGS.TAG_ID
ORDER BY KNOWLEDGE_COUNT DESC
LIMIT ? OFFSET ?

Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
SELECT TAGS.*, COUNT(KNOWLEDGE_TAGS.KNOWLEDGE_ID) AS KNOWLEDGE_COUNT FROM TAGS
INNER JOIN KNOWLEDGE_TAGS ON (TAGS.TAG_ID = KNOWLEDGE_TAGS.TAG_ID)
WHERE EXISTS (
SELECT KNOWLEDGES.KNOWLEDGE_ID FROM KNOWLEDGES
INNER JOIN KNOWLEDGE_USERS ON (KNOWLEDGES.KNOWLEDGE_ID = KNOWLEDGE_USERS.KNOWLEDGE_ID)
WHERE KNOWLEDGE_TAGS.KNOWLEDGE_ID = KNOWLEDGES.KNOWLEDGE_ID
AND KNOWLEDGES.DELETE_FLAG = 0
)
AND TAGS.DELETE_FLAG = 0
GROUP BY TAGS.TAG_ID
ORDER BY KNOWLEDGE_COUNT DESC
LIMIT ? OFFSET ?
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

<meta http-equiv="expires" content="0" />
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="Cache-Control" content="no-cache">

<meta content="Knowledge - フリーの情報共有サービス" name="title">
<meta content="Knowledgeは無料で利用できる情報共有の仕組みです。" name="description">
Expand Down
28 changes: 22 additions & 6 deletions src/main/webapp/WEB-INF/views/commons/layout/commonScripts.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,20 @@
<script type="text/javascript">
var _CONTEXT = '<%= request.getContextPath() %>';
function setCookie(c_name, value, expiredays) {
var getCookies = function() {
var result = new Array();
var allcookies = document.cookie;
if( allcookies != '' ) {
var cookies = allcookies.split( '; ' );
for( var i = 0; i < cookies.length; i++ ) {
var cookie = cookies[ i ].split( '=' );
result[ cookie[ 0 ] ] = decodeURIComponent( cookie[ 1 ] );
}
}
return result;
}
var setCookie = function(c_name, value, expiredays, path) {
// var path = location.pathname;
// var paths = new Array();
// paths = path.split("/");
Expand All @@ -34,14 +47,17 @@ function setCookie(c_name, value, expiredays) {
var extime = new Date().getTime();
var cltime = new Date(extime + (60 * 60 * 24 * 1000 * expiredays));
var exdate = cltime.toUTCString();
var s = "";
s += c_name + "=" + escape(value);
s += "; path=" + _CONTEXT;
var s = '';
s += c_name + '=' + escape(value) + ';';
if (expiredays) {
s += "; expires=" + exdate + "; ";
s += ' expires=' + exdate + ';';
}
if (path) {
s += ' path=' + path + ';';
} else {
s += "; ";
s += ' path=' + _CONTEXT + ';';
}
document.cookie = s;
}
setCookie('<%= JspUtil.TIME_ZONE_OFFSET %>', (new Date()).getTimezoneOffset(), 60);
Expand Down
19 changes: 12 additions & 7 deletions src/main/webapp/WEB-INF/views/open/knowledge/list.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -79,19 +79,19 @@
<p class="insert_info">
<img src="<%= request.getContextPath()%>/images/loader.gif"
data-echo="<%= request.getContextPath()%>/open.account/icon/${knowledge.insertUser}"
alt="icon" width="32" height="32" />
alt="icon" width="36" height="36" style="float:left"/>
<i class="fa fa-user"></i>&nbsp;${knowledge.insertUserName}
&nbsp;&nbsp;&nbsp;
<i class="fa fa-thumbs-o-up"></i>&nbsp;× <span id="like_count">${knowledge.likeCount}</span>
&nbsp;&nbsp;&nbsp;

<i class="fa fa-calendar"></i>&nbsp;<%= jspUtil.date("knowledge.updateDatetime")%>
&nbsp;&nbsp;&nbsp;
<%= jspUtil.is(String.valueOf(KnowledgeLogic.PUBLIC_FLAG_PUBLIC), "knowledge.publicFlag",
"<i class=\"fa fa-globe\"></i>&nbsp;[公開]") %>
<%= jspUtil.is(String.valueOf(KnowledgeLogic.PUBLIC_FLAG_PRIVATE), "knowledge.publicFlag",
"<i class=\"fa fa-lock\"></i>&nbsp;[非公開]") %>
<br/>
<i class="fa fa-calendar"></i>&nbsp;<%= jspUtil.date("knowledge.updateDatetime")%>
&nbsp;&nbsp;&nbsp;
<i class="fa fa-thumbs-o-up"></i>&nbsp;× <span id="like_count">${knowledge.likeCount}</span>
</p>
<p style="clear:left;">

<p style="word-break:break-all" class="content">
<%-- <c:out value="${knowledge.content}"></c:out>--%>
Expand All @@ -114,13 +114,18 @@
</a>
</c:forEach>
</div>
<div style="width: 100%;text-align: right;">
<a href="<%= request.getContextPath() %>/open.tag/list">
<i class="fa fa-tags"></i>&nbsp;タグ一覧
</a>&nbsp;&nbsp;&nbsp;
</div>

<h5>- 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") %>"
class="list-group-item">
<h5 class="list-group-item-heading"><i class="fa fa-history"></i>&nbsp;${history.title}</h5>
<h5 class="list-group-item-heading"><i class="fa fa-history"></i>&nbsp;[${history.knowledgeId}]&nbsp;${history.title}</h5>
<p class="list-group-item-text">${history.content}</p>
</a>
</c:forEach>
Expand Down
71 changes: 71 additions & 0 deletions src/main/webapp/WEB-INF/views/open/tag/list.jsp
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<%@page import="org.support.project.knowledge.logic.KnowledgeLogic"%>
<%@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"%>

<% 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">

<h4>タグ一覧</h4>

<nav>
<ul class="pager">
<li class="previous">
<a href="<%= request.getContextPath() %>/open.tag/list/${previous}">
<span aria-hidden="true">&larr;</span>Previous
</a>
</li>
<li class="next">
<a href="<%= request.getContextPath() %>/open.tag/list/${next}">
Next <span aria-hidden="true">&rarr;</span>
</a>
</li>
</ul>
</nav>

<c:if test="${empty tags}">
<div class="col-sm-12">
一覧に表示するタグがありません
</div>
</c:if>

<div class="list-group">
<c:forEach var="tag" items="${tags}">
<a class="list-group-item "
href="<%= request.getContextPath() %>/open.knowledge/list?tag=${tag.tagId}" >
<span class="badge">${tag.knowledgeCount}</span>
<i class="fa fa-tag"></i>&nbsp;${tag.tagName}
</a>
</c:forEach>
</div>

<nav>
<ul class="pager">
<li class="previous">
<a href="<%= request.getContextPath() %>/open.tag/list/${previous}">
<span aria-hidden="true">&larr;</span>Previous
</a>
</li>
<li class="next">
<a href="<%= request.getContextPath() %>/open.tag/list/${next}">
Next <span aria-hidden="true">&rarr;</span>
</a>
</li>
</ul>
</nav>

</c:param>

</c:import>

Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,19 @@ private void addSample(String line) throws Exception {
String tags = "";
if (count % 5 == 0) {
entity.setPublicFlag(KnowledgeLogic.PUBLIC_FLAG_PUBLIC);
tags = "テスト";
tags = "テスト,サンプル1,データ"+count;
} else if (count % 9 == 0) {
entity.setPublicFlag(KnowledgeLogic.PUBLIC_FLAG_PUBLIC);
tags = "サンプル,タグ2,データ"+count;
} else if (count % 13 == 0) {
entity.setPublicFlag(KnowledgeLogic.PUBLIC_FLAG_PUBLIC);
tags = "サンプル,タグ3,タグ4,テスト,データ"+count;
} else if (count % 7 == 0) {
entity.setPublicFlag(KnowledgeLogic.PUBLIC_FLAG_PRIVATE);
tags = "サンプルデータ,タグ1";
tags = "サンプルデータ,タグ1,データ"+count;
} else if (count % 8 == 0) {
entity.setPublicFlag(KnowledgeLogic.PUBLIC_FLAG_PRIVATE);
tags = "テスト,サンプルデータ,タグ1,タグ2";
tags = "テスト,サンプルデータ,テスト1,タグ2,データ"+count;
} else {
entity.setPublicFlag(KnowledgeLogic.PUBLIC_FLAG_PRIVATE);
}
Expand Down

0 comments on commit 7f0eb69

Please sign in to comment.