Esempio n. 1
0
    def processAccessible(self, encode, data):
        '''
        Process the accessible paths for the provided data.
        '''
        assert isinstance(encode, EncodeModel), 'Invalid encode model %s' % encode
        assert isinstance(data, DataModel), 'Invalid data model %s' % data

        if data.accessibleIsProcessed: return
        data.accessibleIsProcessed = True
        if data.accessiblePath is None: return
        assert isinstance(data.accessiblePath, Path), 'Invalid path %s' % data.accessiblePath

        #TODO: Make sure when placing the accessible paths that there isn't already an accessible path
        # that already returns the inherited model see the example for MetaData and ImageData in relation
        # with MetaInfo and ImageInfo
        accessible = list(findGetAllAccessible(data.accessiblePath))
        # These paths will get updated in the encode model when the data model path is updated
        # because they are extended from the base path.
        assert isinstance(encode.modelType, TypeModel)
        for parentType in encode.modelType.parents():
            parentPath = findGetModel(data.accessiblePath, parentType)
            if parentPath:
                accessiblePaths = findGetAllAccessible(parentPath)
                if accessiblePaths:
                    data.modelPaths[parentType] = parentPath
                    accessible.extend(accessiblePaths)

        if accessible:
            data.accessible = OrderedDict()
            for acc in accessible:
                pathName = pathLongName(acc)
                if pathName not in data.accessible: data.accessible[pathName] = acc
Esempio n. 2
0
    def processAccessible(self, encode, data):
        '''
        Process the accessible paths for the provided data.
        '''
        assert isinstance(encode, EncodeModel), 'Invalid encode model %s' % encode
        assert isinstance(data, DataModel), 'Invalid data model %s' % data

        if data.accessibleIsProcessed: return
        data.accessibleIsProcessed = True
        if data.accessiblePath is None: return
        assert isinstance(data.accessiblePath, Path), 'Invalid path %s' % data.accessiblePath

        # TODO: Make sure when placing the accessible paths that there isn't already an accessible path
        # that already returns the inherited model see the example for MetaData and ImageData in relation
        # with MetaInfo and ImageInfo
        accessible = list(findGetAllAccessible(data.accessiblePath))
        # These paths will get updated in the encode model when the data model path is updated
        # because they are extended from the base path.
        assert isinstance(encode.modelType, TypeModel)
        for parentType in encode.modelType.parents():
            parentPath = findGetModel(data.accessiblePath, parentType)
            if parentPath:
                accessiblePaths = findGetAllAccessible(parentPath)
                if accessiblePaths:
                    data.modelPaths[parentType] = parentPath
                    accessible.extend(accessiblePaths)

        if accessible:
            data.accessible = OrderedDict()
            for acc in accessible:
                pathName = pathLongName(acc)
                if pathName not in data.accessible: data.accessible[pathName] = acc
Esempio n. 3
0
    def createDataModel(self, encode, path, showAccessible, inCollection):
        '''
        Create the data model for the provided encode model.
        '''
        assert isinstance(encode, EncodeModel), 'Invalid encode model %s' % encode

        data = DataModel()
        if path:
            assert isinstance(path, Path), 'Invalid request path %s' % path
            data.path = findGetModel(path, encode.modelType)
            data.modelPaths[encode.modelType] = data.path
            if inCollection: data.accessiblePath = data.path
            else: data.accessiblePath = path
            if showAccessible: self.processAccessible(encode, data)

        for nameProp, encodeProp in encode.properties.items():
            if isinstance(encodeProp, EncodeModel):
                assert isinstance(encodeProp, EncodeModel)
                data.datas[nameProp] = self.createDataModel(encodeProp, findGetModel(path, encodeProp.modelType),
                                                            False, False)

        return data
Esempio n. 4
0
    def createDataModel(self, encode, path, showAccessible, inCollection):
        '''
        Create the data model for the provided encode model.
        '''
        assert isinstance(encode, EncodeModel), 'Invalid encode model %s' % encode

        data = DataModel()
        if path:
            assert isinstance(path, Path), 'Invalid request path %s' % path
            data.path = findGetModel(path, encode.modelType)
            data.modelPaths[encode.modelType] = data.path
            if inCollection: data.accessiblePath = data.path
            else: data.accessiblePath = path
            if showAccessible: self.processAccessible(encode, data)

        for nameProp, encodeProp in encode.properties.items():
            if isinstance(encodeProp, EncodeModel):
                assert isinstance(encodeProp, EncodeModel)
                data.datas[nameProp] = self.createDataModel(encodeProp, findGetModel(path, encodeProp.modelType),
                                                            False, False)

        return data