Ejemplo n.º 1
0
 /**
  * Print Attributes to System.out
  *
  * @param attrs
  */
 private static void dump(Attributes attrs) {
   if (attrs == null) {
     System.out.println("No attributes");
   } else {
     /* Print each attribute */
     try {
       for (NamingEnumeration<? extends Attribute> ae = attrs.getAll(); ae.hasMore(); ) {
         Attribute attr = ae.next();
         System.out.println("attribute: " + attr.getID());
         /* print each value */
         for (NamingEnumeration<?> e = attr.getAll();
             e.hasMore();
             System.out.println("    value: " + e.next())) ;
       }
     } catch (NamingException e) {
       e.printStackTrace();
     }
   }
 } //	dump
Ejemplo n.º 2
0
  /** Parse Definition Attributes for a LDAP matching rule */
  static LDAPMatchingRuleSchema parseDefAttributes(Attributes attrs) throws NamingException {
    String name = null, oid = null, desc = null, syntax = null;
    boolean obsolete = false;
    Vector applies = new Vector();

    for (Enumeration attrEnum = attrs.getAll(); attrEnum.hasMoreElements(); ) {
      Attribute attr = (Attribute) attrEnum.nextElement();
      String attrName = attr.getID();
      if (attrName.equals(NAME)) {
        name = getSchemaAttrValue(attr);
      } else if (attrName.equals(NUMERICOID)) {
        oid = getSchemaAttrValue(attr);
      } else if (attrName.equals(SYNTAX)) {
        syntax = getSchemaAttrValue(attr);
      } else if (attrName.equals(DESC)) {
        desc = getSchemaAttrValue(attr);
      } else if (attrName.equals(APPLIES)) {
        for (Enumeration valEnum = attr.getAll(); valEnum.hasMoreElements(); ) {
          applies.addElement((String) valEnum.nextElement());
        }
      } else if (attrName.equals(OBSOLETE)) {
        obsolete = parseTrueFalseValue(attr);
      } else {
        throw new NamingException(
            "Invalid schema attribute type for matching rule definition " + attrName);
      }
    }

    LDAPMatchingRuleSchema mrule =
        new LDAPMatchingRuleSchema(name, oid, desc, vectorToStringAry(applies), syntax);

    if (obsolete) {
      mrule.setQualifier(OBSOLETE, "");
    }
    return mrule;
  }
