コード例 #1
0
ファイル: JournalZPU.java プロジェクト: baywind/rujel
 protected static NSArray prepareJournalZPU(
     Enumeration substitutes, Enumeration variations, SchoolSection section) {
   NSMutableArray result = new NSMutableArray();
   NSMutableSet lessons = new NSMutableSet();
   if (variations != null) {
     while (variations.hasMoreElements()) {
       Variation var = (Variation) variations.nextElement();
       if (section != null && !section.equals(var.valueForKeyPath("course.cycle.section")))
         continue;
       EduLesson lesson = var.relatedLesson();
       if (lesson != null) {
         if (lessons.containsObject(lesson)) continue;
         lessons.addObject(lesson);
       }
       NSMutableDictionary dict = convertEvent(var);
       NSArray multiply = (NSArray) dict.valueForKey("multiply");
       if (multiply != null) {
         Enumeration mul = multiply.objectEnumerator();
         while (mul.hasMoreElements()) {
           Substitute sub = (Substitute) mul.nextElement();
           NSMutableDictionary clon = dict.mutableClone();
           clon.takeValueForKey(sub.teacher(), "plusTeacher");
           clon.takeValueForKey(sub.value(), "value");
           result.addObject(clon);
         }
       } else {
         result.addObject(dict);
       }
     }
   }
   if (substitutes != null) {
     while (substitutes.hasMoreElements()) {
       Substitute sub = (Substitute) substitutes.nextElement();
       EduLesson lesson = sub.lesson();
       if (lessons.containsObject(lesson)) continue;
       if (section != null && !section.equals(lesson.valueForKeyPath("course.cycle.section")))
         continue;
       //				lessons.addObject(sub.lesson());
       NSMutableDictionary dict = convertEvent(sub);
       result.addObject(dict);
     }
   }
   NSArray sorter =
       new NSArray(
           new EOSortOrdering[] {
             new EOSortOrdering("date", EOSortOrdering.CompareAscending),
             new EOSortOrdering("minusTeacher", EOSortOrdering.CompareAscending),
             new EOSortOrdering("grade", EOSortOrdering.CompareAscending),
             new EOSortOrdering("eduGroup", EOSortOrdering.CompareAscending),
             new EOSortOrdering("plusTeacher", EOSortOrdering.CompareAscending)
           });
   EOSortOrdering.sortArrayUsingKeyOrderArray(result, sorter);
   return result;
 }
