killbill-aplcache

util: payment: tenant: update missing template files Signed-off-by:

11/5/2012 7:02:38 PM

Details

diff --git a/payment/src/main/resources/com/ning/billing/payment/dao/RefundSqlDao.sql.stg b/payment/src/main/resources/com/ning/billing/payment/dao/RefundSqlDao.sql.stg
index 2f9f7e7..5c683d1 100644
--- a/payment/src/main/resources/com/ning/billing/payment/dao/RefundSqlDao.sql.stg
+++ b/payment/src/main/resources/com/ning/billing/payment/dao/RefundSqlDao.sql.stg
@@ -1,28 +1,18 @@
-group RefundSqlDao : EntitySqlDao;
-
-CHECK_TENANT() ::= "tenant_record_id = :tenantRecordId"
-AND_CHECK_TENANT() ::= "AND <CHECK_TENANT()>"
-
-refundFields(prefix) ::= <<
-<prefix>id,
-<prefix>account_id,
-<prefix>payment_id,
-<prefix>amount,  
-<prefix>currency,
-<prefix>is_adjusted,
-<prefix>refund_status,    
-<prefix>created_by,
-<prefix>created_date,
-<prefix>updated_by,
-<prefix>updated_date,
-<prefix>account_record_id,
-<prefix>tenant_record_id
->>
-
-insertRefund() ::= <<
-    INSERT INTO refunds (<refundFields()>)
-    VALUES (:id, :accountId, :paymentId, :amount, :currency, :isAdjusted, :refundStatus, :userName, :createdDate,
-            :userName, :createdDate, :accountRecordId, :tenantRecordId);
+group RefundSqlDao: EntitySqlDao;
+
+tableName() ::= "refunds"
+
+tableFields(prefix) ::= <<
+  <prefix>account_id,
+, <prefix>payment_id,
+, <prefix>amount,
+, <prefix>currency,
+, <prefix>is_adjusted,
+, <prefix>refund_status,
+, <prefix>created_by,
+, <prefix>created_date,
+, <prefix>updated_by,
+, <prefix>updated_date
 >>
 
 updateStatus() ::= <<
@@ -33,14 +23,6 @@ updateStatus() ::= <<
     ;
 >>
 
-getRefund() ::= <<
-    SELECT <refundFields()>
-    FROM refunds
-    WHERE id = :id
-    <AND_CHECK_TENANT()>
-    ;
->>
-
 getRefundsForPayment()  ::= <<
     SELECT <refundFields()>
     FROM refunds
@@ -55,6 +37,4 @@ getRefundsForAccount()  ::= <<
     WHERE account_id = :accountId
     <AND_CHECK_TENANT()>
     ;
->> 
-
-
+>>
diff --git a/tenant/src/main/resources/com/ning/billing/tenant/dao/TenantSqlDao.sql.stg b/tenant/src/main/resources/com/ning/billing/tenant/dao/TenantSqlDao.sql.stg
index d48780a..8716c41 100644
--- a/tenant/src/main/resources/com/ning/billing/tenant/dao/TenantSqlDao.sql.stg
+++ b/tenant/src/main/resources/com/ning/billing/tenant/dao/TenantSqlDao.sql.stg
@@ -1,16 +1,23 @@
-group TenantDaoSql;
+group TenantDaoSql: EntitySqlDao;
 
-tenantFields(prefix) ::= <<
-    <prefix>record_id,
-    <prefix>id,
-    <prefix>external_key,
-    <prefix>api_key,
-    <prefix>created_date,
-    <prefix>created_by,
-    <prefix>updated_date,
-    <prefix>updated_by
+tableName() ::= "tenants"
+
+/** Don't add api_secret and api_salt in these fields, we shouldn't need to retrieve them */
+tableFields(prefix) ::= <<
+  <prefix>external_key
+, <prefix>api_key
+, <prefix>created_date
+, <prefix>created_by
+, <prefix>updated_date
+, <prefix>updated_by
 >>
 
+/** No account_record_id field */
+accountRecordIdField(prefix) ::= ""
+
+/** No tenant_record_id field */
+tenantRecordIdField(prefix) ::= ""
+
 create() ::= <<
     INSERT INTO tenants (
         id
@@ -35,17 +42,6 @@ create() ::= <<
     );
 >>
 
-get() ::= <<
-    SELECT <tenantFields()>
-    FROM tenants;
->>
-
-getById() ::= <<
-    SELECT <tenantFields()>
-    FROM tenants
-    WHERE id = :id;
->>
-
 getByApiKey() ::= <<
     SELECT <tenantFields()>
     FROM tenants
