@Test public void testStartSelectByFlavor() throws Exception { operation.setConfiguration(StartTranscriptionOperationHandler.SOURCE_FLAVOR, "audio/ogg"); WorkflowOperationResult result = operationHandler.start(workflowInstance, null); Assert.assertEquals(Action.CONTINUE, result.getAction()); Assert.assertEquals("audioTrack1", capturedTrack.getValue().getIdentifier()); }
@Override public WorkflowOperationResult start(final WorkflowInstance workflowInstance, JobContext context) throws WorkflowOperationException { MediaPackage mediaPackage = workflowInstance.getMediaPackage(); WorkflowOperationInstance operation = workflowInstance.getCurrentOperation(); String skipOption = StringUtils.trimToNull(operation.getConfiguration(SKIP_IF_FLAVOR_EXISTS)); if (skipOption != null) { MediaPackageElement[] mpes = mediaPackage.getElementsByFlavor(MediaPackageElementFlavor.parseFlavor(skipOption)); if (mpes != null && mpes.length > 0) { logger.info( "Start transcription operation will be skipped because flavor {} already exists in the media package", skipOption); return createResult(Action.SKIP); } } logger.debug("Start transcription for mediapackage {} started", mediaPackage); String sourceTagOption = StringUtils.trimToNull(operation.getConfiguration(SOURCE_TAG)); String sourceFlavorOption = StringUtils.trimToNull(operation.getConfiguration(SOURCE_FLAVOR)); AbstractMediaPackageElementSelector<Track> elementSelector = new TrackSelector(); if (StringUtils.isBlank(sourceTagOption) && StringUtils.isBlank(sourceFlavorOption)) throw new WorkflowOperationException("No source tag or flavor have been specified!"); if (StringUtils.isNotBlank(sourceFlavorOption)) { String flavor = StringUtils.trim(sourceFlavorOption); try { elementSelector.addFlavor(MediaPackageElementFlavor.parseFlavor(flavor)); } catch (IllegalArgumentException e) { throw new WorkflowOperationException("Source flavor '" + flavor + "' is malformed"); } } if (sourceTagOption != null) elementSelector.addTag(sourceTagOption); Collection<Track> elements = elementSelector.select(mediaPackage, false); Job job = null; for (Track track : elements) { if (track.hasVideo()) { logger.info("Skipping track {} since it contains a video stream", track); continue; } try { job = service.startTranscription(mediaPackage.getIdentifier().toString(), track); break; } catch (TranscriptionServiceException e) { throw new WorkflowOperationException(e); } } if (job == null) { logger.info("No matching tracks found"); return createResult(mediaPackage, Action.CONTINUE); } if (!waitForStatus(job).isSuccess()) { throw new WorkflowOperationException("Transcription job did not complete successfully"); } logger.debug("External transcription job for mediapackage {} was created", mediaPackage); return createResult(Action.CONTINUE); }
StartTranscriptionOperationHandler extends AbstractWorkflowOperationHandler { @Override public WorkflowOperationResult start(final WorkflowInstance workflowInstance, JobContext context) throws WorkflowOperationException { MediaPackage mediaPackage = workflowInstance.getMediaPackage(); WorkflowOperationInstance operation = workflowInstance.getCurrentOperation(); String skipOption = StringUtils.trimToNull(operation.getConfiguration(SKIP_IF_FLAVOR_EXISTS)); if (skipOption != null) { MediaPackageElement[] mpes = mediaPackage.getElementsByFlavor(MediaPackageElementFlavor.parseFlavor(skipOption)); if (mpes != null && mpes.length > 0) { logger.info( "Start transcription operation will be skipped because flavor {} already exists in the media package", skipOption); return createResult(Action.SKIP); } } logger.debug("Start transcription for mediapackage {} started", mediaPackage); String sourceTagOption = StringUtils.trimToNull(operation.getConfiguration(SOURCE_TAG)); String sourceFlavorOption = StringUtils.trimToNull(operation.getConfiguration(SOURCE_FLAVOR)); AbstractMediaPackageElementSelector<Track> elementSelector = new TrackSelector(); if (StringUtils.isBlank(sourceTagOption) && StringUtils.isBlank(sourceFlavorOption)) throw new WorkflowOperationException("No source tag or flavor have been specified!"); if (StringUtils.isNotBlank(sourceFlavorOption)) { String flavor = StringUtils.trim(sourceFlavorOption); try { elementSelector.addFlavor(MediaPackageElementFlavor.parseFlavor(flavor)); } catch (IllegalArgumentException e) { throw new WorkflowOperationException("Source flavor '" + flavor + "' is malformed"); } } if (sourceTagOption != null) elementSelector.addTag(sourceTagOption); Collection<Track> elements = elementSelector.select(mediaPackage, false); Job job = null; for (Track track : elements) { if (track.hasVideo()) { logger.info("Skipping track {} since it contains a video stream", track); continue; } try { job = service.startTranscription(mediaPackage.getIdentifier().toString(), track); break; } catch (TranscriptionServiceException e) { throw new WorkflowOperationException(e); } } if (job == null) { logger.info("No matching tracks found"); return createResult(mediaPackage, Action.CONTINUE); } if (!waitForStatus(job).isSuccess()) { throw new WorkflowOperationException("Transcription job did not complete successfully"); } logger.debug("External transcription job for mediapackage {} was created", mediaPackage); return createResult(Action.CONTINUE); } }
StartTranscriptionOperationHandler extends AbstractWorkflowOperationHandler { @Override public WorkflowOperationResult start(final WorkflowInstance workflowInstance, JobContext context) throws WorkflowOperationException { MediaPackage mediaPackage = workflowInstance.getMediaPackage(); WorkflowOperationInstance operation = workflowInstance.getCurrentOperation(); String skipOption = StringUtils.trimToNull(operation.getConfiguration(SKIP_IF_FLAVOR_EXISTS)); if (skipOption != null) { MediaPackageElement[] mpes = mediaPackage.getElementsByFlavor(MediaPackageElementFlavor.parseFlavor(skipOption)); if (mpes != null && mpes.length > 0) { logger.info( "Start transcription operation will be skipped because flavor {} already exists in the media package", skipOption); return createResult(Action.SKIP); } } logger.debug("Start transcription for mediapackage {} started", mediaPackage); String sourceTagOption = StringUtils.trimToNull(operation.getConfiguration(SOURCE_TAG)); String sourceFlavorOption = StringUtils.trimToNull(operation.getConfiguration(SOURCE_FLAVOR)); AbstractMediaPackageElementSelector<Track> elementSelector = new TrackSelector(); if (StringUtils.isBlank(sourceTagOption) && StringUtils.isBlank(sourceFlavorOption)) throw new WorkflowOperationException("No source tag or flavor have been specified!"); if (StringUtils.isNotBlank(sourceFlavorOption)) { String flavor = StringUtils.trim(sourceFlavorOption); try { elementSelector.addFlavor(MediaPackageElementFlavor.parseFlavor(flavor)); } catch (IllegalArgumentException e) { throw new WorkflowOperationException("Source flavor '" + flavor + "' is malformed"); } } if (sourceTagOption != null) elementSelector.addTag(sourceTagOption); Collection<Track> elements = elementSelector.select(mediaPackage, false); Job job = null; for (Track track : elements) { if (track.hasVideo()) { logger.info("Skipping track {} since it contains a video stream", track); continue; } try { job = service.startTranscription(mediaPackage.getIdentifier().toString(), track); break; } catch (TranscriptionServiceException e) { throw new WorkflowOperationException(e); } } if (job == null) { logger.info("No matching tracks found"); return createResult(mediaPackage, Action.CONTINUE); } if (!waitForStatus(job).isSuccess()) { throw new WorkflowOperationException("Transcription job did not complete successfully"); } logger.debug("External transcription job for mediapackage {} was created", mediaPackage); return createResult(Action.CONTINUE); }  }
StartTranscriptionOperationHandler extends AbstractWorkflowOperationHandler { @Override public WorkflowOperationResult start(final WorkflowInstance workflowInstance, JobContext context) throws WorkflowOperationException { MediaPackage mediaPackage = workflowInstance.getMediaPackage(); WorkflowOperationInstance operation = workflowInstance.getCurrentOperation(); String skipOption = StringUtils.trimToNull(operation.getConfiguration(SKIP_IF_FLAVOR_EXISTS)); if (skipOption != null) { MediaPackageElement[] mpes = mediaPackage.getElementsByFlavor(MediaPackageElementFlavor.parseFlavor(skipOption)); if (mpes != null && mpes.length > 0) { logger.info( "Start transcription operation will be skipped because flavor {} already exists in the media package", skipOption); return createResult(Action.SKIP); } } logger.debug("Start transcription for mediapackage {} started", mediaPackage); String sourceTagOption = StringUtils.trimToNull(operation.getConfiguration(SOURCE_TAG)); String sourceFlavorOption = StringUtils.trimToNull(operation.getConfiguration(SOURCE_FLAVOR)); AbstractMediaPackageElementSelector<Track> elementSelector = new TrackSelector(); if (StringUtils.isBlank(sourceTagOption) && StringUtils.isBlank(sourceFlavorOption)) throw new WorkflowOperationException("No source tag or flavor have been specified!"); if (StringUtils.isNotBlank(sourceFlavorOption)) { String flavor = StringUtils.trim(sourceFlavorOption); try { elementSelector.addFlavor(MediaPackageElementFlavor.parseFlavor(flavor)); } catch (IllegalArgumentException e) { throw new WorkflowOperationException("Source flavor '" + flavor + "' is malformed"); } } if (sourceTagOption != null) elementSelector.addTag(sourceTagOption); Collection<Track> elements = elementSelector.select(mediaPackage, false); Job job = null; for (Track track : elements) { if (track.hasVideo()) { logger.info("Skipping track {} since it contains a video stream", track); continue; } try { job = service.startTranscription(mediaPackage.getIdentifier().toString(), track); break; } catch (TranscriptionServiceException e) { throw new WorkflowOperationException(e); } } if (job == null) { logger.info("No matching tracks found"); return createResult(mediaPackage, Action.CONTINUE); } if (!waitForStatus(job).isSuccess()) { throw new WorkflowOperationException("Transcription job did not complete successfully"); } logger.debug("External transcription job for mediapackage {} was created", mediaPackage); return createResult(Action.CONTINUE); }  @Override WorkflowOperationResult start(final WorkflowInstance workflowInstance, JobContext context); void setTranscriptionService(TranscriptionService service); }
StartTranscriptionOperationHandler extends AbstractWorkflowOperationHandler { @Override public WorkflowOperationResult start(final WorkflowInstance workflowInstance, JobContext context) throws WorkflowOperationException { MediaPackage mediaPackage = workflowInstance.getMediaPackage(); WorkflowOperationInstance operation = workflowInstance.getCurrentOperation(); String skipOption = StringUtils.trimToNull(operation.getConfiguration(SKIP_IF_FLAVOR_EXISTS)); if (skipOption != null) { MediaPackageElement[] mpes = mediaPackage.getElementsByFlavor(MediaPackageElementFlavor.parseFlavor(skipOption)); if (mpes != null && mpes.length > 0) { logger.info( "Start transcription operation will be skipped because flavor {} already exists in the media package", skipOption); return createResult(Action.SKIP); } } logger.debug("Start transcription for mediapackage {} started", mediaPackage); String sourceTagOption = StringUtils.trimToNull(operation.getConfiguration(SOURCE_TAG)); String sourceFlavorOption = StringUtils.trimToNull(operation.getConfiguration(SOURCE_FLAVOR)); AbstractMediaPackageElementSelector<Track> elementSelector = new TrackSelector(); if (StringUtils.isBlank(sourceTagOption) && StringUtils.isBlank(sourceFlavorOption)) throw new WorkflowOperationException("No source tag or flavor have been specified!"); if (StringUtils.isNotBlank(sourceFlavorOption)) { String flavor = StringUtils.trim(sourceFlavorOption); try { elementSelector.addFlavor(MediaPackageElementFlavor.parseFlavor(flavor)); } catch (IllegalArgumentException e) { throw new WorkflowOperationException("Source flavor '" + flavor + "' is malformed"); } } if (sourceTagOption != null) elementSelector.addTag(sourceTagOption); Collection<Track> elements = elementSelector.select(mediaPackage, false); Job job = null; for (Track track : elements) { if (track.hasVideo()) { logger.info("Skipping track {} since it contains a video stream", track); continue; } try { job = service.startTranscription(mediaPackage.getIdentifier().toString(), track); break; } catch (TranscriptionServiceException e) { throw new WorkflowOperationException(e); } } if (job == null) { logger.info("No matching tracks found"); return createResult(mediaPackage, Action.CONTINUE); } if (!waitForStatus(job).isSuccess()) { throw new WorkflowOperationException("Transcription job did not complete successfully"); } logger.debug("External transcription job for mediapackage {} was created", mediaPackage); return createResult(Action.CONTINUE); }  @Override WorkflowOperationResult start(final WorkflowInstance workflowInstance, JobContext context); void setTranscriptionService(TranscriptionService service);  }