@Test public void testMatchPresentDCTermOverwriteProperty() throws Exception { operation.setConfiguration(ConfigureByDublinCoreTermWOH.DCCATALOG_PROPERTY, "episode"); operation.setConfiguration(ConfigureByDublinCoreTermWOH.DCTERM_PROPERTY, "publisher"); operation.setConfiguration(ConfigureByDublinCoreTermWOH.MATCH_VALUE_PROPERTY, "University of Opencast"); operation.setConfiguration(ConfigureByDublinCoreTermWOH.COPY_PROPERTY, "false"); operation.setConfiguration("oldConfigProperty", "bar"); WorkflowOperationResult result = operationHandler.start(instance, null); Map<String, String> properties = result.getProperties(); Assert.assertTrue(properties.containsKey("oldConfigProperty")); Assert.assertEquals("bar", properties.get("oldConfigProperty")); }
@Override public WorkflowOperationResult start(WorkflowInstance workflowInstance, JobContext context) throws WorkflowOperationException { MediaPackage mediaPackage = workflowInstance.getMediaPackage(); WorkflowOperationInstance currentOperation = workflowInstance.getCurrentOperation(); String configuredCatalog = StringUtils.trimToEmpty(currentOperation.getConfiguration(DCCATALOG_PROPERTY)); String configuredDCTerm = StringUtils.trimToEmpty(currentOperation.getConfiguration(DCTERM_PROPERTY)); String configuredDefaultValue = StringUtils.trimToNull(currentOperation.getConfiguration(DEFAULT_VALUE_PROPERTY)); String configuredMatchValue = StringUtils.trimToEmpty(currentOperation.getConfiguration(MATCH_VALUE_PROPERTY)); Catalog[] catalogs = mediaPackage .getCatalogs(new MediaPackageElementFlavor("dublincore", StringUtils.lowerCase(configuredCatalog))); if (catalogs != null && catalogs.length > 0) { Boolean foundValue = false; EName dcterm = new EName(TERMS_NS_URI, configuredDCTerm); for (Catalog catalog : catalogs) { DublinCoreCatalog dc = DublinCoreUtil.loadDublinCore(workspace, catalog); List<DublinCoreValue> values = dc.get(dcterm); if (values.isEmpty()) { if (configuredDefaultValue != null) { foundValue = configuredDefaultValue.equals(configuredMatchValue); } } else { foundValue = values.contains(DublinCoreValue.mk(configuredMatchValue)); } } if (foundValue) { Map<String, String> properties = new HashMap<>(); for (String key : currentOperation.getConfigurationKeys()) { if (DCCATALOG_PROPERTY.equals(key) || DCTERM_PROPERTY.equals(key) || DEFAULT_VALUE_PROPERTY.equals(key) || MATCH_VALUE_PROPERTY.equals(key)) { continue; } String value = currentOperation.getConfiguration(key); properties.put(key, value); logger.info("Configuration key '{}' of workflow {} is set to value '{}'", key, workflowInstance.getId(), value); } return createResult(mediaPackage, properties, Action.CONTINUE, 0); } } return createResult(mediaPackage, Action.CONTINUE); }
ConfigureByDublinCoreTermWOH extends ResumableWorkflowOperationHandlerBase { @Override public WorkflowOperationResult start(WorkflowInstance workflowInstance, JobContext context) throws WorkflowOperationException { MediaPackage mediaPackage = workflowInstance.getMediaPackage(); WorkflowOperationInstance currentOperation = workflowInstance.getCurrentOperation(); String configuredCatalog = StringUtils.trimToEmpty(currentOperation.getConfiguration(DCCATALOG_PROPERTY)); String configuredDCTerm = StringUtils.trimToEmpty(currentOperation.getConfiguration(DCTERM_PROPERTY)); String configuredDefaultValue = StringUtils.trimToNull(currentOperation.getConfiguration(DEFAULT_VALUE_PROPERTY)); String configuredMatchValue = StringUtils.trimToEmpty(currentOperation.getConfiguration(MATCH_VALUE_PROPERTY)); Catalog[] catalogs = mediaPackage .getCatalogs(new MediaPackageElementFlavor("dublincore", StringUtils.lowerCase(configuredCatalog))); if (catalogs != null && catalogs.length > 0) { Boolean foundValue = false; EName dcterm = new EName(TERMS_NS_URI, configuredDCTerm); for (Catalog catalog : catalogs) { DublinCoreCatalog dc = DublinCoreUtil.loadDublinCore(workspace, catalog); List<DublinCoreValue> values = dc.get(dcterm); if (values.isEmpty()) { if (configuredDefaultValue != null) { foundValue = configuredDefaultValue.equals(configuredMatchValue); } } else { foundValue = values.contains(DublinCoreValue.mk(configuredMatchValue)); } } if (foundValue) { Map<String, String> properties = new HashMap<>(); for (String key : currentOperation.getConfigurationKeys()) { if (DCCATALOG_PROPERTY.equals(key) || DCTERM_PROPERTY.equals(key) || DEFAULT_VALUE_PROPERTY.equals(key) || MATCH_VALUE_PROPERTY.equals(key)) { continue; } String value = currentOperation.getConfiguration(key); properties.put(key, value); logger.info("Configuration key '{}' of workflow {} is set to value '{}'", key, workflowInstance.getId(), value); } return createResult(mediaPackage, properties, Action.CONTINUE, 0); } } return createResult(mediaPackage, Action.CONTINUE); } }
ConfigureByDublinCoreTermWOH extends ResumableWorkflowOperationHandlerBase { @Override public WorkflowOperationResult start(WorkflowInstance workflowInstance, JobContext context) throws WorkflowOperationException { MediaPackage mediaPackage = workflowInstance.getMediaPackage(); WorkflowOperationInstance currentOperation = workflowInstance.getCurrentOperation(); String configuredCatalog = StringUtils.trimToEmpty(currentOperation.getConfiguration(DCCATALOG_PROPERTY)); String configuredDCTerm = StringUtils.trimToEmpty(currentOperation.getConfiguration(DCTERM_PROPERTY)); String configuredDefaultValue = StringUtils.trimToNull(currentOperation.getConfiguration(DEFAULT_VALUE_PROPERTY)); String configuredMatchValue = StringUtils.trimToEmpty(currentOperation.getConfiguration(MATCH_VALUE_PROPERTY)); Catalog[] catalogs = mediaPackage .getCatalogs(new MediaPackageElementFlavor("dublincore", StringUtils.lowerCase(configuredCatalog))); if (catalogs != null && catalogs.length > 0) { Boolean foundValue = false; EName dcterm = new EName(TERMS_NS_URI, configuredDCTerm); for (Catalog catalog : catalogs) { DublinCoreCatalog dc = DublinCoreUtil.loadDublinCore(workspace, catalog); List<DublinCoreValue> values = dc.get(dcterm); if (values.isEmpty()) { if (configuredDefaultValue != null) { foundValue = configuredDefaultValue.equals(configuredMatchValue); } } else { foundValue = values.contains(DublinCoreValue.mk(configuredMatchValue)); } } if (foundValue) { Map<String, String> properties = new HashMap<>(); for (String key : currentOperation.getConfigurationKeys()) { if (DCCATALOG_PROPERTY.equals(key) || DCTERM_PROPERTY.equals(key) || DEFAULT_VALUE_PROPERTY.equals(key) || MATCH_VALUE_PROPERTY.equals(key)) { continue; } String value = currentOperation.getConfiguration(key); properties.put(key, value); logger.info("Configuration key '{}' of workflow {} is set to value '{}'", key, workflowInstance.getId(), value); } return createResult(mediaPackage, properties, Action.CONTINUE, 0); } } return createResult(mediaPackage, Action.CONTINUE); }  }
ConfigureByDublinCoreTermWOH extends ResumableWorkflowOperationHandlerBase { @Override public WorkflowOperationResult start(WorkflowInstance workflowInstance, JobContext context) throws WorkflowOperationException { MediaPackage mediaPackage = workflowInstance.getMediaPackage(); WorkflowOperationInstance currentOperation = workflowInstance.getCurrentOperation(); String configuredCatalog = StringUtils.trimToEmpty(currentOperation.getConfiguration(DCCATALOG_PROPERTY)); String configuredDCTerm = StringUtils.trimToEmpty(currentOperation.getConfiguration(DCTERM_PROPERTY)); String configuredDefaultValue = StringUtils.trimToNull(currentOperation.getConfiguration(DEFAULT_VALUE_PROPERTY)); String configuredMatchValue = StringUtils.trimToEmpty(currentOperation.getConfiguration(MATCH_VALUE_PROPERTY)); Catalog[] catalogs = mediaPackage .getCatalogs(new MediaPackageElementFlavor("dublincore", StringUtils.lowerCase(configuredCatalog))); if (catalogs != null && catalogs.length > 0) { Boolean foundValue = false; EName dcterm = new EName(TERMS_NS_URI, configuredDCTerm); for (Catalog catalog : catalogs) { DublinCoreCatalog dc = DublinCoreUtil.loadDublinCore(workspace, catalog); List<DublinCoreValue> values = dc.get(dcterm); if (values.isEmpty()) { if (configuredDefaultValue != null) { foundValue = configuredDefaultValue.equals(configuredMatchValue); } } else { foundValue = values.contains(DublinCoreValue.mk(configuredMatchValue)); } } if (foundValue) { Map<String, String> properties = new HashMap<>(); for (String key : currentOperation.getConfigurationKeys()) { if (DCCATALOG_PROPERTY.equals(key) || DCTERM_PROPERTY.equals(key) || DEFAULT_VALUE_PROPERTY.equals(key) || MATCH_VALUE_PROPERTY.equals(key)) { continue; } String value = currentOperation.getConfiguration(key); properties.put(key, value); logger.info("Configuration key '{}' of workflow {} is set to value '{}'", key, workflowInstance.getId(), value); } return createResult(mediaPackage, properties, Action.CONTINUE, 0); } } return createResult(mediaPackage, Action.CONTINUE); }  void setWorkspace(Workspace workspace); @Override WorkflowOperationResult start(WorkflowInstance workflowInstance, JobContext context); }
ConfigureByDublinCoreTermWOH extends ResumableWorkflowOperationHandlerBase { @Override public WorkflowOperationResult start(WorkflowInstance workflowInstance, JobContext context) throws WorkflowOperationException { MediaPackage mediaPackage = workflowInstance.getMediaPackage(); WorkflowOperationInstance currentOperation = workflowInstance.getCurrentOperation(); String configuredCatalog = StringUtils.trimToEmpty(currentOperation.getConfiguration(DCCATALOG_PROPERTY)); String configuredDCTerm = StringUtils.trimToEmpty(currentOperation.getConfiguration(DCTERM_PROPERTY)); String configuredDefaultValue = StringUtils.trimToNull(currentOperation.getConfiguration(DEFAULT_VALUE_PROPERTY)); String configuredMatchValue = StringUtils.trimToEmpty(currentOperation.getConfiguration(MATCH_VALUE_PROPERTY)); Catalog[] catalogs = mediaPackage .getCatalogs(new MediaPackageElementFlavor("dublincore", StringUtils.lowerCase(configuredCatalog))); if (catalogs != null && catalogs.length > 0) { Boolean foundValue = false; EName dcterm = new EName(TERMS_NS_URI, configuredDCTerm); for (Catalog catalog : catalogs) { DublinCoreCatalog dc = DublinCoreUtil.loadDublinCore(workspace, catalog); List<DublinCoreValue> values = dc.get(dcterm); if (values.isEmpty()) { if (configuredDefaultValue != null) { foundValue = configuredDefaultValue.equals(configuredMatchValue); } } else { foundValue = values.contains(DublinCoreValue.mk(configuredMatchValue)); } } if (foundValue) { Map<String, String> properties = new HashMap<>(); for (String key : currentOperation.getConfigurationKeys()) { if (DCCATALOG_PROPERTY.equals(key) || DCTERM_PROPERTY.equals(key) || DEFAULT_VALUE_PROPERTY.equals(key) || MATCH_VALUE_PROPERTY.equals(key)) { continue; } String value = currentOperation.getConfiguration(key); properties.put(key, value); logger.info("Configuration key '{}' of workflow {} is set to value '{}'", key, workflowInstance.getId(), value); } return createResult(mediaPackage, properties, Action.CONTINUE, 0); } } return createResult(mediaPackage, Action.CONTINUE); }  void setWorkspace(Workspace workspace); @Override WorkflowOperationResult start(WorkflowInstance workflowInstance, JobContext context); static final String DCCATALOG_PROPERTY; static final String DCTERM_PROPERTY; static final String DEFAULT_VALUE_PROPERTY; static final String MATCH_VALUE_PROPERTY; static final String COPY_PROPERTY; }