コード例 #1
0
 @Override
 public boolean equals(Object obj) {
   if (this == obj) {
     return true;
   }
   if (obj == null || !(obj instanceof EffectiveDateInterval)) {
     return false;
   }
   EffectiveDateInterval other = (EffectiveDateInterval) obj;
   if (endDate == null) {
     if (other.endDate != null) {
       return false;
     }
   } else if (!endDate.equals(other.endDate)) {
     return false;
   }
   if (startDate == null) {
     if (other.startDate != null) {
       return false;
     }
   } else if (!startDate.equals(other.startDate)) {
     return false;
   }
   return true;
 }
コード例 #2
0
ファイル: AnalysisBuilder.java プロジェクト: MayoClinic/swift
  @Override
  public boolean equals(final Object o) {
    if (this == o) {
      return true;
    }
    if (o == null || getClass() != o.getClass()) {
      return false;
    }

    final AnalysisBuilder that = (AnalysisBuilder) o;

    if (analysisDate != null
        ? !analysisDate.equals(that.analysisDate)
        : that.analysisDate != null) {
      return false;
    }
    if (biologicalSamples != null
        ? !biologicalSamples.equals(that.biologicalSamples)
        : that.biologicalSamples != null) {
      return false;
    }
    if (reportData != null ? !reportData.equals(that.reportData) : that.reportData != null) {
      return false;
    }
    if (scaffoldVersion != null
        ? !scaffoldVersion.equals(that.scaffoldVersion)
        : that.scaffoldVersion != null) {
      return false;
    }

    return true;
  }
コード例 #3
0
  private DateTime scheduleMonthly(DateTime now) {
    DateTime nowMidnight = now.toDateMidnight().toDateTime();

    if (schedule.getByDayOfMonth()) {
      int nowDOM = nowMidnight.getDayOfMonth();
      if (nowDOM == schedule.getDayOfMonth()) {
        DateTime nextTimeToday = getNextTimeToday(now, nowMidnight);
        if (nextTimeToday != null) {
          return nextTimeToday;
        }
      }
      DateTime nextDay = getNextScheduleDay(nowMidnight.plusDays(1));
      return getFirstScheduledTimeOnDay(nextDay);
    } else {
      DateTime nextDay = getNextScheduleDay(nowMidnight);
      if (nextDay.equals(nowMidnight)) {
        DateTime nextTimeToday = getNextTimeToday(now, nextDay);
        if (nextTimeToday != null) {
          return nextTimeToday;
        }
        nextDay = getNextScheduleDay(nowMidnight.plusDays(1));
        return getFirstScheduledTimeOnDay(nextDay);
      } else {
        return getFirstScheduledTimeOnDay(nextDay);
      }
    }
  }
コード例 #4
0
  /**
   * Given that the date is in a non-moratorium holiday, shift it past the holiday until either it
   * is no longer in a holiday or moratorium, or until it no longer moves (e.g., lands in a same-day
   * holiday).
   *
   * <p>If the date shifts into a moratorium period, then shift it out using the RepaymentRuleType
   * of the most recent non-moratorium holiday that the date was shifted out of. For example, if
   * shifting the date out of a next-working-day holiday lands it in a moratorium period, then use
   * the next-working-day repayment rule to shift it past the moratorium period.
   *
   * @param date the DateTime to be shifted
   * @return the shifted date
   */
  private DateTime shiftDatePastNonMoratoriumHoliday(DateTime date) {

    assert date != null;
    assert isEnclosedByAHoliday(date);
    assert !isEnclosedByAHolidayWithRepaymentRule(date, RepaymentRuleTypes.REPAYMENT_MORATORIUM);

    Holiday currentlyEnclosingHoliday = getHolidayEnclosing(date);
    RepaymentRuleTypes mostRecentNonMoratoriumRepaymentRule =
        currentlyEnclosingHoliday.getRepaymentRuleType(); // never REPAYMENT_MORATORIUM
    DateTime previousDate = null;
    DateTime adjustedDate = date;

    do {
      previousDate = adjustedDate;
      if (currentlyEnclosingHoliday.getRepaymentRuleType()
          == RepaymentRuleTypes.REPAYMENT_MORATORIUM) {
        adjustedDate =
            buildHolidayFromCurrentHolidayWithRepaymentRule(
                    currentlyEnclosingHoliday, mostRecentNonMoratoriumRepaymentRule)
                .adjust(previousDate, workingDays, scheduledEvent);
      } else {
        adjustedDate = currentlyEnclosingHoliday.adjust(previousDate, workingDays, scheduledEvent);
        mostRecentNonMoratoriumRepaymentRule = currentlyEnclosingHoliday.getRepaymentRuleType();
      }
      if (isEnclosedByAHoliday(adjustedDate)) {
        currentlyEnclosingHoliday = getHolidayEnclosing(adjustedDate);
      }
    } while (isEnclosedByAHoliday(adjustedDate) && (!adjustedDate.equals(previousDate)));

    return adjustedDate;
  }
コード例 #5
0
 @Override
 public boolean equals(Object obj) {
   if (this == obj) return true;
   if (obj == null) return false;
   if (!(obj instanceof AlarmStateHistory)) return false;
   AlarmStateHistory other = (AlarmStateHistory) obj;
   if (alarmId == null) {
     if (other.alarmId != null) return false;
   } else if (!alarmId.equals(other.alarmId)) return false;
   if (metrics == null) {
     if (other.metrics != null) return false;
   } else if (!metrics.equals(other.metrics)) return false;
   if (newState != other.newState) return false;
   if (oldState != other.oldState) return false;
   if (subAlarms == null) {
     if (other.subAlarms != null) return false;
   } else if (!subAlarms.equals(other.subAlarms)) return false;
   if (reason == null) {
     if (other.reason != null) return false;
   } else if (!reason.equals(other.reason)) return false;
   if (reasonData == null) {
     if (other.reasonData != null) return false;
   } else if (!reasonData.equals(other.reasonData)) return false;
   if (timestamp == null) {
     if (other.timestamp != null) return false;
   } else if (!timestamp.equals(other.timestamp)) return false;
   return true;
 }
