+ * 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