当前位置: 首页>>代码示例>>Java>>正文


Java ItemNotFoundException类代码示例

本文整理汇总了Java中org.eclipse.smarthome.core.items.ItemNotFoundException的典型用法代码示例。如果您正苦于以下问题:Java ItemNotFoundException类的具体用法?Java ItemNotFoundException怎么用?Java ItemNotFoundException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ItemNotFoundException类属于org.eclipse.smarthome.core.items包,在下文中一共展示了ItemNotFoundException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: mapState

import org.eclipse.smarthome.core.items.ItemNotFoundException; //导入依赖的package包/类
private org.openhab.core.types.State mapState(State state, String itemName) {
	if(state==null) return null;
	
	Item eshItem;
	try {
		eshItem = itemRegistry.getItem(itemName);
		if(eshItem!=null) {
			return org.openhab.core.types.TypeParser.parseState(
					ItemMapper.mapToOpenHABItem(eshItem).getAcceptedDataTypes(), state.toString());
		} else {
			return null;
		}
	} catch (ItemNotFoundException e) {
		return null;
	}
}
 
开发者ID:Neulinet,项目名称:Zoo,代码行数:17,代码来源:QueryablePersistenceServiceDelegate.java

示例2: setState

import org.eclipse.smarthome.core.items.ItemNotFoundException; //导入依赖的package包/类
@GET
@Produces({ MediaType.APPLICATION_JSON })
public Response setState(@Context HttpHeaders headers, @QueryParam("a") String itemName,
        @QueryParam("v") String value, @QueryParam("ts") long timestamp) {
    if (logger.isDebugEnabled()) {
        logger.debug("Received CV write request at '{}' for item '{}' with value '{}'.", uriInfo.getPath(),
                itemName, value);
    }
    Item item;
    try {
        item = itemRegistry.getItem(itemName);
        Command command = TypeParser.parseCommand(item.getAcceptedCommandTypes(), value);
        SuccessBean bean = new SuccessBean();
        if (command != null) {
            eventPublisher.post(ItemEventFactory.createCommandEvent(item.getName(), command));
            bean.success = 1;
        } else {
            bean.success = 0;
        }
        return Response.ok(bean, MediaType.APPLICATION_JSON).build();
    } catch (ItemNotFoundException e) {
        logger.error("{}", e.getLocalizedMessage());
        return Response.notAcceptable(null).build();
    }
}
 
开发者ID:openhab,项目名称:openhab2-addons,代码行数:26,代码来源:WriteResource.java

示例3: itemStateEvent

import org.eclipse.smarthome.core.items.ItemNotFoundException; //导入依赖的package包/类
private void itemStateEvent(ItemStateEvent event) throws ItemNotFoundException {

		String itemName = event.getItemName();
		State itemState = event.getItemState();

		Item item = itemRegistry.getItem(itemName);

		for (EventSubscriberStruct subscriberStruct : eventSubscribers) {
			subscriberStruct.eventSubscriber
					.stateUpdated(new com.incquerylabs.smarthome.eventbus.api.events.ItemStateEvent(item, itemState));
		}
		logger.trace(event.toString());
	}
 
开发者ID:IncQueryLabs,项目名称:smarthome-cep-demonstrator,代码行数:14,代码来源:EventBusImpl.java

示例4: itemStateChangedEvent

import org.eclipse.smarthome.core.items.ItemNotFoundException; //导入依赖的package包/类
private void itemStateChangedEvent(ItemStateChangedEvent event) throws ItemNotFoundException {

		String itemName = event.getItemName();
		State newState = event.getItemState();
		State oldState = event.getOldItemState();

		Item item = itemRegistry.getItem(itemName);

		for (EventSubscriberStruct subscriberStruct : eventSubscribers) {
			subscriberStruct.eventSubscriber.stateChanged(
					new com.incquerylabs.smarthome.eventbus.api.events.ItemStateChangedEvent(item, newState, oldState));
		}
		logger.trace(event.toString());
	}
 
开发者ID:IncQueryLabs,项目名称:smarthome-cep-demonstrator,代码行数:15,代码来源:EventBusImpl.java

示例5: groupItemStateChangedEvent