コード例 #6
0
  /**
   * Read all PeMS data in the given time range and having a VDS ID in the given list.
   *
   * @see #read() if you want a transaction and logging around the operation.
   */
  public PeMSSet readSet(Interval interval, List<Long> vdsIds) throws DatabaseException {
    PeMSSet set = new PeMSSet();
    List<PeMSMap> mapList = set.getPemsMapList();

    PeMS pems;
    String query = null;

    try {
      query = runQuerySet(interval, vdsIds);
      org.joda.time.DateTime prevTime = null;
      PeMSMap map = null;

      while (null != (pems = pemsFromQueryRS(query))) {
        org.joda.time.DateTime curTime = pems.getJodaTimeMeasured();

        if (map == null || !prevTime.equals(curTime)) {
          map = new PeMSMap();
          mapList.add(map);
          prevTime = curTime;
        }

        map.getMap().put(pems.getVdsId().toString(), pems);
      }
    } finally {
      if (query != null) {
        dbr.psDestroy(query);
      }
    }

    return set;
  }
コード例 #7
0
ファイル: Pending.java プロジェクト: henrypoter/spring_aop
  @Override
  public void tick(WorkItem item) {
    DateTime now = BusinessDateTimeFactory.now();

    if (now.equals(item.start) || now.isAfter(item.start)) {
      item.tryToStart();
    }
  }
コード例 #8
0
  @Override
  public boolean equals(Object o) {
    if (this == o) return true;
    if (o == null || getClass() != o.getClass()) return false;

    ContactAudit that = (ContactAudit) o;

    if (version != that.version) return false;
    if (!birthDate.equals(that.birthDate)) return false;
    if (!createdBy.equals(that.createdBy)) return false;
    if (!createdDate.equals(that.createdDate)) return false;
    if (!firstName.equals(that.firstName)) return false;
    if (!lastModifiedBy.equals(that.lastModifiedBy)) return false;
    if (!lastModifiedDate.equals(that.lastModifiedDate)) return false;
    if (!lastName.equals(that.lastName)) return false;

    return true;
  }
コード例 #9
0
  private static Path<Integer> spacesAvailableAt(DateTime timestamp) {
    // Also other parts of this class assume prediction resolution,
    // so we don't do the rounding here, but require the timestamp
    // to already have been properly rounded.
    assert timestamp.equals(toPredictionResolution(timestamp))
        : "not in prediction resolution: " + timestamp;

    String hhmm = DateTimeFormat.forPattern("HHmm").print(timestamp.withZone(DateTimeZone.UTC));
    return spacesAvailableColumnsByHHmm.get(hhmm);
  }
コード例 #10
0
 @Override
 public boolean equals(Object obj) {
   if (this == obj) return true;
   if (obj == null) return false;
   if (getClass() != obj.getClass()) return false;
   DateTimeFloored other = (DateTimeFloored) obj;
   if (flooredDate == null) {
     if (other.flooredDate != null) return false;
   } else if (!flooredDate.equals(other.flooredDate)) return false;
   return true;
 }
コード例 #11
0
ファイル: ExecutionTime.java プロジェクト: kallem/cron-utils
 /**
  * Provide nearest date for next execution.
  *
  * @param date - jodatime DateTime instance. If null, a NullPointerException will be raised.
  * @return DateTime instance, never null. Next execution time.
  */
 public DateTime nextExecution(DateTime date) {
   Validate.notNull(date);
   try {
     DateTime nextMatch = nextClosestMatch(date);
     if (nextMatch.equals(date)) {
       nextMatch = nextClosestMatch(date.plusSeconds(1));
     }
     return nextMatch;
   } catch (NoSuchValueException e) {
     throw new IllegalArgumentException(e);
   }
 }
コード例 #12
0
ファイル: ExecutionTime.java プロジェクト: kallem/cron-utils
 /**
  * Provide nearest date for last execution.
  *
  * @param date - jodatime DateTime instance. If null, a NullPointerException will be raised.
  * @return DateTime instance, never null. Last execution time.
  */
 public DateTime lastExecution(DateTime date) {
   Validate.notNull(date);
   try {
     DateTime previousMatch = previousClosestMatch(date);
     if (previousMatch.equals(date)) {
       previousMatch = previousClosestMatch(date.minusSeconds(1));
     }
     return previousMatch;
   } catch (NoSuchValueException e) {
     throw new IllegalArgumentException(e);
   }
 }
コード例 #13
0
ファイル: VtGateIT.java プロジェクト: henryanand/vitess
  @Test
  public void testDateFieldTypes() throws Exception {
    DateTime dt = DateTime.now().minusDays(2).withMillisOfSecond(0);
    Util.insertRows(testEnv, 10, 1, dt);
    VtGate vtgate = VtGate.connect("localhost:" + testEnv.port, 0);
    Query allRowsQuery =
        new QueryBuilder("select * from vtgate_test", testEnv.keyspace, "master")
            .setKeyspaceIds(testEnv.getAllKeyspaceIds())
            .build();
    Row row = vtgate.execute(allRowsQuery).next();
    Assert.assertTrue(dt.equals(row.getDateTime("timestamp_col")));
    Assert.assertTrue(dt.equals(row.getDateTime("datetime_col")));
    Assert.assertTrue(
        dt.withHourOfDay(0)
            .withMinuteOfHour(0)
            .withSecondOfMinute(0)
            .equals(row.getDateTime("date_col")));
    Assert.assertTrue(
        dt.withYear(1970).withMonthOfYear(1).withDayOfMonth(1).equals(row.getDateTime("time_col")));

    vtgate.close();
  }
