use of org.apache.sis.internal.metadata.Merger in project sis by apache.
the class MetadataBuilder method mergeMetadata.
/**
* Merge the given metadata into the metadata created by this builder.
* The given source should be an instance of {@link Metadata},
* but some types of metadata components are accepted as well.
*
* <p>This method should be invoked last, just before the call to {@link #build(boolean)}.
* Any identification information, responsible party, extent, coverage description, <i>etc.</i>
* added after this method call will be stored in new metadata object (not merged).</p>
*
* @param source the source metadata to merge. Will never be modified.
* @param locale the locale to use for error message in exceptions, or {@code null} for the default locale.
* @return {@code true} if the given source has been merged,
* or {@code false} if its type is not managed by this builder.
* @throws RuntimeException if the merge failed (may be {@link IllegalArgumentException},
* {@link ClassCastException}, {@link org.apache.sis.metadata.InvalidMetadataException}…)
*
* @see Merger
*/
public boolean mergeMetadata(final Object source, final Locale locale) {
flush();
final ModifiableMetadata target;
if (source instanceof Metadata)
target = metadata();
else if (source instanceof DataIdentification)
target = identification();
else if (source instanceof Citation)
target = citation();
else if (source instanceof Series)
target = series();
else if (source instanceof DefaultResponsibleParty)
target = responsibility();
else if (source instanceof AbstractParty)
target = party();
else if (source instanceof LegalConstraints)
target = constraints();
else if (source instanceof Extent)
target = extent();
else if (source instanceof AcquisitionInformation)
target = acquisition();
else if (source instanceof Platform)
target = platform();
else if (source instanceof FeatureCatalogueDescription)
target = featureDescription();
else if (source instanceof CoverageDescription)
target = coverageDescription();
else if (source instanceof DefaultAttributeGroup)
target = attributeGroup();
else if (source instanceof SampleDimension)
target = sampleDimension();
else if (source instanceof GridSpatialRepresentation)
target = gridRepresentation();
else if (source instanceof GCPCollection)
target = groundControlPoints();
else if (source instanceof Distribution)
target = distribution();
else if (source instanceof Format)
target = format();
else if (source instanceof Lineage)
target = lineage();
else if (source instanceof ProcessStep)
target = processStep();
else if (source instanceof Processing)
target = processing();
else
return false;
final Merger merger = new Merger(locale);
merger.copy(source, target);
return true;
}
Aggregations