}
}
}
private DoubanCollectionObj generateCollection (Long id, CollectionStatus status, List<String> tags, int rating, String content, Long subjectId, Boolean isPrivate) {
DoubanCollectionObj col = new DoubanCollectionObj();
if (status != null) {
col.setStatus(status.getValue());
} else {
return null;
}
if (id != null) {
col.setId(RequestUrls.DOUBAN_COLLECTION_PREFIX + "/" + id);
}
DoubanRatingObj rat = new DoubanRatingObj();
if (rating > 5) {
rating = 5;
} else if (rating < 1) {
rating = 1;
}
rat.setValue(rating);
col.setRating(rat);
if (tags != null && !tags.isEmpty()) {
List<DoubanTagObj> tagsList = new ArrayList<DoubanTagObj>();
for (String t : tags) {
DoubanTagObj tag = new DoubanTagObj();
tag.setName(t);
tagsList.add(tag);
}
col.setTags(tagsList);
}
if (subjectId == null) {
return null;
}
DoubanSubjectObj sub = new DoubanSubjectObj();
sub.setId("" + subjectId);
col.setSubject(sub);
col.setContent(content == null ? "" : content);
if (isPrivate != null && isPrivate) {
List<DoubanAttributeObj> atts = new ArrayList<DoubanAttributeObj>();
DoubanAttributeObj att = new DoubanAttributeObj();
att.setName("privacy");
att.setValue("private");
atts.add(att);
col.setAtt(atts);
}
return col;
}