예제 #1
0
파일: ERXTcpIp.java 프로젝트: hmng/wonder
  /**
   * <div class="ja"> マシンで設定されているIPリストを取得します。 環境設定については: A10Properties. InIpRangeOperatorを参照
   *
   * @return IP 配列が戻ります </div>
   */
  public static NSArray<String> machineIpList() {

    // この関数は WOApplication がインスタンス化される前に実行されるので、ログ出力は標準ではない
    if (ERXArrayUtilities.arrayIsNullOrEmpty(_machineIpList)) {
      // プロパティー内でどの IP を使用するかどうかを読込みます。
      String machineIp =
          ERXProperties.stringFor2Keys(
              "er.erxtensions.ERXTcpIp.UseThisIp", "wodka.a10.A10TcpIp.UseThisIp");

      try {
        // プロパティーがなければ、自動設定を行う
        if (ERXStringUtilities.stringIsNullOrEmpty(machineIp)) {
          log.debug("MachineIp Automatic Mode");

          // マシンIPを得る
          if (ERXArrayUtilities.arrayIsNullOrEmpty(_machineIpList))
            _machineIpList = _machineIpList();

          // 処理不能 ??
          if (ERXArrayUtilities.arrayIsNullOrEmpty(_machineIpList)) {
            String noIpAndNoNetwork =
                ERXProperties.stringFor2Keys(
                    "er.erxtensions.ERXTcpIp.NoIpAndNoNetwork",
                    "wodka.a10.A10TcpIp.NoIpAndNoNetwork");

            // No IP と No ネットワークも設定されていなければ、ローカル IP を使用する
            if (ERXStringUtilities.stringIsNullOrEmpty(noIpAndNoNetwork))
              noIpAndNoNetwork = LOCAL_IP_ADDRESS;

            // 使用する IP をセットします
            _machineIpList = new NSArray<String>(new String[] {noIpAndNoNetwork});

            log.warn("No IpAddress --- no network! use Address : {}", noIpAndNoNetwork);
          }
        } else {
          // 使用する IP をセットします
          _machineIpList = new NSArray<String>(new String[] {machineIp});
        }
      } catch (Exception e) {
        // ここでの処理失敗は致命的
        log.error("getIpAddress error!!!");

        _machineIpList = new NSArray<String>(new String[] {LOCAL_IP_ADDRESS});
      }

      if (log.isInfoEnabled())
        log.info("MachineIp {} is in use.", ERXArrayUtilities.arrayToLogstring(_machineIpList));
    }

    return _machineIpList;
  }
예제 #2
0
 /** @return the lesCapacites */
 public NSArray lesCapacites() {
   if (lesCapacites == null) {
     NSMutableArray<EOCapacite> tmp = new NSMutableArray<EOCapacite>();
     NSMutableArray<EOCapacite> tmp2 = new NSMutableArray<EOCapacite>();
     NSArray<EODomaine> domaines = null;
     NSArray<EORepartDomCapacite> rdcs = null;
     domaines = EODomaine.fetchDomaines(ec, wocomponent().mySession().TODAY);
     if (!wocomponent().droitTout()) domaines = filtreDomaine(domaines).immutableClone();
     domaines =
         ERXArrayUtilities.arrayWithoutDuplicateKeyValue(
             domaines, EODomaine.REPART_DOM_CAPACITES_KEY);
     rdcs =
         (NSArray<EORepartDomCapacite>) domaines.valueForKey(EODomaine.REPART_DOM_CAPACITES_KEY);
     rdcs =
         ERXArrayUtilities.arrayWithoutDuplicateKeyValue(rdcs, EORepartDomCapacite.CAPACITE_KEY);
     if (rdcs != null && rdcs.count() > 0 && verifCap(rdcs)) {
       NSArray tt = (NSArray<EOCapacite>) rdcs.valueForKey(EORepartDomCapacite.CAPACITE_KEY);
       for (int t = 0; t < tt.count(); t++) {
         Object obj = (NSMutableArray) tt.objectAtIndex(t);
         // Correction bug plusieur objet dans un objet
         if (((NSMutableArray) obj).count() > 1) {
           for (Object ob : (NSMutableArray) obj) {
             EOCapacite cp = (EOCapacite) ob;
             if (cp != null) tmp2.addObject(cp);
           }
         } else {
           EOCapacite cp = (EOCapacite) ((NSMutableArray) obj).lastObject();
           if (cp != null) tmp2.addObject(cp);
         }
       }
       NSArray tmp3 = tmp2.immutableClone();
       tmp.addObjectsFromArray(tmp3);
     } else {
       tmp.addObjectsFromArray(EOCapacite.fetchCapacites(ec, wocomponent().mySession().TODAY));
     }
     EOCapacite capacite = selectedCapacite();
     if (capacite != null && !tmp.contains(capacite)) {
       tmp.addObject(capacite);
     }
     if (tmp != null && tmp.count() > 0) {
       ERXArrayUtilities.sortArrayWithKey(tmp, EOCapacite.LBL_COURT_KEY);
       lesCapacites = ERXArrayUtilities.arrayWithoutDuplicates(tmp);
     }
   }
   return lesCapacites;
 }
