Ejemplo n.º 1
0
  protected Element asXMLElement(Document document, Element Screen_element) {
    // Creating XML block for Screen

    if (Screen_element == null) {
      Screen_element = document.createElementNS(NAMESPACE, "Screen");
    }

    if (name != null) {
      // Attribute property Name
      Screen_element.setAttribute("Name", name.toString());
    }
    if (protocolDescription != null) {
      // Attribute property ProtocolDescription
      Screen_element.setAttribute("ProtocolDescription", protocolDescription.toString());
    }
    if (protocolIdentifier != null) {
      // Attribute property ProtocolIdentifier
      Screen_element.setAttribute("ProtocolIdentifier", protocolIdentifier.toString());
    }
    if (reagentSetDescription != null) {
      // Attribute property ReagentSetDescription
      Screen_element.setAttribute("ReagentSetDescription", reagentSetDescription.toString());
    }
    if (type != null) {
      // Attribute property Type
      Screen_element.setAttribute("Type", type.toString());
    }
    if (id != null) {
      // Attribute property ID
      Screen_element.setAttribute("ID", id.toString());
    }
    if (reagentSetIdentifier != null) {
      // Attribute property ReagentSetIdentifier
      Screen_element.setAttribute("ReagentSetIdentifier", reagentSetIdentifier.toString());
    }
    if (description != null) {
      // Element property Description which is not complex (has no
      // sub-elements)
      Element description_element = document.createElementNS(NAMESPACE, "Description");
      description_element.setTextContent(description.toString());
      Screen_element.appendChild(description_element);
    }
    if (reagents != null) {
      // Element property Reagent which is complex (has
      // sub-elements) and occurs more than once
      for (Reagent reagents_value : reagents) {
        Screen_element.appendChild(reagents_value.asXMLElement(document));
      }
    }
    if (plateLinks != null) {
      // Reference property PlateRef which occurs more than once
      for (Plate plateLinks_value : plateLinks) {
        PlateRef o = new PlateRef();
        o.setID(plateLinks_value.getID());
        Screen_element.appendChild(o.asXMLElement(document));
      }
    }
    if (annotationLinks != null) {
      // Reference property AnnotationRef which occurs more than once
      for (Annotation annotationLinks_value : annotationLinks) {
        AnnotationRef o = new AnnotationRef();
        o.setID(annotationLinks_value.getID());
        Screen_element.appendChild(o.asXMLElement(document));
      }
    }
    return super.asXMLElement(document, Screen_element);
  }
Ejemplo n.º 2
0
 /**
  * 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);
   }
 }