@@ -57,7 +53,3 @@ getSecrets() ::= <<
     FROM tenants
     WHERE id = :id;
 >>
-
-test() ::= <<
-    SELECT 1 FROM tenants;
->>
diff --git a/util/src/main/java/com/ning/billing/util/tag/dao/TagDefinitionSqlDao.java b/util/src/main/java/com/ning/billing/util/tag/dao/TagDefinitionSqlDao.java
index bb3b650..2052921 100644
--- a/util/src/main/java/com/ning/billing/util/tag/dao/TagDefinitionSqlDao.java
+++ b/util/src/main/java/com/ning/billing/util/tag/dao/TagDefinitionSqlDao.java
@@ -36,7 +36,6 @@ import org.skife.jdbi.v2.sqlobject.BindingAnnotation;
 import org.skife.jdbi.v2.sqlobject.SqlQuery;
 import org.skife.jdbi.v2.sqlobject.SqlUpdate;
 import org.skife.jdbi.v2.sqlobject.customizers.RegisterMapper;
-import org.skife.jdbi.v2.sqlobject.stringtemplate.ExternalizedSqlViaStringTemplate3;
 import org.skife.jdbi.v2.tweak.ResultSetMapper;
 
 import com.ning.billing.util.audit.ChangeType;
diff --git a/util/src/main/resources/com/ning/billing/util/customfield/dao/CustomFieldSqlDao.sql.stg b/util/src/main/resources/com/ning/billing/util/customfield/dao/CustomFieldSqlDao.sql.stg
index bc67f46..74421f0 100644
--- a/util/src/main/resources/com/ning/billing/util/customfield/dao/CustomFieldSqlDao.sql.stg
+++ b/util/src/main/resources/com/ning/billing/util/customfield/dao/CustomFieldSqlDao.sql.stg
@@ -1,5 +1,17 @@
-group CustomFieldSqlDao : EntitySqlDao;
+group CustomFieldSqlDao: EntitySqlDao;
 
+tableName() ::= "custom_fields"
+
+tableFields(prefix) ::= <<
+  <prefix>object_id
+, <prefix>object_type
+, <prefix>created_by
+, <prefix>created_date
+, <prefix>updated_by
+, <prefix>updated_date
+>>
+
+historyTableName() ::= "custom_field_history"
 
 updateFromTransaction() ::= <<
     UPDATE custom_fields
@@ -16,3 +28,26 @@ deleteFromTransaction() ::= <<
     ;
 >>
 
+load() ::= <<
+    SELECT id, object_id, object_type, field_name, field_value, created_by, created_date, updated_by, updated_date
+    FROM custom_fields
+    WHERE object_id = :objectId AND object_type = :objectType
+    <AND_CHECK_TENANT()>
+    ;
+>>
+
+getRecordIds() ::= <<
+    SELECT record_id, id
+    FROM custom_fields
+    WHERE object_id = :objectId AND object_type = :objectType
+    <AND_CHECK_TENANT()>
+    ;
+>>
+
+getHistoryRecordIds() ::= <<
+    SELECT history_record_id, record_id
+    FROM custom_field_history
+    WHERE history_record_id > :maxHistoryRecordId
+    <AND_CHECK_TENANT()>
+    ;
+>>
diff --git a/util/src/main/resources/com/ning/billing/util/tag/dao/TagDefinitionSqlDao.sql.stg b/util/src/main/resources/com/ning/billing/util/tag/dao/TagDefinitionSqlDao.sql.stg
index 151c68d..2e356eb 100644
--- a/util/src/main/resources/com/ning/billing/util/tag/dao/TagDefinitionSqlDao.sql.stg
+++ b/util/src/main/resources/com/ning/billing/util/tag/dao/TagDefinitionSqlDao.sql.stg
@@ -1,17 +1,20 @@
-group TagDefinitionDao : EntitySqlDao;
-
-
-fields(prefix) ::= <<
-    <prefix>id,
-    <prefix>name,
-    <prefix>description,
-    <prefix>created_by,
-    <prefix>created_date ,
-    <prefix>updated_by,
-    <prefix>updated_date,
-    <prefix>tenant_record_id
+group TagDefinitionDao: EntitySqlDao;
+
+tableName() ::= "tag_definitions"
+
+tableFields(prefix) ::= <<
+  <prefix>name
+, <prefix>description
+, <prefix>created_by
+, <prefix>created_date
+, <prefix>updated_by
+, <prefix>updated_date
 >>
 
