/**
   * 保存指定状态的原始订单至数据库
   *
   * @param originalOrderList
   */
  public void saveOriginalOrders(List<OriginalOrder> originalOrderList) {

    if (CollectionUtils.isEmpty(originalOrderList)) {
      return;
    }

    for (OriginalOrder originalOrder : originalOrderList) {

      if (!(StringUtils.equalsIgnoreCase(
              originalOrder.getStatus(), OriginalOrderStatus.WAIT_SELLER_SEND_GOODS.toString())
          || StringUtils.equalsIgnoreCase(
              originalOrder.getStatus(), OriginalOrderStatus.WAIT_BUYER_CONFIRM_GOODS.toString())
          || StringUtils.equalsIgnoreCase(
              originalOrder.getStatus(), OriginalOrderStatus.TRADE_FINISHED.toString()))) {
        continue;
      }
      // 保存原始订单
      saveOriginalOrder(originalOrder);
      for (OriginalOrderItem originalOrderItem : originalOrder.getOriginalOrderItemList()) {
        // 保存原始订单项
        originalOrderItem.setOriginalOrderId(originalOrder.getId());
        saveOriginalOrderItem(originalOrderItem);
      }
      for (PromotionInfo promotionInfo : originalOrder.getPromotionInfoList()) {
        // 保存订单优惠记录
        promotionInfo.setOriginalOrderId(originalOrder.getId());
        savePromotionInfo(promotionInfo);
      }
    }
  }
Beispiel #2
0
  /** 分析并设置contentType与headers. */
  private static HttpServletResponse initResponseHeader(
      final String contentType, final String... headers) {
    // 分析headers参数
    String encoding = DEFAULT_ENCODING;
    boolean noCache = DEFAULT_NOCACHE;
    for (String header : headers) {
      String headerName = StringUtils.substringBefore(header, ":");
      String headerValue = StringUtils.substringAfter(header, ":");

      if (StringUtils.equalsIgnoreCase(headerName, HEADER_ENCODING)) {
        encoding = headerValue;
      } else if (StringUtils.equalsIgnoreCase(headerName, HEADER_NOCACHE)) {
        noCache = Boolean.parseBoolean(headerValue);
      } else {
        throw new IllegalArgumentException(headerName + "不是一个合法的header类型");
      }
    }

    HttpServletResponse response = ServletActionContext.getResponse();

    // 设置headers参数
    String fullContentType = contentType + ";charset=" + encoding;
    response.setContentType(fullContentType);
    if (noCache) {
      ServletUtils.setDisableCacheHeader(response);
    }

    return response;
  }
  private static int runReplacement(
      String env, ConfigTokens conf, String scope, List<File> toProcess) {
    int errorCount = 0;
    for (File xmlFile : toProcess) {
      try {
        Document xmlDoc = FileReader.getXMLDocument(xmlFile);
        Policy tokens;
        if (StringUtils.equalsIgnoreCase(scope, "proxy")) {
          tokens = conf.getConfigbyEnv(env).getProxyFileNameMatch(xmlFile.getName());
        } else if (StringUtils.equalsIgnoreCase(scope, "policy")) {
          tokens = conf.getConfigbyEnv(env).getPolicyFileNameMatch(xmlFile.getName());
        } else if (StringUtils.equalsIgnoreCase(scope, "target")) {
          tokens = conf.getConfigbyEnv(env).getTargetFileNameMatch(xmlFile.getName());
        } else {
          continue;
        } // === N E X T ===
        xmlDoc = replaceTokens(xmlDoc, tokens);
        DOMSource source = new DOMSource(xmlDoc);
        StreamResult result = new StreamResult(xmlFile);
        tltf.get().transform(source, result);
      } catch (Exception e) {
        logger.error("Error processing " + xmlFile.getName(), e);
        errorCount++;
      }
    }

    return errorCount;
  }
  private boolean validateReplaceeReplacer(PersonMassChange personMassChange) {
    boolean isValid = true;

    if (personMassChange.getReplaceePersonId() == null
        && personMassChange.getReplaceeRolodexId() == null) {
      isValid = false;
      reportError(REPLACEE_FULL_NAME_FIELD, KeyConstants.ERROR_PERSON_MASS_CHANGE_REPLACEE_EMPTY);
      return isValid;
    }

    if (personMassChange.getReplacerPersonId() == null
        && personMassChange.getReplacerRolodexId() == null) {
      isValid = false;
      reportError(REPLACER_FULL_NAME_FIELD, KeyConstants.ERROR_PERSON_MASS_CHANGE_REPLACER_EMPTY);
      return isValid;
    }

    if ((personMassChange.getReplacerPersonId() != null
            && StringUtils.equalsIgnoreCase(
                personMassChange.getReplacerPersonId(), personMassChange.getReplaceePersonId()))
        || (personMassChange.getReplacerRolodexId() != null
            && StringUtils.equalsIgnoreCase(
                String.valueOf(personMassChange.getReplacerRolodexId()),
                String.valueOf(personMassChange.getReplaceeRolodexId())))) {
      isValid = false;
      reportError(REPLACER_FULL_NAME_FIELD, KeyConstants.ERROR_PERSON_MASS_CHANGE_SAME_PERSONS);
    }

    return isValid;
  }
 public void generateParentNodes() {
   if (StringUtils.equalsIgnoreCase("0", getMedusaViewRadio())) {
     setParentNodes(
         getMedusaService().getMedusaByProposal(getModuleName(), getModuleIdentifier()));
   } else if (StringUtils.equalsIgnoreCase("1", getMedusaViewRadio())) {
     setParentNodes(getMedusaService().getMedusaByAward(getModuleName(), getModuleIdentifier()));
   }
   sortNodes(parentNodes);
 }
 public void saveAnswerHeaders(ProposalDevelopmentDocumentForm pdForm, String pageId) {
   if (StringUtils.equalsIgnoreCase(pageId, Constants.KEY_PERSONNEL_PAGE)
       || StringUtils.equalsIgnoreCase(pageId, Constants.CERTIFICATION_PAGE)) {
     saveUpdatePersonAnswerHeaders(
         pdForm.getProposalDevelopmentDocument().getDevelopmentProposal(), pageId);
   } else if (StringUtils.equalsIgnoreCase(pageId, Constants.QUESTIONS_PAGE)) {
     saveUpdateQuestionnaireAnswerHeaders(pdForm.getQuestionnaireHelper(), pageId);
     saveUpdateQuestionnaireAnswerHeaders(pdForm.getS2sQuestionnaireHelper(), pageId);
   }
 }
