mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
ALF-17892: Should be Easier to Override Individual Mappings for Metadata Extractors
- Changed behavior of AbstractMappingMetadataExtracter.init to allow for specified mapping property entries to override the default entries rather than be merged with them - Added Javadoc notes to setInheritDefaultMapping and setInheritDefaultEmbedMapping indicating on the behavior - Changed MappingMetadataExtracterTest.testPropertyMappingMerge to reflect the new expected result - Added MappingMetadataExtracterTest.testPropertyMappingDisable to test disabling a mapping git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@47010 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -373,6 +373,9 @@ abstract public class AbstractMappingMetadataExtracter implements MetadataExtrac
|
||||
* Set if the property mappings augment or override the mapping generically provided by the
|
||||
* extracter implementation. The default is <tt>false</tt>, i.e. any mapping set completely
|
||||
* replaces the {@link #getDefaultMapping() default mappings}.
|
||||
* <p>
|
||||
* Note that even when set to <tt>true</tt> an individual property mapping entry replaces the
|
||||
* entry provided by the extracter implementation.
|
||||
*
|
||||
* @param inheritDefaultMapping <tt>true</tt> to add the configured mapping
|
||||
* to the list of default mappings.
|
||||
@@ -426,6 +429,9 @@ abstract public class AbstractMappingMetadataExtracter implements MetadataExtrac
|
||||
* Set if the embed property mappings augment or override the mapping generically provided by the
|
||||
* extracter implementation. The default is <tt>false</tt>, i.e. any mapping set completely
|
||||
* replaces the {@link #getDefaultEmbedMapping() default mappings}.
|
||||
* <p>
|
||||
* Note that even when set to <tt>true</tt> an individual property mapping entry replaces the
|
||||
* entry provided by the extracter implementation.
|
||||
*
|
||||
* @param inheritDefaultEmbedMapping <tt>true</tt> to add the configured embed mapping
|
||||
* to the list of default embed mappings.
|
||||
@@ -976,9 +982,9 @@ abstract public class AbstractMappingMetadataExtracter implements MetadataExtrac
|
||||
{
|
||||
systemQNames = new HashSet<QName>(3);
|
||||
mapping.put(documentKey, systemQNames);
|
||||
Set<QName> defaultQNames = defaultMapping.get(documentKey);
|
||||
systemQNames.addAll(defaultQNames);
|
||||
}
|
||||
Set<QName> defaultQNames = defaultMapping.get(documentKey);
|
||||
systemQNames.addAll(defaultQNames);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1018,9 +1024,9 @@ abstract public class AbstractMappingMetadataExtracter implements MetadataExtrac
|
||||
{
|
||||
metadataKeys = new HashSet<String>(3);
|
||||
embedMapping.put(modelProperty, metadataKeys);
|
||||
Set<String> defaultMetadataKeys = defaultEmbedMapping.get(modelProperty);
|
||||
metadataKeys.addAll(defaultMetadataKeys);
|
||||
}
|
||||
Set<String> defaultMetadataKeys = defaultEmbedMapping.get(modelProperty);
|
||||
metadataKeys.addAll(defaultMetadataKeys);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -168,14 +168,28 @@ public class MappingMetadataExtracterTest extends TestCase
|
||||
// Added a3
|
||||
destination.clear();
|
||||
extracter.extract(reader, destination);
|
||||
assertEquals(5, destination.size());
|
||||
assertTrue(destination.containsKey(DummyMappingMetadataExtracter.QNAME_A1));
|
||||
assertTrue(destination.containsKey(DummyMappingMetadataExtracter.QNAME_A2));
|
||||
assertEquals(3, destination.size());
|
||||
assertTrue(destination.containsKey(DummyMappingMetadataExtracter.QNAME_A3));
|
||||
assertTrue(destination.containsKey(DummyMappingMetadataExtracter.QNAME_B));
|
||||
assertTrue(destination.containsKey(DummyMappingMetadataExtracter.QNAME_IMG));
|
||||
}
|
||||
|
||||
public void testPropertyMappingDisable() throws Exception
|
||||
{
|
||||
Properties props = new Properties();
|
||||
props.put("namespace.prefix.my", DummyMappingMetadataExtracter.NAMESPACE_MY);
|
||||
props.put(DummyMappingMetadataExtracter.PROP_A, "");
|
||||
extracter.setMappingProperties(props);
|
||||
extracter.setInheritDefaultMapping(true);
|
||||
extracter.register();
|
||||
// Added a3
|
||||
destination.clear();
|
||||
extracter.extract(reader, destination);
|
||||
assertEquals(2, destination.size());
|
||||
assertTrue(destination.containsKey(DummyMappingMetadataExtracter.QNAME_B));
|
||||
assertTrue(destination.containsKey(DummyMappingMetadataExtracter.QNAME_IMG));
|
||||
}
|
||||
|
||||
public void testPropertyMappingOverrideExtra() throws Exception
|
||||
{
|
||||
Properties props = new Properties();
|
||||
|
Reference in New Issue
Block a user