Commit f4bc7ff2 by Kim Gyeongeun

#56950 アンケートの設問コピー機能

parent a5acc56e
......@@ -3,6 +3,17 @@ package jp.agentec.sinaburocast.action.admin.enquete;
import java.util.ArrayList;
import java.util.HashMap;
import org.apache.commons.collections.CollectionUtils;
import org.apache.log4j.Logger;
import org.apache.struts.Globals;
import org.apache.struts.action.ActionMessage;
import org.apache.struts.action.ActionMessages;
import org.apache.struts.util.TokenProcessor;
import org.seasar.framework.beans.util.Beans;
import org.seasar.framework.util.StringUtil;
import org.seasar.struts.annotation.ActionForm;
import org.seasar.struts.annotation.Execute;
import jp.agentec.sinaburocast.action.AbstractAction;
import jp.agentec.sinaburocast.common.SinaburoConstant;
import jp.agentec.sinaburocast.common.SinaburoConstant.EnqueteType;
......@@ -20,17 +31,6 @@ import jp.agentec.sinaburocast.service.OrganizationService;
import jp.agentec.sinaburocast.service.QuestionService;
import jp.agentec.sinaburocast.service.ReplyService;
import org.apache.commons.collections.CollectionUtils;
import org.apache.log4j.Logger;
import org.apache.struts.Globals;
import org.apache.struts.action.ActionMessage;
import org.apache.struts.action.ActionMessages;
import org.apache.struts.util.TokenProcessor;
import org.seasar.framework.beans.util.Beans;
import org.seasar.framework.util.StringUtil;
import org.seasar.struts.annotation.ActionForm;
import org.seasar.struts.annotation.Execute;
/**
* アンケート登録
*
......
......@@ -3,15 +3,6 @@ package jp.agentec.sinaburocast.form.admin.enquete;
import java.util.ArrayList;
import java.util.List;
import jp.agentec.sinaburocast.common.SinaburoConstant;
import jp.agentec.sinaburocast.common.util.PropertyUtil;
import jp.agentec.sinaburocast.common.util.SinaburoUtil;
import jp.agentec.sinaburocast.entity.Answer;
import jp.agentec.sinaburocast.entity.Enquete;
import jp.agentec.sinaburocast.entity.Organization;
import jp.agentec.sinaburocast.entity.Question;
import jp.agentec.sinaburocast.service.QuestionService;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.builder.StandardToStringStyle;
import org.apache.commons.lang.builder.ToStringBuilder;
......@@ -21,6 +12,15 @@ import org.apache.velocity.tools.generic.ListTool;
import org.mobylet.core.util.StringUtils;
import org.seasar.framework.util.StringUtil;
import jp.agentec.sinaburocast.common.SinaburoConstant;
import jp.agentec.sinaburocast.common.util.PropertyUtil;
import jp.agentec.sinaburocast.common.util.SinaburoUtil;
import jp.agentec.sinaburocast.entity.Answer;
import jp.agentec.sinaburocast.entity.Enquete;
import jp.agentec.sinaburocast.entity.Organization;
import jp.agentec.sinaburocast.entity.Question;
import jp.agentec.sinaburocast.service.QuestionService;
/**
......@@ -85,8 +85,6 @@ public class EnqueteRegistForm {
public Question inputQuestion = new Question();
// /**
// * 設問一覧から設問内容をクリックした場合更新。
// */
......
......@@ -2,13 +2,13 @@ package jp.agentec.sinaburocast.service;
import java.util.List;
import jp.agentec.sinaburocast.common.SinaburoConstant;
import jp.agentec.sinaburocast.entity.Answer;
import org.seasar.extension.jdbc.where.SimpleWhere;
import org.seasar.framework.container.annotation.tiger.Component;
import org.seasar.framework.container.annotation.tiger.InstanceType;
import jp.agentec.sinaburocast.common.SinaburoConstant;
import jp.agentec.sinaburocast.entity.Answer;
@Component(instance=InstanceType.SINGLETON)
public class AnswerService extends AbstractService<Answer> {
......@@ -36,6 +36,12 @@ public class AnswerService extends AbstractService<Answer> {
public List<Answer> findAllByEnqueteId(String eid) {
return select().where(new SimpleWhere().eq("enqueteId",eid)).getResultList();
}
public List<Answer> findAllByEnqueteId(Integer enqueteId, Integer questionId) {
return select().where(new SimpleWhere().eq("enqueteId",enqueteId)
.eq("questionId", questionId)
.eq("delFlg", SinaburoConstant.DelFlg.NOT_DEL))
.getResultList();
}
public List<Answer> findAllByQuestionId(Integer questionId) {
return select().where(new SimpleWhere().eq("questionId",questionId)).getResultList();
......
......@@ -14,6 +14,19 @@ import java.util.Map;
import java.util.Properties;
import java.util.TreeMap;
import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
import org.apache.velocity.VelocityContext;
import org.apache.velocity.tools.generic.DateTool;
import org.apache.velocity.tools.generic.MathTool;
import org.seasar.extension.jdbc.AutoSelect;
import org.seasar.extension.jdbc.where.SimpleWhere;
import org.seasar.framework.beans.util.BeanMap;
import org.seasar.framework.beans.util.Beans;
import org.seasar.framework.container.annotation.tiger.Component;
import org.seasar.framework.container.annotation.tiger.InstanceType;
import org.seasar.framework.util.StringUtil;
import jp.agentec.sinaburocast.common.SinaburoConstant;
import jp.agentec.sinaburocast.common.SinaburoConstant.EnqueteStatusType;
import jp.agentec.sinaburocast.common.exception.ExpectedException;
......@@ -35,19 +48,6 @@ import jp.agentec.sinaburocast.form.admin.enquete.EnqueteRegistForm;
import jp.agentec.sinaburocast.form.admin.enquete.EnqueteSearchForm;
import jp.agentec.sinaburocast.form.batch.EnqueteSumBatchForm;
import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
import org.apache.velocity.VelocityContext;
import org.apache.velocity.tools.generic.DateTool;
import org.apache.velocity.tools.generic.MathTool;
import org.seasar.extension.jdbc.AutoSelect;
import org.seasar.extension.jdbc.where.SimpleWhere;
import org.seasar.framework.beans.util.BeanMap;
import org.seasar.framework.beans.util.Beans;
import org.seasar.framework.container.annotation.tiger.Component;
import org.seasar.framework.container.annotation.tiger.InstanceType;
import org.seasar.framework.util.StringUtil;
@Component(instance=InstanceType.SINGLETON)
......@@ -81,7 +81,6 @@ public class EnqueteService extends AbstractService<Enquete> {
public Enquete findById(Integer enqueteId) {
return select().id(enqueteId).getSingleResult();
}
......@@ -952,8 +951,8 @@ public class EnqueteService extends AbstractService<Enquete> {
* @param eid
* @param adminLoginId
*/
public void enqueteCopy(Integer eid,String adminLoginId){
Enquete enquete = this.findById(eid);
public void enqueteCopy(Integer originEnqueteId,String adminLoginId){
Enquete enquete = this.findById(originEnqueteId);
enquete.enqueteName ="コピー"+enquete.enqueteName;
enquete.version = 0;
enquete.status = 0;
......@@ -962,15 +961,18 @@ public class EnqueteService extends AbstractService<Enquete> {
enquete.endDate="";
this.insertEnquete(enquete, adminLoginId);
// 設問をコピーする。
questionService.questionCopy(originEnqueteId, enquete.enqueteId, adminLoginId);
AdminNotifyMail adminNotifyMail = adminNotifyMailService.findByEnqueteId(eid);
AdminNotifyMail adminNotifyMail = adminNotifyMailService.findByEnqueteId(originEnqueteId);
if(adminNotifyMail !=null){
adminNotifyMail.version=0;
adminNotifyMail.enqueteId = enquete.enqueteId;
adminNotifyMailService.insertAdminNotifyMail(adminNotifyMail, adminLoginId);
}
MemberNotifyMail memberNotifyMail =memberNotifyMailService.findByEnqueteId(eid);
MemberNotifyMail memberNotifyMail =memberNotifyMailService.findByEnqueteId(originEnqueteId);
if(memberNotifyMail != null){
memberNotifyMail.version=0;
......
......@@ -3,16 +3,17 @@ package jp.agentec.sinaburocast.service;
import java.util.ArrayList;
import java.util.List;
import org.apache.commons.collections.CollectionUtils;
import org.seasar.extension.jdbc.where.SimpleWhere;
import org.seasar.framework.container.annotation.tiger.Component;
import org.seasar.framework.container.annotation.tiger.InstanceType;
import jp.agentec.sinaburocast.common.SinaburoConstant;
import jp.agentec.sinaburocast.entity.AdminUser;
import jp.agentec.sinaburocast.entity.Answer;
import jp.agentec.sinaburocast.entity.Question;
import jp.agentec.sinaburocast.form.admin.enquete.EnqueteRegistForm;
import org.seasar.extension.jdbc.where.SimpleWhere;
import org.seasar.framework.container.annotation.tiger.Component;
import org.seasar.framework.container.annotation.tiger.InstanceType;
@Component(instance=InstanceType.SINGLETON)
public class QuestionService extends AbstractService<Question> {
......@@ -89,6 +90,10 @@ public class QuestionService extends AbstractService<Question> {
return select().where(new SimpleWhere().eq("enqueteId",eid).eq("delFlg", SinaburoConstant.DelFlg.NOT_DEL)).getResultList();
}
public List<Question> findAllByEnqueteId(Integer eid) {
return select().where(new SimpleWhere().eq("enqueteId",eid).eq("delFlg", SinaburoConstant.DelFlg.NOT_DEL)).getResultList();
}
/**
* アンケート検索画面で削除ボタンを押した場合。論理削除
......@@ -255,6 +260,33 @@ public class QuestionService extends AbstractService<Question> {
this.questionRegist(frm,adminUser.loginId, true);
return 0;
}
/**
* 設問をコピーする。
*
* @param questionId 設問ID
* @return
*/
public void questionCopy(Integer originEnqueteId, Integer newEnqueteId, String loginId) {
List<Question> questionList = findAllByEnqueteId(originEnqueteId);
// アンケートに設問がない場合
if (CollectionUtils.isEmpty(questionList)) {return;}
for (Question question : questionList) {
question.enqueteId = newEnqueteId;
question.version = 0;
// 詳細項目情報取得
List<Answer> answerList = answerService.findAllByEnqueteId(originEnqueteId, question.questionId);
insertQuestion(question, loginId);
for (Answer answer : answerList) {
// 新しいquestionIdをセット
answer.questionId = question.questionId;
answer.version = 0;
answerService.insertAnswer(answer, loginId);
}
}
}
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment