Skip to content

Commit

Permalink
Merge pull request #316 from support-project/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
koda-masaru committed Mar 6, 2016
2 parents 6785613 + 5ebf2eb commit 668ffa2
Show file tree
Hide file tree
Showing 24 changed files with 593 additions and 140 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"marked": "0.3.4",
"highlightjs": "8.9.1",
"bootbox": "4.4.0",
"bootstrap-tagsinput": "0.5.0",
"bootstrap-tagsinput": "0.4.2",
"bootstrap3-typeahead": "3.1.1",
"bootstrap-fileinput": "4.2.8",
"jquery-file-upload": "9.11.2",
Expand Down
10 changes: 8 additions & 2 deletions config/stylecheck.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ Slightly modified version of Sun Checks that better matches the default code for
<module name="LocalFinalVariableName"/>
<module name="LocalVariableName"/>
<module name="MemberName"/>
<module name="MethodName"/>
<module name="MethodName">
<property name="severity" value="ignore"/>
<metadata name="net.sf.eclipsecs.core.lastEnabledSeverity" value="inherit"/>
</module>
<module name="PackageName"/>
<module name="ParameterName"/>
<module name="StaticVariableName"/>
Expand All @@ -41,7 +44,10 @@ Slightly modified version of Sun Checks that better matches the default code for
<module name="LineLength">
<property name="max" value="150"/>
</module>
<module name="MethodLength"/>
<module name="MethodLength">
<property name="severity" value="ignore"/>
<metadata name="net.sf.eclipsecs.core.lastEnabledSeverity" value="inherit"/>
</module>
<module name="ParameterNumber"/>
<module name="EmptyForIteratorPad"/>
<module name="GenericWhitespace"/>
Expand Down
6 changes: 3 additions & 3 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>1.2.0-SNAPSHOT</version>
<version>1.2.0</version>
<name>webapp for knowledge</name>
<url>https://support-project.org/</url>

Expand All @@ -16,13 +16,13 @@
<dependency>
<groupId>org.support-project</groupId>
<artifactId>web</artifactId>
<version>1.2.0-SNAPSHOT</version>
<version>1.2.0</version>
</dependency>

<dependency>
<groupId>org.support-project</groupId>
<artifactId>markedj</artifactId>
<version>1.0.6</version>
<version>1.0.7-SNAPSHOT</version>
</dependency>

<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,21 +45,26 @@
import org.support.project.web.common.HttpStatus;
import org.support.project.web.control.service.Get;
import org.support.project.web.control.service.Post;
import org.support.project.web.dao.GroupsDao;
import org.support.project.web.dao.UsersDao;
import org.support.project.web.entity.GroupsEntity;
import org.support.project.web.entity.UsersEntity;
import org.support.project.web.exception.InvalidParamException;

