serviceDescriptionList.add(serviceDescription.toBuilder().setServiceTemplateId(serviceTemplate.getId()).build()); modification = true; } else { if(serviceDescription.hasType() && serviceTemplate.getType() == serviceDescription.getType()) { serviceDescriptionList.add(serviceDescription.toBuilder().setType(serviceTemplate.getType()).build()); modification = true;
@Override public void init(ProtoBufRegistry<String, ServiceTemplate, ServiceTemplate.Builder> config) throws InitializationException, InterruptedException { try { ServiceTemplate template; // create missing unit template if (registry.size() <= ServiceType.values().length - 1) { for (ServiceType serviceType : ServiceType.values()) { if (serviceType == ServiceType.UNKNOWN) { continue; } template = ServiceTemplate.newBuilder().setType(serviceType).build(); if (!containsServiceTemplateByType(serviceType)) { registry.register(template); } } } } catch (CouldNotPerformException ex) { throw new InitializationException("Could not init " + getClass().getSimpleName() + "!", ex); } }
/** * Method returns the state name of the appurtenant service. * * @param template The service template. * @return The state type name as string. * @throws org.openbase.jul.exception.NotAvailableException is thrown in case the given template is null. * // */ public static String getServiceStateName(final ServiceTemplate template) throws NotAvailableException { try { if (template == null) { assert false; throw new NotAvailableException("ServiceTemplate"); } return getServiceStateName(template.getType()); } catch (CouldNotPerformException ex) { throw new NotAvailableException("ServiceStateName", ex); } }
private static boolean hasPowerStateService(UnitConfig config) throws InterruptedException { for (ServiceConfig sc : config.getServiceConfigList()) { ServiceTemplate.ServiceType type; try { type = getUnitRegistry().getServiceTemplateById(sc.getServiceDescription().getServiceTemplateId()).getType(); } catch (CouldNotPerformException ex) { type = sc.getServiceDescription().getType(); } if (ServiceTemplate.ServiceType.POWER_STATE_SERVICE == type && ServiceTemplate.ServicePattern.OPERATION == sc.getServiceDescription().getPattern()) { return true; } } return false; }
private boolean containsServiceTemplateByType(ServiceType type) throws CouldNotPerformException { for (ServiceTemplate serviceTemplate : registry.getMessages()) { if (serviceTemplate.getType() == type) { return true; } } return false; }
private ServiceTemplate getServiceTemplateByType(ServiceType type) throws CouldNotPerformException { for (ServiceTemplate serviceTemplate : serviceTemplateRegistry.getMessages()) { if (serviceTemplate.getType() == type) { return serviceTemplate; } } throw new NotAvailableException("ServiceTemplate with type[" + type + "]"); } }
@Override public ServiceTemplate getServiceTemplateByType(ServiceType type) throws CouldNotPerformException { for (ServiceTemplate serviceTemplate : serviceTemplateRegistry.getMessages()) { if (serviceTemplate.getType() == type) { return serviceTemplate; } } throw new NotAvailableException("ServiceTemplate with type [" + type + "]"); }
@Override public ServiceTemplate getServiceTemplateByType(ServiceType type) throws CouldNotPerformException { validateData(); for (final ServiceTemplate serviceTemplates : serviceTemplateRemoteRegistry.getMessages()) { if (serviceTemplates.getType() == type) { return serviceTemplates; } } throw new NotAvailableException("ServiceTemplate", type.name(), "No ServiceTemplate with given Type[" + type + "] registered!"); }
public String getServiceIdByType(ServiceTemplateType.ServiceTemplate.ServiceType serviceType) throws CouldNotPerformException { for (ServiceTemplateType.ServiceTemplate serviceTemplate : serviceTemplateRegistry.getMessages()) { if (serviceTemplate.getType() == serviceType) { return serviceTemplate.getId(); } } throw new NotAvailableException("Now service template for type[" + serviceType.name() + "] found!", "service id"); }
public String getServiceIdByType(ServiceType serviceType) throws CouldNotPerformException { for (ServiceTemplate serviceTemplate : serviceTemplateRegistry.getMessages()) { if (serviceTemplate.getType() == serviceType) { return serviceTemplate.getId(); } } throw new NotAvailableException("Now service template for type[" + serviceType.name() + "] found!", "service id"); } }