|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.citygrid.content.places.search.CGPlacesSearch
public class CGPlacesSearch
A builder for invoking the CityGrid Places Search API as documented at http://docs.citygridmedia.com/display/citygridv2/Places+API.
The most popular use case for CityGrid is to be able to perform a places search to show results for places around a lat/lon or zip code, show a detail as a result of any user interaction, and call the tracker on each interaction to earn money.
Let's pretend the user chose to find Movie Theater's in 90045 through your application. This would typically be ready from your UI or model.
// Pretends the user chose to find Movie Theater's in 90045 within the application
// and this is read from your UI or model
CGPlacesSearch search = CityGrid.placesSearch();
search.setType(CGPlacesSearchType.MovieTheater);
search.setWhere("90045");
search.setHistograms(true);
CGPlacesSearchResults results = search(search);
for (CGPlacesSearchLocation location : results.getLocations()) {
// do something with the location...
}
Next, pretend the user selected a location and wanted to view the profile as a result. The selected location might have come from any one from the list of locations, but for the purpose of an example this will chose the first location.
// Pretend the user selected the first location result and wants to display the full location data
// Usually this is a navigation to a detail view.
CGPlacesSearchLocation searchLocation = results.getLocations()[0];
// Get the detail (This will populate the locationId and impressionId for you)
// You could alternatively use the locationId and impressionId yourself, but this is easier
CGPlacesDetailLocation detailLocation = searchLocation.placesDetailLocation();
// do something with the location detail.
The location is displayed, but we also have to track that the location was displayed. Also, if the user clicks on or navigates on any content be sure to track that as well.
try {
detailLocation.track(
MY_MUID,
MY_MOBILE_TYPE,
CGAdsTrackerActionTarget.ClickToCall);
}
catch (CGException e) {
e.printStackTrace();
}
Field Summary | |
---|---|
private static String |
CGPlacesSearchLatLonUri
|
private static String |
CGPlacesSearchWhereUri
|
private int |
chain
Restricts search to listings with the given chain id. |
private int |
connectTimeout
The network connect connectTimeout used when performing a search. |
private String |
first
Restricts search to entities whose name begins with the given character, or if "#", then to entities beginning with any digit. |
private boolean |
histograms
An optional property for providing information on how many listings are in given groups and categories. |
private String |
impressionId
An optional property for grouping API calls for tracking purposes. |
private CGLatLon |
latlon
Latitude and longitude of the center of a circle for a geographic search. |
private CGLatLon |
latlon2
Second latitude and longitude used when performing a manual box search. |
private boolean |
offers
Whether to return only listings that have offers associated with them. |
private int |
page
The page number of the result set to display. |
private String |
placement
An optional property for storing additional information you would like CityGrid Media to log for this view. |
private String |
publisher
The publisher code that identifies you. |
private float |
radius
Radius of a circle search. |
private int |
readTimeout
The network read connectTimeout used when performing a search. |
private int |
resultsPerPage
The number of results to be displayed/returned in a page. |
private CGPlacesSearchSort |
sort
Sort criterion for the results. |
private int |
tag
Restricts search to listings with the given tag id. |
private CGPlacesSearchType |
type
Restricts results to listings of the given type |
private String |
what
Search term text |
private String |
where
The geographic location |
Constructor Summary | |
---|---|
CGPlacesSearch(String publisher)
Create a places search with the publisher. |
Method Summary | |
---|---|
private Map<String,Object> |
build()
|
Object |
clone()
|
boolean |
equals(Object o)
|
int |
getChain()
|
int |
getConnectTimeout()
|
String |
getFirst()
|
String |
getImpressionId()
|
CGLatLon |
getLatlon()
|
CGLatLon |
getLatlon2()
|
int |
getPage()
|
String |
getPlacement()
|
String |
getPublisher()
|
float |
getRadius()
|
int |
getReadTimeout()
|
int |
getResultsPerPage()
|
CGPlacesSearchSort |
getSort()
|
int |
getTag()
|
CGPlacesSearchType |
getType()
|
String |
getWhat()
|
String |
getWhere()
|
int |
hashCode()
|
boolean |
isHistograms()
|
boolean |
isOffers()
|
static CGPlacesSearch |
placesSearch()
Returns a search builder that is initialized to the global publisher ande timeout values. |
static CGPlacesSearch |
placesSearchWithPlacement(String placement)
Returns a search builder that is initialized to the global connectTimeout values. |
static CGPlacesSearch |
placesSearchWithPublisher(String publisher)
Returns a search builder that is initialized to the global connectTimeout values. |
static CGPlacesSearch |
placesSearchWithPublisherAndPlacement(String publisher,
String placement)
Returns a search builder that is initialized to the global connectTimeout values. |
private String[] |
processCategories(org.codehaus.jackson.JsonNode node)
|
private CGPlacesSearchLocation[] |
processLocations(org.codehaus.jackson.JsonNode locationsNode)
|
(package private) CGPlacesSearchResults |
processResults(org.codehaus.jackson.JsonNode rootNode)
|
CGPlacesSearchResults |
search()
Performs a where search as documented by http://docs.citygridmedia.com/display/citygridv2/Places+API#PlacesAPI-SearchUsingWhere |
void |
setChain(int chain)
|
void |
setConnectTimeout(int connectTimeout)
|
void |
setFirst(String first)
|
void |
setHistograms(boolean histograms)
|
void |
setImpressionId(String impressionId)
|
void |
setLatlon(CGLatLon latlon)
|
void |
setLatlon2(CGLatLon latlon2)
|
void |
setOffers(boolean offers)
|
void |
setPage(int page)
|
void |
setPlacement(String placement)
|
void |
setPublisher(String publisher)
|
void |
setRadius(float radius)
|
void |
setReadTimeout(int readTimeout)
|
void |
setResultsPerPage(int resultsPerPage)
|
void |
setSort(CGPlacesSearchSort sort)
|
void |
setTag(int tag)
|
void |
setType(CGPlacesSearchType type)
|
void |
setWhat(String what)
|
void |
setWhere(String where)
|
String |
toString()
|
private List<CGError> |
validate()
|
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
private static final String CGPlacesSearchWhereUri
private static final String CGPlacesSearchLatLonUri
private String publisher
private CGPlacesSearchType type
private String what
private int tag
Tag ids are internal CityGrid identifiers and subject to change. This parameter should only be used in queries that are obtained as "refinement urls" from previous searches.
private int chain
@discussion Chain ids are internal CityGrid identifiers and subject to change. This parameter should only be used in queries that are obtained as "chain expansion urls" from previous searches.
private String first
private String where
Address-based search is performed when this parameter starts with a number and contains non-numeric characters; it is much slower than searching a named region
private float radius
private int page
private int resultsPerPage
private CGPlacesSearchSort sort
Use alpha to sort results alphabetically, and dist to sort by increasing distance from the center of the search region. The dist request is only valid for address-based and circle searches.
If this parameter is omitted, the results will be ranked by relevance for keyword searches and distance for latitude and longitude
private String placement
An example: if you run a search engine marketing campaign for, say, Google and Yahoo!, you can set the placement property to "sem_google" or "sem_yahoo". Alternatively, if you publish CityGrid listings in different locations in your own site, you can set the placement property to values such as "home_page" or "search" (all up to you). CityGrid will organize reports for you by placement
private boolean offers
private boolean histograms
Turning on histograms can affect performance.
private CGLatLon latlon
private CGLatLon latlon2
private int connectTimeout
private int readTimeout
private String impressionId
The value should be set when making subsequent calls that are related to a previously made call. The user should never supply their own generated value for the impression_id.
Constructor Detail |
---|
public CGPlacesSearch(String publisher)
Although this is available to use, it's recommended to use one of the following:
Method Detail |
---|
public String getPublisher()
public void setPublisher(String publisher)
public CGPlacesSearchType getType()
public void setType(CGPlacesSearchType type)
public String getWhat()
public void setWhat(String what)
public int getTag()
public void setTag(int tag)
public int getChain()
public void setChain(int chain)
public String getFirst()
public void setFirst(String first)
public String getWhere()
public void setWhere(String where)
public float getRadius()
public void setRadius(float radius)
public int getPage()
public void setPage(int page)
public int getResultsPerPage()
public void setResultsPerPage(int resultsPerPage)
public CGPlacesSearchSort getSort()
public void setSort(CGPlacesSearchSort sort)
public String getPlacement()
public void setPlacement(String placement)
public boolean isOffers()
public void setOffers(boolean offers)
public boolean isHistograms()
public void setHistograms(boolean histograms)
public CGLatLon getLatlon()
public void setLatlon(CGLatLon latlon)
public CGLatLon getLatlon2()
public void setLatlon2(CGLatLon latlon2)
public int getConnectTimeout()
public void setConnectTimeout(int connectTimeout)
public int getReadTimeout()
public void setReadTimeout(int readTimeout)
public String getImpressionId()
public void setImpressionId(String impressionId)
public static CGPlacesSearch placesSearch()
public static CGPlacesSearch placesSearchWithPublisher(String publisher)
publisher
-
public static CGPlacesSearch placesSearchWithPlacement(String placement)
placement
-
public static CGPlacesSearch placesSearchWithPublisherAndPlacement(String publisher, String placement)
publisher
- placement
-
private List<CGError> validate()
public CGPlacesSearchResults search() throws CGException
CGException
private Map<String,Object> build()
CGPlacesSearchResults processResults(org.codehaus.jackson.JsonNode rootNode)
private CGPlacesSearchLocation[] processLocations(org.codehaus.jackson.JsonNode locationsNode)
private String[] processCategories(org.codehaus.jackson.JsonNode node)
public boolean equals(Object o)
equals
in class Object
public int hashCode()
hashCode
in class Object
public String toString()
toString
in class Object
public Object clone() throws CloneNotSupportedException
clone
in class Object
CloneNotSupportedException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |