Exemplo n.º 1
0
  public static void main(final String[] args) {
    final String pathToCSV = args[0];
    final String activityType = args[1];
    final String pathToOutputFacilities = args[2];

    final boolean publicFacilities = true;

    final ActivityFacilitiesFactoryImpl factory = new ActivityFacilitiesFactoryImpl();
    final ActivityFacilities facilities = FacilitiesUtils.createActivityFacilities();
    int idNumber = 0;

    CSVReader reader = new CSVReader(pathToCSV);
    reader.skipLine(); // skip header
    String[] newLine = reader.readLine(); // first line
    while (newLine != null) {

      // EMPFTE;METER_X;METER_Y;NOGA_CD_2008_6;KATEGORIE;NOGA_TAG;CAPACITY;OPEN_FROM;OPEN_TO;METER_X_GERUNDET;METER_Y_GERUNDET
      double xCoord = Double.parseDouble(newLine[1]);
      double yCoord = Double.parseDouble(newLine[2]);
      String desc = newLine[4] + " (" + newLine[5] + ")";
      double capacity = Double.parseDouble(newLine[6]);
      double openFrom = Double.parseDouble(newLine[7]);
      double openTill = Double.parseDouble(newLine[8]);

      // new facility
      ActivityFacilityImpl newFacility =
          (ActivityFacilityImpl)
              factory.createActivityFacility(
                  Id.create(String.format("%06d", ++idNumber), ActivityFacility.class),
                  new Coord(xCoord, yCoord));
      if (!publicFacilities) {
        newFacility.setDesc(desc);
      }
      // new activity
      ActivityOption newActivity = factory.createActivityOption(activityType);
      newActivity.setCapacity(capacity);
      newActivity.addOpeningTime(new OpeningTimeImpl(openFrom, openTill));
      newFacility.addActivityOption(newActivity);
      // add new facility and activity
      facilities.addActivityFacility(newFacility);

      newLine = reader.readLine(); // next line
    }

    // Write facilities
    FacilitiesWriter facilitiesWriter = new FacilitiesWriter(facilities);
    facilitiesWriter.write(pathToOutputFacilities);
    testFacilities(pathToOutputFacilities);
  }
Exemplo n.º 2
0
 public final ActivityOptionImpl createAndAddActivityOption(final String type) {
   String type2 = type.intern();
   ActivityOptionImpl a = new ActivityOptionImpl(type2);
   addActivityOption(a);
   return a;
 }