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:
-
The ISO metadata that LuciadFusion will generate for the dataset. This ISO metadata is the combination of the
TLcdModelMetadata
returned from theILcdModelDecoder
and theTLcdISO19115Metadata
returned by aILcdMetadataDecoder
. A customILcdMetadataDecoder
can be used to decode files with a proprietary format into ISO metadata. By default, LuciadFusion only support ISO 19139 XML metadata files. -
Additional source files located next to the data file(s) of the dataset.
If no
ILcdMetadataDecoder
has been registered that is capable of decoding these additional source files into aTLcdISO19115Metadata
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
).
Integration in LuciadFusion
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.
Example
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();
}
}
- Since:
- 2022.1
-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic class
ATLfnCustomProperty
collection paired with the additional source files from which they were decoded. -
Method Summary
Modifier and TypeMethodDescriptiondecode
(String aSourceName, TLcdISO19115Metadata aMetadata) Decodes the custom properties for a Data resource.Get the custom property definitions.
-
Method Details
-
decode
ILfnCustomPropertyDecoder.CustomPropertiesWithSource decode(String aSourceName, TLcdISO19115Metadata aMetadata) throws IOException Decodes the custom properties for a Data resource. Custom properties can be decoded from two possible sources: the ISO metadata of the Data resource or additional source files located next to the data file.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.- Parameters:
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 theTLcdModelMetadata
returned from theILcdModelDecoder
and theTLcdISO19115Metadata
returned by aILcdMetadataDecoder
. See the class javadoc for more details.- Returns:
- the custom properties
- Throws:
IOException
- if something goes wrong decoding the custom properties
-
getPropertyDefinitions
TLfnCustomPropertyDefinitions getPropertyDefinitions()Get the custom property definitions. These definitions are global, which means that they apply to all custom properties in LuciadFusion.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.- Returns:
- the custom property definitions
-