List of usage examples for com.google.gwt.core.client JsArrayString length
public final native int length() ;
From source file:com.google.mobile.trippy.web.client.db.LocalDbManager.java
License:Apache License
public void deleteTrip(final Trip trip) { final String tripKey = KEY_LOCAL_STORE_TRIP_PREFIX + trip.getKey(); LocalDbService.deletePersistent(tripKey); final JsArrayString tripKeys = getIndexKeys(KEY_LOCAL_STORE_TRIPS); final JsArrayString newTripKeys = (JsArrayString) JavaScriptObject.createArray(); for (int i = 0; i < tripKeys.length(); ++i) { if (!tripKeys.get(i).equals(tripKey)) { newTripKeys.push(tripKeys.get(i)); }//from w w w .ja va 2 s . co m } setIndexKeys(KEY_LOCAL_STORE_TRIPS, newTripKeys); eventBus.fireEvent(new TripDeletedEvent(trip)); }
From source file:com.google.mobile.trippy.web.client.db.LocalDbManager.java
License:Apache License
public void addTripItem(final TripItem tripItem) { JsoTripItem jsoTripItem = (JsoTripItem) JavaScriptObject.createObject(); jsoTripItem.setTripItem(tripItem);/*from ww w . java2 s . co m*/ final String tripItemKey = KEY_LOCAL_STORE_TI_PREFIX + tripItem.getKey(); LocalDbService.makePersistent(tripItemKey, new JSONObject(jsoTripItem).toString()); final JsArrayString tripItemKeys = getIndexKeys(KEY_LOCAL_STORE_TIS_PREFIX + tripItem.getTripId()); for (int i = 0; i < tripItemKeys.length(); ++i) { if (tripItemKeys.get(i).equals(tripItemKey)) { return; } } tripItemKeys.push(tripItemKey); setIndexKeys(KEY_LOCAL_STORE_TIS_PREFIX + tripItem.getTripId(), tripItemKeys); eventBus.fireEvent(new TripItemAddedEvent(tripItem)); final Trip trip = getTrip(tripItem.getTripId()); final String tripItemStartDate = "Day " + tripItem.getStartDay(); final String latlng = tripItem.getLatitude() + "," + tripItem.getLongitude(); utils.addTripItem(tripItemStartDate, tripItem.getTripId(), tripItem.getKey(), tripItem.getName(), tripItem.getAddress() + ", " + trip.getLocation(), latlng, utils.getTripItemPosition(tripItem.getTripId(), tripItem.getKey(), tripItem.getStartDay())); }
From source file:com.google.mobile.trippy.web.client.db.LocalDbManager.java
License:Apache License
public void deleteTripItem(final String tripId, final String tripItemId) { final TripItem tripItem = getTripItem(tripItemId); final String tripItemKey = KEY_LOCAL_STORE_TI_PREFIX + tripItemId; LocalDbService.deletePersistent(tripItemKey); final JsArrayString tripItemKeys = getIndexKeys(KEY_LOCAL_STORE_TIS_PREFIX + tripId); final JsArrayString newTripItemKeys = (JsArrayString) JavaScriptObject.createArray(); for (int i = 0; i < tripItemKeys.length(); ++i) { if (!tripItemKeys.get(i).equals(tripItemKey)) { newTripItemKeys.push(tripItemKeys.get(i)); }/*from ww w.j ava 2 s . c om*/ } setIndexKeys(KEY_LOCAL_STORE_TIS_PREFIX + tripId, newTripItemKeys); eventBus.fireEvent(new TripItemDeletedEvent(tripItem)); utils.remTripItem(tripItemId); }
From source file:com.google.mobile.trippy.web.client.db.LocalDbManager.java
License:Apache License
/** * Get trip items from main index.// w w w . j a v a 2 s. c om */ public ArrayList<TripItem> getTripItems(final String tripId) { final JsArrayString tripItemKeys = getIndexKeys(KEY_LOCAL_STORE_TIS_PREFIX + tripId); final ArrayList<TripItem> tripItems = new ArrayList<TripItem>(); for (int i = 0; i < tripItemKeys.length(); ++i) { final TripItem tripItem = getTripItemForKey(tripItemKeys.get(i)); if (tripItem != null && tripItem.getStatus().equals(Status.ACTIVE)) { tripItems.add(tripItem); } } return tripItems; }
From source file:com.google.mobile.trippy.web.client.db.LocalDbManager.java
License:Apache License
public ArrayList<String> getTripItemIds() { final JsArrayString keys = getIndexKeys(KEY_LOCAL_STORE_TIS_PREFIX); final ArrayList<String> ids = new ArrayList<String>(); for (int i = 0; i < keys.length(); ++i) { final String key = keys.get(i); final String id = key.replace(KEY_LOCAL_STORE_TI_PREFIX, ""); ids.add(id);//www .j a v a 2 s .co m } return ids; }
From source file:com.google.mobile.trippy.web.client.db.LocalDbManager.java
License:Apache License
public void addComment(final Comment comment) { final JsoComment jsoComment = (JsoComment) JavaScriptObject.createObject(); jsoComment.setComment(comment);//from www .ja v a 2 s . co m final String commentKey = KEY_LOCAL_STORE_COMMENT_PREFIX + comment.getKey(); LocalDbService.makePersistent(commentKey, new JSONObject(jsoComment).toString()); final JsArrayString commentKeys = getIndexKeys( KEY_LOCAL_STORE_COMMENTS_PREFIX + comment.getTripId() + "_" + comment.getTripItemId()); for (int i = 0; i < commentKeys.length(); ++i) { if (commentKeys.get(i).equals(commentKey)) { return; } } commentKeys.push(commentKey); setIndexKeys(KEY_LOCAL_STORE_COMMENTS_PREFIX + comment.getTripId() + "_" + comment.getTripItemId(), commentKeys); eventBus.fireEvent(new CommentAddedEvent(comment)); }
From source file:com.google.mobile.trippy.web.client.db.LocalDbManager.java
License:Apache License
public void deleteComment(final String tripId, final String tripItemId, final String commentId) { final Comment comment = getComment(commentId); final String commentKey = KEY_LOCAL_STORE_COMMENT_PREFIX + commentId; LocalDbService.deletePersistent(commentKey); final JsArrayString commentKeys = getIndexKeys(KEY_LOCAL_STORE_COMMENTS_PREFIX + tripId + "_" + tripItemId); final JsArrayString newCommentKeys = (JsArrayString) JavaScriptObject.createArray(); for (int i = 0; i < commentKeys.length(); ++i) { if (!commentKeys.get(i).equals(commentKey)) { newCommentKeys.push(commentKeys.get(i)); }/*from w w w . j a v a 2 s. co m*/ } setIndexKeys(KEY_LOCAL_STORE_COMMENTS_PREFIX + tripId + "_" + tripItemId, newCommentKeys); eventBus.fireEvent(new CommentDeletedEvent(comment)); }
From source file:com.google.mobile.trippy.web.client.db.LocalDbManager.java
License:Apache License
/** * Get comments by trip and trip item id. *///from ww w . j av a 2s. co m public ArrayList<Comment> getComments(final String tripId, final String tripItemId) { final JsArrayString tripItemKeys = getIndexKeys( KEY_LOCAL_STORE_COMMENTS_PREFIX + tripId + "_" + tripItemId); final ArrayList<Comment> comments = new ArrayList<Comment>(); for (int i = 0; i < tripItemKeys.length(); ++i) { final Comment comment = getCommentFromKey(tripItemKeys.get(i)); if (comment != null && comment.getStatus().equals(Status.ACTIVE)) { comments.add(comment); } } return comments; }
From source file:com.google.mobile.trippy.web.client.db.LocalDbManager.java
License:Apache License
public ArrayList<String> getCommentIds(final String tripId, final String tripItemId) { final JsArrayString keys = getIndexKeys(KEY_LOCAL_STORE_COMMENTS_PREFIX + tripId + "_" + tripItemId); final ArrayList<String> ids = new ArrayList<String>(); for (int i = 0; i < keys.length(); ++i) { final String key = keys.get(i); final String id = key.replace(KEY_LOCAL_STORE_COMMENT_PREFIX, ""); ids.add(id);/*from w w w . ja v a 2 s . c om*/ } return ids; }
From source file:com.google.speedtracer.breaky.client.DumpValidator.java
License:Apache License
/** * In our schema set, if a schema has a fully constrained type property, then * it is a concrete rather than an abstract type. The ID Map let's us quickly * validate based on the concrete type as objects come in. */// ww w.j a v a2 s . c o m private void fillIdMap() { JsArrayString schemaNames = listSchemas(); for (int i = 0; i < schemaNames.length(); i++) { JsonSchema schema = (JsonSchema) DataBag.getJSObjectProperty(schemas, schemaNames.get(i)); JavaScriptObject properties = schema.getProperties(); if (DataBag.hasOwnProperty(properties, "type")) { JsonSchema dumpType = DataBag.getJSObjectProperty(properties, "type"); if ((DataBag.hasOwnProperty(dumpType, "minimum") && DataBag.hasOwnProperty(dumpType, "maximum")) && dumpType.getMinimum() == dumpType.getMaximum()) { idMap.put(dumpType.getMinimum(), schema); } } } }