示例#1
0
  public Page<Log> find(Page<Log> page, Map<String, Object> paramMap) {
    DetachedCriteria dc = logDao.createDetachedCriteria();

    Long createById = StringUtils.toLong(paramMap.get("createById"));
    if (createById > 0) {
      dc.add(Restrictions.eq("createBy.id", createById));
    }

    String requestUri = ObjectUtils.toString(paramMap.get("requestUri"));
    if (StringUtils.isNotBlank(requestUri)) {
      dc.add(Restrictions.like("requestUri", "%" + requestUri + "%"));
    }

    String exception = ObjectUtils.toString(paramMap.get("exception"));
    if (StringUtils.isNotBlank(exception)) {
      dc.add(Restrictions.eq("type", Log.TYPE_EXCEPTION));
    }

    Date beginDate = DateUtils.parseDate(paramMap.get("beginDate"));
    if (beginDate == null) {
      beginDate = DateUtils.setDays(new Date(), 1);
      paramMap.put("beginDate", DateUtils.formatDate(beginDate, "yyyy-MM-dd"));
    }
    Date endDate = DateUtils.parseDate(paramMap.get("endDate"));
    if (endDate == null) {
      endDate = DateUtils.addDays(DateUtils.addMonths(beginDate, 1), -1);
      paramMap.put("endDate", DateUtils.formatDate(endDate, "yyyy-MM-dd"));
    }
    dc.add(Restrictions.between("createDate", beginDate, endDate));

    dc.addOrder(Order.desc("id"));
    return logDao.find(page, dc);
  }
示例#2
0
 public boolean isMoveDoable(ScoreDirector scoreDirector) {
   Object leftValue = variableDescriptor.getValue(leftEntity);
   Object rightEntity = inverseVariableSupply.getInverseSingleton(rightValue);
   if (ObjectUtils.equals(leftValue, rightValue)
       || ObjectUtils.equals(leftEntity, rightValue)
       || ObjectUtils.equals(rightEntity, leftValue)) {
     return false;
   }
   if (rightEntity == null) {
     Object leftAnchor = anchorVariableSupply.getAnchor(leftEntity);
     Object rightAnchor = determineRightAnchor();
     // TODO Currently unsupported because we fail to create a valid undoMove... even though doMove
     // supports it
     if (leftAnchor == rightAnchor) {
       return false;
     }
   }
   if (!variableDescriptor.isValueRangeEntityIndependent()) {
     ValueRangeDescriptor valueRangeDescriptor = variableDescriptor.getValueRangeDescriptor();
     Solution workingSolution = scoreDirector.getWorkingSolution();
     if (rightEntity != null) {
       ValueRange rightValueRange =
           valueRangeDescriptor.extractValueRange(workingSolution, rightEntity);
       if (!rightValueRange.contains(leftValue)) {
         return false;
       }
     }
     ValueRange leftValueRange =
         valueRangeDescriptor.extractValueRange(workingSolution, leftEntity);
     if (!leftValueRange.contains(rightValue)) {
       return false;
     }
   }
   return true;
 }
  @Override
  public boolean equals(Object obj) {
    if (obj == null || !(obj instanceof Response)) return false;

    Response response = (Response) obj;
    if (!ObjectUtils.equals(getType(), response.getType())) return false;
    if (!ObjectUtils.equals(getData(), response.getData())) return false;

    return super.equals(obj);
  }
 protected boolean addScripts(Schema schema, ScriptGeneratorManager manager) {
   boolean generate = true;
   Identifier catalogId = valueOf(manager.getSourceCatalog());
   if (catalogId != null) {
     generate = ObjectUtils.equals(catalogId, schema.getCatalog().getIdentifier());
   }
   Identifier schemaId = valueOf(manager.getSourceSchema());
   if (generate && schemaId != null) {
     generate = ObjectUtils.equals(schemaId, schema.getIdentifier());
   }
   return generate;
 }
 public static String getActivityName(String processDefinitionId, String activityId) {
   ActivityImpl activity = getActivity(processDefinitionId, activityId);
   if (activity != null) {
     return ObjectUtils.toString(activity.getProperty("name"));
   }
   return null;
 }
  public void updateUser(GenericRequestParam genericRequestParam) {
    final Map<String, User> users = getUsers();
    final Set<User> forUpdateOrCreate = Sets.newHashSet();

    for (Map.Entry<String, Object> entry : genericRequestParam.getParams().entrySet()) {
      final String[] n = entry.getKey().split(":");

      if (n.length == 2) {
        String username = n[0];
        final User user = ObjectUtils.defaultIfNull(users.get(username), new User(username));
        final String roleAsString = n[1];
        final String code = entry.getValue().toString();

        if ("courier".equalsIgnoreCase(roleAsString)) {
          Courier courier = courierService.findOneByCode(code);
          user.setCourier(courier);
        } else if ("wireless".equalsIgnoreCase(roleAsString)) {
          WirelessCenter wc = wirelessCenterService.findOneByCode(code);
          user.setWirelessCenter(wc);
        }

        forUpdateOrCreate.add(user);
      }
    }

    userRepository.save(forUpdateOrCreate);
  }
