Changeset 6540


Ignore:
Timestamp:
06/21/10 10:57:47 (9 years ago)
Author:
callan
Message:

Support for 2010-06 schema translation.

Location:
trunk/components/bio-formats
Files:
2 edited

Legend:

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

    r6536 r6540  
    9595    XMLTools.getStylesheet("/loci/formats/meta/2009-09-to-2010-04.xsl", 
    9696    OMEXMLServiceImpl.class); 
     97  private static Templates UPDATE_201004 = 
     98    XMLTools.getStylesheet("/loci/formats/meta/2010-04-to-2010-06.xsl", 
     99    OMEXMLServiceImpl.class); 
    97100 
    98101  /** 
     
    114117    String version = getOMEXMLVersion(xml); 
    115118    if (version.equals(getLatestVersion())) return xml; 
     119    LOGGER.debug("Attempting to update XML with version: {}", version); 
    116120 
    117121    String transformed = null; 
     
    130134      } 
    131135      else transformed = xml; 
    132  
    133       if (!version.equals("2009-09")) { 
     136      LOGGER.debug("XML updated to at least 2008-09"); 
     137 
     138      if (!version.equals("2009-09") && !version.equals("2010-04")) { 
    134139        transformed = XMLTools.transformXML(transformed, UPDATE_200809); 
    135140      } 
    136       transformed = XMLTools.transformXML(transformed, UPDATE_200909); 
     141      LOGGER.debug("XML updated to at least 2009-09"); 
     142      if (!version.equals("2010-04")) { 
     143        transformed = XMLTools.transformXML(transformed, UPDATE_200909); 
     144      } 
     145      LOGGER.debug("XML updated to at least 2010-04"); 
     146      transformed = XMLTools.transformXML(transformed, UPDATE_201004); 
     147      LOGGER.debug("XML updated to at least 2010-06"); 
    137148      // fix namespaces 
    138149      transformed = transformed.replaceAll("<ns.*?:", "<"); 
    139150      transformed = transformed.replaceAll("xmlns:ns.*?=", "xmlns:OME="); 
    140151      transformed = transformed.replaceAll("</ns.*?:", "</"); 
    141  
     152      LOGGER.debug("Dump: {}", transformed); 
    142153      return transformed; 
    143154    } 
     
    225236  public String getOMEXMLVersion(Object o) { 
    226237    if (o == null) return null; 
    227     String name = o.getClass().getName(); 
    228     if (o instanceof OMEXMLMetadata) { 
    229       final String prefix = "loci.formats.ome.OMEXML"; 
    230       final String suffix = "Metadata"; 
    231       if (name.startsWith(prefix) && name.endsWith(suffix)) { 
    232         String numbers = 
    233           name.substring(prefix.length(), name.length() - suffix.length()); 
    234         if (numbers.length() == 6) { 
    235           return numbers.substring(0, 4) + "-" + 
    236             numbers.substring(4, 6).toUpperCase(); 
    237         } 
    238       } 
    239     } 
    240     else if (o instanceof OMEModelObject) { 
    241       return getLatestVersion(); 
     238    if (o instanceof OMEXMLMetadata || o instanceof OMEModelObject) { 
     239      return OMEXMLFactory.LATEST_VERSION; 
    242240    } 
    243241    else if (o instanceof String) { 
  • trunk/components/bio-formats/test/loci/formats/utests/OMEXMLServiceTest.java

    r6128 r6540  
    6868  @Test 
    6969  public void testGetLatestVersion() { 
    70     assertEquals("2008-09", service.getLatestVersion()); 
     70    assertEquals("2010-06", service.getLatestVersion()); 
    7171  } 
    7272 
     
    9494  @Test 
    9595  public void getOMEXMLVersion() throws ServiceException { 
    96     assertEquals("2008-09", 
     96    assertEquals("2010-06", 
    9797      service.getOMEXMLVersion(service.createOMEXMLMetadata(xml))); 
    9898  } 
Note: See TracChangeset for help on using the changeset viewer.