예제 #3
0
 @Override
 @SuppressWarnings("unchecked")
 public boolean evaluateWithObject(Object object) {
   boolean result = false;
   if (object != null && object instanceof NSKeyValueCoding) {
     Object obj = ((NSKeyValueCoding) object).valueForKey(key());
     if (obj == null && object instanceof NSKeyValueCodingAdditions) {
       obj = ((NSKeyValueCodingAdditions) object).valueForKeyPath(key());
     }
     if (obj instanceof NSArray) {
       NSArray objArray = (NSArray) obj;
       if (!objArray.isEmpty()) {
         if (_minCount == 0) {
           result = ERXArrayUtilities.arrayContainsArray(objArray, elements());
         } else {
           result =
               ERXArrayUtilities.intersectingElements(objArray, elements()).count() >= _minCount;
         }
       }
     }
   }
   return result;
 }
  // ----------------------------------------------------------
  protected void beforeAppendToResponse(WOResponse response, WOContext context) {
    log.debug("appendToResponse()");

    subStats = new HashMap<AssignmentOffering, Submission.CumulativeStats>();
    offerings.setObjectArray(assignmentOfferings(courseOfferings()));
    if (log.isDebugEnabled()) {
      log.debug("assignment offerings:");
      for (AssignmentOffering ao : offerings.allObjects()) {
        log.debug("\t" + ao);
      }
    }

    NSMutableArray<Submission> staffSubs = new NSMutableArray<Submission>();
    NSArray<User> admins = User.administrators(localContext());

    for (AssignmentOffering ao : offerings.displayedObjects()) {
      // Stuff the index variable into the public key so the group/stats
      // methods will work for us
      assignmentOffering = ao;
      NSArray<UserSubmissionPair> subs =
          Submission.submissionsForGrading(
              localContext(),
              ao,
              true, // omitPartners
              omitStaff,
              studentStats());
      userGroup().setObjectArray(subs);

      @SuppressWarnings("unchecked")
      NSArray<User> staff =
          ERXArrayUtilities.arrayByAddingObjectsFromArrayWithoutDuplicates(
              ao.courseOffering().staff(), admins);
      staffSubs.addAll(
          extractSubmissions(
              Submission.submissionsForGrading(
                  localContext(),
                  ao,
                  true, // omitPartners
                  staff,
                  null)));
    }

    staffSubmissionGroup.setObjectArray(staffSubs);

    selectedUserSubmissionForPickerDialog = null;
    allUserSubmissionsForNavigationForPickerDialog = null;

    super.beforeAppendToResponse(response, context);
  }
 /**
  * Returns the enterprise objects fetched with decoded <code>formValues</code> from <code>
  * entityName</code>.
  *
  * @param ec the editing context to fetch the objects from
  * @param entityName the entity to fetch the objects from
  * @param formValues dictionary where the values are an encoded representation of the primary key
  *     values in either cleartext or encrypted format.
  * @return the enterprise objects
  */
 public static NSArray enterpriseObjectsForEntityNamedFromFormValues(
     EOEditingContext ec, String entityName, NSDictionary formValues) {
   NSArray formValueObjects = decodeEnterpriseObjectsFromFormValues(ec, formValues);
   NSDictionary groups = ERXArrayUtilities.arrayGroupedByKeyPath(formValueObjects, "entityName");
   EOEntity entity = ERXEOAccessUtilities.entityNamed(ec, entityName);
   NSMutableArray entityGroup = new NSMutableArray();
   if (entity != null && entity.isAbstractEntity()) {
     for (Enumeration e = ERXUtilities.allSubEntitiesForEntity(entity, false).objectEnumerator();
         e.hasMoreElements(); ) {
       EOEntity subEntity = (EOEntity) e.nextElement();
       NSArray aGroup = (NSArray) groups.objectForKey(subEntity.name());
       if (aGroup != null) entityGroup.addObjectsFromArray(aGroup);
     }
   } else {
     entityGroup.addObjectsFromArray((NSArray) groups.objectForKey(entityName));
   }
   return entityGroup != null ? entityGroup : NSArray.EmptyArray;
 }
