Example #1
0
  private void splitJourneyLocation(
      ConcurrentMap<String, IRI> variableTypes,
      List<LDObject> journeyLocation,
      List<LDObject> journeyDatas,
      BindingSet bindings) {
    LDObject locationsData = new LDObject();
    LDObject journeyData = new LDObject();

    bindings
        .getBindingNames()
        .stream()
        .forEach(
            bindingName -> {
              org.openrdf.model.Value value = bindings.getBinding(bindingName).getValue();
              QueryResultsParser.updateVariableTypes(variableTypes, bindingName, value);

              if (Arrays.asList("id", "creationDate", "name", "status").contains(bindingName)) {
                journeyData.addKeyValue(new KeyValue(bindingName, value.stringValue()));
              } else {
                locationsData.addKeyValue(new KeyValue(bindingName, value.stringValue()));
              }

              if ("locationId".equalsIgnoreCase(bindingName)) {
                journeyData.addKeyValue(new KeyValue(bindingName, value.stringValue()));
              }
            });

    journeyLocation.add(locationsData);
    journeyDatas.add(journeyData);
  }
Example #2
0
  private void mapJourneyLocation(
      List<LDObject> journeyLocations, List<JourneyData> finalR, LDObject journey) {
    JourneyData s = new JourneyData();
    s.setJourneyData(journey);
    List<LDObject> filteredLocations =
        journeyLocations
            .stream()
            .parallel()
            .filter(
                loc -> {
                  try {
                    return journey
                        .getMap()
                        .get("locationId")
                        .getValues()
                        .contains(loc.getMap().get("locationId").getSingleValue());
                  } catch (Exception e) {
                    e.printStackTrace();
                    return false;
                  }
                })
            .collect(Collectors.toList());

    s.setLocations(filteredLocations);
    s.removeMappingProperty("locationId");
    finalR.add(s);
  }