Search in sources :

Example 26 with ProcessInfo

use of org.compiere.process.ProcessInfo in project lar_361 by comitsrl.

the class LAR_Validator method anularOperación.

// Marcos Zúñiga -end
/**
 * Anular toda la operación de venta (OV - Recibos - Factura y Remito).
 *
 * @param invoice
 */
private void anularOperación(final MInvoice invoice, final String documentNo, final String fiscalreceiptnumber) {
    SwingWorker worker = new SwingWorker() {

        private String errorMsg = null;

        @Override
        public Object construct() {
            // Crea parámetro que se enviará al proceso
            final ProcessInfoParameter param = new ProcessInfoParameter("C_Order_ID", invoice.getC_Order_ID(), "", "", "");
            // Crea información del proceso
            int AD_Process_ID = 3000037;
            final ProcessInfo pi = new ProcessInfo("PosOrderGlobalVoiding", AD_Process_ID);
            pi.setParameter(new ProcessInfoParameter[] { param });
            // Crea una instancia de proceso (para registro y
            // sincronizacion)
            final MPInstance pinstance = new MPInstance(Env.getCtx(), 0, null);
            pinstance.setAD_Process_ID(AD_Process_ID);
            pinstance.setRecord_ID(0);
            pinstance.save();
            // Conecta el proceso con la instancia de proceso
            pi.setAD_PInstance_ID(pinstance.get_ID());
            // Crea el proceso a ejecutar
            final PosOrderGlobalVoiding process = new PosOrderGlobalVoiding();
            log.info("Iniciando proceso global de anulaci\u00f3n");
            return process.startProcess(Env.getCtx(), pi, null);
        }

        // construct
        @Override
        public void finished() {
            boolean success = (Boolean) getValue();
            if (!success) {
                ADialog.error(0, Env.getWindow(0), errorMsg);
            } else {
                ADialog.warn(0, Env.getWindow(0), "Número de Documento " + documentNo + " duplicado.", "Operación anulada.");
                // Corregir Secuencia.
                MSequence.setFiscalDocTypeNextNroComprobante(invoice.getC_DocType().getDefiniteSequence_ID(), Integer.parseInt(fiscalreceiptnumber) + 1, null);
            }
        }
    };
    // new SwingWorker
    worker.start();
    worker.finished();
}
Also used : ProcessInfoParameter(org.compiere.process.ProcessInfoParameter) PosOrderGlobalVoiding(ar.com.ergio.process.PosOrderGlobalVoiding) MPInstance(org.compiere.model.MPInstance) SwingWorker(org.compiere.apps.SwingWorker) ProcessInfo(org.compiere.process.ProcessInfo)

Example 27 with ProcessInfo

use of org.compiere.process.ProcessInfo in project lar_361 by comitsrl.

the class LAR_Callouts method copyLines.

/**
 * Callout used in Source_Invoice_ID field (C_Invoice table), in order to copy
 * lines of source invoice
 */
