use of com.willshex.blogwt.shared.api.datatype.Rating in project blogwt by billy1380.
the class RatingService method addRating.
@Override
public Rating addRating(Rating rating) {
if (rating.created == null) {
rating.created = new Date();
}
if (rating.by != null) {
rating.byKey = Key.create(rating.by);
}
Key<Rating> key = provide().save().entity(rating).now();
rating.id = keyToId(key);
return rating;
}
use of com.willshex.blogwt.shared.api.datatype.Rating in project blogwt by billy1380.
the class GetRatingsResponse method fromJson.
@Override
public void fromJson(JsonObject jsonObject) {
super.fromJson(jsonObject);
if (jsonObject.has("ratings")) {
JsonElement jsonRatings = jsonObject.get("ratings");
if (jsonRatings != null) {
ratings = new ArrayList<Rating>();
Rating item = null;
for (int i = 0; i < jsonRatings.getAsJsonArray().size(); i++) {
if (jsonRatings.getAsJsonArray().get(i) != null) {
(item = new Rating()).fromJson(jsonRatings.getAsJsonArray().get(i).getAsJsonObject());
ratings.add(item);
}
}
}
}
if (jsonObject.has("pager")) {
JsonElement jsonPager = jsonObject.get("pager");
if (jsonPager != null) {
pager = new Pager();
pager.fromJson(jsonPager.getAsJsonObject());
}
}
}
use of com.willshex.blogwt.shared.api.datatype.Rating in project blogwt by billy1380.
the class SubmitRatingResponse method fromJson.
@Override
public void fromJson(JsonObject jsonObject) {
super.fromJson(jsonObject);
if (jsonObject.has("rating")) {
JsonElement jsonRating = jsonObject.get("rating");
if (jsonRating != null) {
rating = new Rating();
rating.fromJson(jsonRating.getAsJsonObject());
}
}
}
use of com.willshex.blogwt.shared.api.datatype.Rating in project blogwt by billy1380.
the class RatingValidator method lookup.
public static Rating lookup(Rating rating, String name) throws InputValidationException {
if (rating == null)
throwServiceError(InputValidationException.class, ApiError.InvalidValueNull, TYPE + ": " + name);
boolean isIdLookup = false;
if (rating.id != null) {
isIdLookup = true;
}
if (!isIdLookup)
throwServiceError(InputValidationException.class, ApiError.DataTypeNoLookup, TYPE + ": " + name);
Rating lookupRating = null;
if (isIdLookup) {
lookupRating = RatingServiceProvider.provide().getRating(rating.id);
}
if (lookupRating == null)
throwServiceError(InputValidationException.class, ApiError.DataTypeNotFound, TYPE + ": " + name);
return lookupRating;
}
use of com.willshex.blogwt.shared.api.datatype.Rating in project blogwt by billy1380.
the class SubmitRatingRequest method fromJson.
@Override
public void fromJson(JsonObject jsonObject) {
super.fromJson(jsonObject);
if (jsonObject.has("rating")) {
JsonElement jsonRating = jsonObject.get("rating");
if (jsonRating != null) {
rating = new Rating();
rating.fromJson(jsonRating.getAsJsonObject());
}
}
}
Aggregations