forum.bitel.ru http://forum.bitel.ru/ |
|
Создание нового устройства в Inet http://forum.bitel.ru/viewtopic.php?f=19&t=6897 |
Страница 1 из 1 |
Автор: | aiwbend [ 25 июн 2012, 11:18 ] |
Заголовок сообщения: | Создание нового устройства в Inet |
Нужно создать новое устройство в модуле инет. Натыкал примерно так Код: package ru.rta.bgbilling.inet; import ru.bitel.bgbilling.kernel.script.server.dev.GlobalScriptBase; import ru.bitel.bgbilling.server.util.Setup; import ru.bitel.common.sql.ConnectionSet; import ru.bitel.bgbilling.modules.inet.api.common.bean.InetDevice; import ru.bitel.bgbilling.modules.inet.api.common.bean.InetDeviceType; import ru.bitel.bgbilling.modules.inet.api.server.bean.InetDeviceDao; import ru.bitel.oss.systems.inventory.resource.common.bean.Device; import ru.bitel.oss.systems.inventory.resource.common.bean.DeviceType; import ru.bitel.oss.systems.inventory.resource.server.bean.DeviceDao; import java.sql.*; public class test extends GlobalScriptBase { Connection con; @Override public void execute( Setup setup, ConnectionSet connectionSet ) throws Exception { con = connectionSet.getConnection(); InetDevice inetd = new InetDevice(); InetDeviceType inetdt = new InetDeviceType(5, "DGS 3627G"); InetDeviceDao idd = new InetDeviceDao (con, 2); print (inetdt); inetd.setParentId(2); inetd.setDeviceTypeId(5); inetd.setHost("10.147.2.254"); inetd.setTitle(Device.generateTitle(inetd, inetdt)); inetd.setIdentifier("50let40-1p-9et-DGS-3627G-M"); //idd.updateImpl(inetd);// уг print (inetd); } } правильно ли я "собрал" InetDevice() и как теперь его засунуть в бд? эти абстрактные классы выжали меня ) |
Автор: | Amir [ 25 июн 2012, 13:22 ] |
Заголовок сообщения: | Re: Создание нового устройства в Inet |
Код: package ru; import ru.bitel.bgbilling.kernel.container.managed.ServerContext; import ru.bitel.bgbilling.kernel.event.EventProcessor; import ru.bitel.bgbilling.kernel.script.server.dev.GlobalScriptBase; import ru.bitel.bgbilling.modules.inet.api.common.bean.InetDevice; import ru.bitel.bgbilling.modules.inet.api.common.bean.InetDeviceType; import ru.bitel.bgbilling.modules.inet.api.common.service.InetDeviceService; import ru.bitel.bgbilling.modules.inet.api.server.event.InetReloadEvent; import ru.bitel.bgbilling.server.util.Setup; import ru.bitel.common.sql.ConnectionSet; import ru.bitel.oss.systems.inventory.resource.common.bean.Device; public class test extends GlobalScriptBase { @Override public void execute( Setup setup, ConnectionSet connectionSet ) throws Exception { ServerContext context = ServerContext.get(); InetDeviceService deviceService = context.newService( InetDeviceService.class, 2 ); // получение типа устройства по id InetDeviceType deviceType = deviceService.deviceTypeGet( 5 ); InetDevice device = new InetDevice(); device.setDeviceTypeId( 5 ); .... device.setTitle( Device.generateTitle( device, deviceType ) ); // обновление в базе deviceService.deviceUpdate( device ); // перезагрузка конфигурации на всех приложениях (access/accounting) EventProcessor.getInstance().publish( new InetReloadEvent( moduleId, userId ) ); } } Но InetDeviceService еще не попал в API, т.к. может измениться класс InetDevice viewtopic.php?f=44&t=6870 |
Автор: | aiwbend [ 25 июн 2012, 15:34 ] |
Заголовок сообщения: | Re: Создание нового устройства в Inet |
Спасибо большое! Вот так все заработало, может пригодится кому нибудь. Код: package ru.rta.bgbilling.inet;
import ru.bitel.bgbilling.kernel.container.managed.ServerContext; import ru.bitel.bgbilling.kernel.event.EventProcessor; import ru.bitel.bgbilling.kernel.script.server.dev.GlobalScriptBase; import ru.bitel.bgbilling.modules.inet.api.common.bean.InetDevice; import ru.bitel.bgbilling.modules.inet.api.common.bean.InetDeviceType; import ru.bitel.bgbilling.modules.inet.api.common.service.InetDeviceService; import ru.bitel.bgbilling.modules.inet.api.server.event.InetReloadEvent; import ru.bitel.bgbilling.server.util.Setup; import ru.bitel.common.sql.ConnectionSet; import ru.bitel.oss.systems.inventory.resource.common.bean.Device; import java.util.*; public class test extends GlobalScriptBase { @Override public void execute( Setup setup, ConnectionSet connectionSet ) throws Exception { HashSet groupd = new HashSet( 1, 1 ); //сэт с id групп устройств groupd.add(new Integer(1)); ServerContext context = ServerContext.get(); InetDeviceService deviceService = context.newService( InetDeviceService.class, 2 ); //(Class, int moduleId) // получение типа устройства по id InetDeviceType deviceType = deviceService.deviceTypeGet( 5 ); InetDevice device = new InetDevice(); device.setDeviceTypeId( 5 ); device.setParentId(2); device.setHost("10.147.2.254"); device.setIdentifier("50let40-1p-9et-DGS-3627G-M"); device.setUsername(""); device.setPassword(""); device.setSecret(""); device.setConfig(""); device.setComment(""); device.setDeviceGroupIds(groupd); device.setTitle( Device.generateTitle( device, deviceType ) ); print(device); // обновление в базе deviceService.deviceUpdate( device ); // перезагрузка конфигурации на всех приложениях (access/accounting) EventProcessor.getInstance().publish( new InetReloadEvent( 2, 0 )); //( moduleId, userId ) } } |
Страница 1 из 1 | Часовой пояс: UTC + 5 часов [ Летнее время ] |
Powered by phpBB® Forum Software © phpBB Group http://www.phpbb.com/ |