@Override
  public CustomerDTO read()
      throws Exception, UnexpectedInputException, ParseException, NonTransientResourceException {
    CustomerDTO customerDTO = null;

    // Boucle sur les lignes du fichier
    for (FieldSet ligne = delegate.read(); ligne != null; ligne = delegate.read()) {
      String prefix = ligne.readString(0);

      if (prefix.equals("BEGIN")) {
        customerDTO = new CustomerDTO();
      } else if (prefix.equals("NAME")) {
        Assert.notNull(customerDTO, "No 'BEGIN' was found.");
        customerDTO.setFirstName(ligne.readString(1));
        customerDTO.setLastName(ligne.readString(2));
      } else if (prefix.equals("AGE")) {
        Assert.notNull(customerDTO, "No 'BEGIN' was found.");
        customerDTO.setAge(ligne.readInt(1));
      } else if (prefix.equals("GENDER")) {
        Assert.notNull(customerDTO, "No 'BEGIN' was found.");
        customerDTO.setGender(ligne.readString(1));
      } else if (prefix.equals("END")) {
        return customerDTO;
      }
    }
    // Si BEGIN mais pas de END
    if (customerDTO != null) {
      Assert.notNull(customerDTO, "No 'END' was found.");
    }

    return null;
  }
Пример #2
0
 // TODO: set reader().setNames to correct order in csv. then update fields in this mapper class by
 // index
 @Override
 public Maintenance mapFieldSet(FieldSet fieldSet) throws BindException {
   // System.out.println("MARKER"+Arrays.asList(fieldSet.getValues()));
   // System.out.println("MARKER"+fieldSet.readString(10)+","+fieldSet.readString(11)+","+fieldSet.readString(12)+","+fieldSet.readString(13));
   // System.out.println("planned");
   Maintenance unplannedMaintenance = new Maintenance();
   unplannedMaintenance.setNominalId(fieldSet.readString("H3G_Nominal_ID"));
   try {
     unplannedMaintenance.setStartDate(
         dateFormat.parse(fieldSet.readString("Planned_Outage_Start_Time")));
     unplannedMaintenance.setFinishDate(
         dateFormat.parse(fieldSet.readString("Planned_Outage_End_Time")));
     unplannedMaintenance.setCreatedDate(new Date());
   } catch (ParseException pe) {
     // TODO:
   }
   // unplannedMaintenance.setDescription(fieldSet.readString("Description"));
   unplannedMaintenance.setNetwork(fieldSet.readString("Network_Type"));
   unplannedMaintenance.setMBNL_Site_ID(fieldSet.readString("MBNL_Site_ID"));
   unplannedMaintenance.setOutage("Planned");
   unplannedMaintenance.setStatus(
       "Completed".equals(fieldSet.readString("Status"))
           ? fieldSet.readString("Status")
           : "Closed");
   // unplannedMaintenance.setService(fieldSet.readString("Products_List")); //Products_List
   unplannedMaintenance.setReference(fieldSet.readString("CMID"));
   return unplannedMaintenance;
 }
  @Override
  public Employee mapFieldSet(FieldSet fieldSet) throws BindException {
    Employee employee = new Employee();
    employee.setAge(fieldSet.readInt("age"));
    employee.setName(fieldSet.readString("name"));

    return employee;
  }
  @Override
  public Player mapFieldSet(FieldSet fs) {

    if (fs == null) {
      return null;
    }

    Player player = new Player();
    player.setId(fs.readString("ID"));
    player.setLastName(fs.readString("lastName"));
    player.setFirstName(fs.readString("firstName"));
    player.setPosition(fs.readString("position"));
    player.setDebutYear(fs.readInt("debutYear"));
    player.setBirthYear(fs.readInt("birthYear"));

    return player;
  }
Пример #5
0
 public Geoname mapFieldSet(FieldSet fieldSet) throws BindException {
   if (fieldSet == null) return null;
   Geoname geoname = new Geoname();
   geoname.setGeonameId(fieldSet.readInt(0));
   geoname.setName(fieldSet.readString(1));
   geoname.setAsciiname(fieldSet.readString(2));
   geoname.setAlternatenames(fieldSet.readString(3));
   geoname.setLatitude(fieldSet.readDouble(4));
   geoname.setLongitude(fieldSet.readDouble(5));
   geoname.setFeatureClass(fieldSet.readString(6));
   geoname.setFeatureCode(fieldSet.readString(7));
   geoname.setCountryCode(fieldSet.readString(8));
   geoname.setCC2(fieldSet.readString(9));
   geoname.setAdmin1Code(fieldSet.readString(10));
   geoname.setAdmin2Code(fieldSet.readString(11));
   geoname.setAdmin3Code(fieldSet.readString(12));
   geoname.setAdmin4Code(fieldSet.readString(13));
   geoname.setPopulation(fieldSet.readInt(14));
   geoname.setElevation(fieldSet.readInt(15, 0));
   geoname.setDem(fieldSet.readInt(16));
   geoname.setTimezone(fieldSet.readString(17));
   geoname.setModificationDate(fieldSet.readDate(18));
   return geoname;
 }