Example #1
0
 private String getScriptXML(File file) {
   if (file.exists() && file.isFile()) {
     DAScript dascript = DAScript.getInstance(file);
     return dascript.toXMLString();
   }
   return "<script/>";
 }
  /**
   * 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;
  }
 public ScriptTable(DAScript script) {
   super();
   Document scriptXML = script.toXML();
   Element scriptRoot = scriptXML.getDocumentElement();
   Node child = scriptRoot.getFirstChild();
   while (child != null) {
     if ((child instanceof Element) && child.getNodeName().equals("e")) {
       Element eChild = (Element) child;
       if (eChild.getAttribute("en").equals("T")) {
         int tag = StringUtil.getHexInt(eChild.getAttribute("t"));
         String command = eChild.getTextContent();
         Matcher processMatcher = processPattern.matcher(command);
         Matcher lookupMatcher = lookupPattern.matcher(command);
         Integer tagInteger = new Integer(tag);
         if (processMatcher.find() || lookupMatcher.find()) {
           this.put(tagInteger, command);
         }
       }
     }
     child = child.getNextSibling();
   }
 }