Beispiel #1
0
    /**
     * Overriden to contruct a valid SQL92 JOIN clause as opposed to the Oracle-like SQL the
     * superclass produces.
     *
     * <p>kieran copied from PostgresqlExpression
     */
    @Override
    public String joinClauseString() {
      NSMutableDictionary<String, Boolean> seenIt = new NSMutableDictionary<String, Boolean>();
      StringBuilder sb = new StringBuilder();
      JoinClauseDefinition jc;
      EOSortOrdering.sortArrayUsingKeyOrderArray(
          _alreadyJoined,
          new NSArray<EOSortOrdering>(
              EOSortOrdering.sortOrderingWithKey("sortKey", EOSortOrdering.CompareAscending)));
      if (_alreadyJoined.count() > 0) {
        jc = _alreadyJoined.objectAtIndex(0);

        sb.append(jc);
        seenIt.setObjectForKey(Boolean.TRUE, jc._table1);
        seenIt.setObjectForKey(Boolean.TRUE, jc._table2);
      }

      for (int i = 1; i < _alreadyJoined.count(); i++) {
        jc = _alreadyJoined.objectAtIndex(i);

        sb.append(jc._op);
        if (seenIt.objectForKey(jc._table1) == null) {
          sb.append(jc._table1);
          seenIt.setObjectForKey(Boolean.TRUE, jc._table1);
        } else if (seenIt.objectForKey(jc._table2) == null) {
          sb.append(jc._table2);
          seenIt.setObjectForKey(Boolean.TRUE, jc._table2);
        }
        sb.append(jc._joinCondition);
      }
      return sb.toString();
    }
Beispiel #2
0
 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;
 }
Beispiel #3
0
 public void search() {
   try {
     found = Person.Utility.search(ec, entity(), searchString);
     if ((found == null || found.count() == 0) && alterEntity() != null)
       found = Person.Utility.search(ec, alterEntity(), searchString);
   } catch (Exception e) {
     searchMessage = e.getMessage();
     canCreate = false;
     return;
   }
   if (found.count() < 1) {
     searchMessage = (String) session().valueForKeyPath("strings.Strings.messages.nothingFound");
     canCreate = Various.boolForObject(session().valueForKeyPath("readAccess.create." + entity()));
     return;
   }
   NSMutableArray fullList = (NSMutableArray) session().valueForKey("personList");
   NSMutableArray tmp = found.mutableClone();
   tmp.removeObjectsInArray(fullList);
   fullList.addObjectsFromArray(tmp);
   if (fullList.count() > 1) EOSortOrdering.sortArrayUsingKeyOrderArray(fullList, Person.sorter);
   searchMessage = null;
 }