[MGNLDAM-725] External-dam-app: media field not loaded when view asset details Created: 21/Sep/17 Updated: 07/Nov/17 Resolved: 06/Nov/17 |
|
| Status: | Closed |
| Project: | Magnolia DAM Module |
| Component/s: | None |
| Affects Version/s: | 2.2.6 |
| Fix Version/s: | 2.3 |
| Type: | Bug | Priority: | Neutral |
| Reporter: | Jonathan Ayala | Assignee: | Robert Šiška |
| Resolution: | Fixed | Votes: | 1 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Attachments: |
|
||||
| Issue Links: |
|
||||
| Template: |
|
||||
| Acceptance criteria: |
Empty
|
||||
| Task DoD: |
[ ]*
Doc/release notes changes? Comment present?
[ ]*
Downstream builds green?
[ ]*
Solution information and context easily available?
[ ]*
Tests
[ ]*
FixVersion filled and not yet released
[ ] 
Architecture Decision Record (ADR)
|
||||
| Bug DoR: |
[ ]*
Steps to reproduce, expected, and actual results filled
[ ]*
Affected version filled
|
||||
| Date of First Response: | |||||
| Sprint: | Kromeriz 119, Kromeriz 120, Kromeriz 121 | ||||
| Story Points: | 5 | ||||
| Description |
|
When using external-dam-app without changing the initial configuration, if an asset is selected and view asset action is clicked, media and metadata fields are not shown correctly in the form. external-dam-app version 2.2.6 Here's the log's output: WARN agnolia.ui.form.field.factory.AbstractFieldFactory: BeanItem doesn't have any property for id media, returning default property WARN agnolia.ui.form.field.factory.AbstractFieldFactory: BeanItem doesn't have any property for id metadata, returning default property |
| Comments |
| Comment by Pieter Ardinois [ 25/Sep/17 ] |
|
I've fixed this locally by overriding the initializeProperty method in the field factory. Hereby the code of the original initializeProperty that is in AbstractFieldFactory: @SuppressWarnings("unchecked") protected Property<T> initializeProperty() { // exclude selectively for now; ultimately we might reduce that to JCR adapters only. boolean useTransformers = !(item instanceof BeanItem); if (useTransformers) { Class<? extends Transformer<?>> transformerClass = definition.getTransformerClass(); if (transformerClass == null) { // Down casting is needed due to API of the #initializeTransformer(Class<? extends Transformer<?>>) // the second wildcard in '? extends Transformer< --> ?>' is unnecessary and only forces compiler // to claim that BasicTransformer.class is not convertible into Class<? extends Transformer<?>>. // At runtime it all works due to type erasure. transformerClass = (Class<? extends Transformer<?>>) (Object) BasicTransformer.class; } Transformer<?> transformer = initializeTransformer(transformerClass); transformer.setLocale(locale); return new TransformedProperty(transformer); } else { // return property straight from the Item for the field binding, no assumption on conversion/saving strategy here. Property property = item.getItemProperty(definition.getName()); if (property == null) { log.warn(String.format("BeanItem doesn't have any property for id %s, returning default property", definition.getName())); Class<?> propertyType = DefaultPropertyUtil.getFieldTypeClass(definition.getType()); property = new ObjectProperty<>(null, propertyType); item.addItemProperty(definition.getName(), property); } return property; } } I've created my own FieldFactory: MyAssetMediaFieldFactory, that extends from AssetMediaFieldFactory: I've overriden the method: @SuppressWarnings("unchecked") protected Property<BeanItem> initializeProperty() { Class<? extends Transformer<?>> transformerClass = definition.getTransformerClass(); if (transformerClass == null) { transformerClass = (Class<? extends Transformer<?>>) (Object) BasicTransformer.class; } Transformer<?> transformer = initializeTransformer(transformerClass); return new TransformedProperty(transformer); } It fixes the issue. |
| Comment by Jonathan Ayala [ 25/Sep/17 ] |
|
Thank you very much Pieter for sharing your workaround. Kind Regards. |