Coverage Report - org.codeforamerica.open311.internals.parsing.DataParser
 
Classes in this File Line Coverage Branch Coverage Complexity
DataParser
N/A
N/A
1
 
 1  
 package org.codeforamerica.open311.internals.parsing;
 2  
 
 3  
 import java.util.List;
 4  
 
 5  
 import org.codeforamerica.open311.facade.data.POSTServiceRequestResponse;
 6  
 import org.codeforamerica.open311.facade.data.Service;
 7  
 import org.codeforamerica.open311.facade.data.ServiceDefinition;
 8  
 import org.codeforamerica.open311.facade.data.ServiceDiscoveryInfo;
 9  
 import org.codeforamerica.open311.facade.data.ServiceRequest;
 10  
 import org.codeforamerica.open311.facade.data.ServiceRequestIdResponse;
 11  
 import org.codeforamerica.open311.facade.exceptions.DataParsingException;
 12  
 import org.codeforamerica.open311.facade.exceptions.GeoReportV2Error;
 13  
 
 14  
 /**
 15  
  * Specifies required operations to the parsers.
 16  
  * 
 17  
  * @author Santiago MunĂ­n <santimunin@gmail.com>
 18  
  * 
 19  
  */
 20  
 public interface DataParser {
 21  
         public static final String TEXT_FORMAT = "utf-8";
 22  
         public static final String SERVICE_TAG = "service";
 23  
         public static final String SERVICE_CODE_TAG = "service_code";
 24  
         public static final String SERVICE_NAME_TAG = "service_name";
 25  
         public static final String DESCRIPTION_TAG = "description";
 26  
         public static final String METADATA_TAG = "metadata";
 27  
         public static final String TYPE_TAG = "type";
 28  
         public static final String KEYWORDS_TAG = "keywords";
 29  
         public static final String KEYWORDS_SEPARATOR = ",";
 30  
         public static final String SERVICE_GROUP_TAG = "group";
 31  
         public static final String SERVICE_DEFINITION_TAG = "service_definition";
 32  
         public static final String ATTRIBUTE_TAG = "attribute";
 33  
         public static final String ATTRIBUTES_TAG = "attributes";
 34  
         public static final String VARIABLE_TAG = "variable";
 35  
         public static final String CODE_TAG = "code";
 36  
         public static final String DATATYPE_TAG = "datatype";
 37  
         public static final String REQUIRED_TAG = "required";
 38  
         public static final String DATATYPE_DESCRIPTION_TAG = "datatype_description";
 39  
         public static final String ORDER_TAG = "order";
 40  
         public static final String VALUE_TAG = "value";
 41  
         public static final String VALUES_TAG = "values";
 42  
         public static final String KEY_TAG = "key";
 43  
         public static final String NAME_TAG = "name";
 44  
         public static final String SERVICE_REQUEST_TAG = "request";
 45  
         public static final String SERVICE_REQUESTS_TAG = "service_requests";
 46  
         public static final String TOKEN_TAG = "token";
 47  
         public static final String SERVICE_REQUEST_ID_TAG = "service_request_id";
 48  
         public static final String STATUS_TAG = "status";
 49  
         public static final String STATUS_NOTES_TAG = "status_notes";
 50  
         public static final String AGENCY_RESPONSIBLE_TAG = "agency_responsible";
 51  
         public static final String SERVICE_NOTICE_TAG = "service_notice";
 52  
         public static final String REQUESTED_DATETIME_TAG = "requested_datetime";
 53  
         public static final String UPDATED_DATETIME_TAG = "updated_datetime";
 54  
         public static final String EXPECTED_DATETIME_TAG = "expected_datetime";
 55  
         public static final String ADDRESS_TAG = "address";
 56  
         public static final String ADDRESS_ID_TAG = "address_id";
 57  
         public static final String ZIPCODE_TAG = "zipcode";
 58  
         public static final String LATITUDE_TAG = "lat";
 59  
         public static final String LONGITUDE_TAG = "long";
 60  
         public static final String MEDIA_URL_TAG = "media_url";
 61  
         public static final String ACCOUNT_ID_TAG = "account_id";
 62  
         public static final String ERROR_TAG = "error";
 63  
         public static final String DISCOVERY_TAG = "discovery";
 64  
         public static final String CHANGESET_TAG = "changeset";
 65  
         public static final String CONTACT_TAG = "contact";
 66  
         public static final String KEY_SERVICE_TAG = "key_service";
 67  
         public static final String SPECIFICATION_TAG = "specification";
 68  
         public static final String URL_TAG = "url";
 69  
         public static final String FORMAT_TAG = "format";
 70  
         public static final String ENDPOINT_TAG = "endpoint";
 71  
         public static final String START_DATE_TAG = "start_date";
 72  
         public static final String END_DATE_TAG = "end_date";
 73  
         public static final String EMAIL_TAG = "email";
 74  
         public static final String DEVICE_ID_TAG = "device_id";
 75  
         public static final String FIRST_NAME_TAG = "first_name";
 76  
         public static final String LAST_NAME_TAG = "last_name";
 77  
         public static final String PHONE_TAG = "phone";
 78  
 
 79  
         /**
 80  
          * Parses the response to the GET service list operation.
 81  
          * 
 82  
          * @param rawData
 83  
          *            Text data.
 84  
          * @return A list of {@link Service} objects.
 85  
          */
 86  
         public List<Service> parseServiceList(String rawData)
 87  
                         throws DataParsingException;
 88  
 
 89  
         /**
 90  
          * Parses a service definition.
 91  
          * 
 92  
          * @param rawData
 93  
          *            Text data.
 94  
          * @throws DataParsingException
 95  
          *             If there was any problem parsing the data.
 96  
          * 
 97  
          * @return A service definition object.
 98  
          */
 99  
         public ServiceDefinition parseServiceDefinition(String rawData)
 100  
                         throws DataParsingException;
 101  
 
 102  
         /**
 103  
          * Parses the response to the GET service request id from a token.
 104  
          * 
 105  
          * @param rawData
 106  
          *            Text data.
 107  
          * @return the given token and the service request id.
 108  
          * @throws DataParsingException
 109  
          *             If there was any problem parsing the data.
 110  
          */
 111  
         public ServiceRequestIdResponse parseServiceRequestIdFromAToken(
 112  
                         String rawData) throws DataParsingException;
 113  
 
 114  
         /**
 115  
          * Parses a list of service requests.
 116  
          * 
 117  
          * @param rawData
 118  
          *            Text data.
 119  
          * @return A list of ServiceRequest objects.
 120  
          * @throws DataParsingException
 121  
          *             If there was any problem parsing the data.
 122  
          */
 123  
         public List<ServiceRequest> parseServiceRequests(String rawData)
 124  
                         throws DataParsingException;
 125  
 
 126  
         /**
 127  
          * Parses the response of a POST Service Request operation.
 128  
          * 
 129  
          * @param rawData
 130  
          *            Text data.
 131  
          * @return an object containing the response information.
 132  
          * @throws DataParsingException
 133  
          *             If there was any problem parsing the data.
 134  
          */
 135  
         public POSTServiceRequestResponse parsePostServiceRequestResponse(
 136  
                         String rawData) throws DataParsingException;
 137  
 
 138  
         /**
 139  
          * Parses an error and returns an object with its information.
 140  
          * 
 141  
          * @param rawData
 142  
          *            Text data.
 143  
          * @return Error information.
 144  
          * @throws DataParsingException
 145  
          *             If there was any problem parsing the data.
 146  
          */
 147  
         public GeoReportV2Error parseGeoReportV2Errors(String rawData)
 148  
                         throws DataParsingException;
 149  
 
 150  
         /**
 151  
          * Parses a service discovery and returns an object with its information.
 152  
          * 
 153  
          * @param rawData
 154  
          *            Text data.
 155  
          * @return Service discovery information (endpoints and their formats).
 156  
          * @throws DataParsingException
 157  
          *             If there was any problem parsing the data.
 158  
          */
 159  
         public ServiceDiscoveryInfo parseServiceDiscovery(String rawData)
 160  
                         throws DataParsingException;
 161  
 }