Re: V201206 old java client library Report Definition selector fields and predicates
Hi Jason, Thanks for the report, I'll try to get that (SelectorError in ReportDefinitionDervice) removed. - Kevin Winter AdWords API Team On Tuesday, November 6, 2012 8:16:09 PM UTC-5, Jason Stedman wrote: Kevin, The original link seems to have been removed, but there is still a Selector link in this section that links to the BudgetOrderService.Selector: https://developers.google.com/adwords/api/docs/reference/latest/ReportDefinitionService#SelectorError -- =~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~ Also find us on our blog and discussion group: http://adwordsapi.blogspot.com http://groups.google.com/group/adwords-api =~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~ You received this message because you are subscribed to the Google Groups AdWords API Forum group. To post to this group, send email to adwords-api@googlegroups.com To unsubscribe from this group, send email to adwords-api+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/adwords-api?hl=en
Re: V201206 old java client library Report Definition selector fields and predicates
Thanks for the suggestion Jason. The code example does it slightly differently: https://code.google.com/p/google-api-ads-java/source/browse/examples/adwords_axis/src/main/java/adwords/axis/v201209/reporting/DownloadCriteriaReport.java#64 That link unfortunately won't work - the latest version of the ReportDefinitionService doesn't define the Selector class anymore. Did you follow a link to this page? We should fix that if so. - Kevin Winter AdWords API Team On Thursday, September 27, 2012 7:58:05 AM UTC-4, Jason Stedman wrote: Christian, This is more a java suggestion than anything to do with AdWords as your posted code works, but I think it is aligned with the nature of the question. A cleaner way to handle this would be to extract the array of strings out of the constructor calls and setter methods and instead make them fields of your class. This also saves on garbage collection overhead if you make multiple calls to that method reusing the same instance of your class. I feel this will also make the code much more maintainable in the future. You can then abstract the logic out to something like this(which addAll most likely does anyway under the covers): { // class level declarations to save on garbage collection for things that are always initialized with the same value in a particular method String[] fieldsInReport = new String[] {AdGroupId, KeywordId, Id, Impressions, Clicks, Cost, AveragePosition, Date}; String[] predicateValues = new String[] {ENABLED, PAUSED, DISABLED}; ... // inside the method which uses the arrays of Strings for(String field : fieldsInReport){ fields.add(field); } statusPredicate = new Predicate(); statusPredicate.setField(Status); statusPredicate.setOperator(PredicateOperator.IN); ListString values = statusPredicate.getValues(); for(String value : predicateValues){ values.add(value); } } AdWords team : While thinking about this question I noticed the documentation is broken for the new Selector class in ReportDefinitionService: https://developers.google.com/adwords/api/docs/reference/latest/ReportDefinitionService.Selector -- =~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~ Also find us on our blog and discussion group: http://adwordsapi.blogspot.com http://groups.google.com/group/adwords-api =~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~ You received this message because you are subscribed to the Google Groups AdWords API Forum group. To post to this group, send email to adwords-api@googlegroups.com To unsubscribe from this group, send email to adwords-api+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/adwords-api?hl=en
Re: V201206 old java client library Report Definition selector fields and predicates
Kevin, The original link seems to have been removed, but there is still a Selector link in this section that links to the BudgetOrderService.Selector: https://developers.google.com/adwords/api/docs/reference/latest/ReportDefinitionService#SelectorError -- =~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~ Also find us on our blog and discussion group: http://adwordsapi.blogspot.com http://groups.google.com/group/adwords-api =~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~ You received this message because you are subscribed to the Google Groups AdWords API Forum group. To post to this group, send email to adwords-api@googlegroups.com To unsubscribe from this group, send email to adwords-api+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/adwords-api?hl=en
Re: V201206 old java client library Report Definition selector fields and predicates
Christian, This is more a java suggestion than anything to do with AdWords as your posted code works, but I think it is aligned with the nature of the question. A cleaner way to handle this would be to extract the array of strings out of the constructor calls and setter methods and instead make them fields of your class. This also saves on garbage collection overhead if you make multiple calls to that method reusing the same instance of your class. I feel this will also make the code much more maintainable in the future. You can then abstract the logic out to something like this(which addAll most likely does anyway under the covers): { // class level declarations to save on garbage collection for things that are always initialized with the same value in a particular method String[] fieldsInReport = new String[] {AdGroupId, KeywordId, Id, Impressions, Clicks, Cost, AveragePosition, Date}; String[] predicateValues = new String[] {ENABLED, PAUSED, DISABLED}; ... // inside the method which uses the arrays of Strings for(String field : fieldsInReport){ fields.add(field); } statusPredicate = new Predicate(); statusPredicate.setField(Status); statusPredicate.setOperator(PredicateOperator.IN); ListString values = statusPredicate.getValues(); for(String value : predicateValues){ values.add(value); } } AdWords team : While thinking about this question I noticed the documentation is broken for the new Selector class in ReportDefinitionService: https://developers.google.com/adwords/api/docs/reference/latest/ReportDefinitionService.Selector -- =~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~ Also find us on our blog and discussion group: http://adwordsapi.blogspot.com http://groups.google.com/group/adwords-api =~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~ You received this message because you are subscribed to the Google Groups AdWords API Forum group. To post to this group, send email to adwords-api@googlegroups.com To unsubscribe from this group, send email to adwords-api+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/adwords-api?hl=en
V201206 old java client library Report Definition selector fields and predicates
Since the transition from com.google.api.adwords.v201206.cm to com.google.api.adwords.v201206.jaxb.cm for ReportDefinition classes. Is there a simple means to translate selector fields and predicates between the two packages? Currently, I seem to be faced with re-writing the references from com.google.api.adwords.v201206.cm.Selector selector = new Selector(); selector.setFields(new String[] {AdGroupId, KeywordId, Id, Impressions, Clicks, Cost, AveragePosition, Date}); statusPredicate = new Predicate(Status, PredicateOperator.IN, new String[] {ENABLED, PAUSED, DISABLED}); to fields.addAll(Arrays.StringasList(new String[] {AdGroupId, KeywordId, Id, Impressions, Clicks, Cost, AveragePosition, Date})); statusPredicate = new Predicate(); statusPredicate.setField(Status); statusPredicate.setOperator(PredicateOperator.IN); statusPredicate.getValues().add(ENABLED); statusPredicate.getValues().add(PAUSED); statusPredicate.getValues().add(DISABLED); Perhaps I'm missing something but this seems cumbersome. Christian -- =~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~ Also find us on our blog and discussion group: http://adwordsapi.blogspot.com http://groups.google.com/group/adwords-api =~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~ You received this message because you are subscribed to the Google Groups AdWords API Forum group. To post to this group, send email to adwords-api@googlegroups.com To unsubscribe from this group, send email to adwords-api+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/adwords-api?hl=en