use of org.alfresco.transform.client.model.config.TransformOptionValue in project alfresco-repository by Alfresco.
the class TransformServiceRegistryConfigTest method retrieveTransformOptionByPropertyName.
private TransformOption retrieveTransformOptionByPropertyName(TransformOptionGroup transformOptionGroup, String propertyName, String propertyType) {
Iterator<TransformOption> iterator = transformOptionGroup.getTransformOptions().iterator();
List<TransformOption> transformOptionsList = new ArrayList<>();
while (iterator.hasNext()) {
transformOptionsList.add(iterator.next());
}
for (TransformOption t : transformOptionsList) {
if (t instanceof TransformOptionValue) {
TransformOptionValue value = (TransformOptionValue) t;
if (propertyType.equalsIgnoreCase("TransformOptionValue")) {
if (value.getName().equalsIgnoreCase(propertyName))
return value;
} else {
if (value.getName().contains(propertyName))
return transformOptionGroup;
}
} else {
TransformOption result = retrieveTransformOptionByPropertyName((TransformOptionGroup) t, propertyName, propertyType);
if (result != null)
return result;
}
}
return null;
}
use of org.alfresco.transform.client.model.config.TransformOptionValue in project alfresco-repository by Alfresco.
the class TransformServiceRegistryConfigTest method testJsonPipeline.
@Test
public void testJsonPipeline() throws IOException {
register(getTransformServiceConfigPipeline());
// Check the count of transforms supported
int expectedTransforms = getExpectedTransformsForTestJsonPipeline();
assertEquals("The number of UNIQUE source to target mimetypes transforms has changed. Config change?", expectedTransforms, countSupportedTransforms(true));
assertEquals("The number of source to target mimetypes transforms has changed. " + "There may be multiple transformers for the same combination. Config change?", expectedTransforms, countSupportedTransforms(false));
// Check required and optional default correctly
Map<String, List<SupportedTransform>> transformsToWord = registry.getData().getTransforms().get(DOC);
List<SupportedTransform> supportedTransforms = transformsToWord.get(GIF);
SupportedTransform supportedTransform = supportedTransforms.get(0);
Set<TransformOption> transformOptionsSet = supportedTransform.getTransformOptions().getTransformOptions();
Iterator<TransformOption> iterator = transformOptionsSet.iterator();
assertTrue("Expected transform values", iterator.hasNext());
// Because Set is unordered we don't know which TransformOptionGroup we retrieve
TransformOptionGroup transformOptions1 = (TransformOptionGroup) iterator.next();
assertTrue("Expected transform values", iterator.hasNext());
TransformOptionGroup transformOptions2 = (TransformOptionGroup) iterator.next();
TransformOptionGroup imagemagick;
TransformOptionGroup pdf;
if (containsTransformOptionValueName(transformOptions1, "alphaRemove")) {
imagemagick = transformOptions1;
pdf = transformOptions2;
} else {
imagemagick = transformOptions2;
pdf = transformOptions1;
}
TransformOptionValue alphaRemove = (TransformOptionValue) retrieveTransformOptionByPropertyName(imagemagick, "alphaRemove", "TransformOptionValue");
TransformOptionGroup crop = (TransformOptionGroup) retrieveTransformOptionByPropertyName(imagemagick, "crop", "TransformOptionGroup");
TransformOptionValue cropGravity = (TransformOptionValue) retrieveTransformOptionByPropertyName(crop, "cropGravity", "TransformOptionValue");
TransformOptionValue cropWidth = (TransformOptionValue) retrieveTransformOptionByPropertyName(crop, "cropWidth", "TransformOptionValue");
assertTrue("The holding group should be required", supportedTransform.getTransformOptions().isRequired());
assertFalse("imagemagick should be optional as it is not set", imagemagick.isRequired());
assertFalse("pdf should be optional as required is not set", pdf.isRequired());
assertEquals("alphaRemove", alphaRemove.getName());
assertEquals("cropGravity", cropGravity.getName());
assertEquals("cropWidth", cropWidth.getName());
assertFalse("alphaRemove should be optional as required is not set", alphaRemove.isRequired());
assertFalse("crop should be optional as required is not set", crop.isRequired());
assertTrue("cropGravity should be required as it is set", cropGravity.isRequired());
assertFalse("cropWidth should be optional as required is not set", cropWidth.isRequired());
// Check a supported transform for each transformer.
assertSupported(DOC, 1234, GIF, emptyMap(), null, "");
assertSupported(DOC, 1234, PNG, emptyMap(), null, "");
assertSupported(DOC, 1234, JPEG, emptyMap(), null, "");
assertSupported(DOC, 1234, TIFF, emptyMap(), null, "");
Map<String, String> actualOptions = new HashMap<>();
actualOptions.put("thumbnail", "true");
actualOptions.put("resizeWidth", "100");
actualOptions.put("resizeHeight", "100");
actualOptions.put("allowEnlargement", "false");
actualOptions.put("maintainAspectRatio", "true");
assertSupported(DOC, 1234, PNG, actualOptions, null, "");
}
Aggregations