public ComponentDetail enrich(final ComponentDetail node, final String lang) { return doEnrich("component", lang, patch -> { final ComponentDetail copy = new ComponentDetail(node.getId(), node.getDisplayName(), node.getIcon(), node.getType(), node.getVersion(), new ArrayList<>(), new ArrayList<>(node.getActions()), node.getInputFlows(), node.getOutputFlows(), node.getLinks()); patch.doPatchProperties(copy.getProperties(), node.getProperties()); patch.appendBuiltInActions(copy.getActions()); return copy; }).orElse(node); }
final ComponentDetail componentDetail = new ComponentDetail(); componentDetail.setLinks(emptyList() /* todo ? */); componentDetail.setId(createMetaId(container, meta)); componentDetail.setVersion(meta.getVersion()); componentDetail.setIcon(meta.getIcon()); componentDetail.setInputFlows(model.get().getInputFlows()); componentDetail.setOutputFlows(model.get().getOutputFlows()); componentDetail .setType(ComponentFamilyMeta.ProcessorMeta.class.isInstance(meta) ? "processor" : "input"); componentDetail .setDisplayName(meta .findBundle(container.getLoader(), locale) .displayName() .orElse(meta.getName())); componentDetail .setProperties(propertiesService .buildProperties(meta.getParameterMetas(), container.getLoader(), locale, null) .collect(toList())); componentDetail .setActions(actionsService .findActions(meta.getParent().getName(), container, locale, meta, meta.getParent().findBundle(container.getLoader(), locale)));
@CacheResult public CompletionStage<Collection<SimplePropertyDefinition>> getComponentSpec(final String id) { return client .path("component/details") .queryParam("identifiers", id) .queryParam("language", "en") .request(APPLICATION_JSON_TYPE) .rx() .get(ComponentDetailList.class) .thenApply(list -> list.getDetails().iterator().next().getProperties()); }
/** * Converts a component form to a uiSpec. * * @param detail the component model. * @param context an optional custom context to propagate some parameters. * @return the uiSpec corresponding to the model. */ public CompletionStage<Ui> convert(final ComponentDetail detail, final String lang, final T context) { return convert(detail::getDisplayName, detail.getId()::getFamily, detail::getProperties, detail::getActions, p -> p.getName().equals(p.getPath()), context, lang); }