public String copyLines(final Properties ctx, final int windowNo, final GridTab mTab, final GridField mField, Object value) throws AdempiereSystemError {
    Integer Source_Invoice_ID = (Integer) value;
    if (Source_Invoice_ID == null || Source_Invoice_ID.intValue() == 0)
        return "";
    if (!ADialog.ask(windowNo, Env.getWindow(windowNo), "¿Copiar las líneas desde la Factura?"))
        return "";
    // Config CopyFromInvoice process (AD_Process_ID=210)
    int AD_Process_ID = 210;
    int C_Invoice_ID = (Integer) mTab.getValue("C_Invoice_ID");
    MPInstance instance = new MPInstance(Env.getCtx(), AD_Process_ID, 0);
    if (!instance.save())
        return Msg.getMsg(Env.getCtx(), "ProcessNoInstance");
    ProcessInfo pi = new ProcessInfo("", AD_Process_ID);
    pi.setRecord_ID(C_Invoice_ID);
    pi.setAD_PInstance_ID(instance.getAD_PInstance_ID());
    // Add Parameters
    MPInstancePara param = new MPInstancePara(instance, 10);
    param.setParameter("C_Invoice_ID", Source_Invoice_ID);
    if (!param.save())
        return Msg.getMsg(Env.getCtx(), "ParameterMissing");
    // TODO - Creates a dummy asyc control process thread (review)
    final ASyncProcess asyncProcess = new ASyncProcess() {

        private JFrame component = Env.getWindow(windowNo);

        /**
         * {@inheritDoc}
         */
        public void lockUI(ProcessInfo pi) {
            component.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
            component.setEnabled(false);
        }

        // lockUI
        /**
         * {@inheritDoc}
         */
        public void unlockUI(ProcessInfo pi) {
            component.setEnabled(true);
            component.setCursor(Cursor.getDefaultCursor());
        }

        // unlockUI
        /**
         * {@inheritDoc}
         */
        public boolean isUILocked() {
            return component.isEnabled();
        }

        // isUILocked
        /**
         * {@inheritDoc}
         */
        public void executeASync(ProcessInfo pi) {
        }
    };
    // Execute process
    ProcessCtl worker = new ProcessCtl(asyncProcess, windowNo, pi, null);
    worker.run();
    return "";
}
Also used : MPInstancePara(org.compiere.model.MPInstancePara) MPInstance(org.compiere.model.MPInstance) JFrame(javax.swing.JFrame) ProcessCtl(org.compiere.apps.ProcessCtl) ASyncProcess(org.compiere.util.ASyncProcess) ProcessInfo(org.compiere.process.ProcessInfo)

Example 28 with ProcessInfo

use of org.compiere.process.ProcessInfo in project adempiere by adempiere.

the class InitialClientSetup method main.

