Multiple-elements unique keys in ome.xml models
Posted: Tue Aug 31, 2010 1:12 pm
Hi everyone,
I'm writing some new ome.xml files to extend omero data model and I wanted to know if I can write a multi-elements unique key inside the XML code.
I try to explain using an example.
I want to create a new item with some fields
My problem is that each DummyItem object must have a unique key for the myDate AND the myOtherUniqueField fields, two items with the same values in both these fields have to be considered two duplicated items and one of them must raise an exception during the save operation.
I wanted to know if there is a syntax that I can use to create this kind of key or if I have to use a "combined" field with the unique constraint like this
where uniqueKeyValues can be (for example) a string field obtained using the two fields (myDate and myOtherUniqueField).
I'm writing some new ome.xml files to extend omero data model and I wanted to know if I can write a multi-elements unique key inside the XML code.
I try to explain using an example.
I want to create a new item with some fields
- Code: Select all
<type id="ome.model.DummyItem">
<properties>
<required name="label" type="string"/>
<required name="myDate" type="timestamp"/>
<required name="myOtherUniqueField" type="string"/>
</properties>
</type>
My problem is that each DummyItem object must have a unique key for the myDate AND the myOtherUniqueField fields, two items with the same values in both these fields have to be considered two duplicated items and one of them must raise an exception during the save operation.
I wanted to know if there is a syntax that I can use to create this kind of key or if I have to use a "combined" field with the unique constraint like this
- Code: Select all
<type id="ome.model.DummyItem">
<properties>
<required name="label" type="string"/>
<required name="myDate" type="timestamp"/>
<required name="myOtherUniqueField" type="string"/>
<required name="uniqueKeyValues" type="string" unique="true"/>
</properties>
</type>
where uniqueKeyValues can be (for example) a string field obtained using the two fields (myDate and myOtherUniqueField).