It looks like within the database configuration, metadata term mappings are enforced to be unique within a single source:
I believe this is correct… and is, in fact, is a core intent of metadata mappings… to provide unique source/code pairs to reference metadata so we can get away from references them by uuid.
However, there doesn’t seem to be any code (or Hibernate) level enforcement of this. This seems incorrect?
Also, to make mappings truly easy-to-use, I would think the saveMetadataMappingTerm() method should be smart enough to update when required.
For instance, let’s say make the following two calls:
saveMetadataTermMapping(new MetadataTermMapping(emrApiSource, “defaultLocation”, Location.class.getName(), “uuid-of-original-default-location”)
saveMetadataTermMapping(new MetadataTermMapping(emrApiSource, “defaultLocation”, Location.class.getName(), “uuid-of-updated-default-location”)
I believe this currently will pass at the application level, and fail at the database level. At minimum, this should fail at the application level, but I believe it would be helpful to do the “right” think and update an existing mapping–ie, in this case you’d end up with a single mapping, mapping emrapi.defaultLocation to the location with uuid “uuid-of-updated-default-location”.
If not, I’m thinking we should at least provide a saveOrUpdateMetadataTermMapping method… or, at minimum, there should be some sort of utility method provided by the metadata mapping module to update the value of a mapping via a single line.
Thoughts? Am I misunderstanding anything here?
Thanks! Mark