wangting
2024-09-27 a3e87f78ee262ca9bb7d9b0c997639d5f3295890
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
package com.vci.client.omd.lifecycle.pubimpl;
 
import java.util.ArrayList;
import java.util.List;
 
import com.vci.client.omd.lifecycle.LifeCycleStart;
import com.vci.client.omd.lifecycle.itf.LifecycleClientInterface;
import com.vci.corba.common.VCIError;
import com.vci.corba.omd.lcm.LifeCycle;
import com.vci.corba.omd.lcm.TransitionVO;
import com.vci.corba.omd.lcm.TransitionVOEvent;
 
public class LifecycleClientInterfaceImpl implements LifecycleClientInterface{
    
    private List<TransitionVO> tVos = new ArrayList<TransitionVO>();
 
    @Override
    public String getFirstLifeCycleStateByName(String name) {
        String startState = null;
        try {
            LifeCycle lifeCycle = LifeCycleStart.getService().getLifeCycle(name);
            startState = lifeCycle.startState;
        } catch (VCIError e) {
            e.printStackTrace();
        }
        return startState;
    }
 
    @Override
    public List<String> getNextStateByLifeCycleNameAndCurrentState(
            String lifecycleName, String currentState) {
        List<String> list = null;
        TransitionVO route = null;
        try {
            list = new ArrayList<String>();
            LifeCycle[] lifeCyles = LifeCycleStart.getService().getLifeCycles();
            for (LifeCycle lc : lifeCyles) {
                if (lc.name.equals(lifecycleName)) {
                    for(int i=0;i<lc.routes.length;i++){
                        route = lc.routes[i];
                        if(route.source.equals(currentState)){
                            list.add(route.destination);
                        }
                    }
                }
            }
        } catch (VCIError e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        return list;
    }
 
//    @Override
//    public List<TransitionVO> getTransitionVOListByNameAndSouce(String name,String startNode) {
//        List<TransitionVO> tVos = null;
//        try {
//            LifeCyle[] lifeCyles = LifeCycleStart.getService().getLifeCyles();
//            for(LifeCyle lifeCyle:lifeCyles){
//                if(lifeCyle.name.equals(name)){
//                    tVos= getTransitionVOsBySouce(lifeCyle, startNode);
//                }
//            }
//            
//        } catch (VCIError e) {
//            e.printStackTrace();
//        }
//        return tVos;
//    }
    
    /**
     * 閫氳繃璺冭縼绾胯捣鐐硅幏鍙栦笅绾ф墍鏈夎穬杩佸璞�
     * @param souce
     * @return
     */
    public List<TransitionVO> getTransitionVOsBySouce(LifeCycle lc, String souce) {
        TransitionVO[] transitionVOs = lc.routes;
        for (TransitionVO tv : transitionVOs) {
            if (tv.source.equals(souce)) {
                tVos.add(tv);
                //String mid  = tv.destination;
                //getTransitionVOsBySouce(lc, mid);
            }
        }
        return tVos;
    }
 
    @Override
    public TransitionVOEvent[] getTransitionVOEventsByLifeCycleNameAndTransition(
            String lifecycleName, String transition) {
        try {
            LifeCycle[] lifeCyles = LifeCycleStart.getService().getLifeCycles();
            for(LifeCycle lc:lifeCyles){
                if(lc.name.equals(lifecycleName)){
                    TransitionVO[] transitionVOs = lc.routes;
                    for(TransitionVO tVo:transitionVOs){
                        if(tVo.connect.equals(transition)){
                            return tVo.transitionVOEvents;
                        }
                    }
                }
            }
            return null;
        } catch (VCIError e) {
            e.printStackTrace();
        }
        return null;
    }
}