public static void main(String[] args) {
    Adempiere.startupEnvironment(false);
    CLogMgt.setLevel(Level.CONFIG);
    String propFileName = Adempiere.getAdempiereHome() + File.separatorChar + "clientsetup.properties";
    if (args.length > 0)
        propFileName = args[0];
    ProcessInfo pi = new ProcessInfo("Initial Client Setup", 53161);
    pi.setAD_Client_ID(0);
    pi.setAD_User_ID(100);
    Properties prop = new Properties();
    try {
        prop.load(new FileInputStream(propFileName));
        pi.addParameter("ClientName", prop.getProperty("ClientName"), prop.getProperty("ClientName"));
        pi.addParameter("OrgValue", prop.getProperty("OrgValue"), prop.getProperty("OrgValue"));
        pi.addParameter("OrgName", prop.getProperty("OrgName"), prop.getProperty("OrgName"));
        pi.addParameter("AdminUserName", prop.getProperty("AdminUserName"), prop.getProperty("AdminUserName"));
        pi.addParameter("NormalUserName", prop.getProperty("NormalUserName"), prop.getProperty("NormalUserName"));
        if (prop.getProperty("CurrencyCode") != null) {
            MCurrency currency = MCurrency.get(Env.getCtx(), prop.getProperty("CurrencyCode"));
            if (currency != null)
                pi.addParameter("C_Currency_ID", currency.getC_Currency_ID(), currency.getISO_Code());
        }
        if (prop.getProperty("CountryCode") != null) {
            MCountry country = MCountry.get(Env.getCtx(), prop.getProperty("CountryCode"));
            if (country != null)
                pi.addParameter("C_Country_ID", country.getC_Country_ID(), country.getCountryCode());
        }
        pi.addParameter("C_Region_ID", prop.getProperty("C_Region_ID"), prop.getProperty("C_Region_ID"));
        pi.addParameter("CityName", prop.getProperty("CityName"), prop.getProperty("CityName"));
        pi.addParameter("C_City_ID", prop.getProperty("C_City_ID"), prop.getProperty("C_City_ID"));
        pi.addParameter("Postal", prop.getProperty("Postal"), prop.getProperty("Postal"));
        pi.addParameter("Address1", prop.getProperty("Address1"), prop.getProperty("Address1"));
        pi.addParameter("IsUseBPDimension", prop.getProperty("IsUseBPDimension"), prop.getProperty("IsUseBPDimension"));
        pi.addParameter("IsUseProductDimension", prop.getProperty("IsUseProductDimension"), prop.getProperty("IsUseProductDimension"));
        pi.addParameter("IsUseProjectDimension", prop.getProperty("IsUseProjectDimension"), prop.getProperty("IsUseProjectDimension"));
        pi.addParameter("IsUseCampaignDimension", prop.getProperty("IsUseCampaignDimension"), prop.getProperty("IsUseCampaignDimension"));
        pi.addParameter("IsUseSalesRegionDimension", prop.getProperty("IsUseSalesRegionDimension"), prop.getProperty("IsUseSalesRegionDimension"));
        pi.addParameter("CoAFile", prop.getProperty("CoAFile"), prop.getProperty("CoAFile"));
        pi.addParameter("Phone", prop.getProperty("Phone"), prop.getProperty("Phone"));
        pi.addParameter("Phone2", prop.getProperty("Phone2"), prop.getProperty("Phone2"));
        pi.addParameter("Fax", prop.getProperty("Fax"), prop.getProperty("Fax"));
        pi.addParameter("EMail", prop.getProperty("EMail"), prop.getProperty("EMail"));
        pi.addParameter("TaxID", prop.getProperty("TaxID"), prop.getProperty("TaxID"));
        pi.addParameter("Logo", prop.getProperty("Logo"), prop.getProperty("Logo"));
        pi.addParameter("StartDate", prop.getProperty("StartDate"), prop.getProperty("StartDate"));
        pi.addParameter("HistoryYears", prop.getProperty("HistoryYears"), prop.getProperty("HistoryYears"));
        pi.addParameter("DUNS", prop.getProperty("DUNS"), prop.getProperty("DUNS"));
        pi.addParameter("BankName", prop.getProperty("BankName"), prop.getProperty("BankName"));
        pi.addParameter("RoutingNo", prop.getProperty("RoutingNo"), prop.getProperty("RoutingNo"));
        pi.addParameter("AccountNo", prop.getProperty("AccountNo"), prop.getProperty("AccountNo"));
    } catch (Exception e) {
    // TODO: handle exception
    }
    InitialClientSetup setup = new InitialClientSetup();
    setup.startProcess(Env.getCtx(), pi, null);
}
Also used : MCountry(org.compiere.model.MCountry) MCurrency(org.compiere.model.MCurrency) ProcessInfo(org.compiere.process.ProcessInfo) Properties(java.util.Properties) FileInputStream(java.io.FileInputStream) AdempiereException(org.adempiere.exceptions.AdempiereException)

Example 29 with ProcessInfo

use of org.compiere.process.ProcessInfo in project adempiere by adempiere.

the class MigrationLoader method main.