import org.eclipse.smarthome.core.items.ItemNotFoundException; //导入依赖的package包/类
private void groupItemStateChangedEvent(GroupItemStateChangedEvent event) throws ItemNotFoundException {

		String itemName = event.getItemName();
		State newState = event.getItemState();
		State oldState = event.getOldItemState();

		Item item = itemRegistry.getItem(itemName);

		for (EventSubscriberStruct subscriberStruct : eventSubscribers) {
			subscriberStruct.eventSubscriber.groupStateChanged(
					new com.incquerylabs.smarthome.eventbus.api.events.GroupItemStateChangedEvent(item, newState,
							oldState));
		}
		logger.trace(event.toString());
	}
 
开发者ID:IncQueryLabs,项目名称:smarthome-cep-demonstrator,代码行数:16,代码来源:EventBusImpl.java

示例6: itemCommandEvent

import org.eclipse.smarthome.core.items.ItemNotFoundException; //导入依赖的package包/类
private void itemCommandEvent(ItemCommandEvent event) throws ItemNotFoundException {
	String itemName = event.getItemName();
	Command command = event.getItemCommand();

	Item item = itemRegistry.getItem(itemName);
	for (EventSubscriberStruct subscriberStruct : eventSubscribers) {
		subscriberStruct.eventSubscriber.commandReceived(
				new com.incquerylabs.smarthome.eventbus.api.events.ItemCommandEvent(item, command));
	}
	logger.trace(event.toString());
}
 
开发者ID:IncQueryLabs,项目名称:smarthome-cep-demonstrator,代码行数:12,代码来源:EventBusImpl.java

示例7: itemAddedEvent

import org.eclipse.smarthome.core.items.ItemNotFoundException; //导入依赖的package包/类
private void itemAddedEvent(ItemAddedEvent event) throws ItemNotFoundException {
	String itemName = event.getItem().name;
	Item item = itemRegistry.getItem(itemName);

	for (EventSubscriberStruct subscriberStruct : eventSubscribers) {
		subscriberStruct.eventSubscriber
				.itemAdded(new com.incquerylabs.smarthome.eventbus.api.events.ItemAddedEvent(item));
	}
	logger.trace(event.toString());
}
 
开发者ID:IncQueryLabs,项目名称:smarthome-cep-demonstrator,代码行数:11,代码来源:EventBusImpl.java

示例8: itemUpdatedEvent

import org.eclipse.smarthome.core.items.ItemNotFoundException; //导入依赖的package包/类
private void itemUpdatedEvent(ItemUpdatedEvent event) throws ItemNotFoundException {
	String itemName = event.getItem().name;
	String oldItemName = event.getOldItem().name;

	Item item = itemRegistry.getItem(itemName);

	for (EventSubscriberStruct subscriberStruct : eventSubscribers) {
		subscriberStruct.eventSubscriber.itemUpdated(
				new com.incquerylabs.smarthome.eventbus.api.events.ItemUpdatedEvent(item, oldItemName));
	}
	logger.trace(event.toString());
}
 
开发者ID:IncQueryLabs,项目名称:smarthome-cep-demonstrator,代码行数:13,代码来源:EventBusImpl.java

示例9: createChart

import org.eclipse.smarthome.core.items.ItemNotFoundException; //导入依赖的package包/类
@Override
public BufferedImage createChart(String service, String theme, Date startTime, Date endTime, int height, int width,
        String items, String groups) throws ItemNotFoundException {
    try {
        return provider.createChart(service, theme, startTime, endTime, height, width, items, groups);
    } catch (org.openhab.core.items.ItemNotFoundException e) {
        throw new ItemNotFoundException(StringUtils.substringBetween(e.getMessage(), "'"));
    }
}
 
开发者ID:Neulinet,项目名称:Zoo,代码行数:10,代码来源:ChartProviderDelegate.java

示例10: sendCommand

import org.eclipse.smarthome.core.items.ItemNotFoundException; //导入依赖的package包/类
@Override
public void sendCommand(String itemName, Command command) {
	try {
		Item item = itemRegistry.getItem(itemName);
		org.eclipse.smarthome.core.types.Command eshCommand = TypeParser.parseCommand(item.getAcceptedCommandTypes(), command.toString());
		eventPublisher.sendCommand(itemName, eshCommand);
	} catch (ItemNotFoundException e) {
		logger.warn("Could not process command event '{}' as item '{}' is unknown", command.toString(), itemName);
	}
}
 
开发者ID:Neulinet,项目名称:Zoo,代码行数:11,代码来源:EventPublisherDelegate.java

