コード例 #1
0
ファイル: Screen.java プロジェクト: Jondeen/bioformats
 /**
  * Updates Screen recursively from an XML DOM tree. <b>NOTE:</b> No properties are removed, only
  * added or updated.
  *
  * @param element Root of the XML DOM tree to construct a model object graph from.
  * @param model Handler for the OME model which keeps track of instances and references seen
  *     during object population.
  * @throws EnumerationException If there is an error instantiating an enumeration during model
  *     object creation.
  */
 public void update(Element element, OMEModel model) throws EnumerationException {
   super.update(element, model);
   String tagName = element.getTagName();
   if (!"Screen".equals(tagName)) {
     LOGGER.debug("Expecting node name of Screen got {}", tagName);
   }
   if (element.hasAttribute("Name")) {
     // Attribute property Name
     setName(String.valueOf(element.getAttribute("Name")));
   }
   if (element.hasAttribute("ProtocolDescription")) {
     // Attribute property ProtocolDescription
     setProtocolDescription(String.valueOf(element.getAttribute("ProtocolDescription")));
   }
   if (element.hasAttribute("ProtocolIdentifier")) {
     // Attribute property ProtocolIdentifier
     setProtocolIdentifier(String.valueOf(element.getAttribute("ProtocolIdentifier")));
   }
   if (element.hasAttribute("ReagentSetDescription")) {
     // Attribute property ReagentSetDescription
     setReagentSetDescription(String.valueOf(element.getAttribute("ReagentSetDescription")));
   }
   if (element.hasAttribute("Type")) {
     // Attribute property Type
     setType(String.valueOf(element.getAttribute("Type")));
   }
   if (!element.hasAttribute("ID") && getID() == null) {
     // TODO: Should be its own exception
     throw new RuntimeException(String.format("Screen missing required ID property."));
   }
   if (element.hasAttribute("ID")) {
     // ID property
     setID(String.valueOf(element.getAttribute("ID")));
     // Adding this model object to the model handler
     model.addModelObject(getID(), this);
   }
   if (element.hasAttribute("ReagentSetIdentifier")) {
     // Attribute property ReagentSetIdentifier
     setReagentSetIdentifier(String.valueOf(element.getAttribute("ReagentSetIdentifier")));
   }
   List<Element> Description_nodeList = getChildrenByTagName(element, "Description");
   if (Description_nodeList.size() > 1) {
     // TODO: Should be its own Exception
     throw new RuntimeException(
         String.format("Description node list size %d != 1", Description_nodeList.size()));
   } else if (Description_nodeList.size() != 0) {
     // Element property Description which is not complex (has no
     // sub-elements)
     setDescription(String.valueOf(Description_nodeList.get(0).getTextContent()));
   }
   // Element property Reagent which is complex (has
   // sub-elements) and occurs more than once
   List<Element> Reagent_nodeList = getChildrenByTagName(element, "Reagent");
   for (Element Reagent_element : Reagent_nodeList) {
     addReagent(new Reagent(Reagent_element, model));
   }
   // Element reference PlateRef
   List<Element> PlateRef_nodeList = getChildrenByTagName(element, "PlateRef");
   for (Element PlateRef_element : PlateRef_nodeList) {
     PlateRef plateLinks_reference = new PlateRef();
     plateLinks_reference.setID(PlateRef_element.getAttribute("ID"));
     model.addReference(this, plateLinks_reference);
   }
   // Element reference AnnotationRef
   List<Element> AnnotationRef_nodeList = getChildrenByTagName(element, "AnnotationRef");
   for (Element AnnotationRef_element : AnnotationRef_nodeList) {
     AnnotationRef annotationLinks_reference = new AnnotationRef();
     annotationLinks_reference.setID(AnnotationRef_element.getAttribute("ID"));
     model.addReference(this, annotationLinks_reference);
   }
 }
