Example #1
0
  /**
   * Update the indexes for this object. This stage tracks the following data:
   *
   * <ul>
   *   <li>Processing date (today)
   *   <li>PatientID
   *   <li>StudyInstanceUID
   *   <li>SeriesInstanceUID
   *   <li>SOPInstanceUID
   * </ul>
   *
   * It creates table entries for the values in this object. IDs which are not unique may be
   * overwritten by subsequent objects (e.g. duplicates). Thus, the tables contain only records of
   * unique objects that have been processed.
   *
   * @param fileObject the object to process.
   * @return the same FileObject if the result is true; otherwise null.
   */
  public FileObject process(FileObject fileObject) {

    lastFileIn = new File(fileObject.getFile().getAbsolutePath());
    lastTimeIn = System.currentTimeMillis();

    try {
      if (fileObject instanceof DicomObject) {
        DicomObject dob = (DicomObject) fileObject;

        String date = StringUtil.getDate("");
        String patientID = dob.getPatientID();
        String studyInstanceUID = dob.getStudyInstanceUID();
        String seriesInstanceUID = dob.getSeriesInstanceUID();
        String sopInstanceUID = dob.getSOPInstanceUID();

        index(dateIndex, date, patientID);
        index(patientIndex, patientID, studyInstanceUID);
        index(studyIndex, studyInstanceUID, seriesInstanceUID);
        index(seriesIndex, seriesInstanceUID, sopInstanceUID);

        recman.commit();
      }
    } catch (Exception skip) {
      logger.debug("Unable to process " + fileObject.getFile());
    }

    lastFileOut = new File(fileObject.getFile().getAbsolutePath());
    lastTimeOut = System.currentTimeMillis();
    return fileObject;
  }
 /** Update the lookup table and the database. */
 public synchronized void update(Document doc) {
   LookupTable lut = LookupTable.getInstance(lutFile);
   Properties props = lut.getProperties();
   Element root = doc.getDocumentElement();
   boolean changed = false;
   Node child = root.getFirstChild();
   while (child != null) {
     if (child instanceof Element) {
       Element term = (Element) child;
       String key = term.getAttribute("key");
       String value = term.getAttribute("value");
       props.setProperty(key, value);
       try {
         index.remove(key);
       } catch (Exception ignore) {
       }
       changed = true;
     }
     child = child.getNextSibling();
   }
   if (changed) {
     try {
       recman.commit();
     } catch (Exception ignore) {
     }
     lut.save();
   }
 }
  /**
   * Check a DicomObject and record any failing lookups in the database.
   *
   * @param fileObject the object to process.
   * @return the same FileObject if the result is true; otherwise null.
   */
  public FileObject process(FileObject fileObject) {
    String cmd;

    lastFileIn = new File(fileObject.getFile().getAbsolutePath());
    lastTimeIn = System.currentTimeMillis();

    if (fileObject instanceof DicomObject) {
      DicomObject dob = (DicomObject) fileObject;
      if (dcmScriptFile != null) {
        DAScript daScript = DAScript.getInstance(dcmScriptFile);
        scriptTable = new ScriptTable(daScript);
        lutProps = LookupTable.getProperties(lutFile);
        synchronized (this) {
          Dataset ds = dob.getDataset();
          charset = ds.getSpecificCharacterSet();
          boolean ok = checkDataset(ds);
          if (!ok) {
            try {
              recman.commit();
            } catch (Exception unable) {
            }
            ;
            if (quarantine != null) quarantine.insert(fileObject);
            return null;
          }
        }
      }
    }
    lastFileOut = new File(fileObject.getFile().getAbsolutePath());
    lastTimeOut = System.currentTimeMillis();
    return fileObject;
  }
Example #4
0
 /** Stop the stage. */
 public void shutdown() {
   // Commit and close the database
   if (recman != null) {
     try {
       recman.commit();
       recman.close();
     } catch (Exception ex) {
       logger.warn("Unable to commit and close the database.");
     }
   }
   // Set stop so the isDown method will return the correct value.
   stop = true;
 }