Search in sources :

Example 1 with GwtBundleInfo

use of org.eclipse.kapua.app.console.shared.model.GwtBundleInfo in project kapua by eclipse.

the class DeviceTabPackagesInstalled method refresh.

public void refresh() {
    if (m_dirty && m_initialized) {
        GwtDevice selectedDevice = getSelectedDevice();
        if (selectedDevice == null || !selectedDevice.isOnline()) {
            m_treeStore.removeAll();
            m_treeGrid.unmask();
            m_treeGrid.getView().setEmptyText(MSGS.deviceNoDeviceSelectedOrOffline());
        } else {
            m_treeGrid.mask(MSGS.loading());
            gwtDeviceManagementService.findDevicePackages(selectedDevice.getScopeId(), selectedDevice.getId(), new AsyncCallback<List<GwtDeploymentPackage>>() {

                @Override
                public void onSuccess(List<GwtDeploymentPackage> packages) {
                    m_treeStore.removeAll();
                    if (packages != null && !packages.isEmpty()) {
                        for (GwtDeploymentPackage pkg : packages) {
                            m_treeStore.add(pkg, false);
                            if (pkg.getBundleInfos() != null) {
                                for (GwtBundleInfo bundle : pkg.getBundleInfos()) {
                                    m_treeStore.add(pkg, bundle, false);
                                }
                            }
                        }
                    } else {
                        m_rootTabPanel.getUninstallButton().disable();
                        m_treeGrid.getView().setEmptyText(MSGS.deviceNoPackagesInstalled());
                        m_treeGrid.getView().refresh(false);
                    }
                    m_treeGrid.unmask();
                }

                @Override
                public void onFailure(Throwable caught) {
                    FailureHandler.handle(caught);
                    m_treeGrid.unmask();
                }
            });
        }
        m_dirty = false;
    }
}
Also used : GwtDevice(org.eclipse.kapua.app.console.shared.model.GwtDevice) GwtDeploymentPackage(org.eclipse.kapua.app.console.shared.model.GwtDeploymentPackage) List(java.util.List) GwtBundleInfo(org.eclipse.kapua.app.console.shared.model.GwtBundleInfo)

Example 2 with GwtBundleInfo

use of org.eclipse.kapua.app.console.shared.model.GwtBundleInfo in project kapua by eclipse.

the class GwtDeviceManagementServiceImpl method findDevicePackages.

// 
// Packages
// 
@Override
public List<GwtDeploymentPackage> findDevicePackages(String scopeShortId, String deviceShortId) throws GwtKapuaException {
    List<GwtDeploymentPackage> gwtPkgs = new ArrayList<GwtDeploymentPackage>();
    try {
        KapuaLocator locator = KapuaLocator.getInstance();
        DevicePackageManagementService deviceManagementService = locator.getService(DevicePackageManagementService.class);
        KapuaId scopeId = KapuaEid.parseShortId(scopeShortId);
        KapuaId deviceId = KapuaEid.parseShortId(deviceShortId);
        DevicePackages deploymentPackages = deviceManagementService.getInstalled(scopeId, deviceId, null);
        for (DevicePackage deploymentPackage : deploymentPackages.getPackages()) {
            GwtDeploymentPackage gwtPkg = new GwtDeploymentPackage();
            gwtPkg.setName(deploymentPackage.getName());
            gwtPkg.setVersion(deploymentPackage.getVersion());
            DevicePackageBundleInfos devicePackageBundleInfos = deploymentPackage.getBundleInfos();
            if (devicePackageBundleInfos != null) {
                List<GwtBundleInfo> gwtBundleInfos = new ArrayList<GwtBundleInfo>();
                for (DevicePackageBundleInfo bundleInfo : devicePackageBundleInfos.getBundlesInfos()) {
                    GwtBundleInfo gwtBundleInfo = new GwtBundleInfo();
                    gwtBundleInfo.setName(bundleInfo.getName());
                    gwtBundleInfo.setVersion(bundleInfo.getVersion());
                    gwtBundleInfos.add(gwtBundleInfo);
                }
                gwtPkg.setBundleInfos(gwtBundleInfos);
            }
            gwtPkgs.add(gwtPkg);
        }
    } catch (Throwable t) {
        KapuaExceptionHandler.handle(t);
    }
    return gwtPkgs;
}
Also used : KapuaLocator(org.eclipse.kapua.locator.KapuaLocator) GwtDeploymentPackage(org.eclipse.kapua.app.console.shared.model.GwtDeploymentPackage) ArrayList(java.util.ArrayList) DevicePackageBundleInfo(org.eclipse.kapua.service.device.management.packages.model.DevicePackageBundleInfo) DevicePackage(org.eclipse.kapua.service.device.management.packages.model.DevicePackage) DevicePackages(org.eclipse.kapua.service.device.management.packages.model.DevicePackages) DevicePackageManagementService(org.eclipse.kapua.service.device.management.packages.DevicePackageManagementService) DevicePackageBundleInfos(org.eclipse.kapua.service.device.management.packages.model.DevicePackageBundleInfos) KapuaId(org.eclipse.kapua.model.id.KapuaId) GwtBundleInfo(org.eclipse.kapua.app.console.shared.model.GwtBundleInfo)

Aggregations

GwtBundleInfo (org.eclipse.kapua.app.console.shared.model.GwtBundleInfo)2 GwtDeploymentPackage (org.eclipse.kapua.app.console.shared.model.GwtDeploymentPackage)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 GwtDevice (org.eclipse.kapua.app.console.shared.model.GwtDevice)1 KapuaLocator (org.eclipse.kapua.locator.KapuaLocator)1 KapuaId (org.eclipse.kapua.model.id.KapuaId)1 DevicePackageManagementService (org.eclipse.kapua.service.device.management.packages.DevicePackageManagementService)1 DevicePackage (org.eclipse.kapua.service.device.management.packages.model.DevicePackage)1 DevicePackageBundleInfo (org.eclipse.kapua.service.device.management.packages.model.DevicePackageBundleInfo)1 DevicePackageBundleInfos (org.eclipse.kapua.service.device.management.packages.model.DevicePackageBundleInfos)1 DevicePackages (org.eclipse.kapua.service.device.management.packages.model.DevicePackages)1