コード例 #14
0
 /**
  *
  * <!-- begin-user-doc -->
  * <!-- end-user-doc -->
  *
  * @generated
  */
 @Override
 public boolean eIsSet(int featureID) {
   switch (featureID) {
     case StoryPackage.STORY__ID:
       return ID_EDEFAULT == null ? id != null : !ID_EDEFAULT.equals(id);
     case StoryPackage.STORY__CREATION_TIME:
       return CREATION_TIME_EDEFAULT == null
           ? creationTime != null
           : !CREATION_TIME_EDEFAULT.equals(creationTime);
     case StoryPackage.STORY__MODIFICATION_TIME:
       return MODIFICATION_TIME_EDEFAULT == null
           ? modificationTime != null
           : !MODIFICATION_TIME_EDEFAULT.equals(modificationTime);
     case StoryPackage.STORY__SCHEMA_VERSION:
       return schemaVersion != SCHEMA_VERSION_EDEFAULT;
     case StoryPackage.STORY__STATUS:
       return status != STATUS_EDEFAULT;
     case StoryPackage.STORY__ACTION:
       return action != null;
     case StoryPackage.STORY__OWNER:
       return owner != null;
     case StoryPackage.STORY__SUBJECTS:
       return subjects != null && !subjects.isEmpty();
     case StoryPackage.STORY__RECEIVERS:
       return isSetReceivers();
     case StoryPackage.STORY__ATTACHMENTS:
       return attachments != null && !attachments.isEmpty();
     case StoryPackage.STORY__SUBJECT:
       return basicGetSubject() != null;
     case StoryPackage.STORY__RECEIVER:
       return basicGetReceiver() != null;
     case StoryPackage.STORY__ATTACHMENT:
       return basicGetAttachment() != null;
   }
   return super.eIsSet(featureID);
 }
コード例 #15
0
ファイル: Vouch.java プロジェクト: ayax79/bb
  @Override
  public boolean equals(Object o) {
    if (this == o) return true;
    if (o == null || getClass() != o.getClass()) return false;
    if (!super.equals(o)) return false;

    Vouch vouch = (Vouch) o;

    if (accepted != vouch.accepted) return false;
    if (count != vouch.count) return false;
    if (expirationDate != null
        ? !expirationDate.equals(vouch.expirationDate)
        : vouch.expirationDate != null) return false;
    if (target != null ? !target.equals(vouch.target) : vouch.target != null) return false;
    if (voucher != null ? !voucher.equals(vouch.voucher) : vouch.voucher != null) return false;

    return true;
  }
コード例 #16
0
 @Override
 public boolean equals(Object obj) {
   if (this == obj) return true;
   if (obj == null) return false;
   if (getClass() != obj.getClass()) return false;
   ListableContainerPropertiesImpl other = (ListableContainerPropertiesImpl) obj;
   if (eTag == null) {
     if (other.eTag != null) return false;
   } else if (!eTag.equals(other.eTag)) return false;
   if (lastModified == null) {
     if (other.lastModified != null) return false;
   } else if (!lastModified.equals(other.lastModified)) return false;
   if (name == null) {
     if (other.name != null) return false;
   } else if (!name.equals(other.name)) return false;
   if (url == null) {
     if (other.url != null) return false;
   } else if (!url.equals(other.url)) return false;
   return true;
 }
コード例 #17
0
  // TODO the else pathway below will return only the top level members and not resolve the nested
  // roles + groups.
  private List<Map<String, String>> getRoleQualifiers(
      String principalId,
      List<String> roleIds,
      Map<String, String> qualifiers,
      DateTime asOfDate,
      boolean activeOnly) {
    List<Map<String, String>> roleQualifiers = new ArrayList<Map<String, String>>();

    if (CollectionUtils.isNotEmpty(roleIds)) {
      if (asOfDate.equals(LocalDate.now().toDateTimeAtStartOfDay()) && activeOnly) {
        List<String> groupIds = getGroupService().getGroupIdsByPrincipalId(principalId);
        List<RoleMembership> principalAndGroupRoleMembers =
            getRoleService().getRoleMembers(roleIds, qualifiers);
        for (RoleMembership roleMember : principalAndGroupRoleMembers) {
          // check for principals or groups
          if (MemberType.PRINCIPAL.equals(roleMember.getType())) {
            if (roleMember.getMemberId().equals(principalId)) {
              roleQualifiers.add(roleMember.getQualifier());
            }
          } else if ((MemberType.GROUP.equals(roleMember.getType()))
              && (CollectionUtils.isNotEmpty(groupIds))) {
            if (groupIds.contains(roleMember.getMemberId())) {
              roleQualifiers.add(roleMember.getQualifier());
            }
          }
        }
      } else {
        List<RoleMember> principalIdRoleMembers =
            getPrincipalIdRoleMembers(principalId, roleIds, asOfDate, activeOnly);
        for (RoleMember principalIdRoleMember : principalIdRoleMembers) {
          roleQualifiers.add(principalIdRoleMember.getAttributes());
        }
      }
    }

    return roleQualifiers;
  }
コード例 #18
0
 @Override
 public boolean equals(Object obj) {
   if (this == obj) return true;
   if (obj == null) return false;
   if (getClass() != obj.getClass()) return false;
   DefaultBlockingState other = (DefaultBlockingState) obj;
   if (blockBilling != other.blockBilling) return false;
   if (blockChange != other.blockChange) return false;
   if (blockEntitlement != other.blockEntitlement) return false;
   if (blockingId == null) {
     if (other.blockingId != null) return false;
   } else if (!blockingId.equals(other.blockingId)) return false;
   if (service == null) {
     if (other.service != null) return false;
   } else if (!service.equals(other.service)) return false;
   if (stateName == null) {
     if (other.stateName != null) return false;
   } else if (!stateName.equals(other.stateName)) return false;
   if (timestamp == null) {
     if (other.timestamp != null) return false;
   } else if (!timestamp.equals(other.timestamp)) return false;
   if (type != other.type) return false;
   return true;
 }
