diff --git a/Third_party_license.txt b/Third_party_license.txt index b75540e6d..de0235b13 100644 --- a/Third_party_license.txt +++ b/Third_party_license.txt @@ -185,3 +185,22 @@ - jstzdetect - License: [MIT] https://pellepim.bitbucket.io/jstz/ - project-url: https://pellepim.bitbucket.io/jstz/ + +- bootstrap-table + - License: [MIT] https://github.com/wenzhixin/bootstrap-table/blob/develop/LICENSE + - project-url: http://bootstrap-table.wenzhixin.net.cn/ + +- tableExport.jquery.plugin + - License: [MIT] https://github.com/hhurz/tableExport.jquery.plugin/blob/master/bower.json + - project-url: https://github.com/hhurz/tableExport.jquery.plugin + +- diff2html + - License: [MIT] https://github.com/rtfpessoa/diff2html#license + - project-url: https://diff2html.xyz/ + +- jsdiff + - License: [BSD License] https://github.com/kpdecker/jsdiff/blob/master/LICENSE + - project-url: https://github.com/kpdecker/jsdiff + + + \ No newline at end of file diff --git a/bower.json b/bower.json index a84d86e44..b223fe2b6 100644 --- a/bower.json +++ b/bower.json @@ -31,10 +31,16 @@ "picEdit": "andyvr/picEdit", "clockpicker": "0.0.7", "moment-timezone": "0.5.11", - "jstzdetect": "1.0.6" + "jstzdetect": "1.0.6", + "bootstrap-table": "1.11.1", + "tableExport.jquery.plugin": "1.8.1", + "diff2html": "2.3.0", + "jsdiff": "3.2.0" }, "devDependencies": {}, "resolutions": { - "jquery": "2.2.3" + "jquery": "2.2.3", + "jspdf": "1.3.2", + "jspdf-autotable": "2.0.17" } } diff --git a/gulpfile.js b/gulpfile.js index 51d0dcb17..b403113fc 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -22,12 +22,20 @@ gulp.task('min', function() { .pipe(gulp.dest('target/knowledge/WEB-INF/views/')); }); -gulp.task('copy', ['copy:bootswatch', 'copy:highlightjs', 'copy:font-awesome', 'copy:flag-icon-css', - 'copy:html5shiv', 'copy:respond', 'copy:MathJax', 'copy:emoji-parser', 'copy:free-file-icons']); +gulp.task('copy', ['copy:bootswatch', 'copy:bootswatch2', 'copy:highlightjs', 'copy:font-awesome', 'copy:flag-icon-css', + 'copy:html5shiv', 'copy:respond', 'copy:MathJax', 'copy:emoji-parser', 'copy:free-file-icons', + 'copy:diff2html', 'copy:jsdiff']); + gulp.task('copy:bootswatch', function() { return gulp.src([ 'src/main/webapp/bower/bootswatch/**/*' ]) + .pipe(gulp.dest('target/knowledge/bower/bootswatch')); +}); +gulp.task('copy:bootswatch2', function() { + return gulp.src([ + 'src/main/webapp/bower/bootswatch/**/*.css' + ]) .pipe(replace(/^@import url\("https:\/\/fonts.googleapis.com\/css.*\)\;/, '')) .pipe(gulp.dest('target/knowledge/bower/bootswatch')); }); @@ -79,6 +87,17 @@ gulp.task('copy:free-file-icons', function() { ]) .pipe(gulp.dest('target/knowledge/bower/teambox.free-file-icons')); }); - +gulp.task('copy:diff2html', function() { + return gulp.src([ + 'src/main/webapp/bower/diff2html/**/*' + ]) + .pipe(gulp.dest('target/knowledge/bower/diff2html')); +}); +gulp.task('copy:jsdiff', function() { + return gulp.src([ + 'src/main/webapp/bower/jsdiff/**/*' + ]) + .pipe(gulp.dest('target/knowledge/bower/jsdiff')); +}); gulp.task('default', ['min', 'copy']); diff --git a/pom.xml b/pom.xml index 8eecbbe6d..0bdd28d62 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ org.support-project knowledge - 1.8.1 + 1.9.0 war knowledge @@ -59,7 +59,7 @@ org.support-project web - 1.8.0 + 1.9.0 diff --git a/src/main/java/org/support/project/knowledge/bat/DataTransferBat.java b/src/main/java/org/support/project/knowledge/bat/DataTransferBat.java index 9ac6d2d11..77fbe805c 100644 --- a/src/main/java/org/support/project/knowledge/bat/DataTransferBat.java +++ b/src/main/java/org/support/project/knowledge/bat/DataTransferBat.java @@ -21,10 +21,11 @@ public static void main(String[] args) throws Exception { try { initLogName("DataTransferBat.log"); configInit(ClassUtils.getShortClassName(DataTransferBat.class)); - + DataTransferLogic.get().requestTransfer(); DataTransferBat bat = new DataTransferBat(); bat.dbInit(); bat.start(); + } catch (Exception e) { LOG.error("any error", e); throw e; @@ -38,10 +39,10 @@ public void run() { try { AppConfig appConfig = ConfigLoader.load(AppConfig.APP_CONFIG, AppConfig.class); String[] parms = { "-tcp", "-baseDir", appConfig.getDatabasePath() }; - + + LOG.info("start h2 database"); Server server = Server.createTcpServer(parms); server.start(); - // System.out.println("Database start..."); serverStarted = true; while (runing) { diff --git a/src/main/java/org/support/project/knowledge/control/admin/TemplateControl.java b/src/main/java/org/support/project/knowledge/control/admin/TemplateControl.java index 87575c64a..c26142ed1 100644 --- a/src/main/java/org/support/project/knowledge/control/admin/TemplateControl.java +++ b/src/main/java/org/support/project/knowledge/control/admin/TemplateControl.java @@ -30,10 +30,11 @@ public class TemplateControl extends Control { * テンプレートの一覧を表示 * * @return + * @throws InvalidParamException */ @Get(publishToken = "admin") @Auth(roles = "admin") - public Boundary list() { + public Boundary list() throws InvalidParamException { // テンプレートの個数はあまり多く出来ないようにする(でないと登録の画面が微妙) List templates = TemplateLogic.get().selectAll(); setAttribute("templates", templates); @@ -54,7 +55,7 @@ public Boundary edit() throws InvalidParamException { } /** - * 編集画面を表示する + * 保存されているデータを取得 * * @return * @throws InvalidParamException @@ -65,7 +66,7 @@ public Boundary load() throws InvalidParamException { Integer id = super.getPathInteger(-1); TemplateMastersEntity entity = TemplateLogic.get().loadTemplate(id); if (entity == null) { - sendError(404, null); + return sendError(404, null); } return send(entity); } @@ -81,7 +82,7 @@ public Boundary load() throws InvalidParamException { * @throws IllegalAccessException * @throws InstantiationException */ - private TemplateMastersEntity loadParams(List errors) + protected TemplateMastersEntity loadParams(List errors) throws InstantiationException, IllegalAccessException, JSONException, IOException, InvalidParamException { TemplateMastersEntity template = new TemplateMastersEntity(); Map values = getParams(); diff --git a/src/main/java/org/support/project/knowledge/control/open/AccountControl.java b/src/main/java/org/support/project/knowledge/control/open/AccountControl.java index 1d79385c1..67b1c1aa9 100644 --- a/src/main/java/org/support/project/knowledge/control/open/AccountControl.java +++ b/src/main/java/org/support/project/knowledge/control/open/AccountControl.java @@ -1,11 +1,16 @@ package org.support.project.knowledge.control.open; +import java.io.ByteArrayInputStream; +import java.io.IOException; import java.io.InputStream; +import java.security.NoSuchAlgorithmException; import java.util.HashMap; import java.util.List; import java.util.Map; import org.apache.http.HttpStatus; +import org.support.project.common.log.Log; +import org.support.project.common.log.LogFactory; import org.support.project.common.util.StringUtils; import org.support.project.di.DI; import org.support.project.di.Instance; @@ -16,6 +21,7 @@ import org.support.project.knowledge.entity.AccountImagesEntity; import org.support.project.knowledge.entity.KnowledgesEntity; import org.support.project.knowledge.entity.TemplateMastersEntity; +import org.support.project.knowledge.logic.IdenticonLogic; import org.support.project.knowledge.logic.KnowledgeLogic; import org.support.project.knowledge.vo.AccountInfo; import org.support.project.knowledge.vo.StockKnowledge; @@ -25,8 +31,10 @@ @DI(instance = Instance.Prototype) public class AccountControl extends Control { + /** ログ */ + private static final Log LOG = LogFactory.getLog(AccountControl.class); + public static final int PAGE_LIMIT = 50; - /** * ユーザのアイコン画像を取得 * @@ -35,22 +43,33 @@ public class AccountControl extends Control { */ @Get public Boundary icon() throws InvalidParamException { - Integer userId = getPathInteger(-1); - - AccountImagesDao dao = AccountImagesDao.get(); - AccountImagesEntity entity = dao.selectOnUserId(userId); - + long size = 12140; String fileName = "icon.png"; String contentType = "image/png"; InputStream inputStream; - long size = 12140; - if (entity != null) { - fileName = entity.getFileName(); - contentType = entity.getContentType(); - size = entity.getFileSize().longValue(); - inputStream = entity.getFileBinary(); - } else { + + Integer userId = getPathInteger(-1); + if (userId.intValue() == -1) { inputStream = getClass().getResourceAsStream("/icon/icon.png"); + } else { + AccountImagesDao dao = AccountImagesDao.get(); + AccountImagesEntity entity = dao.selectOnUserId(userId); + + if (entity != null) { + fileName = entity.getFileName(); + contentType = entity.getContentType(); + size = entity.getFileSize().longValue(); + inputStream = entity.getFileBinary(); + } else { + try { + byte[] bytes = IdenticonLogic.get().generate(String.valueOf(userId)); + size = bytes.length; + inputStream = new ByteArrayInputStream(bytes); + } catch (NoSuchAlgorithmException | IOException e) { + LOG.warn("generate icon error.", e); + inputStream = getClass().getResourceAsStream("/icon/icon.png"); + } + } } return download(fileName, inputStream, size, contentType); } diff --git a/src/main/java/org/support/project/knowledge/control/open/IntervalControl.java b/src/main/java/org/support/project/knowledge/control/open/IntervalControl.java new file mode 100644 index 000000000..06449e903 --- /dev/null +++ b/src/main/java/org/support/project/knowledge/control/open/IntervalControl.java @@ -0,0 +1,19 @@ +package org.support.project.knowledge.control.open; + +import org.support.project.di.DI; +import org.support.project.di.Instance; +import org.support.project.knowledge.control.Control; +import org.support.project.web.bean.Msg; +import org.support.project.web.boundary.Boundary; +import org.support.project.web.control.service.Get; +import org.support.project.web.exception.InvalidParamException; + +@DI(instance = Instance.Prototype) +public class IntervalControl extends Control { + + @Get + public Boundary access() throws InvalidParamException { + return send(new Msg("OK")); + } + +} diff --git a/src/main/java/org/support/project/knowledge/control/protect/KnowledgeControl.java b/src/main/java/org/support/project/knowledge/control/protect/KnowledgeControl.java index 978fbc676..b030278c0 100644 --- a/src/main/java/org/support/project/knowledge/control/protect/KnowledgeControl.java +++ b/src/main/java/org/support/project/knowledge/control/protect/KnowledgeControl.java @@ -8,6 +8,7 @@ import java.util.Map; import org.support.project.common.bean.ValidateError; +import org.support.project.common.config.INT_FLAG; import org.support.project.common.exception.ParseException; import org.support.project.common.log.Log; import org.support.project.common.log.LogFactory; @@ -276,15 +277,25 @@ private Boundary update(KnowledgesEntity entity) throws Exception { errors.add(new ValidateError("knowledge.edit.noaccess")); return sendValidateError(errors); } - + if (!StringUtils.isEmpty(getParam("updateContent")) && getParam("updateContent").toLowerCase().equals("true")) { data.setUpdateContent(true); LOG.debug("コンテンツを更新した"); } else { + // メタデータのみ更新 data.setUpdateContent(false); LOG.debug("メタデータのみ更新"); + if (check.getNotifyStatus() == null || check.getNotifyStatus().intValue() == INT_FLAG.OFF.getValue()) { + if (check.getPublicFlag().intValue() == KnowledgeLogic.PUBLIC_FLAG_PRIVATE && + check.getPublicFlag().intValue() != data.getKnowledge().getPublicFlag().intValue()) { + // まだ通知を一度も出しておらず、かつ、「非公開」になっていたものを、それ以外の区分に変更した場合は、通知を出す + data.setUpdateContent(true); + LOG.debug("メタデータのみ更新であったが、非公開から公開などへ変更した"); + } + } } + KnowledgesEntity updatedEntity = knowledgeLogic.update(data, super.getLoginedUser()); if (data.isUpdateContent()) { @@ -302,10 +313,10 @@ private Boundary update(KnowledgesEntity entity) throws Exception { * @return Boundary * @throws Exception Exception */ - @Post(subscribeToken = "knowledge") + @Post(subscribeToken = "knowledge", checkReqToken = true) public Boundary save(KnowledgesEntity entity) throws Exception { try { - if (entity.getKnowledgeId() != null && entity.getKnowledgeId() > 1) { + if (entity.getKnowledgeId() != null && entity.getKnowledgeId() >= 1) { return update(entity); } else { return add(entity); @@ -321,7 +332,7 @@ public Boundary save(KnowledgesEntity entity) throws Exception { * @return Boundary * @throws Exception Exception */ - @Post(subscribeToken = "knowledge") + @Post(subscribeToken = "knowledge", checkReqToken = true) public Boundary draft() throws Exception { DraftKnowledgesEntity draft = getParamOnProperty(DraftKnowledgesEntity.class); draft.setAccesses(super.getParam("groups")); @@ -356,7 +367,7 @@ public Boundary draft() throws Exception { * @return * @throws Exception */ - @Post(subscribeToken = "knowledge") + @Post(subscribeToken = "knowledge", checkReqToken = true) public Boundary delete() throws Exception { // 共通処理呼の表示条件の保持の呼び出し setViewParam(); diff --git a/src/main/java/org/support/project/knowledge/control/protect/SurveyControl.java b/src/main/java/org/support/project/knowledge/control/protect/SurveyControl.java new file mode 100644 index 000000000..afe817e91 --- /dev/null +++ b/src/main/java/org/support/project/knowledge/control/protect/SurveyControl.java @@ -0,0 +1,285 @@ +package org.support.project.knowledge.control.protect; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +import org.support.project.common.bean.ValidateError; +import org.support.project.common.log.Log; +import org.support.project.common.log.LogFactory; +import org.support.project.common.util.PropertyUtil; +import org.support.project.common.util.StringUtils; +import org.support.project.di.DI; +import org.support.project.di.Instance; +import org.support.project.knowledge.control.admin.TemplateControl; +import org.support.project.knowledge.entity.ItemChoicesEntity; +import org.support.project.knowledge.entity.KnowledgesEntity; +import org.support.project.knowledge.entity.SurveyAnswersEntity; +import org.support.project.knowledge.entity.SurveyChoicesEntity; +import org.support.project.knowledge.entity.SurveyItemAnswersEntity; +import org.support.project.knowledge.entity.SurveyItemsEntity; +import org.support.project.knowledge.entity.SurveysEntity; +import org.support.project.knowledge.entity.TemplateItemsEntity; +import org.support.project.knowledge.entity.TemplateMastersEntity; +import org.support.project.knowledge.logic.KnowledgeLogic; +import org.support.project.knowledge.logic.SurveyLogic; +import org.support.project.knowledge.vo.SurveyReport; +import org.support.project.web.boundary.Boundary; +import org.support.project.web.common.HttpStatus; +import org.support.project.web.config.MessageStatus; +import org.support.project.web.control.service.Delete; +import org.support.project.web.control.service.Get; +import org.support.project.web.control.service.Post; +import org.support.project.web.exception.InvalidParamException; +import org.support.project.web.logic.DateConvertLogic; + +import net.arnx.jsonic.JSONException; + +@DI(instance = Instance.Prototype) +public class SurveyControl extends TemplateControl { + /** ログ */ + private static final Log LOG = LogFactory.getLog(SurveyControl.class); + + + /** + * 登録 + * 画面遷移すると再度画面を作るのが面倒なので、Ajaxアクセスとする + * + * @return + * @throws InvalidParamException + * @throws IOException + * @throws JSONException + * @throws IllegalAccessException + * @throws InstantiationException + */ + @Post(subscribeToken = "survey", checkReqToken = true) + public Boundary save() throws InstantiationException, IllegalAccessException, JSONException, IOException, InvalidParamException { + List errors = new ArrayList(); + TemplateMastersEntity template = loadParams(errors); + if (!errors.isEmpty()) { + return sendValidateError(errors); + } + String id = getParam("knowledgeId"); + Long knowledgeId = null; + if (StringUtils.isLong(id)) { + knowledgeId = Long.parseLong(id); + } + if (knowledgeId == null) { + return sendError(HttpStatus.SC_400_BAD_REQUEST, "BAD_REQUEST"); + } + KnowledgesEntity knowledge = KnowledgeLogic.get().select(knowledgeId, getLoginedUser()); + if (knowledge == null || !KnowledgeLogic.get().isEditor(super.getLoginedUser(), knowledge, null)) { + return sendError(HttpStatus.SC_403_FORBIDDEN, "FORBIDDEN"); + } + // テンプレートと同じ構造にしているが、アンケートに変換して保存する + SurveysEntity survey = convSurvey(template); + survey.setKnowledgeId(knowledgeId); + + // 保存 + survey = SurveyLogic.get().saveSurvey(survey, getLoginedUser()); + + // メッセージ送信 + return sendMsg(MessageStatus.Success, HttpStatus.SC_200_OK, "saved", "message.success.save"); + } + + private SurveysEntity convSurvey(TemplateMastersEntity template) { + SurveysEntity survey = new SurveysEntity(); + survey.setTitle(template.getTypeName()); + survey.setDescription(template.getDescription()); + + List items = template.getItems(); + for (TemplateItemsEntity item : items) { + SurveyItemsEntity sitem = new SurveyItemsEntity(); + sitem.setItemName(item.getItemName()); + sitem.setItemNo(item.getItemNo()); + sitem.setItemType(item.getItemType()); + sitem.setDescription(item.getDescription()); + survey.getItems().add(sitem); + + List choices = item.getChoices(); + for (ItemChoicesEntity choice : choices) { + SurveyChoicesEntity schoice = new SurveyChoicesEntity(); + schoice.setChoiceNo(choice.getChoiceNo()); + schoice.setChoiceLabel(choice.getChoiceLabel()); + schoice.setChoiceValue(choice.getChoiceValue()); + sitem.getChoices().add(schoice); + } + } + + return survey; + } + + + /** + * 一覧取得 + * @return + * @throws InvalidParamException + */ + @Get + public Boundary list() throws InvalidParamException { + Integer page = super.getPathInteger(0); + String plefix = getParam("q"); + if (plefix == null) { + plefix = ""; + } + List list = SurveyLogic.get().listSurveys(getLoginedUser(), plefix, page); + return send(list); + } + + + /** + * 保存されているデータを取得 + * + * @return + * @throws InvalidParamException + */ + @Get + public Boundary load() throws InvalidParamException { + Long id = super.getPathLong(new Long(-1)); + SurveysEntity entity = SurveyLogic.get().loadSurvey(id, getLoginUserId()); + if (entity == null) { + return sendError(404, null); + } + return send(entity); + } + + /** + * アンケート削除 + * @return + * @throws InvalidParamException + */ + @Delete + public Boundary delete() throws InvalidParamException { + Long id = super.getPathLong(new Long(-1)); + SurveyLogic.get().deleteSurvey(id); + return sendMsg(MessageStatus.Success, HttpStatus.SC_200_OK, String.valueOf(id), "message.success.delete"); + } + + + /** + * 回答 + * 画面遷移すると再度画面を作るのが面倒なので、Ajaxアクセスとする + * + * @return + * @throws InvalidParamException + * @throws IOException + * @throws JSONException + * @throws IllegalAccessException + * @throws InstantiationException + */ + @Post(subscribeToken = "knowledge", checkReqToken = true) + public Boundary answer() throws InstantiationException, IllegalAccessException, JSONException, IOException, InvalidParamException { + String id = getParam("knowledgeId"); + if (!StringUtils.isLong(id)) { + return sendError(HttpStatus.SC_400_BAD_REQUEST, "BAD_REQUEST"); + } + Long knowledgeId = new Long(id); + + SurveysEntity survey = SurveyLogic.get().loadSurvey(knowledgeId, getLoginUserId()); + if (survey == null) { + return sendError(HttpStatus.SC_400_BAD_REQUEST, "BAD_REQUEST"); + } + SurveyAnswersEntity answer = new SurveyAnswersEntity(); + answer.setAnswerId(getLoginUserId()); // 回答のIDは、ユーザとする(ユーザ毎に1件) + answer.setKnowledgeId(knowledgeId); + + List items = survey.getItems(); + for (SurveyItemsEntity item : items) { + SurveyItemAnswersEntity answerItem = new SurveyItemAnswersEntity(); + answerItem.setAnswerId(getLoginUserId()); + answerItem.setKnowledgeId(knowledgeId); + answerItem.setItemNo(item.getItemNo()); + answerItem.setItemValue(""); + answer.getItems().add(answerItem); + + String[] itemValues = super.getParam("item_" + item.getItemNo(), String[].class); + if (itemValues != null && itemValues.length == 1) { + String itemValue = itemValues[0]; + if (itemValue.startsWith("[") && itemValue.endsWith("]")) { + itemValue = itemValue.substring(1, itemValue.length() - 1); + answerItem.setItemValue(itemValue); + } else { + answerItem.setItemValue(itemValue); + } + } else if (itemValues != null && itemValues.length > 1) { + for (String itemValue : itemValues) { + StringBuilder value = new StringBuilder(); + if (!StringUtils.isEmpty(answerItem.getItemValue())) { + value.append(answerItem.getItemValue()).append(","); + } + if (itemValue.startsWith("[") && itemValue.endsWith("]")) { + itemValue = itemValue.substring(1, itemValue.length() - 1); + value.append(itemValue); + } else { + value.append(itemValue); + } + answerItem.setItemValue(value.toString()); + } + } + } + + if (LOG.isDebugEnabled()) { + LOG.debug(PropertyUtil.reflectionToString(answer)); + } + SurveyLogic.get().saveAnswer(answer, getLoginUserId()); + + // メッセージ送信 + return sendMsg(MessageStatus.Success, HttpStatus.SC_200_OK, "saved", "message.success.save"); + } + + + /** + * 回答のレポート表示 + * @return + * @throws InvalidParamException + */ + @Get + public Boundary report() throws InvalidParamException { + Long knowledgeId = super.getPathLong(new Long(-1)); + if (!KnowledgeLogic.get().isEditor(super.getLoginedUser(), knowledgeId)) { + return sendError(HttpStatus.SC_403_FORBIDDEN, "FORBIDDEN"); + } + SurveyReport report = SurveyLogic.get().loadAnswers(knowledgeId, getLoginUserId()); + List answers = report.getAnswers(); + for (SurveyAnswersEntity ans : answers) { + ans.setLocalDatetime(DateConvertLogic.get().convertDate(ans.getInsertDatetime(), getRequest())); + } + return send(report); + } + + + /** + * アンケート編集画面を表示 + * @return + * @throws InvalidParamException + */ + @Get(publishToken = "survey") + public Boundary edit() throws InvalidParamException { + Long knowledgeId = super.getPathLong(new Long(-1)); + if (!KnowledgeLogic.get().isEditor(super.getLoginedUser(), knowledgeId)) { + return sendError(HttpStatus.SC_403_FORBIDDEN, "FORBIDDEN"); + } + setAttribute("knowledgeId", knowledgeId); + return forward("edit.jsp"); + } + /** + * アンケート結果レポート + * @return + * @throws InvalidParamException + */ + @Get + public Boundary answers() throws InvalidParamException { + Long knowledgeId = super.getPathLong(new Long(-1)); + if (!KnowledgeLogic.get().isEditor(super.getLoginedUser(), knowledgeId)) { + return sendError(HttpStatus.SC_403_FORBIDDEN, "FORBIDDEN"); + } + setAttribute("knowledgeId", knowledgeId); + return forward("answers.jsp"); + } + + + + + + +} diff --git a/src/main/java/org/support/project/knowledge/dao/SurveyAnswersDao.java b/src/main/java/org/support/project/knowledge/dao/SurveyAnswersDao.java index 57d39b792..3cb0d0fc2 100644 --- a/src/main/java/org/support/project/knowledge/dao/SurveyAnswersDao.java +++ b/src/main/java/org/support/project/knowledge/dao/SurveyAnswersDao.java @@ -21,6 +21,14 @@ public class SurveyAnswersDao extends GenSurveyAnswersDao { public static SurveyAnswersDao get() { return Container.getComp(SurveyAnswersDao.class); } + public void deleteOnKnowledgeId(Long knowledgeId) { + String sql = "DELETE FROM SURVEY_ANSWERS WHERE KNOWLEDGE_ID = ?"; + executeUpdate(sql, knowledgeId); + } + public int selectCountOnKnowledgeId(Long knowledgeId) { + String sql = "SELECT COUNT(*) FROM SURVEY_ANSWERS WHERE KNOWLEDGE_ID = ?"; + return executeQuerySingle(sql, Integer.class, knowledgeId); + } diff --git a/src/main/java/org/support/project/knowledge/dao/SurveyChoicesDao.java b/src/main/java/org/support/project/knowledge/dao/SurveyChoicesDao.java index 2f88c7335..3d9351875 100644 --- a/src/main/java/org/support/project/knowledge/dao/SurveyChoicesDao.java +++ b/src/main/java/org/support/project/knowledge/dao/SurveyChoicesDao.java @@ -21,6 +21,11 @@ public class SurveyChoicesDao extends GenSurveyChoicesDao { public static SurveyChoicesDao get() { return Container.getComp(SurveyChoicesDao.class); } + + public void deleteOnKnowledgeId(Long knowledgeId) { + String sql = "DELETE FROM SURVEY_CHOICES WHERE KNOWLEDGE_ID = ?"; + executeUpdate(sql, knowledgeId); + } diff --git a/src/main/java/org/support/project/knowledge/dao/SurveyItemAnswersDao.java b/src/main/java/org/support/project/knowledge/dao/SurveyItemAnswersDao.java index eb6d8b2e2..ebb910684 100644 --- a/src/main/java/org/support/project/knowledge/dao/SurveyItemAnswersDao.java +++ b/src/main/java/org/support/project/knowledge/dao/SurveyItemAnswersDao.java @@ -1,10 +1,13 @@ package org.support.project.knowledge.dao; +import java.util.List; + 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.GenSurveyItemAnswersDao; +import org.support.project.knowledge.entity.SurveyItemAnswersEntity; /** * アンケートの回答 @@ -21,6 +24,14 @@ public class SurveyItemAnswersDao extends GenSurveyItemAnswersDao { public static SurveyItemAnswersDao get() { return Container.getComp(SurveyItemAnswersDao.class); } + public void deleteOnKnowledgeId(Long knowledgeId) { + String sql = "DELETE FROM SURVEY_ITEM_ANSWERS WHERE KNOWLEDGE_ID = ?"; + executeUpdate(sql, knowledgeId); + } + public List selectOnKnowledgeIdAndAnswerId(Long knowledgeId, Integer userId) { + String sql = "SELECT * FROM SURVEY_ITEM_ANSWERS WHERE KNOWLEDGE_ID = ? AND ANSWER_ID = ?"; + return executeQueryList(sql, SurveyItemAnswersEntity.class, knowledgeId, userId); + } diff --git a/src/main/java/org/support/project/knowledge/dao/SurveyItemsDao.java b/src/main/java/org/support/project/knowledge/dao/SurveyItemsDao.java index ae7684c0f..cda8433c6 100644 --- a/src/main/java/org/support/project/knowledge/dao/SurveyItemsDao.java +++ b/src/main/java/org/support/project/knowledge/dao/SurveyItemsDao.java @@ -3,7 +3,6 @@ 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.GenSurveyItemsDao; /** @@ -21,6 +20,11 @@ public class SurveyItemsDao extends GenSurveyItemsDao { public static SurveyItemsDao get() { return Container.getComp(SurveyItemsDao.class); } + + public void deleteOnKnowledgeId(Long knowledgeId) { + String sql = "DELETE FROM SURVEY_ITEMS WHERE KNOWLEDGE_ID = ?"; + executeUpdate(sql, knowledgeId); + } diff --git a/src/main/java/org/support/project/knowledge/dao/SurveysDao.java b/src/main/java/org/support/project/knowledge/dao/SurveysDao.java index 17f0546f0..bc3aa36de 100644 --- a/src/main/java/org/support/project/knowledge/dao/SurveysDao.java +++ b/src/main/java/org/support/project/knowledge/dao/SurveysDao.java @@ -1,10 +1,16 @@ package org.support.project.knowledge.dao; +import java.util.ArrayList; +import java.util.List; + 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.GenSurveysDao; +import org.support.project.knowledge.entity.SurveysEntity; +import org.support.project.ormapping.common.SQLManager; +import org.support.project.web.bean.LoginedUser; +import org.support.project.web.entity.GroupsEntity; /** * アンケート @@ -21,7 +27,63 @@ public class SurveysDao extends GenSurveysDao { public static SurveysDao get() { return Container.getComp(SurveysDao.class); } + + /** + * IDのプレフィックスで絞り込んだアンケートの一覧を取得 + * @param idPrefix + * @param limit + * @param offset + * @return + */ + public List selectWithKnowledgeTitle(String idPrefix, int limit, int offset) { + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/SurveysDao/SurveysDao_select_with_knowledge_title.sql"); + return executeQueryList(sql, SurveysEntity.class, idPrefix, limit, offset); + } + /** + * IDのプレフィックスで絞り込んだアンケートの一覧を取得 + * アクセス権のあるKnowledgeに紐付いたもののみ + * @param loginedUser + * @param idPrefix + * @param limit + * @param offset + * @return + */ + public List selectWithKnowledgeTitleOnlyAccessAble(LoginedUser loginedUser, String idPrefix, int limit, int offset) { + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/SurveysDao/SurveysDao_select_on_accessable.sql"); + List params = new ArrayList<>(); + params.add(idPrefix); + Integer loginuserId = Integer.MIN_VALUE; + if (loginedUser != null) { + loginuserId = loginedUser.getUserId(); + } + params.add(loginuserId); + params.add(loginuserId); + + List groups = new ArrayList<>(); + groups.add(0); // ALL Groups + if (loginedUser != null && loginedUser.getGroups() != null) { + List 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, SurveysEntity.class, params.toArray(new Object[0])); + } } diff --git a/src/main/java/org/support/project/knowledge/dao/gen/GenMailLocaleTemplatesDao.java b/src/main/java/org/support/project/knowledge/dao/gen/GenMailLocaleTemplatesDao.java index 924319dfe..88db5e38f 100644 --- a/src/main/java/org/support/project/knowledge/dao/gen/GenMailLocaleTemplatesDao.java +++ b/src/main/java/org/support/project/knowledge/dao/gen/GenMailLocaleTemplatesDao.java @@ -103,6 +103,15 @@ public MailLocaleTemplatesEntity selectOnKey(String key, String templateId) { String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/MailLocaleTemplatesDao/MailLocaleTemplatesDao_select_on_key.sql"); return executeQuerySingle(sql, MailLocaleTemplatesEntity.class, key, templateId); } + /** + * Select data that not deleted on KEY column. + * @param key key + * @return list + */ + public List selectOnKey(String key) { + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/MailLocaleTemplatesDao/MailLocaleTemplatesDao_select_on_col_key.sql"); + return executeQueryList(sql, MailLocaleTemplatesEntity.class, key); + } /** * Select data that not deleted on TEMPLATE_ID column. * @param templateId templateId @@ -118,7 +127,7 @@ public List selectOnTemplateId(String templateId) { * @return list */ public List physicalSelectOnKey(String key) { - String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/MailLocaleTemplatesDao/MailLocaleTemplatesDao_physical_select_on_key.sql"); + String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/MailLocaleTemplatesDao/MailLocaleTemplatesDao_physical_select_on_col_key.sql"); return executeQueryList(sql, MailLocaleTemplatesEntity.class, key); } /** diff --git a/src/main/java/org/support/project/knowledge/deploy/v0_0_1/InitializeSystem.java b/src/main/java/org/support/project/knowledge/deploy/v0_0_1/InitializeSystem.java index f720f9484..60b0b028a 100644 --- a/src/main/java/org/support/project/knowledge/deploy/v0_0_1/InitializeSystem.java +++ b/src/main/java/org/support/project/knowledge/deploy/v0_0_1/InitializeSystem.java @@ -1,9 +1,8 @@ package org.support.project.knowledge.deploy.v0_0_1; -import java.io.IOException; -import java.io.UnsupportedEncodingException; - import org.support.project.common.util.FileUtil; +import org.support.project.common.util.StringUtils; +import org.support.project.common.util.SystemUtils; import org.support.project.knowledge.config.AppConfig; import org.support.project.knowledge.dao.ServiceConfigsDao; import org.support.project.knowledge.dao.ServiceLocaleConfigsDao; @@ -22,7 +21,8 @@ import org.support.project.web.entity.UsersEntity; public class InitializeSystem implements Migrate { - + private String adminKey = "admin"; + public static InitializeSystem get() { return org.support.project.di.Container.getComp(InitializeSystem.class); } @@ -34,7 +34,7 @@ public boolean doMigrate() throws Exception { return true; } - private void addInitDatas() throws UnsupportedEncodingException, IOException { + private void addInitDatas() throws Exception { // 権限の追加 RolesEntity adminRole = RolesEntity.get(); adminRole.setRoleId(1); @@ -52,9 +52,17 @@ private void addInitDatas() throws UnsupportedEncodingException, IOException { UsersDao usersDao = UsersDao.get(); UsersEntity usersEntity = UsersEntity.get(); usersEntity.setUserId(1); - usersEntity.setUserKey("admin"); - usersEntity.setPassword("admin123"); - usersEntity.setUserName("管理者ユーザ"); + String admin = SystemUtils.getenv("KNOWLEDGE_ADMIN_KEY"); + if (!StringUtils.isEmpty(admin)) { + adminKey = admin; + } + usersEntity.setUserKey(adminKey); + String password = SystemUtils.getenv("KNOWLEDGE_ADMIN_PASSWORD"); + if (StringUtils.isEmpty(password)) { + password = "admin123"; + } + usersEntity.setPassword(password); + usersEntity.setUserName("Administrator"); usersDao.save(usersEntity); // 管理者ユーザと管理者権を紐付け @@ -81,6 +89,7 @@ private void addInitDatas() throws UnsupportedEncodingException, IOException { MailLogic.get().initMailTemplate(); } + private void createTables() { DatabaseControlDao dao1 = new DatabaseControlDao(); dao1.dropAllTable(); @@ -97,5 +106,6 @@ private void createTables() { }; initializeDao.initializeDatabase(sqlpaths); } - + + } diff --git a/src/main/java/org/support/project/knowledge/entity/SurveyAnswersEntity.java b/src/main/java/org/support/project/knowledge/entity/SurveyAnswersEntity.java index 2ad1585b7..bb065c63c 100644 --- a/src/main/java/org/support/project/knowledge/entity/SurveyAnswersEntity.java +++ b/src/main/java/org/support/project/knowledge/entity/SurveyAnswersEntity.java @@ -1,16 +1,12 @@ package org.support.project.knowledge.entity; -import org.support.project.knowledge.entity.gen.GenSurveyAnswersEntity; - +import java.util.ArrayList; import java.util.List; -import java.util.Map; -import org.support.project.common.bean.ValidateError; import org.support.project.di.Container; import org.support.project.di.DI; import org.support.project.di.Instance; - -import java.sql.Timestamp; +import org.support.project.knowledge.entity.gen.GenSurveyAnswersEntity; /** @@ -19,6 +15,13 @@ @DI(instance = Instance.Prototype) public class SurveyAnswersEntity extends GenSurveyAnswersEntity { + private List items = new ArrayList(); + + /** 回答者の名前 */ + private String userName; + /** 回答集計を操作しているユーザのタイムゾーン/ロケールでの日付文字列 */ + private String localDatetime; + /** SerialVersion */ private static final long serialVersionUID = 1L; @@ -47,4 +50,46 @@ public SurveyAnswersEntity(Integer answerId, Long knowledgeId) { super( answerId, knowledgeId); } + /** + * @return the items + */ + public List getItems() { + return items; + } + + /** + * @param items the items to set + */ + public void setItems(List items) { + this.items = items; + } + + /** + * @return the userName + */ + public String getUserName() { + return userName; + } + + /** + * @param userName the userName to set + */ + public void setUserName(String userName) { + this.userName = userName; + } + + /** + * @return the localDatetime + */ + public String getLocalDatetime() { + return localDatetime; + } + + /** + * @param localDatetime the localDatetime to set + */ + public void setLocalDatetime(String localDatetime) { + this.localDatetime = localDatetime; + } + } diff --git a/src/main/java/org/support/project/knowledge/entity/SurveyItemsEntity.java b/src/main/java/org/support/project/knowledge/entity/SurveyItemsEntity.java index 8e78a35d0..c2a47a964 100644 --- a/src/main/java/org/support/project/knowledge/entity/SurveyItemsEntity.java +++ b/src/main/java/org/support/project/knowledge/entity/SurveyItemsEntity.java @@ -1,16 +1,12 @@ package org.support.project.knowledge.entity; -import org.support.project.knowledge.entity.gen.GenSurveyItemsEntity; - +import java.util.ArrayList; import java.util.List; -import java.util.Map; -import org.support.project.common.bean.ValidateError; import org.support.project.di.Container; import org.support.project.di.DI; import org.support.project.di.Instance; - -import java.sql.Timestamp; +import org.support.project.knowledge.entity.gen.GenSurveyItemsEntity; /** @@ -19,6 +15,11 @@ @DI(instance = Instance.Prototype) public class SurveyItemsEntity extends GenSurveyItemsEntity { + private List choices = new ArrayList<>(); + + /** 項目値 */ + private String itemValue; + /** SerialVersion */ private static final long serialVersionUID = 1L; @@ -47,4 +48,32 @@ public SurveyItemsEntity(Integer itemNo, Long knowledgeId) { super( itemNo, knowledgeId); } + /** + * @return the choices + */ + public List getChoices() { + return choices; + } + + /** + * @param choices the choices to set + */ + public void setChoices(List choices) { + this.choices = choices; + } + + /** + * @return the itemValue + */ + public String getItemValue() { + return itemValue; + } + + /** + * @param itemValue the itemValue to set + */ + public void setItemValue(String itemValue) { + this.itemValue = itemValue; + } + } diff --git a/src/main/java/org/support/project/knowledge/entity/SurveysEntity.java b/src/main/java/org/support/project/knowledge/entity/SurveysEntity.java index 089963bb0..e4cfca0b1 100644 --- a/src/main/java/org/support/project/knowledge/entity/SurveysEntity.java +++ b/src/main/java/org/support/project/knowledge/entity/SurveysEntity.java @@ -1,16 +1,12 @@ package org.support.project.knowledge.entity; -import org.support.project.knowledge.entity.gen.GenSurveysEntity; - +import java.util.ArrayList; import java.util.List; -import java.util.Map; -import org.support.project.common.bean.ValidateError; import org.support.project.di.Container; import org.support.project.di.DI; import org.support.project.di.Instance; - -import java.sql.Timestamp; +import org.support.project.knowledge.entity.gen.GenSurveysEntity; /** @@ -19,6 +15,12 @@ @DI(instance = Instance.Prototype) public class SurveysEntity extends GenSurveysEntity { + private List items = new ArrayList(); + + private boolean editable; + + private String knowledgeTitle; + /** SerialVersion */ private static final long serialVersionUID = 1L; @@ -46,4 +48,46 @@ public SurveysEntity(Long knowledgeId) { super( knowledgeId); } + /** + * @return the items + */ + public List getItems() { + return items; + } + + /** + * @param items the items to set + */ + public void setItems(List items) { + this.items = items; + } + + /** + * @return the editable + */ + public boolean isEditable() { + return editable; + } + + /** + * @param editable the editable to set + */ + public void setEditable(boolean editable) { + this.editable = editable; + } + + /** + * @return the knowledgeTitle + */ + public String getKnowledgeTitle() { + return knowledgeTitle; + } + + /** + * @param knowledgeTitle the knowledgeTitle to set + */ + public void setKnowledgeTitle(String knowledgeTitle) { + this.knowledgeTitle = knowledgeTitle; + } + } diff --git a/src/main/java/org/support/project/knowledge/indexer/impl/LuceneIndexer.java b/src/main/java/org/support/project/knowledge/indexer/impl/LuceneIndexer.java index b3c6eeaff..f37451b91 100644 --- a/src/main/java/org/support/project/knowledge/indexer/impl/LuceneIndexer.java +++ b/src/main/java/org/support/project/knowledge/indexer/impl/LuceneIndexer.java @@ -50,30 +50,32 @@ private String getIndexPath() { } public void writeIndex(IndexingValue indexingValue) throws Exception { - boolean create = true; - File indexDir = new File(getIndexPath()); - if (!indexDir.exists()) { - indexDir.mkdirs(); - } else { - String[] children = indexDir.list(); - if (children != null && children.length > 0) { - create = false; + synchronized (FIELD_LABEL_TYPE) { + boolean create = true; + File indexDir = new File(getIndexPath()); + if (!indexDir.exists()) { + indexDir.mkdirs(); + } else { + String[] children = indexDir.list(); + if (children != null && children.length > 0) { + create = false; + } } - } - Directory dir = FSDirectory.open(indexDir); - IndexWriterConfig iwc = new IndexWriterConfig(Version.LUCENE_4_10_2, analyzer); - if (create) { - iwc.setOpenMode(OpenMode.CREATE); - } else { - iwc.setOpenMode(OpenMode.CREATE_OR_APPEND); - } - IndexWriter writer = null; - try { - writer = new IndexWriter(dir, iwc); - addDoc(writer, indexingValue); - } finally { - if (writer != null) { - writer.close(); + Directory dir = FSDirectory.open(indexDir); + IndexWriterConfig iwc = new IndexWriterConfig(Version.LUCENE_4_10_2, analyzer); + if (create) { + iwc.setOpenMode(OpenMode.CREATE); + } else { + iwc.setOpenMode(OpenMode.CREATE_OR_APPEND); + } + IndexWriter writer = null; + try { + writer = new IndexWriter(dir, iwc); + addDoc(writer, indexingValue); + } finally { + if (writer != null) { + writer.close(); + } } } } diff --git a/src/main/java/org/support/project/knowledge/logic/AccountLogic.java b/src/main/java/org/support/project/knowledge/logic/AccountLogic.java index a07d801f3..81b4b4e62 100644 --- a/src/main/java/org/support/project/knowledge/logic/AccountLogic.java +++ b/src/main/java/org/support/project/knowledge/logic/AccountLogic.java @@ -7,7 +7,6 @@ import java.util.List; import java.util.UUID; -import org.apache.commons.fileupload.FileItem; import org.support.project.aop.Aspect; import org.support.project.common.bean.ValidateError; import org.support.project.common.log.Log; @@ -25,8 +24,12 @@ import org.support.project.knowledge.vo.UploadFile; import org.support.project.web.bean.LoginedUser; import org.support.project.web.dao.ConfirmMailChangesDao; +import org.support.project.web.dao.GroupsDao; +import org.support.project.web.dao.RolesDao; import org.support.project.web.dao.UsersDao; import org.support.project.web.entity.ConfirmMailChangesEntity; +import org.support.project.web.entity.GroupsEntity; +import org.support.project.web.entity.RolesEntity; import org.support.project.web.entity.UsersEntity; @DI(instance = Instance.Singleton) @@ -209,5 +212,29 @@ public List completeChangeEmailRequest(String id, LoginedUser log mailChangesDao.delete(mailChangesEntity); return errors; } - + + /** + * ログインユーザのオブジェクトを生成する + * @param userKey + * @return + */ + public LoginedUser createLoginUser(String userKey) { + UsersDao usersDao = UsersDao.get(); + UsersEntity usersEntity = usersDao.selectOnUserKey(userKey); + RolesDao rolesDao = RolesDao.get(); + List rolesEntities = rolesDao.selectOnUserKey(userKey); + + LoginedUser loginedUser = new LoginedUser(); + loginedUser.setLoginUser(usersEntity); + loginedUser.setRoles(rolesEntities); + loginedUser.setLocale(usersEntity.getLocale()); + + // グループ + GroupsDao groupsDao = GroupsDao.get(); + List groups = groupsDao.selectMyGroup(loginedUser, 0, Integer.MAX_VALUE); + loginedUser.setGroups(groups); + + return loginedUser; + } + } diff --git a/src/main/java/org/support/project/knowledge/logic/DataTransferLogic.java b/src/main/java/org/support/project/knowledge/logic/DataTransferLogic.java index 4015cfb5e..32c61491f 100644 --- a/src/main/java/org/support/project/knowledge/logic/DataTransferLogic.java +++ b/src/main/java/org/support/project/knowledge/logic/DataTransferLogic.java @@ -74,27 +74,27 @@ public void transferData(ConnectionConfig from, ConnectionConfig to) throws Exce initDB.start(); // コピー先のDBの初期化 - LOG.info("migrate to db"); + LOG.info("init and migrate to db : " + to.getName()); ConnectionManager.getInstance().setDefaultConnectionName(to.getName()); - DatabaseControlDao dao1 = new DatabaseControlDao(); - org.support.project.web.dao.gen.DatabaseControlDao dao2 = new org.support.project.web.dao.gen.DatabaseControlDao(); - dao1.setConnectionName(to.getName()); - dao2.setConnectionName(to.getName()); - dao1.dropAllTable(); - dao2.dropAllTable(); + DatabaseControlDao knowledgeControlDao = new DatabaseControlDao(); + org.support.project.web.dao.gen.DatabaseControlDao webControlDao = new org.support.project.web.dao.gen.DatabaseControlDao(); + knowledgeControlDao.setConnectionName(to.getName()); + webControlDao.setConnectionName(to.getName()); + knowledgeControlDao.dropAllTable(); + webControlDao.dropAllTable(); initDB.start(); // データコピー先のDBに入っている、初期データを削除 LOG.info("clear init data from to db."); ConnectionManager.getInstance().setDefaultConnectionName(to.getName()); List truncateTargets = new ArrayList(); - truncateTargets.add(GroupsDao.get()); +// truncateTargets.add(GroupsDao.get()); truncateTargets.add(RolesDao.get()); truncateTargets.add(UserRolesDao.get()); truncateTargets.add(UsersDao.get()); - truncateTargets.add(SystemsDao.get()); - truncateTargets.add(TemplateItemsDao.get()); - truncateTargets.add(TemplateMastersDao.get()); +// truncateTargets.add(SystemsDao.get()); +// truncateTargets.add(TemplateItemsDao.get()); +// truncateTargets.add(TemplateMastersDao.get()); for (AbstractDao targetDao : truncateTargets) { targetDao.setConnectionName(to.getName()); Method truncateMethods = targetDao.getClass().getMethod("truncate"); @@ -149,7 +149,7 @@ public void transferData(ConnectionConfig from, ConnectionConfig to) throws Exce List list = (List) selectAllMethods.invoke(dao, args); // Toへデータ登録 - LOG.info(" -> insert data to " + to.getName()); + LOG.info(" -> insert data(100) to " + to.getName()); ConnectionManager.getInstance().setDefaultConnectionName(to.getName()); setConnectionNameMethods.invoke(dao, to.getName()); TransactionManager transactionManager = Container.getComp(TransactionManager.class); @@ -158,8 +158,26 @@ public void transferData(ConnectionConfig from, ConnectionConfig to) throws Exce if (LOG.isTraceEnabled()) { LOG.trace(entity); } - Method insertMethods = class1.getMethod("rawPhysicalInsert", entity.getClass()); - insertMethods.invoke(dao, entity); + Method getKeyValuesMethods = entity.getClass().getMethod("getKeyValues"); + Object[] keys = (Object[]) getKeyValuesMethods.invoke(entity); + Class[] params = new Class[keys.length]; + StringBuilder builder = new StringBuilder(); + for (int j = 0; j < keys.length; j++) { + params[j] = keys[j].getClass(); + if (j > 0) { + builder.append(","); + } + builder.append(keys[j]); + } + LOG.trace(class1.getName() + " : " + builder.toString()); + Method physicalSelectOnKeyMethods = class1.getMethod("physicalSelectOnKey", params); + Object obj = physicalSelectOnKeyMethods.invoke(dao, keys); + if (obj == null) { + Method insertMethods = class1.getMethod("rawPhysicalInsert", entity.getClass()); + insertMethods.invoke(dao, entity); + } else { + LOG.warn("skip (already exists): " + class1.getName() + " : " + builder.toString()); + } } transactionManager.commit(to.getName()); } diff --git a/src/main/java/org/support/project/knowledge/logic/IdenticonLogic.java b/src/main/java/org/support/project/knowledge/logic/IdenticonLogic.java new file mode 100644 index 000000000..3d290ec1a --- /dev/null +++ b/src/main/java/org/support/project/knowledge/logic/IdenticonLogic.java @@ -0,0 +1,111 @@ +package org.support.project.knowledge.logic; + +import java.awt.geom.AffineTransform; +import java.awt.image.AffineTransformOp; +import java.awt.image.BufferedImage; +import java.awt.image.WritableRaster; +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.IOException; +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; + +import javax.imageio.ImageIO; + +import org.support.project.common.log.Log; +import org.support.project.common.log.LogFactory; +import org.support.project.common.util.RandomUtil; +import org.support.project.di.Container; +import org.support.project.di.DI; +import org.support.project.di.Instance; +import org.support.project.knowledge.vo.SizeLimitMap; + +@DI(instance = Instance.Singleton) +public class IdenticonLogic { + /** ログ */ + private static final Log LOG = LogFactory.getLog(IdenticonLogic.class); + + public static IdenticonLogic get() { + return Container.getComp(IdenticonLogic.class); + } + + private MessageDigest digest = null; + public static final int ICON_SIZE = 20; + // アイコンが登録されていない場合に、アイコンを生成するが、良く使われる人は20人までキャッシュする + private SizeLimitMap _map = new SizeLimitMap<>(20); + + public static void main(String[] args) throws IOException, NoSuchAlgorithmException { + String userName = RandomUtil.randamGen(16); + LOG.info("start"); + BufferedImage identicon = IdenticonLogic.get().generateIdenticons(userName); + LOG.info("end"); + ImageIO.write(identicon,"PNG",new File(userName + ".png")); + } + + public byte[] hash(String str) throws NoSuchAlgorithmException { + if (digest == null) { + digest = MessageDigest.getInstance("MD5"); + } + byte[] hash = digest.digest(str.getBytes()); + return hash; + } + + public byte[] generate(String id) throws NoSuchAlgorithmException, IOException{ + if (_map.containsKey(id)) { + return _map.get(id); + } + BufferedImage img = generateIdenticons(id, ICON_SIZE, ICON_SIZE); + ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); + ImageIO.write(img,"PNG", outputStream); + byte[] bytes = outputStream.toByteArray(); + _map.put(id, bytes); + return bytes; + } + + + public BufferedImage generateIdenticons(String id) throws NoSuchAlgorithmException{ + return generateIdenticons(id, ICON_SIZE, ICON_SIZE); + } + + + public BufferedImage generateIdenticons(String id, int image_width, int image_height) throws NoSuchAlgorithmException{ + int width = 5; + int height = 5; + + byte[] hash = hash(id); + + BufferedImage identicon = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); + WritableRaster raster = identicon.getRaster(); + + int [] background = new int [] {255,255,255, 0}; + int [] foreground = new int [] {hash[0] & 255, hash[1] & 255, hash[2] & 255, 255}; + + for(int x=0 ; x < width ; x++) { + //Enforce horizontal symmetry + int i = x < 3 ? x : 4 - x; + for(int y=0 ; y < height; y++) { + int [] pixelColor; + //toggle pixels based on bit being on/off + if((hash[i] >> y & 1) == 1) + pixelColor = foreground; + else + pixelColor = background; + raster.setPixel(x, y, pixelColor); + } + } + + BufferedImage finalImage = new BufferedImage(image_width, image_height, BufferedImage.TYPE_INT_ARGB); + + //Scale image to the size you want + AffineTransform at = new AffineTransform(); + at.scale(image_width / width, image_height / height); + AffineTransformOp op = new AffineTransformOp(at, AffineTransformOp.TYPE_NEAREST_NEIGHBOR); + finalImage = op.filter(identicon, finalImage); + + return finalImage; + } + + + + +} diff --git a/src/main/java/org/support/project/knowledge/logic/KnowledgeLogic.java b/src/main/java/org/support/project/knowledge/logic/KnowledgeLogic.java index 5e158507c..1c6f1063c 100644 --- a/src/main/java/org/support/project/knowledge/logic/KnowledgeLogic.java +++ b/src/main/java/org/support/project/knowledge/logic/KnowledgeLogic.java @@ -540,9 +540,24 @@ public List searchKnowledge(String keyword, List t } // グループが指定されてる場合はグループのみ対象にして検索する - if (groups != null) { + if (groups != null && !groups.isEmpty()) { + boolean exit = false; for (GroupsEntity groupsEntity : groups) { - searchingValue.addGroup(groupsEntity.getGroupId()); + // 指定のグループは、自分が所属しているグループかどうか + List logiedUserGroups = loginedUser.getGroups(); + if (logiedUserGroups != null && !logiedUserGroups.isEmpty()) { + for (GroupsEntity userGroup : logiedUserGroups) { + if (userGroup.getGroupId().intValue() == groupsEntity.getGroupId().intValue()) { + searchingValue.addGroup(groupsEntity.getGroupId()); + exit = true; + } + } + } + } + if (!exit) { + // 権限の無いグループの情報を参照しようとしているので、検索できないようにする + LOG.warn("Bad request group param"); + searchingValue.addTag(-123); //ありえないタグで検索するので、絶対に何もヒットしない } return searchKnowledge(searchingValue); } @@ -1319,6 +1334,9 @@ public void reindexing(KnowledgesEntity knowledgesEntity) throws Exception { * @return */ public boolean isEditor(LoginedUser loginedUser, Long knowledgeId) { + if (loginedUser.isAdmin()) { + return true; + } KnowledgesEntity check = KnowledgesDao.get().selectOnKey(knowledgeId); if (check == null) { return false; @@ -1349,22 +1367,24 @@ public boolean isEditor(LoginedUser loginedUser, KnowledgesEntity entity, List groups = loginedUser.getGroups(); - if (groups != null) { - for (GroupsEntity groupsEntity : groups) { - if (groupsEntity.getGroupId().intValue() == id.intValue()) { - return true; + if (editors != null) { + for (LabelValue labelValue : editors) { + Integer id = TargetLogic.get().getGroupId(labelValue.getValue()); + if (id != Integer.MIN_VALUE) { + List groups = loginedUser.getGroups(); + if (groups != null) { + for (GroupsEntity groupsEntity : groups) { + if (groupsEntity.getGroupId().intValue() == id.intValue()) { + return true; + } } } - } - } else { - id = TargetLogic.get().getUserId(labelValue.getValue()); - if (id != Integer.MIN_VALUE) { - if (id.intValue() == loginedUser.getUserId().intValue()) { - return true; + } else { + id = TargetLogic.get().getUserId(labelValue.getValue()); + if (id != Integer.MIN_VALUE) { + if (id.intValue() == loginedUser.getUserId().intValue()) { + return true; + } } } } diff --git a/src/main/java/org/support/project/knowledge/logic/MailLogic.java b/src/main/java/org/support/project/knowledge/logic/MailLogic.java index 65ea316dd..d9e6b3f48 100644 --- a/src/main/java/org/support/project/knowledge/logic/MailLogic.java +++ b/src/main/java/org/support/project/knowledge/logic/MailLogic.java @@ -958,7 +958,7 @@ public void notifyKnowledgeUpdate(NotifyQueuesEntity notifyQueuesEntity) throws */ private void updateNotifyStatus(KnowledgesEntity knowledge) { if (knowledge.getNotifyStatus() == null || knowledge.getNotifyStatus().intValue() == 0) { - knowledge.setNotifyStatus(1); // 通知済へ + knowledge.setNotifyStatus(INT_FLAG.ON.getValue()); // 通知済へ KnowledgesDao.get().physicalUpdate(knowledge); // 更新日時などは更新しない } } diff --git a/src/main/java/org/support/project/knowledge/logic/SurveyLogic.java b/src/main/java/org/support/project/knowledge/logic/SurveyLogic.java new file mode 100644 index 000000000..936511ad5 --- /dev/null +++ b/src/main/java/org/support/project/knowledge/logic/SurveyLogic.java @@ -0,0 +1,205 @@ +package org.support.project.knowledge.logic; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.support.project.aop.Aspect; +import org.support.project.common.log.Log; +import org.support.project.common.log.LogFactory; +import org.support.project.di.Container; +import org.support.project.di.DI; +import org.support.project.di.Instance; +import org.support.project.knowledge.dao.SurveyAnswersDao; +import org.support.project.knowledge.dao.SurveyChoicesDao; +import org.support.project.knowledge.dao.SurveyItemAnswersDao; +import org.support.project.knowledge.dao.SurveyItemsDao; +import org.support.project.knowledge.dao.SurveysDao; +import org.support.project.knowledge.entity.SurveyAnswersEntity; +import org.support.project.knowledge.entity.SurveyChoicesEntity; +import org.support.project.knowledge.entity.SurveyItemAnswersEntity; +import org.support.project.knowledge.entity.SurveyItemsEntity; +import org.support.project.knowledge.entity.SurveysEntity; +import org.support.project.knowledge.vo.SurveyReport; +import org.support.project.web.bean.LoginedUser; +import org.support.project.web.dao.UsersDao; +import org.support.project.web.entity.UsersEntity; + +@DI(instance = Instance.Singleton) +public class SurveyLogic extends TemplateLogic { + private static final Log LOG = LogFactory.getLog(SurveyLogic.class); + + public static SurveyLogic get() { + return Container.getComp(SurveyLogic.class); + } + + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public SurveysEntity saveSurvey(SurveysEntity survey, LoginedUser loginedUser) { + LOG.trace("saveSurvey"); + SurveyItemsDao.get().deleteOnKnowledgeId(survey.getKnowledgeId()); + SurveyChoicesDao.get().deleteOnKnowledgeId(survey.getKnowledgeId()); + + survey = SurveysDao.get().save(survey); + List items = survey.getItems(); + int itemNo = 0; + for (SurveyItemsEntity item : items) { + item.setKnowledgeId(survey.getKnowledgeId()); + item.setItemNo(itemNo); + SurveyItemsDao.get().save(item); + + int choiceNo = 0; + List choices = item.getChoices(); + for (SurveyChoicesEntity choice : choices) { + choice.setKnowledgeId(survey.getKnowledgeId()); + choice.setItemNo(itemNo); + choice.setChoiceNo(choiceNo); + SurveyChoicesDao.get().save(choice); + choiceNo++; + } + itemNo++; + } + return new SurveysEntity(); + } + + /** + * 登録されているアンケートの一覧を取得(ページ制御あり) + * @param user ログインユーザ + * @param idPrefix IDのプレフィックス(絞込条件) + * @param page ページ番号 + * @return + */ + public List listSurveys(LoginedUser user, String idPrefix, int page) { + int limit = 10; + int offset = page * limit; + if (user == null) { + // アンケート一覧はコピーする対象を選択する機能なので、Knowledge編集者のはずで、userがnullはありえない + return new ArrayList<>(); + } else if (user.isAdmin()) { + // アクセス権関係なく、全てのアンケート情報を取得 + return SurveysDao.get().selectWithKnowledgeTitle(idPrefix, limit, offset); + } else { + // アクセス可能なアンケートの情報を取得 + return SurveysDao.get().selectWithKnowledgeTitleOnlyAccessAble(user, idPrefix, limit, offset); + } + } + + + /** + * アンケート情報の取得 + * @param knowledgeId + * @param userId + * @return + */ + public SurveysEntity loadSurvey(Long knowledgeId, Integer userId) { + LOG.trace("loadSurvey"); + SurveysEntity entity = SurveysDao.get().selectOnKey(knowledgeId); + if (entity == null) { + return null; + } + List itemsEntities = SurveyItemsDao.get().selectOnKnowledgeId(knowledgeId); + // 念のためソート + Collections.sort(itemsEntities, new Comparator() { + @Override + public int compare(SurveyItemsEntity o1, SurveyItemsEntity o2) { + if (!o1.getItemNo().equals(o2.getItemNo())) { + return o1.getItemNo().compareTo(o2.getItemNo()); + } + return 0; + } + }); + entity.setItems(itemsEntities); + Map itemMap = new HashMap(); + for (SurveyItemsEntity itemsEntity : itemsEntities) { + itemsEntity.setChoices(new ArrayList()); + itemMap.put(itemsEntity.getItemNo(), itemsEntity); + } + + List choicesEntities = SurveyChoicesDao.get().selectOnKnowledgeId(knowledgeId); + // 念のためソート + Collections.sort(choicesEntities, new Comparator() { + @Override + public int compare(SurveyChoicesEntity o1, SurveyChoicesEntity o2) { + if (!o1.getKnowledgeId().equals(o2.getKnowledgeId())) { + return o1.getKnowledgeId().compareTo(o2.getKnowledgeId()); + } + if (!o1.getItemNo().equals(o2.getItemNo())) { + return o1.getItemNo().compareTo(o2.getItemNo()); + } + if (!o1.getChoiceNo().equals(o2.getChoiceNo())) { + return o1.getChoiceNo().compareTo(o2.getChoiceNo()); + } + return 0; + } + }); + for (SurveyChoicesEntity itemChoicesEntity : choicesEntities) { + if (itemMap.containsKey(itemChoicesEntity.getItemNo())) { + SurveyItemsEntity templateItemsEntity = itemMap.get(itemChoicesEntity.getItemNo()); + templateItemsEntity.getChoices().add(itemChoicesEntity); + } + } + + List annswers = SurveyItemAnswersDao.get().selectOnKnowledgeIdAndAnswerId(knowledgeId, userId); + for (SurveyItemAnswersEntity answer : annswers) { + if (itemMap.containsKey(answer.getItemNo())) { + SurveyItemsEntity templateItemsEntity = itemMap.get(answer.getItemNo()); + templateItemsEntity.setItemValue(answer.getItemValue()); + } + } + + entity.setEditable(true); + return entity; + } + + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public void deleteSurvey(Long knowledgeId) { + SurveysDao.get().physicalDelete(knowledgeId); + SurveyItemsDao.get().deleteOnKnowledgeId(knowledgeId); + SurveyChoicesDao.get().deleteOnKnowledgeId(knowledgeId); + + SurveyAnswersDao.get().deleteOnKnowledgeId(knowledgeId); + SurveyItemAnswersDao.get().deleteOnKnowledgeId(knowledgeId); + } + + + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public void saveAnswer(SurveyAnswersEntity answer, Integer userId) { + SurveyAnswersDao.get().save(answer); + List items = answer.getItems(); + for (SurveyItemAnswersEntity item : items) { + SurveyItemAnswersDao.get().save(item); + } + } + + public SurveyReport loadAnswers(Long knowledgeId, Integer userId) { + SurveyReport report = new SurveyReport(); + List answers = SurveyAnswersDao.get().selectOnKnowledgeId(knowledgeId); + for (SurveyAnswersEntity answer : answers) { + List items = SurveyItemAnswersDao.get().selectOnKnowledgeIdAndAnswerId(knowledgeId, answer.getAnswerId()); + // 念のためソート + Collections.sort(items, new Comparator() { + @Override + public int compare(SurveyItemAnswersEntity o1, SurveyItemAnswersEntity o2) { + if (!o1.getItemNo().equals(o2.getItemNo())) { + return o1.getItemNo().compareTo(o2.getItemNo()); + } + return 0; + } + }); + answer.setItems(items); + + UsersEntity user = UsersDao.get().physicalSelectOnKey(answer.getAnswerId()); + if (user != null) { + answer.setUserName(user.getUserName()); + } + } + report.setAnswers(answers); + + SurveysEntity survey = this.loadSurvey(knowledgeId, userId); + report.setSurvey(survey); + return report; + } + +} diff --git a/src/main/java/org/support/project/knowledge/vo/KnowledgeData.java b/src/main/java/org/support/project/knowledge/vo/KnowledgeData.java index ff920f601..8fbc20ba4 100644 --- a/src/main/java/org/support/project/knowledge/vo/KnowledgeData.java +++ b/src/main/java/org/support/project/knowledge/vo/KnowledgeData.java @@ -212,7 +212,7 @@ public String getTagsStr() { * @param tagsStr the tagsStr to set */ public void setTagsStr(String tagsStr) { - this.tagsStr = tagsStr; + this.setTags(tagsStr); } /** * Get filesStrs diff --git a/src/main/java/org/support/project/knowledge/vo/SizeLimitMap.java b/src/main/java/org/support/project/knowledge/vo/SizeLimitMap.java new file mode 100644 index 000000000..a7cb711e8 --- /dev/null +++ b/src/main/java/org/support/project/knowledge/vo/SizeLimitMap.java @@ -0,0 +1,275 @@ +package org.support.project.knowledge.vo; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Set; +import java.util.function.BiConsumer; +import java.util.function.BiFunction; +import java.util.function.Function; + +public class SizeLimitMap implements Map{ + private LinkedHashMap _map; + private int _limit; + + public SizeLimitMap(int limit) { + super(); + _map = new LinkedHashMap<>(); + _limit = limit; + } + + /** + * @param key + * @param value + * @return + * @see java.util.HashMap#put(java.lang.Object, java.lang.Object) + */ + public V put(K key, V value) { + synchronized (_map) { + while (_map.size() >= _limit) { + K k = new ArrayList(_map.keySet()).get(_map.size() - 1); + _map.remove(k); + } + return _map.put(key, value); + } + } + + + /** + * @param o + * @return + * @see java.util.AbstractMap#equals(java.lang.Object) + */ + public boolean equals(Object o) { + return _map.equals(o); + } + + /** + * @param value + * @return + * @see java.util.LinkedHashMap#containsValue(java.lang.Object) + */ + public boolean containsValue(Object value) { + return _map.containsValue(value); + } + + /** + * @param key + * @return + * @see java.util.LinkedHashMap#get(java.lang.Object) + */ + public V get(Object key) { + return _map.get(key); + } + + /** + * @return + * @see java.util.AbstractMap#hashCode() + */ + public int hashCode() { + return _map.hashCode(); + } + + /** + * @param key + * @param defaultValue + * @return + * @see java.util.LinkedHashMap#getOrDefault(java.lang.Object, java.lang.Object) + */ + public V getOrDefault(Object key, V defaultValue) { + return _map.getOrDefault(key, defaultValue); + } + + /** + * + * @see java.util.LinkedHashMap#clear() + */ + public void clear() { + _map.clear(); + } + + /** + * @return + * @see java.util.AbstractMap#toString() + */ + public String toString() { + return _map.toString(); + } + + /** + * @return + * @see java.util.LinkedHashMap#keySet() + */ + public Set keySet() { + return _map.keySet(); + } + + /** + * @return + * @see java.util.HashMap#size() + */ + public int size() { + return _map.size(); + } + + /** + * @return + * @see java.util.HashMap#isEmpty() + */ + public boolean isEmpty() { + return _map.isEmpty(); + } + + /** + * @return + * @see java.util.LinkedHashMap#values() + */ + public Collection values() { + return _map.values(); + } + + /** + * @param key + * @return + * @see java.util.HashMap#containsKey(java.lang.Object) + */ + public boolean containsKey(Object key) { + return _map.containsKey(key); + } + + + /** + * @return + * @see java.util.LinkedHashMap#entrySet() + */ + public Set> entrySet() { + return _map.entrySet(); + } + + /** + * @param action + * @see java.util.LinkedHashMap#forEach(java.util.function.BiConsumer) + */ + public void forEach(BiConsumer action) { + _map.forEach(action); + } + + /** + * @param function + * @see java.util.LinkedHashMap#replaceAll(java.util.function.BiFunction) + */ + public void replaceAll(BiFunction function) { + _map.replaceAll(function); + } + + /** + * @param m + * @see java.util.HashMap#putAll(java.util.Map) + */ + public void putAll(Map m) { + _map.putAll(m); + } + + /** + * @param key + * @return + * @see java.util.HashMap#remove(java.lang.Object) + */ + public V remove(Object key) { + return _map.remove(key); + } + + /** + * @param key + * @param value + * @return + * @see java.util.HashMap#putIfAbsent(java.lang.Object, java.lang.Object) + */ + public V putIfAbsent(K key, V value) { + return _map.putIfAbsent(key, value); + } + + /** + * @param key + * @param value + * @return + * @see java.util.HashMap#remove(java.lang.Object, java.lang.Object) + */ + public boolean remove(Object key, Object value) { + return _map.remove(key, value); + } + + /** + * @param key + * @param oldValue + * @param newValue + * @return + * @see java.util.HashMap#replace(java.lang.Object, java.lang.Object, java.lang.Object) + */ + public boolean replace(K key, V oldValue, V newValue) { + return _map.replace(key, oldValue, newValue); + } + + /** + * @param key + * @param value + * @return + * @see java.util.HashMap#replace(java.lang.Object, java.lang.Object) + */ + public V replace(K key, V value) { + return _map.replace(key, value); + } + + /** + * @param key + * @param mappingFunction + * @return + * @see java.util.HashMap#computeIfAbsent(java.lang.Object, java.util.function.Function) + */ + public V computeIfAbsent(K key, Function mappingFunction) { + return _map.computeIfAbsent(key, mappingFunction); + } + + /** + * @param key + * @param remappingFunction + * @return + * @see java.util.HashMap#computeIfPresent(java.lang.Object, java.util.function.BiFunction) + */ + public V computeIfPresent(K key, BiFunction remappingFunction) { + return _map.computeIfPresent(key, remappingFunction); + } + + /** + * @param key + * @param remappingFunction + * @return + * @see java.util.HashMap#compute(java.lang.Object, java.util.function.BiFunction) + */ + public V compute(K key, BiFunction remappingFunction) { + return _map.compute(key, remappingFunction); + } + + /** + * @param key + * @param value + * @param remappingFunction + * @return + * @see java.util.HashMap#merge(java.lang.Object, java.lang.Object, java.util.function.BiFunction) + */ + public V merge(K key, V value, BiFunction remappingFunction) { + return _map.merge(key, value, remappingFunction); + } + + /** + * @return + * @see java.util.HashMap#clone() + */ + public Object clone() { + return _map.clone(); + } + + + +} diff --git a/src/main/java/org/support/project/knowledge/vo/SurveyReport.java b/src/main/java/org/support/project/knowledge/vo/SurveyReport.java new file mode 100644 index 000000000..ae0f7b692 --- /dev/null +++ b/src/main/java/org/support/project/knowledge/vo/SurveyReport.java @@ -0,0 +1,41 @@ +package org.support.project.knowledge.vo; + +import java.io.Serializable; +import java.util.List; + +import org.support.project.knowledge.entity.SurveyAnswersEntity; +import org.support.project.knowledge.entity.SurveysEntity; + +public class SurveyReport implements Serializable { + /** シリアルバージョン */ + private static final long serialVersionUID = 1L; + /** アンケート情報 */ + private SurveysEntity survey; + /** 回答 */ + private List answers; + /** + * @return the survey + */ + public SurveysEntity getSurvey() { + return survey; + } + /** + * @param survey the survey to set + */ + public void setSurvey(SurveysEntity survey) { + this.survey = survey; + } + /** + * @return the answers + */ + public List getAnswers() { + return answers; + } + /** + * @param answers the answers to set + */ + public void setAnswers(List answers) { + this.answers = answers; + } + +} diff --git a/src/main/resources/appresource.properties b/src/main/resources/appresource.properties index 7af2461c1..ba74d7ee1 100644 --- a/src/main/resources/appresource.properties +++ b/src/main/resources/appresource.properties @@ -59,7 +59,7 @@ message.allready.started=Already started. message.confirm.delete=Are you sure you want to delete? # Common Label -label.version=v1.8.1 +label.version=v1.9.0 label.login=Sign in label.previous = Previous label.next=Next @@ -111,6 +111,8 @@ label.draft=Draft label.release=Release label.new=New label.initialize=Initialize +label.move.up=Move Up +label.move.down=Move Down label.public.view= [Public] label.protect.view= [Protection] @@ -260,6 +262,7 @@ knowledge.view.label.nonparticipation=Nonparticipation knowledge.view.label.participants=Participants knowledge.view.label.status.participation=Participant knowledge.view.label.status.wait.cansel=Wait Cancel +knowledge.view.label.answer=Answer survey knowledge.view.msg.toc.empty=TOC item is not found. knowledge.view.msg.url.copy=Copied the URL knowledge.view.msg.participate=Registered a participant @@ -683,6 +686,7 @@ knowledge.template.label.not.editable=This template is the default template of t knowledge.template.msg.not.delete=The default template (knowledge, bookmark) can not be deleted. knowledge.template.label.item=Item knowledge.template.label.item.text=Text +knowledge.template.label.item.textarea=TextArea knowledge.template.label.item.integer=Integer knowledge.template.label.item.radio=Radio knowledge.template.label.item.checkbox=Checkbox @@ -786,3 +790,19 @@ knowledge.event.label.timing.week=this week knowledge.event.label.timing.tody=today knowledge.event.label.timing.soon=soon +knowledge.survey.label.edit=Edit Survey +knowledge.survey.label.report=Report Survey +knowledge.survey.label.answer=Answers +knowledge.survey.label.answer.title=Title +knowledge.survey.label.answer.count=Count +knowledge.survey.label.answer.date=DateTime +knowledge.survey.label.answer.user=User +knowledge.survey.label.copy=Copy survey +knowledge.survey.label.search=Search on knowledge id prefix +knowledge.survey.msg.survey=Please post first (because you need to assign ID) +knowledge.survey.msg.warning.move=Please do not delete items or move up and down, if there is an answer already. +knowledge.survey.msg.survey.notfound=survey data is not found +knowledge.survey.msg.copy.select=Please select a survey for copy. +knowledge.survey.msg.copy.confirm=Do you want to copy the survey? This contents are overwritten with the contents to be copied. + + diff --git a/src/main/resources/appresource_ja.properties b/src/main/resources/appresource_ja.properties index 61dc46846..866503a8f 100644 --- a/src/main/resources/appresource_ja.properties +++ b/src/main/resources/appresource_ja.properties @@ -59,7 +59,7 @@ message.allready.started=すでに開始済です message.confirm.delete=本当に削除しますか? # Common Label -label.version=v1.8.1 +label.version=v1.9.0 label.login=サインイン label.previous = 前へ label.next = 次へ @@ -111,6 +111,8 @@ label.draft=下書き label.release=投稿する label.new=新規作成 label.initialize=初期化 +label.move.up=上へ移動 +label.move.down=下へ移動 label.public.view= [公開] label.protect.view= [保護] @@ -260,6 +262,7 @@ knowledge.view.label.nonparticipation=参加取消し knowledge.view.label.participants=参加者 knowledge.view.label.status.participation=参加登録済 knowledge.view.label.status.wait.cansel=キャンセル待ち +knowledge.view.label.answer=アンケート回答 knowledge.view.msg.toc.empty=目次になる「見出し」が見つかりません。「見出し」はMarkdownで「#」で開始する行に付きます。 knowledge.view.msg.url.copy=URLをコピーしました knowledge.view.msg.participate=参加登録しました @@ -683,6 +686,7 @@ knowledge.template.label.not.editable=このテンプレートはシステムの knowledge.template.msg.not.delete=デフォルトのテンプレート(knowledge,bookmark)は削除できません knowledge.template.label.item=項目 knowledge.template.label.item.text=テキスト項目 +knowledge.template.label.item.textarea=テキストエリア項目 knowledge.template.label.item.integer=整数項目 knowledge.template.label.item.radio=ラジオボタン項目 knowledge.template.label.item.checkbox=チェックボックス項目 @@ -786,3 +790,18 @@ knowledge.event.label.timing.week=今週 knowledge.event.label.timing.tody=本日 knowledge.event.label.timing.soon=もうすぐ +knowledge.survey.label.edit=アンケート編集 +knowledge.survey.label.report=アンケート集計 +knowledge.survey.label.answer=アンケートの回答 +knowledge.survey.label.answer.title=アンケートのタイトル +knowledge.survey.label.answer.count=回答件数 +knowledge.survey.label.answer.date=回答日時 +knowledge.survey.label.answer.user=回答者 +knowledge.survey.label.copy=アンケートのコピー +knowledge.survey.label.search=IDで検索 +knowledge.survey.msg.survey=先に投稿してください(IDを採番する必要があるため) +knowledge.survey.msg.warning.move=既にアンケートの回答が登録されている場合は、項目の削除、上下の移動をしないでください。 +knowledge.survey.msg.survey.notfound=取得できるアンケートが存在しません。まだアンケートが一件も登録されていないと思われます。 +knowledge.survey.msg.copy.select=コピーするアンケートを選択してください +knowledge.survey.msg.copy.confirm=アンケートをコピーしますか?編集中の内容はコピーされる内容で上書きされます。 + diff --git a/src/main/resources/log4j.xml b/src/main/resources/log4j.xml index b21b03ab5..c75941cea 100644 --- a/src/main/resources/log4j.xml +++ b/src/main/resources/log4j.xml @@ -13,7 +13,7 @@ - + diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/MailLocaleTemplatesDao/MailLocaleTemplatesDao_physical_select_on_col_key.sql b/src/main/resources/org/support/project/knowledge/dao/sql/MailLocaleTemplatesDao/MailLocaleTemplatesDao_physical_select_on_col_key.sql new file mode 100644 index 000000000..f62abb4ee --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/MailLocaleTemplatesDao/MailLocaleTemplatesDao_physical_select_on_col_key.sql @@ -0,0 +1,4 @@ +SELECT * FROM MAIL_LOCALE_TEMPLATES + WHERE +KEY = ? +; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/MailLocaleTemplatesDao/MailLocaleTemplatesDao_physical_select_on_key.sql b/src/main/resources/org/support/project/knowledge/dao/sql/MailLocaleTemplatesDao/MailLocaleTemplatesDao_physical_select_on_key.sql index f62abb4ee..cf4ca6c9f 100644 --- a/src/main/resources/org/support/project/knowledge/dao/sql/MailLocaleTemplatesDao/MailLocaleTemplatesDao_physical_select_on_key.sql +++ b/src/main/resources/org/support/project/knowledge/dao/sql/MailLocaleTemplatesDao/MailLocaleTemplatesDao_physical_select_on_key.sql @@ -1,4 +1,5 @@ SELECT * FROM MAIL_LOCALE_TEMPLATES WHERE KEY = ? + AND TEMPLATE_ID = ? ; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/MailLocaleTemplatesDao/MailLocaleTemplatesDao_select_on_col_key.sql b/src/main/resources/org/support/project/knowledge/dao/sql/MailLocaleTemplatesDao/MailLocaleTemplatesDao_select_on_col_key.sql new file mode 100644 index 000000000..1c8e90348 --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/MailLocaleTemplatesDao/MailLocaleTemplatesDao_select_on_col_key.sql @@ -0,0 +1,4 @@ +SELECT * FROM MAIL_LOCALE_TEMPLATES + WHERE +TEMPLATE_ID = ? + AND DELETE_FLAG = 0; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/SurveysDao/SurveysDao_select_on_accessable.sql b/src/main/resources/org/support/project/knowledge/dao/sql/SurveysDao/SurveysDao_select_on_accessable.sql new file mode 100644 index 000000000..8727e5cb7 --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/SurveysDao/SurveysDao_select_on_accessable.sql @@ -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 ?; diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/SurveysDao/SurveysDao_select_with_knowledge_title.sql b/src/main/resources/org/support/project/knowledge/dao/sql/SurveysDao/SurveysDao_select_with_knowledge_title.sql new file mode 100644 index 000000000..723ac4d40 --- /dev/null +++ b/src/main/resources/org/support/project/knowledge/dao/sql/SurveysDao/SurveysDao_select_with_knowledge_title.sql @@ -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 ?; diff --git a/src/main/resources/org/support/project/knowledge/database/init_datas.sql b/src/main/resources/org/support/project/knowledge/database/init_datas.sql index 1e7e00cf1..0bfd75b5c 100644 --- a/src/main/resources/org/support/project/knowledge/database/init_datas.sql +++ b/src/main/resources/org/support/project/knowledge/database/init_datas.sql @@ -1,18 +1,18 @@ INSERT INTO GROUPS ( GROUP_ID, GROUP_KEY, GROUP_NAME, DESCRIPTION, PARENT_GROUP_KEY, GROUP_CLASS, ROW_ID, INSERT_USER, INSERT_DATETIME, UPDATE_USER, UPDATE_DATETIME, DELETE_FLAG ) - VALUES (0,'g-all','ALL USERS','全てのユーザが所属するグループ',null,0,'g-all',0,'2015-07-04 00:00:00',null,null,0); + VALUES (0,'g-all','ALL USERS','Group which all users belong',null,0,'g-all',0,'2015-07-04 00:00:00',null,null,0); INSERT INTO TEMPLATE_MASTERS ( TYPE_ID, TYPE_NAME, TYPE_ICON, DESCRIPTION, INSERT_USER, INSERT_DATETIME, UPDATE_USER, UPDATE_DATETIME, DELETE_FLAG ) -VALUES (-100,'knowledge', 'fa-book', '通常のナレッジ',0,'2015-09-09 00:00:00',null,null,0); +VALUES (-100,'knowledge', 'fa-book', 'Share information written by Markdown',0,'2015-09-09 00:00:00',null,null,0); INSERT INTO TEMPLATE_MASTERS ( TYPE_ID, TYPE_NAME, TYPE_ICON, DESCRIPTION, INSERT_USER, INSERT_DATETIME, UPDATE_USER, UPDATE_DATETIME, DELETE_FLAG ) -VALUES (-99,'bookmark', 'fa-bookmark', '特定のURLについての情報をシェアします',0,'2015-09-09 00:00:00',null,null,0); +VALUES (-99,'bookmark', 'fa-bookmark', 'Share information about the URL',0,'2015-09-09 00:00:00',null,null,0); INSERT INTO TEMPLATE_ITEMS ( TYPE_ID, ITEM_NO, ITEM_NAME, ITEM_TYPE, INSERT_USER, INSERT_DATETIME, UPDATE_USER, UPDATE_DATETIME, DELETE_FLAG ) VALUES (-99,0,'URL',0,0,'2015-09-09 00:00:00',null,null,0); INSERT INTO TEMPLATE_MASTERS ( TYPE_ID, TYPE_NAME, TYPE_ICON, DESCRIPTION, INSERT_USER, INSERT_DATETIME, UPDATE_USER, UPDATE_DATETIME, DELETE_FLAG ) -VALUES (-101,'event', 'fa-calendar', '勉強会などのイベント情報をシェアします',0,'2017-02-16 00:00:00',null,null,0); +VALUES (-101,'event', 'fa-calendar', 'Share information about a event',0,'2017-02-16 00:00:00',null,null,0); INSERT INTO TEMPLATE_ITEMS ( TYPE_ID, ITEM_NO, ITEM_NAME, ITEM_TYPE, INSERT_USER, INSERT_DATETIME, UPDATE_USER, UPDATE_DATETIME, DELETE_FLAG ) VALUES (-101,0,'Date',20,0,'2017-02-16 00:00:00',null,null,0); diff --git a/src/main/webapp/WEB-INF/views/admin/template/edit.jsp b/src/main/webapp/WEB-INF/views/admin/template/edit.jsp index f9f64ec20..d220b6f53 100644 --- a/src/main/webapp/WEB-INF/views/admin/template/edit.jsp +++ b/src/main/webapp/WEB-INF/views/admin/template/edit.jsp @@ -17,35 +17,10 @@ - + + - - + @@ -79,6 +54,9 @@ function deleteTemplate() {  <%= jspUtil.label("knowledge.template.label.item.add", jspUtil.label("knowledge.template.label.item.text")) %> + +  <%= jspUtil.label("knowledge.template.label.item.add", jspUtil.label("knowledge.template.label.item.textarea")) %> +  <%= jspUtil.label("knowledge.template.label.item.add", jspUtil.label("knowledge.template.label.item.radio")) %> diff --git a/src/main/webapp/WEB-INF/views/admin/template/include_template_label.jsp b/src/main/webapp/WEB-INF/views/admin/template/include_template_label.jsp new file mode 100644 index 000000000..5ecf2c75e --- /dev/null +++ b/src/main/webapp/WEB-INF/views/admin/template/include_template_label.jsp @@ -0,0 +1,33 @@ +<%@page pageEncoding="UTF-8" isELIgnored="false" session="false" errorPage="/WEB-INF/views/commons/errors/jsp_error.jsp"%> + +<%@page import="org.support.project.web.util.JspUtil"%> + +<%@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); %> + + + diff --git a/src/main/webapp/WEB-INF/views/commons/layout/commonFooter.jsp b/src/main/webapp/WEB-INF/views/commons/layout/commonFooter.jsp index e7da17f0b..b9fe98dba 100644 --- a/src/main/webapp/WEB-INF/views/commons/layout/commonFooter.jsp +++ b/src/main/webapp/WEB-INF/views/commons/layout/commonFooter.jsp @@ -13,7 +13,7 @@ <%= jspUtil.label("knowledge.footer.about") %>
  • - <%= jspUtil.label("knowledge.footer.manual") %> + <%= jspUtil.label("knowledge.footer.manual") %>
  • <%= jspUtil.label("knowledge.footer.license") %> diff --git a/src/main/webapp/WEB-INF/views/commons/layout/commonScripts.jsp b/src/main/webapp/WEB-INF/views/commons/layout/commonScripts.jsp index dbec91ae1..50c36ea01 100644 --- a/src/main/webapp/WEB-INF/views/commons/layout/commonScripts.jsp +++ b/src/main/webapp/WEB-INF/views/commons/layout/commonScripts.jsp @@ -41,6 +41,7 @@ var _LOGIN_USER_ID = <%= jspUtil.id() %>; <% } else { %> var _LOGIN_USER_ID = null; <% } %> +var _LANG = '<%= jspUtil.locale().getLanguage()%>'; var getCookies = function() { var result = new Array(); diff --git a/src/main/webapp/WEB-INF/views/open/knowledge/history.jsp b/src/main/webapp/WEB-INF/views/open/knowledge/history.jsp index c664046f0..7f3882a85 100644 --- a/src/main/webapp/WEB-INF/views/open/knowledge/history.jsp +++ b/src/main/webapp/WEB-INF/views/open/knowledge/history.jsp @@ -12,14 +12,26 @@ + + + + @@ -36,22 +48,20 @@

    <%= jspUtil.label("knowledge.histories.label.diff") %>
    -
    <%= jspUtil.label("knowledge.histories.list.label.empty") %>
    -<%= jspUtil.out("change") %>
    -
    +

    <%= jspUtil.label("knowledge.histories.label.history") %>
    - +

    <%= jspUtil.label("knowledge.histories.label.now") %>
    - +
    diff --git a/src/main/webapp/WEB-INF/views/open/knowledge/partials/common_list.jsp b/src/main/webapp/WEB-INF/views/open/knowledge/partials/common_list.jsp index 0d571451c..36ce002e6 100644 --- a/src/main/webapp/WEB-INF/views/open/knowledge/partials/common_list.jsp +++ b/src/main/webapp/WEB-INF/views/open/knowledge/partials/common_list.jsp @@ -36,13 +36,13 @@ <%=jspUtil.out("params")%>" class="text-primary btn-link">
    + + #<%= jspUtil.out("knowledge.knowledgeId") %> + <%=jspUtil.out("knowledge.title", JspUtil.ESCAPE_CLEAR)%>
    - - #<%= jspUtil.out("knowledge.knowledgeId") %> - " alt="icon" width="20" height="20" /> @@ -135,7 +135,7 @@ - "> + "> <%=jspUtil.out("tagName")%>   diff --git a/src/main/webapp/WEB-INF/views/open/knowledge/partials/partials-view-attach-files.jsp b/src/main/webapp/WEB-INF/views/open/knowledge/partials/partials-view-attach-files.jsp index 57c38b7f8..49c4e231a 100644 --- a/src/main/webapp/WEB-INF/views/open/knowledge/partials/partials-view-attach-files.jsp +++ b/src/main/webapp/WEB-INF/views/open/knowledge/partials/partials-view-attach-files.jsp @@ -9,23 +9,30 @@ <% JspUtil jspUtil = new JspUtil(request, pageContext); %> -<% int MAX_COUNT = 5; %> +<% int MAX_COUNT = 6; %> -
    +<% + int num = 0; + List attachs = jspUtil.getValue("files", List.class); + for (int i = 0; i < attachs.size(); i++) { + UploadFile attach = attachs.get(i); + if (attach.getCommentNo() == null || attach.getCommentNo() == 0) { + num++; + } + } + String e = "hide"; + if (num > 0) { + e = ""; + } +%> + +
    + +

     <%= jspUtil.label("knowledge.view.label.attach") %>     - <% - int num = 0; - List attachs = jspUtil.getValue("files", List.class); - for (int i = 0; i < attachs.size(); i++) { - UploadFile attach = attachs.get(i); - if (attach.getCommentNo() == null || attach.getCommentNo() == 0) { - num++; - } - } - %> - [<%= num %>]

    @@ -34,6 +41,7 @@ int count = 0; String hide = ""; %> +
    <% count++; %> @@ -42,20 +50,17 @@ hide = "hide"; } %> -
    - <% if (count > MAX_COUNT) { %>
    more... diff --git a/src/main/webapp/WEB-INF/views/open/knowledge/partials/partials-view-comment-list.jsp b/src/main/webapp/WEB-INF/views/open/knowledge/partials/partials-view-comment-list.jsp index 87e5f24c2..fe6fafe03 100644 --- a/src/main/webapp/WEB-INF/views/open/knowledge/partials/partials-view-comment-list.jsp +++ b/src/main/webapp/WEB-INF/views/open/knowledge/partials/partials-view-comment-list.jsp @@ -10,12 +10,14 @@ <% JspUtil jspUtil = new JspUtil(request, pageContext); %> +
    + <% List commentList = jspUtil.getValue("comments", List.class); if (commentList != null && !commentList.isEmpty()) { %>
    -
    +
     <%=jspUtil.label("knowledge.view.comment.label")%>
    diff --git a/src/main/webapp/WEB-INF/views/open/knowledge/partials/partials-view-count.jsp b/src/main/webapp/WEB-INF/views/open/knowledge/partials/partials-view-count.jsp new file mode 100644 index 000000000..ba0977df3 --- /dev/null +++ b/src/main/webapp/WEB-INF/views/open/knowledge/partials/partials-view-count.jsp @@ -0,0 +1,43 @@ +<%@page pageEncoding="UTF-8" isELIgnored="false" session="false" errorPage="/WEB-INF/views/commons/errors/jsp_error.jsp"%> +<%@page import="java.util.List"%> +<%@page import="org.support.project.common.util.StringUtils"%> +<%@page import="org.support.project.web.util.JspUtil"%> +<%@page import="org.support.project.knowledge.logic.KnowledgeLogic"%> +<%@page import="org.support.project.knowledge.logic.TemplateLogic"%> +<%@page import="org.support.project.knowledge.vo.UploadFile"%> +<%@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); %> + +<%=jspUtil.out("params")%>" class="text-primary btn-link"> +  <%=jspUtil.label("knowledge.view.like")%> × <%=jspUtil.out("like_count")%> + + +  <%=jspUtil.label("knowledge.view.comment.label")%> + × <%=jspUtil.out("comments.size()")%> + + +<% + int num = 0; + List attachs = jspUtil.getValue("files", List.class); + for (int i = 0; i < attachs.size(); i++) { + UploadFile attach = attachs.get(i); + if (attach.getCommentNo() == null || attach.getCommentNo() == 0) { + num++; + } + } +%> + + +  <%=jspUtil.label("knowledge.view.label.attach")%> + × <%= num %> + + +<% if (jspUtil.is(TemplateLogic.TYPE_ID_EVENT, "typeId")) { %> + +  <%= jspUtil.label("knowledge.view.label.participants") %> + + +<% } %> diff --git a/src/main/webapp/WEB-INF/views/open/knowledge/partials/partials-view-editor.jsp b/src/main/webapp/WEB-INF/views/open/knowledge/partials/partials-view-editor.jsp index 1ccacf2c9..c6acf437d 100644 --- a/src/main/webapp/WEB-INF/views/open/knowledge/partials/partials-view-editor.jsp +++ b/src/main/webapp/WEB-INF/views/open/knowledge/partials/partials-view-editor.jsp @@ -9,32 +9,32 @@ <% JspUtil jspUtil = new JspUtil(request, pageContext); %> -
    - " alt="icon" width="24" - height="24" style="float: left" /> - <% - String insertLink = "" - + jspUtil.out("insertUserName", JspUtil.ESCAPE_CLEAR) + ""; - %> - <%=jspUtil.label("knowledge.view.info.insert", insertLink, jspUtil.date("insertDatetime"))%> - - <% if (!jspUtil.date("insertDatetime").equals(jspUtil.date("updateDatetime"))) { %> - ( - " alt="icon" width="24" - height="24" /> - <% - String updateLink = "" - + jspUtil.out("updateUserName", JspUtil.ESCAPE_CLEAR) + ""; - %> - <%=jspUtil.label("knowledge.view.info.update", updateLink, jspUtil.date("updateDatetime"))%> - <% - String historyLink = "<" - + jspUtil.label("knowledge.view.info.history") + ">"; - %> - <%= historyLink %> - ) - <% } %> -
    +
    + " alt="icon" width="24" + height="24" style="float: left" /> + <% + String insertLink = "" + + jspUtil.out("insertUserName", JspUtil.ESCAPE_CLEAR) + ""; + %> + <%=jspUtil.label("knowledge.view.info.insert", insertLink, jspUtil.date("insertDatetime"))%> + +<% if (!jspUtil.date("insertDatetime").equals(jspUtil.date("updateDatetime"))) { %> +( + " alt="icon" width="24" + height="24" /> + <% + String updateLink = "" + + jspUtil.out("updateUserName", JspUtil.ESCAPE_CLEAR) + ""; + %> + <%=jspUtil.label("knowledge.view.info.update", updateLink, jspUtil.date("updateDatetime"))%> + <% + String historyLink = "<" + + jspUtil.label("knowledge.view.info.history") + ">"; + %> + <%= historyLink %> +) +<% } %> +
    diff --git a/src/main/webapp/WEB-INF/views/open/knowledge/partials/partials-view-main-contents.jsp b/src/main/webapp/WEB-INF/views/open/knowledge/partials/partials-view-main-contents.jsp index fccd14c4b..196362bc8 100644 --- a/src/main/webapp/WEB-INF/views/open/knowledge/partials/partials-view-main-contents.jsp +++ b/src/main/webapp/WEB-INF/views/open/knowledge/partials/partials-view-main-contents.jsp @@ -12,7 +12,7 @@ " /> <%-- テンプレートの項目 --%> <%-- ナレッジコンテンツ --%>
    diff --git a/src/main/webapp/WEB-INF/views/open/knowledge/partials/partials-view-menu-buttons.jsp b/src/main/webapp/WEB-INF/views/open/knowledge/partials/partials-view-menu-buttons.jsp index 749845416..4a75af5b1 100644 --- a/src/main/webapp/WEB-INF/views/open/knowledge/partials/partials-view-menu-buttons.jsp +++ b/src/main/webapp/WEB-INF/views/open/knowledge/partials/partials-view-menu-buttons.jsp @@ -1,112 +1,119 @@ -<%@page import="org.support.project.knowledge.logic.TemplateLogic"%> +<%@page pageEncoding="UTF-8" isELIgnored="false" session="false" errorPage="/WEB-INF/views/commons/errors/jsp_error.jsp"%> <%@page import="org.support.project.common.util.StringUtils"%> -<%@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"%> +<%@page import="org.support.project.knowledge.logic.KnowledgeLogic"%> +<%@page import="org.support.project.knowledge.logic.TemplateLogic"%> <%@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); %> -
    -
    - <% - if (request.getRemoteUser() != null) { - if ((Boolean) request.getAttribute("edit")) { - %> - " - class="btn btn-primary btn_edit" role="button">  <%=jspUtil.label("knowledge.view.edit")%> - - <% - } else { - %> - - <% - } - %> - <% - } else { - %> - " - class="btn btn-primary btn_edit" role="button">  <%=jspUtil.label("knowledge.view.edit.with.login")%> - - <% - } - %> -
    +
    +
    + <% + if (request.getRemoteUser() != null) { + if ((Boolean) request.getAttribute("edit")) { + %> + " + class="btn btn-primary btn_edit" role="button">  <%=jspUtil.label("knowledge.view.edit")%> + + <% + } else { + %> + + <% + } + %> + <% + } else { + %> + " + class="btn btn-primary btn_edit" role="button">  <%=jspUtil.label("knowledge.view.edit.with.login")%> + + <% + } + %> +
    -
    - <% - if (request.getRemoteUser() != null) { - %> - - <% - } else { - %> - " - class="btn btn-info btn_stock" role="button">   <%=jspUtil.label("knowledge.view.fav")%><%--(<%= jspUtil.label("knowledge.navbar.signin") %>) --%> - - <% - } - %> - -
    - -
    - - -
    - - <% if (jspUtil.is(TemplateLogic.TYPE_ID_EVENT, "typeId")) { %> -
    - <% if (jspUtil.logined()) { %> - - - <% } else { %> - " class="btn btn-default btn_col2"> -   - <%=jspUtil.label("knowledge.view.label.participation")%> - - <% } %> -
    - <% } %> -
    - - - - <% if (jspUtil.is(TemplateLogic.TYPE_ID_EVENT, "typeId")) { %> - + + <% + if (request.getRemoteUser() != null && (Boolean) request.getAttribute("edit")) { + %> + + + <% } %> + + + +
    + diff --git a/src/main/webapp/WEB-INF/views/open/knowledge/partials/partials-view-modal-answer-survey.jsp b/src/main/webapp/WEB-INF/views/open/knowledge/partials/partials-view-modal-answer-survey.jsp new file mode 100644 index 000000000..4f8f19679 --- /dev/null +++ b/src/main/webapp/WEB-INF/views/open/knowledge/partials/partials-view-modal-answer-survey.jsp @@ -0,0 +1,40 @@ +<%@page pageEncoding="UTF-8" isELIgnored="false" session="false" errorPage="/WEB-INF/views/commons/errors/jsp_error.jsp"%> +<%@page import="org.support.project.web.util.JspUtil"%> +<%@page import="org.support.project.web.logic.HttpRequestCheckLogic"%> +<%@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); %> + + + diff --git a/src/main/webapp/WEB-INF/views/open/knowledge/partials/partials-view-modal-stock.jsp b/src/main/webapp/WEB-INF/views/open/knowledge/partials/partials-view-modal-stock.jsp index 702536be8..ded6c6245 100644 --- a/src/main/webapp/WEB-INF/views/open/knowledge/partials/partials-view-modal-stock.jsp +++ b/src/main/webapp/WEB-INF/views/open/knowledge/partials/partials-view-modal-stock.jsp @@ -17,21 +17,26 @@