예제 #6
0
  /**
   * Overridden to handle case of in-memory evaluation of QualifierOperatorContains selector and a
   * keyPath that has multiple toMany and/or manyToMany-flattened relationships resulting in arrays
   * of arrays rather than an array of discrete objects. In that case the object is evaluated
   * against a flattened array which gives the same result as SQL evaluation.
   *
   * <p>Since legacy code may depend on workarounds to the incorrect behavior, this patch can be
   * disabled by setting the property <code>er.extensions.ERXKeyValueQualifier.Contains.flatten
   * </code> to <code>false</code>
   */
  @Override
  public boolean evaluateWithObject(Object object) {
    Object objectValue = NSKeyValueCodingAdditions.Utility.valueForKeyPath(object, _key);

    if (_value instanceof EOQualifierVariable) {
      throw new IllegalStateException(
          "Error evaluating qualifier with key "
              + _key
              + ", selector "
              + _selector
              + ", value "
              + _value
              + " - value must be substitued for variable before evaluating");
    }

    if (_selector.equals(EOQualifier.QualifierOperatorCaseInsensitiveLike)) {
      if (_lowercaseCache == null) {
        _lowercaseCache =
            (_value != NSKeyValueCoding.NullValue) ? (_value.toString()).toLowerCase() : "";
      }
      return _NSStringUtilities.stringMatchesPattern(
          ((objectValue != null) && (objectValue != NSKeyValueCoding.NullValue))
              ? objectValue.toString()
              : "",
          _lowercaseCache,
          true);
    }

    // Flatten in case we have array of arrays
    if (_selector.equals(EOQualifier.QualifierOperatorContains)
        && PROPERTIES.shouldFlattenValueObject
        && objectValue != null
        && objectValue instanceof NSArray) {
      objectValue = ERXArrayUtilities.flatten((NSArray<?>) objectValue);
    }
    return ComparisonSupport.compareValues(
        (objectValue != null) ? objectValue : NSKeyValueCoding.NullValue, _value, _selector);
  }
 // DELETEME?: grouping objects is not this class' responsibility...
 public static NSDictionary groupedEnterpriseObjectsFromFormValues(
     EOEditingContext ec, NSDictionary formValues) {
   NSArray formValueObjects = decodeEnterpriseObjectsFromFormValues(ec, formValues);
   return ERXArrayUtilities.arrayGroupedByKeyPath(formValueObjects, "entityName");
 }