Search in sources :

Example 1 with Field

use of org.hibernate.search.annotations.Field in project pyramus by otavanopisto.

the class Person method getLastNameSortable.

@Transient
@Field(analyze = Analyze.NO, store = Store.NO)
@SortableField
public String getLastNameSortable() {
    Student student = getLatestStudent();
    StaffMember staffMember = getStaffMember();
    return student != null ? student.getLastName() : staffMember != null ? staffMember.getLastName() : "";
}
Also used : Student(fi.otavanopisto.pyramus.domainmodel.students.Student) StaffMember(fi.otavanopisto.pyramus.domainmodel.users.StaffMember) SortableField(org.hibernate.search.annotations.SortableField) Field(org.hibernate.search.annotations.Field) SortableField(org.hibernate.search.annotations.SortableField) Transient(javax.persistence.Transient)

Example 2 with Field

use of org.hibernate.search.annotations.Field in project pyramus by otavanopisto.

the class Person method getFirstNameSortable.

@Transient
@Field(analyze = Analyze.NO, store = Store.NO)
@SortableField
public String getFirstNameSortable() {
    Student student = getLatestStudent();
    StaffMember staffMember = getStaffMember();
    return student != null ? student.getFirstName() : staffMember != null ? staffMember.getFirstName() : "";
}
Also used : Student(fi.otavanopisto.pyramus.domainmodel.students.Student) StaffMember(fi.otavanopisto.pyramus.domainmodel.users.StaffMember) SortableField(org.hibernate.search.annotations.SortableField) Field(org.hibernate.search.annotations.Field) SortableField(org.hibernate.search.annotations.SortableField) Transient(javax.persistence.Transient)

Example 3 with Field

use of org.hibernate.search.annotations.Field in project elide by yahoo.

the class SearchDataTransaction method fieldIsIndexed.

private boolean fieldIsIndexed(Type<?> entityClass, FilterPredicate predicate) {
    String fieldName = predicate.getField();
    List<Field> fields = new ArrayList<>();
    Field fieldAnnotation = dictionary.getAttributeOrRelationAnnotation(entityClass, Field.class, fieldName);
    if (fieldAnnotation != null) {
        fields.add(fieldAnnotation);
    } else {
        Fields fieldsAnnotation = dictionary.getAttributeOrRelationAnnotation(entityClass, Fields.class, fieldName);
        if (fieldsAnnotation != null) {
            Arrays.stream(fieldsAnnotation.value()).forEach(fields::add);
        }
    }
    boolean indexed = false;
    for (Field field : fields) {
        if (field.index() == Index.YES && (field.name().equals(fieldName) || field.name().isEmpty())) {
            indexed = true;
        }
    }
    return indexed;
}
Also used : SortableField(org.hibernate.search.annotations.SortableField) Field(org.hibernate.search.annotations.Field) Fields(org.hibernate.search.annotations.Fields) ArrayList(java.util.ArrayList)

Aggregations

Field (org.hibernate.search.annotations.Field)3 SortableField (org.hibernate.search.annotations.SortableField)3 Student (fi.otavanopisto.pyramus.domainmodel.students.Student)2 StaffMember (fi.otavanopisto.pyramus.domainmodel.users.StaffMember)2 Transient (javax.persistence.Transient)2 ArrayList (java.util.ArrayList)1 Fields (org.hibernate.search.annotations.Fields)1