Package com.webobjects.foundation

Examples of com.webobjects.foundation.NSMutableArray$ListItr


  public void executeSQL(String sql) throws SQLException {
    fixClassPath();
    EODatabaseContext databaseContext = new EODatabaseContext(new EODatabase(_model));
    EOAdaptorContext adaptorContext = databaseContext.adaptorContext();

    NSMutableArray beforeOpenChannels = new NSMutableArray();
    Enumeration beforeChannelsEnum = adaptorContext.channels().objectEnumerator();
    while (beforeChannelsEnum.hasMoreElements()) {
      EOAdaptorChannel channel = (EOAdaptorChannel) beforeChannelsEnum.nextElement();
      if (channel.isOpen()) {
        beforeOpenChannels.addObject(channel);
      }
    }
    try {
      EODatabaseChannel databaseChannel = databaseContext.availableChannel();
      EOAdaptorChannel adaptorChannel = databaseChannel.adaptorChannel();
      boolean channelOpen = adaptorChannel.isOpen();
      if (!channelOpen) {
        adaptorChannel.openChannel();
      }
      try {
        JDBCContext jdbccontext = (JDBCContext) adaptorChannel.adaptorContext();
        try {
          jdbccontext.beginTransaction();
          Connection conn = jdbccontext.connection();
          Statement stmt = conn.createStatement();
          stmt.executeUpdate(sql);
          conn.commit();
        } catch (SQLException sqlexception) {
          sqlexception.printStackTrace(System.out);
          jdbccontext.rollbackTransaction();
          throw sqlexception;
        }
      } finally {
        if (!channelOpen) {
          adaptorChannel.closeChannel();
        }
      }
    } finally {
      Enumeration afterChannelsEnum = adaptorContext.channels().objectEnumerator();
      while (afterChannelsEnum.hasMoreElements()) {
        EOAdaptorChannel channel = (EOAdaptorChannel) afterChannelsEnum.nextElement();
        if (channel.isOpen() && !beforeOpenChannels.containsObject(channel)) {
          channel.closeChannel();
        }
      }
    }
  }
