'Compare the last saved metadata for each tool in the repository with the new metadata in
self.metadata_dict to determine if a new repository_metadata table record is required, or if
the last saved metadata record can be updated instead.'

def new_tool_metadata_required(self, repository_metadata):

    if ('tools' in self.metadata_dict):
        if repository_metadata:
            metadata = repository_metadata.metadata
            if metadata:
                if ('tools' in metadata):
                    saved_tool_ids = []
                    for new_tool_metadata_dict in self.metadata_dict['tools']:
                        for saved_tool_metadata_dict in metadata['tools']:
                            if (saved_tool_metadata_dict['id'] not in saved_tool_ids):
                                saved_tool_ids.append(saved_tool_metadata_dict['id'])
                            if (new_tool_metadata_dict['id'] == saved_tool_metadata_dict['id']):
                                if (new_tool_metadata_dict['version'] != saved_tool_metadata_dict['version']):
                                    return True
                    for new_tool_metadata_dict in self.metadata_dict['tools']:
                        if (new_tool_metadata_dict['id'] not in saved_tool_ids):
                            return True
                    return False
                else:
                    return False
            else:
                return False
        else:
            return True
    return False