コード例 #19
0
  @Override
  public SupplierInfoChangedDto baseCompanyChanged(
      Long userId,
      CompanyDto updatedCompanyDto,
      Company oldCompany,
      List<CompanyMainBusiness> oldMainBusinesses,
      List<CompanySupplyPark> oldSupplyParks) {
    SupplierInfoChangedDto supplierInfoChangedDto = new SupplierInfoChangedDto();

    Company updatedCompany = updatedCompanyDto.getCompany();
    List<CompanyMainBusiness> updatedMainBusinesses = updatedCompanyDto.getCompanyMainBusinesses();
    List<CompanySupplyPark> updatedSupplyParks = updatedCompanyDto.getCompanySupplyParks();

    // 取出新的信息
    CompanyDto newCompanyDto =
        getNewBaseCompany(userId, oldCompany, oldMainBusinesses, oldSupplyParks).getSupplierInfo();
    Company newCompany = newCompanyDto.getCompany();
    List<CompanyMainBusiness> newMainBusinesses = newCompanyDto.getCompanyMainBusinesses();
    List<CompanySupplyPark> newSupplyParks = newCompanyDto.getCompanySupplyParks();

    Map<String, String> changedInfo = Maps.newHashMap();

    if (!Objects.equal(updatedCompany.getCorporation(), newCompany.getCorporation())) {
      changedInfo.put(ChangedInfoKeys.companyCorporation(), updatedCompany.getCorporation());
      updatedCompany.setCorporation(null);
    }

    if (!Objects.equal(updatedCompany.getInitAgent(), newCompany.getInitAgent())) {
      changedInfo.put(ChangedInfoKeys.companyInitAgent(), updatedCompany.getInitAgent());
      updatedCompany.setInitAgent(null);
    }

    if (!Objects.equal(updatedCompany.getDesc(), newCompany.getDesc())) {
      changedInfo.put(ChangedInfoKeys.companyDesc(), updatedCompany.getDesc());
      updatedCompany.setDesc(null);
    }

    if (!Objects.equal(updatedCompany.getRegCountry(), newCompany.getRegCountry())) {
      changedInfo.put(
          ChangedInfoKeys.companyRegCountry(), String.valueOf(updatedCompany.getRegCountry()));
      updatedCompany.setRegCountry(null);
    }

    //        if (!Objects.equal(company.getCustomers(), newCompany.getCustomers())) {
    //            changedInfo.put("", newCompany.getCustomers());
    //        }
    //
    if (!Objects.equal(updatedCompany.getProductLine(), newCompany.getProductLine())) {
      changedInfo.put(ChangedInfoKeys.companyProductLine(), updatedCompany.getProductLine());
    }

    if (mainBusinessChanged(updatedMainBusinesses, newMainBusinesses)) {
      changedInfo.put(
          ChangedInfoKeys.companyMainBusiness(),
          JsonMapper.nonEmptyMapper().toJson(updatedMainBusinesses));
    }

    if (supplyParkChanged(updatedSupplyParks, newSupplyParks)) {
      changedInfo.put(
          ChangedInfoKeys.companySupplyPark(),
          JsonMapper.nonEmptyMapper().toJson(updatedSupplyParks));
    }

    // 如果有V码,则继续检查合同信息
    if (!Strings.isNullOrEmpty(newCompany.getSupplierCode())) {

      if (!Objects.equal(updatedCompany.getGroupName(), newCompany.getGroupName())) {
        changedInfo.put(ChangedInfoKeys.companyGroupName(), updatedCompany.getGroupName());
        updatedCompany.setGroupName(null);
      }
      if (!Objects.equal(updatedCompany.getGroupAddr(), newCompany.getGroupAddr())) {
        changedInfo.put(ChangedInfoKeys.companyGroupAddr(), updatedCompany.getGroupAddr());
        updatedCompany.setGroupAddr(null);
      }
      if (!Objects.equal(updatedCompany.getRegCapital(), newCompany.getRegCapital())) {
        changedInfo.put(
            ChangedInfoKeys.companyRegCapical(), String.valueOf(updatedCompany.getRegCapital()));
        updatedCompany.setRegCapital(null);
      }
      if (!Objects.equal(updatedCompany.getRcCoinType(), newCompany.getRcCoinType())) {
        changedInfo.put(
            ChangedInfoKeys.companyRcCoinType(), String.valueOf(updatedCompany.getRcCoinType()));
        updatedCompany.setRcCoinType(null);
      }
      if (!Objects.equal(updatedCompany.getPersonScale(), newCompany.getPersonScale())) {
        changedInfo.put(ChangedInfoKeys.companyPersonScale(), updatedCompany.getPersonScale());
        updatedCompany.setPersonScale(null);
      }
      if (!Objects.equal(updatedCompany.getRegProvince(), newCompany.getRegProvince())) {
        changedInfo.put(
            ChangedInfoKeys.companyRegProvince(), String.valueOf(updatedCompany.getRegProvince()));
        updatedCompany.setRegProvince(null);
      }
      if (!Objects.equal(updatedCompany.getRegCity(), newCompany.getRegCity())) {
        changedInfo.put(
            ChangedInfoKeys.companyRegCity(), String.valueOf(updatedCompany.getRegCity()));
        updatedCompany.setRegCity(null);
      }
      if (!Objects.equal(updatedCompany.getFixedAssets(), newCompany.getFixedAssets())) {
        changedInfo.put(
            ChangedInfoKeys.companyFixedAssets(), String.valueOf(updatedCompany.getFixedAssets()));
        updatedCompany.setFixedAssets(null);
      }
      if (!Objects.equal(updatedCompany.getFaCoinType(), newCompany.getFaCoinType())) {
        changedInfo.put(
            ChangedInfoKeys.companyFaCoinType(), String.valueOf(updatedCompany.getFaCoinType()));
        updatedCompany.setFaCoinType(null);
      }

      Date updatedFoundAt = updatedCompany.getFoundAt();
      Date oldFoundAt = newCompany.getFoundAt();
      if (updatedFoundAt != null) {
        DateTime updated = new DateTime(updatedFoundAt);
        if (oldFoundAt == null) {
          changedInfo.put(ChangedInfoKeys.companyFoundAt(), updated.toString(FORMATTER));
          updatedCompany.setFoundAt(null);
        } else {
          DateTime old = new DateTime(oldFoundAt);
          if (!updated.equals(old)) {
            changedInfo.put(ChangedInfoKeys.companyFoundAt(), updated.toString(FORMATTER));
            updatedCompany.setFoundAt(null);
          }
        }
      }

      if (!Objects.equal(updatedCompany.getOfficialWebsite(), newCompany.getOfficialWebsite())) {
        changedInfo.put(
            ChangedInfoKeys.companyOfficialWebSite(), updatedCompany.getOfficialWebsite());
        updatedCompany.setOfficialWebsite(null);
      }
      if (!Objects.equal(updatedCompany.getNature(), newCompany.getNature())) {
        changedInfo.put(
            ChangedInfoKeys.companyNature(), String.valueOf(updatedCompany.getNature()));
        updatedCompany.setNature(null);
      }
      if (!Objects.equal(updatedCompany.getWorldTop(), newCompany.getWorldTop())) {
        changedInfo.put(
            ChangedInfoKeys.companyWorldTop(), String.valueOf(updatedCompany.getWorldTop()));
        updatedCompany.setWorldTop(null);
      }
      if (!Objects.equal(updatedCompany.getListedStatus(), newCompany.getListedStatus())) {
        changedInfo.put(
            ChangedInfoKeys.companyListedStatus(),
            String.valueOf(updatedCompany.getListedStatus()));
        updatedCompany.setListedStatus(null);
      }
      if (!Objects.equal(updatedCompany.getListedRegion(), newCompany.getListedRegion())) {
        changedInfo.put(ChangedInfoKeys.companyListedRegion(), updatedCompany.getListedRegion());
        updatedCompany.setListedRegion(null);
      }
      if (!Objects.equal(updatedCompany.getTicker(), newCompany.getTicker())) {
        changedInfo.put(ChangedInfoKeys.companyTicker(), updatedCompany.getTicker());
        updatedCompany.setTicker(null);
      }
    }

    if (!changedInfo.isEmpty()) {
      supplierInfoChangedDto.setChanged(true);
      supplierInfoChangedDto.setChangedInfo(changedInfo);
    }

    return supplierInfoChangedDto;
  }
