Exemple #1
0
    def from_data(
            ctx: 'CdmCorpusContext', data: 'OperationCombineAttributes'
    ) -> 'CdmOperationCombineAttributes':
        if not data:
            return None

        combine_attributes_op = ctx.corpus.make_object(
            CdmObjectType.OPERATION_COMBINE_ATTRIBUTES_DEF)

        if data.type and not StringUtils.equals_with_ignore_case(
                data.type,
                OperationTypeConvertor._operation_type_to_string(
                    CdmOperationType.COMBINE_ATTRIBUTES)):
            logger.error(
                _TAG, ctx,
                '$type {} is invalid for this operation.'.format(data.type))
        else:
            combine_attributes_op.type = CdmOperationType.COMBINE_ATTRIBUTES

        if data.explanation:
            combine_attributes_op.explanation = data.explanation

        combine_attributes_op.take = data.take
        combine_attributes_op.merge_into = utils.create_attribute(
            ctx, data.mergeInto)

        return combine_attributes_op
Exemple #2
0
    def from_data(
        ctx: 'CdmCorpusContext', data: 'OperationAddSupportingAttribute'
    ) -> 'CdmOperationAddSupportingAttribute':
        if not data:
            return None

        add_supporting_attribute_op = ctx.corpus.make_object(
            CdmObjectType.OPERATION_ADD_SUPPORTING_ATTRIBUTE_DEF)

        if data.type and not StringUtils.equals_with_ignore_case(
                data.type,
                OperationTypeConvertor._operation_type_to_string(
                    CdmOperationType.ADD_SUPPORTING_ATTRIBUTE)):
            logger.error(
                _TAG, ctx,
                '$type {} is invalid for this operation.'.format(data.type))
        else:
            add_supporting_attribute_op.type = CdmOperationType.ADD_SUPPORTING_ATTRIBUTE

        if data.explanation:
            add_supporting_attribute_op.explanation = data.explanation

        if data.supportingAttribute:
            add_supporting_attribute_op.supporting_attribute = utils.create_attribute(
                ctx, data.supportingAttribute)

        return add_supporting_attribute_op
    def from_data(ctx: 'CdmCorpusContext', data: 'OperationAddTypeAttribute') -> 'CdmOperationAddTypeAttribute':
        if not data:
            return None

        add_type_attribute_op = OperationBasePersistence.from_data(ctx,
            CdmObjectType.OPERATION_ADD_TYPE_ATTRIBUTE_DEF, data)  # type: CdmOperationAddTypeAttribute
        add_type_attribute_op.type_attribute = utils.create_attribute(ctx, data.typeAttribute)

        return add_type_attribute_op
Exemple #4
0
    def from_data(
        ctx: 'CdmCorpusContext', data: 'OperationAddSupportingAttribute'
    ) -> 'CdmOperationAddSupportingAttribute':
        if not data:
            return None

        add_supporting_attribute_op = OperationBasePersistence.from_data(
            ctx, CdmObjectType.OPERATION_ADD_SUPPORTING_ATTRIBUTE_DEF,
            data)  # type: CdmOperationAddSupportingAttribute
        add_supporting_attribute_op.supporting_attribute = utils.create_attribute(
            ctx, data.supportingAttribute)

        return add_supporting_attribute_op
Exemple #5
0
    def from_data(
        ctx: 'CdmCorpusContext', data: 'OperationReplaceAsForeignKey'
    ) -> 'CdmOperationReplaceAsForeignKey':
        if not data:
            return None

        replace_as_foreign_key_op = OperationBasePersistence.from_data(
            ctx, CdmObjectType.OPERATION_REPLACE_AS_FOREIGN_KEY_DEF,
            data)  # type: CdmOperationReplaceAsForeignKey
        replace_as_foreign_key_op.reference = data.reference
        replace_as_foreign_key_op.replace_with = utils.create_attribute(
            ctx, data.replaceWith)

        return replace_as_foreign_key_op
Exemple #6
0
    def from_data(
            ctx: 'CdmCorpusContext', data: 'OperationCombineAttributes'
    ) -> 'CdmOperationCombineAttributes':
        if not data:
            return None

        combine_attributes_op = OperationBasePersistence.from_data(
            ctx, CdmObjectType.OPERATION_COMBINE_ATTRIBUTES_DEF,
            data)  # type: CdmOperationCombineAttributes
        combine_attributes_op.select = data.select
        combine_attributes_op.merge_into = utils.create_attribute(
            ctx, data.mergeInto)

        return combine_attributes_op