|
7 | 7 | import java.util.List; |
8 | 8 | import java.util.Map; |
9 | 9 |
|
| 10 | +/** |
| 11 | + * Command for executing multiple data modification operations (insert, update, delete) in a single request |
| 12 | + * to a LabKey Server. This command allows batching multiple operations together, optionally in a transaction. |
| 13 | + * <p> |
| 14 | + * All data exposed from a LabKey Server is organized into schemas containing queries. Each command in a batch |
| 15 | + * specifies the schema name (e.g., 'lists' or 'study') and query name (e.g., 'People' or 'Samples') to operate on. |
| 16 | + * <p> |
| 17 | + * The command supports several features: |
| 18 | + * <ul> |
| 19 | + * <li>Multiple operations (insert, update, delete) in a single request</li> |
| 20 | + * <li>Optional transaction support to ensure all-or-nothing execution</li> |
| 21 | + * <li>Validation-only mode to check operations without making changes</li> |
| 22 | + * <li>Audit trail support with configurable detail levels</li> |
| 23 | + * <li>Custom audit comments for tracking changes</li> |
| 24 | + * </ul> |
| 25 | + * <p> |
| 26 | + * Example usage: |
| 27 | + * <pre><code> |
| 28 | + * ApiKeyCredentialsProvider credentials = new ApiKeyCredentialsProvider("xxx"); |
| 29 | + * Connection conn = new Connection("http://localhost:8080", credentials); |
| 30 | + * SaveRowsApiCommand saveCmd = new SaveRowsApiCommand(); |
| 31 | + * |
| 32 | + * // Add new gene annotations |
| 33 | + * saveCmd.addCommand(new Command(CommandType.Insert, "genome", "GeneAnnotations", |
| 34 | + * List.of( |
| 35 | + * Map.of("name", "p53 binding site", "geneName", "TP53", "start", 1000, "end", 1020), |
| 36 | + * Map.of("name", "TATA box", "geneName", "BRCA1", "start", 2500, "end", 2506) |
| 37 | + * ))); |
| 38 | + * |
| 39 | + * // Update annotation positions |
| 40 | + * Command updateCmd = new Command(CommandType.Update, "genome", "GeneAnnotations", |
| 41 | + * List.of(Map.of( |
| 42 | + * "name", "Promoter region", |
| 43 | + * "geneName", "EGFR", |
| 44 | + * "start", 5000, |
| 45 | + * "end", 5500 |
| 46 | + * ))); |
| 47 | + * updateCmd.setAuditBehavior(SaveRowsCommand.AuditBehavior.DETAILED); |
| 48 | + * updateCmd.setAuditUserComment("Updated promoter region coordinates based on new assembly"); |
| 49 | + * saveCmd.addCommand(updateCmd); |
| 50 | + * |
| 51 | + * // Delete obsolete annotation |
| 52 | + * saveCmd.addCommand(new Command(CommandType.Delete, "genome", "GeneAnnotations", |
| 53 | + * List.of(Map.of("name", "Putative enhancer", "geneName", "MYC")))); |
| 54 | + * |
| 55 | + * // Execute all commands in a transaction |
| 56 | + * SaveRowsApiResponse response = saveCmd.execute(conn, "GenomeProject"); |
| 57 | + * </code></pre> |
| 58 | + */ |
10 | 59 | public class SaveRowsApiCommand extends PostCommand<SaveRowsApiResponse> |
11 | 60 | { |
12 | 61 | private final List<Command> _commands = new ArrayList<>(); |
|
0 commit comments