Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Mar 07 04:26
    eelti edited #3385
  • Mar 07 04:17
    eelti opened #3385
  • Mar 06 03:23
  • Mar 05 17:40
    GabrielMartinezBranisa starred adempiere/adempiere
  • Mar 04 14:14

    e-Evolution on develop

    Add github actions to use a sin… Merge pull request #3384 from m… (compare)

  • Mar 04 14:14
    e-Evolution closed #3384
  • Mar 04 14:14
    e-Evolution closed #3383
  • Mar 04 13:07

    mckayERP on #3383_UpdateGithubActionsForJava1.8

    (compare)

  • Mar 04 12:56
    mckayERP review_requested #3384
  • Mar 04 12:56
    mckayERP review_requested #3384
  • Mar 04 12:56
    mckayERP review_requested #3384
  • Mar 04 12:56
    mckayERP opened #3384
  • Mar 04 12:50

    mckayERP on #3383_UpdateGithubActionsForJava1.8

    Update github actions to use ja… (compare)

  • Mar 04 12:44

    mckayERP on develop

    Add github actions to use a sin… (compare)

  • Mar 04 12:40
    mckayERP labeled #3383
  • Mar 04 12:40
    mckayERP assigned #3383
  • Mar 04 12:40
    mckayERP opened #3383
  • Mar 04 12:38

    mckayERP on develop

    #3368 Throws an error when doin… (compare)

  • Mar 04 12:32
    mckayERP synchronize #3377
  • Mar 04 12:32

    mckayERP on #3309_FixGardenWorldCleanUp

    Fix an assumption in the TimeUt… (compare)

e-Evolution
@e-Evolution
@DulipKumara I use debian 10 stable version, and work perfect
Marek Mosiewicz
@marekmosiewicz
@e-Evolution which jdk do you use ?
e-Evolution
@e-Evolution
@marekmosiewicz I currectly use https://adoptopenjdk.net
JDK 8
fincencius hasti mahardhika
@FincenciusHastiMahardhika333
Hello Sir , I want use Domain and upload ADempiere in Jelastic use Tomcat 8.5 there is any setting that need to requiered for that or use AWS , I run on local is nicely in my lapton with OS Ubuntu Focal Forsa 20.4 and my database in postgresql 13 , Apache Tomcat 8.5? For your Advice I'm so thankful
fincencius hasti mahardhika
@FincenciusHastiMahardhika333
and if i use localy or cloud with only OS Ubuntu Server with not setting set up how I edit this code :
Screenshot from 2021-01-15 08-55-14.png
I Use VPN hamachi for group join IP VPN
fincencius hasti mahardhika
@FincenciusHastiMahardhika333
Whats mean VPN propile is @Deprecated ?
fincencius hasti mahardhika
@FincenciusHastiMahardhika333
Oh , I get it , must create docker image , but that code wan or vpn must edit or not?
fincencius hasti mahardhika
@FincenciusHastiMahardhika333
but when I try localy , i cannot run in LAN, Wifi connection , even i use VPN Hamachi local cannot run too? i need some help sir, only run in my laptop but at network cannot
Michael McKay
@mckayERP
@FincenciusHastiMahardhika333 Are you successfully running docker on your laptop? If so, it should run equally well on a cloud server.
fincencius hasti mahardhika
@FincenciusHastiMahardhika333
no sir in my laptop run without docker , but manually without docker , thank sir , i will create with docker first
Michael McKay
@mckayERP

@e-Evolution @yamelsenih I found an issue with the ProcessBuilder. As a static method, I can "hijack" the process if I'm running more than one process at a time. In my case, I have one process, call it Process1, that I have to run multiple times. I have another process, Process2, that I'm going to run in between the runs of Process1. I can reduce code duplication by creating a processorForProcess1 using the ProcessBuilder where I set the parameters and then call processorForProcess1.execute() each time I want to run it. It works the for multiple runs as expected. But when I use the ProcessBuilder to execute Process2, the next time I call processorForProcess1.execute()again, it reruns Process2.

I think the problem is the static constructor used by the ProcessBuilder and the internal static processBuilder field. I'd suggest we deprecate these and use a non-static constructor instead.