public static void main(String[] args) {
    boolean clean_arg = false;
    // and delete all the steps and data to save space.
    if (args.length > 0)
        clean_arg = args[0].equals("clean");
    Adempiere.startupEnvironment(false);
    CLogMgt.setLevel(Level.CONFIG);
    if (!DB.isConnected()) {
        log.info("No DB Connection");
        System.exit(1);
    }
    // Turn off the Log Migration Script preference.
    Ini.setProperty(Ini.P_LOGMIGRATIONSCRIPT, false);
    // Parameter values - these need to be final or effectively final
    // Load migrations from the default location
    String fileName = Adempiere.getAdempiereHome() + File.separator + "migration";
    boolean apply = true;
    boolean failOnError = true;
    boolean clean = clean_arg;
    Properties context = Env.getCtx();
    try {
        //Import Migration from XML
        ProcessInfo processInfo = ProcessBuilder.create(context).process(org.compiere.process.MigrationFromXML.class).withTitle("Import Migration from XML").withParameter("FailOnError", failOnError).withParameter("FileName", fileName).withParameter("Apply", apply).withParameter("Clean", clean).execute();
        log.log(Level.CONFIG, "Process=" + processInfo.getTitle() + " Error=" + processInfo.isError() + " Summary=" + processInfo.getSummary());
        if (failOnError && processInfo.isError())
            throw new AdempiereException(processInfo.getSummary());
        processInfo = ProcessBuilder.create(context).process(org.compiere.process.SequenceCheck.class).withTitle("Sequence Check").execute();
        log.log(Level.CONFIG, "Process=" + processInfo.getTitle() + " Error=" + processInfo.isError() + " Summary=" + processInfo.getSummary());
        processInfo = ProcessBuilder.create(context).process(org.compiere.process.SynchronizeTerminology.class).withTitle("Synchronize Terminology").withParameter(SynchronizeTerminology.IsCreateElement, false).withParameter(SynchronizeTerminology.IsDeletingUnusedElement, false).execute();
        log.log(Level.CONFIG, "Process=" + processInfo.getTitle() + " Error=" + processInfo.isError() + " Summary=" + processInfo.getSummary());
        processInfo = ProcessBuilder.create(context).process(org.compiere.process.RoleAccessUpdate.class).withTitle("Role Access Update").withParameter("AD_Client_ID", 0).executeUsingSystemRole();
        log.log(Level.CONFIG, "Process=" + processInfo.getTitle() + " Error=" + processInfo.isError() + " Summary=" + processInfo.getSummary());
        processInfo = ProcessBuilder.create(context).process(org.compiere.process.CleanUpGW.class).withTitle("Updating Garden World").executeUsingSystemRole();
        log.log(Level.CONFIG, "Process=" + processInfo.getTitle() + " Error=" + processInfo.isError() + " Summary=" + processInfo.getSummary());
    } catch (AdempiereException e) {
        e.printStackTrace();
    }
}
Also used : AdempiereException(org.adempiere.exceptions.AdempiereException) SynchronizeTerminology(org.compiere.process.SynchronizeTerminology) ProcessInfo(org.compiere.process.ProcessInfo) Properties(java.util.Properties)

Example 30 with ProcessInfo

use of org.compiere.process.ProcessInfo in project adempiere by adempiere.

the class ModelExporter method main.

public static void main(String[] args) {
    CLogMgt.setLoggerLevel(Level.INFO, null);
    CLogMgt.setLevel(Level.INFO);
    Adempiere.startupEnvironment(true);
    ProcessInfo pi = new ProcessInfo("Test Import Model", 1000000);
    pi.setAD_Client_ID(11);
    pi.setAD_User_ID(100);
    ModelExporter modelExporter = new ModelExporter();
    modelExporter.startProcess(Env.getCtx(), pi, null);
}
Also used : ProcessInfo(org.compiere.process.ProcessInfo)

Aggregations

ProcessInfo (org.compiere.process.ProcessInfo)65 MPInstance (org.compiere.model.MPInstance)21 Trx (org.compiere.util.Trx)17 AdempiereException (org.adempiere.exceptions.AdempiereException)14 MPInstancePara (org.compiere.model.MPInstancePara)12 ReportEngine (org.compiere.print.ReportEngine)11 File (java.io.File)10 MProcess (org.compiere.model.MProcess)9 ProcessCtl (org.compiere.apps.ProcessCtl)8 SQLException (java.sql.SQLException)6 Timestamp (java.sql.Timestamp)6 ArrayList (java.util.ArrayList)6 IOException (java.io.IOException)5 ServletException (javax.servlet.ServletException)4 MBrowse (org.adempiere.model.MBrowse)4 PrintInfo (org.compiere.model.PrintInfo)4 ProcessInfoParameter (org.compiere.process.ProcessInfoParameter)4 Properties (java.util.Properties)3 MMovement (org.compiere.model.MMovement)3 PO (org.compiere.model.PO)3