def __init__(self, ctx: 'CdmCorpusContext', name: str) -> None:
        super().__init__(ctx, name)

        self._TAG = CdmLocalEntityDeclarationDefinition.__name__

        self.last_child_file_modified_time = None  # type: Optional[datetime]

        self.last_file_modified_time = None  # type: Optional[datetime]

        self.last_file_status_check_time = None  # type: Optional[datetime]

        # Internal
        self._data_partitions = CdmCollection(self.ctx, self,
                                              CdmObjectType.DATA_PARTITION_DEF)
        self._data_partition_patterns = CdmCollection(
            self.ctx, self, CdmObjectType.DATA_PARTITION_PATTERN_DEF)
예제 #2
0
    def __init__(self, ctx: 'CdmCorpusContext', name: str,
                 extends_entity: Optional['CdmEntityReference']) -> None:
        super().__init__(ctx)

        # the entity attribute Context.
        self.attribute_context = None  # type: Optional[CdmAttributeContext]

        # the entity entity name.
        self.entity_name = name  # type: str

        # the entity extended by this entity.
        self.extends_entity = extends_entity  # type: Optional[CdmEntityReference]

        # the resolution guidance for attributes taken from the entity extended by this entity
        self.extends_entity_resolution_guidance = None  # type: Optional[CdmAttributeResolutionGuidanceDefinition]

        # --- internal ---
        self._rasb = None  # type: Optional[ResolvedAttributeSetBuilder]
        self._resolving_entity_references = False  # type: bool
        self._attributes = CdmCollection(
            self.ctx, self,
            CdmObjectType.TYPE_ATTRIBUTE_DEF)  # type: CdmCollection
        self._ttpm = None  # type: Optional[TraitToPropertyMap]

        self._TAG = CdmEntityDefinition.__name__
예제 #3
0
    def __init__(self, ctx: 'CdmCorpusContext', name: str) -> None:
        super().__init__(ctx)

        # the attribute group name.
        self.attribute_group_name = name  # type: str

        # the attribute group context.
        self.attribute_context = None  # type: Optional[CdmAttributeContextReference]

        # Internal

        self._members = CdmCollection(self.ctx, self, CdmObjectType.TYPE_ATTRIBUTE_DEF)  # type: CdmCollection[CdmAttributeItem]
예제 #4
0
    def from_data(ctx: CdmCorpusContext, data: AttributeContext) -> Optional[CdmAttributeContext]:
        if data is None:
            return None

        attribute_context = ctx.corpus.make_object(CdmObjectType.ATTRIBUTE_CONTEXT_DEF, data.name)
        attribute_context.type = map_type_name_to_enum[data.type]

        if data.get('parent'):
            attribute_context.parent = AttributeContextReferencePersistence.from_data(ctx, data.get('parent'))

        if data.get('explanation'):
            attribute_context.explanation = data.get('explanation')

        if data.get('definition'):
            if attribute_context.type == CdmAttributeContextType.ENTITY or attribute_context.type == CdmAttributeContextType.ENTITY_REFERENCE_EXTENDS:
                attribute_context.definition = EntityReferencePersistence.from_data(ctx, data.definition)
            elif attribute_context.type == CdmAttributeContextType.ATTRIBUTE_GROUP:
                attribute_context.definition = AttributeGroupReferencePersistence.from_data(ctx, data.definition)
            elif attribute_context.type == CdmAttributeContextType.ADDED_ATTRIBUTE_SUPPORTING \
                    or attribute_context.type == CdmAttributeContextType.ADDED_ATTRIBUTE_IDENTITY \
                    or attribute_context.type == CdmAttributeContextType.ADDED_ATTRIBUTE_EXPANSION_TOTAL \
                    or attribute_context.type == CdmAttributeContextType.ADDED_ATTRIBUTE_SELECTED_TYPE \
                    or attribute_context.type == CdmAttributeContextType.ATTRIBUTE_DEFINITION:
                attribute_context.definition = AttributeReferencePersistence.from_data(ctx, data.definition)

        # I know the trait collection names look wrong. but I wanted to use the def baseclass
        utils.add_list_to_cdm_collection(attribute_context.exhibits_traits,
                                         utils.create_trait_reference_array(ctx, data.get('appliedTraits')))

        if data.get('contents'):
            if attribute_context.contents is None:
                attribute_context.contents = []

            for elem in data.contents:
                if isinstance(elem, str):
                    attribute_context.contents.append(AttributeReferencePersistence.from_data(ctx, elem))
                else:
                    attribute_context.contents.append(AttributeContextPersistence.from_data(ctx, elem))

        if data.get('lineage'):
            if attribute_context.lineage is None:
                attribute_context.lineage = CdmCollection(ctx, attribute_context, CdmObjectType.ATTRIBUTE_CONTEXT_REF)

            for elem in data.lineage:
                attribute_context.lineage.append(AttributeContextReferencePersistence.from_data(ctx, elem))

        return attribute_context
예제 #5
0
파일: utils.py 프로젝트: rt112000/CDM
def add_list_to_cdm_collection(cdm_collection: CdmCollection,
                               the_list: List) -> None:
    """Adds all elements of a list to a CdmCollection"""
    if cdm_collection is not None and the_list is not None:
        for element in the_list:
            cdm_collection.append(element)