1 |
0451b182
|
h.fradin
|
/**
|
2 |
01be5674
|
Andreas Müller
|
* Copyright (C) 2007 EDIT
|
3 |
|
|
* European Distributed Institute of Taxonomy
|
4 |
|
|
* http://www.e-taxonomy.eu
|
5 |
|
|
*
|
6 |
|
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
7 |
|
|
* See LICENSE.TXT at the top of this package for the full license terms.
|
8 |
|
|
*/
|
9 |
0451b182
|
h.fradin
|
|
10 |
|
|
package eu.etaxonomy.cdm.io.sdd;
|
11 |
|
|
|
12 |
|
|
import java.io.File;
|
13 |
|
|
import java.io.FileOutputStream;
|
14 |
|
|
import java.io.IOException;
|
15 |
|
|
import java.io.OutputStreamWriter;
|
16 |
|
|
import java.io.Writer;
|
17 |
60fed2eb
|
h.fradin
|
import java.util.HashMap;
|
18 |
|
|
import java.util.Iterator;
|
19 |
|
|
import java.util.List;
|
20 |
|
|
import java.util.Map;
|
21 |
|
|
import java.util.Set;
|
22 |
0451b182
|
h.fradin
|
|
23 |
|
|
import javax.xml.bind.Marshaller;
|
24 |
|
|
|
25 |
|
|
import org.apache.log4j.Logger;
|
26 |
56a7b96d
|
h.fradin
|
import org.apache.xerces.dom.DocumentImpl;
|
27 |
|
|
import org.apache.xerces.dom.ElementImpl;
|
28 |
2574d729
|
h.fradin
|
import org.joda.time.DateTime;
|
29 |
308145c5
|
ben.clark
|
import org.joda.time.format.DateTimeFormatter;
|
30 |
|
|
import org.joda.time.format.ISODateTimeFormat;
|
31 |
0451b182
|
h.fradin
|
import org.xml.sax.SAXException;
|
32 |
|
|
|
33 |
|
|
import com.sun.org.apache.xerces.internal.impl.xpath.regex.ParseException;
|
34 |
|
|
import com.sun.org.apache.xml.internal.serialize.DOMSerializer;
|
35 |
|
|
import com.sun.org.apache.xml.internal.serialize.OutputFormat;
|
36 |
|
|
import com.sun.org.apache.xml.internal.serialize.XMLSerializer;
|
37 |
|
|
|
38 |
|
|
import eu.etaxonomy.cdm.io.jaxb.CdmMarshallerListener;
|
39 |
60fed2eb
|
h.fradin
|
import eu.etaxonomy.cdm.model.agent.Person;
|
40 |
|
|
import eu.etaxonomy.cdm.model.agent.Team;
|
41 |
|
|
import eu.etaxonomy.cdm.model.agent.TeamOrPersonBase;
|
42 |
|
|
import eu.etaxonomy.cdm.model.common.Annotation;
|
43 |
3c784107
|
h.fradin
|
import eu.etaxonomy.cdm.model.common.DefinedTermBase;
|
44 |
|
|
import eu.etaxonomy.cdm.model.common.IdentifiableEntity;
|
45 |
60fed2eb
|
h.fradin
|
import eu.etaxonomy.cdm.model.common.OriginalSource;
|
46 |
3c784107
|
h.fradin
|
import eu.etaxonomy.cdm.model.common.Representation;
|
47 |
|
|
import eu.etaxonomy.cdm.model.common.TermBase;
|
48 |
|
|
import eu.etaxonomy.cdm.model.common.TermVocabulary;
|
49 |
|
|
import eu.etaxonomy.cdm.model.common.VersionableEntity;
|
50 |
|
|
import eu.etaxonomy.cdm.model.description.Feature;
|
51 |
|
|
import eu.etaxonomy.cdm.model.description.State;
|
52 |
60fed2eb
|
h.fradin
|
import eu.etaxonomy.cdm.model.media.Media;
|
53 |
3c784107
|
h.fradin
|
import eu.etaxonomy.cdm.model.media.Rights;
|
54 |
|
|
import eu.etaxonomy.cdm.model.name.TaxonNameBase;
|
55 |
56a7b96d
|
h.fradin
|
import eu.etaxonomy.cdm.model.reference.Article;
|
56 |
60fed2eb
|
h.fradin
|
import eu.etaxonomy.cdm.model.reference.Database;
|
57 |
|
|
import eu.etaxonomy.cdm.model.reference.ReferenceBase;
|
58 |
0451b182
|
h.fradin
|
|
59 |
|
|
/**
|
60 |
|
|
* Writes the SDD XML file.
|
61 |
|
|
*
|
62 |
|
|
* @author h.fradin
|
63 |
01be5674
|
Andreas Müller
|
* @created 10.12.2008
|
64 |
|
|
* @version 1.0
|
65 |
0451b182
|
h.fradin
|
*/
|
66 |
|
|
|
67 |
|
|
public class SDDDocumentBuilder {
|
68 |
60fed2eb
|
h.fradin
|
|
69 |
0451b182
|
h.fradin
|
private DocumentImpl document;
|
70 |
|
|
private XMLSerializer xmlserializer;
|
71 |
|
|
private Writer writer;
|
72 |
|
|
private DOMSerializer domi;
|
73 |
60fed2eb
|
h.fradin
|
private SDDDataSet cdmSource;
|
74 |
|
|
|
75 |
|
|
private Map<Person,String> agents = new HashMap<Person,String>();
|
76 |
3c784107
|
h.fradin
|
private Map<TaxonNameBase,String> taxonNames = new HashMap<TaxonNameBase,String>();
|
77 |
|
|
private Map<Feature,String> characters = new HashMap<Feature,String>();
|
78 |
|
|
private Map<Media,String> medias = new HashMap<Media,String>();
|
79 |
|
|
private Map<State,String> states = new HashMap<State,String>();
|
80 |
56a7b96d
|
h.fradin
|
private Map<Article, String> articles = new HashMap<Article, String>();
|
81 |
60fed2eb
|
h.fradin
|
private int agentsCount = 0;
|
82 |
3c784107
|
h.fradin
|
private int taxonNamesCount = 0;
|
83 |
|
|
private int charactersCount = 0;
|
84 |
|
|
private int mediasCount = 0;
|
85 |
|
|
private int statesCount = 0;
|
86 |
60fed2eb
|
h.fradin
|
|
87 |
0451b182
|
h.fradin
|
private String AGENT = "Agent";
|
88 |
|
|
private String AGENTS = "Agents";
|
89 |
|
|
private String CATEGORICAL = "Categorical";
|
90 |
|
|
private String CATEGORICAL_CHARACTER = "CategoricalCharacter";
|
91 |
|
|
private String CHARACTER = "Character";
|
92 |
|
|
private String CHARACTERS = "Characters";
|
93 |
|
|
private String CHARACTER_TREE = "CharacterTree";
|
94 |
|
|
private String CHARACTER_TREES = "CharacterTrees";
|
95 |
|
|
private String CHAR_NODE = "CharNode";
|
96 |
|
|
private String CODED_DESCRIPTION = "CodedDescription";
|
97 |
|
|
private String CODED_DESCRIPTIONS = "CodedDescriptions";
|
98 |
|
|
private String CREATORS = "Creators";
|
99 |
|
|
private String DATASET = "Dataset";
|
100 |
|
|
private String DATASETS = "Datasets";
|
101 |
|
|
private String DATE_CREATED = "DateCreated";
|
102 |
|
|
private String DATE_MODIFIED = "DateModified";
|
103 |
|
|
private String DEPENDENCY_RULES = "DependencyRules";
|
104 |
|
|
private String DESCRIPTIVE_CONCEPT = "DescriptiveConcept";
|
105 |
|
|
private String DESCRIPTIVE_CONCEPTS = "DescriptiveConcepts";
|
106 |
|
|
private String DETAIL = "Detail";
|
107 |
|
|
private String GENERATOR = "Generator";
|
108 |
|
|
private String ID = "id";
|
109 |
|
|
private String IMAGE = "Image";
|
110 |
|
|
private String INAPPLICABLE_IF = "InapplicableIf";
|
111 |
|
|
private String IPR_STATEMENT = "IPRStatement";
|
112 |
|
|
private String IPR_STATEMENTS = "IPRStatements";
|
113 |
|
|
private String LABEL = "Label";
|
114 |
|
|
private String MEDIA_OBJECT = "MediaObject";
|
115 |
|
|
private String MEDIA_OBJECTS = "MediaObjects";
|
116 |
|
|
private String NODE = "Node";
|
117 |
|
|
private String NODES = "Nodes";
|
118 |
|
|
private String NOTE = "Note";
|
119 |
|
|
private String PARENT = "Parent";
|
120 |
3c784107
|
h.fradin
|
private String QUANTITATIVE_CHARACTER = "QuantitativeCharacter";
|
121 |
0451b182
|
h.fradin
|
private String REF = "ref";
|
122 |
|
|
private String REPRESENTATION = "Representation";
|
123 |
|
|
private String REVISION_DATA = "RevisionData";
|
124 |
60fed2eb
|
h.fradin
|
private String ROLE = "role";
|
125 |
0451b182
|
h.fradin
|
private String SHOULD_CONTAIN_ALL_CHARACTERS = "ShouldContainAllCharacters";
|
126 |
|
|
private String SOURCE = "Source";
|
127 |
|
|
private String STATE = "State";
|
128 |
|
|
private String STATE_DEFINITION = "StateDefinition";
|
129 |
|
|
private String STATES = "States";
|
130 |
|
|
private String STATUS = "Status";
|
131 |
|
|
private String SUMMARY_DATA = "SummaryData";
|
132 |
3c784107
|
h.fradin
|
private String TAXON_NAME = "TaxonName";
|
133 |
|
|
private String TAXON_NAMES = "TaxonNames";
|
134 |
0451b182
|
h.fradin
|
private String TECHNICAL_METADATA = "TechnicalMetadata";
|
135 |
|
|
private String TEXT = "Text";
|
136 |
7c58e269
|
h.fradin
|
private String TEXT_CHARACTER = "TextCharacter";
|
137 |
0451b182
|
h.fradin
|
private String TYPE = "Type";
|
138 |
3c784107
|
h.fradin
|
private String URI = "uri";
|
139 |
60fed2eb
|
h.fradin
|
|
140 |
0451b182
|
h.fradin
|
private static final Logger logger = Logger.getLogger(SDDDocumentBuilder.class);
|
141 |
60fed2eb
|
h.fradin
|
|
142 |
0451b182
|
h.fradin
|
// private SDDContext sddContext;
|
143 |
60fed2eb
|
h.fradin
|
|
144 |
0451b182
|
h.fradin
|
public SDDDocumentBuilder() throws SAXException, IOException {
|
145 |
60fed2eb
|
h.fradin
|
|
146 |
0451b182
|
h.fradin
|
document = new DocumentImpl();
|
147 |
60fed2eb
|
h.fradin
|
|
148 |
0451b182
|
h.fradin
|
// sddContext = SDDContext.newInstance(new Class[] {SDDDataSet.class});
|
149 |
|
|
// logger.debug(sddContext.toString());
|
150 |
|
|
|
151 |
|
|
}
|
152 |
60fed2eb
|
h.fradin
|
|
153 |
|
|
public void marshal(SDDDataSet cdmSource, File sddDestination) throws IOException {
|
154 |
|
|
|
155 |
|
|
this.cdmSource = cdmSource;
|
156 |
2574d729
|
h.fradin
|
Marshaller marshaller;
|
157 |
0451b182
|
h.fradin
|
CdmMarshallerListener marshallerListener = new CdmMarshallerListener();
|
158 |
|
|
logger.info("Start marshalling");
|
159 |
60fed2eb
|
h.fradin
|
writeCDMtoSDD(sddDestination);
|
160 |
|
|
|
161 |
0451b182
|
h.fradin
|
}
|
162 |
|
|
|
163 |
|
|
/**Write the DOM document.
|
164 |
|
|
* @param base
|
165 |
|
|
* @throws IOException
|
166 |
|
|
*/
|
167 |
60fed2eb
|
h.fradin
|
public void writeCDMtoSDD(File sddDestination) throws IOException {
|
168 |
|
|
|
169 |
0451b182
|
h.fradin
|
try {
|
170 |
60fed2eb
|
h.fradin
|
buildDocument();
|
171 |
0451b182
|
h.fradin
|
} catch (ParseException e) {
|
172 |
|
|
System.out.println("Problem with SDD export located in the buildDocument() method ...");
|
173 |
|
|
e.printStackTrace();
|
174 |
|
|
}
|
175 |
60fed2eb
|
h.fradin
|
|
176 |
0451b182
|
h.fradin
|
OutputFormat format = new OutputFormat(document, "UTF-8", true);
|
177 |
60fed2eb
|
h.fradin
|
|
178 |
0451b182
|
h.fradin
|
FileOutputStream fos = new FileOutputStream(sddDestination);
|
179 |
60fed2eb
|
h.fradin
|
|
180 |
0451b182
|
h.fradin
|
writer = new OutputStreamWriter(fos, "UTF-8");
|
181 |
60fed2eb
|
h.fradin
|
|
182 |
0451b182
|
h.fradin
|
xmlserializer = new XMLSerializer(writer, format);
|
183 |
|
|
domi = xmlserializer.asDOMSerializer(); // As a DOM Serializer
|
184 |
60fed2eb
|
h.fradin
|
|
185 |
0451b182
|
h.fradin
|
domi.serialize(document.getDocumentElement());
|
186 |
60fed2eb
|
h.fradin
|
|
187 |
0451b182
|
h.fradin
|
writer.close();
|
188 |
|
|
}
|
189 |
|
|
|
190 |
|
|
// #############
|
191 |
|
|
// # BUILD DOM #
|
192 |
|
|
// #############
|
193 |
60fed2eb
|
h.fradin
|
|
194 |
|
|
/**
|
195 |
|
|
* Builds the whole document.
|
196 |
|
|
* @param base the Base
|
197 |
|
|
* @throws ParseException
|
198 |
|
|
*/
|
199 |
|
|
public void buildDocument() throws ParseException {
|
200 |
|
|
|
201 |
|
|
//create <Datasets> = root node
|
202 |
|
|
ElementImpl baselement = new ElementImpl(document, DATASETS);
|
203 |
|
|
|
204 |
|
|
baselement.setAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance");
|
205 |
|
|
baselement.setAttribute("xmlns", "http://rs.tdwg.org/UBIF/2006/");
|
206 |
|
|
baselement.setAttribute("xsi:schemaLocation", "http://rs.tdwg.org/UBIF/2006 http://rs.tdwg.org/UBIF/2006/Schema/1.1/SDD.xsd");
|
207 |
|
|
|
208 |
|
|
buildTechnicalMetadata(baselement);
|
209 |
|
|
|
210 |
|
|
List<ReferenceBase> references = cdmSource.getReferences();
|
211 |
|
|
Iterator<ReferenceBase> iterator = references.iterator();
|
212 |
|
|
Database d = Database.NewInstance();
|
213 |
|
|
while (iterator.hasNext()) {
|
214 |
|
|
ReferenceBase reference = (ReferenceBase) iterator.next();
|
215 |
|
|
if (reference instanceof Database) {
|
216 |
|
|
buildDataset(baselement, (Database) reference);
|
217 |
2574d729
|
h.fradin
|
}
|
218 |
60fed2eb
|
h.fradin
|
}
|
219 |
|
|
|
220 |
|
|
// for datasets with no Database ReferenceBase
|
221 |
|
|
// buildDataset(baselement, cdmSource, null);
|
222 |
|
|
|
223 |
|
|
//append the root element to the DOM document
|
224 |
|
|
document.appendChild(baselement);
|
225 |
|
|
}
|
226 |
|
|
|
227 |
|
|
// #############
|
228 |
|
|
// # BUILD DOM #
|
229 |
|
|
// #############
|
230 |
|
|
|
231 |
|
|
/**
|
232 |
|
|
* Builds TechnicalMetadata associated with the SDD file
|
233 |
|
|
*/
|
234 |
|
|
public void buildTechnicalMetadata(ElementImpl baselement) throws ParseException {
|
235 |
|
|
//create TechnicalMetadata
|
236 |
|
|
ElementImpl technicalMetadata = new ElementImpl(document, TECHNICAL_METADATA);
|
237 |
|
|
//select different databases associated to different descriptions TODO
|
238 |
|
|
List<ReferenceBase> references = cdmSource.getReferences();
|
239 |
|
|
Iterator<ReferenceBase> iterator = references.iterator();
|
240 |
|
|
boolean database = false;
|
241 |
|
|
Database d = Database.NewInstance();
|
242 |
|
|
while ((iterator.hasNext()) && (!database)) {
|
243 |
|
|
ReferenceBase reference = (ReferenceBase) iterator.next();
|
244 |
|
|
if (reference instanceof Database) {
|
245 |
|
|
d = (Database) reference;
|
246 |
|
|
}
|
247 |
|
|
}
|
248 |
|
|
DateTime dt = d.getCreated();
|
249 |
|
|
String date = dt.toString().substring(0, 19);
|
250 |
|
|
technicalMetadata.setAttribute("created", date);
|
251 |
|
|
|
252 |
|
|
ElementImpl generator = new ElementImpl(document, GENERATOR);
|
253 |
|
|
generator.setAttribute("name", "EDIT CDM");
|
254 |
|
|
generator.setAttribute("version", "v1");
|
255 |
|
|
generator.setAttribute("notes","This SDD file has been generated by the SDD export functionality of the EDIT platform for Cybertaxonomy - Copyright (c) 2008");
|
256 |
|
|
technicalMetadata.appendChild(generator);
|
257 |
|
|
|
258 |
|
|
baselement.appendChild(technicalMetadata);
|
259 |
|
|
}
|
260 |
|
|
|
261 |
|
|
// Builds the information associated with a dataset
|
262 |
|
|
public void buildDataset(ElementImpl baselement, Database reference) throws ParseException {
|
263 |
|
|
// create Dataset and language
|
264 |
|
|
ElementImpl dataset = new ElementImpl(document, DATASET);
|
265 |
|
|
// no default language associated with a dataset in the CDM
|
266 |
|
|
// dataset.setAttribute("xml:lang", datasetLanguage);
|
267 |
|
|
baselement.appendChild(dataset);
|
268 |
|
|
buildRepresentation(dataset, reference);
|
269 |
|
|
buildRevisionData(dataset, reference);
|
270 |
3c784107
|
h.fradin
|
buildIPRStatements(dataset, reference);
|
271 |
|
|
buildTaxonNames(dataset);
|
272 |
|
|
buildCharacters(dataset);
|
273 |
60fed2eb
|
h.fradin
|
|
274 |
|
|
}
|
275 |
|
|
|
276 |
|
|
/**
|
277 |
3c784107
|
h.fradin
|
* Builds a Representation element using a ReferenceBase
|
278 |
60fed2eb
|
h.fradin
|
*/
|
279 |
|
|
public void buildRepresentation(ElementImpl element, ReferenceBase reference) throws ParseException {
|
280 |
|
|
|
281 |
|
|
// create <Representation> element
|
282 |
|
|
ElementImpl representation = new ElementImpl(document, REPRESENTATION);
|
283 |
|
|
element.appendChild(representation);
|
284 |
|
|
buildLabel(representation, reference.getTitleCache());
|
285 |
|
|
|
286 |
|
|
Set<Annotation> annotations = reference.getAnnotations();
|
287 |
|
|
Iterator iterator = annotations.iterator();
|
288 |
|
|
String detailText = null;
|
289 |
|
|
if (iterator.hasNext()) {
|
290 |
|
|
Annotation annotation = (Annotation) iterator.next();
|
291 |
|
|
detailText = annotation.getText();
|
292 |
|
|
}
|
293 |
|
|
|
294 |
|
|
if (detailText != null && !detailText.equals("")) {
|
295 |
|
|
ElementImpl detail = new ElementImpl(document, DETAIL);
|
296 |
|
|
detail.appendChild(document.createTextNode(detailText));
|
297 |
|
|
representation.appendChild(detail);
|
298 |
|
|
}
|
299 |
|
|
|
300 |
3c784107
|
h.fradin
|
Set<Media> rm = reference.getMedia();
|
301 |
60fed2eb
|
h.fradin
|
|
302 |
3c784107
|
h.fradin
|
if (rm != null && rm.size() > 0) {
|
303 |
60fed2eb
|
h.fradin
|
ElementImpl mediaObject;
|
304 |
|
|
|
305 |
3c784107
|
h.fradin
|
for (int i = 0; i < rm.size(); i++) {
|
306 |
60fed2eb
|
h.fradin
|
mediaObject = new ElementImpl(document, MEDIA_OBJECT);
|
307 |
01be5674
|
Andreas Müller
|
//mediaObject = org.apache.xerces.dom.ElementImpl(document, MEDIA_OBJECT);
|
308 |
7c58e269
|
h.fradin
|
mediasCount = buildReference((Media) rm.toArray()[i], medias, REF, mediaObject, "m", mediasCount);
|
309 |
60fed2eb
|
h.fradin
|
representation.appendChild(mediaObject);
|
310 |
|
|
}
|
311 |
|
|
}
|
312 |
|
|
|
313 |
|
|
}
|
314 |
|
|
|
315 |
|
|
// ################
|
316 |
|
|
// # GENERIC BRICKS #
|
317 |
|
|
// ################
|
318 |
|
|
|
319 |
|
|
/**
|
320 |
|
|
* Creates a Label element
|
321 |
|
|
* @param base
|
322 |
|
|
* @param element
|
323 |
|
|
*/
|
324 |
|
|
public void buildLabel(ElementImpl element, String text) {
|
325 |
|
|
// create <Label> element
|
326 |
|
|
ElementImpl label = new ElementImpl(document, LABEL);
|
327 |
|
|
|
328 |
3c784107
|
h.fradin
|
// if language different from language dataset, indicate it TODO, but need to deal with a database language
|
329 |
60fed2eb
|
h.fradin
|
label.appendChild(document.createTextNode(text));
|
330 |
|
|
element.appendChild(label);
|
331 |
|
|
}
|
332 |
|
|
|
333 |
|
|
|
334 |
|
|
/**
|
335 |
3c784107
|
h.fradin
|
* Builds TaxonNames associated with the Dataset
|
336 |
60fed2eb
|
h.fradin
|
*/
|
337 |
3c784107
|
h.fradin
|
public void buildTaxonNames(ElementImpl dataset) throws ParseException {
|
338 |
60fed2eb
|
h.fradin
|
|
339 |
3c784107
|
h.fradin
|
// <TaxonNames>
|
340 |
|
|
// <TaxonName id="t1" uri="urn:lsid:authority:namespace:my-own-id">
|
341 |
|
|
// <Representation>
|
342 |
|
|
// <Label xml:lang="la">Viola hederacea Labill.</Label>
|
343 |
|
|
// </Representation>
|
344 |
|
|
// </TaxonName>
|
345 |
|
|
// </TaxonNames>
|
346 |
60fed2eb
|
h.fradin
|
|
347 |
3c784107
|
h.fradin
|
if (cdmSource.getTaxonomicNames() != null) {
|
348 |
|
|
ElementImpl elTaxonNames = new ElementImpl(document, TAXON_NAMES);
|
349 |
60fed2eb
|
h.fradin
|
|
350 |
3c784107
|
h.fradin
|
for (int i = 0; i < cdmSource.getTaxonomicNames().size(); i++) {
|
351 |
|
|
ElementImpl elTaxonName = new ElementImpl(document, TAXON_NAME);
|
352 |
|
|
TaxonNameBase tnb = cdmSource.getTaxonomicNames().get(i);
|
353 |
60fed2eb
|
h.fradin
|
|
354 |
7c58e269
|
h.fradin
|
taxonNamesCount = buildReference(tnb, taxonNames, REF, elTaxonName, "t", taxonNamesCount);
|
355 |
3c784107
|
h.fradin
|
|
356 |
|
|
buildRepresentation(elTaxonName, tnb);
|
357 |
|
|
|
358 |
|
|
elTaxonNames.appendChild(elTaxonName);
|
359 |
60fed2eb
|
h.fradin
|
}
|
360 |
3c784107
|
h.fradin
|
|
361 |
|
|
dataset.appendChild(elTaxonNames);
|
362 |
60fed2eb
|
h.fradin
|
}
|
363 |
|
|
|
364 |
|
|
}
|
365 |
|
|
|
366 |
|
|
/**
|
367 |
|
|
* Builds an element Agent referring to Agent defined later in the SDD file
|
368 |
|
|
*/
|
369 |
|
|
public void buildRefAgent(ElementImpl element, TeamOrPersonBase ag, String role) throws ParseException {
|
370 |
|
|
if (ag instanceof Person) {
|
371 |
|
|
Person p = (Person) ag;
|
372 |
|
|
ElementImpl agent = new ElementImpl(document, AGENT);
|
373 |
|
|
agent.setAttribute(ROLE, role);
|
374 |
7c58e269
|
h.fradin
|
agentsCount = buildReference(p, agents, REF, agent, "a", agentsCount);
|
375 |
60fed2eb
|
h.fradin
|
element.appendChild(agent);
|
376 |
|
|
}
|
377 |
|
|
|
378 |
|
|
if (ag instanceof Team) {
|
379 |
|
|
Team team = (Team) ag;
|
380 |
|
|
for (int i = 0; i < team.getTeamMembers().size(); i++) {
|
381 |
|
|
ElementImpl agent = new ElementImpl(document, AGENT);
|
382 |
|
|
agent.setAttribute(ROLE, role);
|
383 |
|
|
Person author = team.getTeamMembers().get(i);
|
384 |
|
|
if (author.getSources() != null) {
|
385 |
|
|
OriginalSource os = (OriginalSource) author.getSources().toArray()[0];
|
386 |
|
|
String id = os.getIdInSource();
|
387 |
|
|
if (id != null) {
|
388 |
|
|
if (!id.equals("")) {
|
389 |
|
|
if (!agents.containsValue(id)) {
|
390 |
|
|
agent.setAttribute(REF, id);
|
391 |
|
|
} else if (!agents.containsValue("a" + (agentsCount+1))) {
|
392 |
|
|
agent.setAttribute(REF, "a" + (agentsCount+1));
|
393 |
|
|
agentsCount++;
|
394 |
|
|
} else {
|
395 |
|
|
agent.setAttribute(REF, id + (agentsCount+1));
|
396 |
|
|
agentsCount++;
|
397 |
|
|
}
|
398 |
|
|
} else {
|
399 |
|
|
agent.setAttribute(REF, "a" + (agentsCount+1));
|
400 |
|
|
agentsCount++;
|
401 |
|
|
}
|
402 |
|
|
} else {
|
403 |
|
|
agent.setAttribute(REF, "a" + (agentsCount+1));
|
404 |
|
|
agentsCount++;
|
405 |
|
|
}
|
406 |
3c784107
|
h.fradin
|
} else {
|
407 |
|
|
agent.setAttribute(REF, "a" + (agentsCount+1));
|
408 |
|
|
agentsCount++;
|
409 |
60fed2eb
|
h.fradin
|
}
|
410 |
3c784107
|
h.fradin
|
agents.put(author, agent.getAttribute(REF));
|
411 |
60fed2eb
|
h.fradin
|
element.appendChild(agent);
|
412 |
|
|
}
|
413 |
|
|
}
|
414 |
|
|
}
|
415 |
|
|
|
416 |
eeace9f2
|
h.fradin
|
/**
|
417 |
|
|
* Builds ModifiedDate associated with RevisionData
|
418 |
|
|
*/
|
419 |
|
|
public void buildDateModified(ElementImpl revisionData, Database database) throws ParseException {
|
420 |
3c784107
|
h.fradin
|
|
421 |
eeace9f2
|
h.fradin
|
// <DateModified>2006-04-08T00:00:00</DateModified>
|
422 |
3c784107
|
h.fradin
|
|
423 |
eeace9f2
|
h.fradin
|
if (database.getUpdated() != null) {
|
424 |
|
|
ElementImpl dateModified = new ElementImpl(document, DATE_MODIFIED);
|
425 |
3c784107
|
h.fradin
|
|
426 |
308145c5
|
ben.clark
|
DateTime c = database.getUpdated();
|
427 |
|
|
DateTimeFormatter fmt = ISODateTimeFormat.dateTime();
|
428 |
|
|
|
429 |
|
|
String date = fmt.print(c);
|
430 |
eeace9f2
|
h.fradin
|
dateModified.appendChild(document.createTextNode(date));
|
431 |
3c784107
|
h.fradin
|
|
432 |
eeace9f2
|
h.fradin
|
revisionData.appendChild(dateModified);
|
433 |
|
|
}
|
434 |
|
|
|
435 |
3c784107
|
h.fradin
|
}
|
436 |
60fed2eb
|
h.fradin
|
|
437 |
|
|
/**
|
438 |
3c784107
|
h.fradin
|
* Builds IPRStatements associated with the Dataset
|
439 |
60fed2eb
|
h.fradin
|
*/
|
440 |
3c784107
|
h.fradin
|
public void buildIPRStatements(ElementImpl dataset, Database database) throws ParseException {
|
441 |
|
|
|
442 |
|
|
// <IPRStatements>
|
443 |
|
|
// <IPRStatement role="Copyright">
|
444 |
|
|
// <Label xml:lang="en-au">(c) 2003-2006 Centre for Occasional Botany.</Label>
|
445 |
|
|
// </IPRStatement>
|
446 |
|
|
// </IPRStatements>
|
447 |
|
|
|
448 |
|
|
if (database.getRights() != null) {
|
449 |
|
|
// create IPRStatements
|
450 |
|
|
ElementImpl iprStatements = new ElementImpl(document, IPR_STATEMENTS);
|
451 |
|
|
dataset.appendChild(iprStatements);
|
452 |
|
|
|
453 |
|
|
//mapping between IPRStatement Copyright (SDD) and first Right in the list of Rights
|
454 |
|
|
ElementImpl iprStatement = new ElementImpl(document, IPR_STATEMENT);
|
455 |
|
|
iprStatement.setAttribute("role", "Copyright");
|
456 |
|
|
iprStatements.appendChild(iprStatement);
|
457 |
|
|
buildLabel(iprStatement, ((Rights) database.getRights().toArray()[0]).getText());
|
458 |
60fed2eb
|
h.fradin
|
}
|
459 |
|
|
|
460 |
3c784107
|
h.fradin
|
}
|
461 |
60fed2eb
|
h.fradin
|
|
462 |
3c784107
|
h.fradin
|
/**
|
463 |
|
|
* Builds RevisionData associated with the Dataset
|
464 |
60fed2eb
|
h.fradin
|
*/
|
465 |
3c784107
|
h.fradin
|
public void buildRevisionData(ElementImpl dataset, Database database) throws ParseException {
|
466 |
60fed2eb
|
h.fradin
|
|
467 |
3c784107
|
h.fradin
|
// <RevisionData>
|
468 |
|
|
// <Creators>
|
469 |
|
|
// <Agent role="aut" ref="a1"/>
|
470 |
|
|
// <Agent role="aut" ref="a2"/>
|
471 |
|
|
// <Agent role="edt" ref="a3"/>
|
472 |
|
|
// </Creators>
|
473 |
|
|
// <DateModified>2006-04-08T00:00:00</DateModified>
|
474 |
|
|
// </RevisionData>
|
475 |
60fed2eb
|
h.fradin
|
|
476 |
3c784107
|
h.fradin
|
ElementImpl revisionData = new ElementImpl(document, REVISION_DATA);
|
477 |
60fed2eb
|
h.fradin
|
|
478 |
3c784107
|
h.fradin
|
// authors
|
479 |
|
|
TeamOrPersonBase authors = database.getAuthorTeam();
|
480 |
308145c5
|
ben.clark
|
// TeamOrPersonBase editors = database.getUpdatedBy();
|
481 |
60fed2eb
|
h.fradin
|
|
482 |
308145c5
|
ben.clark
|
if ((authors != null)) { // || (editors != null)) {
|
483 |
3c784107
|
h.fradin
|
ElementImpl creators = new ElementImpl(document, CREATORS);
|
484 |
|
|
if (authors != null) {
|
485 |
|
|
buildRefAgent(creators, authors, "aut");
|
486 |
|
|
}
|
487 |
308145c5
|
ben.clark
|
// if (editors != null) {
|
488 |
|
|
// buildRefAgent(creators, editors, "edt");
|
489 |
|
|
// }
|
490 |
3c784107
|
h.fradin
|
revisionData.appendChild(creators);
|
491 |
60fed2eb
|
h.fradin
|
}
|
492 |
|
|
|
493 |
3c784107
|
h.fradin
|
buildDateModified(revisionData, database);
|
494 |
60fed2eb
|
h.fradin
|
|
495 |
3c784107
|
h.fradin
|
dataset.appendChild(revisionData);
|
496 |
|
|
}
|
497 |
|
|
|
498 |
|
|
/**
|
499 |
|
|
* Builds a Representation element using an IdentifiableEntity
|
500 |
60fed2eb
|
h.fradin
|
*/
|
501 |
3c784107
|
h.fradin
|
public void buildRepresentation(ElementImpl element, IdentifiableEntity ie) throws ParseException {
|
502 |
60fed2eb
|
h.fradin
|
|
503 |
3c784107
|
h.fradin
|
// create <Representation> element
|
504 |
|
|
ElementImpl representation = new ElementImpl(document, REPRESENTATION);
|
505 |
|
|
element.appendChild(representation);
|
506 |
|
|
buildLabel(representation, ie.getTitleCache());
|
507 |
60fed2eb
|
h.fradin
|
|
508 |
3c784107
|
h.fradin
|
Set<Annotation> annotations = ie.getAnnotations();
|
509 |
|
|
Iterator iterator = annotations.iterator();
|
510 |
|
|
String detailText = null;
|
511 |
|
|
if (iterator.hasNext()) {
|
512 |
|
|
Annotation annotation = (Annotation) iterator.next();
|
513 |
|
|
detailText = annotation.getText();
|
514 |
|
|
}
|
515 |
60fed2eb
|
h.fradin
|
|
516 |
3c784107
|
h.fradin
|
if (detailText != null && !detailText.equals("")) {
|
517 |
|
|
ElementImpl detail = new ElementImpl(document, DETAIL);
|
518 |
|
|
detail.appendChild(document.createTextNode(detailText));
|
519 |
|
|
representation.appendChild(detail);
|
520 |
|
|
}
|
521 |
60fed2eb
|
h.fradin
|
|
522 |
3c784107
|
h.fradin
|
}
|
523 |
60fed2eb
|
h.fradin
|
|
524 |
3c784107
|
h.fradin
|
/**
|
525 |
|
|
* Builds Characters associated with the Dataset
|
526 |
|
|
*/
|
527 |
|
|
public void buildCharacters(ElementImpl dataset) throws ParseException {
|
528 |
|
|
|
529 |
|
|
if (cdmSource.getTerms() != null) {
|
530 |
|
|
ElementImpl elCharacters = new ElementImpl(document, CHARACTERS);
|
531 |
|
|
|
532 |
|
|
//TODO Boucle infinie
|
533 |
|
|
int f = cdmSource.getTerms().size();
|
534 |
|
|
for (int i = 0; i < f; i++) {
|
535 |
|
|
if (cdmSource.getTerms().get(i) instanceof Feature) {
|
536 |
|
|
Feature character = (Feature) cdmSource.getTerms().get(i);
|
537 |
08b9a163
|
ben.clark
|
if (character.supportsQuantitativeData()) {
|
538 |
3c784107
|
h.fradin
|
ElementImpl elQuantitativeCharacter = new ElementImpl(document, QUANTITATIVE_CHARACTER);
|
539 |
7c58e269
|
h.fradin
|
charactersCount = buildReference(character, characters, ID, elQuantitativeCharacter, "c", charactersCount);
|
540 |
3c784107
|
h.fradin
|
// TODO if the character also supports text, add to the label a short tag to distinguish
|
541 |
|
|
// it as the quantitative version and create a unique label
|
542 |
|
|
buildRepresentation(elQuantitativeCharacter, character);
|
543 |
|
|
// TODO <MeasurementUnit> and <Default>
|
544 |
|
|
elCharacters.appendChild(elQuantitativeCharacter);
|
545 |
|
|
}
|
546 |
08b9a163
|
ben.clark
|
if (character.supportsTextData()) {
|
547 |
d37cd796
|
ben.clark
|
Set<TermVocabulary<State>> enumerations = character.getSupportedCategoricalEnumerations();
|
548 |
3c784107
|
h.fradin
|
if (enumerations != null) {
|
549 |
|
|
if (enumerations.size()>0) {
|
550 |
|
|
ElementImpl elCategoricalCharacter = new ElementImpl(document, CATEGORICAL_CHARACTER);
|
551 |
7c58e269
|
h.fradin
|
charactersCount = buildReference(character, characters, ID, elCategoricalCharacter, "c", charactersCount);
|
552 |
3c784107
|
h.fradin
|
buildRepresentation(elCategoricalCharacter, character);
|
553 |
|
|
ElementImpl elStates = new ElementImpl(document, STATES);
|
554 |
|
|
TermVocabulary tv = (TermVocabulary) enumerations.toArray()[0];
|
555 |
|
|
Set<State> stateList = tv.getTerms();
|
556 |
|
|
for (int j = 0; j < stateList.size(); j++) {
|
557 |
|
|
ElementImpl elStateDefinition = new ElementImpl(document, STATE_DEFINITION);
|
558 |
|
|
State state = (State) stateList.toArray()[j];
|
559 |
7c58e269
|
h.fradin
|
statesCount = buildReference(state, states, ID, elStateDefinition, "s", statesCount);
|
560 |
3c784107
|
h.fradin
|
buildRepresentation(elStateDefinition, state);
|
561 |
|
|
elStates.appendChild(elStateDefinition);
|
562 |
|
|
}
|
563 |
|
|
elCategoricalCharacter.appendChild(elStates);
|
564 |
|
|
elCharacters.appendChild(elCategoricalCharacter);
|
565 |
60fed2eb
|
h.fradin
|
}
|
566 |
|
|
}
|
567 |
7c58e269
|
h.fradin
|
if ((enumerations == null) || (enumerations.size() <= 0)) {
|
568 |
|
|
ElementImpl elTextCharacter = new ElementImpl(document, TEXT_CHARACTER);
|
569 |
|
|
charactersCount = buildReference(character, characters, ID, elTextCharacter, "c", charactersCount);
|
570 |
|
|
buildRepresentation(elTextCharacter, character);
|
571 |
|
|
// TODO <MeasurementUnit> and <Default>
|
572 |
|
|
elCharacters.appendChild(elTextCharacter);
|
573 |
|
|
}
|
574 |
60fed2eb
|
h.fradin
|
}
|
575 |
|
|
}
|
576 |
3c784107
|
h.fradin
|
}
|
577 |
60fed2eb
|
h.fradin
|
|
578 |
3c784107
|
h.fradin
|
dataset.appendChild(elCharacters);
|
579 |
|
|
}
|
580 |
|
|
|
581 |
|
|
}
|
582 |
|
|
|
583 |
|
|
/**
|
584 |
|
|
* Builds an element Agent referring to Agent defined later in the SDD file
|
585 |
|
|
*/
|
586 |
7c58e269
|
h.fradin
|
public int buildReference(VersionableEntity ve, Map references, String refOrId, ElementImpl element, String prefix, int count) throws ParseException {
|
587 |
3c784107
|
h.fradin
|
if (ve instanceof IdentifiableEntity) {
|
588 |
|
|
IdentifiableEntity ie = (IdentifiableEntity) ve;
|
589 |
|
|
if (ie.getSources() != null) {
|
590 |
|
|
OriginalSource os = (OriginalSource) ie.getSources().toArray()[0];
|
591 |
|
|
String id = os.getIdInSource();
|
592 |
|
|
if (id != null) {
|
593 |
|
|
if (!id.equals("")) {
|
594 |
|
|
if (!references.containsValue(id)) {
|
595 |
|
|
element.setAttribute(refOrId, id);
|
596 |
|
|
} else while (element.getAttribute(refOrId).equals("")) {
|
597 |
|
|
if (!references.containsValue(prefix + (count+1))) {
|
598 |
|
|
element.setAttribute(refOrId, prefix + (count+1));
|
599 |
60fed2eb
|
h.fradin
|
}
|
600 |
3c784107
|
h.fradin
|
count++;
|
601 |
60fed2eb
|
h.fradin
|
}
|
602 |
3c784107
|
h.fradin
|
} else while (element.getAttribute(refOrId).equals("")) {
|
603 |
|
|
if (!references.containsValue(prefix + (count+1))) {
|
604 |
|
|
element.setAttribute(refOrId, prefix + (count+1));
|
605 |
|
|
}
|
606 |
|
|
count++;
|
607 |
|
|
}
|
608 |
|
|
} else while (element.getAttribute(refOrId).equals("")) {
|
609 |
|
|
if (!references.containsValue(prefix + (count+1))) {
|
610 |
|
|
element.setAttribute(refOrId, prefix + (count+1));
|
611 |
60fed2eb
|
h.fradin
|
}
|
612 |
3c784107
|
h.fradin
|
count++;
|
613 |
|
|
}
|
614 |
|
|
} else while (element.getAttribute(refOrId).equals("")) {
|
615 |
|
|
if (!references.containsValue(prefix + (count+1))) {
|
616 |
|
|
element.setAttribute(refOrId, prefix + (count+1));
|
617 |
60fed2eb
|
h.fradin
|
}
|
618 |
3c784107
|
h.fradin
|
count++;
|
619 |
|
|
}
|
620 |
|
|
} else while (element.getAttribute(refOrId).equals("")) {
|
621 |
|
|
if (!references.containsValue(prefix + (count+1))) {
|
622 |
|
|
element.setAttribute(refOrId, prefix + (count+1));
|
623 |
|
|
}
|
624 |
|
|
count++;
|
625 |
|
|
}
|
626 |
|
|
references.put(ve, element.getAttribute(refOrId));
|
627 |
7c58e269
|
h.fradin
|
return count;
|
628 |
3c784107
|
h.fradin
|
}
|
629 |
|
|
|
630 |
|
|
/**
|
631 |
|
|
* Builds a Representation element using a Feature
|
632 |
60fed2eb
|
h.fradin
|
*/
|
633 |
3c784107
|
h.fradin
|
public void buildRepresentation(ElementImpl element, TermBase tb) throws ParseException {
|
634 |
|
|
|
635 |
|
|
// create <Representation> element
|
636 |
|
|
ElementImpl representation = new ElementImpl(document, REPRESENTATION);
|
637 |
|
|
element.appendChild(representation);
|
638 |
|
|
String label = ((Representation) tb.getRepresentations().toArray()[0]).getLabel();
|
639 |
|
|
buildLabel(representation, label);
|
640 |
|
|
|
641 |
|
|
String detailText = tb.getDescription();
|
642 |
|
|
|
643 |
|
|
if (detailText != null && !detailText.equals("")) {
|
644 |
|
|
if (!detailText.equals(label)) {
|
645 |
|
|
ElementImpl detail = new ElementImpl(document, DETAIL);
|
646 |
|
|
detail.appendChild(document.createTextNode(detailText));
|
647 |
|
|
representation.appendChild(detail);
|
648 |
|
|
}
|
649 |
60fed2eb
|
h.fradin
|
}
|
650 |
3c784107
|
h.fradin
|
|
651 |
|
|
if (tb instanceof DefinedTermBase) {
|
652 |
|
|
DefinedTermBase dtb = (DefinedTermBase) tb;
|
653 |
|
|
Set<Media> rm = dtb.getMedia();
|
654 |
|
|
|
655 |
|
|
if (rm != null && rm.size() > 0) {
|
656 |
|
|
ElementImpl mediaObject;
|
657 |
60fed2eb
|
h.fradin
|
|
658 |
3c784107
|
h.fradin
|
for (int i = 0; i < rm.size(); i++) {
|
659 |
|
|
mediaObject = new ElementImpl(document, MEDIA_OBJECT);
|
660 |
7c58e269
|
h.fradin
|
mediasCount = buildReference((Media) rm.toArray()[i], medias, REF, mediaObject, "m", mediasCount);
|
661 |
3c784107
|
h.fradin
|
representation.appendChild(mediaObject);
|
662 |
|
|
}
|
663 |
|
|
}
|
664 |
|
|
}
|
665 |
|
|
|
666 |
60fed2eb
|
h.fradin
|
}
|
667 |
3c784107
|
h.fradin
|
|
668 |
|
|
|
669 |
|
|
// /**
|
670 |
|
|
// * Build Hashtables with the references for the different elements that build the dataset,
|
671 |
|
|
// * and that are then used in the different building elements methods
|
672 |
|
|
// */
|
673 |
|
|
//
|
674 |
|
|
// public void buildReferences() {
|
675 |
|
|
//
|
676 |
|
|
// // <TaxonNames> references
|
677 |
|
|
// for (int i = 0; i < cdmSource.getTaxonomicNames().size(); i++) {
|
678 |
|
|
// OriginalSource os = (OriginalSource) cdmSource.getAgents().get(i).getSources().toArray()[i];
|
679 |
|
|
// String id = os.getIdNamespace();
|
680 |
|
|
// if (id != null) {
|
681 |
|
|
// if (!id.equals("")) {
|
682 |
|
|
// if (!references.containsValue(id)) {
|
683 |
|
|
// references.put(cdmSource.getAgents().get(i), id);
|
684 |
|
|
// } else if (!references.containsValue("a" + (i+1))) {
|
685 |
|
|
// references.put(cdmSource.getAgents().get(i), "a" + (i+1));
|
686 |
|
|
// } else {
|
687 |
|
|
// references.put(cdmSource.getAgents().get(i), id + (i+1));
|
688 |
|
|
// }
|
689 |
|
|
// } else {
|
690 |
|
|
// references.put(cdmSource.getAgents().get(i), "a" + (i+1));
|
691 |
|
|
// }
|
692 |
|
|
// } else {
|
693 |
|
|
// references.put(cdmSource.getAgents().get(i), "a" + (i+1));
|
694 |
|
|
// }
|
695 |
|
|
// }
|
696 |
|
|
//
|
697 |
|
|
// // <Character> references
|
698 |
|
|
// for (int i = 0; i < cdmSource.getFeatureData().size(); i++) {
|
699 |
|
|
// references.put(cdmSource.getFeatureData().get(i), "c" + (i+1));
|
700 |
|
|
// }
|
701 |
|
|
//
|
702 |
|
|
// /* no groups so far in CDM TODO
|
703 |
|
|
// // <DescriptiveConcept> and <Node> references
|
704 |
|
|
// for (int i = 0; i < base.getNbGroups(); i++) {
|
705 |
|
|
// references.put(base.getGroupAt(i), "dc" + (i+1));
|
706 |
|
|
// }
|
707 |
|
|
// */
|
708 |
|
|
//
|
709 |
|
|
// // <State> references
|
710 |
|
|
//
|
711 |
|
|
// for (int i = 0; i < cdmSource.get(); i++) {
|
712 |
|
|
// variable = base.getVariableAt(i);
|
713 |
|
|
// for (int j = 0; j < variable.getNbModes(); j++) {
|
714 |
|
|
// references.put(variable.getModeAt(j), "s" + statesCounter);
|
715 |
|
|
// statesCounter++;
|
716 |
|
|
// }
|
717 |
|
|
// }
|
718 |
|
|
//
|
719 |
|
|
// // <CodedDescription> references
|
720 |
|
|
// for (int i = 0; i < base.getNbIndividuals(); i++) {
|
721 |
|
|
// references.put(base.getIndividualAt(i), "D" + (i+1));
|
722 |
|
|
// }
|
723 |
|
|
//
|
724 |
|
|
// // <MediaObject> references
|
725 |
|
|
// // TODO
|
726 |
|
|
// ArrayList al = base.getAllResources();
|
727 |
|
|
// for (int i = 0; i < al.size(); i++) {
|
728 |
|
|
// BaseObjectResource bor = (BaseObjectResource) al.get(i);
|
729 |
|
|
//
|
730 |
|
|
// if (!referencesMediaObjects.containsKey(bor)) {
|
731 |
|
|
// referencesMediaObjects.put(bor, "m" + mediaObjectsCounter);
|
732 |
|
|
// mediaObjectsCounter++;
|
733 |
|
|
// }
|
734 |
|
|
// }
|
735 |
|
|
//
|
736 |
|
|
// // base.images
|
737 |
|
|
// // BaseObjectResource bor = base.getResource();
|
738 |
|
|
// //bor.getName();
|
739 |
|
|
// //bor.getDescription();
|
740 |
|
|
// //bor.getFullFilename();
|
741 |
|
|
//
|
742 |
|
|
// if (!referencesMediaObjects.containsKey(bor)) {
|
743 |
|
|
// referencesMediaObjects.put(bor, "m" + mediaObjectsCounter);
|
744 |
|
|
// mediaObjectsCounter++;
|
745 |
|
|
// }
|
746 |
|
|
//
|
747 |
|
|
// // group.images
|
748 |
|
|
//
|
749 |
|
|
// for (int i = 0; i < base.getNbGroups(); i++) {
|
750 |
|
|
// Object[] tab = ((Group) base.getGroupAt(i)).getAllResources();
|
751 |
|
|
//
|
752 |
|
|
// for (int j = 0; j < tab.length; j++) {
|
753 |
|
|
// bor = (BaseObjectResource) tab[j];
|
754 |
|
|
//
|
755 |
|
|
// if (!referencesMediaObjects.containsKey(bor)) {
|
756 |
|
|
// referencesMediaObjects.put(bor, "m" + mediaObjectsCounter);
|
757 |
|
|
// mediaObjectsCounter++;
|
758 |
|
|
// }
|
759 |
|
|
// }
|
760 |
|
|
// }
|
761 |
|
|
//
|
762 |
|
|
// int nbGroups = base.getNbGroups();
|
763 |
|
|
// ArrayList mObjArrayList;
|
764 |
|
|
// if (nbGroups > 0) {
|
765 |
|
|
// for (int i = 0; i < nbGroups; i++) {
|
766 |
|
|
// mObjArrayList = ((Group) base.getGroupAt(i)).getImages();
|
767 |
|
|
// for (int j = 0; j < mObjArrayList.size(); j++) {
|
768 |
|
|
// String temp = (String) mObjArrayList.get(j);
|
769 |
|
|
// if (!referencesMediaObjects.containsKey(temp)) {
|
770 |
|
|
// referencesMediaObjects.put(temp, "m" + mediaObjectsCounter);
|
771 |
|
|
// mediaObjectsCounter++;
|
772 |
|
|
// }
|
773 |
|
|
// }
|
774 |
|
|
// }
|
775 |
|
|
// }
|
776 |
|
|
//
|
777 |
|
|
// // individual.images
|
778 |
|
|
// for (int i = 0; i < base.getNbIndividuals(); i++) {
|
779 |
|
|
// Object[] tab = ((Individual) base.getIndividualAt(i)).getAllResources();
|
780 |
|
|
//
|
781 |
|
|
// for (int j = 0; j < tab.length; j++) {
|
782 |
|
|
// bor = (BaseObjectResource) tab[j];
|
783 |
|
|
//
|
784 |
|
|
// if (!referencesMediaObjects.containsKey(bor)) {
|
785 |
|
|
// referencesMediaObjects.put(bor, "m" + mediaObjectsCounter);
|
786 |
|
|
// mediaObjectsCounter++;
|
787 |
|
|
// }
|
788 |
|
|
// }
|
789 |
|
|
// }
|
790 |
|
|
//
|
791 |
|
|
// int nbIndividuals = base.getNbIndividuals();
|
792 |
|
|
// if (nbIndividuals > 0) {
|
793 |
|
|
// for (int i = 0; i < nbIndividuals; i++) {
|
794 |
|
|
// mObjArrayList = ((Individual) base.getIndividualAt(i)).getImages();
|
795 |
|
|
// for (int j = 0; j < mObjArrayList.size(); j++) {
|
796 |
|
|
// String temp = (String) mObjArrayList.get(j);
|
797 |
|
|
// if (!referencesMediaObjects.containsKey(temp)) {
|
798 |
|
|
// referencesMediaObjects.put(temp, "m" + mediaObjectsCounter);
|
799 |
|
|
// mediaObjectsCounter++;
|
800 |
|
|
// }
|
801 |
|
|
// }
|
802 |
|
|
// }
|
803 |
|
|
// }
|
804 |
|
|
//
|
805 |
|
|
// // variable.images
|
806 |
|
|
//
|
807 |
|
|
// int nbVariables = base.getNbVariables();
|
808 |
|
|
// if (nbVariables > 0) {
|
809 |
|
|
// for (int i = 0; i < nbVariables; i++) {
|
810 |
|
|
// mObjArrayList = ((Variable) base.getVariableAt(i)).getImages();
|
811 |
|
|
// for (int j = 0; j < mObjArrayList.size(); j++) {
|
812 |
|
|
// String temp = (String) mObjArrayList.get(j);
|
813 |
|
|
// if (!referencesMediaObjects.containsKey(temp)) {
|
814 |
|
|
// referencesMediaObjects.put(temp, "m" + mediaObjectsCounter);
|
815 |
|
|
// mediaObjectsCounter++;
|
816 |
|
|
// }
|
817 |
|
|
// }
|
818 |
|
|
// }
|
819 |
|
|
// }
|
820 |
|
|
//
|
821 |
|
|
// // mode.images
|
822 |
|
|
//
|
823 |
|
|
// int nbModesTotal = base.getNbModes();
|
824 |
|
|
// int nbModes;
|
825 |
|
|
// if (nbModesTotal > 0) {
|
826 |
|
|
// for (int i = 0; i < nbVariables; i++) {
|
827 |
|
|
// variable = (Variable) base.getVariableAt(i);
|
828 |
|
|
// nbModes = variable.getNbModes();
|
829 |
|
|
// for (int j = 0; j < nbModes; j++) {
|
830 |
|
|
// mObjArrayList = variable.getModeAt(j).getImages();
|
831 |
|
|
// for (int k = 0; k < mObjArrayList.size(); k++) {
|
832 |
|
|
// String temp = (String) mObjArrayList.get(k);
|
833 |
|
|
// if (!referencesMediaObjects.containsKey(temp)) {
|
834 |
|
|
// referencesMediaObjects.put(temp, "m" + mediaObjectsCounter);
|
835 |
|
|
// mediaObjectsCounter++;
|
836 |
|
|
// }
|
837 |
|
|
// }
|
838 |
|
|
// }
|
839 |
|
|
// }
|
840 |
|
|
// }
|
841 |
|
|
//
|
842 |
|
|
// for (int i = 0; i < base.getLinks().size(); i++) {
|
843 |
|
|
// referencesLinks.put(base.getLinkAt(i), "m" + mediaObjectsCounter);
|
844 |
|
|
// mediaObjectsCounter++;
|
845 |
|
|
// }
|
846 |
|
|
//
|
847 |
|
|
// }
|
848 |
0451b182
|
h.fradin
|
|
849 |
|
|
}
|
850 |
|
|
|
851 |
60fed2eb
|
h.fradin
|
|