Electron energy loss spectroscopy in the framework of the discrete dipole approximation