Task #7017 (closed)
Bug: OMEXMLMetadataImpl.dumpXML() can alter the model
Reported by: | crueden-x | Owned by: | cxallan |
---|---|---|---|
Priority: | minor | Milestone: | n.a. |
Component: | n.a. | Version: | n.a. |
Keywords: | n.a. | Cc: | mlinkert |
Resources: | n.a. | Referenced By: | n.a. |
References: | n.a. | Remaining Time: | 0.0d |
Sprint: | n.a. |
Description
In some cases, calling OMEXMLMetadataImpl.dumpXML() to dump an OME model object to OME-XML can result in the model itself being modified. Here is an example:
// // OMEXMLBug.java // import loci.common.services.ServiceFactory; import loci.common.xml.XMLTools; import loci.formats.meta.IMetadata; import loci.formats.services.OMEXMLService; public class OMEXMLBug { public static void main(final String[] args) throws Exception { final ServiceFactory serviceFactory = new ServiceFactory(); final OMEXMLService omexmlService = serviceFactory.getInstance(OMEXMLService.class); // construct OME metadata object hierarchy final IMetadata omeMeta = omexmlService.createOMEXMLMetadata(); omeMeta.setInstrumentID("Instrument:0", 0); omeMeta.setFilterID("Filter:0", 0, 0); omeMeta.setImageID("Image:0", 0); omeMeta.setChannelID("Channel:0", 0, 0); omeMeta.setLightPathExcitationFilterRef("Filter:0", 0, 0, 0); // dump OME metadata to XML for (int i = 1; i <= 3; i++) { System.out.println("---------- " + i + " ------------"); final String xml = omexmlService.getOMEXML(omeMeta); System.out.println(XMLTools.indentXML(xml, true)); } } }
The first time through the print loop, there is (correctly so) one instance of excitation filter ref. Each time through the loop, another instance of the ref appears.
I traced the problem to a call to OMEModelObject#link in OMEModelImpl#resolveReferences, but thought I would file a ticket for review before going further, since Chris is more familiar with this code.
Change History (4)
comment:1 Changed 13 years ago by jmoore
- Summary changed from OMEXMLMetadataImpl.dumpXML() can alter the model to Bug: OMEXMLMetadataImpl.dumpXML() can alter the model
- Type changed from Bug to Task
comment:2 Changed 12 years ago by Melissa Linkert <melissa@…>
- Remaining Time set to 0
- Resolution set to fixed
- Status changed from new to closed
(In [8ee54ead17d74d38f4168bf628e1167693fe6155/ome.git] on branch develop) Do not link objects that have already been linked
If an object can reference multiple objects of the same type, then
before adding a reference to an object we must check if that object is
already referenced. This prevents additional references to the same
object from being created on successive calls to link(...).
Closes #7017.
comment:3 Changed 12 years ago by Melissa Linkert <melissa@…>
(In [f91d95188be8780d183c8f4966c55af013ef9474/bioformats.git] on branch develop) Results of running xsd-fu against latest templates
See #7017.
comment:4 Changed 12 years ago by Melissa Linkert <melissa@…>
(In [17db504da0a667b48901f8efdb55055b4e73a67c/bioformats.git] on branch develop) Results of running xsd-fu against latest templates
See #7017.
Changing to "Bug:" since we don't use the ticket type Bug.