|
@@ -15,6 +15,7 @@ import cn.iselab.mooctest.site.web.data.forMongo.CaseGraphDTO;
|
|
import cn.iselab.mooctest.site.web.data.forMongo.graph.Node;
|
|
import cn.iselab.mooctest.site.web.data.forMongo.graph.Node;
|
|
import cn.iselab.mooctest.site.web.data.fromKibug.ScoreRuleItemVO;
|
|
import cn.iselab.mooctest.site.web.data.fromKibug.ScoreRuleItemVO;
|
|
import cn.iselab.mooctest.site.web.logic.CaseLogic;
|
|
import cn.iselab.mooctest.site.web.logic.CaseLogic;
|
|
|
|
+import org.apache.zookeeper.Op;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
@@ -63,23 +64,26 @@ public class ScoreRuleServiceImpl implements ScoreRuleService{
|
|
|
|
|
|
List<ScoreRuleItemVO> scoreRuleList = getGeneralScoreRule(taskId, caseId);
|
|
List<ScoreRuleItemVO> scoreRuleList = getGeneralScoreRule(taskId, caseId);
|
|
if (scoreRuleList.isEmpty()) {
|
|
if (scoreRuleList.isEmpty()) {
|
|
- List<String> nodeTypeList = getNodeTypeList(caseId);
|
|
|
|
- if (!nodeTypeList.isEmpty()) {
|
|
|
|
- scoreRuleList.add(new ScoreRuleItemVO(nodeTypeList.get(0), 100));
|
|
|
|
- }
|
|
|
|
|
|
+ Optional<List<String>> opNodeTypeList = getNodeTypeList(caseId);
|
|
|
|
+ opNodeTypeList.ifPresent( (nodeTypeList) -> scoreRuleList.add(new ScoreRuleItemVO(nodeTypeList.get(0), 100)));
|
|
|
|
+
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
return scoreRuleList;
|
|
return scoreRuleList;
|
|
}
|
|
}
|
|
|
|
|
|
- private List<String> getNodeTypeList(Long caseId) throws Exception {
|
|
|
|
|
|
+ private Optional<List<String>> getNodeTypeList(Long caseId) throws Exception {
|
|
CaseGraphDTO caseGraph = caseLogic.getGraph(caseId, null);
|
|
CaseGraphDTO caseGraph = caseLogic.getGraph(caseId, null);
|
|
|
|
+
|
|
|
|
+ if (caseGraph == null) return Optional.empty();
|
|
|
|
+
|
|
List<Node> caseNodeList = caseGraph.getNodes();
|
|
List<Node> caseNodeList = caseGraph.getNodes();
|
|
Set<String> nodeTypeSet = new HashSet<>();
|
|
Set<String> nodeTypeSet = new HashSet<>();
|
|
for(Node node:caseNodeList){
|
|
for(Node node:caseNodeList){
|
|
nodeTypeSet.add(node.getCategory());
|
|
nodeTypeSet.add(node.getCategory());
|
|
}
|
|
}
|
|
- return new ArrayList<>(nodeTypeSet);
|
|
|
|
|
|
+ return Optional.of(new ArrayList<>(nodeTypeSet));
|
|
}
|
|
}
|
|
|
|
|
|
private List<ScoreRuleItemVO> removeZeroValues(List<ScoreRuleItemVO> list){
|
|
private List<ScoreRuleItemVO> removeZeroValues(List<ScoreRuleItemVO> list){
|
|
@@ -114,7 +118,7 @@ public class ScoreRuleServiceImpl implements ScoreRuleService{
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public List<String> getOptionsFromNode(long taskId, long caseId) throws Exception {
|
|
public List<String> getOptionsFromNode(long taskId, long caseId) throws Exception {
|
|
- return getNodeTypeList(caseId);
|
|
|
|
|
|
+ return getNodeTypeList(caseId).orElseGet(ArrayList::new);
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|