killbill-memoizeit
Changes
entitlement/src/main/java/com/ning/billing/entitlement/engine/dao/model/EntitlementEventModelDao.java 4(+4 -0)
Details
diff --git a/account/src/main/resources/com/ning/billing/account/dao/AccountEmailSqlDao.sql.stg b/account/src/main/resources/com/ning/billing/account/dao/AccountEmailSqlDao.sql.stg
index 30972a6..49c37e0 100644
--- a/account/src/main/resources/com/ning/billing/account/dao/AccountEmailSqlDao.sql.stg
+++ b/account/src/main/resources/com/ning/billing/account/dao/AccountEmailSqlDao.sql.stg
@@ -4,6 +4,8 @@ tableName() ::= "account_emails"
historyTableName() ::= "account_email_history"
+andCheckSoftDeletionWithComma(prefix) ::= "and <prefix>is_active"
+
tableFields(prefix) ::= <<
account_id
, email
diff --git a/entitlement/src/main/java/com/ning/billing/entitlement/engine/dao/model/EntitlementEventModelDao.java b/entitlement/src/main/java/com/ning/billing/entitlement/engine/dao/model/EntitlementEventModelDao.java
index 42f2c45..fa2507a 100644
--- a/entitlement/src/main/java/com/ning/billing/entitlement/engine/dao/model/EntitlementEventModelDao.java
+++ b/entitlement/src/main/java/com/ning/billing/entitlement/engine/dao/model/EntitlementEventModelDao.java
@@ -149,6 +149,10 @@ public class EntitlementEventModelDao extends EntityBase implements EntityModelD
public static EntitlementEvent toEntitlementEvent(final EntitlementEventModelDao src) {
+ if (src == null) {
+ return null;
+ }
+
final EventBaseBuilder<?> base = ((src.getEventType() == EventType.PHASE) ?
new PhaseEventBuilder() :
new ApiEventBuilder())
diff --git a/entitlement/src/main/resources/com/ning/billing/entitlement/engine/dao/EntitlementEventSqlDao.sql.stg b/entitlement/src/main/resources/com/ning/billing/entitlement/engine/dao/EntitlementEventSqlDao.sql.stg
index a619632..e2bd516 100644
--- a/entitlement/src/main/resources/com/ning/billing/entitlement/engine/dao/EntitlementEventSqlDao.sql.stg
+++ b/entitlement/src/main/resources/com/ning/billing/entitlement/engine/dao/EntitlementEventSqlDao.sql.stg
@@ -2,6 +2,12 @@ group EventSqlDao: EntitySqlDao;
tableName() ::= "subscription_events"
+andCheckSoftDeletionWithComma(prefix) ::= "and <prefix>is_active"
+
+extraTableFieldsWithComma(prefix) ::= <<
+, <prefix>record_id as total_ordering
+>>
+
tableFields(prefix) ::= <<
<prefix> event_type
, <prefix> user_type
@@ -105,34 +111,3 @@ effective_date asc
;
>>
-/** Redefine the 3 base nethods to account for total_ordering **/
-
-get(limit) ::= <<
-select
-<allTableFields("t.")>
-, record_id as total_ordering
-from <tableName()> t
-where <CHECK_TENANT("t.")>
-<if(limit)>limit :limit<endif>
-;
->>
-
-getById(id) ::= <<
-select
-<allTableFields()>
-, record_id as total_ordering
-from <tableName()> t
-where <idField()> = :id
-<AND_CHECK_TENANT()>
-;
->>
-
-getByRecordId(recordId) ::= <<
-select
-<allTableFields()>
-, record_id as total_ordering
-from <tableName()>
-where <recordIdField()> = :recordId
-<AND_CHECK_TENANT()>
-;
->>
diff --git a/payment/src/main/resources/com/ning/billing/payment/dao/PaymentMethodSqlDao.sql.stg b/payment/src/main/resources/com/ning/billing/payment/dao/PaymentMethodSqlDao.sql.stg
index 51ef088..a242999 100644
--- a/payment/src/main/resources/com/ning/billing/payment/dao/PaymentMethodSqlDao.sql.stg
+++ b/payment/src/main/resources/com/ning/billing/payment/dao/PaymentMethodSqlDao.sql.stg
@@ -1,6 +1,13 @@
group PaymentMethodSqlDao: EntitySqlDao;
+
+tableName() ::= "payment_methods"
+
+historyTableName() ::= "payment_method_history"
+
+andCheckSoftDeletionWithComma(prefix) ::= "and <prefix>is_active"
+
tableFields(prefix) ::= <<
<prefix>account_id
, <prefix>plugin_name
@@ -23,20 +30,6 @@ tableValues() ::= <<
, :updatedDate
>>
-tableName() ::= "payment_methods"
-
-historyTableName() ::= "payment_method_history"
-
-
-getById(id) ::= <<
-select
-<allTableFields()>
-from <tableName()>
-where id = :id
-and is_active = 1
-<AND_CHECK_TENANT()>
-;
->>
markPaymentMethodAsDeleted(id) ::= <<
update <tableName()>
diff --git a/payment/src/main/resources/com/ning/billing/payment/dao/PaymentSqlDao.sql.stg b/payment/src/main/resources/com/ning/billing/payment/dao/PaymentSqlDao.sql.stg
index ecef78a..f04f02e 100644
--- a/payment/src/main/resources/com/ning/billing/payment/dao/PaymentSqlDao.sql.stg
+++ b/payment/src/main/resources/com/ning/billing/payment/dao/PaymentSqlDao.sql.stg
@@ -1,6 +1,10 @@
group PaymentSqlDao: EntitySqlDao;
+extraTableFieldsWithComma(prefix) ::= <<
+, <prefix>record_id as payment_number
+>>
+
tableFields(prefix) ::= <<
<prefix>account_id
, <prefix>invoice_id
@@ -47,7 +51,6 @@ where account_id = :accountId
;
>>
-
getPaymentsForInvoice() ::= <<
select <allTableFields()>
, record_id as payment_number
@@ -70,7 +73,6 @@ order by effective_date desc limit 1
>>
-
updatePaymentStatusAndExtRef() ::= <<
update payments
set payment_status = :paymentStatus
diff --git a/tenant/src/main/resources/com/ning/billing/tenant/dao/TenantKVSqlDao.sql.stg b/tenant/src/main/resources/com/ning/billing/tenant/dao/TenantKVSqlDao.sql.stg
index fac3271..c42eaca 100644
--- a/tenant/src/main/resources/com/ning/billing/tenant/dao/TenantKVSqlDao.sql.stg
+++ b/tenant/src/main/resources/com/ning/billing/tenant/dao/TenantKVSqlDao.sql.stg
@@ -2,6 +2,8 @@ group TenantKVSqlDao: EntitySqlDao;
tableName() ::= "tenant_kvs"
+andCheckSoftDeletionWithComma(prefix) ::= "and <prefix>is_active"
+
tableFields(prefix) ::= <<
<prefix>tenant_key
, <prefix>tenant_value
@@ -32,7 +34,7 @@ select
<allTableFields("t.")>
from <tableName()> t
where t.tenant_key = :tenantKey
-and t.is_active = 1
+and t.is_active
<AND_CHECK_TENANT("t.")>
;
>>
diff --git a/util/src/main/resources/com/ning/billing/util/entity/dao/EntitySqlDao.sql.stg b/util/src/main/resources/com/ning/billing/util/entity/dao/EntitySqlDao.sql.stg
index 349034c..eaa5d6f 100644
--- a/util/src/main/resources/com/ning/billing/util/entity/dao/EntitySqlDao.sql.stg
+++ b/util/src/main/resources/com/ning/billing/util/entity/dao/EntitySqlDao.sql.stg
@@ -1,6 +1,7 @@
group EntitySqlDao;
-/** To override in each EntitySqlDao template file **/
+
+/****************** To override in each EntitySqlDao template file *****************************/
tableName() ::= ""
@@ -23,11 +24,16 @@ historyTableValues() ::= <<
, <tableValues()>
>>
-/****************************************************/
+/** Used for entities that can be soft deleted to make we exclude those entries in base calls getById(), get() **/
+andCheckSoftDeletionWithComma(prefix) ::= ""
+
/** Add extra fields for SELECT queries **/
extraTableFieldsWithComma(prefix) ::= ""
+/****************** To override in each EntitySqlDao template file <end> *****************************/
+
+
idField(prefix) ::= <<
<prefix>id
>>
@@ -53,12 +59,11 @@ targetRecordIdField(prefix) ::= <<
targetRecordIdValue() ::= ":targetRecordId"
/** Override this if the Entity isn't tied to an account **/
-
-
accountRecordIdField(prefix) ::= <<
<prefix>account_record_id
>>
+
accountRecordIdFieldWithComma(prefix) ::= <<
, <accountRecordIdField(prefix)>
>>
@@ -84,6 +89,7 @@ tenantRecordIdValueWithComma() ::= <<
, <tenantRecordIdValue()>
>>
+
allTableFields(prefix) ::= <<
<recordIdField(prefix)>
, <idField(prefix)>
@@ -127,11 +133,22 @@ allHistoryTableValues() ::= <<
CHECK_TENANT(prefix) ::= "<prefix>tenant_record_id = :tenantRecordId"
AND_CHECK_TENANT(prefix) ::= "and <CHECK_TENANT(prefix)>"
+get(limit) ::= <<
+select
+<allTableFields("t.")>
+from <tableName()> t
+where <CHECK_TENANT("t.")>
+<andCheckSoftDeletionWithComma("t.")>
+<if(limit)>limit :limit<endif>
+;
+>>
+
getById(id) ::= <<
select
<allTableFields("t.")>
from <tableName()> t
where <idField("t.")> = :id
+<andCheckSoftDeletionWithComma("t.")>
<AND_CHECK_TENANT("t.")>
;
>>
@@ -182,14 +199,6 @@ where <targetRecordIdField("t.")> = :targetRecordId
;
>>
-get(limit) ::= <<
-select
-<allTableFields("t.")>
-from <tableName()> t
-where <CHECK_TENANT("t.")>
-<if(limit)>limit :limit<endif>
-;
->>
create() ::= <<
insert into <tableName()> (
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 1a23c7e..08e0800 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
@@ -2,6 +2,8 @@ group TagDefinitionDao: EntitySqlDao;
tableName() ::= "tag_definitions"
+andCheckSoftDeletionWithComma(prefix) ::= "and <prefix>is_active"
+
tableFields(prefix) ::= <<
<prefix>name
, <prefix>description
@@ -66,13 +68,3 @@ and <idField("t.")> in (<tag_definition_ids: {id | :id_<i0>}; separator="," >)
;
>>
-get(limit) ::= <<
-select
-<allTableFields("t.")>
-from <tableName()> t
-where
-t.is_active
-<AND_CHECK_TENANT("t.")>
-<if(limit)>limit :limit<endif>
-;
->>
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 410f56b..4d709a9 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
@@ -2,6 +2,8 @@ group TagDao: EntitySqlDao;
tableName() ::= "tags"
+andCheckSoftDeletionWithComma(prefix) ::= "and <prefix>is_active"
+
tableFields(prefix) ::= <<
<prefix>tag_definition_id
, <prefix>object_id