+ // if (rb!=null) {\r
+ // if (k == 0) {\r
+ rb.addMedia(media);\r
+ //System.out.println(rb.getTitle());\r
+ // } else {\r
+ // Media me = (Media) media.clone();\r
+ // rb.addMedia(me);\r
+ // }\r
+ // }\r
+ }/* else if (lcb.get(k) instanceof TaxonNameBase){\r
+ TaxonNameBase tb = (TaxonNameBase) lcb.get(k);\r
+ tb.addMedia(media);\r
+ }*/\r
+ }\r
+ }\r
+ }\r
+\r
+ } catch (Exception e) {\r
+ //FIXME\r
+ logger.warn("Could not attach MediaObject " + j + "(SDD: " + id + ") to several objects.");\r
+ success = false; \r
+ }\r
+\r
+ if ((++j % modCount) == 0){ logger.info("MediaObjects handled: " + j);\r
+\r
+ }\r
+ }\r
+ }\r
+ }\r
+\r
+ // imports the <DescriptiveConcepts> block\r
+ protected void importDescriptiveConcepts(Element elDataset, Namespace sddNamespace, SDDImportConfigurator sddConfig){\r
+ // <DescriptiveConcepts>\r
+ logger.info("start DescriptiveConcepts ...");\r
+ Element elDescriptiveConcepts = elDataset.getChild("DescriptiveConcepts",sddNamespace);\r
+ // <DescriptiveConcept id="b">\r
+ if (elDescriptiveConcepts != null) {\r
+ List<Element> listDescriptiveConcepts = elDescriptiveConcepts.getChildren("DescriptiveConcept", sddNamespace);\r
+ int j = 0;\r
+ //for each DescriptiveConcept\r
+ int g = 1;\r
+\r
+ for (Element elDescriptiveConcept : listDescriptiveConcepts){\r
+\r
+ String id = elDescriptiveConcept.getAttributeValue("id");\r
+ String uri = elDescriptiveConcept.getAttributeValue("uri");\r
+\r
+ FeatureNode fn = null;\r
+\r
+ if (!id.equals("")) {\r
+ fn = FeatureNode.NewInstance();\r
+ Feature feature = Feature.NewInstance();\r
+ feature.setKindOf(Feature.DESCRIPTION());\r
+ // <Representation>\r
+ // <Label>Body</Label>\r
+ importRepresentation(elDescriptiveConcept, sddNamespace, feature, id, sddConfig);\r
+ //System.out.println(feature.getLabel()+id);\r
+ features.put("g" + g, feature);\r
+ g++;\r
+ /*Element elModifiers = elDescriptiveConcept.getChild("Modifiers", sddNamespace);\r
+ if (elModifiers !=null){\r
+ List<Element> listModifiers = elModifiers.getChildren("Modifier", sddNamespace);\r
+ for (Element elModifier : listModifiers) {\r
+ TermVocabulary<Modifier> termVocabularyState = new TermVocabulary<Modifier>("test","test","test","test");\r
+ Modifier modif = Modifier.NewInstance();\r
+ String idmod = elModifier.getAttributeValue("id");\r
+ importRepresentation(elModifier, sddNamespace, modif, idmod, sddConfig);\r
+ termVocabularyState.addTerm(modif);\r
+ //XIMfeature.addRecommendedModifierEnumeration(termVocabularyState);\r
+ }\r
+ }*/\r
+ \r
+ fn.setFeature(feature);\r
+\r
+ // TODO if an OriginalSource can be attached to a FeatureNode or a Feature \r
+ // OriginalSource source = null;\r
+ // if (uri != null) {\r
+ // if (!uri.equals("")) {\r
+ // source = OriginalSource.NewInstance(id, "DescriptiveConcept", Generic.NewInstance(), uri);\r
+ // }\r
+ // } else {\r
+ // source = OriginalSource.NewInstance(id, "DescriptiveConcept");\r
+ // }\r
+ // f.addSource(source);\r
+\r
+ featureNodes.put(id,fn);\r
+ }\r
+\r
+ if ((++j % modCount) == 0){ logger.info("DescriptiveConcepts handled: " + j);}\r
+\r
+ }\r
+ }\r
+ }\r
+ \r
+ protected void importCharacterTrees(Element elDataset, Namespace sddNamespace, SDDImportConfigurator sddConfig, boolean success){\r
+ // <CharacterTrees>\r
+ logger.info("start CharacterTrees ...");\r
+ Element elCharacterTrees = elDataset.getChild("CharacterTrees",sddNamespace);\r
+\r
+ // <CharacterTree>\r
+\r
+ if (elCharacterTrees != null) {\r
+ List<Element> listCharacterTrees = elCharacterTrees.getChildren("CharacterTree", sddNamespace);\r
+ int j = 0;\r
+ //for each CharacterTree\r
+ for (Element elCharacterTree : listCharacterTrees){\r
+ try {\r
+ Element elRepresentation = elCharacterTree.getChild("Representation",sddNamespace);\r
+ String label = (String)ImportHelper.getXmlInputValue(elRepresentation,"Label",sddNamespace);\r
+ Element elDesignedFor = elCharacterTree.getChild("DesignedFor",sddNamespace);\r
+ /*XIMList<Element> listRoles = elDesignedFor.getChildren("Role",sddNamespace);\r
+ boolean isgroups = false;\r
+\r
+ for (Element elRole : listRoles){\r
+ if (elRole.getText().equals("Filtering")) {\r
+ isgroups = true;\r
+ }\r
+ }*/\r
+\r
+ // only treats the case of flat groups containing characters\r
+ // should also be added: dependencies between characters, \r
+ //XIM\r
+\r
+ FeatureTree feattree = FeatureTree.NewInstance();\r
+ importRepresentation(elCharacterTree, sddNamespace, feattree, "", sddConfig);\r
+ FeatureNode root = feattree.getRoot();\r
+ //XIM several <Nodes> found in some files, is it correct ?\r
+ List<Element> listelNodes = elCharacterTree.getChildren("Nodes", sddNamespace);\r
+ for (Element elNodes : listelNodes) {\r
+ List<Element> listNodes = elNodes.getChildren("Node", sddNamespace);\r
+ if (listNodes != null) {\r
+ for (Element elNode : listNodes){\r
+ String idN = elNode.getAttributeValue("id");\r
+ FeatureNode fn = null;\r
+ if (!idN.equals("")) {\r
+ Element elDescriptiveConcept = elNode.getChild("DescriptiveConcept", sddNamespace);\r
+ if (elDescriptiveConcept != null){\r
+ String refDC = elDescriptiveConcept.getAttributeValue("ref");\r
+ //System.out.println(refDC);\r
+ fn = featureNodes.get(refDC);\r
+ }\r
+ else {\r
+ fn = FeatureNode.NewInstance();\r
+ featureNodes.put(idN,fn);\r
+ }\r
+ Element elParent = elNode.getChild("Parent", sddNamespace);\r
+ if (elParent!=null){\r
+ String refP = elParent.getAttributeValue("ref");\r
+ if (!refP.equals("")) {\r
+ FeatureNode parent = nodes.get(refP);\r
+ parent.addChild(fn);\r
+ }\r
+ }\r
+ else {\r
+ fn = FeatureNode.NewInstance();\r
+ root.addChild(fn);\r
+ }\r
+ }\r
+ nodes.put(idN, fn);\r
+ }\r
+ //System.out.println("zic");\r
+ List<Element> listCharNodes = elNodes.getChildren("CharNode", sddNamespace);\r
+ for (Element elCharNode : listCharNodes){\r
+ Element elParent = elCharNode.getChild("Parent", sddNamespace);\r
+ Element elCharacter = elCharNode.getChild("Character", sddNamespace); \r
+ FeatureNode fn = FeatureNode.NewInstance();\r
+ if (elParent!=null){\r
+ String refP = elParent.getAttributeValue("ref");\r
+ if ((refP!=null)&&(!refP.equals(""))) {\r
+ FeatureNode parent = nodes.get(refP);\r
+ if (parent==null){\r
+ parent = root; // because of Delta example\r
+ }\r
+ parent.addChild(fn);\r