Search in sources :

Example 1 with IndexObjectFieldReference

use of org.hibernate.search.engine.backend.document.IndexObjectFieldReference in project hibernate-search by hibernate.

the class PojoIndexingProcessorCastedTypeNode method process.

@Override
// As long as T is not a proxy-specific interface, it will also be implemented by the unproxified object
@SuppressWarnings("unchecked")
public final void process(DocumentElement target, T source, PojoIndexingProcessorRootContext context) {
    if (source == null) {
        return;
    }
    source = (T) context.sessionContext().runtimeIntrospector().unproxy(source);
    // The caster can only cast to the raw type, beyond that we have to use an unchecked cast.
    @SuppressWarnings("unchecked") U castedSource = (U) caster.cast(source);
    // which may be costly (reflection, ...)
    if (isEntityType && context.isDeleted(castedSource)) {
        return;
    }
    DocumentElement parentObject = target;
    for (IndexObjectFieldReference objectFieldReference : parentIndexObjectReferences) {
        parentObject = parentObject.addObject(objectFieldReference);
    }
    nested.process(parentObject, castedSource, context);
}
Also used : DocumentElement(org.hibernate.search.engine.backend.document.DocumentElement) IndexObjectFieldReference(org.hibernate.search.engine.backend.document.IndexObjectFieldReference)

Example 2 with IndexObjectFieldReference

use of org.hibernate.search.engine.backend.document.IndexObjectFieldReference in project infinispan by infinispan.

the class IndexingTagHandler method pushContext.

private void pushContext(FieldDescriptor fieldDescriptor, Descriptor messageDescriptor) {
    String fieldPath = messageContext.getFieldPath();
    fieldPath = fieldPath != null ? fieldPath + '.' + fieldDescriptor.getName() : fieldDescriptor.getName();
    DocumentElement documentElement = null;
    if (messageContext.getDocument() != null) {
        IndexObjectFieldReference objectReference = indexReferenceHolder.getObjectReference(fieldPath);
        if (objectReference != null) {
            documentElement = messageContext.getDocument().addObject(objectReference);
        }
    }
    messageContext = new IndexingMessageContext(messageContext, fieldDescriptor, messageDescriptor, documentElement);
}
Also used : DocumentElement(org.hibernate.search.engine.backend.document.DocumentElement) IndexObjectFieldReference(org.hibernate.search.engine.backend.document.IndexObjectFieldReference)

Example 3 with IndexObjectFieldReference

use of org.hibernate.search.engine.backend.document.IndexObjectFieldReference in project infinispan by infinispan.

the class ProtobufMessageBinder method createIndexReferenceProvider.

private IndexReferenceHolder createIndexReferenceProvider(TypeBindingContext context, int maxDepth) {
    final Map<String, IndexFieldReference<?>> fieldReferenceMap = new HashMap<>();
    final Map<String, IndexObjectFieldReference> objectReferenceMap = new HashMap<>();
    Stack<State> stack = new Stack<>();
    stack.push(new State(globalReferenceHolder.getMessageReferenceProviders().get(rootMessageName), "", context.indexSchemaElement(), 0));
    while (!stack.isEmpty()) {
        State currentState = stack.pop();
        fieldReferenceMap.putAll(currentState.bind());
        if (currentState.depth == maxDepth) {
            continue;
        }
        for (MessageReferenceProvider.Embedded embedded : currentState.messageReferenceProvider.getEmbedded()) {
            String newPath = ("".equals(currentState.path)) ? embedded.getFieldName() : currentState.path + "." + embedded.getFieldName();
            String typeName = embedded.getTypeFullName();
            MessageReferenceProvider messageReferenceProvider = globalReferenceHolder.getMessageReferenceProviders().get(typeName);
            IndexSchemaObjectField indexSchemaElement = currentState.indexSchemaElement.objectField(embedded.getFieldName());
            if (embedded.isRepeated()) {
                indexSchemaElement.multiValued();
            }
            objectReferenceMap.put(newPath, indexSchemaElement.toReference());
            State state = new State(messageReferenceProvider, newPath, indexSchemaElement, currentState.depth + 1);
            stack.push(state);
        }
    }
    return new IndexReferenceHolder(fieldReferenceMap, objectReferenceMap);
}
Also used : IndexSchemaObjectField(org.hibernate.search.engine.backend.document.model.dsl.IndexSchemaObjectField) HashMap(java.util.HashMap) IndexObjectFieldReference(org.hibernate.search.engine.backend.document.IndexObjectFieldReference) MessageReferenceProvider(org.infinispan.query.remote.impl.mapping.reference.MessageReferenceProvider) Stack(java.util.Stack) IndexFieldReference(org.hibernate.search.engine.backend.document.IndexFieldReference) IndexReferenceHolder(org.infinispan.query.remote.impl.mapping.reference.IndexReferenceHolder)

Example 4 with IndexObjectFieldReference

use of org.hibernate.search.engine.backend.document.IndexObjectFieldReference in project hibernate-search by hibernate.

the class PojoIndexingProcessorOriginalTypeNode method process.

@Override
// As long as T is not a proxy-specific interface, it will also be implemented by the unproxified object
@SuppressWarnings("unchecked")
public final void process(DocumentElement target, T source, PojoIndexingProcessorRootContext context) {
    if (source == null) {
        return;
    }
    source = (T) context.sessionContext().runtimeIntrospector().unproxy(source);
    // which may be costly (reflection, ...)
    if (isEntityType && context.isDeleted(source)) {
        return;
    }
    DocumentElement parentObject = target;
    for (IndexObjectFieldReference objectFieldReference : parentIndexObjectReferences) {
        parentObject = parentObject.addObject(objectFieldReference);
    }
    nested.process(parentObject, source, context);
}
Also used : DocumentElement(org.hibernate.search.engine.backend.document.DocumentElement) IndexObjectFieldReference(org.hibernate.search.engine.backend.document.IndexObjectFieldReference)

Aggregations

IndexObjectFieldReference (org.hibernate.search.engine.backend.document.IndexObjectFieldReference)4 DocumentElement (org.hibernate.search.engine.backend.document.DocumentElement)3 HashMap (java.util.HashMap)1 Stack (java.util.Stack)1 IndexFieldReference (org.hibernate.search.engine.backend.document.IndexFieldReference)1 IndexSchemaObjectField (org.hibernate.search.engine.backend.document.model.dsl.IndexSchemaObjectField)1 IndexReferenceHolder (org.infinispan.query.remote.impl.mapping.reference.IndexReferenceHolder)1 MessageReferenceProvider (org.infinispan.query.remote.impl.mapping.reference.MessageReferenceProvider)1