View Javadoc
1   /*
2    * The contents of this file are subject to the terms of the Common Development and
3    * Distribution License (the License). You may not use this file except in compliance with the
4    * License.
5    *
6    * You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the
7    * specific language governing permission and limitations under the License.
8    *
9    * When distributing Covered Software, include this CDDL Header Notice in each file and include
10   * the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL
11   * Header, with the fields enclosed by brackets [] replaced by your own identifying
12   * information: "Portions copyright [year] [name of copyright owner]".
13   *
14   * Copyright 2015 ForgeRock AS.
15   */
16  package org.forgerock.audit.handlers.jdbc;
17  
18  import com.fasterxml.jackson.annotation.JsonProperty;
19  import com.fasterxml.jackson.annotation.JsonPropertyDescription;
20  
21  import java.util.Collections;
22  import java.util.Map;
23  import java.util.TreeMap;
24  
25  /**
26   * Contains the necessary information to map an event to a database table, and the event fields to the columns
27   * in that database table.
28   */
29  public class TableMapping {
30      @JsonProperty
31      @JsonPropertyDescription("audit.handlers.jdbc.mapping.event")
32      private String event;
33  
34      @JsonProperty
35      @JsonPropertyDescription("audit.handlers.jdbc.mapping.table")
36      private String table;
37  
38      @JsonProperty
39      @JsonPropertyDescription("audit.handlers.jdbc.mapping.fieldToColumn")
40      private Map<String, String> fieldToColumn = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
41  
42      /**
43       * Gets the audit event the table mapping is for.
44       * @return The audit event the mapping is for.
45       */
46      public String getEvent() {
47          return event;
48      }
49  
50      /**
51       * Sets the audit event the table mapping is for.
52       * @param event The audit event the mapping is for.
53       */
54      public void setEvent(String event) {
55          this.event = event;
56      }
57  
58      /**
59       * Gets the table name for the mapping.
60       * @return The table name for the mapping.
61       */
62      public String getTable() {
63          return table;
64      }
65  
66      /**
67       * Sets the table name for the mapping.
68       * @param table The table name for the mapping.
69       */
70      public void setTable(String table) {
71          this.table = table;
72      }
73  
74      /**
75       * Sets the field to column mapping.
76       * @return The field to column mapping.
77       */
78      public Map<String, String> getFieldToColumn() {
79          return Collections.unmodifiableMap(fieldToColumn);
80      }
81  
82      /**
83       * Sets the field to column mapping. The map should be case insensitive.
84       * @param fieldToColumn The field to column mapping.
85       */
86      public void setFieldToColumn(Map<String, String> fieldToColumn) {
87          this.fieldToColumn = fieldToColumn;
88      }
89  }