示例#7
0
 public ActionForward delete(
     ActionMapping mapping,
     ActionForm form,
     HttpServletRequest request,
     HttpServletResponse response)
     throws Exception {
   BudgetForm budgetForm = (BudgetForm) form;
   AwardBudgetDocument awardBudgetDocument = budgetForm.getBudgetDocument();
   int selectedLineNumber = getSelectedLine(request);
   BudgetSubAwards subAward =
       awardBudgetDocument.getBudget().getBudgetSubAwards().get(selectedLineNumber);
   for (BudgetPeriod period : awardBudgetDocument.getBudget().getBudgetPeriods()) {
     Iterator<BudgetLineItem> iter = period.getBudgetLineItems().iterator();
     while (iter.hasNext()) {
       BudgetLineItem item = iter.next();
       if (org.apache.commons.lang3.ObjectUtils.equals(
           subAward.getSubAwardNumber(), item.getSubAwardNumber())) {
         iter.remove();
       }
     }
   }
   awardBudgetDocument.getBudget().getBudgetSubAwards().remove(selectedLineNumber);
   Collections.sort(awardBudgetDocument.getBudget().getBudgetSubAwards());
   return mapping.findForward(Constants.MAPPING_BASIC);
 }
  @SuppressWarnings("deprecation")
  public static List<String> getTableColumns(String tableName) {
    List<String> result = new ArrayList<String>();
    if (tableName == null) {
      return result;
    }
    String tn = tableName.toLowerCase();
    if (tableColumns.containsKey(tn)) {
      return tableColumns.get(tn);
    } else {
      JdbcTemplate jdbcTemplate = ContextUtil.getBean(JdbcTemplate.class);

      String sql = "select column_name from USER_TAB_COLUMNS where lower(table_name)=?";
      List<Map<String, Object>> colList = jdbcTemplate.queryForList(sql, tn);
      if (colList.size() > 0) {
        for (Map<String, Object> map2 : colList) {
          String colName = ObjectUtils.toString(map2.get("column_name")).toLowerCase();
          result.add(colName);
        }
      }
      if (result.size() > 0) {
        tableColumns.put(tn, result);
      }
      return result;
    }
  }
  /*
   * validate code description is unique
   */
  @SuppressWarnings("unchecked")
  private boolean checkDescriptionUniqueness(CoiNoteType newFinIntEntityRelType) {
    boolean isValid = true;

    String description = newFinIntEntityRelType.getDescription();

    Map<String, Object> fieldValues = new HashMap<String, Object>();
    fieldValues.put(DESCRIPTION_FIELD_NAME, description);
    Collection<CoiNoteType> matchingRelTypes =
        getBusinessObjectService().findMatching(CoiNoteType.class, fieldValues);

    for (CoiNoteType noteType : matchingRelTypes) {
      if (!ObjectUtils.equals(
          noteType.getNoteTypeCode(), newFinIntEntityRelType.getNoteTypeCode())) {
        isValid = false;
        putFieldError(
            DESCRIPTION_FIELD_NAME,
            KeyConstants.ERROR_DUPLICATE_PROPERTY,
            new String[] {"Description"});
        break;
      }
    }

    return isValid;
  }
