Sorry for the late reply Balendra, I just now realized the new JIRA
ticket with the patch [1].

I looked at the patch and it looks good except for two small doubts
from my side:

 * In the SalesforceDataSet all the spaces have been replaced by tabs.
We do use spaces in MM, and changing it makes it harder to see the
diff.
 * In the test SalesforceDataContextTest.testRewriteWhereItem you've
changed the example input timezone from GMT+1 to UTC. Is there a
reason for this? I see you also changed the subsequent assertions, but
I doubt why this was necesary at all?

If you can maybe fix/answer these points, then I am good to give it my +1.

And a remark for everyone: The patch is made against the org.eobjects
codebase. Obviously we will apply it to both codebases. Since this is
a bugfix, I imagine it will also go into a bugfix release of the old
MetaModel.

[1] https://issues.apache.org/jira/browse/METAMODEL-9

2013/8/2 Kasper Sørensen <[email protected]>:
> Hi Balendra,
>
> Is it possible for you to post it as a patch file. Either upload it to
> the MM JIRA [1] or simply make a gist [2] or so.
>
> [1] https://issues.apache.org/jira/browse/METAMODEL
> [2] https://gist.github.com/
>
> 2013/8/2 Balendra Singh <[email protected]>:
>> Hi,
>>
>> In my case field type is date. SalesforceTable is returning ColumnType.DATE
>> for date, datetime and time. In SalesforceDataSet, it is using a datetime
>> format to format my date value field and was throwing exception.
>>
>> I made the following fixes for this issue -
>>
>> 1. In SalesforceDataSet.convert(Object value, ColumnType columnType)
>>
>> private Object convert(Object value, ColumnType columnType) {
>> if (value instanceof String && !columnType.isLiteral()) {
>> if (columnType.isBoolean()) {
>> return BooleanComparator.toBoolean(value);
>> }
>> if (columnType.isNumber()) {
>> return NumberComparator.toNumber(columnType.isNumber());
>> }
>> if (columnType.isTimeBased()) {
>>
>> SimpleDateFormat format;
>> *if (columnType == ColumnType.DATE) {*
>> *
>> *
>> * format = new SimpleDateFormat(*
>> * SalesforceDataContext.SOQL_DATE_FORMAT_IN);*
>> * } else if (columnType == ColumnType.TIMESTAMP) {*
>> * format = new SimpleDateFormat(*
>> * SalesforceDataContext.SOQL_DATE_TIME_FORMAT_IN);*
>> * } else {*
>> * format = new SimpleDateFormat(*
>> * SalesforceDataContext.SOQL_TIME_FORMAT_IN);*
>> * }*
>> format.setTimeZone(SalesforceDataContext.SOQL_TIMEZONE);
>> try {
>> return format.parse(value.toString());
>> } catch (ParseException e) {
>> throw new IllegalStateException(
>> "Unable to parse date/time value: " + value);
>> }
>> }
>> }
>> return value;
>> }
>>
>>
>> 2. In SalesforceDataContext added the following date format strings -
>>
>>     public static final String SOQL_DATE_FORMAT_IN = "yyyy-MM-dd";
>>     public static final String SOQL_DATE_FORMAT_OUT = "yyyy-MM-dd";
>>     public static final String SOQL_DATE_TIME_FORMAT_IN =
>> "yyyy-MM-dd'T'HH:mm:ss.SSS";
>>     public static final String SOQL_DATE_TIME_FORMAT_OUT =
>> "yyyy-MM-dd'T'HH:mm:ssZZZ";
>>     public static final String SOQL_TIME_FORMAT_IN = "HH:mm:ss.SSS";
>>     public static final String SOQL_TIME_FORMAT_OUT = "HH:mm:ssZZZ";
>>
>> 3. In SalesforceTable.toColumnType - I have returned specific date
>> datatypes
>>
>>
>>  protected static ColumnType toColumnType(FieldType type) {
>>         switch (type) {
>>         case _boolean:
>>             return ColumnType.BOOLEAN;
>>         case _int:
>>             return ColumnType.INTEGER;
>>         case _double:
>>             return ColumnType.DOUBLE;
>> *        case date:*
>> *        return ColumnType.DATE;*
>> *        case datetime:*
>> *        return ColumnType.TIMESTAMP;*
>> *        case time:*
>> *            return ColumnType.TIME;*
>>         case string:
>>         case email:
>>         case url:
>>         case phone:
>>         case reference:
>>         case textarea:
>>         case encryptedstring:
>>         case base64:
>>         case currency:
>>         case id:
>>         case picklist:
>>             return ColumnType.VARCHAR;
>>         }
>>         return ColumnType.OTHER;
>>     }
>>
>> Please validate the code changes for the issue.
>>
>>
>> Thanks,
>> Balendra
>>
>>
>>
>>
>>
>> On 1 August 2013 18:41, Kasper Sørensen 
>> <[email protected]>wrote:
>>
>>> Strange, it seems that Salesforce sends dates back in not just a
>>> single, but various formats. Usually we have seen the format
>>> "yyyy-MM-dd'T'HH:mm:ss.SSS" (Represented by
>>> SalesforceDataContext.SOQL_DATE_FORMAT_IN). In your case it seems it
>>> simply sent a date in the format yyyy-MM-dd. Do you happen to know
>>> what field this failed for, and what datatype it had? Maybe this is a
>>> simple case that we need to distinguish in a more detailed manner for
>>> e.g. DATE vs DATETIME vs TIMESTAMP types...
>>>
>>> Anyways, the fix shouldn't be too hard. Simplest solution would be to
>>> simply make a "convertToDate(String)" method in SalesforceUtils and
>>> probe the incoming string to select a proper date format.
>>>
>>> 2013/8/1 Balendra Singh <[email protected]>:
>>> > While using metamodel in our project we found the following exception -
>>> >
>>> > In salesforce, if date value is provided then
>>> > SalesforceDataSet<http://eobjects.org/trac/wiki/SalesforceDataSet> is
>>> > throwing following exception while inserting this record to some other
>>> > database.
>>> >
>>> > *Stacktrace*
>>> >
>>> > Job execution FAILURE - Unable to parse date/time value: 2012-08-02 (
>>> > IllegalStateException <
>>> http://eobjects.org/trac/wiki/IllegalStateException>)
>>> > - Exception stacktrace of failure condition:
>>> > java.lang.IllegalStateException<
>>> http://eobjects.org/trac/wiki/IllegalStateException>:
>>> > Unable to parse date/time value: 2012-08-02 at
>>> > org.eobjects.metamodel.salesforce.SalesforceDataSet<
>>> http://eobjects.org/trac/wiki/SalesforceDataSet>.
>>> > convert(SalesforceDataSet
>>> > <http://eobjects.org/trac/wiki/SalesforceDataSet>.java:119)
>>> > at org.eobjects.metamodel.salesforce.SalesforceDataSet<
>>> http://eobjects.org/trac/wiki/SalesforceDataSet>
>>> > .getRow(SalesforceDataSet
>>> > <http://eobjects.org/trac/wiki/SalesforceDataSet>.java:98)
>>> > at org.eobjects.analyzer.job.runner.
>>> > RowProcessingPublisher<
>>> http://eobjects.org/trac/wiki/RowProcessingPublisher>
>>> > .processRows(RowProcessingPublisher<
>>> http://eobjects.org/trac/wiki/RowProcessingPublisher>.java:295)
>>> > at org.eobjects.analyzer.job.tasks.RunRowProcessingPublisherTask?<
>>> http://eobjects.org/trac/wiki/RunRowProcessingPublisherTask>
>>> > .execute(RunRowProcessingPublisherTask?<
>>> http://eobjects.org/trac/wiki/RunRowProcessingPublisherTask>
>>> > .java:43)
>>> >
>>> > at org.eobjects.analyzer.job.concurrent.TaskRunnable<
>>> http://eobjects.org/trac/wiki/TaskRunnable>
>>> > .run(TaskRunnable <http://eobjects.org/trac/wiki/TaskRunnable>.java:63)
>>> at
>>> > java.util.concurrent.ThreadPoolExecutor<
>>> http://eobjects.org/trac/wiki/ThreadPoolExecutor>
>>> > $Worker.runTask(ThreadPoolExecutor<
>>> http://eobjects.org/trac/wiki/ThreadPoolExecutor>.java:886)
>>> > at java.util.concurrent.ThreadPoolExecutor<
>>> http://eobjects.org/trac/wiki/ThreadPoolExecutor>
>>> > $Worker.run(ThreadPoolExecutor?<
>>> http://eobjects.org/trac/wiki/ThreadPoolExecutor>.java:908)
>>> > at java.lang.Thread.run(Thread.java:662)
>>>

Reply via email to