Beispiel #7
0
 /**
  * @param element
  * @return
  */
 private boolean doesElementHaveRequestedTargetAttribute(Element element) {
   if (!element.hasAttr(TARGET_ATTR)) {
     return false;
   }
   String targetValue = element.attr(TARGET_ATTR);
   if (StringUtils.equalsIgnoreCase(targetValue, TOP_TARGET_VALUE)
       || StringUtils.equalsIgnoreCase(targetValue, PARENT_TARGET_VALUE)
       || StringUtils.equalsIgnoreCase(targetValue, SELF_TARGET_VALUE)) {
     return false;
   }
   return true;
 }
  private void initCoiDisclosureAttachment() {

    this.setNewCoiDisclosureAttachment(new CoiDisclosureAttachment(this.getCoiDisclosure()));
    CoiDisclosure coiDisclosure = coiDisclosureForm.getCoiDisclosureDocument().getCoiDisclosure();
    String event = coiDisclosure.getEventTypeCode();
    if (StringUtils.equalsIgnoreCase(event, CoiDisclosureEventType.AWARD)
        || StringUtils.equalsIgnoreCase(event, CoiDisclosureEventType.DEVELOPMENT_PROPOSAL)
        || StringUtils.equalsIgnoreCase(event, CoiDisclosureEventType.INSTITUTIONAL_PROPOSAL)
        || StringUtils.equalsIgnoreCase(event, CoiDisclosureEventType.IRB_PROTOCOL)) {
      String projectId = coiDisclosure.getCoiDisclProjects().get(0).getProjectId();
      newCoiDisclosureAttachment.setProjectId(projectId);
    }
  }
