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());
}
}
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;
}
Aggregations