use of com.linkedin.restli.restspec.ParameterSchemaArray in project rest.li by linkedin.
the class ResourceModelEncoder method createFinders.
private FinderSchemaArray createFinders(final ResourceModel resourceModel) {
FinderSchemaArray findersArray = new FinderSchemaArray();
List<ResourceMethodDescriptor> resourceMethodDescriptors = resourceModel.getResourceMethodDescriptors();
Collections.sort(resourceMethodDescriptors, RESOURCE_METHOD_COMPARATOR);
for (ResourceMethodDescriptor resourceMethodDescriptor : resourceMethodDescriptors) {
if (ResourceMethod.FINDER.equals(resourceMethodDescriptor.getType())) {
FinderSchema finder = new FinderSchema();
finder.setName(resourceMethodDescriptor.getFinderName());
String doc = _docsProvider.getMethodDoc(resourceMethodDescriptor.getMethod());
if (doc != null) {
finder.setDoc(doc);
}
ParameterSchemaArray parameters = createParameters(resourceMethodDescriptor);
if (parameters.size() > 0) {
finder.setParameters(parameters);
}
StringArray assocKeys = createAssocKeyParameters(resourceMethodDescriptor);
if (assocKeys.size() > 0) {
finder.setAssocKeys(assocKeys);
}
if (resourceMethodDescriptor.getFinderMetadataType() != null) {
Class<?> metadataType = resourceMethodDescriptor.getFinderMetadataType();
MetadataSchema metadataSchema = new MetadataSchema();
metadataSchema.setType(buildDataSchemaType(metadataType));
finder.setMetadata(metadataSchema);
}
final DataMap customAnnotation = resourceMethodDescriptor.getCustomAnnotationData();
String deprecatedDoc = _docsProvider.getMethodDeprecatedTag(resourceMethodDescriptor.getMethod());
if (deprecatedDoc != null) {
customAnnotation.put(DEPRECATED_ANNOTATION_NAME, deprecateDocToAnnotationMap(deprecatedDoc));
}
if (!customAnnotation.isEmpty()) {
finder.setAnnotations(new CustomAnnotationContentSchemaMap(customAnnotation));
}
if (resourceMethodDescriptor.isPagingSupported()) {
finder.setPagingSupported(true);
}
findersArray.add(finder);
}
}
return findersArray;
}
use of com.linkedin.restli.restspec.ParameterSchemaArray in project rest.li by linkedin.
the class JavaRequestBuilderGenerator method methodMetadataMapInit.
private JVar methodMetadataMapInit(JDefinedClass facadeClass, ActionSchemaArray resourceActions, ActionSchemaArray entityActions, JBlock staticInit) {
// CreateMetadata (only for actions right now)
final JClass MetadataMapClass = getCodeModel().ref(HashMap.class).narrow(_stringClass, getCodeModel().ref(DynamicRecordMetadata.class));
final JVar requestMetadataMap = staticInit.decl(MetadataMapClass, "requestMetadataMap").init(JExpr._new(MetadataMapClass));
final JClass fieldDefListClass = getCodeModel().ref(ArrayList.class).narrow(getCodeModel().ref(FieldDef.class).narrow(getCodeModel().ref(Object.class).wildcard()));
// get all actions into a single ActionSchemaArray
final int resourceActionsSize = resourceActions == null ? 0 : resourceActions.size();
final int entityActionsSize = entityActions == null ? 0 : entityActions.size();
final ActionSchemaArray allActionSchema = new ActionSchemaArray(resourceActionsSize + entityActionsSize);
allActionSchema.addAll(resourceActions == null ? new ActionSchemaArray() : resourceActions);
allActionSchema.addAll(entityActions == null ? new ActionSchemaArray() : entityActions);
for (ActionSchema actionSchema : allActionSchema) {
final String varName = actionSchema.getName() + "Params";
final JVar currMethodParams = staticInit.decl(fieldDefListClass, varName).init(JExpr._new(fieldDefListClass));
final ParameterSchemaArray parameters = actionSchema.getParameters();
for (ParameterSchema parameterSchema : parameters == null ? new ParameterSchemaArray() : parameters) {
final JInvocation fieldDefParam = createFieldDef(parameterSchema.getName(), parameterSchema.getType(), facadeClass);
staticInit.add(currMethodParams.invoke("add").arg(fieldDefParam));
}
final String methodName = actionSchema.getName();
final JInvocation newSchema = createMetadata(methodName, currMethodParams);
staticInit.add(requestMetadataMap.invoke("put").arg(methodName).arg(newSchema));
}
return requestMetadataMap;
}
use of com.linkedin.restli.restspec.ParameterSchemaArray in project rest.li by linkedin.
the class ExampleRequestResponseGenerator method addParams.
private void addParams(RestfulRequestBuilder<?, ?, ?> builder, ResourceMethod method) {
RestMethodSchema methodSchema = _resourceSchema.getMethod(method.toString().toLowerCase());
ParameterSchemaArray parameters = methodSchema.getParameters();
addParams(builder, parameters);
}
Aggregations