barsch/seishub.core

multiple schemas for one resource type

Closed this issue · 4 comments

@barsch, @krischer currently, only one schema file can be stored per resource type. QuakeML bases on two separate schema files however.
I've tried to fix this here: https://github.com/barsch/seishub.core/blob/master/seishub/core/packages/installer.py#L58

                if env.registry.schemas.get(package_id, resourcetype_id, type):
                    msg = "Skipping Schema /%s/%s - %s"
                    msg = msg % (package_id, resourcetype_id, filename)
                    env.log.debug(msg)
                    continue

by checking against file name of the registered resources:

                to_skip = env.registry.schemas.get(package_id, resourcetype_id,
                                                   type)
                if any([str(x.getResource()).endswith(name) for x in to_skip]):

but then I get an error

WARN: ('Error storing an object.', IntegrityError('(IntegrityError) columns package_id, resourcetype_id, type are not unique',))

so I guess this case is not supported by the current setup. Where to fix this?

IntegrityError is raised because of the current SQL schema definition set in https://github.com/barsch/seishub.core/blob/master/seishub/core/registry/defaults.py#L44 - please note: type can be only one of ['XMLSchema', 'RelaxNG', 'Schematron']

deleting the UniqueConstraint should resolve the issue - however you have to update existing databases as well to make sure you cycle over all valid schemas if appropriate - right now the system expects max. one schema per resourcetype

What is the status here - should we close this as QuakeML is not complete anyway? ;)

blah. whatever.

Closing. We use the RelaxNG schema for validation now and that can be easily merged into one file, see barsch/seishub.plugins.seismology#3.