public interface ILfnCustomPropertyDecoder
TLfnData
resource.
Custom properties are name-value pairs, with the name uniquely identifying the property and the value
containing the information for that property. Custom properties can store any additional information you would want
to associate directly with a TLfnData
resource. They can be accessed by using the TLfnData.getCustomProperties()
method, or through the REST API (GET /api/data/{id}
).
Custom properties can be decoded from two possible sources, or a combination of both:
TLcdModelMetadata
returned from the ILcdModelDecoder
and the
TLcdISO19115Metadata
returned by a ILcdMetadataDecoder
. A custom ILcdMetadataDecoder
can be used to decode files with a proprietary format into ISO metadata. By default, LuciadFusion only support
ISO 19139 XML metadata files.
ILcdMetadataDecoder
has been registered that is capable of decoding these additional source files into
a TLcdISO19115Metadata
object, or if the information inside these files is not meant to be part of the
ISO19115 metadata of the dataset, implementations can access these additional source files directly and decode
the custom properties from them.
By providing custom property definitions, it is possible to specify a display name for a property and indicate if the
property is queryable. If a property is set to queryable, the property can be used to query Data resources through
the REST API (GET /api/data/filter
).
Add the Spring bean definition of your ILfnCustomPropertyDecoder
implementation to a Spring @Configuration
class and add the package containing that @Configuration
class to the fusion.config.additionalScanPackages
property so LuciadFusion can find your ILfnCustomPropertyDecoder
implementation in the application context
and can use it to decode custom properties.
In the following sample, we decode the status
property from the ISO metadata and provide it as a custom property.
public class CustomPropertyDecoder implements ILfnCustomPropertyDecoder {
@Override
public CustomPropertiesWithSource decode(String aSourceName, TLcdISO19115Metadata aMetadata) throws IOException {
Collection<TLfnCustomProperty> result = new ArrayList<>();
List<TLcdISO19115Identification> identificationInfo = aMetadata.getIdentificationInfo();
if (identificationInfo != null && !identificationInfo.isEmpty()) {
List<TLcdISO19115ProgressCode> statusCodes = identificationInfo.get(0).getStatus();
if (statusCodes != null && !statusCodes.isEmpty()) {
String status = statusCodes.get(0).getValueObject();
result.add(TLfnCustomProperty.newBuilder().name("status").stringValue(status).build());
}
}
return new CustomPropertiesWithSource(result);
}
@Override
public TLfnCustomPropertyDefinitions getPropertyDefinitions() {
return TLfnCustomPropertyDefinitions.newBuilder()
.addStringProperty("status", "Status", true)
.build();
}
}
Modifier and Type | Interface and Description |
---|---|
static class |
ILfnCustomPropertyDecoder.CustomPropertiesWithSource
A
TLfnCustomProperty collection paired with the additional source files from which they were decoded. |
Modifier and Type | Method and Description |
---|---|
ILfnCustomPropertyDecoder.CustomPropertiesWithSource |
decode(String aSourceName,
TLcdISO19115Metadata aMetadata)
Decodes the custom properties for a Data resource.
|
TLfnCustomPropertyDefinitions |
getPropertyDefinitions()
Get the custom property definitions.
|
ILfnCustomPropertyDecoder.CustomPropertiesWithSource decode(String aSourceName, TLcdISO19115Metadata aMetadata) throws IOException
This method returns a CustomPropertiesWithSource
object, which contains both the custom properties
and the list of all additional files used for decoding these custom properties. If all custom properties are
derived from the ISO metadata, the list of additional files is empty.
aSourceName
- points to the main data file of the Data resource. The decoder can use this path
to search for additional files containing custom properties and decodes them from there.aMetadata
- the ISO metadata of the Data resource. This ISO metadata is the combination of the
TLcdModelMetadata
returned from the ILcdModelDecoder
and the
TLcdISO19115Metadata
returned by a ILcdMetadataDecoder
. See the class javadoc for more details.IOException
- if something goes wrong decoding the custom propertiesTLfnCustomPropertyDefinitions getPropertyDefinitions()
It is recommended to define every property that can be returned by the decode
method, although it is not required.
Custom properties without a corresponding definition won't have a display name and will not be queryable. In
addition, the type of the property will not be validated by LuciadFusion.