View Full Code Here


          nsDict.setObjectForKey(value, key);
        }
      }
      result = nsDict;
    } else if (obj instanceof List) {
      NSMutableArray nsArray = new NSMutableArray();
      List list = (List) obj;
      Iterator valuesEnum = list.iterator();
      while (valuesEnum.hasNext()) {
        Object value = valuesEnum.next();
        if (value != null) {
          value = toWOCollections(value);
          nsArray.addObject(value);
        }
      }
      result = nsArray;
    } else if (obj instanceof Set) {
      Set set = (Set) obj;
View Full Code Here

      throw new IllegalArgumentException("Unknown list item ID array " + listItemIDArrayObj);
    }

    NSArray list = (NSArray) valueForBinding("list");
    boolean mutableList = (list instanceof NSMutableArray);
    NSMutableArray reorderedList;
    if (mutableList) {
      reorderedList = (NSMutableArray) list;
    }
    else {
      reorderedList = new NSMutableArray();
    }

    int startIndex = 0;
    // If we're starting at an index > 0, add the initial objects
    if (canGetValueForBinding("startIndex")) {
      Number startIndexNumber = (Number) valueForBinding("startIndex");
      startIndex = startIndexNumber.intValue();
      if (!mutableList) {
        for (int i = 0; i < startIndex; i++) {
          reorderedList.addObject(list.objectAtIndex(i));
        }
      }
    }

    // Add the reordered objects
    int listItemIDCount = listItemIDArray.count();
    for (int listItemIDIndex = 0; listItemIDIndex < listItemIDCount; listItemIDIndex++) {
      String itemID = (String) listItemIDArray.objectAtIndex(listItemIDIndex);
      NSRange itemPageRange;
      if (mutableList) {
        itemPageRange = new NSRange(startIndex + listItemIDIndex, listItemIDCount - listItemIDIndex);
      }
      else {
        itemPageRange = new NSRange(startIndex, listItemIDCount);
      }
      NSArray itemPageArray = list.subarrayWithRange(itemPageRange);
      EOQualifier itemIDQualifier = new EOKeyValueQualifier(listItemIDKeyPath, EOQualifier.QualifierOperatorEqual, itemID);
      NSArray matchingItems = EOQualifier.filteredArrayWithQualifier(itemPageArray, itemIDQualifier);
      if (matchingItems.count() == 0) {
        throw new NoSuchElementException("There was no item that matched the ID '" + itemID + "' in " + list + ".");
      }
      else if (matchingItems.count() > 1) {
        throw new IllegalStateException("There was more than one item that matched the ID '" + itemID + "' in " + list + ".");
      }
      Object replacingItem = matchingItems.objectAtIndex(0);
      if (mutableList) {
        int replacedItemIndex = itemPageRange.location();
        Object replacedItem = reorderedList.objectAtIndex(replacedItemIndex);
        if (replacedItem != replacingItem) {
          int replacingItemIndex = replacedItemIndex + itemPageArray.indexOfObject(replacingItem);
          reorderedList.replaceObjectAtIndex(replacingItem, replacedItemIndex);
          reorderedList.replaceObjectAtIndex(replacedItem, replacingItemIndex);
        }
      }
      else {
        reorderedList.addObject(replacingItem);
      }
    }

    // If we're just looking at a page, add all the objects AFTER the page
    if (!mutableList) {
      int listCount = list.count();
      for (int i = startIndex + reorderedList.count(); i < listCount; i++) {
        reorderedList.addObject(list.objectAtIndex(i));
      }
      setValueForBinding(reorderedList, "list");
    }

    if (canGetValueForBinding("action")) {
View Full Code Here

     *
     * @param component the component to evaluate the bindings in
     * @return the bindings in the form of an AjaxOptions dictionary
     */
    public NSDictionary createAjaxOptions(WOComponent component) {
        NSMutableArray ajaxOptionsArray = new NSMutableArray();
        ajaxOptionsArray.addObject(new AjaxOption("asynchronous", Boolean.TRUE, AjaxOption.BOOLEAN));
        ajaxOptionsArray.addObject(new AjaxOption("evalScripts", Boolean.FALSE, AjaxOption.BOOLEAN));
        ajaxOptionsArray.addObject(new AjaxOption("frequency", Integer.valueOf(60), AjaxOption.NUMBER));
        ajaxOptionsArray.addObject(new AjaxOption("method", "get", AjaxOption.STRING));
        ajaxOptionsArray.addObject(new AjaxOption("onFailure", "function(response) { window.close();}", AjaxOption.SCRIPT));
        ajaxOptionsArray.addObject(new AjaxOption("parameters", AjaxOption.STRING));
        NSMutableDictionary options = AjaxOption.createAjaxOptionsDictionary(ajaxOptionsArray, component, associations());
        return options;
    }
View Full Code Here

    super.appendToResponse(response, context);
  }

  public NSDictionary createAjaxOptions() {
    // PROTOTYPE OPTIONS
    NSMutableArray ajaxOptionsArray = new NSMutableArray();
    ajaxOptionsArray.addObject(new AjaxOption("accept", AjaxOption.STRING_ARRAY));
    ajaxOptionsArray.addObject(new AjaxOption("containment", AjaxOption.STRING_ARRAY));
    ajaxOptionsArray.addObject(new AjaxOption("hoverclass", AjaxOption.STRING));
    ajaxOptionsArray.addObject(new AjaxOption("overlap", AjaxOption.STRING));
    ajaxOptionsArray.addObject(new AjaxOption("greedy", AjaxOption.BOOLEAN));
    ajaxOptionsArray.addObject(new AjaxOption("onHover", AjaxOption.SCRIPT));
    ajaxOptionsArray.addObject(new AjaxOption("evalScripts", AjaxOption.BOOLEAN));
    NSMutableDictionary options = AjaxOption.createAjaxOptionsDictionary(ajaxOptionsArray, this);
  if (options.objectForKey("evalScripts") == null) {
    options.setObjectForKey("true", "evalScripts");
  }
    return options;
View Full Code Here

    /**
     * <span class="ja">データの選択範囲をセット </span>
     */
    public void setSelections(NSArray aFormValuesArray) {
        // ** This is where we accept the formValues.  Kind of weird.
        NSMutableArray aSelectionsArray = new NSMutableArray();
        if (aFormValuesArray != null) {
            Enumeration anIndexEnumerator = aFormValuesArray.objectEnumerator();
            NSArray anItemList = (NSArray)_WOJExtensionsUtil.valueForBindingOrNull("list",this);
            if (anItemList == null) {
                anItemList = NSArray.EmptyArray;
            }
            int anItemCount = anItemList.count();
            while (anIndexEnumerator.hasMoreElements()) {
                int i = Integer.parseInt((String)anIndexEnumerator.nextElement());
                if (i < anItemCount) {
                    Object anObject = anItemList.objectAtIndex(i);
                    aSelectionsArray.addObject(anObject);
                } else {
                    // ** serious problem here. Raise an exception?
                }
            }
        }
View Full Code Here

        return _sectionKey;
    }
   
    public NSArray sections() {
        if (_sections==null) {
            _sections= new NSMutableArray();
            NSArray list=(NSArray)valueForBinding("list");
            _itemsPerSection=new NSMutableDictionary();
            if (list!=null) {
                boolean ignoreNulls = booleanValueForBinding("ignoreNulls", false);
               
                for (Enumeration e=list.objectEnumerator(); e.hasMoreElements();) {
                    Object item=e.nextElement();
                    if(log.isDebugEnabled()) log.debug("item = "+item);
                   
                    // push value up, so parent can tell us the group
                    setValueForBinding(item,"item");
                   
                    // Sections have to be copiable objects -- no EOs!!
                    Object section=valueForBinding("sectionForItem");
                    if (section==NSKeyValueCoding.NullValue) section=null;
                    Object sectionKey;

                    if(section == null) {
                        if(ignoreNulls) {
                            continue;
                        }
                        section=NULL;
                    }
                    sectionKey = keyForSection(section);
                    if(sectionKey instanceof NSArray) {
                        NSArray array = (NSArray)sectionKey;
                        int index = 0;
                        for (Enumeration keys = ((NSArray)sectionKey).objectEnumerator(); keys.hasMoreElements(); ) {
                            Object currentKey = keys.nextElement();
                            Object currentSection = ((NSArray)section).objectAtIndex(index++);
                            NSMutableArray currentItemsForSection=(NSMutableArray)_itemsPerSection.objectForKey(currentKey);
                            if (currentItemsForSection==null) {
                                _sections.addObject(currentSection);
                                currentItemsForSection=new NSMutableArray();
                                _itemsPerSection.setObjectForKey(currentItemsForSection,currentKey);
                            }
                            currentItemsForSection.addObject(item);
                        }
                    } else {
                        NSMutableArray currentItemsForSection=(NSMutableArray)_itemsPerSection.objectForKey(sectionKey);
                        if (currentItemsForSection==null) {
                            _sections.addObject(section);
                            currentItemsForSection=new NSMutableArray();
                            _itemsPerSection.setObjectForKey(currentItemsForSection,sectionKey);
                        }
                        currentItemsForSection.addObject(item);
                    }
                }
            }
            String sortKey = (String)valueForBinding("sortKey");
            //the key act on the array, so it must be in the form "@sortAsc.someKey"
View Full Code Here

      if (selections() == null) return null;
      return selections().contains(item()) ? item() : null;
    }
   
    public void setSelection(Object value) {
       NSMutableArray selections = (selections() != null) ? selections().mutableClone() : new NSMutableArray();
      if (value != null) {
        selections.addObject(item());
      } else {
        selections.removeObject(item());
      }
      setValueForBinding(selections, Bindings.selections);
    }
View Full Code Here

        NSArray<EOEnterpriseObject> eos = (NSArray<EOEnterpriseObject>) dict.objectForKey(key);
        for (Enumeration enumeration = eos.objectEnumerator(); enumeration.hasMoreElements();) {
            EOEnterpriseObject eo = (EOEnterpriseObject) enumeration.nextElement();
            if(eo.entityName().equals(entityName())) {
              if (releventEOs == null) {
                releventEOs = new NSMutableArray();
              }
              releventEOs.addObject((T)eo);
            }
        }
        return releventEOs != null ? releventEOs : NSArray.EmptyArray;
View Full Code Here

     */
    public NSArray<T> allObjects(EOEditingContext ec, EOQualifier additionalQualifier) {
    additionalQualifier = ERXEOControlUtilities.localInstancesInQualifier(ec, additionalQualifier);
      ERXExpiringCache<Object, EORecord<T>> cache = cache();
      NSArray allKeys = cache.allKeys();
      NSMutableArray allObjects = new NSMutableArray(allKeys.count());

      for (Object entryKey : allKeys) {
        T object = objectForKey(ec, entryKey, false);
        if (object != null && (additionalQualifier == null || additionalQualifier.evaluateWithObject(object))) {
            allObjects.addObject(object);
        }
      }
      return allObjects;
    }
View Full Code Here

TOP

Related Classes of com.webobjects.foundation.NSMutableArray$ListItr

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.