Ejemplo n.º 3
0
  /**
   * Constructs an image information class based on the 5D image source, and the individual set of
   * pixels desired in that image. Needs Factory to query the database about statistics. (this might
   * not be a good thing)
   *
   * @param imageSource The image to store information about.
   * @param pixels The pixel source of the image.
   * @param dataSource The factory used to access the OME database. Is there a better way to do
   *     this?
   */
  public ImageInformation(Image imageSource, ImagePixels pixels, Factory dataSource) {
    this.imageSource = imageSource;
    this.pixels = pixels;
    this.pixelsAttribute = pixels.getPixelsAttribute();
    this.dataSource = dataSource;

    Map imageSourceMap = new HashMap();
    imageSourceMap.put("target", imageSource);

    // extract the channel/wavelength information for this image.
    List channelComponents = dataSource.findAttributes("PixelChannelComponent", imageSourceMap);

    final int pixelsID = pixelsAttribute.getID();

    // this taken straight out of the SVG viewer code
    // might be a faster/better/less OME-call-intensive way to do it
    channelComponents =
        Filter.grep(
            channelComponents,
            new GrepOperator() {
              public boolean eval(Object o) {
                Attribute attribute = (Attribute) o;
                Attribute pixels = attribute.getAttributeElement("Pixels");
                return pixels.getID() == pixelsID;
              }
            });

    channelInfo = new Wavelength[channelComponents.size()];
    for (int i = 0; i < channelComponents.size(); i++) {
      Attribute channel = (Attribute) channelComponents.get(i);
      channelInfo[i] = new Wavelength(channel.getIntElement("Index"));
    }

    CBS = ChannelBlackScaleData.getDefaultChannelScale(channelInfo);
    cbsMap = new HashMap();

    // hopefully this doesn't break right here

    // extract the proper stack statistics for this image,
    // this might be done the hard way (I dunno)

    Map moduleConstraints = new HashMap();
    moduleConstraints.put("name", "Fast Stack statistics");

    Module stackModule = (Module) dataSource.findObject("OME::Module", moduleConstraints);

    Map formalInputConstraints = new HashMap();
    formalInputConstraints.put("module_id", new Integer(stackModule.getID()));
    formalInputConstraints.put("name", "Pixels");

    Module.FormalInput formalInput =
        (Module.FormalInput)
            dataSource.findObject("OME::Module::FormalInput", formalInputConstraints);

    RemoteModuleExecution moduleExecution =
        (RemoteModuleExecution) pixelsAttribute.getModuleExecution();

    Map actualInputConstraints = new HashMap();
    actualInputConstraints.put("formal_input_id", new Integer(formalInput.getID()));
    actualInputConstraints.put("input_module_execution_id", new Integer(moduleExecution.getID()));

    ModuleExecution.ActualInput actualInput =
        (ModuleExecution.ActualInput)
            dataSource.findObject("OME::ModuleExecution::ActualInput", actualInputConstraints);

    final int stackAnalysisID = actualInput.getModuleExecution().getID();

    // retrieve statistics
    List stackMins = dataSource.findAttributes("StackMinimum", imageSourceMap);
    List stackMaxes = dataSource.findAttributes("StackMaximum", imageSourceMap);
    List stackMeans = dataSource.findAttributes("StackMean", imageSourceMap);
    List stackSigmas = dataSource.findAttributes("StackSigma", imageSourceMap);
    List stackGeomeans = dataSource.findAttributes("StackGeometricMean", imageSourceMap);
    List stackGeosigmas = dataSource.findAttributes("StackGeometricSigma", imageSourceMap);

    GrepOperator stackIDOperator =
        new GrepOperator() {
          public boolean eval(Object o) {
            Attribute attribute = (Attribute) o;
            RemoteModuleExecution execution =
                (RemoteModuleExecution) attribute.getModuleExecution();
            if (execution.getID() == stackAnalysisID) {
              return true;
            } else return false;
          }
        };

    List usableMins = Filter.grep(stackMins, stackIDOperator);
    List usableMaxes = Filter.grep(stackMaxes, stackIDOperator);
    List usableMeans = Filter.grep(stackMeans, stackIDOperator);
    List usableSigmas = Filter.grep(stackSigmas, stackIDOperator);
    List usableGeomeans = Filter.grep(stackGeomeans, stackIDOperator);
    List usableGeosigmas = Filter.grep(stackGeosigmas, stackIDOperator);

    sizeX = pixelsAttribute.getIntElement("SizeX");
    sizeY = pixelsAttribute.getIntElement("SizeY");
    sizeZ = pixelsAttribute.getIntElement("SizeZ");
    sizeC = pixelsAttribute.getIntElement("SizeC");
    sizeT = pixelsAttribute.getIntElement("SizeT");
    bitsPerPixel = pixelsAttribute.getIntElement("BitsPerPixel");

    stackStats = new StackStatistics[sizeC][sizeT];

    // initialize array
    for (int i = 0; i < sizeC; i++) {
      for (int j = 0; j < sizeT; j++) {
        stackStats[i][j] = new StackStatistics();
      }
    }

    // populate internal data structures
    for (Iterator iter = usableMins.iterator(); iter.hasNext(); ) {
      Attribute stackMin = (Attribute) iter.next();
      int theC = stackMin.getIntElement("TheC");
      int theT = stackMin.getIntElement("TheT");
      stackStats[theC][theT].setMin(stackMin.getIntElement("Minimum"));
    }

    for (Iterator iter = usableMaxes.iterator(); iter.hasNext(); ) {
      Attribute stackMax = (Attribute) iter.next();
      int theC = stackMax.getIntElement("TheC");
      int theT = stackMax.getIntElement("TheT");
      stackStats[theC][theT].setMax(stackMax.getIntElement("Maximum"));
    }

    for (Iterator iter = usableMeans.iterator(); iter.hasNext(); ) {
      Attribute stackMean = (Attribute) iter.next();
      int theC = stackMean.getIntElement("TheC");
      int theT = stackMean.getIntElement("TheT");
      stackStats[theC][theT].setMean(stackMean.getFloatElement("Mean"));
    }

    for (Iterator iter = usableSigmas.iterator(); iter.hasNext(); ) {
      Attribute stackSigma = (Attribute) iter.next();
      int theC = stackSigma.getIntElement("TheC");
      int theT = stackSigma.getIntElement("TheT");
      stackStats[theC][theT].setSigma(stackSigma.getFloatElement("Sigma"));
    }

    for (Iterator iter = usableGeomeans.iterator(); iter.hasNext(); ) {
      Attribute stackMean = (Attribute) iter.next();
      int theC = stackMean.getIntElement("TheC");
      int theT = stackMean.getIntElement("TheT");
      stackStats[theC][theT].setGeoMean(stackMean.getFloatElement("GeometricMean"));
    }

    for (Iterator iter = usableGeosigmas.iterator(); iter.hasNext(); ) {
      Attribute stackSigma = (Attribute) iter.next();
      int theC = stackSigma.getIntElement("TheC");
      int theT = stackSigma.getIntElement("TheT");
      stackStats[theC][theT].setGeoSigma(stackSigma.getFloatElement("GeometricSigma"));
    }
  }