Package com.linkedin.restli.restspec

Examples of com.linkedin.restli.restspec.ActionSchemaArray


    compareTypes(actual.getKeyType(), expected.getKeyType());
    compareTypes(actual.getValueType(), expected.getValueType());
    compareComplexKey(actual.getComplexKeyType(), expected.getComplexKeyType());
    compareKeyParts(actual.getKeyParts(), expected.getKeyParts());

    ActionSchemaArray actions = resourceSchema.getActions();
    compareActions(actual, expected, actions);

    ActionSchemaArray entityActions = resourceSchema.getEntityActions();
    compareActions(actual, expected, entityActions);

    FinderSchemaArray finders = resourceSchema.getFinders();
    for (FinderSchema finder : finders)
    {
View Full Code Here


    Map<String, AssocKeyTypeInfo> assocKeyTypeInfos = Collections.emptyMap();
    StringArray supportsList=null;
    RestMethodSchemaArray restMethods = null;
    FinderSchemaArray finders = null;
    ResourceSchemaArray subresources = null;
    ActionSchemaArray resourceActions = null;
    ActionSchemaArray entityActions = null;

    if (resource.getCollection() != null)
    {
      resourceSchemaClass = CollectionSchema.class;
      CollectionSchema collection = resource.getCollection();
View Full Code Here

    JVar responseMetadataMap = staticInit.decl(MetadataMapClass, "responseMetadataMap").init(JExpr._new(MetadataMapClass));

    // get all actions into a single ActionSchemaArray
    int resourceActionsSize = resourceActions == null ? 0 : resourceActions.size();
    int entityActionsSize = entityActions == null ? 0 : entityActions.size();
    ActionSchemaArray allActionSchema = new ActionSchemaArray(resourceActionsSize + entityActionsSize);
    allActionSchema.addAll(resourceActions == null ? new ActionSchemaArray() : resourceActions);
    allActionSchema.addAll(entityActions == null ? new ActionSchemaArray() : entityActions);

    String returnName = "value";

    for(ActionSchema actionSchema : allActionSchema)
    {
View Full Code Here

    JClass fieldDefListClass = getCodeModel().ref(ArrayList.class).narrow(getCodeModel().ref(FieldDef.class).narrow(getCodeModel().ref(Object.class).wildcard()));

    // get all actions into a single ActionSchemaArray
    int resourceActionsSize = resourceActions == null ? 0 : resourceActions.size();
    int entityActionsSize = entityActions == null ? 0 : entityActions.size();
    ActionSchemaArray allActionSchema = new ActionSchemaArray(resourceActionsSize + entityActionsSize);
    allActionSchema.addAll(resourceActions == null ? new ActionSchemaArray() : resourceActions);
    allActionSchema.addAll(entityActions == null ? new ActionSchemaArray() : entityActions);

    for(ActionSchema actionSchema : allActionSchema)
    {
      String varName = actionSchema.getName() + "Params";
      JVar currMethodParams = staticInit.decl(fieldDefListClass, varName).init(JExpr._new(fieldDefListClass));
View Full Code Here

    FinderSchemaArray finders = createFinders(collectionModel);
    if (finders.size() > 0)
    {
      collectionSchema.setFinders(finders);
    }
    ActionSchemaArray actions = createActions(collectionModel, ResourceLevel.COLLECTION);
    if (actions.size() > 0)
    {
      collectionSchema.setActions(actions);
    }
    appendEntityToCollectionSchema(collectionSchema, collectionModel);
View Full Code Here

  private void appendActionsModel(final ResourceSchema resourceSchema,
                                  final ResourceModel resourceModel)
  {
    appendCommon(resourceModel, resourceSchema);
    ActionsSetSchema actionsNode = new ActionsSetSchema();
    ActionSchemaArray actions = createActions(resourceModel, ResourceLevel.COLLECTION);
    if (actions.size() > 0)
    {
      actionsNode.setActions(actions);
    }
    resourceSchema.setActionsSet(actionsNode);
  }
View Full Code Here

    SimpleSchema simpleSchema = new SimpleSchema();

    appendSupportsNodeToSimpleSchema(simpleSchema, resourceModel);
    appendMethodsToSimpleSchema(simpleSchema, resourceModel);

    ActionSchemaArray actions = createActions(resourceModel, ResourceLevel.ENTITY);
    if (actions.size() > 0)
    {
      simpleSchema.setActions(actions);
    }

    appendEntityToSimpleSchema(simpleSchema, resourceModel);
View Full Code Here

    EntitySchema entityNode = new EntitySchema();
    entityNode.setPath(buildPathForEntity(resourceModel));

    if (resourceModel.getResourceLevel() == ResourceLevel.COLLECTION)
    {
      ActionSchemaArray actions = createActions(resourceModel, ResourceLevel.ENTITY);
      if (actions.size() > 0)
      {
        entityNode.setActions(actions);
      }
    }
View Full Code Here

  @SuppressWarnings("unchecked")
  private ActionSchemaArray createActions(final ResourceModel resourceModel,
                                          final ResourceLevel resourceLevel)
  {
    ActionSchemaArray actionsArray = new ActionSchemaArray();

    List<ResourceMethodDescriptor> resourceMethodDescriptors =
        resourceModel.getResourceMethodDescriptors();
    Collections.sort(resourceMethodDescriptors, new Comparator<ResourceMethodDescriptor>()
    {
      @Override
      public int compare(final ResourceMethodDescriptor o1, final ResourceMethodDescriptor o2)
      {
        if (o1.getType().equals(ResourceMethod.ACTION))
        {
          if (o2.getType().equals(ResourceMethod.ACTION))
          {
            return o1.getActionName().compareTo(o2.getActionName());
          }
          else
          {
            return 1;
          }
        }
        else if (o2.getType().equals(ResourceMethod.ACTION))
        {
          return -1;
        }
        else
        {
          return 0;
        }
      }
    });

    for (ResourceMethodDescriptor resourceMethodDescriptor : resourceMethodDescriptors)
    {
      if (ResourceMethod.ACTION.equals(resourceMethodDescriptor.getType()))
      {
        //do not apply entity-level actions at collection level or vice-versa
        if (resourceMethodDescriptor.getActionResourceLevel() != resourceLevel)
        {
          continue;
        }

        ActionSchema action = new ActionSchema();

        action.setName(resourceMethodDescriptor.getActionName());

        //We have to construct the method doc for the action which includes the action return type
        final String methodDoc = _docsProvider.getMethodDoc(resourceMethodDescriptor.getMethod());
        if (methodDoc != null)
        {
          final StringBuilder methodDocBuilder = new StringBuilder(methodDoc.trim());
          if (methodDocBuilder.length() > 0)
          {
            final String returnDoc = sanitizeDoc(_docsProvider.getReturnDoc(resourceMethodDescriptor.getMethod()));
            if (returnDoc != null && !returnDoc.isEmpty())
            {
              methodDocBuilder.append("\n");
              methodDocBuilder.append("Service Returns: ");
              //Capitalize the first character
              methodDocBuilder.append(returnDoc.substring(0, 1).toUpperCase());
              methodDocBuilder.append(returnDoc.substring(1));
            }
          }
          action.setDoc(methodDocBuilder.toString());
        }

        ParameterSchemaArray parameters = createParameters(resourceMethodDescriptor);
        if (parameters.size() > 0)
        {
          action.setParameters(parameters);
        }

        Class<?> returnType = resourceMethodDescriptor.getActionReturnType();
        if (returnType != Void.TYPE)
        {
          String returnTypeString =
              buildDataSchemaType(returnType,
                                  resourceMethodDescriptor.getActionReturnRecordDataSchema().getField(ActionResponse.VALUE_NAME).getType());
          action.setReturns(returnTypeString);
        }

        final DataMap customAnnotation = resourceMethodDescriptor.getCustomAnnotationData();
        String deprecatedDoc = _docsProvider.getMethodDeprecatedTag(resourceMethodDescriptor.getMethod());
        if(deprecatedDoc != null)
        {
          customAnnotation.put(DEPRECATED_ANNOTATION_NAME, deprecateDocToAnnotationMap(deprecatedDoc));
        }

        if (!customAnnotation.isEmpty())
        {
          action.setAnnotations(new CustomAnnotationContentSchemaMap(customAnnotation));
        }

        actionsArray.add(action);
      }
    }
    return actionsArray;
  }
View Full Code Here

  private static ActionSchema findActionsSetAction(ResourceSchema resourceSchema, String actionName)
  {
    final ActionsSetSchema actionsSetSchema = resourceSchema.getActionsSet();
    if (actionsSetSchema != null)
    {
      final ActionSchemaArray actions = actionsSetSchema.getActions();
      if (actions != null)
      {
        for (ActionSchema actionSchema: actions)
        {
          if (actionSchema.getName().equals(actionName))
View Full Code Here

TOP

Related Classes of com.linkedin.restli.restspec.ActionSchemaArray

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.