Browse Source

Merge branch 'DEV' into 'Test'

Dev



See merge request !519

LiHaoyu 7 years ago
parent
commit
d5071f8fae

+ 4 - 1
mooctest-site-server/src/main/java/cn/iselab/mooctest/site/dao/GroupDao.java

@@ -5,6 +5,7 @@ import cn.iselab.mooctest.site.models.User;
 import cn.iselab.mooctest.site.models.Worker;
 import org.springframework.data.domain.Page;
 import org.springframework.data.domain.Pageable;
+import org.springframework.data.domain.Sort;
 import org.springframework.data.jpa.repository.Modifying;
 import org.springframework.data.jpa.repository.Query;
 import org.springframework.data.repository.PagingAndSortingRepository;
@@ -136,7 +137,9 @@ public interface GroupDao extends PagingAndSortingRepository<Group, Long> {
             "or u.school LIKE concat('%',:keyword,'%'))")
     Page<User> findByIdAndKeyWord(@Param("groupId")long groupId, @Param("keyword") String keyword, Pageable pageable);
 
-    List<Group> findByOwnerIdAndIsActive(long ownerId,boolean isActive);
+    List<Group> findByOwnerIdAndIsActive(long ownerId, boolean isActive, Sort sort);
+
+    List<Group> findByOwnerIdAndIsActive(long ownerId, boolean isActive);
 }
 
 

+ 1 - 1
mooctest-site-server/src/main/java/cn/iselab/mooctest/site/service/TargetGraphService.java

@@ -15,5 +15,5 @@ public interface TargetGraphService {
 
     TargetGraphDTO getTargetGraph(Long targetId);
 
-    void saveTargetGraphJson(TargetGraphDTO dto);
+    void saveTargetGraphJson(TargetGraphDTO dto)throws Exception;
 }

+ 11 - 13
mooctest-site-server/src/main/java/cn/iselab/mooctest/site/service/impl/GroupServiceImpl.java

@@ -1,26 +1,23 @@
 package cn.iselab.mooctest.site.service.impl;
 
-import cn.iselab.mooctest.site.dao.*;
-import cn.iselab.mooctest.site.data.AssignedCase;
+import cn.iselab.mooctest.site.dao.Group2WorkerDao;
+import cn.iselab.mooctest.site.dao.GroupDao;
+import cn.iselab.mooctest.site.dao.ManagerPropertyDao;
+import cn.iselab.mooctest.site.dao.Task2GroupDao;
 import cn.iselab.mooctest.site.models.*;
 import cn.iselab.mooctest.site.models.instancePermission.GroupPermission;
-import cn.iselab.mooctest.site.service.*;
+import cn.iselab.mooctest.site.service.AssignedTaskService;
+import cn.iselab.mooctest.site.service.GroupService;
+import cn.iselab.mooctest.site.service.UserService;
+import cn.iselab.mooctest.site.service.WorkerService;
 import cn.iselab.mooctest.site.service.instancePermission.GroupPermissionService;
-import cn.iselab.mooctest.site.util.data.StringUtil;
 import cn.iselab.mooctest.site.web.exception.IllegalOperationException;
-import org.apache.commons.lang3.StringUtils;
-import org.apache.shiro.SecurityUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.domain.Page;
 import org.springframework.data.domain.Pageable;
-import org.springframework.data.jpa.domain.Specification;
-import org.springframework.data.jpa.domain.Specifications;
+import org.springframework.data.domain.Sort;
 import org.springframework.stereotype.Service;
 
-import javax.persistence.criteria.CriteriaBuilder;
-import javax.persistence.criteria.CriteriaQuery;
-import javax.persistence.criteria.Predicate;
-import javax.persistence.criteria.Root;
 import java.sql.Timestamp;
 import java.util.ArrayList;
 import java.util.List;
