Changeset 6233


Ignore:
Timestamp:
05/05/10 11:34:59 (10 years ago)
Author:
melissa
Message:

Populate original metadata using StructuredAnnotations.

Location:
trunk/components/bio-formats/src/loci/formats
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/components/bio-formats/src/loci/formats/MetadataTools.java

    r6230 r6233  
    106106    for (int i=0; i<r.getSeriesCount(); i++) { 
    107107      r.setSeries(i); 
     108      store.setImageID(createLSID("Image", i), i); 
    108109      if (doImageName) store.setImageName(r.getCurrentFile(), i); 
    109       String pixelsID = createLSID("Pixels", i, 0); 
     110      String pixelsID = createLSID("Pixels", 0); 
    110111      store.setPixelsID(pixelsID, i); 
    111112      store.setPixelsSizeX(new PositiveInteger(r.getSizeX()), i); 
     
    127128        Integer sampleCount = new Integer(r.getRGBChannelCount()); 
    128129        for (int c=0; c<r.getEffectiveSizeC(); c++) { 
     130          store.setChannelID(createLSID("Channel", i, c), i, c); 
    129131          store.setChannelSamplesPerPixel(sampleCount, i, c); 
    130132        } 
  • trunk/components/bio-formats/src/loci/formats/ome/AbstractOMEXMLMetadata.java

    r6232 r6233  
    3333 
    3434import ome.xml.DOMUtil; 
     35import ome.xml.r201004.OME; 
    3536import ome.xml.r201004.OMEModelObject; 
    3637 
     
    5455  // -- Constants -- 
    5556 
    56   /** Custom attribute for storing original metadata key/value pairs. */ 
    57   private static final String ORIGINAL_METADATA = "OriginalMetadata"; 
     57  /** XSI namespace. */ 
     58  public static final String XSI_NS = 
     59    "http://www.w3.org/2001/XMLSchema-instance"; 
     60 
     61  /** OME-XML schema location. */ 
     62  public static final String SCHEMA = 
     63    "http://www.openmicroscopy.org/Schemas/OME/2010-04/ome.xsd"; 
    5864 
    5965  // -- Fields -- 
     
    6470  /** DOM element that backs the first Image's CustomAttributes node. */ 
    6571  private Element imageCA; 
    66  
    67   /** Whether OriginalMetadata semantic type definition has been created. */ 
    68   private boolean omCreated; 
    69  
    70   /** Hashtable containing all OriginalMetadata objects. */ 
    71   private Hashtable<String, String> originalMetadata; 
    7272 
    7373  private DocumentBuilder builder; 
     
    9898      Document doc = builder.newDocument(); 
    9999      Element r = root.asXMLElement(doc); 
     100      r.setAttribute("xmlns:xsi", XSI_NS); 
     101      r.setAttribute("xsi:schemaLocation", OME.NAMESPACE + " " + SCHEMA); 
    100102      doc.appendChild(r); 
    101103      DOMUtil.writeXML(os, doc); 
     
    105107    } 
    106108    return null; 
    107   } 
    108  
    109   /** Adds the key/value pair as a new OriginalMetadata node. */ 
    110   public void setOriginalMetadata(String key, String value) { 
    111     // TODO : deprecate and use a StringAnnotation instead 
    112   } 
    113  
    114   /** Gets the Hashtable containing all OriginalMetadata key/value pairs. */ 
    115   public Hashtable<String, String> getOriginalMetadata() { 
    116     // TODO : deprecate and return StringAnnotations instead 
    117     if (originalMetadata != null) return originalMetadata; 
    118     originalMetadata = new Hashtable<String, String>(); 
    119     return originalMetadata; 
    120   } 
    121  
    122   /** Gets the OriginalMetadata value corresponding to the given key. */ 
    123   public String getOriginalMetadataValue(String key) { 
    124     return originalMetadata == null ? null : originalMetadata.get(key); 
    125109  } 
    126110 
     
    137121  /* @see loci.formats.meta.MetadataStore#setRoot(Object) */ 
    138122  public void setRoot(Object root) { 
    139     originalMetadata = null; 
    140123  } 
    141124 
  • trunk/components/bio-formats/src/loci/formats/ome/OMEXMLMetadata.java

    r6026 r6233  
    4545  public String dumpXML(); 
    4646 
    47   /** Adds the key/value pair as a new OriginalMetadata node. */ 
    48   public void setOriginalMetadata(String key, String value); 
    49  
    50   /** Gets the Hashtable containing all OriginalMetadata key/value pairs. */ 
    51   public Hashtable<String, String> getOriginalMetadata(); 
    52  
    53   /** Gets the OriginalMetadata value corresponding to the given key. */ 
    54   public String getOriginalMetadataValue(String key); 
    5547} 
  • trunk/components/bio-formats/src/loci/formats/services/OMEXMLServiceImpl.java

    r6230 r6233  
    3434import loci.common.services.ServiceException; 
    3535import loci.common.xml.XMLTools; 
     36import loci.formats.MetadataTools; 
    3637import loci.formats.meta.IMetadata; 
    3738import loci.formats.meta.MetadataConverter; 
     
    4142import ome.xml.OMEXMLFactory; 
    4243import ome.xml.OMEXMLNode; 
     44import ome.xml.r201004.StructuredAnnotations; 
    4345 
    4446import org.slf4j.Logger; 
     
    6870    XMLTools.getStylesheet("/loci/formats/meta/reorder-2008-09.xsl", 
    6971                           OMEXMLServiceImpl.class); 
    70    
     72 
    7173  /** 
    7274   * Default constructor. 
     
    7678    checkClassDependency(ome.xml.OMEXMLNode.class); 
    7779  } 
    78    
     80 
    7981  /* (non-Javadoc) 
    8082   * @see loci.formats.services.OMEXMLService#getLatestVersion() 
     
    290292    String key, String value) 
    291293  { 
    292     omexmlMeta.setOriginalMetadata(key, value); 
     294    int annotationIndex = 0; 
     295    try { 
     296      annotationIndex = omexmlMeta.getListAnnotationCount(); 
     297    } 
     298    catch (NullPointerException e) { } 
     299    String listID = MetadataTools.createLSID("Annotation", annotationIndex * 3); 
     300    omexmlMeta.setListAnnotationID(listID, annotationIndex); 
     301    omexmlMeta.setListAnnotationNamespace( 
     302      StructuredAnnotations.NAMESPACE, annotationIndex); 
     303 
     304    int keyIndex = annotationIndex * 2; 
     305    int valueIndex = annotationIndex * 2 + 1; 
     306    String keyID = 
     307      MetadataTools.createLSID("Annotation", annotationIndex * 3 + 1); 
     308    String valueID = 
     309      MetadataTools.createLSID("Annotation", annotationIndex * 3 + 2); 
     310    omexmlMeta.setStringAnnotationID(keyID, keyIndex); 
     311    omexmlMeta.setStringAnnotationID(valueID, valueIndex); 
     312    omexmlMeta.setStringAnnotationValue(key, keyIndex); 
     313    omexmlMeta.setStringAnnotationValue(value, valueIndex); 
     314    omexmlMeta.setStringAnnotationNamespace( 
     315      StructuredAnnotations.NAMESPACE, keyIndex); 
     316    omexmlMeta.setStringAnnotationNamespace( 
     317      StructuredAnnotations.NAMESPACE, valueIndex); 
     318    omexmlMeta.setListAnnotationAnnotationRef(keyID, annotationIndex, 0); 
     319    omexmlMeta.setListAnnotationAnnotationRef(valueID, annotationIndex, 1); 
    293320  } 
    294321 
Note: See TracChangeset for help on using the changeset viewer.