@DI(instance=Instance.Prototype)
/**
* ナレッジ操作のコントロール
* @author Koda
*/
@DI(instance = Instance.Prototype)
public class KnowledgeControl extends KnowledgeControlBase {
/** ログ */
private static Log LOG = LogFactory.getLog(KnowledgeControl.class);

private static final Log LOG = LogFactory.getLog(KnowledgeControl.class);
/** Cookieに保持する閲覧履歴の件数 */
private static final int COOKIE_COUNT = 20;
/** Cookieに保持する閲覧履歴の区切り文字 */
private static final String COOKIE_SEPARATOR = "-";

/** ナレッジ一覧に表示する件数 */
public static final int PAGE_LIMIT = 50;
/** お気に入りに表示する件数 */
public static final int FAV_PAGE_LIMIT = 10;

/**
Expand Down Expand Up @@ -186,6 +191,12 @@ public Boundary list() throws Exception {
setAttribute("offset", offset);
String keyword = getParam("keyword");
setAttribute("searchKeyword", keyword);

// ログインユーザ情報を最新化
// TODO 毎回最新化するのは、パフォーマンスが悪い?グループ情報が更新になった場合に、影響があるユーザの一覧を保持しておき、
// そのユーザのみを更新した方が良いかも。いったんは、ナレッジの一覧を表示する際に、毎回更新してみる(それほど負荷が高くなさそうなので)
super.updateLoginInfo();

// 共通処理呼の表示条件の保持の呼び出し
setViewParam();

Expand Down Expand Up @@ -344,7 +355,7 @@ public Boundary list() throws Exception {
setAttribute("targets", targets);
setAttribute("targetLogic", targetLogic);

int previous = offset -1;
int previous = offset - 1;
if (previous < 0) {
previous = 0;
}
Expand Down Expand Up @@ -377,7 +388,11 @@ public Boundary list() throws Exception {
}



/**
* 閲覧履歴の表示
* @return
* @throws InvalidParamException
*/
@Get
public Boundary show_history() throws InvalidParamException {
LoginedUser loginedUser = super.getLoginedUser();
Expand Down Expand Up @@ -439,6 +454,56 @@ public Boundary show_history() throws InvalidParamException {
}


/**
* 閲覧履歴の表示
* @return
* @throws InvalidParamException
*/
@Get
public Boundary show_popularity() throws InvalidParamException {
LoginedUser loginedUser = super.getLoginedUser();
KnowledgeLogic knowledgeLogic = KnowledgeLogic.get();
TagsDao tagsDao = TagsDao.get();
ExGroupsDao groupsDao = ExGroupsDao.get();

List<KnowledgesEntity> popularities = knowledgeLogic.getPopularityKnowledges(loginedUser, 0, 20);
LOG.trace("取得完了");
setAttribute("popularities", popularities);

ArrayList<Long> knowledgeIds = new ArrayList<>();
for (KnowledgesEntity knowledgesEntity : popularities) {
knowledgeIds.add(knowledgesEntity.getKnowledgeId());
}

// タグとグループの情報を取得
if (loginedUser != null && loginedUser.isAdmin()) {
// 管理者であれば、ナレッジの件数は、参照権限を考慮していない
List<TagsEntity> tags = tagsDao.selectTagsWithCount(0, FAV_PAGE_LIMIT);
setAttribute("tags", tags);

List<GroupsEntity> groups = groupsDao.selectGroupsWithCount(0, FAV_PAGE_LIMIT);
setAttribute("groups", groups);
} else {
TagLogic tagLogic = TagLogic.get();
List<TagsEntity> tags = tagLogic.selectTagsWithCount(loginedUser, 0, FAV_PAGE_LIMIT);
setAttribute("tags", tags);

if (loginedUser != null) {
GroupLogic groupLogic = GroupLogic.get();
List<GroupsEntity> groups = groupLogic.selectMyGroup(loginedUser, 0, FAV_PAGE_LIMIT);
setAttribute("groups", groups);
}
}
LOG.trace("タグ、グループ取得完了");

TargetLogic targetLogic = TargetLogic.get();
Map<Long, ArrayList<LabelValue>> targets = targetLogic.selectTargetsOnKnowledgeIds(knowledgeIds, loginedUser);
setAttribute("targets", targets);
setAttribute("targetLogic", targetLogic);

return forward("popularity.jsp");
}


/**
* いいねを押下
Expand Down Expand Up @@ -550,7 +615,7 @@ public Boundary likes() throws InvalidParamException {
setAttribute("likes", likes);


int previous = page -1;
int previous = page - 1;
if (previous < 0) {
previous = 0;
}
Expand All @@ -561,6 +626,11 @@ public Boundary likes() throws InvalidParamException {
return forward("likes.jsp");
}

/**
* 編集履歴の表示
* @return
* @throws InvalidParamException
*/
@Get
public Boundary histories() throws InvalidParamException {
// 共通処理呼の表示条件の保持の呼び出し
Expand All @@ -580,7 +650,7 @@ public Boundary histories() throws InvalidParamException {
if (StringUtils.isInteger(p)) {
page = Integer.parseInt(p);
}
int previous = page -1;
int previous = page - 1;
if (previous < 0) {
previous = 0;
}
Expand All @@ -596,7 +666,11 @@ public Boundary histories() throws InvalidParamException {
return forward("histories.jsp");
}


/**
* 編集履歴の更新内容表示
* @return
* @throws InvalidParamException
*/
@Get
public Boundary history() throws InvalidParamException {
// 共通処理呼の表示条件の保持の呼び出し
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,13 @@
import org.support.project.web.entity.UserGroupsEntity;
import org.support.project.web.exception.InvalidParamException;

@DI(instance=Instance.Prototype)
/**
* グループ操作のコントロール
* @author Koda
*/
@DI(instance = Instance.Prototype)
public class GroupControl extends Control {

/** 一覧の表示件数 */
public static final int PAGE_LIMIT = 10;

/**
Expand All @@ -45,7 +49,7 @@ public Boundary mygroups() throws InvalidParamException {
List<GroupsEntity> groups = groupLogic.selectMyGroup(super.getLoginedUser(), offset * PAGE_LIMIT, PAGE_LIMIT);
setAttribute("groups", groups);

int previous = offset -1;
int previous = offset - 1;
if (previous < 0) {
previous = 0;
}
Expand All @@ -71,7 +75,7 @@ public Boundary list() throws InvalidParamException {
List<GroupsEntity> groups = groupLogic.selectOnKeyword(keyword, super.getLoginedUser(), offset * PAGE_LIMIT, PAGE_LIMIT);
setAttribute("groups", groups);

int previous = offset -1;
int previous = offset - 1;
if (previous < 0) {
previous = 0;
}
Expand Down Expand Up @@ -158,7 +162,7 @@ public Boundary view() throws InvalidParamException {
}
}

int previous = offset -1;
int previous = offset - 1;
if (previous < 0) {
previous = 0;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@
import org.support.project.knowledge.dao.gen.GenKnowledgesDao;
import org.support.project.knowledge.entity.KnowledgesEntity;
import org.support.project.ormapping.common.SQLManager;
import org.support.project.web.bean.LoginedUser;
import org.support.project.web.entity.GroupsEntity;

/**
* ナレッジ
*/
@DI(instance=Instance.Singleton)
@DI(instance = Instance.Singleton)
public class KnowledgesDao extends GenKnowledgesDao {

/** SerialVersion */
Expand Down Expand Up @@ -139,4 +141,67 @@ public List<KnowledgesEntity> selectBetween(Long start, Long end) {
}


/**
* 指定期間でイイネの登録件数が大きいもから先頭に取得
* アクセス権限を考慮しないので、管理者用
* @param start
* @param end
* @param offset
* @param limit
* @return
*/
public List<KnowledgesEntity> selectPopularity(Timestamp start, Timestamp end, int offset, int limit) {
String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/KnowledgesDao/KnowledgesDao_selectPopularity.sql");
return executeQueryList(sql, KnowledgesEntity.class, start, end, limit, offset);
}
/**
* 指定期間でイイネの登録件数が大きいものから取得
* アクセス権限を考慮する
* @param loginedUser
* @param start
* @param end
* @param offset
* @param limit
* @return
*/
public List<KnowledgesEntity> selectPopularityWithAccessControl(LoginedUser loginedUser, Timestamp start, Timestamp end,
int offset, int limit) {
String sql = SQLManager.getInstance()
.getSql("/org/support/project/knowledge/dao/sql/KnowledgesDao/KnowledgesDao_selectPopularityWithAccessControl.sql");
List<Object> params = new ArrayList<>();
params.add(start);
params.add(end);
Integer loginuserId = Integer.MIN_VALUE;
if (loginedUser != null) {
loginuserId = loginedUser.getUserId();
}
params.add(loginuserId);
params.add(loginuserId);

List<Integer> groups = new ArrayList<>();
groups.add(0); // ALL Groups
if (loginedUser != null && loginedUser.getGroups() != null) {
List<GroupsEntity> userGroups = loginedUser.getGroups();
for (GroupsEntity groupsEntity : userGroups) {
groups.add(groupsEntity.getGroupId());
}
}
StringBuilder groupParams = new StringBuilder();
int cnt = 0;
for (Integer integer : groups) {
if (cnt > 0) {
groupParams.append(", ");
}
cnt++;
params.add(integer);
groupParams.append("?");
}
sql = sql.replace("%GROUPS%", groupParams.toString());
params.add(limit);
params.add(offset);

return executeQueryList(sql, KnowledgesEntity.class, params.toArray(new Object[0]));
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ public static KnowledgesEntity get() {

/** スコア(検索した際のスコア) */
private Float score;
/** 指定期間内のイイネ件数 */
private Integer likeCountOnTerm;

/**
* コンストラクタ
Expand Down Expand Up @@ -126,6 +128,20 @@ public Float getScore() {
public void setScore(Float score) {
this.score = score;
}

/**
* @return the likeCountOnTerm
*/
public Integer getLikeCountOnTerm() {
return likeCountOnTerm;
}

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



Expand Down
Loading

0 comments on commit 668ffa2

Please sign in to comment.