コード例 #20
0
  @Override
  public boolean equals(final Object o) {
    if (this == o) {
      return true;
    }
    if (o == null || getClass() != o.getClass()) {
      return false;
    }

    final Subscription that = (Subscription) o;

    if (account != null ? !account.equals(that.account) : that.account != null) {
      return false;
    }
    if (activatedAt != null ? !activatedAt.equals(that.activatedAt) : that.activatedAt != null) {
      return false;
    }
    if (addOns != null ? !addOns.equals(that.addOns) : that.addOns != null) {
      return false;
    }
    if (canceledAt != null ? !canceledAt.equals(that.canceledAt) : that.canceledAt != null) {
      return false;
    }
    if (currency != null ? !currency.equals(that.currency) : that.currency != null) {
      return false;
    }
    if (currentPeriodEndsAt != null
        ? !currentPeriodEndsAt.equals(that.currentPeriodEndsAt)
        : that.currentPeriodEndsAt != null) {
      return false;
    }
    if (currentPeriodStartedAt != null
        ? !currentPeriodStartedAt.equals(that.currentPeriodStartedAt)
        : that.currentPeriodStartedAt != null) {
      return false;
    }
    if (expiresAt != null ? !expiresAt.equals(that.expiresAt) : that.expiresAt != null) {
      return false;
    }
    if (plan != null ? !plan.equals(that.plan) : that.plan != null) {
      return false;
    }
    if (quantity != null ? !quantity.equals(that.quantity) : that.quantity != null) {
      return false;
    }

    if (state != null ? !state.equals(that.state) : that.state != null) {
      return false;
    }

    if (trialEndsAt != null ? !trialEndsAt.equals(that.trialEndsAt) : that.trialEndsAt != null) {
      return false;
    }
    if (trialStartedAt != null
        ? !trialStartedAt.equals(that.trialStartedAt)
        : that.trialStartedAt != null) {
      return false;
    }
    if (unitAmountInCents != null
        ? !unitAmountInCents.equals(that.unitAmountInCents)
        : that.unitAmountInCents != null) {
      return false;
    }
    if (uuid != null ? !uuid.equals(that.uuid) : that.uuid != null) {
      return false;
    }

    return true;
  }
