| 1 | |
package org.codeforamerica.open311.facade.data.operations; |
| 2 | |
|
| 3 | |
import java.io.Serializable; |
| 4 | |
import java.util.Date; |
| 5 | |
import java.util.HashMap; |
| 6 | |
import java.util.Map; |
| 7 | |
|
| 8 | |
import org.codeforamerica.open311.facade.APIWrapper; |
| 9 | |
import org.codeforamerica.open311.facade.data.ServiceRequest.Status; |
| 10 | |
import org.codeforamerica.open311.internals.parsing.DataParser; |
| 11 | |
import org.codeforamerica.open311.internals.parsing.DateParser; |
| 12 | |
|
| 13 | |
|
| 14 | |
|
| 15 | |
|
| 16 | |
|
| 17 | |
|
| 18 | |
|
| 19 | |
|
| 20 | |
|
| 21 | |
|
| 22 | 5 | public class GETServiceRequestsFilter implements Serializable { |
| 23 | |
|
| 24 | |
private static final long serialVersionUID = 3037178220547056225L; |
| 25 | 5 | private Map<String, String> parameters = new HashMap<String, String>(); |
| 26 | |
|
| 27 | |
|
| 28 | |
|
| 29 | |
|
| 30 | |
|
| 31 | |
|
| 32 | |
|
| 33 | |
|
| 34 | |
|
| 35 | |
public GETServiceRequestsFilter setServiceRequestId(String serviceRequestId) { |
| 36 | 2 | if (serviceRequestId != null && serviceRequestId.length() > 0) { |
| 37 | 0 | parameters.put(DataParser.SERVICE_REQUEST_ID_TAG, serviceRequestId); |
| 38 | |
} |
| 39 | 2 | return this; |
| 40 | |
} |
| 41 | |
|
| 42 | |
public GETServiceRequestsFilter setServiceCode(String serviceCode) { |
| 43 | 5 | if (serviceCode != null && serviceCode.length() > 0) { |
| 44 | 3 | parameters.put(DataParser.SERVICE_CODE_TAG, serviceCode); |
| 45 | |
} |
| 46 | 5 | return this; |
| 47 | |
} |
| 48 | |
|
| 49 | |
public GETServiceRequestsFilter setStartDate(Date startDate) { |
| 50 | 1 | if (startDate != null) { |
| 51 | 0 | parameters.put(DataParser.START_DATE_TAG, |
| 52 | |
new DateParser().printDate(startDate)); |
| 53 | |
} |
| 54 | 1 | return this; |
| 55 | |
} |
| 56 | |
|
| 57 | |
public GETServiceRequestsFilter setEndDate(Date endDate) { |
| 58 | 1 | if (endDate != null) { |
| 59 | 0 | parameters.put(DataParser.END_DATE_TAG, |
| 60 | |
new DateParser().printDate(endDate)); |
| 61 | |
} |
| 62 | 1 | return this; |
| 63 | |
} |
| 64 | |
|
| 65 | |
public GETServiceRequestsFilter setStatus(Status status) { |
| 66 | 2 | if (status != null) { |
| 67 | 1 | parameters.put(DataParser.STATUS_TAG, status.toString()); |
| 68 | |
} |
| 69 | 2 | return this; |
| 70 | |
} |
| 71 | |
|
| 72 | |
|
| 73 | |
|
| 74 | |
|
| 75 | |
|
| 76 | |
|
| 77 | |
public Map<String, String> getOptionalParametersMap() { |
| 78 | 6 | Map<String, String> result = new HashMap<String, String>(); |
| 79 | 6 | result.putAll(parameters); |
| 80 | 6 | return result; |
| 81 | |
} |
| 82 | |
} |