public Collection ejbFindByComplex(Integer complexID) throws FinderException {
   Table category = new Table(this, "c");
   Table type = new Table(ApartmentType.class, "t");
   Table apartment = new Table(Apartment.class, "a");
   Table floor = new Table(Floor.class, "f");
   Table building = new Table(Building.class, "b");
   SelectQuery query = new SelectQuery(category);
   query.setAsDistinct(true);
   query.addColumn(new WildCardColumn(category));
   try {
     query.addJoin(type, category);
     query.addJoin(apartment, type);
     query.addJoin(apartment, floor);
     query.addJoin(floor, building);
   } catch (IDORelationshipException e) {
     throw new FinderException(e.getMessage());
   }
   query.addCriteria(
       new MatchCriteria(
           new Column(building, BuildingBMPBean.BU_COMPLEX_ID),
           MatchCriteria.EQUALS,
           complexID.intValue()));
   query.addOrder(category, this.getIDColumnName(), true);
   return idoFindPKsBySQL(query.toString());
 }
 @Override
 public Collection<ICFile> getAllAttachments() {
   try {
     return super.idoGetRelatedEntities(ICFile.class);
   } catch (IDORelationshipException e) {
     e.printStackTrace();
   }
   return null;
 }
 @Override
 public Collection<User> getReadBy() {
   try {
     return super.idoGetRelatedEntities(User.class);
   } catch (IDORelationshipException e) {
     e.printStackTrace();
   }
   return null;
 }
  public PresentationObject getCatalog(
      ProductCatalog productCatalog, IWContext iwc, List productCategories)
      throws RemoteException, FinderException {
    this.localeID = iwc.getCurrentLocaleId();
    this.locale = iwc.getCurrentLocale();
    this.defaultLocale = iwc.getIWMainApplication().getSettings().getDefaultLocale();
    this.defaultLocaleID = ICLocaleBusiness.getLocaleId(this.defaultLocale);

    Table table = new Table();
    table.setWidth("100%");
    table.setCellspacing(1);
    table.setCellpadding(2);

    Collection products = productCatalog.getProducts(productCategories);
    Iterator iter = products.iterator();
    Iterator catIter = productCategories.iterator();

    int row = 1;
    int column = 1;
    int imageColumn = 1;

    Hashtable metaDataTypes = new Hashtable();

    table.add(
        productCatalog.getHeader(
            productCatalog.iwrb.getLocalizedString("product.product", "Product")),
        column++,
        row);
    List metadataKeys = new Vector();
    String[] metadata = new String[10 + column];

    while (catIter.hasNext()) {
      ICCategory element = (ICCategory) catIter.next();
      metaDataTypes.putAll(
          getCategoryService(iwc).getInheritedMetaDataTypes(element.getMetaDataTypes(), element));
    }

    if (!metaDataTypes.isEmpty()) {
      Set set = metaDataTypes.keySet();
      Iterator setIter = set.iterator();
      while (setIter.hasNext()) {
        String key = setIter.next().toString();
        if (!metadataKeys.contains(key)) {
          metadataKeys.add(key);
          metadata[column] = key;
          table.add(
              productCatalog.getHeader(productCatalog.iwrb.getLocalizedString(METADATA + key, key)),
              column++,
              row);
        }
      }
    }
    imageColumn = column;
    table.add(
        productCatalog.getHeader(
            productCatalog.iwrb.getLocalizedString("product.images", "Images")),
        column++,
        row);
    table.setRowColor(row, productCatalog.getHeaderBackgroundColor());

    Product product;
    String key;
    String meta;
    Locale localeInUse;
    int localeIDinUse;
    while (iter.hasNext()) {
      ++row;
      product = (Product) iter.next();

      if (null == product.getProductName(this.localeID, null)) {
        localeInUse = this.defaultLocale;
        localeIDinUse = this.defaultLocaleID;
      } else {
        localeInUse = this.locale;
        localeIDinUse = this.localeID;
      }

      if (productCatalog.hasEditPermission()) {
        table.add(productCatalog.getProductEditorLink(product), 1, row);
      }
      table.add(
          productCatalog.getNamePresentationObject(
              product, product.getProductName(localeIDinUse), false),
          1,
          row);
      for (int i = 0; i < metadata.length; i++) {
        key = metadata[i];
        if (key != null) {
          meta = product.getMetaData(METADATA + key + "_" + localeInUse.toString());
          if (meta != null) {
            table.add(productCatalog.getText(meta), i, row);
          }
        }
      }

      // Collection coll = getEditorBusiness(iwc).getFiles(product);
      Collection coll;
      try {
        coll = product.getICFile();
        Iterator images = coll.iterator();
        Image image;
        int counter = 0;
        while (images.hasNext()) {
          ++counter;
          try {
            image =
                new Image(
                    new Integer(((ICFile) images.next()).getPrimaryKey().toString()).intValue());
            Window window = new Window(image);

            Link link = new Link(productCatalog.getText(Integer.toString(counter)));

            if (productCatalog._iconPhoto != null) {
              link = new Link(productCatalog._iconPhoto);
            }

            link.setWindow(window);

            table.add(link, imageColumn, row);
            table.add(productCatalog.getText(Text.NON_BREAKING_SPACE), imageColumn, row);
          } catch (Exception e) {
            e.printStackTrace(System.err);
          }
        }
      } catch (IDORelationshipException e1) {
        e1.printStackTrace();
      }

      table.setRowColor(row, productCatalog.getBackgroundColor());
    }

    return table;
  }