示例11: postCommand

import org.eclipse.smarthome.core.items.ItemNotFoundException; //导入依赖的package包/类
@Override
public void postCommand(String itemName, Command command) {
	try {
		Item item = itemRegistry.getItem(itemName);
		org.eclipse.smarthome.core.types.Command eshCommand = TypeParser.parseCommand(item.getAcceptedCommandTypes(), command.toString());
		eventPublisher.postCommand(itemName, eshCommand);
	} catch (ItemNotFoundException e) {
		logger.warn("Could not process command event '{}' as item '{}' is unknown", command.toString(), itemName);
	}
}
 
开发者ID:Neulinet,项目名称:Zoo,代码行数:11,代码来源:EventPublisherDelegate.java

示例12: postUpdate

import org.eclipse.smarthome.core.items.ItemNotFoundException; //导入依赖的package包/类
@Override
public void postUpdate(String itemName, State newState) {
	try {
		Item item = itemRegistry.getItem(itemName);
		org.eclipse.smarthome.core.types.State eshState = TypeParser.parseState(item.getAcceptedDataTypes(), newState.toString());
		eventPublisher.postUpdate(itemName, eshState);
	} catch (ItemNotFoundException e) {
		logger.warn("Could not process command event '{}' as item '{}' is unknown", newState.toString(), itemName);
	}
}
 
开发者ID:Neulinet,项目名称:Zoo,代码行数:11,代码来源:EventPublisherDelegate.java

示例13: query

import org.eclipse.smarthome.core.items.ItemNotFoundException; //导入依赖的package包/类
@Override
public Iterable<HistoricItem> query(FilterCriteria filter) {
	org.openhab.core.persistence.FilterCriteria mappedFilter = new org.openhab.core.persistence.FilterCriteria()
		.setBeginDate(filter.getBeginDate())
		.setEndDate(filter.getEndDate())
		.setItemName(filter.getItemName())
		.setOperator(mapOperator(filter.getOperator()))
		.setOrdering(mapOrdering(filter.getOrdering()))
		.setPageNumber(filter.getPageNumber())
		.setPageSize(filter.getPageSize())
		.setState(mapState(filter.getState(), filter.getItemName()));
	org.openhab.core.persistence.QueryablePersistenceService pService = (org.openhab.core.persistence.QueryablePersistenceService) service;
	Iterable<org.openhab.core.persistence.HistoricItem> historicItems = pService.query(mappedFilter);
	ArrayList<HistoricItem> result = new ArrayList<>();
	for(final org.openhab.core.persistence.HistoricItem item : historicItems) {
		result.add(new HistoricItem() {
			@Override
			public Date getTimestamp() {
				return item.getTimestamp();
			}
			
			@Override
			public State getState() {
				Item eshItem;
				try {
					eshItem = itemRegistry.getItem(item.getName());
					if(eshItem!=null) {
						return TypeParser.parseState(eshItem.getAcceptedDataTypes(), item.getState().toString());
					} else {
						return null;
					}
				} catch (ItemNotFoundException e) {
					return null;
				}
			}
			
			@Override
			public String getName() {
				return item.getName();
			}
		});
	}
	return result;
}
 
开发者ID:Neulinet,项目名称:Zoo,代码行数:45,代码来源:QueryablePersistenceServiceDelegate.java

示例14: getStates

import org.eclipse.smarthome.core.items.ItemNotFoundException; //导入依赖的package包/类
/**
 * Subscribes the connecting client to the stream of events filtered by the
 * given eventFilter.
 *
 * @param eventFilter
 * @return {@link EventOutput} object associated with the incoming
 *         connection.
 * @throws IOException
 * @throws InterruptedException
 */