コード例 #21
0
  private static List<AttributeStatement> validateAssertion(
      Assertion samlAssertion,
      SignatureTrustEngine sigTrustEngine,
      String myURI,
      MessageReplayRule replayRule,
      VerifySignatureType verifySignature,
      boolean responseSignatureVerified)
      throws SAMLValidationException {
    if (logger.isDebugEnabled()) {
      logger.debug(
          "validateAndExtractContext(Assertion, String, SignatureTrustEngine, String, MessageReplayRule, VerifySignatureType) - start"); //$NON-NLS-1$
    }

    // Check the replay attack
    if (replayRule != null) {
      BasicSAMLMessageContext messageContext = new BasicSAMLMessageContext();
      // messageContext.setInboundMessage(samlResponse);
      if (samlAssertion.getIssuer() != null)
        messageContext.setInboundMessageIssuer(samlAssertion.getIssuer().getValue());
      messageContext.setInboundSAMLMessageId(samlAssertion.getID());

      try {
        replayRule.evaluate(messageContext);
      } catch (SecurityPolicyException e) {
        logger.error(
            "validateAndExtractContext(Assertion, String, SignatureTrustEngine, String, MessageReplayRule, VerifySignatureType)",
            e); //$NON-NLS-1$

        throw createSAMLValidationException("Possible Replay Attack for Assertion", false, e);
      }
    }

    if (verifySignature != VerifySignatureType.never) {
      Signature signature = samlAssertion.getSignature();
      if (signature == null) {
        if (verifySignature == VerifySignatureType.force && !responseSignatureVerified) {
          throw createSAMLValidationException("Signature does exist in Assertion", true);
        }
      } else {
        verifySignature(signature, samlAssertion.getIssuer().getValue(), sigTrustEngine);
      }
    }
    DateTime dt = new DateTime();

    // get subject (code below only processes first Subject confirmation)
    Subject subject = samlAssertion.getSubject();
    SubjectSchemaValidator subjectSchemaValidator = new SubjectSchemaValidator();
    try {
      subjectSchemaValidator.validate(subject);
    } catch (ValidationException e) {
      logger.error(
          "validateAndExtractContext(Assertion, String, SignatureTrustEngine, String, MessageReplayRule, VerifySignatureType)",
          e); //$NON-NLS-1$

      throw createSAMLValidationException("Subject validation failed: " + e.getMessage(), true, e);
    }
    List<SubjectConfirmation> subjectConfirmations = subject.getSubjectConfirmations();
    for (SubjectConfirmation subjectConfirmation : subjectConfirmations) {
      SubjectConfirmationSchemaValidator subjectConfirmationSchemaValidator =
          new SubjectConfirmationSchemaValidator();
      try {
        subjectConfirmationSchemaValidator.validate(subjectConfirmation);
      } catch (ValidationException e) {
        logger.error(
            "validateAndExtractContext(Assertion, String, SignatureTrustEngine, String, MessageReplayRule, VerifySignatureType)",
            e); //$NON-NLS-1$

        throw createSAMLValidationException(
            "Subject Confirmation validation failed: " + e.getMessage(), true, e);
      }
      SubjectConfirmationData subjectConfirmationData =
          subjectConfirmation.getSubjectConfirmationData();
      try {
        subjectConfirmationSchemaValidator.validate(subjectConfirmation);
      } catch (ValidationException e) {
        logger.error(
            "validateAndExtractContext(Assertion, String, SignatureTrustEngine, String, MessageReplayRule, VerifySignatureType)",
            e); //$NON-NLS-1$

        throw createSAMLValidationException(
            "Subject Confirmation validation failed: " + e.getMessage(), true, e);
      }

      // verify the validity of time using clock skew, subjectConfirmationData.getNotBefore() and
      // subjectConfirmationData.getNotOnOrAfter()@
      DateTime notBefore = subjectConfirmationData.getNotBefore();
      DateTime notAfter = subjectConfirmationData.getNotOnOrAfter();

      if (notBefore != null && dt.isBefore(notBefore)) {
        throw createSAMLValidationException("Subject confirmation expired.", true);
      }

      if (notAfter != null && (dt.equals(notAfter) || dt.isAfter(notAfter))) {
        throw createSAMLValidationException("Subject confirmation expired.", true);
      }
    }

    //		 validate conditions
    Conditions conditions = samlAssertion.getConditions();

    // Validate the spec

    ConditionsSpecValidator conditionValidator = new ConditionsSpecValidator();
    try {
      conditionValidator.validate(conditions);
    } catch (ValidationException e) {
      logger.error(
          "validateAndExtractContext(Assertion, String, SignatureTrustEngine, String, MessageReplayRule, VerifySignatureType)",
          e); //$NON-NLS-1$

      throw createSAMLValidationException("Condition Validity Failed.", true, e);
    }

    // verify the validity of time using clock skew, conditions.getNotBefore() and
    // conditions.getNotOnOrAfter()@
    DateTime notBefore = conditions.getNotBefore();
    DateTime notAfter = conditions.getNotOnOrAfter();
    if (notBefore != null && dt.isBefore(notBefore)) {
      throw createSAMLValidationException("Assertion expired.", true);
    }

    if (notAfter != null && (dt.equals(notAfter) || dt.isAfter(notAfter))) {
      throw createSAMLValidationException("Assertion expired.", true);
    }

    for (Condition condition : conditions.getConditions()) {
      if (condition instanceof AudienceRestriction) {
        if (myURI != null && myURI.length() > 0) {
          boolean audiencePresent = false;
          boolean iAmOneOfTheAudience = false;
          AudienceRestriction audienceRestriction = (AudienceRestriction) condition;
          for (Audience audience : audienceRestriction.getAudiences()) {
            audiencePresent = true;
            String audienceURI = audience.getAudienceURI();
            if (myURI.equals(audienceURI)) {
              iAmOneOfTheAudience = true;
              break;
            }
          }
          if (!(audiencePresent && iAmOneOfTheAudience)) {
            throw createSAMLValidationException(
                "None of the audience is intended for me: " + myURI, false);
          }
        }
      }
    }

    List<AttributeStatement> asList = samlAssertion.getAttributeStatements();

    if (logger.isDebugEnabled()) {
      logger.debug(
          "validateAndExtractContext(Assertion, String, SignatureTrustEngine, String, MessageReplayRule, VerifySignatureType) - end"); //$NON-NLS-1$
    }
    return asList;
  }
コード例 #22
0
 private boolean isEligible(final SectionType sectionType, final DateTime birthDate) {
   final DateTime startingAge = sectionType.getStartingAge().getBirthDate();
   final DateTime endingAge = sectionType.getEndingAge().getBirthDate();
   return (birthDate.equals(startingAge) || birthDate.isBefore(startingAge))
       && (birthDate.isAfter(endingAge) || birthDate.equals(endingAge));
 }
コード例 #23
0
ファイル: GeocacheLog.java プロジェクト: following5/cmanager
 public boolean equals(GeocacheLog log) {
   return type == log.type
       && date.equals(log.date)
       && author.equals(log.author)
       && text.equals(log.text);
 }