示例#10
0
 /**
  * . This is the Getter Method for rolodex
  *
  * @return Returns the rolodex.
  */
 public Rolodex getRolodex() {
   if (rolodex == null
       || !ObjectUtils.equals(rolodex.getRolodexId(), rolodexId) && rolodexId != null) {
     refreshRolodex();
   }
   return rolodex;
 }
示例#11
0
 public void func_75692_b(int p_75692_1_, Object p_75692_2_) {
   DataWatcher.WatchableObject var3 = this.func_75691_i(p_75692_1_);
   if (ObjectUtils.notEqual(p_75692_2_, var3.func_75669_b())) {
     var3.func_75673_a(p_75692_2_);
     this.field_151511_a.func_145781_i(p_75692_1_);
     var3.func_75671_a(true);
     this.field_75696_c = true;
   }
 }
示例#12
0
 public BrowsableFileField(FileType fileType, OpenType openType) {
   setBrowseWindowTitle(DefaultI18nContext.getInstance().i18n("Select a file"));
   getBrowseButton().setOnAction(handler);
   getTextField().setOnAction(handler);
   this.fileType = ObjectUtils.defaultIfNull(fileType, FileType.ALL);
   this.openType = ObjectUtils.defaultIfNull(openType, OpenType.OPEN);
   if (FileType.ALL != fileType) {
     getTextField()
         .setPromptText(
             String.format(
                 "%s: %s",
                 DefaultI18nContext.getInstance().i18n("Select a file"),
                 fileType.getFilter().getExtensions()));
   } else {
     getTextField().setPromptText(DefaultI18nContext.getInstance().i18n("Select a file"));
   }
   setOnDragOver(e -> dragConsume(e, this.onDragOverConsumer()));
   setOnDragDropped(e -> dragConsume(e, this.onDragDropped()));
 }
示例#13
0
  public <T> void set(DataParameter<T> key, T value) {
    EntityDataManager.DataEntry<T> dataentry = this.<T>getEntry(key);

    if (ObjectUtils.notEqual(value, dataentry.getValue())) {
      dataentry.setValue(value);
      this.entity.notifyDataManagerChange(key);
      dataentry.setDirty(true);
      this.dirty = true;
    }
  }
示例#14
0
 public int compareTo(final FileDetails o) {
   if (o == null) {
     throw new NullPointerException();
   }
   // N.B. this is in reverse order to how we'd normally compare
   int result = o.getFile().compareTo(file);
   if (result == 0) {
     result = ObjectUtils.compare(o.getLastModified(), lastModified);
   }
   return result;
 }
 // this setter will also refresh the reference object if the new affiliation type code
 // is different from the existing one.
 public void setAffiliationTypeCode(Integer newAffiliationTypeCode) {
   boolean changed = true;
   if (ObjectUtils.equals(this.affiliationTypeCode, newAffiliationTypeCode)) {
     changed = false;
   }
   this.affiliationTypeCode = newAffiliationTypeCode;
   if (changed) {
     this.refreshReferenceObject("affiliationType");
     this.setAffiliationTypeCodeChanged(true);
   }
 }
 protected List<BudgetLineItem> findLineItemsByCostElement(
     List<BudgetLineItem> lineItems, String costElement) {
   List<BudgetLineItem> lineItemsFound = new ArrayList<>();
   for (BudgetLineItem lineItem : lineItems) {
     if (StringUtils.equals(lineItem.getCostElement(), costElement)
         && ObjectUtils.equals(lineItem.getSubAwardNumber(), subAward.getSubAwardNumber())) {
       lineItemsFound.add(lineItem);
     }
   }
   return lineItemsFound;
 }
示例#17
0
 /** pre-condition: mergeTo and beMerged are isostructural */
 private static void mergeDirectoryFiles(
     @Nonnull DirectoryFile mergeTo, @Nonnull DirectoryFile beMerged) {
   for (File file : beMerged.getChildren()) {
     final File fileInMergeTo = findFirst(mergeTo.getChildren(), file, ISOSTRUCTURAL_FILE);
     if (fileInMergeTo == null) {
       mergeTo.addChild(ObjectUtils.clone(file));
     } else {
       mergeFiles0(fileInMergeTo, file);
     }
   }
 }
示例#18
0
 @Nonnull
 public static File mergeFiles(@Nonnull File... files) {
   if (files.length == 0) {
     throw new IllegalArgumentException("no files to merge");
   }
   File result = ObjectUtils.clone(files[0]);
   for (int index = 1; index < files.length; index++) {
     mergeFiles(result, files[index]);
   }
   return result;
 }
