public AdapterDescription(AdapterDescription other) { super(other); this.adapterId = other.getAdapterId(); this.userName = other.getUserName(); this.rules = other.getRules(); this.adapterType = other.getAdapterType(); this.icon = other.getIcon(); if (other.getEventGrounding() != null) this.eventGrounding = new EventGrounding(other.getEventGrounding()); }
protected AdapterDescriptionBuilder(String id, String label, String description, T adapterTypeInstance) { super(id, label, description, adapterTypeInstance); this.elementDescription.setAdapterId(id); } }
String uri = adapterDescription.getUri() + UUID.randomUUID().toString(); adapterDescription.setUri(uri); adapterDescription.setElementId(uri); adapterDescription.setAdapterId(uri); return adapterDescription.getId();
public static AdapterDescription getAdapterDescription(String jsonld) throws AdapterException { Set<String> adapterIds = AdapterRegistry.getAllAdapters().keySet(); AdapterDescription result = null; for (String key : adapterIds) { if (jsonld.contains(key)) { Adapter adapter = AdapterRegistry.getAllAdapters().get(key); AdapterDescription resultDescription = adapter.declareModel(); result = JsonLdUtils.fromJsonLd(jsonld, resultDescription.getClass()); if (result.getAdapterId() == null) { result.setAdapterId(result.getUri()); } } } if (result == null) { throw new AdapterException("Json-Ld of adapter description could not be deserialized: " + jsonld); } return result; } }
public static Adapter getAdapter(AdapterDescription adapterDescription) { if (adapterDescription != null) { Map<String, Adapter> adapterMap = AdapterRegistry.getAllAdapters(); return adapterMap.get(adapterDescription.getAdapterId()).getInstance(adapterDescription); } else { return null; } }
private AdapterPipeline getAdapterPipeline(T adapterDescription) { List<AdapterPipelineElement> pipelineElements = new ArrayList<>(); // Must be before the schema transformations to ensure that user can move this event property TimestampTransformationRuleDescription timestampTransformationRuleDescription = getTimestampRule(adapterDescription); if (timestampTransformationRuleDescription != null) { pipelineElements.add(new AddTimestampPipelineElement(timestampTransformationRuleDescription.getRuntimeKey())); } AddValueTransformationRuleDescription valueTransformationRuleDescription = getAddValueRule(adapterDescription); if (valueTransformationRuleDescription != null) { pipelineElements.add(new AddValuePipelineElement(valueTransformationRuleDescription.getRuntimeKey(), valueTransformationRuleDescription.getStaticValue())); } // first transform schema before transforming vales // value rules should use unique keys for of new schema pipelineElements.add(new TransformSchemaAdapterPipelineElement(adapterDescription.getSchemaRules())); pipelineElements.add(new TransformValueAdapterPipelineElement(adapterDescription.getValueRules())); RemoveDuplicatesTransformationRuleDescription duplicatesTransformationRuleDescription = getRemoveDuplicateRule(adapterDescription); if (duplicatesTransformationRuleDescription != null) { pipelineElements.add(new DuplicateFilterPipelineElement(duplicatesTransformationRuleDescription.getFilterTimeWindow())); } // Needed when adapter is if (adapterDescription.getEventGrounding() != null && adapterDescription.getEventGrounding().getTransportProtocol() != null && adapterDescription.getEventGrounding().getTransportProtocol().getBrokerHostname() != null) { pipelineElements.add(new SendToKafkaAdapterSink( adapterDescription)); } return new AdapterPipeline(pipelineElements); }
ad.setEventGrounding(eventGrounding); ad.setElementId(newId); String adapterCouchdbId = ""; for (AdapterDescription a : allAdapters) { if (a.getElementId().equals(ad.getElementId())) { adapterCouchdbId = a.getId();
String topic = adapterDescription.getEventGrounding().getTransportProtocol().getTopicDefinition().getActualTopicName(); String url = adapterDescription.getUri().toString(); ds.setName(adapterDescription.getName()); ds.setDescription("Description");
public static String extractBroker(AdapterDescription adapterDescription) { String host = adapterDescription.getEventGrounding().getTransportProtocol().getBrokerHostname(); int port = ((KafkaTransportProtocol) adapterDescription.getEventGrounding().getTransportProtocol()).getKafkaPort(); return host + ":" + port; }
String uriString = null; try { uriString = ad.getUri(); uri = new URI(uriString); } catch (URISyntaxException e) { Description d = new Description(ad.getName(), "", uri); d.setType("set"); streams.add(d); DataSourceDescriptionHtml dsd = new DataSourceDescriptionHtml("Adapter Stream", "This stream is generated by an StreamPipes Connect adapter. ID of adapter: " + ad.getId(), uri, streams); dsd.setType("source"); allAdapterDescriptions.add(dsd);
logger.info("User: " + userName + " starts adapter " + adapterDescription.getAdapterId()); AdapterStorageImpl(), userName); } catch (AdapterException e) { logger.error("Error while starting adapter with id " + adapterDescription.getAppId(), e); return ok(Notifications.error(e.getMessage()));
String username = ad.getUserName(); String elementUrl = ad.getUri();
private <G extends TransformationRuleDescription> G getRule(T adapterDescription, Class<G> type) { for (TransformationRuleDescription tr : adapterDescription.getRules()) { if (type.isInstance(tr)) { return type.cast(tr); } } return null; }
public static void startAllStreamAdapters() throws AdapterException { AdapterStorageImpl adapterStorage = new AdapterStorageImpl(); List<AdapterDescription> allAdapters = adapterStorage.getAllAdapters(); for (AdapterDescription ad : allAdapters) { if (ad instanceof AdapterStreamDescription) { String url = Utils.addUserNameToApi(ConnectContainerConfig.INSTANCE.getConnectContainerWorkerUrl(), ad.getUserName()); WorkerRestClient.invokeStreamAdapter(url, (AdapterStreamDescription) ad); } } }
for (StaticProperty property: adapterDescription.getConfig()) { if (property.getInternalName().equals("sensortype")) { ((FreeTextStaticProperty)property).setValue("bla");
public AdapterDescription getAdapter(String id, AdapterStorageImpl adapterStorage) throws AdapterException { List<AdapterDescription> allAdapters = adapterStorage.getAllAdapters(); if (allAdapters != null && id != null) { for (AdapterDescription ad : allAdapters) { if (id.equals(ad.getAdapterId())) { return ad; } } } throw new AdapterException("Could not find adapter with id: " + id); }
public static String extractTopic(AdapterDescription adapterDescription) { return adapterDescription.getEventGrounding().getTransportProtocol().getTopicDefinition().getActualTopicName(); }
public static Adapter getAdapter(AdapterDescription adapterDescription) { if (adapterDescription != null) { Map<String, Adapter> adapterMap = AdapterRegistry.getAllAdapters(); return adapterMap.get(adapterDescription.getAdapterId()).getInstance(adapterDescription); } else { return null; } }
private static EventGrounding getEventGrounding(AdapterDescription adapterDescription) { EventGrounding eventGrounding = null; if (adapterDescription instanceof SpecificAdapterSetDescription) { eventGrounding = ((SpecificAdapterSetDescription) adapterDescription).getDataSet().getEventGrounding(); } else if (adapterDescription instanceof GenericAdapterSetDescription) { eventGrounding = ((GenericAdapterSetDescription) adapterDescription).getDataSet().getEventGrounding(); } else { eventGrounding = adapterDescription.getEventGrounding(); } return eventGrounding; }