Пример #1
0
  /**
   * Don't modify this. Don't try to understand what this function does. It works, leave it as is.
   * If something breaks, verify query params (locationId, id, creationDate, etc) Increment hour
   * counter spent here : 5
   */
  @Override
  public ServiceResponse<JourneyResult> getJourneys(String userId) {
    String finalUserId = transformDbId(userId, appNamespace);
    String getUserJourneysQuery = getUsersJourney.replaceAll(":id:", finalUserId);

    ConcurrentMap<String, IRI> variableTypes = new ConcurrentHashMap<>();

    List<LDObject> journeyLocation = new ArrayList<>();
    List<LDObject> journeyData = new ArrayList<>();

    List<BindingSet> bindingSets = service.query(getUserJourneysQuery);

    bindingSets
        .stream()
        .forEach(
            bindings ->
                splitJourneyLocation(variableTypes, journeyLocation, journeyData, bindings));

    // add this to the other journey stuff
    List<LDObject> journeyLocations = mergeLocations(journeyLocation);
    List<LDObject> journeys = mergeJourneys(journeyData);

    List<JourneyData> finalR = new ArrayList<>();
    journeys
        .stream()
        .parallel()
        .forEach(journey -> mapJourneyLocation(journeyLocations, finalR, journey));

    ContextCreator creator = new ContextCreator();
    JourneyResult journeyResult = new JourneyResult();
    journeyResult.setContext(creator.create(getUserJourneysQuery, variableTypes));
    journeyResult.setItems(finalR);

    ServiceResponse<JourneyResult> serviceResponse = new ServiceResponse<>();
    serviceResponse.setStatus(ServiceResponse.Status.SUCCESS);
    serviceResponse.setResult(journeyResult);

    return serviceResponse;
  }
Пример #2
0
 private boolean userExists(String userId) {
   String checkIfUSerExists = getUserById.replace(":id:", transformDbId(userId, appNamespace));
   return !service.query(checkIfUSerExists).isEmpty();
 }
Пример #3
0
 private boolean userExists(RegisterModel model) {
   String checkIfUSerExists = getUserByName.replace(":name:", model.getUsername());
   return !service.query(checkIfUSerExists).isEmpty();
 }