public String renderComponentJob(ComponentJob job) { final ComponentDescriptor<?> desc = job.getDescriptor(); if (desc instanceof HasAnalyzerResultComponentDescriptor) { // if descriptor is an HasAnalyzerResultComponentDescriptor return renderMetrics(job, (HasAnalyzerResultComponentDescriptor<?>) desc); } // or else we cannot handle it return ""; }
protected ResultDescriptor getResultDescriptor(final ComponentJob componentJob, final AnalyzerResult analyzerResult) { final ComponentDescriptor<?> descriptor = componentJob.getDescriptor(); if (descriptor instanceof ResultDescriptor) { return (ResultDescriptor) descriptor; } // slightly more expensive, but potentially also better / more specific! return Descriptors.ofResult(analyzerResult); } }
@Override public Boolean eval(ComponentJob o) { final String actualDescriptorName = o.getDescriptor().getDisplayName(); final String metricDescriptorName = componentJobDescriptorName; return metricDescriptorName.equals(actualDescriptorName); } });
@Override public int compare(final ComponentJob o1, final ComponentJob o2) { int diff = o1.getDescriptor().compareTo(o2.getDescriptor()); if (diff == 0) { diff = ToStringComparator.getComparator().compare(o1.getName(), o2.getName()); } if (diff == 0) { diff = ToStringComparator.getComparator().compare(o1, o2); } if (diff == 0) { diff = o1.hashCode() - o2.hashCode(); } return diff; }
protected void writeBodyHtmlFragment(final Writer writer, final ComponentJob componentJob, final HtmlFragment htmlFragment, final HtmlRenderingContext context) throws IOException { final String displayName = componentJob.getDescriptor().getDisplayName(); final String styleName = toStyleName(displayName); writer.write("<div class=\"analyzerResult " + styleName + "\">"); if (_headers) { writeHeader(writer, componentJob, context, htmlFragment); } writer.write("<div class=\"analyzerResultContent\">\n"); final List<BodyElement> bodyElements = htmlFragment.getBodyElements(); for (final BodyElement bodyElement : bodyElements) { writeBodyElement(writer, componentJob, htmlFragment, bodyElement, context); } writer.write("</div>"); writer.write("<div class=\"analyzerResultFooter\"></div>"); writer.write("</div>\n"); }
private void cleanup() { logger.debug("cleanup()"); final int publishersLeft = _consumer.onPublisherClosed(_publisher); if (publishersLeft == 0) { final Object component = _consumer.getComponent(); final ComponentDescriptor<?> descriptor = _consumer.getComponentJob().getDescriptor(); // close can occur AFTER completion _lifeCycleHelper.close(descriptor, component, _success.get()); _consumer.getActiveOutputDataStreams().forEach(ActiveOutputDataStream::close); } }
/** * Gets the identifying input column of an {@link ComponentJob}, if there is * such a column. With an identifying input column, a externalizable * reference to the {@link ComponentJob} can be build, based on the * descriptor name, component name and the identifying column. * * @param componentJob * @return */ public static InputColumn<?> getIdentifyingInputColumn(final ComponentJob componentJob) { final ComponentDescriptor<?> descriptor = componentJob.getDescriptor(); final Set<ConfiguredPropertyDescriptor> inputProperties = descriptor.getConfiguredPropertiesForInput(false); if (inputProperties.size() != 1) { return null; } final ConfiguredPropertyDescriptor inputProperty = inputProperties.iterator().next(); final Object input = componentJob.getConfiguration().getProperty(inputProperty); if (input instanceof InputColumn) { return (InputColumn<?>) input; } else if (input instanceof InputColumn[]) { final InputColumn<?>[] inputColumns = (InputColumn[]) input; if (inputColumns.length != 1) { return null; } return inputColumns[0]; } return null; }
public Table[] getTables(final SourceColumnFinder sourceColumnFinder, final ComponentJob componentJob, Column[] physicalColumns) { if (physicalColumns == null) { physicalColumns = getPhysicalColumns(sourceColumnFinder, componentJob); } final Table[] tables; if (physicalColumns.length == 0) { // if not dependent on any specific tables, make component available // for all tables final Set<Table> allTables = new HashSet<>(); final Collection<InputColumn<?>> allSourceColumns = _analysisJob.getSourceColumns(); for (final InputColumn<?> inputColumn : allSourceColumns) { allTables.add(inputColumn.getPhysicalColumn().getTable()); } tables = allTables.toArray(new Table[allTables.size()]); } else { tables = MetaModelHelper.getTables(physicalColumns); } if (tables.length > 1) { if (!componentJob.getDescriptor().isMultiStreamComponent()) { throw new IllegalStateException("Component has input columns from multiple tables: " + componentJob); } } if (tables.length == 0) { throw new IllegalStateException("Component has no dependent tables: " + componentJob); } return tables; }
public Tab<AnalyzerResultPanel> getOrCreateResultPanel(final ComponentJob componentJob, final boolean finished) { synchronized (_resultPanels) { final Tab<AnalyzerResultPanel> existingTab = _resultPanels.get(componentJob); if (existingTab != null) { return existingTab; } String title = LabelUtils.getLabel(componentJob, false, false, false); if (title.length() > 40) { title = title.substring(0, 39) + "..."; } final Icon icon = IconUtils.getDescriptorIcon(componentJob.getDescriptor(), IconUtils.ICON_SIZE_TAB); final AnalyzerResultPanel resultPanel = new AnalyzerResultPanel(_rendererFactory, _progressInformationPanel, componentJob); final Tab<AnalyzerResultPanel> tab = _tabbedPane.addTab(title, icon, resultPanel); tab.setTooltip(LabelUtils.getLabel(componentJob, false, true, true)); _resultPanels.put(componentJob, tab); return tab; } }
private static void addJobConfigurations(final AnalysisJob job, final Set<Datastore> datastores, final Set<Dictionary> dictionaries, final Set<StringPattern> stringPatterns, final Set<SynonymCatalog> synonymCatalogs) { datastores.add(job.getDatastore()); Iterators.concat(job.getAnalyzerJobs().iterator(), job.getFilterJobs().iterator(), job.getTransformerJobs().iterator()).forEachRemaining(component -> { component.getDescriptor().getConfiguredProperties().forEach(descriptor -> { final Class<?> type = descriptor.getBaseType(); if (type == Datastore.class) { datastores.addAll(getProperties(component, descriptor)); } else if (type == Dictionary.class) { dictionaries.addAll(getProperties(component, descriptor)); } else if (type == StringPattern.class) { stringPatterns.addAll(getProperties(component, descriptor)); } else if (type == SynonymCatalog.class) { synonymCatalogs.addAll(getProperties(component, descriptor)); } }); for (final OutputDataStreamJob outputDataStreamJob : component.getOutputDataStreamJobs()) { addJobConfigurations(outputDataStreamJob.getJob(), datastores, dictionaries, stringPatterns, synonymCatalogs); } }); }
public ConsumerCreation getOrCreateConsumer(final RowProcessingPublisher publisher, final ComponentJob componentJob, final InputColumn<?>[] inputColumns) { RowProcessingConsumer consumer = _consumers.get(componentJob); final boolean create = consumer == null; if (create) { final Component component = (Component) componentJob.getDescriptor().newInstance(); if (componentJob instanceof AnalyzerJob) { final AnalyzerJob analyzerJob = (AnalyzerJob) componentJob; final Analyzer<?> analyzer = (Analyzer<?>) component; consumer = new AnalyzerConsumer(analyzer, analyzerJob, inputColumns, publisher); } else if (componentJob instanceof TransformerJob) { final TransformerJob transformerJob = (TransformerJob) componentJob; final Transformer transformer = (Transformer) component; consumer = new TransformerConsumer(transformer, transformerJob, inputColumns, publisher); } else if (componentJob instanceof FilterJob) { final FilterJob filterJob = (FilterJob) componentJob; final Filter<?> filter = (Filter<?>) component; consumer = new FilterConsumer(filter, filterJob, inputColumns, publisher); } else { throw new UnsupportedOperationException("Unsupported component job type: " + componentJob); } _consumers.put(componentJob, consumer); } consumer.registerPublisher(publisher); return new ConsumerCreation(consumer, create); }
final Collection<? extends ComponentJob> componentJobs) { for (final ComponentJob componentJob : componentJobs) { if (!componentJob.getDescriptor().isMultiStreamComponent()) { Table originatingTable = null; final InputColumn<?>[] input = componentJob.getInput();
lifeCycleHelper.close(consumer.getComponentJob().getDescriptor(), consumer.getComponent(), true);
/** * Creates a component builder similar to the incoming {@link ComponentJob}. * Note that input (columns and requirements) will not be mapped since these * depend on the context of the {@link FilterJob} and may not be matched in * the {@link AnalysisJobBuilder}. * * @param componentJob * * @return the builder object for the specific component */ protected ComponentBuilder addComponent(final ComponentJob componentJob) { final ComponentDescriptor<?> descriptor = componentJob.getDescriptor(); final ComponentBuilder builder = addComponent(descriptor); builder.setName(componentJob.getName()); builder.setConfiguredProperties(componentJob.getConfiguration()); builder.setMetadataProperties(componentJob.getMetadataProperties()); if (componentJob instanceof InputColumnSourceJob) { final InputColumn<?>[] output = ((InputColumnSourceJob) componentJob).getOutput(); final TransformerComponentBuilder<?> transformerJobBuilder = (TransformerComponentBuilder<?>) builder; final List<MutableInputColumn<?>> outputColumns = transformerJobBuilder.getOutputColumns(); assert output.length == outputColumns.size(); for (int i = 0; i < output.length; i++) { final MutableInputColumn<?> mutableOutputColumn = outputColumns.get(i); mutableOutputColumn.setName(output[i].getName()); } } return builder; }
componentDescriptor = (HasAnalyzerResultComponentDescriptor<?>) componentJob.getDescriptor(); metricDescriptor = componentDescriptor.getResultMetric(metricDescriptorName);
final ComponentBuilder builder = entry.getValue(); final Set<ConfiguredPropertyDescriptor> inputColumnProperties = componentJob.getDescriptor().getConfiguredPropertiesForInput(true);
public AnalyzerResultPanel(final RendererFactory rendererFactory, final ProgressInformationPanel progressInformationPanel, final ComponentJob componentJob) { super(WidgetUtils.COLOR_DEFAULT_BACKGROUND); _rendererFactory = rendererFactory; _progressInformationPanel = progressInformationPanel; _componentJob = componentJob; setBorder(new EmptyBorder(10, 10, 10, 10)); setLayout(new BorderLayout()); final ComponentDescriptor<?> descriptor = componentJob.getDescriptor(); final Icon icon = IconUtils.getDescriptorIcon(descriptor, IconUtils.ICON_SIZE_TASK_PANE); final String headerText = getHeaderText(); final JLabel header1 = createHeader(icon, headerText, WidgetUtils.FONT_HEADER1, WidgetUtils.BG_COLOR_DARK); final JLabel header2 = createHeader(null, getSubHeaderText(componentJob, headerText), WidgetUtils.FONT_SMALL, WidgetUtils.BG_COLOR_BLUE_MEDIUM); final DCPanel headerPanel = new DCPanel(); headerPanel.setLayout(new VerticalLayout(4)); headerPanel.add(header1); headerPanel.add(header2); headerPanel.setBorder(new EmptyBorder(0, 0, 4, 0)); add(headerPanel, BorderLayout.NORTH); _loadingIcon = new LoadingIcon(); add(_loadingIcon, BorderLayout.CENTER); }
final ComponentDescriptor<?> componentDescriptor = componentJobToUse.getDescriptor();
if (result instanceof AnalyzerResultFuture) { _progressInformationPanel.addUserLog( headerText + " is still in progress - see the '" + _componentJob.getDescriptor() .getDisplayName() + "' tab"); } else {
private static void executeInternal(final RowProcessingConsumer consumer, final RowProcessingPublisher publisher, final LifeCycleHelper lifeCycleHelper) { // we synchronize to avoid a race condition where initialization // is on-going in one stream and therefore skipped in the other synchronized (consumer) { final int publisherCount = consumer.onPublisherInitialized(publisher); if (publisherCount == 1) { final ComponentConfiguration configuration = consumer.getComponentJob().getConfiguration(); final ComponentDescriptor<?> descriptor = consumer.getComponentJob().getDescriptor(); final Object component = consumer.getComponent(); lifeCycleHelper.assignConfiguredProperties(descriptor, component, configuration); lifeCycleHelper.assignProvidedProperties(descriptor, component); lifeCycleHelper.validate(descriptor, component); final Collection<ActiveOutputDataStream> activeOutputDataStreams = consumer.getActiveOutputDataStreams(); for (final ActiveOutputDataStream activeOutputDataStream : activeOutputDataStreams) { activeOutputDataStream.initialize(); final RowProcessingPublisher outputDataStreamPublisher = activeOutputDataStream.getPublisher(); for (final RowProcessingConsumer outputDataStreamConsumer : outputDataStreamPublisher .getConsumers()) { final LifeCycleHelper outputDataStreamLifeCycleHelper = outputDataStreamPublisher.getPublishers().getConsumerSpecificLifeCycleHelper(consumer); executeInternal(outputDataStreamConsumer, outputDataStreamPublisher, outputDataStreamLifeCycleHelper); } } lifeCycleHelper.initialize(descriptor, component); } } }