static boolean isRelationshipField(ISearchField field) {
   if (AbstractSearchField.class.isInstance(field)) {
     AbstractSearchField selection = (AbstractSearchField) field;
     return selection.getRootField().getDataType().equals(DataTypeEnum.RELATIONSHIP)
         && (selection.getInnerField() == null
             || selection.getInnerField().equals(InternalFieldEnum.ID.getDbName()));
   }
   return false;
 }
Example #2
0
  @Override
  public boolean isIndexUsable(ISearchField field, MetaClass metaClass) {
    Collection<IndexInfo> indexes = metaClass.getIndexesOnField(field.getFieldName());
    for (IndexInfo index : indexes) {
      String firstKey = index.getKeyList().get(0);
      MetaField metaField = metaClass.getFieldByName(firstKey);

      String physicalKeyName = getFieldValueName(metaField);
      if (metaField.getDataType().equals(DataTypeEnum.RELATIONSHIP)) {
        physicalKeyName =
            metaField.getFlattenValueDbName()
                + AbstractEntityIDHelper.DOT
                + InternalFieldEnum.ID.getDbName();
      }
      if (physicalKeyName.equals(field.getFullDbName())) {
        return true;
      }
    }
    return false;
  }