2.4. Creating ApprovalHelper Bean
Create the ApprovalHelper bean as described in the Creating Managed Beans section of the CUBA Studio User Guide.
Replace its content with the following code:
package com.company.bpmdemo.core;
import org.springframework.stereotype.Component;
import com.company.bpmdemo.entity.Contract;
import com.haulmont.cuba.core.Persistence;
import com.haulmont.cuba.core.Transaction;
import javax.inject.Inject;
import java.util.UUID;
@Component(ApprovalHelper.NAME)
public class ApprovalHelper {
    public static final String NAME = "demo_ApprovalHelper";
    @Inject
    private Persistence persistence;
    public void updateState(UUID entityId, String state) {
        try (Transaction tx = persistence.getTransaction()) {
            Contract contract = persistence.getEntityManager().find(Contract.class, entityId);
            if (contract != null) {
                contract.setState(state);
            }
            tx.commit();
        }
    }
} 
  The updateState() method of the ApprovalHelper bean will be invoked from the contract approval process for setting a contract state.
Method parameters:
-  
entityId– contract entity identifier; -  
state– contract state.