Search in sources :

Example 1 with Content

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));
    }
}
Also used : Episode(org.atlasapi.content.Episode) SeriesRef(org.atlasapi.content.v2.model.udt.SeriesRef)

Example 2 with Content

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())))));
}
Also used : Item(org.atlasapi.content.Item) Broadcast(org.atlasapi.content.Broadcast) UpdateTimes(org.atlasapi.content.v2.model.udt.UpdateTimes) Duration(org.joda.time.Duration)

Example 3 with Content

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()));
    }
}
Also used : UpdateTimes(org.atlasapi.content.v2.model.udt.UpdateTimes) Duration(org.joda.time.Duration) Item(org.atlasapi.content.Item) Broadcast(org.atlasapi.content.Broadcast) SegmentEvent(org.atlasapi.content.v2.model.udt.SegmentEvent)

Example 4 with Content

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;
}
Also used : Content(org.atlasapi.content.v2.model.Content)

Example 5 with Content

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);
}
Also used : ProfileOptions(com.ibm.watson.developer_cloud.personality_insights.v3.model.ProfileOptions) Content(com.ibm.watson.developer_cloud.personality_insights.v3.model.Content) Profile(com.ibm.watson.developer_cloud.personality_insights.v3.model.Profile) Test(org.junit.Test) WatsonServiceTest(com.ibm.watson.developer_cloud.WatsonServiceTest)

Aggregations

Test (org.junit.Test)9 Content (com.ibm.watson.developer_cloud.personality_insights.v3.model.Content)6 Content (com.ibm.watson.personality_insights.v3.model.Content)5 ProfileOptions (com.ibm.watson.personality_insights.v3.model.ProfileOptions)5 Profile (com.ibm.watson.developer_cloud.personality_insights.v3.model.Profile)4 ProfileOptions (com.ibm.watson.developer_cloud.personality_insights.v3.model.ProfileOptions)4 ContentItem (com.ibm.watson.personality_insights.v3.model.ContentItem)4 Profile (com.ibm.watson.personality_insights.v3.model.Profile)4 File (java.io.File)4 FileInputStream (java.io.FileInputStream)4 SeriesRef (org.atlasapi.content.v2.model.udt.SeriesRef)4 WatsonServiceTest (com.ibm.watson.common.WatsonServiceTest)3 WatsonServiceTest (com.ibm.watson.developer_cloud.WatsonServiceTest)3 WatsonServiceUnitTest (com.ibm.watson.developer_cloud.WatsonServiceUnitTest)3 ContentItem (com.ibm.watson.developer_cloud.personality_insights.v3.model.ContentItem)3 Date (java.util.Date)3 RecordedRequest (okhttp3.mockwebserver.RecordedRequest)3 Ref (org.atlasapi.content.v2.model.udt.Ref)3 Map (java.util.Map)2 Objects (java.util.Objects)2