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) 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<@NotNull Object, List<AttachmentMetadata>> listAttachmentsForFeaturesByFeatureId(TMFeatureType featureType, List<Object> featurePKs) List attachments for multiple features grouped by their IDs.
-
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
public static Map<@NotNull Object,List<AttachmentMetadata>> listAttachmentsForFeaturesByFeatureId(TMFeatureType featureType, List<Object> featurePKs) throws IOException List attachments for multiple features grouped by their IDs.
NOTE: the featurePKs list should containComparableobjects (e.g. nobyte[]), as these are used as map keys. E.g.byte[]is converted toByteBuffer.TODO: HTM-1771
- 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
-