示例#19
0
 public boolean equals(Object o) {
   if (this == o) {
     return true;
   }
   if (o == null || !(o instanceof AwardBudgetLimit)) {
     return false;
   }
   AwardBudgetLimit l = (AwardBudgetLimit) o;
   if (!ObjectUtils.equals(this.getBudgetLimitId(), l.getBudgetLimitId())) {
     return false;
   }
   return true;
 }
 @Override
 public String modifyShoppingCartNum(String accountId, Integer cartId, Integer modifyNum) {
   ShoppingCart shoppingCart = shoppingCartDAO.find(ShoppingCart.class, cartId);
   if (shoppingCart == null || ObjectUtils.notEqual(accountId, shoppingCart.getAccountId())) {
     return "记录不存在";
   }
   if (shoppingCart.getProductNum() + modifyNum <= 0) {
     return TextConstant.PARAM_ERROR;
   }
   shoppingCart.setProductNum(shoppingCart.getProductNum() + modifyNum);
   shoppingCartDAO.update(ShoppingCart.class, shoppingCart);
   return null;
 }
示例#21
0
  public String getResourceDot(String resourceType) {
    StringBuilder buffer = new StringBuilder();
    Set<String> nodes = new HashSet<String>();
    buffer.append("digraph \"").append(resourceType).append("\" {\n");

    for (ProcessDefinition def : processDefinitions) {
      if (ObjectUtils.equals(resourceType, def.getResourceType())) {
        addTransitions(def, nodes, buffer);
      }
    }

    buffer.append("}\n");
    return buffer.toString();
  }
示例#22
0
  public void createUser(GenericRequestParam genericRequestParam) {

    if (genericRequestParam != null && MapUtils.isNotEmpty(genericRequestParam.getParams())) {

      Map<String, Object> params = genericRequestParam.getParams();

      String username = null;
      {
        if (params.containsKey("username")) {
          username = params.get("username").toString();
        }
      }

      String courierCode = null;
      {
        if (params.containsKey("courier")) {
          courierCode = params.get("courier").toString();
        }
      }

      String wirelessCenterCode = null;
      {
        if (params.containsKey("wireless")) {
          wirelessCenterCode = params.get("wireless").toString();
        }
      }

      if (username != null) {
        User user =
            ObjectUtils.defaultIfNull(
                userRepository.findOne(User_.username(username)), new User(username));

        if (StringUtils.isNotBlank(courierCode)) {
          Courier courier = courierService.findOneByCode(courierCode);
          if (courier != null) {
            user.setCourier(courier);
          }
        }

        if (StringUtils.isNotBlank(wirelessCenterCode)) {
          WirelessCenter wirelessCenter = wirelessCenterService.findOneByCode(wirelessCenterCode);
          if (wirelessCenter != null) {
            user.setWirelessCenter(wirelessCenter);
          }
        }

        userRepository.save(user);
      }
    }
  }
