source: DCWoRMS/trunk/src/dcworms/schedframe/scheduling/utils/JobDescription.java @ 490

Revision 490, 1.6 KB checked in by wojtekp, 13 years ago (diff)
  • Property svn:mime-type set to text/plain
Line 
1package dcworms.schedframe.scheduling.utils;
2
3import java.io.StringReader;
4import java.util.ArrayList;
5
6import org.exolab.castor.xml.MarshalException;
7import org.exolab.castor.xml.ResolverException;
8import org.exolab.castor.xml.Unmarshaller;
9import org.exolab.castor.xml.ValidationException;
10import org.exolab.castor.xml.XMLContext;
11
12import schedframe.DescriptionContainer;
13
14import org.qcg.broker.schemas.jobdesc.QcgJob;
15
16
17public class JobDescription extends ArrayList<TaskDescription> implements DescriptionContainer<QcgJob>{
18
19        private static final long serialVersionUID = 7853990656207447619L;
20        protected static Unmarshaller unmarshaller;
21        static {
22                XMLContext context = new XMLContext();
23                try {
24                        context.addClass(org.qcg.broker.schemas.jobdesc.QcgJob.class);
25                        unmarshaller = context.createUnmarshaller();
26                } catch (ResolverException e) {
27                        e.printStackTrace();
28                        unmarshaller = null;
29                }
30        }
31       
32        protected String xml;
33        protected QcgJob job;
34        protected String jobId;
35       
36        public JobDescription(String xmlJobDesc) throws MarshalException, ValidationException{
37                xml = xmlJobDesc;
38        }
39       
40        public String getJobId(){
41                return this.jobId;
42        }
43       
44        public void setJobId(String id){
45                this.jobId = id;
46        }
47       
48        public void discardUnused(){
49                job = null;
50                xml = null;
51                for(int i = 0; i < size(); i++){
52                        get(i).discardUnused();
53                }
54        }
55       
56        public QcgJob getDescription() {
57                if(job == null){
58                        try {
59                                job = (QcgJob) unmarshaller.unmarshal(new StringReader(xml));
60                        } catch (MarshalException e) {
61                                e.printStackTrace();
62                        } catch (ValidationException e) {
63                                e.printStackTrace();
64                        }
65                }
66                return job;
67        }
68
69        public String getDocument() throws Exception {
70                return xml;
71        }
72
73}
Note: See TracBrowser for help on using the repository browser.