Esempio n. 1
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;
 }
Esempio n. 4
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;
 }
  /*
   * 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;
  }
Esempio n. 6
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);
 }
 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;
 }
 // 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);
   }
 }
Esempio n. 9
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;
 }
Esempio n. 10
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();
  }
Esempio n. 11
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));
   }
 }
  @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());
  }
Esempio n. 13
0
 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());
  }
 @SuppressWarnings("unchecked")
 public boolean doKeyValuesMatch(PersistableBusinessObject object, Map<String, Object> keyValues)
     throws NoSuchFieldException, IllegalAccessException, InvocationTargetException,
         ClassNotFoundException {
   boolean matchesAll = true;
   Class clazz = object.getClass();
   for (Map.Entry<String, Object> entry : keyValues.entrySet()) {
     boolean matches = false;
     for (PropertyDescriptor propDescriptor : PropertyUtils.getPropertyDescriptors(clazz)) {
       if (StringUtils.equals(propDescriptor.getName(), entry.getKey())) {
         Method getter = propDescriptor.getReadMethod();
         Object value = getter.invoke(object);
         if (ObjectUtils.equals(value, entry.getValue())) {
           matches = true;
         }
       }
     }
     matchesAll &= matches;
   }
   return matchesAll;
 }
 public Solution cloneSolution(Solution originalSolution) {
   SolutionDescriptor solutionDescriptor = getSolutionDescriptor();
   Solution cloneSolution = solutionDescriptor.getSolutionCloner().cloneSolution(originalSolution);
   if (scoreDirectorFactory.isAssertClonedSolution()) {
     if (!ObjectUtils.equals(originalSolution.getScore(), cloneSolution.getScore())) {
       throw new IllegalStateException(
           "Cloning corruption: "
               + "the original's score ("
               + originalSolution.getScore()
               + ") is different from the clone's score ("
               + cloneSolution.getScore()
               + ").\n"
               + "Check the "
               + SolutionCloner.class.getSimpleName()
               + ".");
     }
     List<Object> originalEntityList = solutionDescriptor.getEntityList(originalSolution);
     Map<Object, Object> originalEntityMap =
         new IdentityHashMap<Object, Object>(originalEntityList.size());
     for (Object originalEntity : originalEntityList) {
       originalEntityMap.put(originalEntity, null);
     }
     for (Object cloneEntity : solutionDescriptor.getEntityList(cloneSolution)) {
       if (originalEntityMap.containsKey(cloneEntity)) {
         throw new IllegalStateException(
             "Cloning corruption: "
                 + "the same entity ("
                 + cloneEntity
                 + ") is present in both the original and the clone.\n"
                 + "So when a planning variable in the original solution changes, "
                 + "the cloned solution will change too.\n"
                 + "Check the "
                 + SolutionCloner.class.getSimpleName()
                 + ".");
       }
     }
   }
   return cloneSolution;
 }
Esempio n. 18
0
  public void run() {
    List<AnnotationDTO> pastAnnotations =
        cao.getTopAnnotationsByLaunch(pastLaunchIds, topAnnoTypes);
    List<AnnotationDTO> newAnnotations = cao.getTopAnnotationsByLaunch(newLaunchIds, topAnnoTypes);
    pastIndex = new AnnoIndex(pastAnnotations);
    // newIndex = new AnnoIndex(newAnnotations);

    Set<Long> handledPastAnnotations = new HashSet<Long>();
    for (AnnotationDTO newAnno : newAnnotations) {
      AnnotationDTO pastAnno = pastIndex.getClosestOverlappingOfSameType(newAnno);
      if (pastAnno == null) {
        fireNewAnnotation(newAnno);
        continue;
      }
      // sanityCheck
      if (!ObjectUtils.equals(pastAnno.getDocUri(), newAnno.getDocUri())
          || newAnno.getStartOffset() > pastAnno.getEndOffset()
          || newAnno.getEndOffset() < pastAnno.getStartOffset()) {
        throw new IllegalStateException("Assertion failed. Index is incorrect");
      }
      handledPastAnnotations.add(pastAnno.getId());
      if (newAnno.getStartOffset() == pastAnno.getStartOffset()
          && newAnno.getEndOffset() == pastAnno.getEndOffset()) {
        // TODO it's place to check features
        fireSavedAnnotation(pastAnno, newAnno);
      } else {
        fireChangedAnnotation(pastAnno, newAnno);
      }
    }

    // catch all lost annotations
    for (AnnotationDTO oldAnno : pastAnnotations) {
      if (!handledPastAnnotations.contains(oldAnno.getId())) {
        fireLostAnnotation(oldAnno);
      }
    }
  }
  /*
   * validate that sort id is unique
   */
  @SuppressWarnings("unchecked")
  private boolean checkSortIdUniqueness(CoiNoteType newCoiNoteType) {
    boolean isValid = true;

    Integer groupSortId = newCoiNoteType.getSortId();

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

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

    return isValid;
  }
 public void setLocation(NegotiationLocation location) {
   if (!ObjectUtils.equals(this.location, location)) {
     updated = true;
   }
   this.location = location;
 }
 public void setLocationId(Long locationId) {
   if (!ObjectUtils.equals(this.locationId, locationId)) {
     updated = true;
   }
   this.locationId = locationId;
 }
 public void setActivityTypeId(Long activityTypeId) {
   if (!ObjectUtils.equals(this.activityTypeId, activityTypeId)) {
     updated = true;
   }
   this.activityTypeId = activityTypeId;
 }
 public void setEndDate(Date endDate) {
   if (!ObjectUtils.equals(this.endDate, endDate)) {
     updated = true;
   }
   this.endDate = endDate;
 }
 public void setDescription(String description) {
   if (!ObjectUtils.equals(this.description, description)) {
     updated = true;
   }
   this.description = description;
 }
 public void setStartDate(Date startDate) {
   if (!ObjectUtils.equals(this.startDate, startDate)) {
     updated = true;
   }
   this.startDate = startDate;
 }