示例#23
0
 public <R extends AbstractResource<?>> void notNullAndSameAccountIdAndRegion(
     Collection<R> resources) {
   Validate.notNull(resources);
   String preAccountId = null;
   Region preRegion = null;
   for (R resource : resources) {
     String accountId = resource.getAccountId();
     Region region = resource.getRegion();
     Validate.notNull(accountId);
     ResourceType rt = ResourceType.find(resource);
     if (rt.isMultiRegion()) {
       Validate.notNull(region);
     }
     if (preAccountId == null) {
       preAccountId = accountId;
     }
     if (preRegion == null) {
       preRegion = region;
     }
     Validate.isTrue(ObjectUtils.equals(accountId, preAccountId));
     Validate.isTrue(ObjectUtils.equals(region, preRegion));
   }
 }
 private Object[] construct(
     Map<String, String> columnNameMap,
     Map<String, Object> paramMap,
     StringBuffer sql,
     UrpayOrderRequest request) {
   // 列名对应的中文名称
   columnNameMap.put("created", "发送时间");
   columnNameMap.put("mobile", "手机号码");
   columnNameMap.put("type", "发送类型");
   columnNameMap.put("buyerNick", "淘宝昵称");
   columnNameMap.put("tid", "订单编号");
   columnNameMap.put("smsContent", "短信内容");
   // 查询 sql
   sql.append("select from tb_tc_send_log ").append("where dp_id = :dpId ");
   // 查询参数
   paramMap.put("dpId", request.getDpId());
   if (ObjectUtils.notEqual(request.getType(), null)) {
     sql.append("and type = :type ");
     paramMap.put("type", request.getType());
   }
   if (ObjectUtils.notEqual(request.getStartCreated(), null)
       && ObjectUtils.notEqual(request.getEndCreated(), null)) {
     sql.append("and (created between :startCreated and :endCreated) ");
     paramMap.put("startCreated", new Date(request.getStartCreated()));
     paramMap.put("endCreated", new Date(request.getEndCreated()));
   }
   if (StringUtils.isNotEmpty(request.getMobileOrNickOrTid())) {
     sql.append("and (mobile = :fields or buyer_nick = :fields or tid = :fields) ");
     paramMap.put("fields", request.getMobileOrNickOrTid());
   }
   String columns =
       " date_format(created, ''%Y-%m-%d %H:%i:%s'') as {0}, mobile as {1}, type as {2}, buyer_nick as {3}, tid as {4}, sms_content as {5}";
   Object[] columnName = columnNameMap.keySet().toArray(new Object[0]);
   columns = MessageFormat.format(columns, columnName);
   sql.insert(6, columns);
   return columnName;
 }
