-
Notifications
You must be signed in to change notification settings - Fork 190
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#695 Add a internal processing for survey copy
- Loading branch information
1 parent
b47f644
commit 21e72be
Showing
10 changed files
with
450 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
...rces/org/support/project/knowledge/dao/sql/SurveysDao/SurveysDao_select_on_accessable.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
SELECT | ||
KNOWLEDGES.KNOWLEDGE_ID, | ||
KNOWLEDGES.TITLE AS KNOWLEDGE_TITLE, | ||
SURVEYS.TITLE AS TITLE | ||
FROM | ||
KNOWLEDGES | ||
INNER JOIN SURVEYS ON (KNOWLEDGES.KNOWLEDGE_ID = SURVEYS.KNOWLEDGE_ID) | ||
WHERE | ||
KNOWLEDGES.DELETE_FLAG = 0 | ||
AND CAST(KNOWLEDGES.KNOWLEDGE_ID AS VARCHAR(20)) LIKE ? || '%' | ||
AND ( | ||
KNOWLEDGES.PUBLIC_FLAG = 0 | ||
OR ( | ||
KNOWLEDGES.PUBLIC_FLAG = 1 | ||
AND KNOWLEDGES.INSERT_USER = ? | ||
) | ||
OR ( | ||
KNOWLEDGES.PUBLIC_FLAG = 2 | ||
AND EXISTS ( | ||
SELECT | ||
* | ||
FROM | ||
KNOWLEDGE_USERS | ||
WHERE | ||
KNOWLEDGES.KNOWLEDGE_ID = KNOWLEDGE_USERS.KNOWLEDGE_ID | ||
AND KNOWLEDGE_USERS.USER_ID = ? | ||
) | ||
) | ||
OR ( | ||
KNOWLEDGES.PUBLIC_FLAG = 2 | ||
AND EXISTS ( | ||
SELECT | ||
* | ||
FROM | ||
KNOWLEDGE_GROUPS | ||
WHERE | ||
KNOWLEDGES.KNOWLEDGE_ID = KNOWLEDGE_GROUPS.KNOWLEDGE_ID | ||
AND KNOWLEDGE_GROUPS.GROUP_ID IN (%GROUPS%) | ||
) | ||
) | ||
) | ||
ORDER BY | ||
KNOWLEDGES.KNOWLEDGE_ID ASC | ||
LIMIT ? OFFSET ?; |
13 changes: 13 additions & 0 deletions
13
...g/support/project/knowledge/dao/sql/SurveysDao/SurveysDao_select_with_knowledge_title.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
SELECT | ||
KNOWLEDGES.KNOWLEDGE_ID, | ||
KNOWLEDGES.TITLE AS KNOWLEDGE_TITLE, | ||
SURVEYS.TITLE AS TITLE | ||
FROM | ||
KNOWLEDGES | ||
INNER JOIN SURVEYS ON (KNOWLEDGES.KNOWLEDGE_ID = SURVEYS.KNOWLEDGE_ID) | ||
WHERE | ||
KNOWLEDGES.DELETE_FLAG = 0 | ||
AND CAST(KNOWLEDGES.KNOWLEDGE_ID AS VARCHAR(20)) LIKE ? || '%' | ||
ORDER BY | ||
KNOWLEDGES.KNOWLEDGE_ID ASC | ||
LIMIT ? OFFSET ?; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
87 changes: 87 additions & 0 deletions
87
src/test/java/org/support/project/knowledge/dao/SurveysDaoTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
package org.support.project.knowledge.dao; | ||
|
||
import static org.junit.Assert.*; | ||
|
||
import java.util.List; | ||
|
||
import org.junit.Test; | ||
import org.support.project.common.test.Order; | ||
import org.support.project.knowledge.TestCommon; | ||
import org.support.project.knowledge.entity.KnowledgesEntity; | ||
import org.support.project.knowledge.entity.SurveysEntity; | ||
import org.support.project.knowledge.logic.KnowledgeLogic; | ||
import org.support.project.knowledge.vo.KnowledgeData; | ||
import org.support.project.ormapping.common.DBUserPool; | ||
import org.support.project.web.bean.LoginedUser; | ||
|
||
public class SurveysDaoTest extends TestCommon { | ||
|
||
@Test | ||
@Order(order = 1) | ||
public void testSelectWithKnowledgeTitle() throws Exception { | ||
LoginedUser admin = SurveysDaoTest.loginedAdmin; //AdminUser | ||
|
||
DBUserPool.get().setUser(admin.getUserId()); | ||
|
||
// Knowledge登録(非公開) | ||
KnowledgesEntity entity = new KnowledgesEntity(); | ||
entity.setTitle("Test1"); | ||
entity.setContent("テストだよ"); | ||
entity.setTypeId(-100); | ||
KnowledgeLogic logic = KnowledgeLogic.get(); | ||
KnowledgeData data = new KnowledgeData(); | ||
data.setKnowledge(entity); | ||
entity.setPublicFlag(KnowledgeLogic.PUBLIC_FLAG_PRIVATE); | ||
entity = logic.insert(data, admin); | ||
|
||
// Survey登録 | ||
SurveysEntity survey = new SurveysEntity(entity.getKnowledgeId()); | ||
survey.setTitle("テストアンケート"); | ||
SurveysDao.get().save(survey); | ||
|
||
// 検索 | ||
List<SurveysEntity> surveysEntities = SurveysDao.get().selectWithKnowledgeTitle("", 10, 0); | ||
|
||
// 結果確認(1件取得) | ||
assertEquals(1, surveysEntities.size()); | ||
} | ||
|
||
@Test | ||
@Order(order = 2) | ||
public void testSelectWithKnowledgeTitleOnlyAccessAble() throws Exception { | ||
LoginedUser admin = SurveysDaoTest.loginedAdmin; //AdminUser | ||
LoginedUser user = SurveysDaoTest.loginedUser2; | ||
KnowledgeLogic logic = KnowledgeLogic.get(); | ||
|
||
DBUserPool.get().setUser(admin.getUserId()); | ||
|
||
// 検索 | ||
List<SurveysEntity> surveysEntities = SurveysDao.get().selectWithKnowledgeTitleOnlyAccessAble(user, "", 10, 0); | ||
// 結果確認(Privateは取得されない/test1で登録したものが取得される) | ||
assertEquals(0, surveysEntities.size()); | ||
|
||
// Knowledge登録(公開) | ||
KnowledgesEntity entity = new KnowledgesEntity(); | ||
entity.setTitle("Test2"); | ||
entity.setContent("テストだよ"); | ||
entity.setTypeId(-100); | ||
KnowledgeData data = new KnowledgeData(); | ||
data.setKnowledge(entity); | ||
entity.setPublicFlag(KnowledgeLogic.PUBLIC_FLAG_PUBLIC); | ||
entity = logic.insert(data, admin); | ||
|
||
// Survey登録 | ||
SurveysEntity survey = new SurveysEntity(entity.getKnowledgeId()); | ||
survey.setTitle("テストアンケート"); | ||
SurveysDao.get().save(survey); | ||
|
||
// 検索 | ||
surveysEntities = SurveysDao.get().selectWithKnowledgeTitleOnlyAccessAble(user, "", 10, 0); | ||
// 結果確認(1件取得) | ||
assertEquals(1, surveysEntities.size()); | ||
} | ||
|
||
|
||
|
||
|
||
} |
Oops, something went wrong.