コード例 #1
0
 /**
  * Remove nominative information from the Proposal record
  *
  * @param pointOfView Identify the anonymization point of view
  * @param proposals Array of entities to purge
  * @return List of cleaned up Proposal instances
  */
 public static JsonArray anonymizeProposals(QueryPointOfView pointOfView, JsonArray proposals) {
   int idx = proposals.size();
   while (0 < idx) {
     --idx;
     anonymizeProposal(pointOfView, proposals.getJsonObject(idx));
   }
   return proposals;
 }
コード例 #2
0
  public static List<Proposal> getProposals(
      PersistenceManager pm,
      JsonObject parameters,
      Long ownerKey,
      QueryPointOfView pointOfView,
      Long saleAssociateKey)
      throws ReservedOperationException, InvalidIdentifierException, DataSourceException {

    Map<String, Object> queryParameters = prepareQueryForSelection(parameters);
    int maximumResults =
        parameters.containsKey(BaseRestlet.MAXIMUM_RESULTS_PARAMETER_KEY)
            ? (int) parameters.getLong(BaseRestlet.MAXIMUM_RESULTS_PARAMETER_KEY)
            : 0;

    List<Proposal> output = null;

    if (QueryPointOfView.CONSUMER.equals(pointOfView)) {
      queryParameters.put(Proposal.CONSUMER_KEY, ownerKey);

      boolean withKeySet = parameters.containsKey(Entity.KEY);
      if (withKeySet) {
        JsonArray intialKeys = parameters.getJsonArray(Entity.KEY);
        List<Long> convertedKeys = new ArrayList<Long>();
        int limit = intialKeys.size();
        for (int idx = 0; idx < limit; idx++) {
          convertedKeys.add(Long.valueOf(intialKeys.getString(idx)));
        }
        output = getProposalOperations().getProposals(pm, convertedKeys);
      } else {
        output = getProposalOperations().getProposals(pm, queryParameters, maximumResults);
      }
    } else if (QueryPointOfView.SALE_ASSOCIATE.equals(pointOfView)) {
      if (saleAssociateKey == null) {
        throw new ReservedOperationException(Action.list, Proposal.class.getName());
      }
      queryParameters.put(Proposal.OWNER_KEY, saleAssociateKey);

      output = getProposalOperations().getProposals(pm, queryParameters, maximumResults);
    } else { // if (QueryPointOfView.anonymous.equals(pointOfView)) {
      List<Location> locations = LocationSteps.getLocations(pm, parameters, true);

      output = getProposalOperations().getProposals(pm, queryParameters, locations, maximumResults);
    }

    return output;
  }