示例#25
0
  public Guarantee newGuarantee(
      final Lease lease,
      final String reference,
      final String name,
      final GuaranteeType guaranteeType,
      final LocalDate startDate,
      final LocalDate endDate,
      final String description,
      final BigDecimal contractualAmount,
      final BigDecimal startAmount) {

    AgreementRoleType artGuarantee =
        agreementRoleTypeRepository.findByTitle(GuaranteeConstants.ART_GUARANTEE);
    Party leasePrimaryParty = lease.getPrimaryParty();

    AgreementRoleType artGuarantor =
        agreementRoleTypeRepository.findByTitle(GuaranteeConstants.ART_GUARANTOR);
    Party leaseSecondaryParty = lease.getSecondaryParty();

    Guarantee guarantee = newTransientInstance(Guarantee.class);
    final AgreementType at = agreementTypeRepository.find(GuaranteeConstants.AT_GUARANTEE);
    guarantee.setType(at);
    guarantee.setReference(reference);
    guarantee.setDescription(description);
    guarantee.setName(name);
    guarantee.setStartDate(startDate);
    guarantee.setEndDate(endDate);
    guarantee.setGuaranteeType(guaranteeType);
    guarantee.setLease(lease);
    guarantee.setContractualAmount(contractualAmount);

    guarantee.newRole(artGuarantee, leasePrimaryParty, null, null);
    guarantee.newRole(artGuarantor, leaseSecondaryParty, null, null);

    FinancialAccountType financialAccountType = guaranteeType.getFinancialAccountType();
    if (financialAccountType != null) {
      FinancialAccount financialAccount =
          financialAccounts.newFinancialAccount(
              financialAccountType, reference, name, leaseSecondaryParty);
      guarantee.setFinancialAccount(financialAccount);
      if (ObjectUtils.compare(startAmount, BigDecimal.ZERO) > 0) {
        financialAccountTransactions.newTransaction(
            guarantee.getFinancialAccount(), startDate, null, startAmount);
      }
    }

    persistIfNotAlready(guarantee);
    return guarantee;
  }
  @Override
  public boolean equals(Object obj) {
    if (this == obj) {
      return true;
    }

    if (obj == null || !(obj instanceof VersionConstraint)) {
      return false;
    }

    VersionConstraint versionConstraint = (VersionConstraint) obj;

    return this.ranges.equals(versionConstraint.getRanges())
        && ObjectUtils.equals(this.version, versionConstraint.getVersion());
  }
 public void compare(IacucProtocolSummary other) {
   IacucProtocolExceptionSummary otherSummary =
       (other == null) ? null : other.findExceptionSummary(iacucProtocolExceptionId);
   if (otherSummary == null) {
     speciesNameChanged = true;
     exceptionCategoryChanged = true;
     exceptionDescriptionChanged = true;
     exceptionCountChanged = true;
   } else {
     speciesNameChanged = !StringUtils.equals(speciesName, otherSummary.speciesName);
     exceptionCategoryChanged =
         !StringUtils.equals(exceptionCategory, otherSummary.exceptionCategory);
     exceptionDescriptionChanged =
         !StringUtils.equals(exceptionDescription, otherSummary.exceptionDescription);
     exceptionCountChanged = !ObjectUtils.equals(exceptionCount, otherSummary.exceptionCount);
   }
 }
  /**
   * This method validates the lookupClass field. The field must may not contain null.
   *
   * @param question - the question to be validated
   * @return true if all validation has passed, false otherwise
   */
  private boolean validateLookupClass(Question question) {
    // Force a reload the lookupReturn dropdown list when the lookupClass changes
    String prevLookupClass =
        (String) GlobalVariables.getUserSession().retrieveObject(Constants.LOOKUP_CLASS_NAME);
    if (ObjectUtils.equals(question.getLookupClass(), prevLookupClass)) {
      GlobalVariables.getUserSession().removeObject(Constants.LOOKUP_RETURN_FIELDS);
    }

    if (question.getLookupClass() != null) {
      return true;
    } else {
      GlobalVariables.getMessageMap()
          .putError(
              Constants.QUESTION_DOCUMENT_FIELD_LOOKUP_CLASS,
              KeyConstants.ERROR_QUESTION_LOOKUP_CLASS_NOT_SPECIFIED);
      return false;
    }
  }
  @Override
  public final boolean equals(@Nullable final Object other) {

    if (other == null) {
      return false;
    }
    // Kleine Performance-Optimierung, die gerade mit dem InterningStringWrapper eine Menge bringt.
    if (this == other) {
      return true;
    }
    if (!getClass().isAssignableFrom(other.getClass())) {
      return false;
    }
    @SuppressWarnings("unchecked")
    final AbstractTypeWrapper<T> otherIT = (AbstractTypeWrapper<T>) other;

    return ObjectUtils.equals(_value, otherIT.getValue());
  }
  protected void updateArrivalTime(ScoreDirector scoreDirector, Customer sourceCustomer) {

    logger.trace(
        "--------------------------------------------------------------------------------");
    logger.trace(
        "----------------updateArrivalTime (customer) begins-----------------------------");
    logger.trace(
        "--------------------------------------------------------------------------------");

    Integer previousDepartureTime = calculatePreviousDepartureTime(sourceCustomer);
    Integer arrivalTime = calculateArrivalTime(sourceCustomer, previousDepartureTime);

    Customer nextCustomer = sourceCustomer;

    logger.trace("sourceCustomer: " + sourceCustomer);
    logger.trace("sourceCustomer.getVehicleRecursive(): " + sourceCustomer.getVehicleRecursive());
    logger.trace(
        "sourceCustomer.getVehicleRecursive().getNextCustomer(): "
            + sourceCustomer.getVehicleRecursive().getNextCustomer());
    logger.trace("calculated departureTime : " + previousDepartureTime);
    logger.trace("sourceCustomer.getArrivalTime() : " + sourceCustomer.getArrivalTime());
    logger.trace("calculated arrivalTime : " + arrivalTime);

    // actualiza solo si es necesario (while se ejecuta solo una vez en las correcciones de los
    // punteros)
    while ((nextCustomer != null)
        && (ObjectUtils.notEqual(nextCustomer.getArrivalTime(), arrivalTime))) {

      logger.trace("while() shadowCustomer: " + nextCustomer);
      scoreDirector.beforeVariableChanged(nextCustomer, "arrivalTime");
      nextCustomer.setArrivalTime(arrivalTime);
      scoreDirector.afterVariableChanged(nextCustomer, "arrivalTime");
      previousDepartureTime = nextCustomer.getDepartureTime();
      nextCustomer = nextCustomer.getNextCustomer();
      arrivalTime = calculateArrivalTime(nextCustomer, previousDepartureTime);
    }

    logger.trace(
        "--------------------------------------------------------------------------------");
    logger.trace(
        "----------------updateArrivalTime (customer) ends-------------------------------");
    logger.trace(
        "--------------------------------------------------------------------------------");
  }