コード例 #24
0
  @Override
  public boolean equals(final Object o) {
    if (this == o) {
      return true;
    }
    if (o == null || getClass() != o.getClass()) {
      return false;
    }
    if (!super.equals(o)) {
      return false;
    }

    final BusinessAccountModelDao that = (BusinessAccountModelDao) o;

    if (address1 != null ? !address1.equals(that.address1) : that.address1 != null) {
      return false;
    }
    if (address2 != null ? !address2.equals(that.address2) : that.address2 != null) {
      return false;
    }
    if (balance != null ? balance.compareTo(that.balance) != 0 : that.balance != null) {
      return false;
    }
    if (billingCycleDayLocal != null
        ? !billingCycleDayLocal.equals(that.billingCycleDayLocal)
        : that.billingCycleDayLocal != null) {
      return false;
    }
    if (city != null ? !city.equals(that.city) : that.city != null) {
      return false;
    }
    if (companyName != null ? !companyName.equals(that.companyName) : that.companyName != null) {
      return false;
    }
    if (country != null ? !country.equals(that.country) : that.country != null) {
      return false;
    }
    if (currency != null ? !currency.equals(that.currency) : that.currency != null) {
      return false;
    }
    if (email != null ? !email.equals(that.email) : that.email != null) {
      return false;
    }
    if (firstNameLength != null
        ? !firstNameLength.equals(that.firstNameLength)
        : that.firstNameLength != null) {
      return false;
    }
    if (lastInvoiceDate != null
        ? !lastInvoiceDate.equals(that.lastInvoiceDate)
        : that.lastInvoiceDate != null) {
      return false;
    }
    if (lastPaymentDate != null
        ? !lastPaymentDate.equals(that.lastPaymentDate)
        : that.lastPaymentDate != null) {
      return false;
    }
    if (lastPaymentStatus != null
        ? !lastPaymentStatus.equals(that.lastPaymentStatus)
        : that.lastPaymentStatus != null) {
      return false;
    }
    if (locale != null ? !locale.equals(that.locale) : that.locale != null) {
      return false;
    }
    if (migrated != null ? !migrated.equals(that.migrated) : that.migrated != null) {
      return false;
    }
    if (nbActiveBundles != null
        ? !nbActiveBundles.equals(that.nbActiveBundles)
        : that.nbActiveBundles != null) {
      return false;
    }
    if (notifiedForInvoices != null
        ? !notifiedForInvoices.equals(that.notifiedForInvoices)
        : that.notifiedForInvoices != null) {
      return false;
    }
    if (paymentMethodId != null
        ? !paymentMethodId.equals(that.paymentMethodId)
        : that.paymentMethodId != null) {
      return false;
    }
    if (phone != null ? !phone.equals(that.phone) : that.phone != null) {
      return false;
    }
    if (postalCode != null ? !postalCode.equals(that.postalCode) : that.postalCode != null) {
      return false;
    }
    if (stateOrProvince != null
        ? !stateOrProvince.equals(that.stateOrProvince)
        : that.stateOrProvince != null) {
      return false;
    }
    if (timeZone != null ? !timeZone.equals(that.timeZone) : that.timeZone != null) {
      return false;
    }
    if (updatedDate != null
        ? (updatedDate.compareTo(that.updatedDate) != 0)
        : that.updatedDate != null) {
      return false;
    }

    return true;
  }
コード例 #25
0
  @Override
  public SupplierInfoChangedDto qualityChanged(
      Long userId, CompanyExtraQuality updatedQuality, CompanyExtraQuality oldQuality) {
    SupplierInfoChangedDto supplierInfoChangedDto = new SupplierInfoChangedDto();

    CompanyExtraQuality newQuality =
        getNewCompanyExtraQuality(userId, oldQuality).getSupplierInfo();

    Map<String, String> changedInfo = Maps.newHashMap();

    if (!Objects.equal(updatedQuality.getRohsId(), newQuality.getRohsId())) {
      changedInfo.put(ChangedInfoKeys.qualityRohsId(), updatedQuality.getRohsId());
      updatedQuality.setRohsId(null);
    }
    if (!Objects.equal(updatedQuality.getRohsAttachUrl(), newQuality.getRohsAttachUrl())) {
      changedInfo.put(ChangedInfoKeys.qualityRohsAttachUrl(), updatedQuality.getRohsAttachUrl());
      updatedQuality.setRohsAttachUrl(null);
    }

    if (updatedQuality.getRohsValidDate() != null) {
      DateTime updatedRohsValidDate = new DateTime(updatedQuality.getRohsValidDate());
      if (newQuality.getRohsValidDate() == null) {
        changedInfo.put(
            ChangedInfoKeys.qualityRohsValidDate(), updatedRohsValidDate.toString(FORMATTER));
        updatedQuality.setRohsValidDate(null);
      } else {
        DateTime oldRohsValidDate = new DateTime(newQuality.getRohsValidDate());
        if (!updatedRohsValidDate.equals(oldRohsValidDate)) {
          changedInfo.put(
              ChangedInfoKeys.qualityRohsValidDate(), updatedRohsValidDate.toString(FORMATTER));
          updatedQuality.setRohsValidDate(null);
        }
      }
    }

    if (!Objects.equal(updatedQuality.getIso9001Id(), newQuality.getIso9001Id())) {
      changedInfo.put(ChangedInfoKeys.qualityISO9001Id(), updatedQuality.getIso9001Id());
      updatedQuality.setIso9001Id(null);
    }
    if (!Objects.equal(updatedQuality.getIso9001AttachUrl(), newQuality.getIso9001AttachUrl())) {
      changedInfo.put(
          ChangedInfoKeys.qualityISO9001AttachUrl(), updatedQuality.getIso9001AttachUrl());
      updatedQuality.setIso9001AttachUrl(null);
    }

    if (updatedQuality.getIso9001ValidDate() != null) {
      DateTime updatedIso9001ValidDate = new DateTime(updatedQuality.getIso9001ValidDate());
      if (newQuality.getIso9001ValidDate() == null) {
        changedInfo.put(
            ChangedInfoKeys.qualityISO9001ValidDate(), updatedIso9001ValidDate.toString(FORMATTER));
        updatedQuality.setIso9001ValidDate(null);
      } else {
        DateTime oldIso9001ValidDate = new DateTime(newQuality.getIso9001ValidDate());
        if (!updatedIso9001ValidDate.equals(oldIso9001ValidDate)) {
          changedInfo.put(
              ChangedInfoKeys.qualityISO9001ValidDate(),
              updatedIso9001ValidDate.toString(FORMATTER));
          updatedQuality.setIso9001ValidDate(null);
        }
      }
    }

    if (!Objects.equal(updatedQuality.getIso14001Id(), newQuality.getIso14001Id())) {
      changedInfo.put(ChangedInfoKeys.qualityISO14001Id(), updatedQuality.getIso14001Id());
      updatedQuality.setIso14001Id(null);
    }
    if (!Objects.equal(updatedQuality.getIso14001AttachUrl(), newQuality.getIso14001AttachUrl())) {
      changedInfo.put(
          ChangedInfoKeys.qualityISO14001AttachUrl(), updatedQuality.getIso14001AttachUrl());
      updatedQuality.setIso14001AttachUrl(null);
    }

    if (updatedQuality.getIso14001ValidDate() != null) {
      DateTime updatedIso14001ValidDate = new DateTime(updatedQuality.getIso14001ValidDate());
      if (newQuality.getIso14001ValidDate() == null) {
        changedInfo.put(
            ChangedInfoKeys.qualityISO14001ValidDate(),
            updatedIso14001ValidDate.toString(FORMATTER));
        updatedQuality.setIso14001ValidDate(null);
      } else {
        DateTime oldIso14001ValidDate = new DateTime(newQuality.getIso14001ValidDate());
        if (!updatedIso14001ValidDate.equals(oldIso14001ValidDate)) {
          changedInfo.put(
              ChangedInfoKeys.qualityISO14001ValidDate(),
              updatedIso14001ValidDate.toString(FORMATTER));
          updatedQuality.setIso14001ValidDate(null);
        }
      }
    }

    if (!Objects.equal(updatedQuality.getTs16949Id(), newQuality.getTs16949Id())) {
      changedInfo.put(ChangedInfoKeys.qualityTS16949Id(), updatedQuality.getTs16949Id());
      updatedQuality.setTs16949Id(null);
    }
    if (!Objects.equal(updatedQuality.getTs16949AttachUrl(), newQuality.getTs16949AttachUrl())) {
      changedInfo.put(
          ChangedInfoKeys.qualityTS16949AttachUrl(), updatedQuality.getTs16949AttachUrl());
      updatedQuality.setTs16949AttachUrl(null);
    }

    if (updatedQuality.getTs16949ValidDate() != null) {
      DateTime updatedTs16949ValidDate = new DateTime(updatedQuality.getTs16949ValidDate());
      if (newQuality.getTs16949ValidDate() == null) {
        changedInfo.put(
            ChangedInfoKeys.qualityTS16949ValidDate(), updatedTs16949ValidDate.toString(FORMATTER));
        updatedQuality.setTs16949ValidDate(null);
      } else {
        DateTime oldTs16949ValidDate = new DateTime(newQuality.getTs16949ValidDate());
        if (!updatedTs16949ValidDate.equals(oldTs16949ValidDate)) {
          changedInfo.put(
              ChangedInfoKeys.qualityTS16949ValidDate(),
              updatedTs16949ValidDate.toString(FORMATTER));
          updatedQuality.setTs16949ValidDate(null);
        }
      }
    }

    if (!changedInfo.isEmpty()) {
      supplierInfoChangedDto.setChanged(true);
      supplierInfoChangedDto.setChangedInfo(changedInfo);
    }
    return supplierInfoChangedDto;
  }