Esempio n. 26
0
 @Override
 public boolean equals(Object o) {
   PointValueTime that = (PointValueTime) o;
   if (time != that.time) return false;
   return ObjectUtils.equals(value, that.value);
 }
 public void setFollowupDate(Date followupDate) {
   if (!ObjectUtils.equals(this.followupDate, followupDate)) {
     updated = true;
   }
   this.followupDate = followupDate;
 }
Esempio n. 28
0
 @Override
 public boolean sameValueAs(Contato other) {
   return other != null && ObjectUtils.equals(telefone, other.telefone);
 }
 public void setRestricted(Boolean restricted) {
   if (!ObjectUtils.equals(this.restricted, restricted)) {
     updated = true;
   }
   this.restricted = restricted;
 }
Esempio n. 30
0
  private void savePointValue(
      PointValueTime newValue, SetPointSource source, boolean async, boolean saveToDatabase) {
    // Null values are not very nice, and since they don't have a specific meaning they are hereby
    // ignored.
    if (newValue == null) return;

    // Check the data type of the value against that of the locator, just for fun.
    int valueDataType = DataTypes.getDataType(newValue.getValue());
    if (valueDataType != DataTypes.UNKNOWN && valueDataType != vo.getPointLocator().getDataTypeId())
      // This should never happen, but if it does it can have serious downstream consequences. Also,
      // we need
      // to know how it happened, and the stack trace here provides the best information.
      throw new ShouldNeverHappenException(
          "Data type mismatch between new value and point locator: newValue="
              + DataTypes.getDataType(newValue.getValue())
              + ", locator="
              + vo.getPointLocator().getDataTypeId());

    // Check if this value qualifies for discardation.
    if (vo.isDiscardExtremeValues()
        && DataTypes.getDataType(newValue.getValue()) == DataTypes.NUMERIC) {
      double newd = newValue.getDoubleValue();
      if (newd < vo.getDiscardLowLimit() || newd > vo.getDiscardHighLimit())
        // Discard the value
        return;
    }

    if (newValue.getTime() > System.currentTimeMillis() + SystemSettingsDao.getFutureDateLimit()) {
      // Too far future dated. Toss it. But log a message first.
      LOG.warn(
          "Future dated value detected: pointId="
              + vo.getId()
              + ", value="
              + newValue.getStringValue()
              + ", type="
              + vo.getPointLocator().getDataTypeId()
              + ", ts="
              + newValue.getTime(),
          new Exception());
      return;
    }

    boolean backdated = pointValue != null && newValue.getTime() < pointValue.getTime();

    // Determine whether the new value qualifies for logging.
    boolean logValue;
    // ... or even saving in the cache.
    boolean saveValue = true;
    switch (vo.getLoggingType()) {
      case DataPointVO.LoggingTypes.ON_CHANGE:
        if (pointValue == null) logValue = true;
        else if (backdated)
          // Backdated. Ignore it
          logValue = false;
        else {
          if (newValue.getValue() instanceof NumericValue) {
            // Get the new double
            double newd = newValue.getDoubleValue();

            // See if the new value is outside of the tolerance.
            double diff = toleranceOrigin - newd;
            if (diff < 0) diff = -diff;

            if (diff > vo.getTolerance()) {
              toleranceOrigin = newd;
              logValue = true;
            } else logValue = false;
          } else logValue = !ObjectUtils.equals(newValue.getValue(), pointValue.getValue());
        }

        saveValue = logValue;
        break;
      case DataPointVO.LoggingTypes.ALL:
        logValue = true;
        break;
      case DataPointVO.LoggingTypes.ON_TS_CHANGE:
        if (pointValue == null) logValue = true;
        else if (backdated)
          // Backdated. Ignore it
          logValue = false;
        else logValue = newValue.getTime() != pointValue.getTime();

        saveValue = logValue;
        break;
      case DataPointVO.LoggingTypes.INTERVAL:
        if (!backdated) intervalSave(newValue);
      default:
        logValue = false;
    }

    if (!saveToDatabase) logValue = false;

    if (saveValue) valueCache.savePointValue(newValue, source, logValue, async);

    // add annotation to newValue before firing events so event detectors can
    // fetch the annotation
    if (source != null) {
      newValue =
          new AnnotatedPointValueTime(
              newValue.getValue(), newValue.getTime(), source.getSetPointSourceMessage());
    }

    // Ignore historical values.
    if (pointValue == null || newValue.getTime() >= pointValue.getTime()) {
      PointValueTime oldValue = pointValue;
      pointValue = newValue;
      fireEvents(oldValue, newValue, source != null, false);
    } else fireEvents(null, newValue, false, true);
  }