@GET
@Produces(SseFeature.SERVER_SENT_EVENTS)
public Object getStates(@QueryParam("a") List<String> itemNames, @QueryParam("i") long index,
        @QueryParam("t") long time) throws IOException, InterruptedException {
    final EventOutput eventOutput = new EventOutput();

    this.itemNames = itemNames;

    broadcaster.add(eventOutput);

    // get all requested items and send their states to the client
    items = new HashMap<Item, Map<String, Class<? extends State>>>();
    // send the current states of all items to the client
    if (this.itemRegistry != null) {
        List<StateBean> states = new ArrayList<StateBean>();
        for (String cvItemName : itemNames) {
            try {
                String[] parts = cvItemName.split(":");
                String ohItemName = cvItemName;
                Class<? extends State> stateClass = null;
                if (parts.length == 2) {
                    String classPrefix = parts[0].toLowerCase();
                    if (Config.itemTypeMapper.containsKey(classPrefix)) {
                        stateClass = Config.itemTypeMapper.get(classPrefix);
                        classPrefix += ":";
                    } else {
                        logger.debug("no type found for '{}'", classPrefix);
                        classPrefix = "";
                    }
                    ohItemName = parts[1];
                }
                Item item = this.itemRegistry.getItem(ohItemName);
                if (!items.containsKey(item)) {
                    items.put(item, new HashMap<String, Class<? extends State>>());
                }
                items.get(item).put(cvItemName, stateClass);
                StateBean itemState = new StateBean();
                itemState.name = cvItemName;

                if (stateClass != null) {
                    itemState.state = item.getStateAs(stateClass).toString();
                    logger.trace("get state of '{}' as '{}' == '{}'", item, stateClass, itemState.state);
                } else {
                    itemState.state = item.getState().toString();
                }
                states.add(itemState);
            } catch (ItemNotFoundException e) {
                logger.error("{}", e.getLocalizedMessage());
            }
        }
        logger.debug("initially broadcasting {}/{} item states", states.size(), itemNames.size());
        broadcaster.broadcast(SseUtil.buildEvent(states));
    }
    // listen to state changes of the requested items
    registerItems();

    return eventOutput;
}
 
开发者ID:openhab,项目名称:openhab2-addons,代码行数:69,代码来源:ReadResource.java

示例15: getChartSeries

import org.eclipse.smarthome.core.items.ItemNotFoundException; //导入依赖的package包/类
@GET
@Produces({ MediaType.APPLICATION_JSON })
public Response getChartSeries(@Context HttpHeaders headers, @QueryParam("rrd") String itemName,
        @QueryParam("ds") String consFunction, @QueryParam("start") String start, @QueryParam("end") String end,
        @QueryParam("res") long resolution) {
    if (logger.isDebugEnabled()) {
        logger.debug("Received GET request at '{}' for rrd '{}'.", uriInfo.getPath(), itemName);
    }
    String responseType = MediaType.APPLICATION_JSON;

    // RRD specific: no equivalent in PersistenceService known
    ConsolFun consilidationFunction = ConsolFun.valueOf(consFunction);

    // read the start/end time as they are provided in the RRD-way, we use
    // the RRD4j to read them
    long[] times = Util.getTimestamps(start, end);
    Date startTime = new Date();
    startTime.setTime(times[0] * 1000L);
    Date endTime = new Date();
    endTime.setTime(times[1] * 1000L);

    if (itemName.endsWith(".rrd")) {
        itemName = itemName.substring(0, itemName.length() - 4);
    }
    String[] parts = itemName.split(":");
    String service = "rrd4j";

    if (parts.length == 2) {
        itemName = parts[1];
        service = parts[0];
    }

    Item item;
    try {
        item = itemRegistry.getItem(itemName);
        logger.debug("item '{}' found ", item);

        // Prefer RRD-Service
        QueryablePersistenceService persistenceService = getPersistenceServices().get(service);
        // Fallback to first persistenceService from list
        if (persistenceService == null) {
            Iterator<Entry<String, QueryablePersistenceService>> pit = getPersistenceServices().entrySet()
                    .iterator();
            if (pit.hasNext()) {
                persistenceService = pit.next().getValue();
            } else {
                throw new IllegalArgumentException("No Persistence service found.");
            }
        }
        Object data = null;
        if (persistenceService.getId().equals("rrd4j")) {
            data = getRrdSeries(persistenceService, item, consilidationFunction, startTime, endTime, resolution);
        } else {
            data = getPersistenceSeries(persistenceService, item, startTime, endTime, resolution);
        }
        return Response.ok(data, responseType).build();
    } catch (ItemNotFoundException e1) {
        logger.error("Item '{}' not found error while requesting series data.", itemName);

    }
    return Response.serverError().build();
}
 
开发者ID:openhab,项目名称:openhab2-addons,代码行数:63,代码来源:ChartResource.java


注:本文中的org.eclipse.smarthome.core.items.ItemNotFoundException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。