private static void addCampaignsToGroup ( AdWordsServicesInterface adWordsServices , AdWordsSession session , CampaignGroup campaignGroup , List < Long > campaignIds ) throws ApiException , RemoteException { // Get the CampaignService. CampaignServiceInterface campaignService = adWordsServices . get ( session , CampaignServiceInterface . class ) ; List < CampaignOperation > operations = new ArrayList <> ( ) ; for ( Long campaignId : campaignIds ) { Campaign campaign = new Campaign ( ) ; campaign . setId ( campaignId ) ; campaign . setCampaignGroupId ( campaignGroup . getId ( ) ) ; CampaignOperation operation = new CampaignOperation ( ) ; operation . setOperand ( campaign ) ; operation . setOperator ( Operator . SET ) ; operations . add ( operation ) ; } CampaignReturnValue returnValue = campaignService . mutate ( operations . toArray ( new CampaignOperation [ operations . size ( ) ] ) ) ; System . out . printf ( "The following campaign IDs were added to the campaign group with ID %d:%n" , campaignGroup . getId ( ) ) ; for ( Campaign campaign : returnValue . getValue ( ) ) { System . out . printf ( "\t%d%n" , campaign . getId ( ) ) ; } }
Adds multiple campaigns to a campaign group .