Search in sources :

Example 1 with TemporaryAnnotationReferenceDataType

use of com.yahoo.searchdefinition.document.annotation.TemporaryAnnotationReferenceDataType in project vespa by vespa-engine.

the class DocumentModelBuilder method extractNestedTypes.

private static void extractNestedTypes(NewDocumentType dt, DataType type) {
    if (type instanceof StructDataType) {
        StructDataType tmp = (StructDataType) type;
        extractDataTypesFromFields(dt, tmp.getFieldsThisTypeOnly());
    } else if (type instanceof DocumentType) {
        throw new IllegalArgumentException("Can not handle nested document definitions. In document type '" + dt.getName().toString() + "', we can not define document type '" + type.toString());
    } else if (type instanceof CollectionDataType) {
        CollectionDataType tmp = (CollectionDataType) type;
        extractNestedTypes(dt, tmp.getNestedType());
        addType(dt, tmp.getNestedType());
    } else if (type instanceof MapDataType) {
        MapDataType tmp = (MapDataType) type;
        extractNestedTypes(dt, tmp.getKeyType());
        extractNestedTypes(dt, tmp.getValueType());
        addType(dt, tmp.getKeyType());
        addType(dt, tmp.getValueType());
    } else if (type instanceof TemporaryAnnotationReferenceDataType) {
        throw new IllegalArgumentException(type.toString());
    }
}
Also used : StructDataType(com.yahoo.document.StructDataType) CollectionDataType(com.yahoo.document.CollectionDataType) DocumentType(com.yahoo.document.DocumentType) NewDocumentType(com.yahoo.documentmodel.NewDocumentType) SDDocumentType(com.yahoo.searchdefinition.document.SDDocumentType) VespaDocumentType(com.yahoo.documentmodel.VespaDocumentType) MapDataType(com.yahoo.document.MapDataType) TemporaryAnnotationReferenceDataType(com.yahoo.searchdefinition.document.annotation.TemporaryAnnotationReferenceDataType)

Example 2 with TemporaryAnnotationReferenceDataType

use of com.yahoo.searchdefinition.document.annotation.TemporaryAnnotationReferenceDataType in project vespa by vespa-engine.

the class DocumentModelBuilder method specialHandleAnnotationReferenceRecurse.

private static DataType specialHandleAnnotationReferenceRecurse(NewDocumentType docType, String fieldName, DataType dataType) {
    if (dataType instanceof TemporaryAnnotationReferenceDataType) {
        TemporaryAnnotationReferenceDataType refType = (TemporaryAnnotationReferenceDataType) dataType;
        if (refType.getId() != 0) {
            return null;
        }
        AnnotationType target = docType.getAnnotationType(refType.getTarget());
        if (target == null) {
            throw new RetryLaterException("Annotation '" + refType.getTarget() + "' in reference '" + fieldName + "' does not exist.");
        }
        dataType = new AnnotationReferenceDataType(target);
        addType(docType, dataType);
        return dataType;
    } else if (dataType instanceof MapDataType) {
        MapDataType mapType = (MapDataType) dataType;
        DataType valueType = specialHandleAnnotationReferenceRecurse(docType, fieldName, mapType.getValueType());
        if (valueType == null) {
            return null;
        }
        mapType = mapType.clone();
        mapType.setValueType(valueType);
        addType(docType, mapType);
        return mapType;
    } else if (dataType instanceof CollectionDataType) {
        CollectionDataType lstType = (CollectionDataType) dataType;
        DataType nestedType = specialHandleAnnotationReferenceRecurse(docType, fieldName, lstType.getNestedType());
        if (nestedType == null) {
            return null;
        }
        lstType = lstType.clone();
        lstType.setNestedType(nestedType);
        addType(docType, lstType);
        return lstType;
    }
    return null;
}
Also used : AnnotationReferenceDataType(com.yahoo.document.annotation.AnnotationReferenceDataType) TemporaryAnnotationReferenceDataType(com.yahoo.searchdefinition.document.annotation.TemporaryAnnotationReferenceDataType) CollectionDataType(com.yahoo.document.CollectionDataType) StructuredDataType(com.yahoo.document.StructuredDataType) TemporaryStructuredDataType(com.yahoo.document.TemporaryStructuredDataType) DataType(com.yahoo.document.DataType) StructDataType(com.yahoo.document.StructDataType) CollectionDataType(com.yahoo.document.CollectionDataType) MapDataType(com.yahoo.document.MapDataType) AnnotationReferenceDataType(com.yahoo.document.annotation.AnnotationReferenceDataType) TemporaryAnnotationReferenceDataType(com.yahoo.searchdefinition.document.annotation.TemporaryAnnotationReferenceDataType) ReferenceDataType(com.yahoo.document.ReferenceDataType) MapDataType(com.yahoo.document.MapDataType) TemporaryAnnotationReferenceDataType(com.yahoo.searchdefinition.document.annotation.TemporaryAnnotationReferenceDataType) SDAnnotationType(com.yahoo.searchdefinition.document.annotation.SDAnnotationType) AnnotationType(com.yahoo.document.annotation.AnnotationType)

Aggregations

CollectionDataType (com.yahoo.document.CollectionDataType)2 MapDataType (com.yahoo.document.MapDataType)2 StructDataType (com.yahoo.document.StructDataType)2 TemporaryAnnotationReferenceDataType (com.yahoo.searchdefinition.document.annotation.TemporaryAnnotationReferenceDataType)2 DataType (com.yahoo.document.DataType)1 DocumentType (com.yahoo.document.DocumentType)1 ReferenceDataType (com.yahoo.document.ReferenceDataType)1 StructuredDataType (com.yahoo.document.StructuredDataType)1 TemporaryStructuredDataType (com.yahoo.document.TemporaryStructuredDataType)1 AnnotationReferenceDataType (com.yahoo.document.annotation.AnnotationReferenceDataType)1 AnnotationType (com.yahoo.document.annotation.AnnotationType)1 NewDocumentType (com.yahoo.documentmodel.NewDocumentType)1 VespaDocumentType (com.yahoo.documentmodel.VespaDocumentType)1 SDDocumentType (com.yahoo.searchdefinition.document.SDDocumentType)1 SDAnnotationType (com.yahoo.searchdefinition.document.annotation.SDAnnotationType)1