import org.joda.time.format.ISODateTimeFormat;\r
import org.xml.sax.SAXException;\r
\r
-import com.sun.org.apache.xerces.internal.impl.xpath.regex.ParseException;\r
-import com.sun.org.apache.xml.internal.serialize.DOMSerializer;\r
-import com.sun.org.apache.xml.internal.serialize.OutputFormat;\r
-import com.sun.org.apache.xml.internal.serialize.XMLSerializer;\r
+import org.apache.xerces.impl.xpath.regex.ParseException;\r
+import org.apache.xml.serialize.DOMSerializer;\r
+import org.apache.xml.serialize.OutputFormat;\r
+import org.apache.xml.serialize.XMLSerializer;\r
\r
import eu.etaxonomy.cdm.io.jaxb.CdmMarshallerListener;\r
import eu.etaxonomy.cdm.model.agent.Person;\r
import eu.etaxonomy.cdm.model.agent.Team;\r
+import eu.etaxonomy.cdm.model.agent.AgentBase;\r
import eu.etaxonomy.cdm.model.agent.TeamOrPersonBase;\r
import eu.etaxonomy.cdm.model.common.Annotation;\r
import eu.etaxonomy.cdm.model.common.AnnotationType;\r
import eu.etaxonomy.cdm.model.common.DefinedTermBase;\r
import eu.etaxonomy.cdm.model.common.IdentifiableEntity;\r
+import eu.etaxonomy.cdm.model.common.IdentifiableSource;\r
import eu.etaxonomy.cdm.model.common.Language;\r
import eu.etaxonomy.cdm.model.common.LanguageString;\r
-import eu.etaxonomy.cdm.model.common.OriginalSource;\r
import eu.etaxonomy.cdm.model.common.Representation;\r
import eu.etaxonomy.cdm.model.common.TermBase;\r
import eu.etaxonomy.cdm.model.common.TermVocabulary;\r
import eu.etaxonomy.cdm.model.common.VersionableEntity;\r
+import eu.etaxonomy.cdm.model.common.Marker;\r
+import eu.etaxonomy.cdm.model.common.MarkerType;\r
import eu.etaxonomy.cdm.model.description.CategoricalData;\r
import eu.etaxonomy.cdm.model.description.DescriptionElementBase;\r
import eu.etaxonomy.cdm.model.description.Feature;\r
+import eu.etaxonomy.cdm.model.description.FeatureNode;\r
+import eu.etaxonomy.cdm.model.description.FeatureTree;\r
import eu.etaxonomy.cdm.model.description.QuantitativeData;\r
import eu.etaxonomy.cdm.model.description.State;\r
import eu.etaxonomy.cdm.model.description.StateData;\r
import eu.etaxonomy.cdm.model.description.StatisticalMeasurementValue;\r
import eu.etaxonomy.cdm.model.description.TaxonDescription;\r
import eu.etaxonomy.cdm.model.description.TextData;\r
+import eu.etaxonomy.cdm.model.description.Modifier;\r
import eu.etaxonomy.cdm.model.media.Media;\r
+import eu.etaxonomy.cdm.model.media.MediaRepresentation;\r
+import eu.etaxonomy.cdm.model.media.IdentifiableMediaEntity;\r
+import eu.etaxonomy.cdm.model.media.MediaRepresentationPart;\r
import eu.etaxonomy.cdm.model.media.Rights;\r
import eu.etaxonomy.cdm.model.name.TaxonNameBase;\r
+import eu.etaxonomy.cdm.model.reference.IArticle;\r
import eu.etaxonomy.cdm.model.reference.Article;\r
-import eu.etaxonomy.cdm.model.reference.Database;\r
+import eu.etaxonomy.cdm.model.reference.IDatabase;\r
import eu.etaxonomy.cdm.model.reference.ReferenceBase;\r
+import eu.etaxonomy.cdm.model.reference.ReferenceFactory;\r
+import eu.etaxonomy.cdm.model.reference.ReferenceType;\r
import eu.etaxonomy.cdm.model.taxon.Taxon;\r
import eu.etaxonomy.cdm.model.taxon.TaxonBase;\r
+import eu.etaxonomy.cdm.model.taxon.TaxonNode;\r
\r
/**\r
* Writes the SDD XML file. \r
private Map<Person,String> agents = new HashMap<Person,String>();\r
private Map<TaxonNameBase,String> taxonNames = new HashMap<TaxonNameBase,String>();\r
private Map<Feature,String> characters = new HashMap<Feature,String>();\r
+ private Map<TaxonDescription,String> codedDescriptions = new HashMap<TaxonDescription,String>();\r
private Map<Media,String> medias = new HashMap<Media,String>();\r
private Map<State,String> states = new HashMap<State,String>();\r
- private Map<Article, String> articles = new HashMap<Article, String>();\r
+ private Map<ReferenceBase, String> articles = new HashMap<ReferenceBase, String>();\r
+ private Map<VersionableEntity, String> featuretrees = new HashMap<VersionableEntity, String>();\r
+ private Map<Modifier, String> modifiers = new HashMap<Modifier, String>();\r
+ private Map<TaxonNode, String> taxonNodes = new HashMap<TaxonNode,String>();\r
+ private ReferenceFactory refFactory = ReferenceFactory.newInstance();\r
+ \r
+ private Map<VersionableEntity,String> features = new HashMap<VersionableEntity,String>();\r
private int agentsCount = 0;\r
private int articlesCount = 0;\r
+ private int codedDescriptionsCount = 0;\r
private int taxonNamesCount = 0;\r
private int charactersCount = 0;\r
+ private int textcharactersCount = 0;\r
private int mediasCount = 0;\r
private int statesCount = 0;\r
+ private int featuresCount = 0;\r
+ private int chartreeCount = 0;\r
+ private int charnodeCount = 0;\r
+ private int taxonNodesCount = 0;\r
\r
private String AGENT = "Agent";\r
private String AGENTS = "Agents";\r
private String NODES = "Nodes";\r
private String NOTE = "Note";\r
private String PARENT = "Parent";\r
+ private String PUBLICATIONS = "Publications";\r
private String QUANTITATIVE = "Quantitative";\r
private String QUANTITATIVE_CHARACTER = "QuantitativeCharacter";\r
private String REF = "ref";\r
private String TAXON_NAME = "TaxonName";\r
private String TAXON_NAMES = "TaxonNames";\r
private String TECHNICAL_METADATA = "TechnicalMetadata";\r
- private String TEXT = "Text";\r
+ private String TEXT = "text";\r
private String TEXT_CHAR = "TextChar";\r
private String TEXT_CHARACTER = "TextCharacter";\r
private String TYPE = "Type";\r
try {\r
buildDocument();\r
} catch (ParseException e) {\r
- System.out.println("Problem with SDD export located in the buildDocument() method ...");\r
e.printStackTrace();\r
}\r
\r
\r
List<ReferenceBase> references = cdmSource.getReferences();\r
Iterator<ReferenceBase> iterator = references.iterator();\r
- Database d = Database.NewInstance();\r
+ IDatabase d = refFactory.newDatabase();\r
while (iterator.hasNext()) {\r
ReferenceBase reference = (ReferenceBase) iterator.next();\r
- if (reference instanceof Database) {\r
- buildDataset(baselement, (Database) reference);\r
+ if (reference.getType().equals(ReferenceType.Database)) {\r
+ buildDataset(baselement, reference);\r
}\r
}\r
\r
List<ReferenceBase> references = cdmSource.getReferences();\r
Iterator<ReferenceBase> iterator = references.iterator();\r
boolean database = false;\r
- Database d = Database.NewInstance();\r
+ IDatabase d = refFactory.newDatabase();\r
while ((iterator.hasNext()) && (!database)) {\r
ReferenceBase reference = (ReferenceBase) iterator.next();\r
- if (reference instanceof Database) {\r
- d = (Database) reference;\r
+ if (reference.getType().equals(ReferenceType.Database)) {\r
+ d = reference;\r
}\r
}\r
DateTime dt = d.getCreated();\r
}\r
\r
// Builds the information associated with a dataset\r
- public void buildDataset(ElementImpl baselement, Database reference) throws ParseException {\r
+ public void buildDataset(ElementImpl baselement,IDatabase reference) throws ParseException {\r
// create Dataset and language\r
ElementImpl dataset = new ElementImpl(document, DATASET);\r
// no default language associated with a dataset in the CDM\r
buildRevisionData(dataset, reference);\r
buildIPRStatements(dataset, reference);\r
buildTaxonNames(dataset);\r
+ buildDescriptiveConcepts(dataset);\r
buildCharacters(dataset);\r
buildCodedDescriptions(dataset);\r
-\r
+ buildAgents(dataset);\r
+ buildPublications(dataset);\r
+ buildMediaObjects(dataset);\r
+ buildCharacterTrees(dataset);\r
+ buildTaxonomicTrees(dataset);\r
}\r
\r
/**\r
* Builds a Representation element using a ReferenceBase\r
*/\r
- public void buildRepresentation(ElementImpl element, ReferenceBase reference) throws ParseException {\r
+ public void buildRepresentation(ElementImpl element, IDatabase reference) throws ParseException {\r
\r
// create <Representation> element\r
ElementImpl representation = new ElementImpl(document, REPRESENTATION);\r
element.appendChild(representation);\r
buildLabel(representation, reference.getTitleCache());\r
\r
- Set<Annotation> annotations = reference.getAnnotations();\r
+ Set<Annotation> annotations = ((ReferenceBase)reference).getAnnotations();\r
Iterator iterator = annotations.iterator();\r
String detailText = null;\r
if (iterator.hasNext()) {\r
representation.appendChild(detail);\r
}\r
\r
- Set<Media> rm = reference.getMedia();\r
+ Set<Media> rm = ((ReferenceBase)reference).getMedia();\r
\r
if (rm != null && rm.size() > 0) {\r
ElementImpl mediaObject;\r
}\r
\r
}\r
+ \r
+ \r
+ /**\r
+ * Builds a Representation element using a Feature\r
+ */\r
+ public void buildRepresentation(ElementImpl element, TermBase tb) throws ParseException {\r
+\r
+ // create <Representation> element\r
+ ElementImpl representation = new ElementImpl(document, REPRESENTATION);\r
+ element.appendChild(representation);\r
+\r
+ Set<Representation> representations = tb.getRepresentations();\r
+ if (representations != null) {\r
+ if (!representations.isEmpty()) {\r
+ String label = ((Representation) representations.toArray()[0]).getLabel();\r
+ buildLabel(representation, label);\r
+ String detailText = tb.getDescription();\r
+\r
+ if (detailText != null && !detailText.equals("")) {\r
+ if (!detailText.equals(label)) {\r
+ ElementImpl detail = new ElementImpl(document, DETAIL);\r
+ detail.appendChild(document.createTextNode(detailText));\r
+ representation.appendChild(detail);\r
+ }\r
+ }\r
+\r
+ }\r
+ } \r
+\r
+ if (tb instanceof DefinedTermBase) {\r
+ DefinedTermBase dtb = (DefinedTermBase) tb;\r
+ Set<Media> rm = dtb.getMedia();\r
+\r
+ if (rm != null && rm.size() > 0) {\r
+ ElementImpl mediaObject;\r
+\r
+ for (int i = 0; i < rm.size(); i++) {\r
+ mediaObject = new ElementImpl(document, MEDIA_OBJECT);\r
+ mediasCount = buildReference((Media) rm.toArray()[i], medias, REF, mediaObject, "m", mediasCount);\r
+ representation.appendChild(mediaObject);\r
+ }\r
+ }\r
+ }\r
+ }\r
+ \r
+ /**\r
+ * Builds a Representation element using an IdentifiableEntity \r
+ */\r
+ public void buildRepresentation(ElementImpl element, IdentifiableEntity ie) throws ParseException {\r
+\r
+ // create <Representation> element\r
+ ElementImpl representation = new ElementImpl(document, REPRESENTATION);\r
+ element.appendChild(representation);\r
+ buildLabel(representation, ie.getTitleCache());\r
+\r
+ Set<Annotation> annotations = ie.getAnnotations();\r
+ Iterator iterator = annotations.iterator();\r
+ String detailText = null;\r
+ if (iterator.hasNext()) {\r
+ Annotation annotation = (Annotation) iterator.next();\r
+ detailText = annotation.getText();\r
+ }\r
+\r
+ if (detailText != null && !detailText.equals("")) {\r
+ ElementImpl detail = new ElementImpl(document, DETAIL);\r
+ detail.appendChild(document.createTextNode(detailText));\r
+ representation.appendChild(detail);\r
+ }\r
+ \r
+ if (ie instanceof DefinedTermBase) {\r
+ DefinedTermBase dtb = (DefinedTermBase) ie;\r
+ Set<Media> rm = dtb.getMedia();\r
+\r
+ if (rm != null && rm.size() > 0) {\r
+ ElementImpl mediaObject;\r
+\r
+ for (int i = 0; i < rm.size(); i++) {\r
+ mediaObject = new ElementImpl(document, MEDIA_OBJECT);\r
+ mediasCount = buildReference((Media) rm.toArray()[i], medias, REF, mediaObject, "m", mediasCount);\r
+ representation.appendChild(mediaObject);\r
+ }\r
+ }\r
+ }\r
+ //XIM\r
+ if (ie instanceof IdentifiableMediaEntity) {\r
+ IdentifiableMediaEntity ime = (IdentifiableMediaEntity) ie;\r
+ Set<Media> medias = ime.getMedia();\r
+ if (medias != null){\r
+ ElementImpl elLinks = new ElementImpl(document, "Links");\r
+ for (Iterator<Media> m = medias.iterator() ; m.hasNext() ;){\r
+ Media media = m.next();\r
+ Set<MediaRepresentation> smr = media.getRepresentations();\r
+ for (Iterator<MediaRepresentation> mr = smr.iterator() ; mr.hasNext();){\r
+ MediaRepresentation mediarep = mr.next();\r
+ List<MediaRepresentationPart> lmrp = mediarep.getParts();\r
+ for (Iterator<MediaRepresentationPart> mrp = lmrp.iterator();mrp.hasNext();){\r
+ MediaRepresentationPart mediareppart = mrp.next();\r
+ ElementImpl elLink = new ElementImpl(document, "Link");\r
+ elLink.setAttribute("href",mediareppart.getUri());\r
+ elLinks.appendChild(elLink);\r
+ }\r
+ }\r
+ }\r
+ element.appendChild(elLinks);\r
+ }\r
+ }\r
+\r
+ }\r
\r
// ################\r
// # GENERIC BRICKS #\r
ElementImpl elTaxonName = new ElementImpl(document, TAXON_NAME);\r
TaxonNameBase tnb = cdmSource.getTaxonomicNames().get(i);\r
\r
- taxonNamesCount = buildReference(tnb, taxonNames, REF, elTaxonName, "t", taxonNamesCount);\r
+ taxonNamesCount = buildReference(tnb, taxonNames, ID, elTaxonName, "t", taxonNamesCount);\r
+ //elTaxonName.setAttribute(URI,"http://www.google.com");\r
\r
buildRepresentation(elTaxonName, tnb);\r
\r
if (ag instanceof Person) {\r
Person p = (Person) ag;\r
ElementImpl agent = new ElementImpl(document, AGENT);\r
- agent.setAttribute(ROLE, role);\r
+ if (ag.getMarkers()!= null){\r
+ Set<Marker> markers = ag.getMarkers();\r
+ for(Iterator<Marker> m = markers.iterator() ; m.hasNext();){\r
+ Marker marker = m.next();\r
+ if (marker.getMarkerType().getLabel() == "editor"){\r
+ agent.setAttribute(ROLE, "edt");\r
+ }\r
+ }\r
+ }\r
+ else {\r
+ agent.setAttribute(ROLE, role);\r
+ }\r
agentsCount = buildReference(p, agents, REF, agent, "a", agentsCount);\r
element.appendChild(agent);\r
}\r
if (ag instanceof Team) {\r
Team team = (Team) ag;\r
for (int i = 0; i < team.getTeamMembers().size(); i++) {\r
- ElementImpl agent = new ElementImpl(document, AGENT);\r
- agent.setAttribute(ROLE, role);\r
Person author = team.getTeamMembers().get(i);\r
+ ElementImpl agent = new ElementImpl(document, AGENT);\r
+ if (author.getMarkers()!= null){\r
+ Set<Marker> markers = author.getMarkers();\r
+ if (!markers.isEmpty()){\r
+ for(Iterator<Marker> m = markers.iterator() ; m.hasNext();){\r
+ Marker marker = m.next();\r
+ if (marker.getMarkerType().getLabel().equals("editor")){\r
+ agent.setAttribute(ROLE, "edt");\r
+ }\r
+ }\r
+ }\r
+ else {\r
+ agent.setAttribute(ROLE, role);\r
+ }\r
+ }\r
+ else {\r
+ agent.setAttribute(ROLE, role);\r
+ }\r
if (author.getSources() != null) {\r
- OriginalSource os = (OriginalSource) author.getSources().toArray()[0];\r
+ IdentifiableSource os = (IdentifiableSource) author.getSources().toArray()[0];\r
String id = os.getIdInSource();\r
if (id != null) {\r
if (!id.equals("")) {\r
/**\r
* Builds ModifiedDate associated with RevisionData\r
*/\r
- public void buildDateModified(ElementImpl revisionData, Database database) throws ParseException {\r
+ public void buildDateModified(ElementImpl revisionData, IDatabase database) throws ParseException {\r
\r
// <DateModified>2006-04-08T00:00:00</DateModified>\r
\r
- if (database.getUpdated() != null) {\r
+ if (((ReferenceBase)database).getUpdated() != null) {\r
ElementImpl dateModified = new ElementImpl(document, DATE_MODIFIED);\r
\r
- DateTime c = database.getUpdated();\r
+ DateTime c = ((ReferenceBase)database).getUpdated();\r
DateTimeFormatter fmt = ISODateTimeFormat.dateTime();\r
\r
String date = fmt.print(c);\r
/**\r
* Builds IPRStatements associated with the Dataset\r
*/\r
- public void buildIPRStatements(ElementImpl dataset, Database database) throws ParseException {\r
+ public void buildIPRStatements(ElementImpl dataset, IDatabase database) throws ParseException {\r
\r
// <IPRStatements>\r
// <IPRStatement role="Copyright">\r
// </IPRStatements>\r
\r
if (database.getRights() != null) {\r
- // create IPRStatements\r
+ //create IPRStatements\r
ElementImpl iprStatements = new ElementImpl(document, IPR_STATEMENTS);\r
dataset.appendChild(iprStatements);\r
\r
ElementImpl iprStatement = new ElementImpl(document, IPR_STATEMENT);\r
iprStatement.setAttribute("role", "Copyright");\r
iprStatements.appendChild(iprStatement);\r
- buildLabel(iprStatement, ((Rights) database.getRights().toArray()[0]).getText());\r
+ Set<Rights> rish = database.getRights();\r
+ if (!database.getRights().isEmpty()) {\r
+ buildLabel(iprStatement, ((Rights) database.getRights().toArray()[0]).getText());\r
+ }\r
}\r
\r
}\r
/**\r
* Builds RevisionData associated with the Dataset\r
*/\r
- public void buildRevisionData(ElementImpl dataset, Database database) throws ParseException {\r
+ public void buildRevisionData(ElementImpl dataset, IDatabase database) throws ParseException {\r
\r
// <RevisionData>\r
// <Creators>\r
\r
// authors\r
TeamOrPersonBase authors = database.getAuthorTeam();\r
- // TeamOrPersonBase editors = database.getUpdatedBy();\r
+ //TeamOrPersonBase editors = database.getUpdatedBy();\r
\r
if ((authors != null)) { // || (editors != null)) {\r
ElementImpl creators = new ElementImpl(document, CREATORS);\r
if (authors != null) {\r
buildRefAgent(creators, authors, "aut");\r
}\r
- // if (editors != null) {\r
- // buildRefAgent(creators, editors, "edt");\r
- // }\r
+// if (editors != null) {\r
+// buildRefAgent(creators, editors, "edt");\r
+// }\r
revisionData.appendChild(creators);\r
}\r
\r
dataset.appendChild(revisionData);\r
}\r
\r
- /**\r
- * Builds a Representation element using an IdentifiableEntity \r
- */\r
- public void buildRepresentation(ElementImpl element, IdentifiableEntity ie) throws ParseException {\r
\r
- // create <Representation> element\r
- ElementImpl representation = new ElementImpl(document, REPRESENTATION);\r
- element.appendChild(representation);\r
- buildLabel(representation, ie.getTitleCache());\r
\r
- Set<Annotation> annotations = ie.getAnnotations();\r
- Iterator iterator = annotations.iterator();\r
- String detailText = null;\r
- if (iterator.hasNext()) {\r
- Annotation annotation = (Annotation) iterator.next();\r
- detailText = annotation.getText();\r
- }\r
\r
- if (detailText != null && !detailText.equals("")) {\r
- ElementImpl detail = new ElementImpl(document, DETAIL);\r
- detail.appendChild(document.createTextNode(detailText));\r
- representation.appendChild(detail);\r
- }\r
-\r
- }\r
\r
/**\r
* Builds Characters associated with the Dataset\r
for (int i = 0; i < f; i++) {\r
if (cdmSource.getTerms().get(i) instanceof Feature) {\r
Feature character = (Feature) cdmSource.getTerms().get(i);\r
- if (character.supportsQuantitativeData()) {\r
+ if (character.isSupportsQuantitativeData()) {\r
ElementImpl elQuantitativeCharacter = new ElementImpl(document, QUANTITATIVE_CHARACTER);\r
charactersCount = buildReference(character, characters, ID, elQuantitativeCharacter, "c", charactersCount);\r
// TODO if the character also supports text, add to the label a short tag to distinguish\r
elCharacters.appendChild(elQuantitativeCharacter);\r
}\r
\r
- if (character.supportsCategoricalData()) {\r
+ if (character.isSupportsCategoricalData()) {\r
ElementImpl elCategoricalCharacter = new ElementImpl(document, CATEGORICAL_CHARACTER);\r
charactersCount = buildReference(character, characters, ID, elCategoricalCharacter, "c", charactersCount);\r
buildRepresentation(elCategoricalCharacter, character);\r
}\r
}\r
}\r
- if (character.supportsTextData()) {\r
+ if (character.isSupportsTextData()) {\r
ElementImpl elTextCharacter = new ElementImpl(document, TEXT_CHARACTER);\r
- charactersCount = buildReference(character, characters, ID, elTextCharacter, "c", charactersCount);\r
+ textcharactersCount = buildReference(character, characters, ID, elTextCharacter, TEXT, textcharactersCount);\r
buildRepresentation(elTextCharacter, character);\r
// TODO <MeasurementUnit> and <Default>\r
elCharacters.appendChild(elTextCharacter);\r
}\r
\r
}\r
+ \r
+ \r
+ /**\r
+ * Builds Agents associated with the Dataset\r
+ */\r
+ public void buildAgents(ElementImpl dataset) throws ParseException {\r
+\r
+ if (cdmSource.getAgents() != null) {\r
+ ElementImpl elAgents = new ElementImpl(document, AGENTS);\r
+\r
+ for (int i = 0; i < cdmSource.getAgents().size(); i++) {\r
+ ElementImpl elAgent = new ElementImpl(document, AGENT);\r
+ AgentBase personagent = (AgentBase)cdmSource.getAgents().get(i);\r
+ if (personagent instanceof Person){\r
+ if (personagent.getMarkers()!= null){\r
+ Set<Marker> markers = personagent.getMarkers();\r
+ for(Iterator<Marker> m = markers.iterator() ; m.hasNext();){\r
+ Marker marker = m.next();\r
+ if (marker.getMarkerType().getLabel() == "editor"){\r
+ agentsCount = buildReference(personagent, agents, ID, elAgent, "a", agentsCount);\r
+ }\r
+ }\r
+ }\r
+ agentsCount = buildReference(personagent, agents, ID, elAgent, "a", agentsCount);\r
+ //elTaxonName.setAttribute(URI,"http://www.google.com");\r
+\r
+ buildRepresentation(elAgent, personagent);\r
+ /*XIMSet<Media> medias = personagent.getMedia();\r
+ if (medias != null){\r
+ ElementImpl elLinks = new ElementImpl(document, "Links");\r
+ for (Iterator<Media> m = medias.iterator() ; m.hasNext() ;){\r
+ Media media = m.next();\r
+ Set<MediaRepresentation> smr = media.getRepresentations();\r
+ for (Iterator<MediaRepresentation> mr = smr.iterator() ; mr.hasNext();){\r
+ MediaRepresentation mediarep = mr.next();\r
+ List<MediaRepresentationPart> lmrp = mediarep.getParts();\r
+ for (Iterator<MediaRepresentationPart> mrp = lmrp.iterator();mrp.hasNext();){\r
+ MediaRepresentationPart mediareppart = mrp.next();\r
+ ElementImpl elLink = new ElementImpl(document, "Link");\r
+ elLink.setAttribute("href",mediareppart.getUri());\r
+ elLinks.appendChild(elLink);\r
+ }\r
+ }\r
+ }\r
+ elAgent.appendChild(elLinks);\r
+ }*/\r
+\r
+ elAgents.appendChild(elAgent);\r
+ }\r
+ }\r
\r
+ dataset.appendChild(elAgents);\r
+ }\r
+ }\r
+ \r
/**\r
- * Builds an element Agent referring to Agent defined later in the SDD file\r
+ * XIM Pas trait\8e si ne d\8epend pas d'un arbre ; Builds CharacterTrees associated with the Dataset\r
+ */\r
+ public void buildCharacterTrees(ElementImpl dataset) throws ParseException {\r
+\r
+ if (cdmSource.getFeatureData() != null) {\r
+ ElementImpl elChartrees = new ElementImpl(document, CHARACTER_TREES);\r
+\r
+ for (int i = 0; i < cdmSource.getFeatureData().size(); i++) {\r
+ VersionableEntity featu = cdmSource.getFeatureData().get(i);\r
+ if (featu instanceof FeatureTree){\r
+ FeatureTree ft = (FeatureTree) featu;\r
+ ElementImpl elChartree = new ElementImpl(document, CHARACTER_TREE);\r
+ chartreeCount = buildReference(featu, featuretrees, ID, elChartree, "ct", chartreeCount);\r
+ elChartrees.appendChild(elChartree);\r
+ ElementImpl elNodes = new ElementImpl(document, NODES);\r
+ elChartree.appendChild(elNodes);\r
+ List<FeatureNode> children = ft.getRootChildren();\r
+ buildBranches(children,ft.getRoot(),elNodes); \r
+ }\r
+ }\r
+ dataset.appendChild(elChartrees);\r
+ }\r
+ }\r
+ \r
+ public void buildTaxonomicTrees(ElementImpl dataset) throws ParseException {\r
+\r
+ if (cdmSource.getTaxa() != null) {\r
+ ElementImpl elTaxonHierarchies = new ElementImpl(document, "TaxonHierarchies");\r
+ ElementImpl elTaxonHierarchy = new ElementImpl(document, "TaxonHierarchy");\r
+ for (Iterator<? extends TaxonBase> tb = cdmSource.getTaxa().iterator() ; tb.hasNext() ;){\r
+ Taxon taxon = (Taxon) tb.next();\r
+ if (taxon.getTaxonNodes()!=null){\r
+ for (Iterator<TaxonNode> tn = taxon.getTaxonNodes().iterator() ; tn.hasNext() ;){\r
+ TaxonNode taxonnode = tn.next();\r
+ if (taxonnode.isTopmostNode()) {\r
+ ElementImpl elNode = new ElementImpl(document, "Node");\r
+ taxonNodesCount = buildReference(taxonnode, taxonNodes, ID, elNode, "tn", taxonNodesCount);\r
+ ElementImpl elTaxonName = new ElementImpl(document, TAXON_NAME);\r
+ taxonNamesCount = buildReference(taxonnode.getTaxon().getName(), taxonNames, REF, elTaxonName, "t", taxonNamesCount);\r
+ elNode.appendChild(elTaxonName);\r
+ elTaxonHierarchy.appendChild(elNode);\r
+ if (taxonnode.hasChildNodes()){\r
+ buildTaxonBranches(taxonnode.getChildNodes(),taxonnode, elTaxonHierarchy);\r
+ }\r
+ }\r
+ }\r
+ }\r
+ }\r
+ elTaxonHierarchies.appendChild(elTaxonHierarchy);\r
+ dataset.appendChild(elTaxonHierarchies);\r
+ }\r
+ }\r
+\r
+ private void buildTaxonBranches(Set<TaxonNode> children, TaxonNode parent, ElementImpl elTaxonHierarchy){\r
+ if (children != null){\r
+ for (Iterator<TaxonNode> tn = children.iterator() ; tn.hasNext();){\r
+ TaxonNode taxonnode = tn.next();\r
+ ElementImpl elNode = new ElementImpl(document, "Node");\r
+ ElementImpl elParent = new ElementImpl(document, PARENT);\r
+ ElementImpl elTaxonName = new ElementImpl(document, TAXON_NAME);\r
+ if (taxonnode.hasChildNodes()){\r
+ buildTaxonBranches(taxonnode.getChildNodes(),taxonnode, elTaxonHierarchy);\r
+ }\r
+ taxonNodesCount = buildReference(taxonnode, taxonNodes, ID, elNode, "tn", taxonNodesCount);\r
+ taxonNodesCount = buildReference(parent, taxonNodes, REF, elParent, "tn", taxonNodesCount);\r
+ taxonNamesCount = buildReference(taxonnode.getTaxon().getName(), taxonNames, REF, elTaxonName, "t", taxonNamesCount);\r
+ elNode.appendChild(elParent);\r
+ elNode.appendChild(elTaxonName);\r
+ elTaxonHierarchy.appendChild(elNode);\r
+ }\r
+ }\r
+ }\r
+ \r
+ public void buildBranches(List<FeatureNode> children, FeatureNode parent, ElementImpl element) {\r
+ if (!parent.isLeaf()){\r
+ ElementImpl elCharNode = new ElementImpl(document, NODE);\r
+ charnodeCount = buildReference(parent, featuretrees, ID, elCharNode, "cn", charnodeCount);\r
+ FeatureNode grandparent = parent.getParent();\r
+ if (grandparent !=null) {\r
+ ElementImpl elParent = new ElementImpl(document, PARENT);\r
+ charnodeCount = buildReference(grandparent, featuretrees, REF, elParent, "cn", charnodeCount);\r
+ }\r
+ ElementImpl elDescriptiveConcept = new ElementImpl(document, DESCRIPTIVE_CONCEPT);\r
+ Feature fref = parent.getFeature();\r
+ featuresCount = buildReference(fref, characters, REF, elDescriptiveConcept, "dc", featuresCount);\r
+ elCharNode.appendChild(elDescriptiveConcept);\r
+ element.appendChild(elCharNode);\r
+ for (Iterator<FeatureNode> ifn = children.iterator() ; ifn.hasNext() ;){\r
+ FeatureNode fn = ifn.next();\r
+ buildBranches(fn.getChildren(),fn,element);\r
+ }\r
+ }\r
+ else {\r
+ ElementImpl elCharNode = new ElementImpl(document, CHAR_NODE);\r
+ ElementImpl elParent = new ElementImpl(document, PARENT);\r
+ charnodeCount = buildReference(parent, featuretrees, REF, elParent, "cn", charnodeCount);\r
+ ElementImpl elCharacter = new ElementImpl(document, CHARACTER);\r
+ Feature fref = parent.getFeature();\r
+ charactersCount = buildReference(fref, characters, REF, elCharacter, "c", charactersCount);\r
+ elCharNode.appendChild(elCharacter);\r
+ elCharNode.appendChild(elParent);\r
+ element.appendChild(elCharNode);\r
+ }\r
+ }\r
+ \r
+ /**\r
+ * XIMBuilds DescriptiveConcepts associated with the Dataset\r
+ */\r
+ public void buildDescriptiveConcepts(ElementImpl dataset) throws ParseException {\r
+\r
+ if (cdmSource.getFeatureData() != null) {\r
+ ElementImpl elFeatures = new ElementImpl(document, DESCRIPTIVE_CONCEPTS);\r
+ \r
+ for (int i = 0; i < cdmSource.getFeatureData().size(); i++) {\r
+ ElementImpl elFeat = new ElementImpl(document, DESCRIPTIVE_CONCEPT);\r
+ VersionableEntity featu = cdmSource.getFeatureData().get(i);\r
+ if (featu instanceof FeatureNode)\r
+ {\r
+ FeatureNode fitou = (FeatureNode) featu;\r
+ if (!fitou.isLeaf() && fitou.getChildCount() > 0){\r
+ featuresCount = buildReference(featu, characters, ID, elFeat, "dc", featuresCount);\r
+ //elTaxonName.setAttribute(URI,"http://www.google.com");\r
+ Feature fitounette = fitou.getFeature();\r
+ if (fitounette != null){\r
+ buildRepresentation(elFeat, fitounette);\r
+ Set<TermVocabulary<Modifier>> stm = null;\r
+ stm = fitounette.getRecommendedModifierEnumeration();\r
+ if (stm != null){\r
+ for (Iterator<TermVocabulary<Modifier>> m = stm.iterator() ; m.hasNext() ;){\r
+ TermVocabulary<Modifier> tv = m.next();\r
+ Set<Modifier> setmod = tv.getTerms();\r
+ for (Iterator<Modifier> mm = setmod.iterator() ; mm.hasNext();){\r
+ Modifier modi = mm.next();\r
+ ElementImpl elModi = new ElementImpl(document,"modifier");\r
+ featuresCount = buildReference(modi, modifiers, ID, elModi, "mod", featuresCount);\r
+ elFeat.appendChild(elModi);\r
+ }\r
+ }\r
+ }\r
+ } \r
+ elFeatures.appendChild(elFeat);\r
+ }\r
+ }\r
+ }\r
+\r
+ dataset.appendChild(elFeatures);\r
+ }\r
+ }\r
+ \r
+ \r
+ \r
+ /**\r
+ * XIMBuilds MediaObjects associated with the Dataset\r
+ */\r
+ public void buildMediaObjects(ElementImpl dataset) throws ParseException {\r
+\r
+ // <TaxonNames>\r
+ // <TaxonName id="t1" uri="urn:lsid:authority:namespace:my-own-id">\r
+ // <Representation>\r
+ // <Label xml:lang="la">Viola hederacea Labill.</Label>\r
+ // </Representation>\r
+ // </TaxonName>\r
+ // </TaxonNames>\r
+\r
+ if (cdmSource.getMedia() != null) {\r
+ ElementImpl elMediaObjects = new ElementImpl(document, MEDIA_OBJECTS);\r
+\r
+ for (int i = 0; i < cdmSource.getMedia().size(); i++) {\r
+ ElementImpl elMediaObject = new ElementImpl(document, MEDIA_OBJECT);\r
+ Media mediobj = (Media) cdmSource.getMedia().get(i);\r
+\r
+ mediasCount = buildReference(mediobj, medias, ID, elMediaObject, "t", mediasCount);\r
+ //elTaxonName.setAttribute(URI,"http://www.google.com");\r
+\r
+ buildRepresentation(elMediaObject, mediobj);\r
+ Set<MediaRepresentation> smr = mediobj.getRepresentations();\r
+ for (Iterator<MediaRepresentation> mr = smr.iterator() ; mr.hasNext();){\r
+ MediaRepresentation mediarep = mr.next();\r
+ ElementImpl elType = new ElementImpl(document, "Type");\r
+ elType.appendChild(document.createTextNode(mediarep.getMimeType()));\r
+ elMediaObject.appendChild(elType);\r
+ List<MediaRepresentationPart> lmrp = mediarep.getParts();\r
+ for (Iterator<MediaRepresentationPart> mrp = lmrp.iterator();mrp.hasNext();){\r
+ MediaRepresentationPart mediareppart = mrp.next();\r
+ ElementImpl elSource = new ElementImpl(document, "Source");\r
+ elSource.setAttribute("href",mediareppart.getUri());\r
+ elMediaObject.appendChild(elSource);\r
+ }\r
+ }\r
+\r
+ elMediaObjects.appendChild(elMediaObject);\r
+ }\r
+\r
+ dataset.appendChild(elMediaObjects);\r
+ }\r
+\r
+ }\r
+ \r
+ /**\r
+ * Builds Publications associated with the Dataset\r
+ */\r
+ public void buildPublications(ElementImpl dataset) throws ParseException {\r
+\r
+ if (cdmSource.getReferences() != null) {\r
+ ElementImpl elPublications = new ElementImpl(document, PUBLICATIONS);\r
+ boolean editorial = false;\r
+ for (int i = 0; i < cdmSource.getReferences().size(); i++) {\r
+ ElementImpl elPublication = new ElementImpl(document, "Publication");\r
+ ReferenceBase publication = cdmSource.getReferences().get(i);\r
+ //if (publication instanceof Article){\r
+ Set<Annotation> annotations = publication.getAnnotations();\r
+ for (Iterator<Annotation> a = annotations.iterator() ; a.hasNext() ;){\r
+ Annotation annotation = a.next();\r
+ AnnotationType annotationType = annotation.getAnnotationType();\r
+ if (annotationType == AnnotationType.EDITORIAL()) {\r
+ editorial = true;\r
+ }\r
+ else {\r
+ editorial = false;\r
+ }\r
+ }\r
+ if (!editorial){\r
+ articlesCount = buildReference(publication, articles, ID, elPublication, "p", articlesCount);\r
+ buildRepresentation(elPublication, (IDatabase) publication);//XIM\r
+ elPublications.appendChild(elPublication);\r
+ }\r
+ \r
+ //}\r
+ }\r
+ dataset.appendChild(elPublications);\r
+ }\r
+ }\r
+\r
+ \r
+ \r
+ /**\r
+ * Builds a Reference\r
*/\r
public int buildReference(VersionableEntity ve, Map references, String refOrId, ElementImpl element, String prefix, int count) throws ParseException {\r
if (references.containsKey(ve)) {\r
if (ve instanceof IdentifiableEntity) {\r
IdentifiableEntity ie = (IdentifiableEntity) ve;\r
if (ie.getSources().size() > 0) {\r
- OriginalSource os = (OriginalSource) ie.getSources().toArray()[0];\r
+ IdentifiableSource os = (IdentifiableSource) ie.getSources().toArray()[0];\r
String id = os.getIdInSource();\r
+ String uri = os.getCitationMicroReference();\r
+ if (uri != null) {element.setAttribute(URI, uri);}\r
if (id != null) {\r
if (!id.equals("")) {\r
if (!references.containsValue(id)) {\r
return count;\r
}\r
\r
- /**\r
- * Builds a Representation element using a Feature\r
- */\r
- public void buildRepresentation(ElementImpl element, TermBase tb) throws ParseException {\r
-\r
- // create <Representation> element\r
- ElementImpl representation = new ElementImpl(document, REPRESENTATION);\r
- element.appendChild(representation);\r
-\r
- Set<Representation> representations = tb.getRepresentations();\r
- if (representations != null) {\r
- if (!representations.isEmpty()) {\r
- String label = ((Representation) representations.toArray()[0]).getLabel();\r
- buildLabel(representation, label);\r
- String detailText = tb.getDescription();\r
-\r
- if (detailText != null && !detailText.equals("")) {\r
- if (!detailText.equals(label)) {\r
- ElementImpl detail = new ElementImpl(document, DETAIL);\r
- detail.appendChild(document.createTextNode(detailText));\r
- representation.appendChild(detail);\r
- }\r
- }\r
-\r
- }\r
- } \r
-\r
- if (tb instanceof DefinedTermBase) {\r
- DefinedTermBase dtb = (DefinedTermBase) tb;\r
- Set<Media> rm = dtb.getMedia();\r
-\r
- if (rm != null && rm.size() > 0) {\r
- ElementImpl mediaObject;\r
-\r
- for (int i = 0; i < rm.size(); i++) {\r
- mediaObject = new ElementImpl(document, MEDIA_OBJECT);\r
- mediasCount = buildReference((Media) rm.toArray()[i], medias, REF, mediaObject, "m", mediasCount);\r
- representation.appendChild(mediaObject);\r
- }\r
- }\r
- }\r
-\r
- }\r
\r
// /**\r
// * Builds Coded Descriptions associated with the Dataset\r
\r
for (Iterator<? extends TaxonBase> tb = cdmSource.getTaxa().iterator() ; tb.hasNext() ;){\r
Taxon taxon = (Taxon) tb.next();\r
+ if (taxon.getTaxonNodes()!=null){\r
+ for (Iterator<TaxonNode> tn = taxon.getTaxonNodes().iterator() ; tn.hasNext() ;){\r
+ TaxonNode taxonnode = tn.next();\r
+ }\r
+ }\r
Set<TaxonDescription> descriptions = taxon.getDescriptions();\r
for (Iterator<TaxonDescription> td = descriptions.iterator() ; td.hasNext() ;){\r
TaxonDescription taxonDescription = td.next();\r
ElementImpl elCodedDescription = new ElementImpl(document, CODED_DESCRIPTION);\r
+ codedDescriptionsCount = buildReference(taxonDescription, codedDescriptions, ID, elCodedDescription, "D", codedDescriptionsCount);\r
buildRepresentation(elCodedDescription, taxonDescription);\r
buildScope(elCodedDescription, taxonDescription);\r
buildSummaryData(elCodedDescription, taxonDescription);\r
Set<ReferenceBase> descriptionSources = taxonDescription.getDescriptionSources();\r
for (Iterator<ReferenceBase> rb = descriptionSources.iterator() ; rb.hasNext() ;){\r
ReferenceBase descriptionSource = rb.next();\r
- if (descriptionSource instanceof Article) {\r
- Article article = (Article) descriptionSource;\r
+ if (descriptionSource.getType().equals(ReferenceType.Article)) {\r
+ \r
ElementImpl citation = new ElementImpl(document, CITATION);\r
- articlesCount = buildReference(article, articles, REF, citation, "p", articlesCount);\r
+ articlesCount = buildReference(descriptionSource, articles, REF, citation, "p", articlesCount);\r
\r
- Set<Annotation> annotations = article.getAnnotations();\r
+ Set<Annotation> annotations = descriptionSource.getAnnotations();\r
for (Iterator<Annotation> a = annotations.iterator() ; a.hasNext() ;){\r
Annotation annotation = a.next();\r
AnnotationType annotationType = annotation.getAnnotationType();\r
element.appendChild(content);\r
}\r
\r
-\r
// /**\r
// * Build Hashtables with the references for the different elements that build the dataset, \r
// * and that are then used in the different building elements methods\r
// }\r
//\r
// }\r
-\r
-}\r
-\r
-\r
+ \r
+}
\ No newline at end of file