コード例 #2
0
ファイル: EOFSQLUtils53.java プロジェクト: koamac/wolips
 public static Object toWOCollections(Object obj) {
   Object result;
   if (obj instanceof Map) {
     NSMutableDictionary nsDict = new NSMutableDictionary();
     Map map = (Map) obj;
     Iterator entriesIter = map.entrySet().iterator();
     while (entriesIter.hasNext()) {
       Map.Entry entry = (Map.Entry) entriesIter.next();
       Object key = entry.getKey();
       Object value = entry.getValue();
       if (key != null && value != null) {
         key = toWOCollections(key);
         value = toWOCollections(value);
         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;
     NSMutableSet nsSet = new NSMutableSet();
     Iterator valuesEnum = set.iterator();
     while (valuesEnum.hasNext()) {
       Object value = valuesEnum.next();
       if (value != null) {
         value = toWOCollections(value);
         nsSet.addObject(value);
       }
     }
     result = nsSet;
   } else {
     result = obj;
   }
   return result;
 }
コード例 #3
0
 /**
  * Like EOQualifier.filteredArrayWithQualifier but for an NSSet.
  *
  * @param <T> type of set contents
  * @param set the set to filter
  * @param qualifier the qualifier to apply
  * @return the filtered set
  */
 public static <T> NSSet<T> filteredSetWithQualifier(NSSet<T> set, EOQualifier qualifier) {
   if (set == null) {
     return NSSet.EmptySet;
   }
   if (qualifier == null || qualifier._isEmpty()) {
     return set;
   }
   int count = set.count();
   NSMutableSet<T> filteredSet = new NSMutableSet<>(count);
   Enumeration setEnum = set.objectEnumerator();
   while (setEnum.hasMoreElements()) {
     Object object = setEnum.nextElement();
     if (qualifier.evaluateWithObject(object)) {
       filteredSet.addObject((T) object);
     }
   }
   return filteredSet;
 }
コード例 #4
0
 /**
  * Returns a deep clone of the given set. A deep clone will attempt to clone the values of this
  * set as well as the set itself.
  *
  * @param <T> class of set elements
  * @param set the set to clone
  * @param onlyCollections if true, only collections in this array will be cloned, not individual
  *     values
  * @return a deep clone of set
  */
 public static <T> NSSet<T> deepClone(NSSet<T> set, boolean onlyCollections) {
   if (set == null) {
     return null;
   }
   NSMutableSet<T> clonedSet = set.mutableClone();
   for (T value : set) {
     T clonedValue = ERXUtilities.deepClone(value, onlyCollections);
     if (clonedValue != null) {
       if (clonedValue != value) {
         clonedSet.remove(value);
         clonedSet.add(clonedValue);
       }
     } else {
       clonedSet.remove(value);
     }
   }
   return clonedSet;
 }
コード例 #5
0
 public NSArray allTests() {
   if (allTests == null) {
     String thisBundleName = NSBundle.bundleForClass(getClass()).name();
     NSMutableSet theClassNames = new NSMutableSet();
     Enumeration bundleEnum = bundles().objectEnumerator();
     while (bundleEnum.hasMoreElements()) {
       NSBundle bundle = (NSBundle) bundleEnum.nextElement();
       if (!bundle.name().equals(thisBundleName)) {
         Enumeration classNameEnum = bundle.bundleClassNames().objectEnumerator();
         while (classNameEnum.hasMoreElements()) {
           String className = (String) classNameEnum.nextElement();
           if (className != null
               && (className.endsWith("Test")
                   || className.endsWith("TestCase")
                   || className.indexOf("tests.") == 0
                   || className.indexOf(".tests.") > 0)
               && !className.startsWith("junit.")
               && className.indexOf("$") < 0) {
             try {
               Class c = ERXPatcher.classForName(className);
               // if(c != null && c.isAssignableFrom(TestCase.class))
               theClassNames.addObject(munge(className));
             } catch (Exception ex) {
               // ignored
               log.warn("Skipping test " + className + ": " + ex);
             }
           }
         }
       }
     }
     allTests = theClassNames.allObjects();
     try {
       allTests = allTests.sortedArrayUsingComparator(NSComparator.AscendingStringComparator);
     } catch (Exception ex) {
       log.warn(ex);
       // so we won't get sorted, oh well :)
     }
   }
   return allTests;
 }
コード例 #6
0
ファイル: ERXRetainer.java プロジェクト: hypeastrum/wonder
  /**
   * <span class="en"> Retains a reference to the object.
   *
   * @param object object to be retained. </span>
   *     <p><span class="ja"> オブジェクトへのリファレンスを保持する為に追加します
   * @param object - 保持するオブジェクト </span>
   */
  public static void retain(Object object) {
    synchronized (_retainerSet) {
      /*if (object instanceof EOEnterpriseObject) {
      	EOEnterpriseObject eo = (EOEnterpriseObject) object;
      	if (ec == null) {
      		ec = ERXEC.newEditingContext();

      	}
      	ec.lock();
      	try {
      		object = ERXEOControlUtilities.localInstanceOfObject(ec, eo);
      	finally {
      		ec.unlock();
      	}

      }*/
      _retainerSet.addObject(object);
    }
  }
コード例 #7
0
 /**
  * Like EOQualifier.filterArrayWithQualifier but for an NSMutableSet.
  *
  * @param <T> type of set contents
  * @param set the set to filter in-place
  * @param qualifier the qualifier to apply
  */
 public static <T> void filterSetWithQualifier(NSMutableSet<T> set, EOQualifier qualifier) {
   set.setSet(ERXSetUtilities.filteredSetWithQualifier(set, qualifier));
 }
コード例 #8
0
ファイル: ERXRetainer.java プロジェクト: hypeastrum/wonder
 /**
  * <span class="en"> Tests if the given object is being retained by the ERXRetainer class.
  *
  * @param object object to be tested.
  * @return returns if the given object is currently retained. </span>
  *     <p><span class="ja"> このクラスで保持されているかどうかをテストします
  * @param object - テストするオブジェクト
  * @return オブジェクトが保持されていれば true を戻します </span>
  */
 @SuppressWarnings("javadoc")
 public static boolean isObjectRetained(Object object) {
   synchronized (_retainerSet) {
     return _retainerSet.containsObject(object);
   }
 }
コード例 #9
0
ファイル: ERXRetainer.java プロジェクト: hypeastrum/wonder
 /**
  * <span class="en"> Releases the reference to the object.
  *
  * @param object object to be released. </span>
  *     <p><span class="ja"> オブジェクトへのリファレンスの取り除きます
  * @param object - 取り除くオブジェクト </span>
  */
 public static void release(Object object) {
   synchronized (_retainerSet) {
     _retainerSet.removeObject(object);
   }
 }