1 package uk.ac.cam.spectra;
2
3 import java.io.File;
4
5 import nu.xom.Document;
6
7 import com.hp.hpl.jena.rdf.model.Model;
8
9 /**
10 * Data object that holds input data, processing instructions and output data
11 * for file processing. The reason for modelling the processing instructions
12 * this way (rather than e.g. as method calls) is that this allows
13 * implementations to perform combinations of procedures (a common use case)
14 * efficiently, by reusing intermediate data structures and avoiding repeated
15 * validations, for example. The class holds both input data, output data and
16 * processing instructions to allow further efficiencies, e.g. allowing clients
17 * to pass in a pre-converted CML. It also allows various efficiencies and
18 * flexibilities on the part of the file handling component.
19 *
20 * @author Jim Downing
21 * @todo Refactor me: extract an interface and merge me with DataFileType.
22 */
23 public class DataProcess {
24
25 private Document convertedCml;
26
27 private Model extractedMetadata;
28
29 private String metadataPackageUri;
30
31 private boolean performConversion;
32
33 private boolean performExtraction;
34
35 private boolean performValidation;
36
37 private File sourceFile;
38
39 private Validation validation = new Validation();
40
41 public Document getConvertedCml() {
42 return convertedCml;
43 }
44
45 /**
46 * @return A Jena model including statements that can have the package and
47 * or individual files as subject resources. The model may be empty
48 * but must not be null.
49 */
50 public Model getExtractedMetadata() {
51 return extractedMetadata;
52 }
53
54 /**
55 * Accessor for the metadataPackageUri.
56 *
57 * @return
58 */
59 public String getMetadataPackageUri() {
60 return metadataPackageUri;
61 }
62
63 /**
64 * Accessor for the sourceFile field.
65 *
66 * @return the source file, may be null if not set or set to null.
67 */
68 public File getSourceFile() {
69 return sourceFile;
70 }
71
72 /**
73 * Returns the results of any validation performed.
74 *
75 * @return A validation object (must not return null). If a validation
76 * fails, then an exception should be raised from the process()
77 * method.
78 */
79 public Validation getValidation() {
80 return validation;
81 }
82
83 /**
84 * Accessor for the conversion processing instruction flag.
85 *
86 * @return
87 */
88 public boolean getPerformConversion() {
89 return performConversion;
90 }
91
92 /**
93 * Accessor for the metadata extraction processing instruction flag.
94 *
95 * @return
96 */
97 public boolean getPerformExtraction() {
98 return performExtraction;
99 }
100
101 /**
102 * Accessor for the metadata extraction processing instruction flag.
103 *
104 * @return
105 */
106 public boolean getPerformValidation() {
107 return performValidation;
108 }
109
110 /**
111 * Accessor for the converted CML. Most of the time this won't be used, but
112 * is useful if a DataFileType implementation indicates that it extracts
113 * metadata from resulting CML (rather than directly from the source file).
114 * Normally should only be used by DataFileType implementations.
115 *
116 * @param convertedCml
117 */
118 public void setConvertedCml(Document convertedCml) {
119 this.convertedCml = convertedCml;
120 }
121
122 /**
123 * Accessor for the extracted metadata. Should only be used by DataFileType
124 * implementations.
125 *
126 * @param extractedMetadata
127 */
128 public void setExtractedMetadata(Model extractedMetadata) {
129 this.extractedMetadata = extractedMetadata;
130 }
131
132 /**
133 * Accessor for the metadata package URI. Should be called by clients who
134 * wish to perform metadata extractions.
135 *
136 * @param metadataPackageUri
137 */
138 public void setMetadataPackageUri(String metadataPackageUri) {
139 this.metadataPackageUri = metadataPackageUri;
140 }
141
142 /**
143 * Accessor for conversion processing instruction flag.
144 * @param performConversion
145 */
146 public void setPerformConversion(boolean performConversion) {
147 this.performConversion = performConversion;
148 }
149
150 /**
151 * Accessor for conversion processing instruction flag.
152 * @param performExtraction
153 */
154 public void setPerformExtraction(boolean performExtraction) {
155 this.performExtraction = performExtraction;
156 }
157
158 public void setPerformValidation(boolean performValidation) {
159 this.performValidation = performValidation;
160 }
161
162 public void setSourceFile(File sourceFile) {
163 this.sourceFile = sourceFile;
164 }
165
166 public void setValidation(Validation validation) {
167 this.validation = validation;
168 }
169 }