Muestra las diferencias entre dos versiones de la página.
| Ambos lados, revisión anterior Revisión previa Próxima revisión | Revisión previa | ||
|
plugins:ejemploplugin [2016/11/18 17:31] fcristina [Menu contextual en campo Entidad Comercial] |
plugins:ejemploplugin [2021/07/02 12:37] (actual) fcristina [Implementación de clases del package ar.com.disytel.plugin.reportProvider] |
||
|---|---|---|---|
| Línea 154: | Línea 154: | ||
| Notar que la modificación de la superclase no presenta problema alguno: Esta es la misma clase del ejemplo anterior (el cual implementaba el método **preBeforeSave()**), | Notar que la modificación de la superclase no presenta problema alguno: Esta es la misma clase del ejemplo anterior (el cual implementaba el método **preBeforeSave()**), | ||
| + | |||
| + | |||
| + | ==== Modificacion de las opciones de acciones de documento ==== | ||
| + | |||
| + | Es posible incorporar o eliminar acciones sobre la lista de posibles acciones sobre un documento en particular. | ||
| + | |||
| + | Dicha interface tiene simplemente un método llamando **customizeValidActions()** que recibe la información relevante del documento, las opciones actuales, etc. Dicho método debe retornar el indice actual que referencia al total de opciones válidas. | ||
| + | |||
| + | Se cuenta además con la clase **DocOptionsUtils**, | ||
| + | |||
| + | NOTA: Esta funcionalidad también es válida para una clase que extienda de PO (sin utilizar lógica de plugins), siempre y cuando implemente **DocOptions** y corresponda con el documento que se quiere procesar. | ||
| + | |||
| + | Ejemplo: se requiere modificar las opciones de acción para un Payment. | ||
| + | |||
| + | <code java> | ||
| + | package org.libertya.ejemplo.model | ||
| + | |||
| + | import java.util.Properties; | ||
| + | |||
| + | import org.openXpertya.model.PO; | ||
| + | import org.openXpertya.plugin.MPluginDocAction; | ||
| + | import org.openXpertya.process.DocAction; | ||
| + | import org.openXpertya.process.DocOptions; | ||
| + | import org.openXpertya.util.DocOptionsUtils; | ||
| + | |||
| + | public class MPayment extends MPluginDocAction implements DocOptions { | ||
| + | |||
| + | public MPayment(PO po, Properties ctx, String trxName, String aPackage) { | ||
| + | super(po, ctx, trxName, aPackage); | ||
| + | // TODO Auto-generated constructor stub | ||
| + | } | ||
| + | |||
| + | @Override | ||
| + | public int customizeValidActions(String docStatus, Object processing, | ||
| + | String orderType, String isSOTrx, int AD_Table_ID, | ||
| + | String[] docAction, String[] options, int index) { | ||
| + | |||
| + | // Si se esta completando el documento, incorporar la opción de WaitComplete | ||
| + | if (DocAction.ACTION_Complete.equals(docAction[0])) { | ||
| + | index = DocOptionsUtils.addAction(options, | ||
| + | } else { | ||
| + | // En caso contrario permitir invalidar el documento | ||
| + | index = DocOptionsUtils.addAction(options, | ||
| + | } | ||
| + | // En todos los casos, quitar la accion ReActivate | ||
| + | index = DocOptionsUtils.removeAction(options, | ||
| + | return index; | ||
| + | } | ||
| + | } | ||
| + | |||
| + | </ | ||
| Línea 431: | Línea 482: | ||
| - | === Soporte para redefinición | + | ===== Implementación |
| - | Es posible | + | A partir de la revision r2968, en caso de necesitar |
| - | Dicha interface tiene simplemente un método llamando **customizeValidActions()** | + | Es importante |
| - | Se cuenta además con la clase **DocOptionsUtils**, la cual simplifica la tarea de incorporar o eliminar acciones. | + | * Debe tener igual nombre de clase que la existente en Libertya CORE |
| + | | ||
| - | NOTA: Esta funcionalidad también es válida para una clase que extienda de PO (sin utilizar lógica de plugins), siempre y cuando implemente **DocOptions** y corresponda con el documento que se quiere procesar. | + | Este método inyecta dos parámetros: |
| - | Ejemplo: se requiere modificar las opciones de acción para un Payment. La clase tiene que ser **MPayment** y debe implementar **DocOptions**: | + | * **MJasperReport report**: Reporte Jasper al cual podremos incorporarle nuevos parámetros previo a su rellenado. |
| + | * **PO po**: El objeto base con la información a imprimir. | ||
| + | |||
| + | Por ejemplo, suponiendo | ||
| <code java> | <code java> | ||
| - | package | + | package |
| - | + | import | |
| - | import | + | import org.openXpertya.model.MInvoice; |
| import org.openXpertya.model.PO; | import org.openXpertya.model.PO; | ||
| - | import org.openXpertya.plugin.MPluginDocAction; | + | import org.openXpertya.plugin.report.ReportProviderInterface; |
| - | import org.openXpertya.process.DocAction; | + | |
| - | import org.openXpertya.process.DocOptions; | + | |
| - | import org.openXpertya.util.DocOptionsUtils; | + | |
| - | + | ||
| - | public class MPayment extends MPluginDocAction implements DocOptions { | + | |
| - | + | ||
| - | public MPayment(PO po, Properties ctx, String trxName, String aPackage) { | + | |
| - | super(po, ctx, trxName, aPackage); | + | |
| - | // TODO Auto-generated constructor stub | + | |
| - | } | + | |
| + | public class LaunchInvoice implements ReportProviderInterface { | ||
| + | |||
| @Override | @Override | ||
| - | public | + | public |
| - | String orderType, String isSOTrx, int AD_Table_ID, | + | // Agregar los parámetros que necesitemos |
| - | String[] docAction, String[] options, int index) { | + | report.addParameter(" |
| - | + | report.addParameter(" | |
| - | // Si se esta completano el documento, incorporar la opción de WaitComplete | + | |
| - | if (DocAction.ACTION_Complete.equals(docAction[0])) { | + | |
| - | index = DocOptionsUtils.addAction(options, | + | |
| - | } else { | + | |
| - | // En caso contrario permitir invalidar el documento | + | |
| - | index = DocOptionsUtils.addAction(options, DocAction.ACTION_Invalidate, | + | |
| - | } | + | |
| - | // En todos los casos, quitar la accion ReActivate | + | |
| - | index = DocOptionsUtils.removeAction(options, DocAction.ACTION_ReActivate, | + | |
| - | return index; | + | |
| } | } | ||
| } | } | ||
| + | </ | ||
| + | |||
| - | </ | ||