Riemann Criterion for Integrability