# Path: server/materialsdatabank/server/models/base.py
# class BaseAccessControlledModel(AccessControlledModel):
#     types = {}
# 
#     def find(self, dataset_id, offset=0, limit=0, timeout=None,
#              fields=None, sort=None):
# 
#         query = {
#             'datasetId': dataset_id
#         }
# 
#         return super(BaseAccessControlledModel, self).find(query, offset, limit,
#                                                            timeout, fields, sort)
#     def validate_list(self, value, func):
#         if not isinstance(value, list):
#             raise ValidationException('Invalid value for list type')
# 
#         return [func(x) for x in value]
# 
#     def validate(self, doc):
#         for k in doc.keys():
#             if k in self.types:
#                 doc[k] = self.types[k](doc[k])
# 
#         return doc


from .base import BaseAccessControlledModel
from girder.constants import AccessType
from girder.models.group import Group
from girder.models.item import Item
from girder.models.file import File
from bson.objectid import ObjectId
        }

        self.setPublic(reconstruction, public)
        curator = list(Group().find({
            'name': 'curator',
        }))
        if len(curator) > 0:
            self.setGroupAccess(reconstruction, group=curator[0], level=AccessType.ADMIN)

        if user:
            reconstruction['userId'] = user['_id']
            self.setUserAccess(reconstruction, user=user, level=AccessType.ADMIN)
        else:
            reconstruction['userId'] = None

        return self.save(reconstruction)

    def update(self, reconstruction, reconstruction_updates, user=None, public=None):
        query = {
            '_id': reconstruction['_id']
        }

        reconstruction_updates = self.validate(reconstruction_updates)

        updates = {}

        mutable_props = ['resolution', 'bFactor', 'hFactor',
                         'zDirection', 'axisConvention']
        for prop in reconstruction_updates:
            if prop in mutable_props:

# Path: server/materialsdatabank/server/models/base.py
# class BaseAccessControlledModel(AccessControlledModel):
#     types = {}
# 
#     def find(self, dataset_id, offset=0, limit=0, timeout=None,
#              fields=None, sort=None):
# 
#         query = {
#             'datasetId': dataset_id
#         }
# 
#         return super(BaseAccessControlledModel, self).find(query, offset, limit,
#                                                            timeout, fields, sort)
#     def validate_list(self, value, func):
#         if not isinstance(value, list):
#             raise ValidationException('Invalid value for list type')
# 
#         return [func(x) for x in value]
# 
#     def validate(self, doc):
#         for k in doc.keys():
#             if k in self.types:
#                 doc[k] = self.types[k](doc[k])
# 
#         return doc


# Path: server/materialsdatabank/server/models/reconstruction.py
from .base import BaseAccessControlledModel
from girder.constants import AccessType
from girder.models.group import Group
from girder.models.item import Item
from girder.models.file import File
from bson.objectid import ObjectId

        }

        self.setPublic(reconstruction, public)
        curator = list(Group().find({
            'name': 'curator',
        }))
        if len(curator) > 0:
            self.setGroupAccess(reconstruction, group=curator[0], level=AccessType.ADMIN)

        if user:
            reconstruction['userId'] = user['_id']
            self.setUserAccess(reconstruction, user=user, level=AccessType.ADMIN)
        else:
            reconstruction['userId'] = None

        return self.save(reconstruction)

    def update(self, reconstruction, reconstruction_updates, user=None, public=None):
        query = {
            '_id': reconstruction['_id']
        }

        reconstruction_updates = self.validate(reconstruction_updates)

        updates = {}

        mutable_props = ['resolution', 'bFactor', 'hFactor',
                         'zDirection', 'axisConvention']
        for prop in reconstruction_updates:
            if prop in mutable_props:

                updates.setdefault('$set', {})[prop] = reconstruction_updates[prop]