def compare(self, other, level): """ :type other: cts_core.metadata.model.annotation.Annotation :rtype: int """ cmp = Comparator(level) cmp.message_both("Annotation: {name}".format(name=self.term)) attributes = set(self.annotations_attributes_list.keys()) attributes_other = set(other.annotations_attributes_list.keys()) all = sorted(list(attributes.union(attributes_other))) both = attributes.intersection(attributes_other) fmt = " {name}={value}" for attribute in all: if attribute in both: if self.annotations_attributes_list[attribute] != other.annotations_attributes_list[attribute]: cmp.set_not_equal() cmp.message_left(fmt.format(name=attribute, value=self.annotations_attributes_list[attribute])) cmp.message_right(fmt.format(name=attribute, value=other.annotations_attributes_list[attribute])) elif attribute in attributes: cmp.set_not_equal() cmp.message_left(fmt.format(name=attribute, value=self.annotations_attributes_list[attribute])) cmp.message_right('?') else: cmp.set_not_equal() cmp.message_left('?') cmp.message_right(fmt.format(name=attribute, value=other.annotations_attributes_list[attribute])) return cmp
def compare(self, other, level): """ :type other: cts_core.metadata.model.property.Property :rtype: int """ cmp = Comparator(level) cmp.message_both("Property: {name}".format(name=self.name)) return cmp.merge_result(self.compare_type(other, level + 1), self.compare_nullable(other, level + 1), self.compare_is_required(other, level + 1), self.compare_patch_status(other, level + 1), self.compare_annotations(other, level + 1))
def compare(self, other): """ :type other: cts_core.metadata.model.metadata_types.complex_type.ComplexType :rtype: int """ cmp = Comparator() cmp.message_both("Type: {type}".format(type=self.name)) cmp.merge_result( self.compare_base_type(other, level=1), self.compare_properties(other, level=1), self.compare_annotations(other, level=1), self.compare_dynamic_property_patterns(other, level=1)) cmp.separator() return cmp
def compare(self, other): """ :type other: cts_core.metadata.model.entity.Entity :rtype: int """ cmp = Comparator(level=0) cmp.message_both("Entity: {entity}".format(entity=self.name)) cmp.merge_result( self.compare_base_type(other, level=1), self.compare_properties(other, level=1), self.compare_annotations(other, level=1), self.compare_dynamic_property_patterns(other, level=1)) cmp.separator() return cmp