killbill-aplcache
Changes
analytics/src/main/resources/com/ning/billing/analytics/dao/BusinessInvoiceItemSqlDao.sql.stg 2(+1 -1)
osgi-bundles/bundles/analytics/src/main/java/com/ning/billing/osgi/bundles/analytics/dao/model/BusinessAccountModelDao.java 2(+1 -1)
Details
diff --git a/analytics/src/main/resources/com/ning/billing/analytics/dao/BusinessInvoiceItemSqlDao.sql.stg b/analytics/src/main/resources/com/ning/billing/analytics/dao/BusinessInvoiceItemSqlDao.sql.stg
index 3a5bd22..cdb5bdb 100644
--- a/analytics/src/main/resources/com/ning/billing/analytics/dao/BusinessInvoiceItemSqlDao.sql.stg
+++ b/analytics/src/main/resources/com/ning/billing/analytics/dao/BusinessInvoiceItemSqlDao.sql.stg
@@ -133,7 +133,7 @@ delete from old_bii where item_id = :item_id <AND_CHECK_TENANT()>;
>>
deleteInvoiceItemsForAccount(account_id) ::= <<
-delete from old_bii where bii.invoice_id in (select invoice_id from bin where bin.account_id = :account_id <AND_CHECK_TENANT("bin.")> for update) <AND_CHECK_TENANT("bii.")>;
+delete from old_bii where old_bii.invoice_id in (select invoice_id from old_bin where old_bin.account_id = :account_id <AND_CHECK_TENANT("old_bin.")> for update) <AND_CHECK_TENANT("old_bii.")>;
>>
test() ::= <<
diff --git a/beatrix/src/main/java/com/ning/billing/beatrix/extbus/BeatrixListener.java b/beatrix/src/main/java/com/ning/billing/beatrix/extbus/BeatrixListener.java
index 07b4cf7..39356fb 100644
--- a/beatrix/src/main/java/com/ning/billing/beatrix/extbus/BeatrixListener.java
+++ b/beatrix/src/main/java/com/ning/billing/beatrix/extbus/BeatrixListener.java
@@ -49,6 +49,7 @@ import com.ning.billing.util.events.SubscriptionInternalEvent;
import com.ning.billing.util.events.UserTagCreationInternalEvent;
import com.ning.billing.util.events.UserTagDefinitionCreationInternalEvent;
import com.ning.billing.util.events.UserTagDefinitionDeletionInternalEvent;
+import com.ning.billing.util.events.UserTagDeletionInternalEvent;
import com.ning.billing.util.svcsapi.bus.InternalBus.EventBusException;
import com.google.common.eventbus.Subscribe;
@@ -170,9 +171,9 @@ public class BeatrixListener {
break;
case USER_TAG_DELETION:
- UserTagDefinitionDeletionInternalEvent realUserTagEventDel = (UserTagDefinitionDeletionInternalEvent) event;
+ UserTagDeletionInternalEvent realUserTagEventDel = (UserTagDeletionInternalEvent) event;
objectType = ObjectType.TAG;
- objectId = null; // TODO missing..
+ objectId = realUserTagEventDel.getObjectId();
eventBusType = ExtBusEventType.TAG_DELETION;
break;
diff --git a/beatrix/src/main/java/com/ning/billing/beatrix/extbus/dao/ExtBusSqlDao.java b/beatrix/src/main/java/com/ning/billing/beatrix/extbus/dao/ExtBusSqlDao.java
index 6a40311..da0ed74 100644
--- a/beatrix/src/main/java/com/ning/billing/beatrix/extbus/dao/ExtBusSqlDao.java
+++ b/beatrix/src/main/java/com/ning/billing/beatrix/extbus/dao/ExtBusSqlDao.java
@@ -18,6 +18,7 @@ package com.ning.billing.beatrix.extbus.dao;
import java.sql.ResultSet;
import java.sql.SQLException;
+import java.sql.Types;
import java.util.Date;
import java.util.UUID;
@@ -83,24 +84,24 @@ public interface ExtBusSqlDao extends Transactional<ExtBusSqlDao>, CloseMe {
@Override
public void bind(@SuppressWarnings("rawtypes") final SQLStatement stmt, final Bind bind, final ExtBusEventEntry evt) {
- stmt.bind("eventType", extractWithNullValue(evt.getExtBusType().toString()));
- stmt.bind("objectId", extractWithNullValue(evt.getObjectId().toString()));
- stmt.bind("objectType", extractWithNullValue(evt.getObjectType().toString()));
+ stmt.bind("eventType", evt.getExtBusType().toString());
+ bindWithPotentialNullStringValue(stmt, "objectId", evt.getObjectId());
+ stmt.bind("objectType", evt.getObjectType().toString());
stmt.bind("userToken", getUUIDString(evt.getUserToken()));
stmt.bind("createdDate", getDate(new DateTime()));
- stmt.bind("creatingOwner", extractWithNullValue(evt.getCreatedOwner()));
+ stmt.bind("creatingOwner", evt.getCreatedOwner());
stmt.bind("processingAvailableDate", getDate(evt.getNextAvailableDate()));
- stmt.bind("processingOwner", extractWithNullValue(evt.getOwner()));
+ stmt.bind("processingOwner", evt.getOwner());
stmt.bind("processingState", PersistentQueueEntryLifecycleState.AVAILABLE.toString());
}
- private String extractWithNullValue(Object obj) {
- if (obj == null) {
- return null;
+ private void bindWithPotentialNullStringValue(final SQLStatement stmt, final String bindType, final Object bindValue) {
+ if (bindValue == null) {
+ stmt.bindNull(bindType, Types.VARCHAR);
+ } else {
+ stmt.bind(bindType, bindValue.toString());
}
- return obj.toString();
}
-
}
public static class ExtBusSqlMapper extends MapperBase implements ResultSetMapper<ExtBusEventEntry> {
diff --git a/beatrix/src/main/resources/com/ning/billing/beatrix/ddl.sql b/beatrix/src/main/resources/com/ning/billing/beatrix/ddl.sql
index d4b955c..789fdf6 100644
--- a/beatrix/src/main/resources/com/ning/billing/beatrix/ddl.sql
+++ b/beatrix/src/main/resources/com/ning/billing/beatrix/ddl.sql
@@ -4,7 +4,7 @@ DROP TABLE IF EXISTS bus_ext_events;
CREATE TABLE bus_ext_events (
record_id int(11) unsigned NOT NULL AUTO_INCREMENT,
event_type varchar(32) NOT NULL,
- object_id varchar(64) NOT NULL,
+ object_id varchar(64) DEFAULT NULL,
object_type varchar(32) NOT NULL,
user_token char(36),
created_date datetime NOT NULL,
@@ -12,8 +12,8 @@ CREATE TABLE bus_ext_events (
processing_owner char(50) DEFAULT NULL,
processing_available_date datetime DEFAULT NULL,
processing_state varchar(14) DEFAULT 'AVAILABLE',
- account_record_id int(11) unsigned default null,
- tenant_record_id int(11) unsigned default null,
+ account_record_id int(11) unsigned DEFAULT NULL,
+ tenant_record_id int(11) unsigned DEFAULT NULL,
PRIMARY KEY(record_id)
);
CREATE INDEX `idx_bus_ext_where` ON bus_ext_events (`processing_state`,`processing_owner`,`processing_available_date`);
@@ -25,8 +25,8 @@ CREATE TABLE claimed_bus_ext_events (
owner_id varchar(64) NOT NULL,
claimed_date datetime NOT NULL,
bus_event_id char(36) NOT NULL,
- account_record_id int(11) unsigned default null,
- tenant_record_id int(11) unsigned default null,
+ account_record_id int(11) unsigned DEFAULT NULL,
+ tenant_record_id int(11) unsigned DEFAULT NULL,
PRIMARY KEY(record_id)
);
CREATE INDEX claimed_bus_ext_events_tenant_account_record_id ON claimed_bus_ext_events(tenant_record_id, account_record_id);
diff --git a/jaxrs/src/main/java/com/ning/billing/jaxrs/json/NotificationJson.java b/jaxrs/src/main/java/com/ning/billing/jaxrs/json/NotificationJson.java
index 21deb71..c32fd7a 100644
--- a/jaxrs/src/main/java/com/ning/billing/jaxrs/json/NotificationJson.java
+++ b/jaxrs/src/main/java/com/ning/billing/jaxrs/json/NotificationJson.java
@@ -44,7 +44,7 @@ public class NotificationJson {
public NotificationJson(final ExtBusEvent event) {
- this(event.getEventType().toString(), event.getAccountId().toString(), event.getObjectType().toString(), event.getObjectId().toString());
+ this(event.getEventType().toString(), event.getAccountId().toString(), event.getObjectType().toString(), event.getObjectId() != null ? event.getObjectId().toString() : null);
}
diff --git a/osgi-bundles/bundles/analytics/src/main/java/com/ning/billing/osgi/bundles/analytics/dao/model/BusinessAccountModelDao.java b/osgi-bundles/bundles/analytics/src/main/java/com/ning/billing/osgi/bundles/analytics/dao/model/BusinessAccountModelDao.java
index e16627e..4417ec8 100644
--- a/osgi-bundles/bundles/analytics/src/main/java/com/ning/billing/osgi/bundles/analytics/dao/model/BusinessAccountModelDao.java
+++ b/osgi-bundles/bundles/analytics/src/main/java/com/ning/billing/osgi/bundles/analytics/dao/model/BusinessAccountModelDao.java
@@ -366,7 +366,7 @@ public class BusinessAccountModelDao extends BusinessModelDaoBase {
if (timeZone != null ? !timeZone.equals(that.timeZone) : that.timeZone != null) {
return false;
}
- if (updatedDate != null ? !updatedDate.equals(that.updatedDate) : that.updatedDate != null) {
+ if (updatedDate != null ? (updatedDate.compareTo(that.updatedDate) != 0) : that.updatedDate != null) {
return false;
}
diff --git a/osgi-bundles/bundles/analytics/src/main/java/com/ning/billing/osgi/bundles/analytics/dao/model/BusinessModelDaoBase.java b/osgi-bundles/bundles/analytics/src/main/java/com/ning/billing/osgi/bundles/analytics/dao/model/BusinessModelDaoBase.java
index 8f4c2ff..a36b589 100644
--- a/osgi-bundles/bundles/analytics/src/main/java/com/ning/billing/osgi/bundles/analytics/dao/model/BusinessModelDaoBase.java
+++ b/osgi-bundles/bundles/analytics/src/main/java/com/ning/billing/osgi/bundles/analytics/dao/model/BusinessModelDaoBase.java
@@ -169,15 +169,12 @@ public abstract class BusinessModelDaoBase {
if (createdComments != null ? !createdComments.equals(that.createdComments) : that.createdComments != null) {
return false;
}
- if (createdDate != null ? !createdDate.equals(that.createdDate) : that.createdDate != null) {
+ if (createdDate != null ? (createdDate.compareTo(that.createdDate) != 0) : that.createdDate != null) {
return false;
}
if (createdReasonCode != null ? !createdReasonCode.equals(that.createdReasonCode) : that.createdReasonCode != null) {
return false;
}
- if (recordId != null ? !recordId.equals(that.recordId) : that.recordId != null) {
- return false;
- }
if (reportGroup != null ? !reportGroup.equals(that.reportGroup) : that.reportGroup != null) {
return false;
}
@@ -191,7 +188,6 @@ public abstract class BusinessModelDaoBase {
@Override
public int hashCode() {
int result = DEFAULT_REPORT_GROUP.hashCode();
- result = 31 * result + (recordId != null ? recordId.hashCode() : 0);
result = 31 * result + (createdDate != null ? createdDate.hashCode() : 0);
result = 31 * result + (createdBy != null ? createdBy.hashCode() : 0);
result = 31 * result + (createdReasonCode != null ? createdReasonCode.hashCode() : 0);
diff --git a/osgi-bundles/bundles/analytics/src/test/java/com/ning/billing/osgi/bundles/analytics/dao/TestBusinessAnalyticsSqlDao.java b/osgi-bundles/bundles/analytics/src/test/java/com/ning/billing/osgi/bundles/analytics/dao/TestBusinessAnalyticsSqlDao.java
index dede896..dcb30df 100644
--- a/osgi-bundles/bundles/analytics/src/test/java/com/ning/billing/osgi/bundles/analytics/dao/TestBusinessAnalyticsSqlDao.java
+++ b/osgi-bundles/bundles/analytics/src/test/java/com/ning/billing/osgi/bundles/analytics/dao/TestBusinessAnalyticsSqlDao.java
@@ -42,10 +42,15 @@ public class TestBusinessAnalyticsSqlDao extends AnalyticsTestSuiteWithEmbeddedD
callContext));
analyticsSqlDao.create(accountModelDao.getTableName(), accountModelDao, callContext);
+ final BusinessAccountModelDao newBusinessAccountModelDao = analyticsSqlDao.getAccountByAccountRecordId(accountModelDao.getAccountRecordId(),
+ accountModelDao.getTenantRecordId(),
+ callContext);
+ Assert.assertEquals(newBusinessAccountModelDao, accountModelDao);
+ /*
Assert.assertEquals(analyticsSqlDao.getAccountByAccountRecordId(accountModelDao.getAccountRecordId(),
accountModelDao.getTenantRecordId(),
callContext), accountModelDao);
-
+*/
analyticsSqlDao.deleteByAccountRecordId(accountModelDao.getTableName(),
accountModelDao.getAccountRecordId(),
accountModelDao.getTenantRecordId(),