def _get_new_attribute_name(self, attribute_state: 'ProjectionAttributeState', source_attribute_name: str): current_attribute_name = attribute_state._current_resolved_attribute._resolved_name ordinal = str(attribute_state._ordinal) if attribute_state._ordinal is not None else '' if not self.rename_format: logger.error(self._TAG, self.ctx, 'RenameFormat should be set for this operation to work.') return '' attribute_name = StringUtils._replace(self.rename_format, 'a', source_attribute_name) attribute_name = StringUtils._replace(attribute_name, 'o', ordinal) attribute_name = StringUtils._replace(attribute_name, 'm', current_attribute_name) return attribute_name
def _get_new_attribute_name(self, attribute_state: 'ProjectionAttributeState', source_attribute_name: str): current_attribute_name = attribute_state._current_resolved_attribute._resolved_name ordinal = str(attribute_state._ordinal ) if attribute_state._ordinal is not None else '' if not self.rename_format: logger.error(self.ctx, self._TAG, self.getNewAttributeName.__name__, self.at_corpus_path, CdmLogCode.ERR_PROJ_RENAME_FORMAT_IS_NOT_SET) return '' attribute_name = StringUtils._replace(self.rename_format, 'a', source_attribute_name) attribute_name = StringUtils._replace(attribute_name, 'o', ordinal) attribute_name = StringUtils._replace(attribute_name, 'm', current_attribute_name) return attribute_name
def _replace_wildcard_characters(format: str, projection_owner_name: str, current_PAS: '******'): """ Replace the wildcard character. {a/A} will be replaced with the current attribute name. {m/M} will be replaced with the entity attribute name. {o} will be replaced with the index of the attribute after an array expansion """ if not format: return '' ordinal = str( current_PAS._ordinal) if current_PAS._ordinal is not None else '' original_member_attribute_name = current_PAS._current_resolved_attribute.target.name if isinstance( current_PAS._current_resolved_attribute.target, CdmAttribute) else '' or '' resolved_member_attribute_name = current_PAS._current_resolved_attribute._resolved_name value = StringUtils._replace(format, 'a', projection_owner_name) value = StringUtils._replace(value, 'o', ordinal) value = StringUtils._replace(value, 'mo', original_member_attribute_name) value = StringUtils._replace(value, 'm', resolved_member_attribute_name) return value