admin
2021-03-06 7804263c6061aef813f0db27cb3046f746572606
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
package com.yeshi.buwan.util.factory;
 
import com.yeshi.buwan.domain.CategoryVideo;
import com.yeshi.buwan.domain.VideoType;
import com.yeshi.buwan.domain.solr.SolrAlbumVideo;
import com.yeshi.buwan.domain.VideoInfo;
import com.yeshi.buwan.domain.VideoResource;
import com.yeshi.buwan.domain.solr.SolrCommonVideo;
import org.yeshi.utils.StringUtil;
 
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
 
public class SolrVideoFactory {
 
 
    public static SolrAlbumVideo createAlbum(VideoInfo videoInfo, List<VideoResource> videoResources) {
        SolrAlbumVideo solrVideo = new SolrAlbumVideo();
        solrVideo.setMainactor(videoInfo.getMainActor());
        solrVideo.setShow(Integer.parseInt(videoInfo.getShow()));
        solrVideo.setLatestHpicture(videoInfo.getLatestHpicture());
        solrVideo.setDuration(videoInfo.getDuration());
        solrVideo.setScore(videoInfo.getScore());
        solrVideo.setVpicture(videoInfo.getVpicture());
        solrVideo.setLatestVpicture(videoInfo.getLatestVpicture());
        solrVideo.setId(videoInfo.getId());
        solrVideo.setTag(videoInfo.getTag());
        solrVideo.setHpicture(videoInfo.getHpicture());
        solrVideo.setArea(videoInfo.getArea());
        solrVideo.setCreatetime(videoInfo.getCreatetime() + "");
        solrVideo.setWatchcount(Integer.parseInt(videoInfo.getWatchCount()));
        solrVideo.setDirector(videoInfo.getDirector());
        solrVideo.setPicture(videoInfo.getPicture());
        solrVideo.setContenttype(videoInfo.getContentType());
        solrVideo.setSolrTime(new Date());
        solrVideo.setCommentcount(videoInfo.getCommentCount());
        solrVideo.setVideocount(videoInfo.getVideocount());
        solrVideo.setName(videoInfo.getName());
        solrVideo.setUpdatetime(videoInfo.getUpdatetime());
        if (videoInfo.getUpdatetime() != null)
            solrVideo.setUpdateTime(Long.parseLong(videoInfo.getUpdatetime()));
        if (videoInfo.getVideoType() != null)
            solrVideo.setRootVideoType(videoInfo.getVideoType().getId());
        else
            solrVideo.setRootVideoType(0);
 
        solrVideo.setYear(videoInfo.getYear());
 
        if (videoResources != null && videoResources.size() > 0) {
            List<String> resourceIds = new ArrayList<>();
            for (VideoResource vr : videoResources) {
                resourceIds.add(vr.getId());
            }
            solrVideo.setResourceIds(StringUtil.concat(resourceIds, ","));
        }
 
        solrVideo.setFreeType(videoInfo.getFree());
 
        return solrVideo;
    }
 
 
    public static SolrCommonVideo createCommon(VideoInfo videoInfo, List<VideoType> typeList, List<VideoResource> videoResources) {
        SolrCommonVideo solrVideo = new SolrCommonVideo();
        solrVideo.setMainactor(videoInfo.getMainActor());
        solrVideo.setShow(Integer.parseInt(videoInfo.getShow()));
        solrVideo.setLatestHpicture(videoInfo.getLatestHpicture());
        solrVideo.setDuration(videoInfo.getDuration());
        solrVideo.setScore(videoInfo.getScore());
        solrVideo.setVpicture(videoInfo.getVpicture());
        solrVideo.setLatestVpicture(videoInfo.getLatestVpicture());
        solrVideo.setId(videoInfo.getId());
        solrVideo.setTag(videoInfo.getTag());
        solrVideo.setHpicture(videoInfo.getHpicture());
        solrVideo.setArea(videoInfo.getArea());
        solrVideo.setCreatetime(videoInfo.getCreatetime() + "");
        solrVideo.setWatchcount(Integer.parseInt(videoInfo.getWatchCount()));
        solrVideo.setDirector(videoInfo.getDirector());
        solrVideo.setPicture(videoInfo.getPicture());
        solrVideo.setContenttype(videoInfo.getContentType());
        solrVideo.setSolrTime(new Date());
        solrVideo.setCommentcount(videoInfo.getCommentCount());
        solrVideo.setVideocount(videoInfo.getVideocount());
        solrVideo.setName(videoInfo.getName());
        solrVideo.setUpdatetime(videoInfo.getUpdatetime());
        if (videoInfo.getUpdatetime() != null)
            solrVideo.setUpdateTime(Long.parseLong(videoInfo.getUpdatetime()));
        if (videoInfo.getVideoType() != null)
            solrVideo.setRootVideoType(videoInfo.getVideoType().getId());
 
        if (typeList != null && typeList.size() > 0) {
            VideoType videoType = typeList.get(0);
            if (videoType.getParent() != null) {
                solrVideo.setRootVideoType(videoType.getParent().getId());
            } else {
                solrVideo.setRootVideoType(videoType.getId());
            }
            List<Long> ids = new ArrayList<>();
            for (VideoType cv : typeList) {
                ids.add(cv.getId());
            }
            solrVideo.setVideoTypes(StringUtil.concat(ids, ","));
        }
 
        solrVideo.setYear(videoInfo.getYear());
 
        if (videoResources != null && videoResources.size() > 0) {
            List<String> resourceIds = new ArrayList<>();
            for (VideoResource vr : videoResources) {
                resourceIds.add(vr.getId());
            }
            solrVideo.setResourceIds(StringUtil.concat(resourceIds, ","));
        }
 
        return solrVideo;
    }
 
 
}