@@ -93,7 +90,8 @@ public class GroupServiceImpl implements GroupService {
 
     @Override
     public List<Group> getGroupsByOwnerId(long ownerId) {
-        List<Group> groupList = groupDao.findByOwnerIdAndIsActive(ownerId,true);
+        Sort sort = new Sort(Sort.Direction.DESC,"id");
+        List<Group> groupList = groupDao.findByOwnerIdAndIsActive(ownerId,true, sort);
         return groupList;
     }
 

+ 1 - 1
mooctest-site-server/src/main/java/cn/iselab/mooctest/site/service/impl/TargetGraphServiceImpl.java

@@ -63,7 +63,7 @@ public class TargetGraphServiceImpl implements TargetGraphService{
     }
 
     @Override
-    public void saveTargetGraphJson(TargetGraphDTO dto){
+    public void saveTargetGraphJson(TargetGraphDTO dto)throws Exception{
         JSONObject objectSC=new JSONObject();
         objectSC.put("categories","mutation");
         objectSC.put("nodes",dto.getNodes().stream().filter(node -> node.getCategory().equals("mutation")).collect(Collectors.toList()));

+ 0 - 242
mooctest-site-server/src/main/java/cn/iselab/mooctest/site/web/ctrl/WechatController.java

@@ -118,246 +118,4 @@ public class WechatController extends BaseController {
     public String joinGroup(HttpServletRequest request, @RequestBody JoinGroupWechatVO body) {
         return wechatLogic.joinGroup(request, body);
     }
-
-    @RequestMapping(value = UrlConstants.API_WECHAT + "test", method = RequestMethod.GET)
-    public String Test(){
-        String str="{\n" +
-                "    \"categories\": [\n" +
-                "        {\n" +
-                "            \"name\": \"mutation\"\n" +
-                "        }\n" +
-                "    ],\n" +
-                "    \"nodes\": [\n" +
-                "        {\n" +
-                "            \"name\": \"Triangle.java_1\",\n" +
-                "            \"description\": \"changed conditional boundary \",\n" +
-                "            \"location\": \"Triangle.java/29\",\n" +
-                "            \"category\": \"mutation\",\n" +
-                "            \"img\": null\n" +
-                "        },\n" +
-                "        {\n" +
-                "            \"name\": \"Triangle.java_2\",\n" +
-                "            \"description\": \"changed conditional boundary \",\n" +
-                "            \"location\": \"Triangle.java/29\",\n" +
-                "            \"category\": \"mutation\",\n" +
-                "            \"img\": null\n" +
-                "        },\n" +
-                "        {\n" +
-                "            \"name\": \"Triangle.java_3\",\n" +
-                "            \"description\": \"changed conditional boundary \",\n" +
-                "            \"location\": \"Triangle.java/29\",\n" +
-                "            \"category\": \"mutation\",\n" +
-                "            \"img\": null\n" +
-                "        },\n" +
-                "        {\n" +
-                "            \"name\": \"Triangle.java_4\",\n" +
-                "            \"description\": \"changed conditional boundary \",\n" +
-                "            \"location\": \"Triangle.java/29\",\n" +
-                "            \"category\": \"mutation\",\n" +
-                "            \"img\": null\n" +
-                "        },\n" +
-                "        {\n" +
-                "            \"name\": \"Triangle.java_5\",\n" +
-                "            \"description\": \"changed conditional boundary \",\n" +
-                "            \"location\": \"Triangle.java/29\",\n" +
-                "            \"category\": \"mutation\",\n" +
-                "            \"img\": null\n" +
-                "        },\n" +
-                "        {\n" +
-                "            \"name\": \"Triangle.java_6\",\n" +
-                "            \"description\": \"changed conditional boundary \",\n" +
-                "            \"location\": \"Triangle.java/29\",\n" +
-                "            \"category\": \"mutation\",\n" +
-                "            \"img\": null\n" +
-                "        },\n" +
-                "        {\n" +
-                "            \"name\": \"Triangle.java_7\",\n" +
-                "            \"description\": \"negated conditional \",\n" +
-                "            \"location\": \"Triangle.java/29\",\n" +
-                "            \"category\": \"mutation\",\n" +
-                "            \"img\": null\n" +
-                "        },\n" +
-                "        {\n" +
-                "            \"name\": \"Triangle.java_8\",\n" +
-                "            \"description\": \"negated conditional \",\n" +
-                "            \"location\": \"Triangle.java/29\",\n" +
-                "            \"category\": \"mutation\",\n" +
-                "            \"img\": null\n" +
-                "        },\n" +
-                "        {\n" +
-                "            \"name\": \"Triangle.java_9\",\n" +
-                "            \"description\": \"negated conditional \",\n" +
-                "            \"location\": \"Triangle.java/29\",\n" +
-                "            \"category\": \"mutation\",\n" +
-                "            \"img\": null\n" +
-                "        },\n" +
-                "        {\n" +
-                "            \"name\": \"Triangle.java_10\",\n" +
-                "            \"description\": \"negated conditional \",\n" +
-                "            \"location\": \"Triangle.java/29\",\n" +
-                "            \"category\": \"mutation\",\n" +
-                "            \"img\": null\n" +
-                "        },\n" +
-                "        {\n" +
-                "            \"name\": \"Triangle.java_11\",\n" +
-                "            \"description\": \"negated conditional \",\n" +
-                "            \"location\": \"Triangle.java/29\",\n" +
-                "            \"category\": \"mutation\",\n" +
-                "            \"img\": null\n" +
-                "        },\n" +
-                "        {\n" +
-                "            \"name\": \"Triangle.java_12\",\n" +
-                "            \"description\": \"negated conditional \",\n" +
-                "            \"location\": \"Triangle.java/29\",\n" +
-                "            \"category\": \"mutation\",\n" +
-                "            \"img\": null\n" +
-                "        },\n" +
-                "        {\n" +
-                "            \"name\": \"Triangle.java_14\",\n" +
-                "            \"description\": \"changed conditional boundary \",\n" +
-                "            \"location\": \"Triangle.java/34\",\n" +
-                "            \"category\": \"mutation\",\n" +
-                "            \"img\": null\n" +
-                "        },\n" +
-                "        {\n" +
-                "            \"name\": \"Triangle.java_15\",\n" +
-                "            \"description\": \"negated conditional \",\n" +
-                "            \"location\": \"Triangle.java/34\",\n" +
-                "            \"category\": \"mutation\",\n" +
-                "            \"img\": null\n" +
-                "        },\n" +
-                "        {\n" +
-                "            \"name\": \"Triangle.java_17\",\n" +
-                "            \"description\": \"changed conditional boundary \",\n" +
-                "            \"location\": \"Triangle.java/35\",\n" +
-                "            \"category\": \"mutation\",\n" +
-                "            \"img\": null\n" +
-                "        },\n" +
-                "        {\n" +
-                "            \"name\": \"Triangle.java_18\",\n" +
-                "            \"description\": \"negated conditional \",\n" +
-                "            \"location\": \"Triangle.java/35\",\n" +
-                "            \"category\": \"mutation\",\n" +
-                "            \"img\": null\n" +
-                "        },\n" +
-                "        {\n" +
-                "            \"name\": \"Triangle.java_20\",\n" +
-                "            \"description\": \"changed conditional boundary \",\n" +
-                "            \"location\": \"Triangle.java/36\",\n" +
-                "            \"category\": \"mutation\",\n" +
-                "            \"img\": null\n" +
-                "        },\n" +
-                "        {\n" +
-                "            \"name\": \"Triangle.java_21\",\n" +
-                "            \"description\": \"negated conditional \",\n" +
-                "            \"location\": \"Triangle.java/36\",\n" +
-                "            \"category\": \"mutation\",\n" +
-                "            \"img\": null\n" +
-                "        },\n" +
-                "        {\n" +
-                "            \"name\": \"Triangle.java_23\",\n" +
-                "            \"description\": \"replaced return of integer sized value with (x == 0 ? 1 : 0) \",\n" +
-                "            \"location\": \"Triangle.java/41\",\n" +
-                "            \"category\": \"mutation\",\n" +
-                "            \"img\": null\n" +
-                "        },\n" +
-                "        {\n" +
-                "            \"name\": \"Triangle.java_25\",\n" +
-                "            \"description\": \"negated conditional \",\n" +
-                "            \"location\": \"Triangle.java/52\",\n" +
-                "            \"category\": \"mutation\",\n" +
-                "            \"img\": null\n" +
-                "        },\n" +
-                "        {\n" +
-                "            \"name\": \"Triangle.java_27\",\n" +
-                "            \"description\": \"negated conditional \",\n" +
-                "            \"location\": \"Triangle.java/54\",\n" +
-                "            \"category\": \"mutation\",\n" +
-                "            \"img\": null\n" +
-                "        },\n" +
-                "        {\n" +
-                "            \"name\": \"Triangle.java_28\",\n" +
-                "            \"description\": \"negated conditional \",\n" +
-                "            \"location\": \"Triangle.java/54\",\n" +
-                "            \"category\": \"mutation\",\n" +
-                "            \"img\": null\n" +
-                "        },\n" +
-                "        {\n" +
-                "            \"name\": \"Triangle.java_30\",\n" +
-                "            \"description\": \"negated conditional \",\n" +
-                "            \"location\": \"Triangle.java/59\",\n" +
-                "            \"category\": \"mutation\",\n" +
-                "            \"img\": null\n" +
-                "        },\n" +
-                "        {\n" +
-                "            \"name\": \"Triangle.java_31\",\n" +
-                "            \"description\": \"negated conditional \",\n" +
-                "            \"location\": \"Triangle.java/59\",\n" +
-                "            \"category\": \"mutation\",\n" +
-                "            \"img\": null\n" +
-                "        },\n" +
-                "        {\n" +
-                "            \"name\": \"Triangle.java_32\",\n" +
-                "            \"description\": \"negated conditional \",\n" +
-                "            \"location\": \"Triangle.java/59\",\n" +
-                "            \"category\": \"mutation\",\n" +
-                "            \"img\": null\n" +
-                "        },\n" +
-                "        {\n" +
-                "            \"name\": \"Triangle.java_34\",\n" +
-                "            \"description\": \"mutated return of Object value for net/mooctest/mutation/analysis/Triangle::getType to ( if (x != null) null else throw new RuntimeException ) \",\n" +
-                "            \"location\": \"Triangle.java/70\",\n" +
-                "            \"category\": \"mutation\",\n" +
-                "            \"img\": null\n" +
-                "        },\n" +
-                "        {\n" +
-                "            \"name\": \"Triangle.java_36\",\n" +
-                "            \"description\": \"changed conditional boundary \",\n" +
-                "            \"location\": \"Triangle.java/78\",\n" +
-                "            \"category\": \"mutation\",\n" +
-                "            \"img\": null\n" +
-                "        },\n" +
-                "        {\n" +
-                "            \"name\": \"Triangle.java_37\",\n" +
-                "            \"description\": \"Replaced long subtraction with addition \",\n" +
-                "            \"location\": \"Triangle.java/78\",\n" +
-                "            \"category\": \"mutation\",\n" +
-                "            \"img\": null\n" +
-                "        },\n" +
-                "        {\n" +
-                "            \"name\": \"Triangle.java_38\",\n" +
-                "            \"description\": \"Replaced long subtraction with addition \",\n" +
-                "            \"location\": \"Triangle.java/78\",\n" +
-                "            \"category\": \"mutation\",\n" +
-                "            \"img\": null\n" +
-                "        },\n" +
-                "        {\n" +
-                "            \"name\": \"Triangle.java_39\",\n" +
-                "            \"description\": \"negated conditional \",\n" +
-                "            \"location\": \"Triangle.java/78\",\n" +
-                "            \"category\": \"mutation\",\n" +
-                "            \"img\": null\n" +
-                "        },\n" +
-                "        {\n" +
-                "            \"name\": \"Triangle.java_40\",\n" +
-                "            \"description\": \"replaced return of long value with value + 1 for net/mooctest/mutation/analysis/Triangle::diffOfBorders \",\n" +
-                "            \"location\": \"Triangle.java/78\",\n" +
-                "            \"category\": \"mutation\",\n" +
-                "            \"img\": null\n" +
-                "        },\n" +
-                "        {\n" +
-                "            \"name\": \"Triangle.java_42\",\n" +
-                "            \"description\": \"mutated return of Object value for net/mooctest/mutation/analysis/Triangle::getBorders to ( if (x != null) null else throw new RuntimeException ) \",\n" +
-                "            \"location\": \"Triangle.java/89\",\n" +
-                "            \"category\": \"mutation\",\n" +
-                "            \"img\": null\n" +
-                "        }\n" +
-                "    ],\n" +
-                "    \"edges\": null\n" +
-                "}";
-        TargetGraphDTO dto=new Gson().fromJson(str,TargetGraphDTO.class);
-        dto.setTargetId(419L);
-        targetGraphService.saveTargetGraphJson(dto);
-        return "ok";
-    }
 }

+ 1 - 1
mooctest-site-server/src/main/java/cn/iselab/mooctest/site/web/ctrl/fromDev/AnalysisController.java

@@ -120,7 +120,7 @@ public class AnalysisController extends BaseController {
     @RequestMapping(value = UrlConstants.API + "mutation/{examId}/{caseId}", method = RequestMethod.GET)
     public String getMutationAnalyseofCaseInExam(@PathVariable Long examId, @PathVariable Long caseId,
                                                  @RequestParam(value = "participantId",required = false)Long participantId) {
-        return apfdLogic.getMutationAnalyseofCaseInExam(examId, caseId, participantId);
+        return apfdLogic.getMutationNodeAnalyseofCaseInExam(examId, caseId, participantId);
     }
 
     @RequestMapping(value = UrlConstants.API_DEV + "mutation", method = RequestMethod.GET)

+ 54 - 0
mooctest-site-server/src/main/java/cn/iselab/mooctest/site/web/data/wrapper/TargetGraphWrapper.java

@@ -0,0 +1,54 @@
+package cn.iselab.mooctest.site.web.data.wrapper;
+
+import cn.iselab.mooctest.site.rpc.dev.data.CategoryDTO;
+import cn.iselab.mooctest.site.rpc.dev.data.EdgeDTO;
+import cn.iselab.mooctest.site.rpc.dev.data.NodeDTO;
+import cn.iselab.mooctest.site.rpc.dev.data.NodeResultDTO;
+import cn.iselab.mooctest.site.web.data.forMongo.TargetGraphDTO;
+import cn.iselab.mooctest.site.web.data.forMongo.caseGraph.Category;
+import cn.iselab.mooctest.site.web.data.forMongo.caseGraph.Edge;
+import cn.iselab.mooctest.site.web.data.forMongo.caseGraph.Node;
+import com.google.common.eventbus.Subscribe;
+import org.springframework.beans.BeanUtils;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+import java.util.stream.Collectors;
+
+/**
+ * @Author ROKG
+ * @Description
+ * @Date: Created in 下午11:18 2018/1/16
+ * @Modified By:
+ */
+@Service
+public class TargetGraphWrapper {
+
+    public void wrap(NodeResultDTO dto,TargetGraphDTO graphDTO){
+        List<CategoryDTO> categoryDTOS=dto.getCategories();
+        graphDTO.setCategories(categoryDTOS.stream().map(categoryDTO -> {
+            Category category=new Category();
+            BeanUtils.copyProperties(categoryDTO,category);
+            return category;
+        }).collect(Collectors.toList()));
+
+        List<NodeDTO> nodeDTOS=dto.getNodes();
+        if(nodeDTOS!=null&&nodeDTOS.size()>0) {
+            graphDTO.setNodes(nodeDTOS.stream().map(nodeDTO -> {
+                Node node=new Node();
+                BeanUtils.copyProperties(nodeDTO,node);
+                return node;
+            }).collect(Collectors.toList()));
+        }
+
+        List<EdgeDTO> edgeDTOS=dto.getEdges();
+        if (edgeDTOS != null&& edgeDTOS.size()>0) {
+            graphDTO.setEdges(edgeDTOS.stream().map(edgeDTO -> {
+                Edge edge=new Edge();
+                BeanUtils.copyProperties(edgeDTO,edge);
+                return edge;
+            }).collect(Collectors.toList()));
+        }
+
+    }
+}

+ 4 - 4
mooctest-site-server/src/main/java/cn/iselab/mooctest/site/web/logic/impl/ExamLogicImpl.java

@@ -172,21 +172,21 @@ public class ExamLogicImpl extends BaseLogic implements ExamLogic {
         long currTime = System.currentTimeMillis();
         boolean isTaskTimeInvalid = currTime > examVO.getBeginTime() || examVO.getBeginTime() > examVO.getEndTime();
         if (isTaskTimeInvalid) {
-            throw new HttpBadRequestException("Invalid exam time");
+            throw new HttpBadRequestException("考试时间无效");
         }
         //check exam name < 30
         if (examVO.getName().length() > 30) {
-            throw new HttpBadRequestException("Invalid exam name");
+            throw new HttpBadRequestException("考试名称不允许超过30字符");
         }
         //check exam description < 256
         if (examVO.getInfo() != null && examVO.getInfo().length() > 256) {
-            throw new HttpBadRequestException("Invalid exam info");
+            throw new HttpBadRequestException("考试描述不允许超过256字符");
         }
 
         List<Task> exams = examService.getTaskByOwnerId(examVO.getManagerId());
         for (Task exam : exams) {
             if (exam.getName().equals(examVO.getName())) {
-                throw new HttpBadRequestException("Task name already used by this manager");
+                throw new HttpBadRequestException("考试名称已存在");
             }
         }
 

+ 22 - 8
mooctest-site-server/src/main/java/cn/iselab/mooctest/site/web/logic/impl/TargetLogicImpl.java

@@ -19,10 +19,7 @@ import cn.iselab.mooctest.site.service.fromKibug.ApplicationService;
 import cn.iselab.mooctest.site.service.instancePermission.AppPermissionService;
 import cn.iselab.mooctest.site.web.data.*;
 import cn.iselab.mooctest.site.web.data.forMongo.TargetGraphDTO;
-import cn.iselab.mooctest.site.web.data.wrapper.TargetDevVOWrapper;
-import cn.iselab.mooctest.site.web.data.wrapper.TargetKibugVOWrapper;
-import cn.iselab.mooctest.site.web.data.wrapper.TargetVOWrapper;
-import cn.iselab.mooctest.site.web.data.wrapper.TargetWebVOWrapper;
+import cn.iselab.mooctest.site.web.data.wrapper.*;
 import cn.iselab.mooctest.site.web.exception.HttpBadRequestException;
 import cn.iselab.mooctest.site.web.exception.HttpNotFoundException;
 import cn.iselab.mooctest.site.web.logic.BaseLogic;
@@ -81,6 +78,9 @@ public class TargetLogicImpl extends BaseLogic implements TargetLogic {
     @Autowired
     EventUtil eventUtil;
 
+    @Autowired
+    TargetGraphWrapper targetGraphWrapper;
+
     @Override
     public List<TargetVO> getManagerTargets(long managerId) throws Exception {
 
@@ -251,15 +251,17 @@ public class TargetLogicImpl extends BaseLogic implements TargetLogic {
 
     @Override
     public void getTargetGraph(long targetId,long targetType,String url){
-        TargetGraphDTO targetGraphDTO = new TargetGraphDTO();
+        TargetGraphDTO targetGraphDTO=new TargetGraphDTO();
         targetGraphDTO.setTargetId(targetId);
         if(targetType == TargetTypeConstants.DEV) {
             try {
                 LOG.info("---------------------------------start mutation analysis--------------------------------");
                 NodeResultDTO nodeResultDTO = analysisService.mutationNodeAnalyze(url);
                 LOG.info("---------------------------------end mutation analysis--------------------------------");
+                System.out.println(nodeResultDTO.getCategories());
+                System.out.println(nodeResultDTO.getNodes().size());
                 if(nodeResultDTO!=null) {
-                    BeanUtils.copyProperties(nodeResultDTO, targetGraphDTO);
+                    targetGraphWrapper.wrap(nodeResultDTO,targetGraphDTO);
                 }else {
                     targetService.rejectTarget(targetId);
                 }
@@ -267,9 +269,21 @@ public class TargetLogicImpl extends BaseLogic implements TargetLogic {
                 e.printStackTrace();
                 targetService.rejectTarget(targetId);
             }
-            targetGraphService.saveTargetGraphJson(targetGraphDTO);
+
+            try {
+                targetGraphService.saveTargetGraph(targetGraphDTO);
+            }catch (Exception e){
+                e.printStackTrace();
+                System.out.println("mongo exception");
+            }
+
+            try {
+                targetGraphService.saveTargetGraphJson(targetGraphDTO);
+            }catch (Exception e){
+                e.printStackTrace();
+                System.out.println("io exception");
+            }
         }
-        targetGraphService.saveTargetGraph(targetGraphDTO);
     }
 
     private void setListener(long targetId,long targetType,String url){