use of org.atlasapi.content.v2.model.Content in project atlas-deer by atlasapi.
the class EpisodeSetter method serialize.
public void serialize(Content internal, org.atlasapi.content.Content content) {
if (!Episode.class.isInstance(content)) {
return;
}
Episode episode = (Episode) content;
internal.setSeriesNumber(episode.getSeriesNumber());
internal.setEpisodeNumber(episode.getEpisodeNumber());
internal.setPartNumber(episode.getPartNumber());
internal.setSpecial(episode.getSpecial());
org.atlasapi.content.SeriesRef seriesRef = episode.getSeriesRef();
SeriesRef ref = seriesRefSerialization.serialize(seriesRef);
if (ref != null) {
internal.setSeriesRefs(ImmutableMap.of(refSerialization.serialize(seriesRef), ref));
}
}
use of org.atlasapi.content.v2.model.Content in project atlas-deer by atlasapi.
the class ItemSetter method serialize.
public void serialize(Content internal, org.atlasapi.content.Content content) {
if (!Item.class.isInstance(content)) {
return;
}
Item item = (Item) content;
internal.setContainerRef(containerRef.serialize(item.getContainerRef()));
internal.setIsLongForm(item.getIsLongForm());
internal.setBlackAndWhite(item.getBlackAndWhite());
internal.setSortKey(item.sortKey());
Duration duration = item.getDuration();
if (duration != null) {
internal.setDuration(duration.getMillis());
}
internal.setContainerSummary(containerSummary.serialize(item.getContainerSummary()));
internal.setBroadcasts(item.getBroadcasts().stream().collect(MoreCollectors.toImmutableMap(Broadcast::getSourceId, broadcast::serialize)));
internal.setSegmentEvents(item.getSegmentEvents().stream().map(segmentEvent::serialize).filter(Objects::nonNull).sorted(SegmentEvent.COMPARATOR).collect(Collectors.toList()));
internal.setRestrictions(item.getRestrictions().stream().collect(SetterUtils.toImmutableMapAllowDuplicates(restriction::serialize, r -> new UpdateTimes(toInstant(r.getLastUpdated()), toInstant(r.getEquivalenceUpdate())))));
}
use of org.atlasapi.content.v2.model.Content in project atlas-deer by atlasapi.
the class ItemSetter method deserialize.
public void deserialize(org.atlasapi.content.Content content, Content internal) {
Item item = (Item) content;
item.setContainerRef(containerRef.deserialize(internal.getContainerRef()));
Boolean isLongForm = internal.getIsLongForm();
if (isLongForm != null) {
item.setIsLongForm(isLongForm);
}
item.setBlackAndWhite(internal.getBlackAndWhite());
item = item.withSortKey(internal.getSortKey());
Long duration = internal.getDuration();
if (duration != null) {
item.setDuration(new Duration(duration));
}
item.setContainerSummary(containerSummary.deserialize(internal.getContainerSummary()));
Map<String, org.atlasapi.content.v2.model.udt.Broadcast> broadcasts = internal.getBroadcasts();
if (broadcasts != null) {
item.setBroadcasts(broadcasts.entrySet().stream().map(entry -> broadcast.deserialize(entry.getKey(), entry.getValue())).collect(Collectors.toSet()));
}
List<SegmentEvent> segmentEvents = internal.getSegmentEvents();
if (segmentEvents != null) {
item.setSegmentEvents(segmentEvents.stream().map(segmentEvent::deserialize).collect(Collectors.toList()));
}
Map<org.atlasapi.content.v2.model.udt.Restriction, UpdateTimes> restrictions = internal.getRestrictions();
if (restrictions != null) {
item.setRestrictions(restrictions.entrySet().stream().map(entry -> restriction.deserialize(entry.getValue(), entry.getKey())).collect(MoreCollectors.toImmutableSet()));
}
}
use of org.atlasapi.content.v2.model.Content in project atlas-deer by atlasapi.
the class ContentSerializerImpl method serialize.
@Override
public Content serialize(org.atlasapi.content.Content content) {
Content internal = new Content();
setType(internal, content);
contentSetter.serialize(internal, content);
itemSetter.serialize(internal, content);
songSetter.serialize(internal, content);
episodeSetter.serialize(internal, content);
filmSetter.serialize(internal, content);
containerSetter.serialize(internal, content);
brandSetter.serialize(internal, content);
seriesSetter.serialize(internal, content);
return internal;
}
use of org.atlasapi.content.v2.model.Content in project java-sdk by watson-developer-cloud.
the class PersonalityInsightsIT method getProfileWithContentItems.
/**
* Gets the profile from a list of content items.
*
* @throws Exception the exception
*/
@Test
public void getProfileWithContentItems() throws Exception {
final Content content = loadFixture(RESOURCE + "v3-contentItems.json", Content.class);
ProfileOptions options = new ProfileOptions.Builder().content(content).consumptionPreferences(true).rawScores(true).build();
Profile profile = service.profile(options).execute();
assertProfile(profile);
}
Aggregations