Commit 2c5ffba2 by qiuchaofei

修改过滤关系的算法

parent 64003e2c
...@@ -218,28 +218,100 @@ public class MetadataRelationServiceImpl implements IMetadataRelationService { ...@@ -218,28 +218,100 @@ public class MetadataRelationServiceImpl implements IMetadataRelationService {
} }
} }
//如果是要过滤的,过滤节点后,要把两端的关系接上
Map<String ,ReturnEdge> newEdgeMap = new HashMap<>(); Map<String ,ReturnEdge> newEdgeMap = new HashMap<>();
for(String filterNodeId :filterNodeIdList){ //先用需要保留的,在从需要保留的另一端,看看是否需要过滤,如果要过了,就继续找,直到找到不需要过滤的节点
if(source2Target.containsKey(filterNodeId) for(String remianNodeId :remianNodeIdList){
&& target2Source.containsKey(filterNodeId)){ if(source2Target.containsKey(remianNodeId)){
List<String> toIdList = source2Target.get(remianNodeId);
if(toIdList == null ){
continue;
}
for(String toId:toIdList){
if(remianNodeIdList.contains(toId)){
ReturnEdge newEdge = new ReturnEdge();
newEdge.setEdgeId(remianNodeId+"_"+toId);
newEdge.setFromId(remianNodeId);
newEdge.setToId(toId);
newEdge.setType("流向");
newEdgeMap.put(newEdge.getEdgeId(),newEdge);
}else {
List<String> to2toIdList = source2Target.get(toId);
if(to2toIdList == null ){
continue;
}
for(String to2toId:to2toIdList){
if(remianNodeIdList.contains(to2toId)){
ReturnEdge newEdge = new ReturnEdge();
newEdge.setEdgeId(remianNodeId+"_"+to2toId);
newEdge.setFromId(remianNodeId);
newEdge.setToId(to2toId);
newEdge.setType("流向");
List<String> toIdList = source2Target.get(filterNodeId); newEdgeMap.put(newEdge.getEdgeId(),newEdge);
List<String> fromIdList = target2Source.get(filterNodeId); }else {
}
}
}
}
}
for(String fromId :fromIdList){ if(target2Source.containsKey(remianNodeId)){
for(String toId : toIdList){ List<String> fromIdList = target2Source.get(remianNodeId);
for(String fromId:fromIdList){
if(remianNodeIdList.contains(fromId)){
ReturnEdge newEdge = new ReturnEdge(); ReturnEdge newEdge = new ReturnEdge();
newEdge.setEdgeId(fromId+"_"+toId); newEdge.setEdgeId(fromId +"_"+remianNodeId);
newEdge.setFromId(fromId); newEdge.setFromId(fromId);
newEdge.setToId(toId); newEdge.setToId(remianNodeId );
newEdge.setType("流向"); newEdge.setType("流向");
newEdgeMap.put(newEdge.getEdgeId(),newEdge); newEdgeMap.put(newEdge.getEdgeId(),newEdge);
}else {
List<String> from2FromIdList = target2Source.get(fromId);
if(from2FromIdList == null ){
continue;
}
for(String from2FromId:from2FromIdList){
if(remianNodeIdList.contains(from2FromId)){
ReturnEdge newEdge = new ReturnEdge();
newEdge.setEdgeId(from2FromId +"_"+remianNodeId);
newEdge.setFromId(from2FromId);
newEdge.setToId(remianNodeId );
newEdge.setType("流向");
newEdgeMap.put(newEdge.getEdgeId(),newEdge);
}else {
}
}
} }
} }
} }
} }
//如果是要过滤的,过滤节点后,要把两端的关系接上
// for(String filterNodeId :filterNodeIdList){
// if(source2Target.containsKey(filterNodeId)
// && target2Source.containsKey(filterNodeId)){
//
// List<String> toIdList = source2Target.get(filterNodeId);
// List<String> fromIdList = target2Source.get(filterNodeId);
//
// for(String fromId :fromIdList){
// for(String toId : toIdList){
// ReturnEdge newEdge = new ReturnEdge();
// newEdge.setEdgeId(fromId+"_"+toId);
// newEdge.setFromId(fromId);
// newEdge.setToId(toId);
// newEdge.setType("流向");
//
// newEdgeMap.put(newEdge.getEdgeId(),newEdge);
// }
// }
// }
// }
for(Object obj : newEdgeMap.keySet()){ for(Object obj : newEdgeMap.keySet()){
ReturnEdge newEdge = newEdgeMap.get(obj); ReturnEdge newEdge = newEdgeMap.get(obj);
newReslult.getEdges().add(newEdge); newReslult.getEdges().add(newEdge);
......
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