public Collection getAsParameters() {
List parameters = new ArrayList();
String media = getMedia();
if (media != null) {
parameters.add(new Parameter("media", media));
}
String userId = getUserId();
if (userId != null) {
parameters.add(new Parameter("user_id", userId));
String contacts = getContacts();
if (contacts != null) {
parameters.add(new Parameter("contacts", contacts));
}
}
String groupId = getGroupId();
if (groupId != null) {
parameters.add(new Parameter("group_id", groupId));
}
String[] tags = getTags();
if (tags != null) {
parameters.add(new Parameter("tags", StringUtilities.join(tags, ",")));
}
String tagMode = getTagMode();
if (tagMode != null) {
parameters.add(new Parameter("tag_mode", tagMode));
}
String[] mtags = getMachineTags();
if (mtags != null) {
parameters.add(new Parameter("machine_tags", StringUtilities.join(mtags, ",")));
}
String mtagMode = getMachineTagMode();
if (mtagMode != null) {
parameters.add(new Parameter("machine_tag_mode", mtagMode));
}
String text = getText();
if (text != null) {
parameters.add(new Parameter("text", text));
}
Date minUploadDate = getMinUploadDate();
if (minUploadDate != null) {
parameters.add(new Parameter("min_upload_date", new Long(minUploadDate.getTime() / 1000L)));
}
Date maxUploadDate = getMaxUploadDate();
if (maxUploadDate != null) {
parameters.add(new Parameter("max_upload_date", new Long(maxUploadDate.getTime() / 1000L)));
}
Date minTakenDate = getMinTakenDate();
if (minTakenDate != null) {
parameters.add(new Parameter("min_taken_date", ((DateFormat)MYSQL_DATE_FORMATS.get()).format(minTakenDate)));
}
Date maxTakenDate = getMaxTakenDate();
if (maxTakenDate != null) {
parameters.add(new Parameter("max_taken_date", ((DateFormat)MYSQL_DATE_FORMATS.get()).format(maxTakenDate)));
}
String license = getLicense();
if (license != null) {
parameters.add(new Parameter("license", license));
}
Date intrestingnessDate = getInterestingnessDate();
if (intrestingnessDate != null) {
parameters.add(new Parameter("date", ((DateFormat)DATE_FORMATS.get()).format(intrestingnessDate)));
}
String[] bbox = getBBox();
if (bbox != null) {
parameters.add(new Parameter("bbox", StringUtilities.join(bbox, ",")));
if (accuracy > 0) {
parameters.add(new Parameter("accuracy", accuracy));
}
} else {
String woeId = getWoeId();
if (woeId != null) {
parameters.add(new Parameter("woe_id", woeId));
}
}
String safeSearch = getSafeSearch();
if (safeSearch != null) {
parameters.add(new Parameter("safe_search", safeSearch));
}
if (extrasLicense || extrasDateUpload ||
extrasDateTaken || extrasOwnerName ||
extrasIconServer || extrasOriginalFormat ||
extrasLastUpdate || extrasGeo ||
extrasTags || extrasMachineTags) {
Vector argsList = new Vector();
if (extrasLicense) argsList.add("license");
if (extrasDateUpload) argsList.add("date_upload");
if (extrasDateTaken) argsList.add("date_taken");
if (extrasOwnerName) argsList.add("owner_name");
if (extrasIconServer) argsList.add("icon_server");
if (extrasOriginalFormat) argsList.add("original_format");
if (extrasLastUpdate) argsList.add("last_update");
if (extrasGeo) argsList.add("geo");
if (extrasTags) argsList.add("tags");
if (extrasMachineTags) argsList.add("machine_tags");
parameters.add(new Parameter("extras", StringUtilities.join(argsList,",")));
}
if (sort != DATE_POSTED_DESC) {
String sortArg = null;
if(sort == DATE_POSTED_ASC) sortArg = "date-posted-asc";
if(sort == DATE_TAKEN_DESC) sortArg = "date-taken-desc";
if(sort == DATE_TAKEN_ASC) sortArg = "date-taken-asc";
if(sort == INTERESTINGNESS_DESC) sortArg = "interestingness-desc";
if(sort == INTERESTINGNESS_ASC) sortArg = "interestingness-asc";
if(sort == RELEVANCE) sortArg = "relevance";
if(sortArg != null) parameters.add(new Parameter("sort", sortArg));
}
return parameters;
}