/** * {@inheritDoc} * * @return {@inheritDoc} */ @Override public boolean isEnabled() { try { assert (getConfig() instanceof UnitConfig); return getConfig().getEnablingState().getValue().equals(EnablingState.State.ENABLED); } catch (CouldNotPerformException ex) { LoggerFactory.getLogger(org.openbase.bco.dal.lib.layer.unit.UnitRemote.class).warn("isEnabled() was called on non initialized unit!"); assert false; } return false; }
@Override public JsonObject upgrade(JsonObject agentConfig, final Map<File, JsonObject> dbSnapshot) { // remove activation state and use it to set up the enabling state if (agentConfig.has("activation_state")) { JsonObject activationState = agentConfig.getAsJsonObject("activation_state"); agentConfig.remove("activation_state"); JsonObject enablingState = new JsonObject(); if (activationState.has("value")) { EnablingState.State enablingValue = EnablingState.State.ENABLED; ActivationState.State activationValue = ActivationState.State.valueOf(activationState.getAsJsonPrimitive("value").getAsString()); switch (activationValue) { case ACTIVE: enablingValue = EnablingState.State.ENABLED; break; case DEACTIVE: enablingValue = EnablingState.State.DISABLED; break; case UNKNOWN: enablingValue = EnablingState.State.UNKNOWN; } enablingState.addProperty("value", enablingValue.toString()); } agentConfig.add("enabling_state", enablingState); } return agentConfig; } }
if (!unitConfig.getEnablingState().getValue().equals(EnablingStateType.EnablingState.State.ENABLED)) { continue;
/** * Method returns the state source(s) result(s) (contains state value(s)) of the input enablingState. * * @param enablingState The EnablingState. * @return state source(s) result(s) of the input state. */ private List<RdfNodeObject> enablingStateSources(final EnablingState enablingState) { final List<RdfNodeObject> stateSources = new ArrayList<>(); final String enablingStateVal = enablingState.getValue().toString(); stateSources.add(new RdfNodeObject(new ArrayList<String>() {{add(enablingStateVal);}}, false)); return stateSources; }
@Override public boolean enablingCondition(UnitConfig config) { return config.getEnablingState().getValue().equals(EnablingStateType.EnablingState.State.ENABLED); } };
private RdfTriple getInsertIsEnabledRelation(final UnitConfig unitConfig) throws NotAvailableException { if (unitConfig.getEnablingState().getValue().equals(State.ENABLED)) { return new RdfTriple(unitConfig.getId(), OntProp.IS_ENABLED.getName(), StringModifier.addQuotationMarks("true")); } else { return new RdfTriple(unitConfig.getId(), OntProp.IS_ENABLED.getName(), StringModifier.addQuotationMarks("false")); } }
private static void updateUnitLabel(final List<String> unitIds) throws CouldNotPerformException, InterruptedException, ExecutionException { for (String unitId : unitIds) { UnitConfig tmp = unitRegistry.getUnitConfigById(unitId); // ignore disabled test unit otherwise they would registered twice with the same label if another enabled instance of the same class exists. if (tmp.getEnablingState().getValue().equals(EnablingState.State.DISABLED)) { continue; } unitRegistry.updateUnitConfig(tmp.toBuilder().setLabel(UNIT_TYPE_LABEL_MAP.get(tmp.getType())).build()).get(); } }
private void verifyUnitConfig(final UnitConfig unitConfig) throws VerificationFailedException { if (!unitConfig.getEnablingState().getValue().equals(EnablingStateType.EnablingState.State.ENABLED)) { try { throw new VerificationFailedException("Referred Unit[" + ScopeGenerator.generateStringRep(unitConfig.getScope()) + "] is disabled!"); } catch (CouldNotPerformException ex) { ExceptionPrinter.printHistory(ex, LOGGER, LogLevel.WARN); throw new VerificationFailedException("Referred Unit[" + unitConfig.getLabel() + "] is disabled!"); } } }
public boolean isEnabled() { try { return getConfig().getEnablingState().getValue().equals(EnablingState.State.ENABLED); } catch (CouldNotPerformException ex) { ExceptionPrinter.printHistory(ex, logger); } return false; }