summaryrefslogtreecommitdiff
path: root/source/com/c2kernel/lifecycle/JoinDef.java
blob: 71bc95c4f484dc74af27afbf1588d77321da38cb (plain)
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
package com.c2kernel.lifecycle;

import com.c2kernel.lifecycle.instance.Join;
import com.c2kernel.lifecycle.instance.WfVertex;

/**
 * @version $Revision: 1.18 $ $Date: 2005/09/29 10:18:31 $
 * @author $Author: abranson $
 */
public class JoinDef extends WfVertexDef
{
	/**
	 * @see java.lang.Object#Object()
	 */
	public JoinDef()
	{
	}
	/**
	 * @see com.c2kernel.lifecycle.WfVertexDef#verify()
	 */
	public boolean verify()
	{
		mErrors.removeAllElements();
		int nbOutEdges = getOutEdges().length;
		int nbInEdges = getInEdges().length;
		String type = (String) getProperties().get("Type");
        if (nbInEdges < 1)
        {
            mErrors.add("not enough previous");
            return false;
        }
        if (type != null && type.equals("Route"))
		{
			if (nbInEdges > 1)
			{
				mErrors.add("Bad nb of previous");
				return false;
			}
		}
		if (nbOutEdges > 1)
		{
			mErrors.add("too many next");
			return false;
		}
		if (nbOutEdges == 0)
		{
			if (!((CompositeActivityDef) getParent()).hasGoodNumberOfActivity())
			{
				mErrors.add("too many endpoints");
				return false;
			}
		}
		return true;
	}
	public boolean isJoin()
	{
		return true;
	}
	
	public WfVertex instantiate() {
		Join newJoin = new Join();
		configureInstance(newJoin);
		return newJoin;
	}
}