Foren

Custom PaginationLiferayConnector batch Session

thumbnail
Salva Tejero, geändert vor 7 Jahren.

Custom PaginationLiferayConnector batch Session

Junior Member Beiträge: 77 Beitrittsdatum: 13.06.11 Neueste Beiträge
Sorry but I need write this in Spanish to explain better.

Buenas, estoy creando un PaginationLiferayConnector para obtener los contenidos de un CustomAssetListScreenlet. Para obtener los datos necesito llamar a dos servicios distintos y estoy intentando hacerlo con un proceso batch de LRSession



override public func doAddPageRowsServiceCall(session session: LRBatchSession, startRow: Int, endRow: Int) {
		
        let service = MiServicioLabMobile_62 (session: session)

		do {
			try service.getCategoriesWithGroupId(groupId, parentCategoryId: parentCategoryId, start: Int32(startRow), end: Int32 (endRow))
                        try service.getMessagesThreadsByGroupIdAndCategoryId(groupId, categoryId: parentCategoryId,
                                                 start: Int32(startRow),
                                                 end: Int32(endRow))
		}
		catch  {
			// ignore error: the method returns nil (converted to an error) because
			// the request is not actually sent
		}
	}

	override public func doAddRowCountServiceCall(session session: LRBatchSession) {
		
        let service = MiServicioLabMobile_62 (session: session)
		do {
			try service.getCategoriesCountWithGroupId(self.groupId, parentCategoryId: self.parentCategoryId)
                        try service.getMessagesThreadsByGroupIdAndCategoryIdCount(self.groupId, categoryId: self.parentCategoryId)
		}
		catch  {
			// ignore error: the method returns nil (converted to an error) because
			// the request is not actually sent
		}
	}



El problema viene que solo se ejecuta la primera llamada, la segunda de cada uno de los métodos nunca se ejecuta.
¿Cómo hago para que esa LRSession se ejecute como un batch?

Gracias

Regards
thumbnail
Salva Tejero, geändert vor 7 Jahren.

RE: Custom PaginationLiferayConnector batch Session

Junior Member Beiträge: 77 Beitrittsdatum: 13.06.11 Neueste Beiträge
Si incluyo cada llamada en un try/catch diferente obtengo un index of bounds en el momento de construir las celdas



override public func doAddPageRowsServiceCall(session session: LRBatchSession, startRow: Int, endRow: Int) {
		
        let service = MiServicioLabMobile_62 (session: session)

		do {
			
            try service.getCategoriesWithGroupId(self.groupId, parentCategoryId: self.parentCategoryId,                                                 start: Int32(startRow), end: Int32(endRow))
		}
		catch  {
            
			// ignore error: the method returns nil (converted to an error) because
			// the request is not actually sent
		}
        
        do {
            
            try service.getMessagesThreadsByGroupIdAndCategoryId(groupId, categoryId: parentCategoryId,
                                                                 start: Int32(startRow),
                                                                 end: Int32(endRow))
        }
        catch  {
            
            // ignore error: the method returns nil (converted to an error) because
            // the request is not actually sent
        }
	}

	override public func doAddRowCountServiceCall(session session: LRBatchSession) {
		
        let service = MiServicioLabMobile_62 (session: session)
		do {
			try service.getCategoriesCountWithGroupId(self.groupId, parentCategoryId: self.parentCategoryId)
            
		}
		catch  {
            
			// ignore error: the method returns nil (converted to an error) because
			// the request is not actually sent
		}
        
        do {
            
            try service.getMessagesThreadsByGroupIdAndCategoryIdCount(self.groupId, categoryId: self.parentCategoryId)
        }
        catch  {
            
            // ignore error: the method returns nil (converted to an error) because
            // the request is not actually sent
        }
	}


thumbnail
Jose M. Navarro, geändert vor 7 Jahren.

RE: Custom PaginationLiferayConnector batch Session

Regular Member Beiträge: 138 Beitrittsdatum: 24.01.14 Neueste Beiträge
Hola Salva,

El BaseListScreenlet está preparado para que se lancen dos peticiones en modo batch: la primera para obtener el resultado de la página, y la segunda para obtener el count total (y saber si tiene que seguir pidiendo páginas).

En tu caso estás lanzando 4 peticiones: dos para datos y dos para cuentas de registros, y eso no se soporta ahora mismo.

A lo mejor puedes sobrescribir algún método de BaseListScreenlet para soportarlo (mañana te lo miro, ahora no sabría decirte), pero si nos dices exactamente tu caso de uso, podemos pensar una solución más general y elegante (y la priorizamos para meterla de cara a la siguiente release)

Saludo!
thumbnail
Salva Tejero, geändert vor 7 Jahren.

RE: Custom PaginationLiferayConnector batch Session

Junior Member Beiträge: 77 Beitrittsdatum: 13.06.11 Neueste Beiträge
Buenas, la idea que tengo es montar una vista muy parecida al foro de Liferay. Te lo adjunto en la captura.

Quiero mostrar en el mismo AssetListScreenlet por una lado las categorías de un foro junto con el primer o último mensaje de cada hilo dentro de una categoría padre.
¿Cómo lo ves?

Me gustaría enseñaros lo que estamos haciendo por si lo veis interesante.
thumbnail
Jose M. Navarro, geändert vor 7 Jahren.

RE: Custom PaginationLiferayConnector batch Session

Regular Member Beiträge: 138 Beitrittsdatum: 24.01.14 Neueste Beiträge
Muy interesante!

Primero intenta crear un screenlet de lista para mostrar las categorías. Hazlo a partir de BaseListScreenlet (no de AssetListScreenlet). Hay un tutorial para eso.

Después tienes que conseguir obtener el primer o último mensaje de cada categoría. BaseListScreenlet no soporta esto, pero podemos pensar algún cambio para que lo soporte.

Otra opción es que hagas tu propio servicio remoto que retorne todo lo que necesites: una lista de elementos, donde cada elemento tiene los datos de la categoría y los datos del último/primer mensaje (este sería el modo soportado actualmente).

Saludo!
thumbnail
Salva Tejero, geändert vor 7 Jahren.

RE: Custom PaginationLiferayConnector batch Session

Junior Member Beiträge: 77 Beitrittsdatum: 13.06.11 Neueste Beiträge
Gracias, voy a hacer la opción de generar un servicio que me devuelva toda la info ya que ya tenía hecho el que me devuelve el primer o último mensaje de cada thread.