예제 #1
0
 private boolean lookupEquals(LookupDto a, LookupDto b) {
   return a != null
       && b != null
       && // NO CHECKSTYLE Boolean expression complexity
       Objects.equals(a.getLookupName(), b.getLookupName())
       && Objects.equals(a.isSingleObjectReturn(), b.isSingleObjectReturn())
       && Objects.equals(a.isExposedViaRest(), b.isExposedViaRest())
       && Objects.equals(a.isReadOnly(), b.isReadOnly())
       && Objects.equals(a.getMethodName(), b.getMethodName())
       && Objects.equals(a.isReferenced(), b.isReferenced())
       && lookupFieldsEqual(a.getLookupFields(), b.getLookupFields());
 }
예제 #2
0
  /**
   * Returns true if lookups are different, false otherwise. It compares only read-only lookups,
   * that created in the code by developer.
   *
   * @param entityId the id of entity
   * @param newLookups the newLookups defined in the code
   * @return true if lookups are different, false otherwise.
   */
  public boolean lookupsDiffer(Long entityId, List<LookupDto> newLookups) {
    List<LookupDto> existingLookups = entityService.getEntityLookups(entityId);
    Map<String, LookupDto> entityLookupsMappings = new HashMap<>();

    for (LookupDto entityLookup : existingLookups) {
      if (entityLookup.isReadOnly()) {
        entityLookupsMappings.put(entityLookup.getLookupName(), entityLookup);
      }
    }

    if (entityLookupsMappings.size() != newLookups.size()) {
      return true;
    }

    for (LookupDto lookup : newLookups) {
      if (!lookupEquals(lookup, entityLookupsMappings.get(lookup.getLookupName()))) {
        return true;
      }
    }

    return false;
  }