001/* 002 * The contents of this file are subject to the terms of the Common Development and 003 * Distribution License (the License). You may not use this file except in compliance with the 004 * License. 005 * 006 * You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the 007 * specific language governing permission and limitations under the License. 008 * 009 * When distributing Covered Software, include this CDDL Header Notice in each file and include 010 * the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL 011 * Header, with the fields enclosed by brackets [] replaced by your own identifying 012 * information: "Portions copyright [year] [name of copyright owner]". 013 * 014 * Copyright 2015 ForgeRock AS. 015 */ 016package org.forgerock.audit.handlers.jdbc; 017 018import com.fasterxml.jackson.annotation.JsonProperty; 019import com.fasterxml.jackson.annotation.JsonPropertyDescription; 020 021import java.util.Collections; 022import java.util.Map; 023import java.util.TreeMap; 024 025/** 026 * Contains the necessary information to map an event to a database table, and the event fields to the columns 027 * in that database table. 028 */ 029public class TableMapping { 030 @JsonProperty 031 @JsonPropertyDescription("audit.handlers.jdbc.mapping.event") 032 private String event; 033 034 @JsonProperty 035 @JsonPropertyDescription("audit.handlers.jdbc.mapping.table") 036 private String table; 037 038 @JsonProperty 039 @JsonPropertyDescription("audit.handlers.jdbc.mapping.fieldToColumn") 040 private Map<String, String> fieldToColumn = new TreeMap<>(String.CASE_INSENSITIVE_ORDER); 041 042 /** 043 * Gets the audit event the table mapping is for. 044 * @return The audit event the mapping is for. 045 */ 046 public String getEvent() { 047 return event; 048 } 049 050 /** 051 * Sets the audit event the table mapping is for. 052 * @param event The audit event the mapping is for. 053 */ 054 public void setEvent(String event) { 055 this.event = event; 056 } 057 058 /** 059 * Gets the table name for the mapping. 060 * @return The table name for the mapping. 061 */ 062 public String getTable() { 063 return table; 064 } 065 066 /** 067 * Sets the table name for the mapping. 068 * @param table The table name for the mapping. 069 */ 070 public void setTable(String table) { 071 this.table = table; 072 } 073 074 /** 075 * Sets the field to column mapping. 076 * @return The field to column mapping. 077 */ 078 public Map<String, String> getFieldToColumn() { 079 return Collections.unmodifiableMap(fieldToColumn); 080 } 081 082 /** 083 * Sets the field to column mapping. The map should be case insensitive. 084 * @param fieldToColumn The field to column mapping. 085 */ 086 public void setFieldToColumn(Map<String, String> fieldToColumn) { 087 this.fieldToColumn = fieldToColumn; 088 } 089}