use of org.talend.sdk.component.runtime.manager.ComponentFamilyMeta in project component-runtime by Talend.
the class ComponentResource method familyIcon.
/**
* Returns a particular family icon in raw bytes.
*
* @param id the family identifier.
* @return the family icon in binary form.
*/
@GET
@Path("icon/family/{id}")
public Response familyIcon(@PathParam("id") final String id) {
// todo: add caching if SvgIconResolver becomes used a lot - not the case ATM
final ComponentFamilyMeta meta = componentFamilyDao.findById(id);
if (meta == null) {
return Response.status(Response.Status.NOT_FOUND).entity(new ErrorPayload(ErrorDictionary.COMPONENT_MISSING, "No family for identifier: " + id)).type(APPLICATION_JSON_TYPE).build();
}
final Optional<Container> plugin = manager.findPlugin(meta.getPlugin());
if (!plugin.isPresent()) {
return Response.status(Response.Status.NOT_FOUND).entity(new ErrorPayload(ErrorDictionary.PLUGIN_MISSING, "No plugin '" + meta.getPlugin() + "' for identifier: " + id)).type(APPLICATION_JSON_TYPE).build();
}
final IconResolver.Icon iconContent = iconResolver.resolve(plugin.get().getLoader(), meta.getIcon());
if (iconContent == null) {
return Response.status(Response.Status.NOT_FOUND).entity(new ErrorPayload(ErrorDictionary.ICON_MISSING, "No icon for family identifier: " + id)).type(APPLICATION_JSON_TYPE).build();
}
return Response.ok(iconContent.getBytes()).type(iconContent.getType()).build();
}
use of org.talend.sdk.component.runtime.manager.ComponentFamilyMeta in project component-runtime by Talend.
the class AdminResource method reload.
@HEAD
@Path("{familyId}")
public void reload(@PathParam("familyId") final String familyId) {
final ComponentFamilyMeta family = ofNullable(componentFamilyDao.findById(familyId)).orElseThrow(() -> new WebApplicationException(Response.Status.NOT_FOUND));
service.manager().findPlugin(family.getPlugin()).orElseThrow(() -> new WebApplicationException(Response.Status.NOT_FOUND)).get(ContainerManager.Actions.class).reload();
log.info("Reloaded family {}", family.getName());
}
use of org.talend.sdk.component.runtime.manager.ComponentFamilyMeta in project component-runtime by Talend.
the class DesignContainerListener method onCreate.
/**
* Enriches {@link Container} with {@link DesignModel} and
* {@link RepositoryModel} It depends on Updater listener which adds
* {@link ContainerComponentRegistry} class to {@link Container}
*/
@Override
public void onCreate(final Container container) {
final ContainerComponentRegistry componentRegistry = container.get(ContainerComponentRegistry.class);
if (componentRegistry == null) {
throw new IllegalArgumentException("container doesn't contain ContainerComponentRegistry");
}
final Collection<ComponentFamilyMeta> componentFamilyMetas = componentRegistry.getComponents().values();
// Create Design Model
componentFamilyMetas.stream().flatMap(family -> Stream.concat(family.getPartitionMappers().values().stream(), family.getProcessors().values().stream())).forEach(meta -> {
final ComponentExtension.ComponentContext context = container.get(ComponentContexts.class).getContexts().get(meta.getType());
final ComponentExtension owningExtension = context.owningExtension();
meta.set(DesignModel.class, ofNullable(owningExtension).map(e -> e.unwrap(FlowsFactory.class, meta)).map(e -> new DesignModel(meta.getId(), e.getInputFlows(), e.getOutputFlows())).orElseGet(() -> {
final FlowsFactory factory = FlowsFactory.get(meta);
return new DesignModel(meta.getId(), factory.getInputFlows(), factory.getOutputFlows());
}));
});
// Create Repository Model
container.set(RepositoryModel.class, repositoryModelBuilder.create(container.get(ComponentManager.AllServices.class), componentFamilyMetas, migrationHandlerFactory));
}
use of org.talend.sdk.component.runtime.manager.ComponentFamilyMeta in project component-runtime by Talend.
the class RepositoryModelBuilderTest method notRootConfig.
@Test
void notRootConfig() {
final RepositoryModel model = new RepositoryModelBuilder().create(new ComponentManager.AllServices(emptyMap()), singleton(new ComponentFamilyMeta("test", emptyList(), "noicon", "test", "test") {
{
final ParameterMeta store = new ParameterMeta(null, DataStore1.class, ParameterMeta.Type.OBJECT, "config.store", "store", new String[0], emptyList(), emptyList(), new HashMap<String, String>() {
{
put("tcomp::configurationtype::type", "datastore");
put("tcomp::configurationtype::name", "testDatastore");
}
});
final ParameterMeta wrapper = new ParameterMeta(null, WrappingStore.class, ParameterMeta.Type.OBJECT, "config", "config", new String[0], singletonList(store), emptyList(), emptyMap());
getPartitionMappers().put("test", new PartitionMapperMeta(this, "mapper", "noicon", 1, PartitionMapper1.class, singletonList(wrapper), m -> null, (a, b) -> null, true) {
});
}
}), new MigrationHandlerFactory(new ReflectionService(new ParameterModelService())));
final List<Config> configs = model.getFamilies().stream().flatMap(f -> f.getConfigs().stream()).collect(toList());
assertEquals(1, configs.size());
}
Aggregations