コード例 #2
0
ファイル: OME.java プロジェクト: hflynn/bioformats
 /**
  * Updates OME recursively from an XML DOM tree. <b>NOTE:</b> No properties are removed, only
  * added or updated.
  *
  * @param element Root of the XML DOM tree to construct a model object graph from.
  * @param model Handler for the OME model which keeps track of instances and references seen
  *     during object population.
  * @throws EnumerationException If there is an error instantiating an enumeration during model
  *     object creation.
  */
 public void update(Element element, OMEModel model) throws EnumerationException {
   super.update(element, model);
   String tagName = element.getTagName();
   if (!"OME".equals(tagName)) {
     LOGGER.debug("Expecting node name of OME got {}", tagName);
   }
   if (element.hasAttribute("UUID")) {
     // Attribute property UUID
     setUUID(String.valueOf(element.getAttribute("UUID")));
   }
   if (element.hasAttribute("Creator")) {
     // Attribute property Creator
     setCreator(String.valueOf(element.getAttribute("Creator")));
   }
   // Element property Project which is complex (has
   // sub-elements) and occurs more than once
   List<Element> Project_nodeList = getChildrenByTagName(element, "Project");
   for (Element Project_element : Project_nodeList) {
     addProject(new Project(Project_element, model));
   }
   // Element property Dataset which is complex (has
   // sub-elements) and occurs more than once
   List<Element> Dataset_nodeList = getChildrenByTagName(element, "Dataset");
   for (Element Dataset_element : Dataset_nodeList) {
     addDataset(new Dataset(Dataset_element, model));
   }
   // Element property Experiment which is complex (has
   // sub-elements) and occurs more than once
   List<Element> Experiment_nodeList = getChildrenByTagName(element, "Experiment");
   for (Element Experiment_element : Experiment_nodeList) {
     addExperiment(new Experiment(Experiment_element, model));
   }
   // Element property Plate which is complex (has
   // sub-elements) and occurs more than once
   List<Element> Plate_nodeList = getChildrenByTagName(element, "Plate");
   for (Element Plate_element : Plate_nodeList) {
     addPlate(new Plate(Plate_element, model));
   }
   // Element property Screen which is complex (has
   // sub-elements) and occurs more than once
   List<Element> Screen_nodeList = getChildrenByTagName(element, "Screen");
   for (Element Screen_element : Screen_nodeList) {
     addScreen(new Screen(Screen_element, model));
   }
   // Element property Experimenter which is complex (has
   // sub-elements) and occurs more than once
   List<Element> Experimenter_nodeList = getChildrenByTagName(element, "Experimenter");
   for (Element Experimenter_element : Experimenter_nodeList) {
     addExperimenter(new Experimenter(Experimenter_element, model));
   }
   // Element property ExperimenterGroup which is complex (has
   // sub-elements) and occurs more than once
   List<Element> ExperimenterGroup_nodeList = getChildrenByTagName(element, "ExperimenterGroup");
   for (Element ExperimenterGroup_element : ExperimenterGroup_nodeList) {
     addExperimenterGroup(new ExperimenterGroup(ExperimenterGroup_element, model));
   }
   // Element property Instrument which is complex (has
   // sub-elements) and occurs more than once
   List<Element> Instrument_nodeList = getChildrenByTagName(element, "Instrument");
   for (Element Instrument_element : Instrument_nodeList) {
     addInstrument(new Instrument(Instrument_element, model));
   }
   // Element property Image which is complex (has
   // sub-elements) and occurs more than once
   List<Element> Image_nodeList = getChildrenByTagName(element, "Image");
   for (Element Image_element : Image_nodeList) {
     addImage(new Image(Image_element, model));
   }
   List<Element> StructuredAnnotations_nodeList =
       getChildrenByTagName(element, "StructuredAnnotations");
   if (StructuredAnnotations_nodeList.size() > 1) {
     // TODO: Should be its own Exception
     throw new RuntimeException(
         String.format(
             "StructuredAnnotations node list size %d != 1",
             StructuredAnnotations_nodeList.size()));
   } else if (StructuredAnnotations_nodeList.size() != 0) {
     // Element property StructuredAnnotations which is complex (has
     // sub-elements)
     setStructuredAnnotations(
         new StructuredAnnotations((Element) StructuredAnnotations_nodeList.get(0), model));
   }
   // Element property ROI which is complex (has
   // sub-elements) and occurs more than once
   List<Element> ROI_nodeList = getChildrenByTagName(element, "ROI");
   for (Element ROI_element : ROI_nodeList) {
     addROI(new ROI(ROI_element, model));
   }
   List<Element> BinaryOnly_nodeList = getChildrenByTagName(element, "BinaryOnly");
   if (BinaryOnly_nodeList.size() > 1) {
     // TODO: Should be its own Exception
     throw new RuntimeException(
         String.format("BinaryOnly node list size %d != 1", BinaryOnly_nodeList.size()));
   } else if (BinaryOnly_nodeList.size() != 0) {
     // Element property BinaryOnly which is complex (has
     // sub-elements)
     setBinaryOnly(new BinaryOnly((Element) BinaryOnly_nodeList.get(0), model));
   }
 }