Skip to content

Commit

Permalink
#43 共同編集者を指定できるようにした
Browse files Browse the repository at this point in the history
トップページのデザイン変更
  • Loading branch information
koda-masaru committed Jun 8, 2015
1 parent ae80775 commit 6f0a996
Show file tree
Hide file tree
Showing 66 changed files with 2,517 additions and 400 deletions.
10 changes: 0 additions & 10 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -135,15 +135,5 @@

</build>

<distributionManagement>
<repository>
<id>org.support.project-releases</id>
<url>https://support-project.org/nexus/content/repositories/releases/</url>
</repository>
<snapshotRepository>
<id>org.support.project-snapshots</id>
<url>https://support-project.org/nexus/content/repositories/snapshots/</url>
</snapshotRepository>
</distributionManagement>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import org.support.project.common.config.ConfigLoader;
import org.support.project.common.util.StringUtils;
import org.support.project.knowledge.vo.LabelValue;
import org.support.project.web.bean.LabelValue;


public class AppConfig extends org.support.project.web.config.AppConfig {
Expand All @@ -24,7 +24,6 @@ public static AppConfig get() {

private boolean convIndexPath = false;

private List<LabelValue> languages = new ArrayList<>();


/**
Expand All @@ -50,18 +49,5 @@ public void setIndexPath(String indexPath) {
this.indexPath = indexPath;
}

/**
* @return the languages
*/
public List<LabelValue> getLanguages() {
return languages;
}

/**
* @param languages the languages to set
*/
public void setLanguages(List<LabelValue> languages) {
this.languages = languages;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@
import org.support.project.knowledge.logic.TagLogic;
import org.support.project.knowledge.logic.TargetLogic;
import org.support.project.knowledge.logic.UploadedFileLogic;
import org.support.project.knowledge.vo.LabelValue;
import org.support.project.knowledge.vo.LikeCount;
import org.support.project.knowledge.vo.UploadFile;
import org.support.project.web.bean.LabelValue;
import org.support.project.web.bean.LoginedUser;
import org.support.project.web.boundary.Boundary;
import org.support.project.web.common.HttpStatus;
Expand Down Expand Up @@ -132,6 +132,13 @@ public Boundary view() throws InvalidParamException {
List<LabelValue> groups = TargetLogic.get().selectTargetsOnKnowledgeId(knowledgeId);
setAttribute("groups", groups);

// 編集権限
List<LabelValue> editors = TargetLogic.get().selectEditorsOnKnowledgeId(knowledgeId);
setAttribute("editors", editors);
LoginedUser loginedUser = super.getLoginedUser();
boolean edit = knowledgeLogic.isEditor(loginedUser, entity, editors);
setAttribute("edit", edit);

return forward("view.jsp");
}

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import org.support.project.knowledge.control.Control;
import org.support.project.knowledge.logic.GroupLogic;
import org.support.project.knowledge.vo.GroupUser;
import org.support.project.knowledge.vo.LabelValue;
import org.support.project.web.bean.LabelValue;
import org.support.project.web.bean.LoginedUser;
import org.support.project.web.boundary.Boundary;
import org.support.project.web.common.HttpStatus;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,24 @@
import org.support.project.di.DI;
import org.support.project.di.Instance;
import org.support.project.knowledge.control.KnowledgeControlBase;
import org.support.project.knowledge.dao.KnowledgeGroupsDao;
import org.support.project.knowledge.dao.KnowledgesDao;
import org.support.project.knowledge.entity.KnowledgeGroupsEntity;
import org.support.project.knowledge.entity.KnowledgeUsersEntity;
import org.support.project.knowledge.entity.KnowledgesEntity;
import org.support.project.knowledge.entity.TagsEntity;
import org.support.project.knowledge.logic.KnowledgeLogic;
import org.support.project.knowledge.logic.TargetLogic;
import org.support.project.knowledge.logic.UploadedFileLogic;
import org.support.project.knowledge.vo.LabelValue;
import org.support.project.knowledge.vo.UploadFile;
import org.support.project.web.bean.LabelValue;
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.config.HttpMethod;
import org.support.project.web.control.service.Get;
import org.support.project.web.control.service.Post;
import org.support.project.web.entity.GroupsEntity;
import org.support.project.web.exception.InvalidParamException;

@DI(instance=Instance.Prototype)
Expand Down Expand Up @@ -80,13 +85,20 @@ public Boundary view_edit() throws InvalidParamException {
setAttribute("files", files);

// 表示するグループを取得
//List<GroupsEntity> groups = GroupLogic.get().selectGroupsOnKnowledgeId(knowledgeId);
List<LabelValue> groups = TargetLogic.get().selectTargetsOnKnowledgeId(knowledgeId);
setAttribute("groups", groups);

if (!super.getLoginedUser().isAdmin() && entity.getInsertUser().intValue() != super.getLoginUserId().intValue()) {
// 共同編集者
List<LabelValue> editors = TargetLogic.get().selectEditorsOnKnowledgeId(knowledgeId);
setAttribute("editors", editors);
// 編集権限チェック
LoginedUser loginedUser = super.getLoginedUser();
boolean edit = knowledgeLogic.isEditor(loginedUser, entity, editors);
if (!edit) {
setAttribute("edit", false);
addMsgWarn("knowledge.edit.noaccess");
return forward("/open/knowledge/view.jsp");
//return forward("/open/knowledge/view.jsp");
return devolution(HttpMethod.get, "open.knowledge/view", String.valueOf(knowledgeId));
}

return forward("view_edit.jsp");
Expand All @@ -107,6 +119,11 @@ public Boundary add(KnowledgesEntity entity) throws Exception {
//List<GroupsEntity> groups = GroupLogic.get().selectGroups(targets);
List<LabelValue> groups = TargetLogic.get().selectTargets(targets);
setAttribute("groups", groups);

String editorsstr = super.getParam("editors");
String[] editordids = editorsstr.split(",");
List<LabelValue> editors = TargetLogic.get().selectTargets(editordids);
setAttribute("editors", editors);

List<Long> fileNos = new ArrayList<Long>();
Object obj = getParam("files", Object.class);
Expand Down Expand Up @@ -150,7 +167,7 @@ public Boundary add(KnowledgesEntity entity) throws Exception {
String tags = super.getParam("tagNames");
List<TagsEntity> tagList = knowledgeLogic.manegeTags(tags);

entity = knowledgeLogic.insert(entity, tagList, fileNos, groups, super.getLoginedUser());
entity = knowledgeLogic.insert(entity, tagList, fileNos, groups, editors, super.getLoginedUser());
setAttributeOnProperty(entity);

List<UploadFile> files = fileLogic.selectOnKnowledgeId(entity.getKnowledgeId(), getRequest().getContextPath());
Expand All @@ -172,10 +189,14 @@ public Boundary update(KnowledgesEntity entity) throws Exception {

String groupsstr = super.getParam("groups");
String[] targets = groupsstr.split(",");
// List<GroupsEntity> groups = GroupLogic.get().selectGroups(targets);
List<LabelValue> groups = TargetLogic.get().selectTargets(targets);
setAttribute("groups", groups);

String editorsstr = super.getParam("editors");
String[] editordids = editorsstr.split(",");
List<LabelValue> editors = TargetLogic.get().selectTargets(editordids);
setAttribute("editors", editors);

List<Long> fileNos = new ArrayList<Long>();
Object obj = getParam("files", Object.class);
if (obj != null) {
Expand Down Expand Up @@ -222,16 +243,19 @@ public Boundary update(KnowledgesEntity entity) throws Exception {
if (check == null) {
return sendError(HttpStatus.SC_404_NOT_FOUND, "NOT_FOUND");
}
if (!super.getLoginedUser().isAdmin() && check.getInsertUser().intValue() != super.getLoginUserId().intValue()) {
// 編集権限チェック
if (!knowledgeLogic.isEditor(super.getLoginedUser(), check, editors)) {
setAttribute("edit", false);
addMsgWarn("knowledge.edit.noaccess");
return forward("/open/knowledge/view.jsp");
//return forward("/open/knowledge/view.jsp");
return devolution(HttpMethod.get, "open.knowledge/view", String.valueOf(entity.getKnowledgeId()));
}

LOG.trace("save");
String tags = super.getParam("tagNames");
List<TagsEntity> tagList = knowledgeLogic.manegeTags(tags);

entity = knowledgeLogic.update(entity, tagList, fileNos, groups, super.getLoginedUser());
entity = knowledgeLogic.update(entity, tagList, fileNos, groups, editors, super.getLoginedUser());
setAttributeOnProperty(entity);
addMsgSuccess("message.success.update");

Expand Down Expand Up @@ -266,9 +290,12 @@ public Boundary delete() throws Exception {
if (check == null) {
return sendError(HttpStatus.SC_404_NOT_FOUND, "NOT_FOUND");
}
if (!super.getLoginedUser().isAdmin() && check.getInsertUser().intValue() != super.getLoginUserId().intValue()) {
List<LabelValue> editors = TargetLogic.get().selectEditorsOnKnowledgeId(knowledgeId);
if (!knowledgeLogic.isEditor(super.getLoginedUser(), check, editors)) {
setAttribute("edit", false);
addMsgWarn("knowledge.edit.noaccess");
return forward("/open/knowledge/view.jsp");
//return forward("/open/knowledge/view.jsp");
return devolution(HttpMethod.get, "open.knowledge/view", String.valueOf(knowledgeId));
}
LOG.trace("save");
knowledgeLogic.delete(knowledgeId, getLoginedUser());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import org.support.project.common.util.StringUtils;
import org.support.project.knowledge.control.Control;
import org.support.project.knowledge.logic.TargetLogic;
import org.support.project.knowledge.vo.LabelValue;
import org.support.project.web.bean.LabelValue;
import org.support.project.web.boundary.Boundary;
import org.support.project.web.control.service.Get;
import org.support.project.web.exception.InvalidParamException;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package org.support.project.knowledge.dao;

import org.support.project.di.Container;
import org.support.project.di.DI;
import org.support.project.di.Instance;
import org.support.project.knowledge.dao.gen.GenKnowledgeEditGroupsDao;

/**
* 編集可能なグループ
*/
@DI(instance=Instance.Singleton)
public class KnowledgeEditGroupsDao extends GenKnowledgeEditGroupsDao {

/** SerialVersion */
private static final long serialVersionUID = 1L;
/**
* インスタンス取得
* AOPに対応
* @return インスタンス
*/
public static KnowledgeEditGroupsDao get() {
return Container.getComp(KnowledgeEditGroupsDao.class);
}
public void deleteOnKnowledgeId(Long knowledgeId) {
String sql = "DELETE FROM KNOWLEDGE_EDIT_GROUPS WHERE KNOWLEDGE_ID = ?";
super.executeUpdate(sql, knowledgeId);
}



}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package org.support.project.knowledge.dao;

import org.support.project.di.Container;
import org.support.project.di.DI;
import org.support.project.di.Instance;
import org.support.project.knowledge.dao.gen.GenKnowledgeEditUsersDao;

/**
* 編集可能なユーザ
*/
@DI(instance=Instance.Singleton)
public class KnowledgeEditUsersDao extends GenKnowledgeEditUsersDao {

/** SerialVersion */
private static final long serialVersionUID = 1L;
/**
* インスタンス取得
* AOPに対応
* @return インスタンス
*/
public static KnowledgeEditUsersDao get() {
return Container.getComp(KnowledgeEditUsersDao.class);
}
public void deleteOnKnowledgeId(Long knowledgeId) {
String sql = "DELETE FROM KNOWLEDGE_EDIT_USERS WHERE KNOWLEDGE_ID = ?";
super.executeUpdate(sql, knowledgeId);
}



}
12 changes: 11 additions & 1 deletion src/main/java/org/support/project/knowledge/dao/TargetsDao.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
import java.util.List;

import org.support.project.di.Container;
import org.support.project.knowledge.vo.LabelValue;
import org.support.project.ormapping.common.SQLManager;
import org.support.project.ormapping.dao.AbstractDao;
import org.support.project.web.bean.LabelValue;
import org.support.project.web.entity.GroupsEntity;
import org.support.project.web.entity.UsersEntity;

Expand Down Expand Up @@ -55,5 +55,15 @@ public List<UsersEntity> selectUsersOnKnowledgeId(Long knowledgeId) {
return executeQueryList(sql, UsersEntity.class, knowledgeId);
}

public List<GroupsEntity> selectEditorGroupsOnKnowledgeId(Long knowledgeId) {
String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/TargetsDao/selectEditorGroupsOnKnowledgeId.sql");
return executeQueryList(sql, GroupsEntity.class, knowledgeId);
}

public List<UsersEntity> selectEditorUsersOnKnowledgeId(Long knowledgeId) {
String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/TargetsDao/selectEditorUsersOnKnowledgeId.sql");
return executeQueryList(sql, UsersEntity.class, knowledgeId);
}


}
Loading

0 comments on commit 6f0a996

Please sign in to comment.