/** * {@inheritDoc} * * @throws org.openbase.jul.exception.NotAvailableException {@inheritDoc} */ @Override public List<UnitConfig> getUnitConfigsByLocation(final String locationId, final boolean recursive) throws CouldNotPerformException { final List<UnitConfig> unitConfigList = new ArrayList<>(); for (String unitConfigId : getLocationConfigById(locationId).getLocationConfig().getUnitIdList()) { final UnitConfig unitConfig = unitRegistry.getUnitConfigById(unitConfigId); if (recursive || unitConfig.getPlacementConfig().getLocationId().equals(locationId)) { unitConfigList.add(unitConfig); } } return unitConfigList; }
public List<LocationRemote> getChildLocationList(final boolean waitForData) throws CouldNotPerformException { final List<LocationRemote> childList = new ArrayList<>(); for (String childId : getConfig().getLocationConfig().getChildIdList()) { try { childList.add(Units.getUnit(CachedLocationRegistryRemote.getRegistry().getLocationConfigById(childId), waitForData, LOCATION)); } catch (InterruptedException ex) { throw new CouldNotPerformException("Could not get all child locations!", ex); } } return childList; }
public List<LocationRemote> getChildLocationList(final boolean waitForData) throws CouldNotPerformException { final List<LocationRemote> childList = new ArrayList<>(); for (String childId : getConfig().getLocationConfig().getChildIdList()) { try { childList.add(Units.getUnit(CachedLocationRegistryRemote.getRegistry().getLocationConfigById(childId), waitForData, LOCATION)); } catch (InterruptedException ex) { throw new CouldNotPerformException("Could not get all child locations!", ex); } } return childList; } }
/** * {@inheritDoc} * * @throws org.openbase.jul.exception.CouldNotPerformException {@inheritDoc} */ @Override public List<UnitConfig> getNeighborLocations(String locationId) throws CouldNotPerformException { UnitConfig locationConfig = getLocationConfigById(locationId); if (locationConfig.getLocationConfig().getType() != LocationConfig.LocationType.TILE) { throw new CouldNotPerformException("Id[" + locationId + "] does not belong to a tile and therefore its neighbors aren't defined!"); } Map<String, UnitConfig> neighborMap = new HashMap<>(); for (UnitConfig connectionConfig : getConnectionConfigs()) { if (connectionConfig.getConnectionConfig().getTileIdList().contains(locationId)) { for (String id : connectionConfig.getConnectionConfig().getTileIdList()) { if (id.equals(locationId)) { continue; } neighborMap.put(id, getLocationConfigById(id)); } } } return new ArrayList<>(neighborMap.values()); }
private static String getLocationLabel(final UnitConfig unitConfig) throws InterruptedException { try { return Registries.getLocationRegistry().getLocationConfigById(unitConfig.getPlacementConfig().getLocationId()).getLabel(); } catch (CouldNotPerformException ex) { return "?"; } }
/** * {@inheritDoc} * * @throws org.openbase.jul.exception.CouldNotPerformException {@inheritDoc} * @throws org.openbase.jul.exception.NotAvailableException {@inheritDoc} */ @Override public List<UnitConfig> getUnitConfigsByLocation(final UnitType type, final String locationConfigId) throws CouldNotPerformException, NotAvailableException { List<UnitConfig> unitConfigList = new ArrayList<>(); UnitConfig unitConfig; for (String unitConfigId : getLocationConfigById(locationConfigId).getLocationConfig().getUnitIdList()) { try { unitConfig = unitRegistry.getUnitConfigById(unitConfigId); if (unitConfig.getType().equals(type) || unitRegistry.getSubUnitTypesOfUnitType(type).contains(unitConfig.getType())) { unitConfigList.add(unitConfig); } } catch (CouldNotPerformException ex) { ExceptionPrinter.printHistory(new CouldNotPerformException("Could not resolve UnitConfigId[" + unitConfigId + "] by UnitRegitryRemote!", ex), logger); } } return unitConfigList; }
/** * {@inheritDoc} * * @throws org.openbase.jul.exception.CouldNotPerformException {@inheritDoc} * @throws org.openbase.jul.exception.NotAvailableException {@inheritDoc} */ @Override public List<UnitConfig> getUnitConfigsByLocation(final ServiceType type, final String locationConfigId) throws CouldNotPerformException, NotAvailableException { List<UnitConfig> unitConfigList = new ArrayList<>(); UnitConfig unitConfig; for (String unitConfigId : getLocationConfigById(locationConfigId).getLocationConfig().getUnitIdList()) { try { unitConfig = unitRegistry.getUnitConfigById(unitConfigId); for (ServiceConfig serviceConfig : unitConfig.getServiceConfigList()) { if (serviceConfig.getServiceDescription().getType().equals(type)) { unitConfigList.add(unitConfig); } } } catch (CouldNotPerformException ex) { ExceptionPrinter.printHistory(new CouldNotPerformException("Could not resolve UnitConfigId[" + unitConfigId + "] by device registry!", ex), logger); } } return unitConfigList; }
for (final UnitConfig config : Registries.getLocationRegistry().getUnitConfigsByLocation(selectedLocationConfigHolder.getConfig().getId())) { try { unitConfigHolderList.add(new UnitConfigHolder(config, Registries.getLocationRegistry().getLocationConfigById(config.getPlacementConfig().getLocationId()))); } catch (CouldNotPerformException ex) { exceptionStack = MultiException.push(this, ex, exceptionStack); throw new InvalidStateException("Could not load location unit of " + config.getLabel() + " because its not configured!"); unitConfigHolderList.add(new UnitConfigHolder(config, Registries.getLocationRegistry().getLocationConfigById(config.getPlacementConfig().getLocationId()))); } catch (CouldNotPerformException ex) { exceptionStack = MultiException.push(this, ex, exceptionStack); for (UnitConfig config : Registries.getLocationRegistry().getUnitConfigsByLocation(selectedUnitType, selectedLocationConfigHolder.getConfig().getId())) { try { unitConfigHolderList.add(new UnitConfigHolder(config, Registries.getLocationRegistry().getLocationConfigById(config.getPlacementConfig().getLocationId()))); } catch (CouldNotPerformException ex) { exceptionStack = MultiException.push(this, ex, exceptionStack); continue; unitConfigHolderList.add(new UnitConfigHolder(config, Registries.getLocationRegistry().getLocationConfigById(config.getPlacementConfig().getLocationId()))); } catch (CouldNotPerformException ex) { exceptionStack = MultiException.push(this, ex, exceptionStack);
@Override protected void execute() throws CouldNotPerformException, InterruptedException { logger.debug("Execute PartyLightTileFollowerApp[" + getLabel() + "]"); // verify if (!Registries.getLocationRegistry().getLocationConfigById(getConfig().getPlacementConfig().getLocationId()).getLocationConfig().getType().equals(LocationConfigType.LocationConfig.LocationType.TILE)) { throw new InvalidStateException("App location is not a tile!"); } new TileFollower().call(); }
nameElement.appendChild(deviceDeviceConfig.getLabel() + " " + Registries.getLocationRegistry().getLocationConfigById(deviceDeviceConfig.getPlacementConfig().getLocationId()).getLabel()); locationElement.appendChild(Registries.getLocationRegistry().getLocationConfigById(deviceDeviceConfig.getPlacementConfig().getLocationId()).getLabel());