use of com.linkedin.restli.restspec.ActionSchema in project rest.li by linkedin.
the class ResourceSchemaToResourceSpecTranslator method toDynamicRecordMetadata.
private ActionCollectionMetadata toDynamicRecordMetadata(ActionSchemaArray actions, ActionSchemaArray entityActions) {
Map<String, DynamicRecordMetadata> response = new HashMap<>();
Map<String, DynamicRecordMetadata> request = new HashMap<>();
ActionSchemaArray[] actionGroups = new ActionSchemaArray[] { actions, entityActions };
for (ActionSchemaArray actionGroup : actionGroups) {
if (actionGroup != null) {
for (ActionSchema action : actionGroup) {
ActionMetadata metadata = toActionMetadata(action);
request.put(metadata._name, metadata._request);
response.put(metadata._name, metadata._response);
}
}
}
return new ActionCollectionMetadata(request, response);
}
use of com.linkedin.restli.restspec.ActionSchema in project rest.li by linkedin.
the class TestResourceSchemaToResourceSpecTranslator method compareActions.
private void compareActions(ResourceSpec actual, ResourceSpec expected, ActionSchemaArray actions) {
for (ActionSchema action : actions) {
ParameterSchemaArray parameters = action.getParameters();
DynamicRecordMetadata actualRequest = actual.getRequestMetadata(action.getName());
DynamicRecordMetadata expectedRequest = expected.getRequestMetadata(action.getName());
if (expectedRequest != null) {
Assert.assertNotNull(actualRequest);
Assert.assertEquals(actualRequest.getRecordDataSchema(), expectedRequest.getRecordDataSchema());
if (parameters != null) {
for (ParameterSchema parameter : parameters) {
compareFieldDef(actualRequest.getFieldDef(parameter.getName()), expectedRequest.getFieldDef(parameter.getName()));
}
}
} else {
Assert.assertNull(actualRequest);
}
compareParameters(actual.getActionResponseMetadata(action.getName()), expected.getActionResponseMetadata(action.getName()));
}
}
use of com.linkedin.restli.restspec.ActionSchema in project rest.li by linkedin.
the class JavaRequestBuilderGenerator method responseMetadataMapInit.
private // lets work on this first...
JVar responseMetadataMapInit(// lets work on this first...
JDefinedClass facadeClass, // lets work on this first...
ActionSchemaArray resourceActions, // lets work on this first...
ActionSchemaArray entityActions, // lets work on this first...
JBlock staticInit) {
final JClass MetadataMapClass = getCodeModel().ref(HashMap.class).narrow(_stringClass, getCodeModel().ref(DynamicRecordMetadata.class));
final JVar responseMetadataMap = staticInit.decl(MetadataMapClass, "responseMetadataMap").init(JExpr._new(MetadataMapClass));
// 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);
final String returnName = "value";
for (ActionSchema actionSchema : allActionSchema) {
final String methodName = actionSchema.getName();
final JInvocation returnFieldDefs;
if (actionSchema.hasReturns()) {
final JInvocation returnFieldDef = createFieldDef(returnName, actionSchema.getReturns(), facadeClass);
returnFieldDefs = getCodeModel().ref(Collections.class).staticInvoke("singletonList").arg(returnFieldDef);
} else {
returnFieldDefs = getCodeModel().ref(Collections.class).staticInvoke("<FieldDef<?>>emptyList");
}
final JInvocation returnMetadata = createMetadata(methodName, returnFieldDefs);
staticInit.add(responseMetadataMap.invoke("put").arg(methodName).arg(returnMetadata));
}
return responseMetadataMap;
}
use of com.linkedin.restli.restspec.ActionSchema in project rest.li by linkedin.
the class RequestBuilderSpecGenerator method generateActions.
private List<RootBuilderMethodSpec> generateActions(RootBuilderSpec rootBuilderSpec, ActionSchemaArray actions, String keyClass, String resourceName, List<String> pathKeys, Map<String, String> pathKeyTypes) {
List<RootBuilderMethodSpec> actionSpecList = new ArrayList<>();
if (actions != null) {
for (ActionSchema action : actions) {
RootBuilderMethodSpec actionSpec = generateActionMethod(rootBuilderSpec, keyClass, action, resourceName, pathKeys, pathKeyTypes);
actionSpecList.add(actionSpec);
}
}
return actionSpecList;
}
use of com.linkedin.restli.restspec.ActionSchema in project rest.li by linkedin.
the class SnapshotGenerator method findModelsActionSet.
private void findModelsActionSet(ResourceSchema resourceSchema, Map<String, NamedDataSchema> foundTypes, List<NamedDataSchema> typeOrder) {
ActionsSetSchema actionsSet = resourceSchema.getActionsSet();
if (actionsSet != null) {
findErrorDetailTypeModels(actionsSet, foundTypes, typeOrder);
if (actionsSet.hasActions()) {
for (ActionSchema actionSchema : actionsSet.getActions()) {
findModelsAction(actionSchema, foundTypes, typeOrder);
findErrorDetailTypeModels(actionSchema, foundTypes, typeOrder);
}
}
}
}
Aggregations