Код:
import ru.bitel.bgbilling.kernel.container.managed.ServerContext;
import ru.bitel.bgbilling.kernel.contract.limit.server.bean.LimitManager;
import ru.bitel.bgbilling.kernel.event.events.LimitChangedEvent;
import ru.bitel.bgbilling.kernel.event.events.system.SystemLimitChangedEvent;
import ru.bitel.bgbilling.kernel.module.common.bean.User;
import ru.bitel.bgbilling.kernel.script.server.dev.GlobalScriptBase;
import ru.bitel.bgbilling.server.util.Setup;
import ru.bitel.common.sql.ConnectionSet;
import java.math.BigDecimal;
import java.sql.Connection;
/**
* Пример смены лимита для Жулика
*
* @author SinTeZ
*/
public class TestJulik
extends GlobalScriptBase {
@Override
public void execute(Setup setup, ConnectionSet connectionSet)
throws Exception {
Connection con = connectionSet.getConnection();
ServerContext serverContext = ServerContext.get();
LimitManager limitManager = new LimitManager(con);
BigDecimal newLimit = new BigDecimal(-100);
int contractId = 315692;
String comment = "Тест";
limitManager.updateContractLimit(User.USER_SERVER, newLimit, contractId, comment, 0);
serverContext.publishAfterCommit(new SystemLimitChangedEvent(contractId, newLimit));
serverContext.publishAfterCommit(new LimitChangedEvent(contractId, newLimit));
}
}