+/** No account_record_id field */
+accountRecordIdField(prefix) ::= ""
+
+historyTableName() ::= "tag_definition_history"
 
 deleteTagDefinition() ::= <<
   DELETE FROM tag_definitions
@@ -35,3 +38,9 @@ getByName() ::= <<
   ;
 >>
 
+getByIds(tag_definition_ids) ::= <<
+  SELECT <fields()>
+  FROM tag_definitions
+  WHERE id IN (<tag_definition_ids: {id | :id_<i0>}; separator="," >)
+  <AND_CHECK_TENANT()>
+>>
diff --git a/util/src/main/resources/com/ning/billing/util/tag/dao/TagSqlDao.sql.stg b/util/src/main/resources/com/ning/billing/util/tag/dao/TagSqlDao.sql.stg
index d738ae8..390f994 100644
--- a/util/src/main/resources/com/ning/billing/util/tag/dao/TagSqlDao.sql.stg
+++ b/util/src/main/resources/com/ning/billing/util/tag/dao/TagSqlDao.sql.stg
@@ -1,23 +1,16 @@
-group TagDao;
+group TagDao: EntitySqlDao;
 
-CHECK_TENANT() ::= "tenant_record_id = :tenantRecordId"
-AND_CHECK_TENANT() ::= "AND <CHECK_TENANT()>"
+tableName() ::= "tags"
 
-fields(prefix) ::= <<
-    <prefix>id,
-    <prefix>tag_definition_id,
-    <prefix>object_id,
-    <prefix>object_type,
-    <prefix>created_by,
-    <prefix>created_date,
-    <prefix>account_record_id,
-    <prefix>tenant_record_id
+tableFields(prefix) ::= <<
+  <prefix>tag_definition_id
+, <prefix>object_id
+, <prefix>object_type
+, <prefix>created_by
+, <prefix>created_date
 >>
 
-insertFromTransaction() ::= <<
-  INSERT INTO tags(<fields()>)
-  VALUES (:id, :tagDefinitionId, :objectId, :objectType, :userName, :createdDate, :accountRecordId, :tenantRecordId);
->>
+historyTableName() ::= "tag_history"
 
 deleteFromTransaction() ::= <<
     DELETE FROM tags
@@ -27,19 +20,6 @@ deleteFromTransaction() ::= <<
     ;
 >>
 
-addTagFromTransaction() ::= <<
-    INSERT INTO tags(<fields()>)
-    VALUES (:id, :tagDefinitionId, :objectId, :objectType, :userName, :createdDate, :accountRecordId, :tenantRecordId);
->>
-
-removeTagFromTransaction() ::= <<
-    DELETE FROM tags
-    WHERE tag_definition_id = :tagDefinitionId
-    AND object_id = :objectId AND object_type = :objectType
-    <AND_CHECK_TENANT()>
-    ;
->>
-
 findTag() ::= <<
     SELECT <fields()> FROM tags
     WHERE tag_definition_id = :tagDefinitionId
@@ -56,31 +36,6 @@ getRecordIds() ::= <<
     ;
 >>
 
-historyFields(prefix) ::= <<
-  <prefix>record_id,
-  <prefix>id,
-  <prefix>object_id,
-  <prefix>object_type,
-  <prefix>tag_definition_id,
-  <prefix>updated_by,
-  <prefix>date,
-  <prefix>change_type,
-  <prefix>account_record_id,
-  <prefix>tenant_record_id
->>
-
-addHistoryFromTransaction() ::= <<
-    INSERT INTO tag_history(<historyFields()>)
-    VALUES(:recordId, :id, :objectId, :objectType, :tagDefinitionId, :userName, :updatedDate, :changeType, :accountRecordId, :tenantRecordId);
->>
-
-getMaxHistoryRecordId() ::= <<
-    SELECT MAX(history_record_id)
-    FROM tag_history
-    WHERE <CHECK_TENANT()>
-    ;
->>
-
 getHistoryRecordIds() ::= <<
     SELECT history_record_id, record_id
     FROM tag_history
@@ -89,16 +44,9 @@ getHistoryRecordIds() ::= <<
     ;
 >>
 
-
 load() ::= <<
   SELECT <fields()>
     FROM tags
   WHERE object_id = :objectId AND object_type = :objectType
   <AND_CHECK_TENANT()>;
 >>
-
-
-test() ::= <<
-  SELECT 1 FROM tags WHERE <CHECK_TENANT()>;
->>
-;