ProcessBuilder processor = ProcessBuilder.with...;
// should be
ProcessBuilder processor = new ProcessBuilder().with...;

What do you think?

Michael McKay
@mckayERP
On second thought, we could also just get rid of the internal static reference and just use "this" in place and the static version would work.
fincencius hasti mahardhika
@FincenciusHastiMahardhika333
Thank You Sir, Mr. Michael @mckayERP , now ADempiere can connect with LAN, Wifi ,actually i still use my local area network in my office , not yet create docker image , Thank you to all developher too, you are amazing
e-Evolution
@e-Evolution

@mckayERP Hi Mike, I did not understand your problem, but currently there is code that from a process is called another process that works correctly, it is important to handle the transaction, you can handle two approaches:

1.- Execute all the processes with the same transaction, it is recommended for processes that are executed in a short time and that must be completely atomic.

In this case, the parameters are important to indicate that it comes from a parent process, that the second process does not close the transaction at the end, and which transaction will be used:

.withParentProcess (this)
.withoutTransactionClose ()
.execute (get_TrxName ());

Example of executing two processes with the same transaction:

https://github.com/adempiere/adempiere/blob/57a1412d8457b13734d8b7c51b8dd4f375102796/org.adempiere.pos/src/main/java/base/org/adempiere/pos/command/CommandImmediateInvoice.java#L44

https://github.com/adempiere/adempiere/blob/57a1412d8457b13734d8b7c51b8dd4f375102796/org.adempiere.pos/src/main/java/base/org/adempiere/pos/process/GenerateImmediateInvoice.java#L48

2.- Execute each process in a different transaction, it is recommended for very long processes and where the control of the processed records is handled individually.

