Changeset 3406


Ignore:
Timestamp:
11/21/07 18:40:56 (12 years ago)
Author:
curtis
Message:

Bugfixes, corrections and improvements toward a working 2007-06 OME-XML.
OMEXML200706Metadata doesn't compile yet, though.

Location:
trunk/loci/formats/auto
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/loci/formats/auto/MetadataAutogen.java

    r3393 r3406  
    193193        String version = line.substring(1, colon).trim(); 
    194194        String paramName = line.substring(colon + 1).trim(); 
    195         paramMap.put(version + "/" + param.name, paramName); 
     195        paramMap.put(version + ":" + node.name + ":" + param.name, paramName); 
    196196        continue; 
    197197      } 
     
    205205          // populate all known versions with the default 
    206206          Enumeration en = versions.keys(); 
     207          Vector indices = getIndices(path); 
    207208          while (en.hasMoreElements()) { 
    208209            String key = (String) en.nextElement(); 
    209210            if (!node.paths.contains(key)) node.paths.put(key, path); 
     211            node.indices = indices; 
    210212          } 
    211213        } 
     
    280282      String value = (String) node.paths.get(key); 
    281283      // OME-XML implementation 
    282       doHelpers("ome/OMEXML" + key + "Metadata.java", value, key); 
     284      String id = "ome/OMEXML" + key + "Metadata.java"; 
     285      doHelpers(id, value, node.indices, key); 
    283286    } 
    284287  } 
     
    301304    // parse path 
    302305    String last = getLastPathElement(path); 
    303     Vector indices = getIndices(path); 
     306    Vector indices = node.indices; 
    304307    int psize = node.params.size(); 
    305308    int isize = indices.size(); 
     
    376379      if (version != null) { 
    377380        boolean noSupport = last.equals("-"); 
    378         String mappedName = getParamName(pi.name, version); 
     381        String mappedName = getParamName(pi.name, node.name, version); 
    379382        if (noSupport || mappedName.equals("-")) { 
    380383          Hashtable vars = (Hashtable) versions.get(version); 
     
    395398          lt.newline(); 
    396399          String ante = "    return " + varName + " == null ? null :"; 
     400 
     401          boolean convert = false; 
     402          if (mappedName.endsWith("%")) { 
     403            mappedName = mappedName.substring(0, mappedName.length() - 1); 
     404            convert = true; 
     405          } 
    397406          String cons = varName + "." + 
    398             (pi.type.equals("Boolean") ? "is" : "get") + mappedName + "();"; 
     407            (pi.type.equals("Boolean") ? "is" : "get") + mappedName + "()"; 
     408          if (convert) { 
     409            cons = toVarName(node.name) + 
     410              mappedName + "To" + pi.type + "(" + cons + ")"; 
     411          } 
     412          cons += ";"; 
    399413          if (ante.length() + cons.length() <= 79) { 
    400414            lt.add(ante + " " + cons); 
     
    435449    // parse path 
    436450    String last = getLastPathElement(path); 
    437     Vector indices = getIndices(path); 
     451    Vector indices = node.indices; 
    438452    int psize = node.params.size(); 
    439453    int isize = indices.size(); 
     
    525539        for (int i=0; i<psize; i++) { 
    526540          Param p = (Param) node.params.get(i); 
    527           String mappedName = getParamName(p.name, version); 
     541          String mappedName = getParamName(p.name, node.name, version); 
    528542          if (mappedName.equals("-")) { 
    529543            Hashtable vars = (Hashtable) versions.get(version); 
     
    534548          else { 
    535549            String ante = "    if (" + toVarName(p.name) + " != null) "; 
    536             String cons = varName + ".set" + mappedName + 
    537               "(" + toVarName(p.name) + ");"; 
     550            boolean convert = false; 
     551            if (mappedName.endsWith("%")) { 
     552              mappedName = mappedName.substring(0, mappedName.length() - 1); 
     553              convert = true; 
     554            } 
     555            String cons = toVarName(p.name); 
     556            if (convert) { 
     557              cons = toVarName(node.name) + 
     558                mappedName + "From" + p.type + "(" + cons + ")"; 
     559            } 
     560            cons = varName + ".set" + mappedName + "(" + cons + ");"; 
    538561            if (ante.length() + cons.length() <= 80) { 
    539562              lt.add(ante + cons); 
     
    562585  /** Generates helper methods for the given node and source file. */ 
    563586  private static void doHelpers(String id, 
    564     String path, String version) throws IOException 
     587    String path, Vector indices, String version) throws IOException 
    565588  { 
    566589    // only generate each path's helper method once 
     
    581604    // parse path 
    582605    String last = getLastPathElement(path); 
    583     Vector indices = getIndices(path); 
    584606    int isize = indices.size(); 
    585607 
     
    630652    while (st.hasMoreTokens()) { 
    631653      String token = st.nextToken(); 
    632       boolean ref = false; 
     654      boolean ref = false, bang = false; 
    633655      if (token.startsWith("@")) { 
    634         token = token.substring(1); 
     656        if (token.startsWith("@!")) { 
     657          token = token.substring(2); 
     658          bang = true; 
     659        } 
     660        else token = token.substring(1); 
    635661        ref = true; 
    636662      } 
     
    683709      else { 
    684710        if (ca || ref) { 
     711          String extra = bang ? "By" + pToken : ""; 
    685712          lt.add("    " + token + "Node " + var + " = null;"); 
    686713          lt.newline(); 
    687714          if (ca) lt.add("    count = ca.countCAList(\"" + token + "\");"); 
    688           else lt.add("    count = " + pVar + ".count" + token + "List();"); 
     715          else { 
     716            lt.add("    count = " + pVar + 
     717              ".count" + token + "List" + extra + "();"); 
     718          } 
    689719          lt.newline(); 
    690720          lt.add("    if (count >= 1) {"); 
     
    695725          } 
    696726          else { 
    697             lt.add(" " + pVar + ".get" + token + "List().get(0);", "        "); 
     727            lt.add(" " + pVar + ".get" + token + 
     728              "List" + extra + "().get(0);", "        "); 
    698729          } 
    699730          lt.newline(); 
     
    805836 
    806837  /** Gets overridden parameter name for the given version, if any. */ 
    807   private static String getParamName(String name, String version) { 
    808     String paramName = (String) paramMap.get(version + "/" + name); 
     838  private static String getParamName(String name, 
     839    String nodeName, String version) 
     840  { 
     841    String paramName = (String) 
     842      paramMap.get(version + ":" + nodeName + ":" + name); 
    809843    return paramName == null ? name : paramName; 
    810844  } 
     
    813847  private static String getLastPathElement(String path) { 
    814848    int first = path.lastIndexOf("/") + 1; 
    815     if (path.charAt(first) == '@') first++; 
    816     int last = path.length(); 
    817     if (path.endsWith("+")) last--; 
    818     return path.substring(first, last); 
     849    return path.substring(first).replaceAll("[@\\!\\+]", ""); 
    819850  } 
    820851 
     
    823854  /** A helper class for storing information about a node. */ 
    824855  private static class Node { 
    825     private String name = null, desc = null, extra = null; 
     856    private String name, desc, extra; 
    826857    private Hashtable paths = new Hashtable(); 
     858    private Vector indices; 
    827859    private Vector params = new Vector(); 
    828860  } 
  • trunk/loci/formats/auto/MetadataAutogenHeaderOMEXML.txt

    r3364 r3406  
    5050 */ 
    5151public class ${class} extends OMEXMLMetadata { 
     52 
     53  // -- OMEXMLMetadata API methods -- 
     54 
     55  /* @see OMEXMLMetadata#createRoot(String) */ 
     56  public void createRoot(String xml) { 
     57    // CTR TEMP 
     58  } 
     59 
     60  /* @see OMEXMLMetadata#dumpXML() */ 
     61  public String dumpXML() { 
     62    // CTR TEMP 
     63    return null; 
     64  } 
  • trunk/loci/formats/auto/MetadataAutogenNodes.txt

    r3393 r3406  
    2020# along with this program; if not, write to the Free Software 
    2121# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
     22 
     23# Path key: 
     24# 1) Elements ending in plus (+) have maxOccurs > 1 and generate an index 
     25#    parameter to allow differentiation between them. 
     26# 2) Elements beginning with at (@) are not direct children of the previous 
     27#    element, but instead reference the parent indirectly somehow. 
     28# 3) Elements beginning with at-bang (@!) also use a parent reference but 
     29#    the API is slightly different -- e.g., for a LightSource accessing its 
     30#    child Laser, the method is lightSource.getLaserListByLightSource() rather 
     31#    than lightSource.getLaserList(). 
     32# 4) Overridden attributes ending in percent (%) mark a type conflict that 
     33#    must be resolved by calling type conversion methods from the  
     34#    OMEXMLMetadata superclass. 
    2235 
    2336[Image] 
     
    3952String Email          the e-mail address of the experimenter 
    4053String Institution    the institution for which the experimenter belongs 
    41 String DataDirectory  the fully qualified path to the experimenter's data 
     54#CTR TODO - decide whether to include DataDirectory 
     55#String DataDirectory  the fully qualified path to the experimenter's data 
    4256#CTR TODO - complexify 
    4357#Object Group          the group to which the experimenter belongs 
     
    5468#Object Contact  the contact for the group 
    5569 
    56 [Instrument] 
    57 an instrument in the metadata store with a particular index 
    58 - 
    59 Default: Instrument+ 
    60 2003FC: CA/Instrument+ 
    61 String Manufacturer  the name of the manufacturer 
    62 String Model         the model number of the instrument 
    63 String SerialNumber  the serial number of the instrument 
    64 String Type          the type of the instrument 
     70#CTR TODO - Instrument shouldn't have any attributes directly... right? 
     71#           so why are they in the 2003 FC CA schema...? 
     72#[Instrument] 
     73#an instrument in the metadata store with a particular index 
     74#- 
     75#Default: Instrument+ 
     76#2003FC: CA/Instrument+ 
     77#String Manufacturer  the name of the manufacturer 
     78#String Model         the model number of the instrument 
     79#String SerialNumber  the serial number of the instrument 
     80#String Type          the type of the instrument 
    6581 
    6682[Dimensions] 
    6783a set of pixel dimensions in the metadata store with a particular index 
    6884Unless both values are non-null, the MetadataStore should assume pixelSizeX equals pixelSizeY (i.e., should populate the null field with the other field's value). 
    69 Default: Image+ 
     85Default: Image+/Pixels+ 
    70862003FC: Image+/CA/Dimensions 
    7187Float PhysicalSizeX  size of an individual pixel's X axis in microns 
     
    7995Integer WaveStart    starting wavelength in nanometers 
    8096*2003FC: - 
    81 Float WaveIncrement  distance between adjacent wavelengths in nanometers 
    82 *2003FC: PixelSizeC 
     97Integer WaveIncrement  distance between adjacent wavelengths in nanometers 
     98*2003FC: PixelSizeC% 
    8399 
    84100[DisplayROI] 
     
    115131[StageLabel] 
    116132a stage label in the metadata store with a particular index 
     133- 
    117134Default: Image+/StageLabel 
    1181352003FC: Image+/CA/StageLabel 
     
    127144Default: Image+/LogicalChannel+ 
    1281452003FC: Image+/CA/LogicalChannel+ 
     146#CTR TODO - where has auxiliary light source gone...? 
     147#Integer AuxLightSource            the index of the auxiliary light source 
     148#Float AuxLightAttenuation         the auxiliary light source attenuation 
     149#String AuxTechnique               the auxiliary technique type 
     150#Integer AuxLightWavelength        the auxiliary light source wavelength 
    129151String Name                       the logical channel's name 
    130152Integer SamplesPerPixel           CTR TODO 
    131 #CTR TODO - complexify 
    132 #Integer Filter                    the index of the filter associated with this channel 
    133 #CTR TODO - complexify 
    134 #Integer LightSource               the index of the primary light source 
    135 Float LightAttenuation            the primary light source attenuation 
    136 Integer LightWavelength           the primary light source wavelength 
    137 #CTR TODO - complexify 
    138 #Integer OTF                       the index of the OTF associated with this channel 
    139 #CTR TODO - complexify 
    140 #Integer Detector                  the index of the detector associated with this channel 
    141 Float DetectorOffset              the detector offset 
    142 Float DetectorGain                the detector gain 
     153# CTR TODO - complexify 
     154#Integer SecondaryEmissionFilter  an index... 
     155# CTR TODO - complexify 
     156#Integer SecondaryExcitationFilter  an index... 
    143157String IlluminationType           the illumination type 
    144158Integer PinholeSize               the size of the pinhole 
     
    146160String Mode                       the acquisition mode 
    147161String ContrastMethod             the constrast method name 
    148 #CTR TODO - complexify 
    149 #Integer AuxLightSource            the index of the auxiliary light source 
    150 Float AuxLightAttenuation         the auxiliary light source attenuation 
    151 String AuxTechnique               the auxiliary technique type 
    152 Integer AuxLightWavelength        the auxiliary light source wavelength 
     162Integer ExWave                    the excitation wavelength 
     163*2003FC: ExcitationWavelength 
    153164Integer EmWave                    the emission wavelength 
    154165*2003FC: EmissionWavelength 
    155 Integer ExWave                    the excitation wavelength 
    156 *2003FC: ExcitationWavelength 
    157166String Fluor                      the fluorescence type 
    158167Float NdFilter                    the neutral-density filter value 
    159168*2003FC: NDFilter 
     169Integer PockelCellSetting         CTR TODO 
     170*2003FC: - 
     171 
     172[ChannelLightSource] 
     173the light source associated with a particular logical channel 
     174- 
     175Default: Image+/LogicalChannel+/LightSourceRef 
     1762003FC: Image+/CA/LogicalChannel+ 
     177#CTR TODO - complexify 
     178#Integer LightSource        the index of the primary light source 
     179Float Attenuation          the primary light source attenuation 
     180*2003FC: LightAttenuation 
     181Integer Wavelength         the primary light source wavelength 
     182*2003FC: LightWavelength 
     183 
     184#[ChannelOTF] 
     185#the optical transfer function associated with a particular logical channel 
     186#- 
     187#Default: Image+/LogicalChannel+/OTFRef 
     188#2003FC: x 
     189#CTR TODO - complexify 
     190#Integer OTF  the index of the OTF associated with this channel 
     191 
     192[ChannelDetector] 
     193the detector associated with a particular logical channel 
     194- 
     195Default: Image+/LogicalChannel+/DetectorRef 
     1962003FC: Image+/CA/LogicalChannel+ 
     197#CTR TODO - complexify 
     198#Integer Detector         the index of the detector associated with this channel 
     199Float Offset             the detector offset 
     200*2003FC: DetectorOffset 
     201Float Gain               the detector gain 
     202*2003FC: DetectorGain 
     203 
     204# CTR TODO - finish/add this - LogicalChannel/FilterSetRef 
     205#[ChannelFilterSet] 
    160206 
    161207[PlaneInfo] 
     
    163209NOTE: The implementation of this method is optional as this is a transitional type. More information about the PlaneInfo type can be found <a href="http://cvs.openmicroscopy.org.uk/tiki/tiki-index.php?page=DataModelProposal#id119301">here</a>. 
    164210Default: Image+/Pixels+/Plane+ 
    165 2003FC: Image+/Pixels+/Plane+/- 
     2112003FC: - 
    166212Integer TheZ        the optical section index 
    167213Integer TheC        the channel index 
    168214Integer TheT        the timepoint 
    169 Float Timestamp     the time of acquisition in seconds of the plane (section) with zero being the start of acquisition 
    170 Float ExposureTime  exposureTime exposure time in seconds. 
     215 
     216[PlaneTiming] 
     217the timing information for a particular X-Y plane (section) within a particular pixels set 
     218- 
     219Default: Image+/Pixels+/Plane+/PlaneTiming 
     2202003FC: - 
     221Float DeltaT        the time in seconds since the beginning of the experiment 
     222Float ExposureTime  the exposure time in seconds 
     223 
     224[StagePosition] 
     225the stage position for a particular X-Y plane (section) within a particular pixels set 
     226- 
     227Default: Image+/Pixels+/Plane+/StagePosition 
     2282003FC: - 
     229Float PositionX  the X coordinate of the stage position 
     230Float PositionY  the Y coordinate of the stage position 
     231Float PositionZ  the Z coordinate of the stage position 
     232 
    171233 
    172234[ImagingEnvironment] 
     
    220282- 
    221283Default: Instrument+/LightSource+/Laser 
    222 2003FC: CA/Instrument+/@LightSource+/@Laser 
    223 #TODO 2003FC needs to call lightSource.getLaserListByLightSource... 
     2842003FC: CA/Instrument+/@LightSource+/@!Laser 
    224285String Type               CTR TODO 
    225286String Medium             CTR TODO 
Note: See TracChangeset for help on using the changeset viewer.