Class AttachmentsHelper
java.lang.Object
org.tailormap.api.geotools.featuresources.AttachmentsHelper
Helper class for managing the
<FT>_attachments sidecar tables in JDBC DataStores.-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionstatic voidcreateAttachmentTableForFeatureType(TMFeatureType featureType) Create attachment table and index for the given FeatureType.static voiddeleteAttachment(UUID attachmentId, TMFeatureType featureType) static voiddropAttachmentTableForFeatureType(TMFeatureType featureType) static StringfidFromPK(@NotNull TMFeatureType featureType, @NotNull Object featurePK) Constructs a Feature ID (FID) string from a feature type and primary key value.getAttachment(TMFeatureType featureType, UUID attachmentId) static AttachmentMetadatainsertAttachment(TMFeatureType featureType, AttachmentMetadata attachment, Object primaryKey, byte[] fileData) static List<AttachmentMetadata> listAttachmentsForFeature(TMFeatureType featureType, Object primaryKey) static Map<String, List<AttachmentMetadata>> listAttachmentsForFeaturesByFeatureId(TMFeatureType featureType, List<Object> featurePKs) List attachments for multiple features grouped by their FIDs.
-
Method Details
-
createAttachmentTableForFeatureType
public static void createAttachmentTableForFeatureType(TMFeatureType featureType) throws IOException, SQLException, IllegalArgumentException Create attachment table and index for the given FeatureType. This will validate that any AttachmentAttribute has a valid name.- Parameters:
featureType- the FeatureType to create the attachment table for- Throws:
IOException- when creating the GeoTools datastore failsSQLException- when executing the SQL statements failsIllegalArgumentException- when the FeatureType is invalid
-
dropAttachmentTableForFeatureType
public static void dropAttachmentTableForFeatureType(TMFeatureType featureType) throws IOException, SQLException - Throws:
IOExceptionSQLException
-
insertAttachment
public static AttachmentMetadata insertAttachment(TMFeatureType featureType, AttachmentMetadata attachment, Object primaryKey, byte[] fileData) throws IOException, SQLException - Throws:
IOExceptionSQLException
-
deleteAttachment
public static void deleteAttachment(UUID attachmentId, TMFeatureType featureType) throws IOException, SQLException - Throws:
IOExceptionSQLException
-
listAttachmentsForFeature
public static List<AttachmentMetadata> listAttachmentsForFeature(TMFeatureType featureType, Object primaryKey) throws IOException, SQLException - Throws:
IOExceptionSQLException
-
getAttachment
public static AttachmentsHelper.AttachmentWithBinary getAttachment(TMFeatureType featureType, UUID attachmentId) throws IOException, SQLException - Throws:
IOExceptionSQLException
-
listAttachmentsForFeaturesByFeatureId
@NonNull public static Map<String,List<AttachmentMetadata>> listAttachmentsForFeaturesByFeatureId(TMFeatureType featureType, List<Object> featurePKs) throws IOException List attachments for multiple features grouped by their FIDs.
NOTE: the featurePKs list should contain objects that can be used as primary keys.- Parameters:
featureType- the feature typefeaturePKs- the feature primary keys- Returns:
- map of feature ID to list of attachments
- Throws:
IOException- when an IO error occurs connecting to the database
-
fidFromPK
public static String fidFromPK(@NotNull @NotNull TMFeatureType featureType, @NotNull @NotNull Object featurePK) Constructs a Feature ID (FID) string from a feature type and primary key value. The FID format is "{featureTypeName}.{primaryKey}". For byte[] primary keys, the bytes are converted to UUID format.- Parameters:
featureType- the feature typefeaturePK- the feature primary key (supports String, Number, UUID, byte[], etc.)- Returns:
- the constructed FID as a String
-