@Override
    public <T extends DataField> IStructFieldSearchFilterItemEditor createEditorInstance(
        Collection<StructField<T>> structFields, MatchType matchType) {
      Collection<TextStructField> textStructFields = CollectionUtil.castCollection(structFields);

      return new TextStructFieldSearchFilterItemEditor(textStructFields, matchType);
    }
Esempio n. 2
0
  @Override
  protected List<Object> loadChildData(ProgressMonitor monitor) {
    try {
      OrderID orderID = (OrderID) JDOHelper.getObjectId(recurringOrder);
      RecurringOrder o =
          RecurringOrderDAO.sharedInstance()
              .getRecurringOrder(
                  orderID, FETCH_GROUPS_ORDER, NLJDOHelper.MAX_FETCH_DEPTH_NO_LIMIT, monitor);

      ArrayList<Offer> res = new ArrayList<Offer>(o.getOffers());

      Collections.sort(
          res,
          new Comparator<Offer>() {
            public int compare(Offer o0, Offer o1) {
              long id0 = o0.getOfferID();
              long id1 = o1.getOfferID();

              if (id0 == id1) return 0;

              if (id0 > id1) return 1;
              else return -1;
            }
          });

      return CollectionUtil.castList(res);
    } catch (Exception e) {
      throw new RuntimeException(e);
    }
  }
  /**
   * @return the collated Set of (non-repeated) fetch-group elements from all the {@link
   *     ColumnDescriptor}s within.
   */
  public String[] getAllColumnFetchGroups() {
    if (columnDescriptors == null) return null;

    Set<String> combinedFetchGroups = new HashSet<String>();
    for (ColumnDescriptor columnDescriptor : columnDescriptors)
      for (String fetchGroup : columnDescriptor.getFetchGroups())
        combinedFetchGroups.add(fetchGroup);

    String[] fetchGroups = CollectionUtil.collection2TypedArray(combinedFetchGroups, String.class);
    return fetchGroups;
  }
 /**
  * @ejb.interface-method
  * @ejb.permission role-name="_Guest_"
  */
 @RolesAllowed("_Guest_")
 public Set<CSVID> getCSVIDs() {
   final PersistenceManager pm = createPersistenceManager();
   try {
     final Query q = pm.newQuery(CSV.class);
     q.setResult("JDOHelper.getObjectId(this)");
     final Collection<CSVID> c = CollectionUtil.castCollection((Collection<?>) q.execute());
     return new HashSet<CSVID>(c);
   } finally {
     pm.close();
   }
 }
  public synchronized Collection<TariffPricePair> getTariffPricePairs(
      ProductTypeID productTypeID,
      CustomerGroupID customerGroupID,
      CurrencyID currencyID,
      ProgressMonitor monitor) {
    //		if (priceConfigID == null)
    //			throw new IllegalArgumentException("priceConfigID must not be null!");
    if (productTypeID == null)
      throw new IllegalArgumentException("productTypeID must not be null!");

    if (customerGroupID == null)
      throw new IllegalArgumentException("customerGroupID must not be null!");

    if (currencyID == null) throw new IllegalArgumentException("currencyID must not be null!");

    String key =
        productTypeID.toString() + "::" + customerGroupID.toString() + "::" + currencyID.toString();

    //		TariffPricePairsCarrier tppc = (TariffPricePairsCarrier) tariffPricePairsCarriers.get(key);

    TariffPricePairsCarrier tppc =
        (TariffPricePairsCarrier)
            cache.get(TariffPricePairDAO.class.getName(), key, (String[]) null, -1);
    if (tppc == null) { // || System.currentTimeMillis() - tppc.loadDT > EXPIRE_MSEC) {
      try {
        SimpleTradeManagerRemote stm = ejbProvider.getRemoteBean(SimpleTradeManagerRemote.class);
        Collection<TariffPricePair> tariffPricePairs =
            CollectionUtil.castCollection(
                stm.getTariffPricePairs(
                    productTypeID,
                    customerGroupID,
                    currencyID,
                    FETCH_GROUPS_TARIFF,
                    FETCH_GROUPS_PRICE));

        tppc =
            new TariffPricePairsCarrier(
                productTypeID, customerGroupID, currencyID, tariffPricePairs);
        //				tariffPricePairsCarriers.put(key, tppc);

        // TODO We have to somehow get notified when the appropriate TariffUserSet changes (and
        // evict the record from the cache). Needs some more thoughts. Marco.
        cache.put(TariffPricePairDAO.class.getName(), key, tppc, (String[]) null, -1);
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tppc.tariffPricePairs;
  }
Esempio n. 6
0
  protected void solveAutomaticPressed() {
    okPressed();
    Set<ArticleID> articleIDs = new HashSet<ArticleID>();

    if (getPaymentDatas() != null
        && (transferWizard.getTransferMode() & TransferWizard.TRANSFER_MODE_PAYMENT) > 0) {
      // add all ArticleIDs from all invoices of all payments
      Set<PayableObjectID> payableObjectIDs = new HashSet<PayableObjectID>();
      for (PaymentData pd : getPaymentDatas()) {
        payableObjectIDs.addAll(pd.getPayment().getPayableObjectIDs());
      }
      Set<InvoiceID> invoiceIDs = CollectionUtil.castSet(payableObjectIDs);
      List<Invoice> invoices =
          InvoiceDAO.sharedInstance()
              .getInvoices(
                  invoiceIDs,
                  new String[] {FetchPlan.DEFAULT, Invoice.FETCH_GROUP_ARTICLES},
                  NLJDOHelper.MAX_FETCH_DEPTH_NO_LIMIT,
                  new NullProgressMonitor());
      for (Invoice invoice : invoices) {
        Collection<? extends ArticleID> tmpArticleIDSet =
            NLJDOHelper.getObjectIDSet(invoice.getArticles());
        articleIDs.addAll(tmpArticleIDSet);
      }
    }
    if (getDeliveryDatas() != null
        && (transferWizard.getTransferMode() & TransferWizard.TRANSFER_MODE_DELIVERY) > 0) {
      // add all ArticleIDs from all deliveryNotes of all deliveries
      for (DeliveryData dd : getDeliveryDatas()) {
        articleIDs.addAll(dd.getDelivery().getArticleIDs());
      }
    }

    CombiTransferArticlesWizard wizard =
        new CombiTransferArticlesWizard(articleIDs, transferWizard.getTransferMode());
    wizard.setErrorHandler(new QuickSaleErrorHandler());
    DynamicPathWizardDialog dialog = new DynamicPathWizardDialog(wizard);
    dialog.open();
    this.transfersSuccessful = wizard.isTransfersSuccessful();
  }
  public List<State> getStates() {
    if (_states == null) _states = CollectionUtil.castList(Collections.unmodifiableList(states));

    return _states;
  }
 @Override
 public Set<TimePattern> _getTimePatterns() {
   return CollectionUtil.castSet(timePatterns);
 }
Esempio n. 9
0
 @SuppressWarnings("unchecked")
 public Map<String, T> getSubtrieElementsWithKeys(String[] path) {
   TrieNode<T> node = getNode(path);
   if (node == null) return Collections.EMPTY_MAP;
   else return traverseSubtrieWithKeys(node, CollectionUtil.array2ArrayList(path), null);
 }