Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Timestamp2Column and Datetime2Column for timestamp and datetime for Open Replicator events #64

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,33 +15,16 @@

import java.nio.charset.Charset;
import java.sql.Time;
import java.sql.Timestamp;
import java.util.Calendar;
import java.util.Date;

import com.google.code.or.common.glossary.column.*;
import org.trpr.platform.core.impl.logging.LogFactory;
import org.trpr.platform.core.spi.logging.Logger;

import com.flipkart.aesop.bootstrap.mysql.MysqlEventProducer;
import com.google.code.or.common.glossary.Column;
import com.google.code.or.common.glossary.column.BitColumn;
import com.google.code.or.common.glossary.column.BlobColumn;
import com.google.code.or.common.glossary.column.DateColumn;
import com.google.code.or.common.glossary.column.DatetimeColumn;
import com.google.code.or.common.glossary.column.DecimalColumn;
import com.google.code.or.common.glossary.column.DoubleColumn;
import com.google.code.or.common.glossary.column.EnumColumn;
import com.google.code.or.common.glossary.column.FloatColumn;
import com.google.code.or.common.glossary.column.Int24Column;
import com.google.code.or.common.glossary.column.LongColumn;
import com.google.code.or.common.glossary.column.LongLongColumn;
import com.google.code.or.common.glossary.column.NullColumn;
import com.google.code.or.common.glossary.column.SetColumn;
import com.google.code.or.common.glossary.column.ShortColumn;
import com.google.code.or.common.glossary.column.StringColumn;
import com.google.code.or.common.glossary.column.TimeColumn;
import com.google.code.or.common.glossary.column.TimestampColumn;
import com.google.code.or.common.glossary.column.TinyColumn;
import com.google.code.or.common.glossary.column.YearColumn;

/**
* <code>ORToMysqlMapper</code> provides mapping of data from open replicator data type to mysql data type
Expand Down Expand Up @@ -82,6 +65,11 @@ else if (column instanceof DatetimeColumn)
*/
return new java.sql.Timestamp((date.getTime() / 1000) * 1000);
}
else if (column instanceof Datetime2Column) {
Datetime2Column datetime2Column = (Datetime2Column) column;
Date date = datetime2Column.getValue();
return new java.sql.Timestamp((date.getTime() / 1000) * 1000);
}
else if (column instanceof DecimalColumn)
{
DecimalColumn decimalColumn = (DecimalColumn) column;
Expand Down Expand Up @@ -160,6 +148,10 @@ else if (column instanceof TimestampColumn)
TimestampColumn timeStampColumn = (TimestampColumn) column;
return timeStampColumn.getValue();
}
else if (column instanceof Timestamp2Column){
Timestamp2Column timeStampColumn = (Timestamp2Column) column;
return timeStampColumn.getValue();
}
else if (column instanceof TinyColumn)
{
TinyColumn tinyColumn = (TinyColumn) column;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,29 +22,11 @@
import java.util.Calendar;
import java.util.Date;

import com.google.code.or.common.glossary.column.*;
import org.trpr.platform.core.impl.logging.LogFactory;
import org.trpr.platform.core.spi.logging.Logger;

import com.google.code.or.common.glossary.Column;
import com.google.code.or.common.glossary.column.BitColumn;
import com.google.code.or.common.glossary.column.BlobColumn;
import com.google.code.or.common.glossary.column.DateColumn;
import com.google.code.or.common.glossary.column.DatetimeColumn;
import com.google.code.or.common.glossary.column.DecimalColumn;
import com.google.code.or.common.glossary.column.DoubleColumn;
import com.google.code.or.common.glossary.column.EnumColumn;
import com.google.code.or.common.glossary.column.FloatColumn;
import com.google.code.or.common.glossary.column.Int24Column;
import com.google.code.or.common.glossary.column.LongColumn;
import com.google.code.or.common.glossary.column.LongLongColumn;
import com.google.code.or.common.glossary.column.NullColumn;
import com.google.code.or.common.glossary.column.SetColumn;
import com.google.code.or.common.glossary.column.ShortColumn;
import com.google.code.or.common.glossary.column.StringColumn;
import com.google.code.or.common.glossary.column.TimeColumn;
import com.google.code.or.common.glossary.column.TimestampColumn;
import com.google.code.or.common.glossary.column.TinyColumn;
import com.google.code.or.common.glossary.column.YearColumn;
import com.linkedin.databus.core.DatabusRuntimeException;
import com.linkedin.databus2.core.DatabusException;
/**
Expand Down Expand Up @@ -133,7 +115,15 @@ public Object orToAvroType(Column column) throws DatabusException{
TimestampColumn timeStampColumn = (TimestampColumn) column;
Timestamp timeStamp = timeStampColumn.getValue();
return timeStamp.getTime();
}else if (column instanceof TinyColumn){
}else if (column instanceof Timestamp2Column){
Timestamp2Column timeStampColumn = (Timestamp2Column) column;
Timestamp timeStamp = timeStampColumn.getValue();
return timeStamp.getTime();
}else if (column instanceof Datetime2Column){
Datetime2Column datetime2Column = (Datetime2Column) column;
Date date = datetime2Column.getValue();
return (date.getTime()/1000) * 1000;
} else if (column instanceof TinyColumn){
TinyColumn tinyColumn = (TinyColumn) column;
return tinyColumn.getValue();
}else if (column instanceof YearColumn){
Expand Down