Use Trx.run (trxName -> {if you need to run a process in its own transaction.

https://github.com/adempiere/adempiere/blob/da25ed00d9ed3ed8ef72e1b31233c0f4a51a3c85/org.adempiere.pos/src/main/java/base/org/adempiere/pos/command/CommandGenerateReturn.java#L41

Michael McKay
@mckayERP
@e-Evolution The issue is the sequence. Here is a test that fails because of the problem.
@DisplayName("Given the GardenWorld context")
class ProcessBuilderTest extends CommonGWSetup {

    private static final String CLIENT_ACCOUNTING_IMMEDIATE = "I";

    ProcessBuilder clientAcctProcessor;
    ProcessBuilder resetAccounting;

    @BeforeEach
    void givenClientAccountingEnabled() {

        enableClientAccounting();

    }

    @Nested
    @DisplayName("When the first process is created")
    class WhenASingleProcessIsCreated {

        @BeforeEach
        void whenClientAcctProcessorIsCreated() {

            clientAcctProcessor = ProcessBuilder.create(ctx)
                    .process(org.adempiere.process.ClientAcctProcessor.class)
                    .withTitle("ClientAcctProcessorTest");

        }

        @Test
        @DisplayName("When the first process is run, "
                + "then the process succeeds")
        void whenTheClientAcctProcessorIsRun_itSucceeds() {

            ProcessInfo info = clientAcctProcessor.execute(trxName);
            assertEquals("OK", info.getSummary());

        }

        @Nested
        @DisplayName("When a second process is created")
        class WhenASecondProcessIsCreated {

            @BeforeEach
            void whenFactResetProcessorIsCreated() {

                resetAccounting = ProcessBuilder.create(ctx)
                        .process(org.compiere.process.FactAcctReset.class)
                        .withTitle("FactAcctReset")
                        .withParameter(FactAcctReset.AD_CLIENT_ID,
                                AD_CLIENT_ID)
                        .withParameter(FactAcctReset.DELETEPOSTING, true)
                        .withParameter(FactAcctReset.DATEACCT,
                                TimeUtil.getDay(1999, 01, 01), today);

            }

            @Test
            @DisplayName("When the second process is executed, "
                    + "then it succeeds")
            void whenTheFactResetProcessorIsRun_itSucceeds() {

                ProcessInfo info = resetAccounting.execute(trxName);
                assertTrue(info.getSummary().startsWith("Updated"));

            }

            @Test
            @DisplayName("When the first process is executed again, "
                    + "then it should succeed")
            void butWhenTheClientAcctProcessorIsRun_itShouldSucceed() {

                ProcessInfo info = clientAcctProcessor.execute(trxName);  // This throws a NPE
                assertEquals("OK", info.getSummary()); 

            }

        }

    }

    private void enableClientAccounting() {

        MSysConfig gwAccounting = getOrCreateClientAcctConfig();
        gwAccounting.setValue(CLIENT_ACCOUNTING_IMMEDIATE);
        gwAccounting.saveEx();

    }

    private MSysConfig getOrCreateClientAcctConfig() {

        return clientAccountingConfigs(AD_CLIENT_ID)
                .filter(config -> config.getAD_Client_ID() == AD_CLIENT_ID)
                .findFirst()
                .orElseGet(() -> {
                    MSysConfig config = new MSysConfig(ctx, 0, null);
                    config.setName("CLIENT_ACCOUNTING");
                    config.saveEx();
                    return config;
                });

    }

    private Stream<MSysConfig> clientAccountingConfigs(int clientId) {

        String where = "Name=? AND AD_Client_ID IN (0, ?)";
        return new Query(ctx, I_AD_SysConfig.Table_Name, where, null)
                .setOnlyActiveRecords(true)
                .setParameters("CLIENT_ACCOUNTING", clientId)
                .setOrderBy("AD_Client_ID DESC, AD_Org_ID DESC")
                .list(MSysConfig.class)
                .stream();

    }

}
Michael McKay
@mckayERP
The last test throws an unexpected NPE. When I trace that cause, I see the processBuilder field is pointing at the FactAcctReset but the processInfo is for the ClientAcctProcessor.
image.png
I think the cause is that the processBuilder field is static.
e-Evolution
@e-Evolution
@mckayERP , can please adding this testing with your branch the refactory for testing
then I can test and same time make merge the refactory testing , please can syncronice your branch with last develop branch
Michael McKay
@mckayERP
@e-Evolution Its been added. Thanks for reviewing this.
e-Evolution
@e-Evolution
@mckayERP , I testing you code and found some problems:
1 reply
or
no return a null value , the first that I executed I got null , I not understand m this throw an exception NPE
I rebuild all project and when a got a value timestamp then the testing continue
e-Evolution
@e-Evolution
Other proiblem that I found was that report to @yamelsenih Yamel , the table FM_Batch have not DateAcct then the return Client Accounting Processor return an NPE for this reason
1 reply
I adding the DateAcct column the FM_Batch only to solve the error
then the testing continue
So the test now show next:
image.png
e-Evolution
@e-Evolution
about the When Acccounting is reset for some case got an exeption :
image.png

@ProcessRunError@ @Error@ Client Accounting is not enabled

In order to run this process you need to enable client accounting, this can be done in window System Configurator, setting the parameter CLIENT_ACCOUNTING to [I]mmediate or [Q]ueue

5 replies
So that I think that test no have right design, because the Client Accounting is not enabled
e-Evolution
@e-Evolution
I think that the exception is not propagate or thi test is not right
@Test
@DisplayName("Then the ClientAcctProcessor doIt method should "
            + "throw an exception")
    final void whenClientAcctDisabled_throwsException() {

        assertThrows(AdempiereException.class, () -> {
            process.execute(trxName);
        });

    }
because I got exception but the assertThrows not passed
image.png
1 reply
I think your other type y problems are not in the thread to see with processBuilder
I think it is good to always validate that the process is carried out with no exception in all its problems so that you can be sure that before you evaluate any assertion that the process is successful
e-Evolution
@e-Evolution
please adding this lines in your test code when finish any process execution
1 reply
       ProcessInfo info = process.execute(trxName);
            if (info.isError())
                throw new AdempiereException(info.getThrowable().toString());
Michael McKay
@mckayERP
image.png
Michael McKay
@mckayERP
@e-Evolution I responded in threads except for the picture above. I'm not sure if it applied to the comment "I think that the exception is not propagate ..." or not. I marked up the picture to show where the failures are coming from. For the assertThrows, no error was caught - which means the exception was thrown as expected - so the test whenClientAcctDispabled_throwsException passed.