if (gateway.isNew()) { Gateway newGateway = gatewayContext.newGateway(gateway.getModel()); newGateway.setName(gateway.getName()); newGateway.setAddress(gateway.getAddress()); newGateway.setDescription(gateway.getDescription()); newGateway.setSerialNumber(gateway.getSerialNumber()); setGateway(newGateway); gateway = newGateway; }
    void saveGateway() {        Gateway gateway = getGateway();        GatewayContext gatewayContext = getGatewayContext();        if (gateway.isNew()) {            Gateway newGateway = gatewayContext.newGateway(gateway.getModel());            newGateway.setName(gateway.getName());            newGateway.setAddress(gateway.getAddress());            newGateway.setDescription(gateway.getDescription());            newGateway.setSerialNumber(gateway.getSerialNumber());            setGateway(newGateway);            gateway = newGateway;        }        gatewayContext.storeGateway(gateway);        // attach gateway to current rule        Integer ruleId = getRuleId();        if (null != ruleId) {            DialPlanContext manager = getDialPlanContext();            DialingRule rule = manager.getRule(ruleId);            rule.addGateway(gateway);            manager.storeRule(rule);        }        // refresh gateway - it cannot be new any more        if (getGatewayId() == null) {            setGatewayId(gateway.getId());            setGateway(null);        }    }