Beispiel #9
0
  /**
   * This method iterates through the awardFandaRateList and creates two hashmaps; one with on
   * campus values and other with off campus values in it.
   *
   * @param awardFandaRateList
   * @param a1
   * @param b1
   */
  protected void createHashMapsForRuleEvaluation(
      List<AwardFandaRate> awardFandaRateList,
      HashMap<String, String> a1,
      HashMap<String, String> b1) {

    for (AwardFandaRate awardFandaRate : awardFandaRateList) {
      if (StringUtils.equalsIgnoreCase(awardFandaRate.getOnCampusFlag(), "N")) {
        a1.put(awardFandaRate.getFandaRateTypeCode(), awardFandaRate.getOnCampusFlag());
      } else if (StringUtils.equalsIgnoreCase(awardFandaRate.getOnCampusFlag(), "F")) {
        b1.put(awardFandaRate.getFandaRateTypeCode(), awardFandaRate.getOnCampusFlag());
      }
    }
  }
 /**
  * @param color
  * @return whether the color is testable, i.e defined as a rgb color
  */
 public static boolean isColorTestable(final String color) {
   return !StringUtils.contains(color, BACKGROUND_IMAGE_KEY)
       && !StringUtils.contains(color, GRADIENT_KEY)
       && !StringUtils.contains(color, ALPHA_COLOR_KEY)
       && !StringUtils.equalsIgnoreCase(color, TRANSPARENT_KEY)
       && StringUtils.startsWith(color, RGB_COLOR_KEY);
 }
  /**
   * This method returns the personnel calculated direct cost.
   *
   * @return
   */
  public Map<RateClassRateType, ScaleTwoDecimal> getPersonnelCalculatedDirectCost(
      Budget currentBudget, AwardBudgetExt previousBudget) {
    SortedMap<RateType, List<ScaleTwoDecimal>> currentTotals =
        currentBudget.getPersonnelCalculatedExpenseTotals();
    int period = currentBudget.getBudgetPeriods().size() - 1;
    Map<RateClassRateType, ScaleTwoDecimal> currentCost =
        new HashMap<RateClassRateType, ScaleTwoDecimal>();
    Map<RateClassRateType, ScaleTwoDecimal> netCost =
        new HashMap<RateClassRateType, ScaleTwoDecimal>();
    for (RateType rate : currentTotals.keySet()) {
      // For some reason indirect cost shows up in this, remove it.
      if (!StringUtils.equalsIgnoreCase(rate.getRateClass().getRateClassTypeCode(), "O")) {
        LOG.info(
            "Rate Class: " + rate.getRateClassCode() + "RateType: " + rate.getRateTypeCode() + "");
        currentCost.put(
            new RateClassRateType(rate.getRateClassCode(), rate.getRateTypeCode()),
            currentTotals.get(rate).get(period));
      }
    }

    for (RateClassRateType rate : currentCost.keySet()) {
      netCost.put(rate, currentCost.get(rate));
    }

    return netCost;
  }
 /** @return <code>true</code> if option has "expected" value. */
 private static boolean isOptionValue(String optionSuffix, String expected) {
   String value = getOptionValue(optionSuffix);
   if (value != null && !"false".equals(value)) {
     SPARSE_OPTION_MAP.put(optionSuffix, value);
   }
   return StringUtils.equalsIgnoreCase(value, expected);
 }
 public static boolean directoryContains(String canonicalParent, String canonicalChild) {
   canonicalParent = normalize(canonicalParent);
   canonicalChild = normalize(canonicalChild);
   return (!StringUtils.equalsIgnoreCase(canonicalParent, canonicalChild))
       && StringUtils.startsWithIgnoreCase(
           normalize(canonicalChild), normalize(canonicalParent) + SEPARATOR);
 }
Beispiel #14
0
 /**
  * This method checks the fields available on the UI and if any of those fields are different than
  * the DB version, it returns true.
  *
  * @param dbReportTracking
  * @return
  */
 public boolean hasBeenUpdated(ReportTracking dbReportTracking) {
   boolean retVal = false;
   if (dbReportTracking != null) {
     if (!StringUtils.equalsIgnoreCase(this.getPreparerId(), dbReportTracking.getPreparerId())) {
       retVal = true;
     } else if (!StringUtils.equalsIgnoreCase(
         this.getStatusCode(), dbReportTracking.getStatusCode())) {
       retVal = true;
     } else if (!StringUtils.equalsIgnoreCase(
         this.getComments(), dbReportTracking.getComments())) {
       retVal = true;
     } else if (!dateEquals(this.activityDate, dbReportTracking.activityDate)) {
       retVal = true;
     }
   }
   return retVal;
 }
