A mayoral candidate in the German city of Cologne has been stabbed by a man claiming to be angry over the country's refugee policies.