|
1
|
|
/*
|
|
2
|
|
* JBind
|
|
3
|
|
*
|
|
4
|
|
* Copyright (c) by Stefan Wachter. All rights reserved.
|
|
5
|
|
*
|
|
6
|
|
* Usage, modification, and redistribution is subject to license terms that are
|
|
7
|
|
* available at 'http://www.jbind.org'. The JBind license is like the
|
|
8
|
|
* 'Apache Software License V 1.1'.
|
|
9
|
|
*/
|
|
10
|
|
package org.jbind.xml.schema.reader;
|
|
11
|
|
|
|
12
|
|
import java.util.ArrayList;
|
|
13
|
|
import java.util.Collection;
|
|
14
|
|
import java.util.Iterator;
|
|
15
|
|
|
|
16
|
|
import org.jbind.xml.base.ILocation;
|
|
17
|
|
import org.jbind.xml.msg.IConstraintViolations;
|
|
18
|
|
import org.jbind.xml.schema.instantiation.IJobHelper;
|
|
19
|
|
import org.jbind.xml.schema.instantiation.IJobRefs;
|
|
20
|
|
|
|
21
|
|
public abstract class Job implements IJob {
|
|
22
|
|
|
|
23
|
|
private IJob myParent = null;
|
|
24
|
|
|
|
25
|
|
private IJobRefs myRefsForCreation = null;
|
|
26
|
|
private IJobRefs myRefsForCompletion = null;
|
|
27
|
|
private IJobRefs myRefsForValidation = null;
|
|
28
|
|
|
|
29
|
|
private Collection mySubJobs = new ArrayList();
|
|
30
|
|
|
|
31
|
|
private boolean myIsValidated = false;
|
|
32
|
|
|
|
33
|
|
private IJobHelper myHelper = null;
|
|
34
|
|
|
|
35
|
3801
|
public Job(IJobHelper aHelper) {
|
|
36
|
3801
|
myHelper = aHelper;
|
|
37
|
|
}
|
|
38
|
|
|
|
39
|
76
|
protected IJobHelper getHelper() {
|
|
40
|
76
|
return myHelper;
|
|
41
|
|
}
|
|
42
|
|
|
|
43
|
17659
|
public boolean getIsValidated() {
|
|
44
|
17659
|
return myIsValidated;
|
|
45
|
|
}
|
|
46
|
|
|
|
47
|
24372
|
public final IJob getParent() {
|
|
48
|
24372
|
return myParent;
|
|
49
|
|
}
|
|
50
|
|
|
|
51
|
3597
|
public final void setParent(IJob aParent) {
|
|
52
|
3597
|
myParent = aParent;
|
|
53
|
|
}
|
|
54
|
|
|
|
55
|
13544
|
public final Iterator iterRefsForCreation() {
|
|
56
|
13544
|
if (null == myRefsForCreation) {
|
|
57
|
3801
|
myRefsForCreation = new JobRefs();
|
|
58
|
3801
|
collectRefsForCreation(myRefsForCreation);
|
|
59
|
|
}
|
|
60
|
13544
|
return myRefsForCreation.iterJobRefs();
|
|
61
|
|
}
|
|
62
|
|
|
|
63
|
|
|
|
64
|
4578
|
public final Iterator iterRefsForCompletion() {
|
|
65
|
4578
|
if (null == myRefsForCompletion) {
|
|
66
|
3773
|
myRefsForCompletion = new JobRefs();
|
|
67
|
3773
|
collectRefsForCompletion(myRefsForCompletion);
|
|
68
|
|
}
|
|
69
|
4578
|
return myRefsForCompletion.iterJobRefs();
|
|
70
|
|
}
|
|
71
|
|
|
|
72
|
|
|
|
73
|
3716
|
public final Iterator iterRefsForValidation() {
|
|
74
|
3716
|
if (null == myRefsForValidation) {
|
|
75
|
3716
|
myRefsForValidation = new JobRefs();
|
|
76
|
3716
|
collectRefsForCompletion(myRefsForValidation);
|
|
77
|
|
}
|
|
78
|
3716
|
return myRefsForValidation.iterJobRefs();
|
|
79
|
|
}
|
|
80
|
|
|
|
81
|
|
|
|
82
|
|
protected abstract void collectRefsForCreation(IJobRefs aJobRefs);
|
|
83
|
|
|
|
84
|
|
protected abstract void collectRefsForCompletion(IJobRefs aJobRefs);
|
|
85
|
|
|
|
86
|
|
protected abstract void collectRefsForValidation(IJobRefs aJobRefs);
|
|
87
|
|
|
|
88
|
3597
|
protected void addSubJob(IJob aJob) {
|
|
89
|
3597
|
mySubJobs.add(aJob);
|
|
90
|
3597
|
aJob.setParent(this);
|
|
91
|
3597
|
getInstantiator().add(aJob);
|
|
92
|
|
}
|
|
93
|
|
|
|
94
|
14060
|
public Iterator iterSubJobs() {
|
|
95
|
14060
|
return mySubJobs.iterator();
|
|
96
|
|
}
|
|
97
|
|
|
|
98
|
3775
|
public final void executeCreation(IConstraintViolations aViolations) {
|
|
99
|
3775
|
doExecuteCreation(aViolations);
|
|
100
|
|
}
|
|
101
|
|
|
|
102
|
|
protected abstract void doExecuteCreation(IConstraintViolations aViolations);
|
|
103
|
|
|
|
104
|
3720
|
public final void executeCompletion(IConstraintViolations aViolations) {
|
|
105
|
3720
|
doExecuteCompletion(aViolations);
|
|
106
|
|
}
|
|
107
|
|
|
|
108
|
|
protected abstract void doExecuteCompletion(IConstraintViolations aViolations);
|
|
109
|
|
|
|
110
|
3716
|
public final void executeValidation(IConstraintViolations aViolations) {
|
|
111
|
3716
|
doExecuteValidation(aViolations);
|
|
112
|
3716
|
myIsValidated = true;
|
|
113
|
|
}
|
|
114
|
|
|
|
115
|
|
protected abstract void doExecuteValidation(IConstraintViolations aViolations);
|
|
116
|
|
|
|
117
|
14007
|
public boolean checkSubJobsValidated() {
|
|
118
|
14007
|
boolean res = true;
|
|
119
|
14007
|
for (Iterator i = iterSubJobs(); res && i.hasNext(); ) {
|
|
120
|
17546
|
IJob j = (IJob)i.next();
|
|
121
|
17546
|
res = j.getIsValidated();
|
|
122
|
|
}
|
|
123
|
14007
|
return res;
|
|
124
|
|
}
|
|
125
|
|
|
|
126
|
109
|
public String toString() {
|
|
127
|
109
|
return getDescription();
|
|
128
|
|
}
|
|
129
|
|
|
|
130
|
159
|
public ILocation getLocation() {
|
|
131
|
159
|
return myHelper.getLocation();
|
|
132
|
|
}
|
|
133
|
|
}
|
|
134
|
|
|