Beispiel #15
0
 public static DataType get(String value) {
   for (DataType dataType : values()) {
     if (StringUtils.equalsIgnoreCase(value, dataType.dataType)) {
       return dataType;
     }
   }
   return null;
 }
  /**
   * Is it mandatory for the submission to contain the committee and schedule?
   *
   * @return true if mandatory; otherwise false
   */
  private boolean isMandatory() {
    final String param =
        this.getParameterService()
            .getParameterValueAsString(
                ProtocolDocument.class, Constants.PARAMETER_IRB_COMM_SELECTION_DURING_SUBMISSION);

    return StringUtils.equalsIgnoreCase(MANDATORY, param);
  }
 /**
  * Returns the setting as the specified type
  *
  * @param identifier the identifier
  * @param clazz the expected type
  * @return the value as clazz
  * @throws GkException GkException
  */
 public <T> T getSetting(String identifier, Class<T> clazz) throws GkException {
   for (TinyGGroupSettings grpSetting : groups) {
     if (StringUtils.equalsIgnoreCase(grpSetting.getGroupIdentifier(), SYSTEM_SETTINGS)) {
       T setting = getSetting(identifier, grpSetting.getSettings(), clazz);
       return setting;
     }
   }
   throw new GkFunctionalException("Setting '" + identifier + "' is unknown");
 }
Beispiel #18
0
  public static DocumentType parseString(final String type) {
    for (DocumentType documentType : values()) {
      if (StringUtils.equalsIgnoreCase(type, documentType.getStringValue())) {
        return documentType;
      }
    }

    throw new IllegalArgumentException("Couldn't parse DocumentType from string '" + type + "'");
  }
 /**
  * Sets the setting value
  *
  * @param groupIdentifier the identifier of the group
  * @param identifier the identifier
  * @param value the value to set
  * @throws GkException GkException
  */
 public <T> void setSetting(String groupIdentifier, String identifier, T value)
     throws GkException {
   for (TinyGGroupSettings grpSetting : groups) {
     if (StringUtils.equalsIgnoreCase(grpSetting.getGroupIdentifier(), groupIdentifier)) {
       setSetting(grpSetting, identifier, value);
       return;
     }
   }
   throw new GkFunctionalException("Setting '" + identifier + "' is unknown");
 }
 private void validateParam(ApprovalCommonParam input, ApprovalRequest existingApproval) {
   // Are we approving or rejecting?
   if (StringUtils.equalsIgnoreCase(input.getApprovalStatus(), ApprovalStatus.PENDING.name())
       == false) {
     // Is existing approval not in pending state
     if (existingApproval.pending() == false) {
       throw APIException.badRequests.updatingCompletedApproval();
     }
   }
 }
  /**
   * serial port names are CASE SENSITIVE. this sounds logically on unix platform however com1 will
   * not work on windows, there all names need to be in uppercase (COM1)
   *
   * <p>see https://github.com/neophob/PixelController/issues/30 for more details
   *
   * @param configuredName
   * @return
   */
  public static String getSerialPortName(String configuredName) {
    for (String portName : Serial.list()) {
      if (StringUtils.equalsIgnoreCase(portName, configuredName)) {
        return portName;
      }
    }

    // we didn't found the port, hope that the provided name will work...
    return configuredName;
  }
Beispiel #22
0
 public boolean processRunAuditBusinessRules(Document document) {
   boolean retval = true;
   AwardDocument awardDocument = (AwardDocument) document;
   if (StringUtils.equalsIgnoreCase(
       this.getParameterService()
           .getParameterValueAsString(
               AwardDocument.class, KeyConstants.ENABLE_AWARD_FNA_VALIDATION),
       KeyConstants.ENABLED_PARAMETER_VALUE_ONE)) {
     retval = isFandaRateInputInPairs(awardDocument.getAward().getAwardFandaRate());
   }
   return retval;
 }
Beispiel #23
0
  public void showRoles(ActionResult actionResult, String username) {
    Page<? extends Role> roles = roleManager.findActiveRoleByKeyword("", null);
    actionResult.addToModel("roles", roles);

    if (!StringUtils.equalsIgnoreCase(username, "-")) {
      User user = userManager.getUserByUsername(username);
      actionResult.addToModel("user", user);

      Page<? extends UserRole> userRoles = userManager.findRoleByUser(user, null);
      actionResult.addToModel("userRoles", userRoles);
    }
  }
 @Override
 public CreatureTemplate loadCreature(String name) {
   if (StringUtils.isBlank(name)) {
     throw new IllegalArgumentException("Card name must not be empty.");
   }
   loadAllCreatures();
   for (CreatureTemplate creatureTemplate : allCreatures) {
     if (StringUtils.equalsIgnoreCase(name, creatureTemplate.getName())) {
       return creatureTemplate;
     }
   }
   throw new IllegalArgumentException("Creature with the given name does not exist: " + name);
 }
