Esempio n. 1
0
  private void updateRecord(DataRecord r, ArrayList<String> fieldsInInport) {
    try {
      DataRecord rorig =
          (versionized ? dataAccess.getValidAt(r.getKey(), validAt) : dataAccess.get(r.getKey()));
      if (rorig == null) {
        logImportFailed(
            r, International.getString("Keine gültige Version des Datensatzes gefunden."), null);
        return;
      }

      // has the import record an InvalidFrom field?
      long invalidFrom = (versionized ? getInvalidFrom(r) : -1);
      if (invalidFrom <= rorig.getValidFrom()) {
        invalidFrom = -1;
      }
      boolean changed = false;

      for (int i = 0; i < fields.length; i++) {
        Object o = r.get(fields[i]);
        if ((o != null || fieldsInInport.contains(fields[i]))
            && !r.isKeyField(fields[i])
            && !fields[i].equals(DataRecord.LASTMODIFIED)
            && !fields[i].equals(DataRecord.VALIDFROM)
            && !fields[i].equals(DataRecord.INVALIDFROM)
            && !fields[i].equals(DataRecord.INVISIBLE)
            && !fields[i].equals(DataRecord.DELETED)) {
          Object obefore = rorig.get(fields[i]);
          rorig.set(fields[i], o);
          if ((o != null && !o.equals(obefore)) || (o == null && obefore != null)) {
            changed = true;
          }
        }
      }

      if (invalidFrom <= 0) {
        long myValidAt = getValidFrom(r);
        if (!versionized
            || updMode.equals(UPDMODE_UPDATEVALIDVERSION)
            || rorig.getValidFrom() == myValidAt) {
          if (changed) {
            dataAccess.update(rorig);
          }
          setCurrentWorkDone(++importCount);
        }
        if (versionized
            && updMode.equals(UPPMODE_CREATENEWVERSION)
            && rorig.getValidFrom() != myValidAt) {
          if (changed) {
            dataAccess.addValidAt(rorig, myValidAt);
          }
          setCurrentWorkDone(++importCount);
        }
      } else {
        dataAccess.changeValidity(rorig, rorig.getValidFrom(), invalidFrom);
        setCurrentWorkDone(++importCount);
      }
    } catch (Exception e) {
      logImportFailed(r, e.toString(), e);
    }
  }
Esempio n. 2
0
 private void addRecord(DataRecord r) {
   try {
     if (versionized) {
       long myValidAt = getValidFrom(r);
       dataAccess.addValidAt(r, myValidAt);
       setCurrentWorkDone(++importCount);
     } else {
       dataAccess.add(r);
       setCurrentWorkDone(++importCount);
     }
   } catch (Exception e) {
     logImportFailed(r, e.toString(), e);
   }
 }