boolean checkValidUntil() {
   validFrom.getValueFromGui();
   validUntil.getValueFromGui();
   if (!validUntil.isValidInput()) {
     if (!_inCancel) {
       Dialog.error(validUntil.getDescription() + ":\n" + validUntil.getLastInvalidError());
       validUntil.requestFocus();
     }
     return false;
   }
   return true;
 }
Ejemplo n.º 2
0
 public int runXmlImport() {
   DataImportXmlParser responseHandler = null;
   try {
     XMLReader parser = EfaUtil.getXMLReader();
     responseHandler = new DataImportXmlParser(this, dataAccess);
     parser.setContentHandler(responseHandler);
     parser.parse(new InputSource(new FileInputStream(filename)));
   } catch (Exception e) {
     logInfo(e.toString());
     errorCount++;
     Logger.log(e);
     if (Daten.isGuiAppl()) {
       Dialog.error(e.toString());
     }
   }
   return (responseHandler != null ? responseHandler.getImportedRecordsCount() : 0);
 }
Ejemplo n.º 3
0
 public int runCsvImport() {
   int count = 0;
   try {
     int linecnt = 0;
     String[] header = null;
     ArrayList<String> fieldsInImport = new ArrayList<String>();
     BufferedReader f =
         new BufferedReader(new InputStreamReader(new FileInputStream(filename), encoding));
     String s;
     DataRecord dummyRecord = storageObject.createNewRecord();
     while ((s = f.readLine()) != null) {
       s = s.trim();
       if (s.length() == 0) {
         continue;
       }
       Vector<String> fields = splitFields(s);
       if (fields.size() > 0) {
         if (linecnt == 0) {
           // header
           header = new String[fields.size()];
           for (int i = 0; i < fields.size(); i++) {
             header[i] = fields.get(i);
             if (header[i].startsWith("#") && header[i].endsWith("#") && header.length > 2) {
               header[i] = header[i].substring(1, header[i].length() - 1).trim();
               overrideKeyField = header[i];
             }
             String[] equivFields = dummyRecord.getEquivalentFields(header[i]);
             for (String ef : equivFields) {
               fieldsInImport.add(ef);
             }
           }
         } else {
           // fields
           DataRecord r = storageObject.createNewRecord();
           for (int i = 0; i < header.length; i++) {
             String value = (fields.size() > i ? fields.get(i) : null);
             if (value != null && value.length() > 0) {
               try {
                 if (!r.setFromText(header[i], value.trim())) {
                   logImportWarning(
                       r,
                       "Value '"
                           + value
                           + "' for Field '"
                           + header[i]
                           + "' corrected to '"
                           + r.getAsText(header[i])
                           + "'");
                 }
               } catch (Exception esetvalue) {
                 logImportWarning(
                     r,
                     "Cannot set value '"
                         + value
                         + "' for Field '"
                         + header[i]
                         + "': "
                         + esetvalue.toString());
               }
             }
           }
           if (importRecord(r, fieldsInImport)) {
             count++;
           }
         }
       }
       linecnt++;
     }
     f.close();
   } catch (Exception e) {
     logInfo(e.toString());
     errorCount++;
     Logger.log(e);
     if (Daten.isGuiAppl()) {
       Dialog.error(e.toString());
     }
   }
   return count;
 }