Beispiel #25
0
 /** 后台地理位置编辑弹框 */
 @RequestMapping(value = "maintainlandmarkposition", method = RequestMethod.GET)
 public String maintainLandmark(
     @ModelAttribute Landmark landmark,
     @RequestParam("type") String type,
     HttpServletResponse response,
     String location,
     ModelMap map) {
   logger.debug("地标管理" + landmark.getId());
   map.put("city_code", landmark.getCityCode());
   map.put("type", type);
   map.put("location", location);
   if (StringUtils.equalsIgnoreCase("edit", type)) {
     map.put("landmark", landmark);
     Position p = landmark.getPosition();
     if (p != null) {
       map.put("position", p);
     }
   } else if (StringUtils.equalsIgnoreCase("add", type)) {
     map.put("landmark", null);
   }
   response.addHeader("Access-Control-Allow-Origin", "http://www.xpos.com");
   return "landmark/landmark_input";
 }
 /**
  * Returns the setting as the specified type
  *
  * @param groupIdentifier the identifier of the group
  * @param identifier the identifier
  * @param clazz the expected type
  * @return the value as clazz
  * @throws GkException GkException
  */
 public <T> T getSetting(String groupIdentifier, String identifier, Class<T> clazz)
     throws GkException {
   for (TinyGGroupSettings grpSetting : groups) {
     if (StringUtils.equalsIgnoreCase(grpSetting.getGroupIdentifier(), groupIdentifier)) {
       T setting = getSetting(identifier, grpSetting.getSettings(), clazz);
       if (setting == null) {
         throw new GkFunctionalException(
             "Setting '" + identifier + "' is unknown for group " + groupIdentifier);
       }
       return setting;
     }
   }
   throw new GkFunctionalException("Unknown  group " + groupIdentifier);
 }
Beispiel #27
0
  private void extractDescription(
      @NotNull Element element, String queryString, DictionaryObjectBuilder objectBuilder) {
    Element descriptionNode = element.getElementsByClass("info").first();
    if (descriptionNode != null) {
      String description = descriptionNode.text();

      description = StringUtils.removeStart(description, "(");
      description = StringUtils.removeEnd(description, ")");

      if (!StringUtils.equalsIgnoreCase(
          description, queryString)) // Set description only if it is different from request string
      objectBuilder.setDescription(StringUtils.strip(description));
    }
  }
 @Override
 public List<CreatureTemplate> loadAllCreatures() {
   if (CollectionUtils.isEmpty(allCreatures)) {
     NodeList nodes = getNodes(filePath);
     for (int i = 0; i < nodes.getLength(); i++) {
       Node node = nodes.item(i);
       if (StringUtils.isNotBlank(node.getNodeName())
           && StringUtils.equalsIgnoreCase(node.getNodeName(), "creature")) {
         allCreatures.add(getCreatureFromNode(node));
       }
     }
   }
   return allCreatures;
 }
  /**
   * @param grants
   * @param formUser
   * @throws TrapException
   */
  protected void checkExportGrantCitizen(Set<FormGrant> grants, FormUser formUser)
      throws TrapException {

    if (formUser.getCitizenship().equalsIgnoreCase("united states")
        || formUser.getCitizenship().equalsIgnoreCase("usa")) {
      return;
    } else {
      for (FormGrant grant : grants) {
        if (StringUtils.equalsIgnoreCase(grant.getOrganizationType(), "noExport")) {
          throw new TrapException(TrapErrors.NONCITIZEN_EXPORT);
        }
      }
    }
  }
  @Override
  public void onSubmit(ArrayList<String> array) {

    String titleCode = "";
    String currencyCode = "";
    String languageCode = "";

    for (GenericNameCode obj : mTitles) {
      if (StringUtils.equalsIgnoreCase(obj.getName(), array.get(0).toString())) {
        titleCode = obj.getCode();
        break;
      }
    }

    for (GenericNameCode obj : mCurrencies) {
      if (StringUtils.equalsIgnoreCase(obj.getName(), array.get(3).toString())) {
        currencyCode = obj.getIsocode();
        break;
      }
    }

    for (GenericNameCode obj : mLanguages) {
      if (StringUtils.equalsIgnoreCase(obj.getName(), array.get(4).toString())) {
        languageCode = obj.getIsocode();
        break;
      }
    }

    QueryCustomer query = new QueryCustomer();
    query.setFirstName(array.get(1));
    query.setLastName(array.get(2));
    query.setTitleCode(titleCode);
    query.setLanguage(languageCode);
    query.setCurrency(currencyCode);

    RESTLoader.execute(this, WebserviceMethodEnums.METHOD_UPDATE_PROFILE, query, this, true, true);
  }