/** * * @param variable {@inheritDoc} * @return {@inheritDoc} * @throws NotAvailableException {@inheritDoc} */ @Override public String getValue(String variable) throws NotAvailableException { return MetaConfigProcessor.getValue(metaConfig, variable); }
@Override public Future<ActionFuture> setColorState(ColorState state) throws CouldNotPerformException { return update(TimestampProcessor.updateTimestampWithCurrentTime(state), unit, ServiceType.COLOR_STATE_SERVICE); } };
/** * Method updates the timestamp field of the given message with the given timestamp. * * @param <M> the message type of the message to milliseconds. * @param milliseconds the time to update * @param messageOrBuilder the message * @return the updated message * @throws CouldNotPerformException */ public static <M extends MessageOrBuilder> M updateTimestamp(final long milliseconds, final M messageOrBuilder) throws CouldNotPerformException { return updateTimestamp(milliseconds, messageOrBuilder, TimeUnit.MILLISECONDS); }
/** * Create an interval which start now and ends after the maximum of MIN_ALLCOCATION_TIME_MILLI * and the executionTimePeriod. * Updates the executionTimePeriod of the given actionDescription. * * @param actionDescription actionDescription * @return an Interval generated as described above */ public static Interval getAllocationInterval(final ActionDescription.Builder actionDescription) { Interval.Builder interval = Interval.newBuilder(); actionDescription.setExecutionTimePeriod(Math.min(actionDescription.getExecutionTimePeriod(), actionDescription.getExecutionValidity().getMillisecondsSinceEpoch() - System.currentTimeMillis())); interval.setBegin(TimestampProcessor.getCurrentTimestamp()); interval.setEnd(TimestampJavaTimeTransform.transform(System.currentTimeMillis() + Math.max(MIN_ALLOCATION_TIME_MILLI, actionDescription.getExecutionTimePeriod()))); return interval.build(); }
/** * Get an ActionDescription which only misses unit and service information. * Is created with default ActionParameter. * Fields which are still missing after: * <ul> * <li>ActionDescription.Label</li> * <li>ActionDescription.Description</li> * <li>ActionDescription.ResourceAllocation.ResourceId</li> * <li>ActionDescription.ResourceAllocation.Description</li> * <li>ActionDescription.ResourceAllocation.UnitId</li> * <li>ActionDescription.ResourceAllocation.ServiceType</li> * <li>ActionDescription.ResourceAllocation.ServiceAttributeType</li> * <li>ActionDescription.ServiceStateDescription.ServiceAttribute</li> * </ul> * * @param actionAuthority the actionAuthority for the actionDescription * @param initiator the initiator type for the resourceAllocation in the actionDescription * @return */ public static ActionDescription.Builder getActionDescription(final ActionAuthority actionAuthority, final ResourceAllocation.Initiator initiator) { return getActionDescription(getDefaultActionParameter(), actionAuthority, initiator); }
/** * Method returns a new Timestamp object with the current system time. * * Note: The Timestamp type uses microseconds since January 1st, 1970 in UTC time as physical unit. * * @return the generated timestamp object representing the current time. */ public static Timestamp getCurrentTimestamp() { return TimestampJavaTimeTransform.transform(System.currentTimeMillis()); }
private String generateItemHardwareConfig(final UnitConfig unitConfig, final ServiceConfig serviceConfig) throws CouldNotPerformException { try { String config = ""; config += configPool.getValue(SERVICE_TEMPLATE_BINDING_TYPE); config += "=\""; config += configPool.getValue(SERVICE_TEMPLATE_BINDING_CONFIG); config += "\""; return config; } catch (Exception ex) { throw new CouldNotPerformException("Could not generate item hardware config of Unit[" + unitConfig.getId() + "] !", ex); } }
public static MetaConfig setValue(final MetaConfig metaConfig, final String key, final String value) throws CouldNotPerformException { return setValue(metaConfig.toBuilder(), key, value).build(); }
/** * * @param variableContains {@inheritDoc} * @return {@inheritDoc} * @throws NotAvailableException {@inheritDoc} */ @Override public Map<String, String> getValues(String variableContains) throws NotAvailableException { return MetaConfigProcessor.getValues(metaConfig, variableContains); }
/** * Update the slot of the ResourceAllocation based on the current time and the * values of the ActionDescription. * To generate the slot the method {@link #getAllocationInterval(ActionDescription.Builder) getAllocationInterval} is used. * * @param actionDescription the ActionDescription inside which the ResourceAllocation is updated * @return the updated ActionDescription */ public static ActionDescription.Builder updateResourceAllocationSlot(final ActionDescription.Builder actionDescription) { final ResourceAllocation.Builder resourceAllocationBuilder = actionDescription.getResourceAllocationBuilder(); resourceAllocationBuilder.setSlot(getAllocationInterval(actionDescription)); return actionDescription; }
/** * Updates the ActionChain which is a description of actions that lead to this action. * The action chain is updated in a way that the immediate parent is the first element of * the chain. So the index of the chain indicates how many actions are in between this * action and the causing action. * * @param actionDescription the ActionDescription which is updated * @param parentAction the ActionDescription of the action which is the cause for the new action * @return the updated ActionDescription */ public static ActionDescription.Builder updateActionChain(final ActionDescription.Builder actionDescription, final ActionDescriptionOrBuilder parentAction) { actionDescription.addActionChain(getActionReferenceFromActionDescription(parentAction)); actionDescription.addAllActionChain(parentAction.getActionChainList()); return actionDescription; }
@Override public Future<ActionFuture> setStandbyState(StandbyStateType.StandbyState state) throws CouldNotPerformException { return update(TimestampProcessor.updateTimestampWithCurrentTime(state), unit, ServiceType.STANDBY_STATE_SERVICE); } };
/** * Method updates the timestamp field of the given message with the current time. * * @param <M> the message type of the message to update. * @param messageOrBuilder the message * @return the updated message * @throws CouldNotPerformException */ public static <M extends MessageOrBuilder> M updateTimestampWithCurrentTime(final M messageOrBuilder) throws CouldNotPerformException { return updateTimestamp(System.currentTimeMillis(), messageOrBuilder); }
@Override public Future<ActionFuture> setTargetTemperatureState(TemperatureState state) throws CouldNotPerformException { return update(TimestampProcessor.updateTimestampWithCurrentTime(state), unit, ServiceType.TARGET_TEMPERATURE_STATE_SERVICE); } };
/** * Method updates the timestamp field of the given message with the given timestamp. * In case of an error the original message is returned. * * @param <M> the message type of the message to update. * @param timestamp the timestamp to update * @param messageOrBuilder the message * @param timeUnit the timeUnit of the timeStamp * @param logger the logger which is used for printing the exception stack in case something went wrong. * @return the updated message or the original one in case of errors. */ public static <M extends MessageOrBuilder> M updateTimestamp(final long timestamp, final M messageOrBuilder, final TimeUnit timeUnit, final Logger logger) { try { return updateTimestamp(timestamp, messageOrBuilder, timeUnit); } catch (CouldNotPerformException ex) { ExceptionPrinter.printHistory(ex, logger); return messageOrBuilder; } }
@Override public Future<ActionFuture> setBrightnessState(BrightnessState state) throws CouldNotPerformException { return update(TimestampProcessor.updateTimestampWithCurrentTime(state), unit, ServiceType.BRIGHTNESS_STATE_SERVICE); } };
/** * Method updates the timestamp field of the given message with the given timestamp. * In case of an error the original message is returned. * * @param <M> the message type of the message to update. * @param timestamp the timestamp to update * @param messageOrBuilder the message * @param logger the logger which is used for printing the exception stack in case something went wrong. * @return the updated message or the original one in case of errors. */ public static <M extends MessageOrBuilder> M updateTimestamp(final long timestamp, final M messageOrBuilder, final Logger logger) { try { return updateTimestamp(timestamp, messageOrBuilder); } catch (CouldNotPerformException ex) { ExceptionPrinter.printHistory(ex, logger); return messageOrBuilder; } }
@Override public Future<ActionFuture> setPowerState(PowerState state) throws CouldNotPerformException { return update(TimestampProcessor.updateTimestampWithCurrentTime(state), unit, ServiceType.POWER_STATE_SERVICE); } };
@Override public Future<ActionFuture> setBlindState(BlindState state) throws CouldNotPerformException { return update(TimestampProcessor.updateTimestampWithCurrentTime(state), unit, ServiceType.BLIND_STATE_SERVICE); } };
/** * Method updates the timestamp field of the given message with the current time. * In case of an error the original message is returned. * * @param <M> the message type of the message to update. * @param messageOrBuilder the message * @param logger the logger which is used for printing the exception stack in case something went wrong. * @return the updated message or the original one in case of errors. */ public static <M extends MessageOrBuilder> M updateTimestampWithCurrentTime(final M messageOrBuilder, final Logger logger) { try { return updateTimestampWithCurrentTime(messageOrBuilder); } catch (CouldNotPerformException ex) { ExceptionPrinter.printHistory(ex, logger); return messageOrBuilder; } } }