0
# Storage & I/O Framework
1
2
Pluggable storage abstraction for form data with support for JSON storage, import/export operations, and custom storage adapters.
3
4
## Capabilities
5
6
### Storage Adapter Interface
7
8
```java { .api }
9
interface DDMStorageAdapter {
10
long create(DDMStorageAdapterSaveRequest ddmStorageAdapterSaveRequest) throws StorageException;
11
void deleteByClass(long ddmStructureId) throws StorageException;
12
void deleteByClassPK(long ddmStructureId, String ddmStructureKey, long classPK) throws StorageException;
13
DDMStorageAdapterGetResponse get(DDMStorageAdapterGetRequest ddmStorageAdapterGetRequest) throws StorageException;
14
void update(DDMStorageAdapterSaveRequest ddmStorageAdapterSaveRequest) throws StorageException;
15
}
16
17
class DDMStorageAdapterSaveRequest {
18
long getClassPK();
19
DDMFormValues getDDMFormValues();
20
long getDDMStructureId();
21
ServiceContext getServiceContext();
22
}
23
24
class DDMStorageAdapterGetResponse {
25
DDMFormValues getDDMFormValues();
26
}
27
```
28
29
### I/O Operations
30
31
```java { .api }
32
interface DDMFormInstanceRecordExporter {
33
byte[] export(long formInstanceId, int status) throws PortalException;
34
}
35
36
interface DDMFormValuesDeserializer {
37
DDMFormValues deserialize(String content);
38
}
39
40
interface DDMFormValuesSerializer {
41
String serialize(DDMFormValues ddmFormValues);
42
}
43
```
44
45
## Usage Examples
46
47
### Custom Storage Implementation
48
49
```java
50
@Component
51
public class CustomStorageExample implements DDMStorageAdapter {
52
53
@Override
54
public long create(DDMStorageAdapterSaveRequest request) throws StorageException {
55
DDMFormValues formValues = request.getDDMFormValues();
56
// Implement custom storage logic
57
return storeFormData(formValues);
58
}
59
60
@Override
61
public DDMStorageAdapterGetResponse get(DDMStorageAdapterGetRequest request) throws StorageException {
62
long classPK = request.getClassPK();
63
DDMFormValues formValues = retrieveFormData(classPK);
64
65
DDMStorageAdapterGetResponse response = new DDMStorageAdapterGetResponse();
66
response.setDDMFormValues(formValues);
67
return response;
68
}
69
70
private long storeFormData(DDMFormValues formValues) {
71
// Custom storage implementation
72
return System.currentTimeMillis(); // Return generated ID
73
}
74
75
private DDMFormValues retrieveFormData(long classPK) {
76
// Custom retrieval implementation
77
return new DDMFormValues();
78
}
79
}
80
```