com.microsoft.bingads.v13.bulk.entities.BulkAssetGroup Maven / Gradle / Ivy
Show all versions of microsoft.bingads Show documentation
package com.microsoft.bingads.v13.bulk.entities;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import com.microsoft.bingads.internal.UncheckedParseException;
import com.microsoft.bingads.internal.functionalinterfaces.BiConsumer;
import com.microsoft.bingads.internal.functionalinterfaces.Function;
import com.microsoft.bingads.v13.bulk.BulkFileReader;
import com.microsoft.bingads.v13.bulk.BulkFileWriter;
import com.microsoft.bingads.v13.bulk.BulkOperation;
import com.microsoft.bingads.v13.bulk.BulkServiceManager;
import com.microsoft.bingads.v13.campaignmanagement.AssetGroup;
import com.microsoft.bingads.v13.campaignmanagement.AssetGroupEditorialStatus;
import com.microsoft.bingads.v13.campaignmanagement.AssetGroupStatus;
import com.microsoft.bingads.v13.campaignmanagement.ArrayOfstring;
import com.microsoft.bingads.v13.campaignmanagement.CallToAction;
import com.microsoft.bingads.v13.campaignmanagement.CampaignType;
import com.microsoft.bingads.v13.internal.bulk.BulkMapping;
import com.microsoft.bingads.v13.internal.bulk.MappingHelpers;
import com.microsoft.bingads.v13.internal.bulk.RowValues;
import com.microsoft.bingads.v13.internal.bulk.SimpleBulkMapping;
import com.microsoft.bingads.v13.internal.bulk.StringExtensions;
import com.microsoft.bingads.v13.internal.bulk.StringTable;
import com.microsoft.bingads.v13.internal.bulk.entities.SingleRecordBulkEntity;
/**
* Represents an Asset Group.
*
*
* This class exposes the {@link #setAssetGroup} and {@link #getAssetGroup} that can be used to read and write
* fields of the Asset Group record in a bulk file.
*
*
*
* For more information, see Asset Group at
* https://go.microsoft.com/fwlink/?linkid=846127.
*
*
* @see BulkServiceManager
* @see BulkOperation
* @see BulkFileReader
* @see BulkFileWriter
*/
public class BulkAssetGroup extends SingleRecordBulkEntity {
private Long campaignId;
private String campaignName;
private AssetGroup assetGroup;
private static final List> MAPPINGS;
static {
List> m = new ArrayList>();
m.add(new SimpleBulkMapping(StringTable.Id,
new Function() {
@Override
public Long apply(BulkAssetGroup c) {
return c.getAssetGroup().getId();
}
},
new BiConsumer() {
@Override
public void accept(String v, BulkAssetGroup c) {
c.getAssetGroup().setId(StringExtensions.nullOrLong(v));
}
}
));
m.add(new SimpleBulkMapping(StringTable.Status,
new Function() {
@Override
public String apply(BulkAssetGroup c) {
return c.getAssetGroup().getStatus() != null ? c.getAssetGroup().getStatus().value() : null;
}
},
new BiConsumer() {
@Override
public void accept(String v, BulkAssetGroup c) {
c.getAssetGroup().setStatus(StringExtensions.parseOptional(v, new Function() {
@Override
public AssetGroupStatus apply(String value) {
return AssetGroupStatus.fromValue(value);
}
}));
}
}
));
m.add(new SimpleBulkMapping(StringTable.ParentId,
new Function() {
@Override
public Long apply(BulkAssetGroup c) {
return c.getCampaignId();
}
},
new BiConsumer() {
@Override
public void accept(String v, BulkAssetGroup c) {
c.setCampaignId(StringExtensions.parseOptional(v, new Function() {
@Override
public Long apply(String value) {
return Long.parseLong(value);
}
}));
}
}
));
m.add(new SimpleBulkMapping(StringTable.Campaign,
new Function() {
@Override
public String apply(BulkAssetGroup c) {
return c.getCampaignName();
}
},
new BiConsumer() {
@Override
public void accept(String v, BulkAssetGroup c) {
c.setCampaignName(v);
}
}
));
m.add(new SimpleBulkMapping(StringTable.AssetGroup,
new Function() {
@Override
public String apply(BulkAssetGroup c) {
return c.getAssetGroup().getName();
}
},
new BiConsumer() {
@Override
public void accept(String v, BulkAssetGroup c) {
c.getAssetGroup().setName(v);
}
}
));
m.add(new SimpleBulkMapping(StringTable.StartDate,
new Function() {
@Override
public String apply(BulkAssetGroup c) {
return StringExtensions.toDateBulkString(c.getAssetGroup().getStartDate());
}
},
new BiConsumer() {
@Override
public void accept(String v, BulkAssetGroup c) {
try {
c.getAssetGroup().setStartDate(StringExtensions.parseDate(v));
} catch (ParseException ex) {
throw new UncheckedParseException(ex);
}
}
}
));
m.add(new SimpleBulkMapping(StringTable.EndDate,
new Function() {
@Override
public String apply(BulkAssetGroup c) {
return StringExtensions.toDateBulkString(c.getAssetGroup().getEndDate());
}
},
new BiConsumer() {
@Override
public void accept(String v, BulkAssetGroup c) {
try {
c.getAssetGroup().setEndDate(StringExtensions.parseDate(v));
} catch (ParseException ex) {
throw new UncheckedParseException(ex);
}
}
}
));
m.add(new SimpleBulkMapping(StringTable.BusinessName,
new Function() {
@Override
public String apply(BulkAssetGroup c) {
return c.getAssetGroup().getBusinessName();
}
},
new BiConsumer() {
@Override
public void accept(String v, BulkAssetGroup c) {
c.getAssetGroup().setBusinessName(v);
}
}
));
m.add(new SimpleBulkMapping(StringTable.CallToAction,
new Function() {
@Override
public String apply(BulkAssetGroup c) {
return c.getAssetGroup().getCallToAction() != null ? c.getAssetGroup().getCallToAction().value() : null;
}
},
new BiConsumer() {
@Override
public void accept(String v, BulkAssetGroup c) {
c.getAssetGroup().setCallToAction(StringExtensions.parseOptional(v, new Function() {
@Override
public CallToAction apply(String value) {
return CallToAction.fromValue(value);
}
}));
}
}
));
m.add(new SimpleBulkMapping(StringTable.Descriptions,
new Function() {
@Override
public String apply(BulkAssetGroup c) {
return StringExtensions.toTextAssetLinksBulkString(c.getAssetGroup().getDescriptions());
}
},
new BiConsumer() {
@Override
public void accept(String v, BulkAssetGroup c) {
c.getAssetGroup().setDescriptions(StringExtensions.parseTextAssetLinks(v));
}
}
));
m.add(new SimpleBulkMapping(StringTable.EditorialStatus,
new Function() {
@Override
public String apply(BulkAssetGroup t) {
return t.getAssetGroup().getEditorialStatus() != null ? t.getAssetGroup().getEditorialStatus().value() : null;
}
},
new BiConsumer() {
@Override
public void accept(String v, BulkAssetGroup c) {
c.getAssetGroup().setEditorialStatus(StringExtensions.parseOptional(v, new Function() {
@Override
public AssetGroupEditorialStatus apply(String value) {
return AssetGroupEditorialStatus.fromValue(value);
}
}));
}
}
));
m.add(new SimpleBulkMapping(StringTable.FinalMobileUrl,
new Function() {
@Override
public String apply(BulkAssetGroup c) {
return StringExtensions.writeUrls("; ", c.getAssetGroup().getFinalMobileUrls(), c.getAssetGroup().getId());
}
},
new BiConsumer() {
@Override
public void accept(String v, BulkAssetGroup c) {
ArrayOfstring urls = new ArrayOfstring();
List urlArray = StringExtensions.parseUrls(v);
if(urlArray == null) {
urls = null;
} else {
urls.getStrings().addAll(urlArray);
}
c.getAssetGroup().setFinalMobileUrls(urls);
}
}
));
m.add(new SimpleBulkMapping(StringTable.FinalUrl,
new Function() {
@Override
public String apply(BulkAssetGroup c) {
return StringExtensions.writeUrls("; ", c.getAssetGroup().getFinalUrls(), c.getAssetGroup().getId());
}
},
new BiConsumer() {
@Override
public void accept(String v, BulkAssetGroup c) {
ArrayOfstring urls = new ArrayOfstring();
List urlArray = StringExtensions.parseUrls(v);
if(urlArray == null) {
urls = null;
} else {
urls.getStrings().addAll(urlArray);
}
c.getAssetGroup().setFinalUrls(urls);
}
}
));
m.add(new SimpleBulkMapping(StringTable.Headlines,
new Function() {
@Override
public String apply(BulkAssetGroup c) {
return StringExtensions.toTextAssetLinksBulkString(c.getAssetGroup().getHeadlines());
}
},
new BiConsumer() {
@Override
public void accept(String v, BulkAssetGroup c) {
c.getAssetGroup().setHeadlines(StringExtensions.parseTextAssetLinks(v));
}
}
));
m.add(new SimpleBulkMapping(StringTable.Images,
new Function() {
@Override
public String apply(BulkAssetGroup c) {
return StringExtensions.toImageAssetLinksBulkString(c.getAssetGroup().getImages());
}
},
new BiConsumer() {
@Override
public void accept(String v, BulkAssetGroup c) {
c.getAssetGroup().setImages(StringExtensions.parseImageAssetLinks(v));
}
}
));
m.add(new SimpleBulkMapping(StringTable.LongHeadlines,
new Function() {
@Override
public String apply(BulkAssetGroup c) {
return StringExtensions.toTextAssetLinksBulkString(c.getAssetGroup().getLongHeadlines());
}
},
new BiConsumer() {
@Override
public void accept(String v, BulkAssetGroup c) {
c.getAssetGroup().setLongHeadlines(StringExtensions.parseTextAssetLinks(v));
}
}
));
m.add(new SimpleBulkMapping(StringTable.Path1,
new Function() {
@Override
public String apply(BulkAssetGroup c) {
return StringExtensions.toOptionalBulkString(c.getAssetGroup().getPath1(), c.getAssetGroup().getId());
}
},
new BiConsumer() {
@Override
public void accept(String v, BulkAssetGroup c) {
c.getAssetGroup().setPath1(StringExtensions.getValueOrEmptyString(v));
}
}
));
m.add(new SimpleBulkMapping(StringTable.Path2,
new Function() {
@Override
public String apply(BulkAssetGroup c) {
return StringExtensions.toOptionalBulkString(c.getAssetGroup().getPath2(), c.getAssetGroup().getId());
}
},
new BiConsumer() {
@Override
public void accept(String v, BulkAssetGroup c) {
c.getAssetGroup().setPath2(StringExtensions.getValueOrEmptyString(v));
}
}
));
MAPPINGS = Collections.unmodifiableList(m);
}
@Override
public void processMappingsFromRowValues(RowValues values) {
this.setAssetGroup(new AssetGroup());
MappingHelpers.convertToEntity(values, MAPPINGS, this);
}
@Override
public void processMappingsToRowValues(RowValues values, boolean excludeReadonlyData) {
validatePropertyNotNull(getAssetGroup(), "AssetGroup");
MappingHelpers.convertToValues(this, values, MAPPINGS);
}
/**
* Gets the identifier of the campaign that contains the ad group.
*
*
* Corresponds to the 'Parent Id' field in the bulk file.
*
*/
public Long getCampaignId() {
return campaignId;
}
/**
* Sets the identifier of the campaign that contains the ad group.
*
*
* Corresponds to the 'Parent Id' field in the bulk file.
*
*/
public void setCampaignId(Long campaignId) {
this.campaignId = campaignId;
}
/**
* Gets the name of the campaign that contains the ad group.
*
*
* Corresponds to the 'Campaign' field in the bulk file.
*
*/
public String getCampaignName() {
return campaignName;
}
/**
* Sets the name of the campaign that contains the ad group.
*
*
* Corresponds to the 'Campaign' field in the bulk file.
*
*/
public void setCampaignName(String campaignName) {
this.campaignName = campaignName;
}
/**
* Gets the AssetGroup Data Object of the Campaign Management Service.
*
*
* A subset of AssetGroup properties are available in the Ad Group record.
* For more information, see Ad Group at
* https://go.microsoft.com/fwlink/?linkid=846127.
*
*/
public AssetGroup getAssetGroup() {
return assetGroup;
}
/**
* Sets the AssetGroup Data Object of the Campaign Management Service.
*
*
* A subset of AssetGroup properties are available in the Ad Group record.
* For more information, see Ad Group at
* https://go.microsoft.com/fwlink/?linkid=846127.
*
*/
public void setAssetGroup(AssetGroup assetGroup) {
this.assetGroup = assetGroup;
}
}