コード例 #26
0
  /**
   * Get the needed datarow from the table.
   *
   * @param tableRowIterator
   * @return the row that is aligned with the expected timestep.
   * @throws IOException if the expected timestep is < than the current.
   */
  private String[] getExpectedRow(TableIterator<String[]> tableRowIterator, DateTime expectedDT)
      throws IOException {
    while (tableRowIterator.hasNext()) {
      String[] row = tableRowIterator.next();
      DateTime currentTimestamp = formatter.parseDateTime(row[1]);
      if (currentTimestamp.equals(expectedDT)) {
        if (pNum == 1) {
          return row;
        } else {
          String[][] allRows = new String[pNum][];
          allRows[0] = row;
          int rowNum = 1;
          for (int i = 1; i < pNum; i++) {
            if (tableRowIterator.hasNext()) {
              String[] nextRow = tableRowIterator.next();
              allRows[i] = nextRow;
              rowNum++;
            }
          }
          // now aggregate
          String[] aggregatedRow = new String[row.length];
          // date is the one of the first instant
          aggregatedRow[0] = allRows[0][0];
          aggregatedRow[1] = allRows[0][1];
          for (int col = 2; col < allRows[0].length; col++) {

            boolean hasOne = false;
            switch (pAggregation) {
              case 0:
                double sum = 0;
                for (int j = 0; j < rowNum; j++) {
                  String valueStr = allRows[j][col];
                  if (!valueStr.equals(fileNovalue)) {
                    double value = Double.parseDouble(valueStr);
                    sum = sum + value;
                    hasOne = true;
                  }
                }
                if (!hasOne) {
                  sum = doubleNovalue;
                }
                aggregatedRow[col] = String.valueOf(sum);
                break;
              case 1:
                double avg = 0;
                for (int j = 0; j < rowNum; j++) {
                  String valueStr = allRows[j][col];
                  if (!valueStr.equals(fileNovalue)) {
                    double value = Double.parseDouble(valueStr);
                    avg = avg + value;
                    hasOne = true;
                  }
                }
                if (!hasOne) {
                  avg = doubleNovalue;
                } else {
                  avg = avg / pNum;
                }
                aggregatedRow[col] = String.valueOf(avg);
                break;

              default:
                break;
            }
          }
          return aggregatedRow;
        }
      } else if (currentTimestamp.isBefore(expectedDT)) {
        // browse until the instant is found
        continue;
      } else if (currentTimestamp.isAfter(expectedDT)) {
        /*
         * lost the moment, for now throw exception.
         * Could be enhanced in future.
         */
        String message =
            "The data are not aligned with the simulation interval ("
                + currentTimestamp
                + "/"
                + expectedDT
                + "). Check your data file: "
                + file;
        throw new IOException(message);
      }
    }
    return null;
  }