Exemplo n.º 1
0
  /**
   * This method is used to execute the core logic for a service.
   *
   * @param apiName contains the name of the api.
   * @param db contains a open database session.
   * @param serviceCoreReturn contains the person identifier value.
   * @param updatedBy contains the userid requesting this information.
   * @param otherParameters contains a Map of Java objects that are additional parameters for the
   *     service.
   * @return will return an object if successful.
   * @throws CprException will be thrown if there are any problems.
   * @throws JSONException will be thrown if there are any issues creating a JSON message.
   * @throws ParseException will be thrown if there are any issues related to parsing a data value.
   * @throws JMSException will be thown if there are any JMS issues.
   */
  @Override
  public Object runApi(
      final String apiName,
      final Database db,
      final ServiceCoreReturn serviceCoreReturn,
      final String updatedBy,
      final Map<String, Object> otherParameters,
      final boolean checkAuthorization)
      throws CprException, JSONException, ParseException, JMSException {

    final String nameType = (String) otherParameters.get(NAME_TYPE_KEY);
    final String returnHistory = (String) otherParameters.get(RETURN_HISTORY_KEY);
    final String nameKey = (String) otherParameters.get(NAME_KEY);
    final long personId = serviceCoreReturn.getPersonId();

    final NamesTable namesTable =
        ValidateName.validateGetNameParameters(
            db, personId, updatedBy, nameType, returnHistory, nameKey);

    final NameReturn[] queryResults = namesTable.getNamesForPersonId(db, personId);

    // Build the return class.
    return new NamesServiceReturn(
        ReturnType.SUCCESS.index(), ApiHelper.SUCCESS_MESSAGE, queryResults, queryResults.length);
  }
Exemplo n.º 2
0
  /**
   * This method is used to execute the core logic for a service.
   *
   * @param apiName contains the name of the api.
   * @param db contains a open database session.
   * @param serviceCoreReturn contains the person identifier value.
   * @param updatedBy contains the userid requesting this information.
   * @param otherParameters contains an map of Java objects that are additional parameters for the
   *     service.
   * @return will return an JsonMessage object if successful.
   * @throws CprException will be thrown if there are any problems.
   * @throws JSONException will be thrown if there are any issues creating a JSON message.
   * @throws ParseException will be thrown if there are any issues related to parsing a data value.
   */
  @Override
  public JsonMessage runApi(
      final String apiName,
      final Database db,
      final ServiceCoreReturn serviceCoreReturn,
      final String updatedBy,
      final Map<String, Object> otherParameters,
      final boolean checkAuthorization)
      throws CprException, JSONException, ParseException {
    final byte[] photo = (byte[]) otherParameters.get(PHOTO_KEY);
    final String photoDateTaken = (String) otherParameters.get(PHOTO_DATE_TAKEN_KEY);

    // Validate the service parameters.
    final PersonPhotoTable personPhotoTable =
        ValidatePersonPhoto.validateAddPhotoParameters(
            db, serviceCoreReturn.getPersonId(), photo, photoDateTaken, updatedBy);

    // Add the photo to the database table.
    personPhotoTable.addPhoto(db);

    return null;
  }