Advertisement
Guest User

Untitled

a guest
Nov 16th, 2018
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.07 KB | None | 0 0
  1. public List<ExcepcionPorProductoDetalle> getDetallesByCodigoExcepcion(ExcepcionPorProductoDetalle excepcion) throws Exception {
  2.  
  3. ExcepcionPorProductoDetalle productos = new ExcepcionPorProductoDetalle();
  4. productos.setCodigoExcepcion(excepcion.getCodigoExcepcion());
  5.  
  6. List<ExcepcionPorProductoDetalle> detalles = null;
  7. MapConfig config;
  8. LoadSettings settings = new LoadSettings();
  9. settings.setQueryStatement(LoadListByExcepcion);
  10. settings.setColumns(
  11. ExcepcionPorProductoDetalle.Columnas.CODIGO_ABONADO,
  12. ExcepcionPorProductoDetalle.Columnas.CODIGO_DETALLE,
  13. ExcepcionPorProductoDetalle.Columnas.IDENTIFICADOR,
  14. ExcepcionPorProductoDetalle.Columnas.CODIGO_EXCEPCION,
  15. ExcepcionPorProductoDetalle.Columnas.LIMIT,
  16. ExcepcionPorProductoDetalle.Columnas.OFFSET
  17. );
  18. settings.setPreventTopLoad(false);
  19. settings.setParalelizeMultiPartition(true);
  20.  
  21. if (excepcion.getLineaPdvMaxicarga().getCodigoPuntoVenta() == null) {
  22. config = new MapConfig(ExcepcionPorProductoDetalle.class, null, false);
  23. } else {
  24. config = new MapConfig(ExcepcionPorProductoDetalle.class, DefaultView.class, false);
  25. }
  26.  
  27. int inicio = excepcion.getOffset();
  28. int limit = excepcion.getLimit();
  29.  
  30. List<PartitionInfo> listaParticiones = new ArrayList<PartitionInfo>();
  31. listaParticiones.addAll(cantRegEnParticiones.keySet());
  32. int i = 0;
  33. int registros = 0;
  34.  
  35. /* Se ordenan las particiones por PartitionId, para recorrer las particiones
  36. * en un orden establecido */
  37. listaParticiones.sort(Comparator.comparing(PartitionInfo::getPartitionId));
  38.  
  39. for (i = 0; i < listaParticiones.size(); i++) {
  40. PartitionInfo pI = listaParticiones.get(i);
  41. registros += cantRegEnParticiones.get(pI);
  42. if (registros >= inicio) {
  43. int cantAnterior = registros - cantRegEnParticiones.get(pI);
  44. if (i > 0) {
  45. excepcion.setOffset(inicio - cantAnterior);
  46. }
  47. detalles = super.singlePartitionedLoadList(excepcion, config, pI.getPartitionKey(), settings);
  48. i++;
  49. break;
  50. }
  51. }
  52. /*
  53. * Si la lista de abonados aún no se llenó con la cantidad buscada en el limit
  54. * se consulta en otra particion existente en la tabla.
  55. */
  56. while (detalles.size() < limit && i < listaParticiones.size()) {
  57. // Se trae de la siguiente partición los elementos que faltan;
  58. excepcion.setLimit(limit - detalles.size());
  59. excepcion.setOffset(0);
  60. PartitionInfo pI = listaParticiones.get(i);
  61. List<ExcepcionPorProductoDetalle> restantes = super.singlePartitionedLoadList(excepcion, config, pI.getPartitionKey(), settings);
  62. detalles.addAll(restantes);
  63. i++;
  64. }
  65.  
  66. return detalles;
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement