Package com.linkedin.restli.restspec

Examples of com.linkedin.restli.restspec.CollectionSchema


    findModelsSimple(resourceSchema, foundTypes, typeOrder);
  }

  private void findModelsCollection(ResourceSchema resourceSchema, Map<String, NamedDataSchema> foundTypes, List<NamedDataSchema> typeOrder)
  {
    CollectionSchema collection = resourceSchema.getCollection();
    if (collection != null)
    {
      IdentifierSchema identifier = collection.getIdentifier();
      findModelsIdentifier(identifier, foundTypes, typeOrder);
      if (collection.hasFinders())
      {
        for (FinderSchema restMethodSchema: collection.getFinders())
        {
          findModelsFinder(restMethodSchema, foundTypes, typeOrder);
        }
      }
      if (collection.hasMethods())
      {
        for (RestMethodSchema restMethodSchema : collection.getMethods())
        {
          findModelsMethod(restMethodSchema, foundTypes, typeOrder);
        }
      }
      if (collection.hasActions())
      {
        for (ActionSchema actionSchema : collection.getActions())
        {
          findModelsAction(actionSchema, foundTypes, typeOrder);
        }
      }
      if (collection.hasEntity())
      {
        EntitySchema entity = collection.getEntity();
        findModelsEntity(entity, foundTypes, typeOrder);
      }
    }
  }
View Full Code Here


    ActionSchemaArray entityActions = null;

    if (resource.getCollection() != null)
    {
      resourceSchemaClass = CollectionSchema.class;
      CollectionSchema collection = resource.getCollection();
      String keyName = collection.getIdentifier().getName();
      // In case of collection with a simple key, return the one specified by "type" in
      // the "identifier". Otherwise, get both "type" and "params", and return
      // ComplexKeyResource parameterized by those two.
      if (collection.getIdentifier().getParams() == null)
      {
        keyClass = getJavaBindingType(collection.getIdentifier().getType(), facadeClass).valueClass;
        JClass declaredClass = getClassRefForSchema(RestSpecCodec.textToSchema(collection.getIdentifier().getType(), getSchemaResolver()), facadeClass);
        if(!declaredClass.equals(keyClass))
        {
          keyTyperefClass = declaredClass;
        }
      }
      else
      {
        keyKeyClass = getJavaBindingType(collection.getIdentifier().getType(), facadeClass).valueClass;
        keyParamsClass = getJavaBindingType(collection.getIdentifier().getParams(), facadeClass).valueClass;
        keyClass = getCodeModel().ref(ComplexResourceKey.class).narrow(keyKeyClass, keyParamsClass);
      }
      pathKeyTypes.put(keyName, keyClass);
      supportsList = collection.getSupports();
      restMethods = collection.getMethods();
      finders = collection.getFinders();
      subresources = collection.getEntity().getSubresources();
      resourceActions = collection.getActions();
      entityActions = collection.getEntity().getActions();
    }
    else if (resource.getAssociation() != null)
    {
      resourceSchemaClass = AssociationSchema.class;
      AssociationSchema association = resource.getAssociation();
View Full Code Here

    final ResourceSchemaVisitior.VisitContext context = buildContext(hierarchy);
    visitor.visitResourceSchema(context, resourceSchema);

    if (resourceSchema.hasCollection())
    {
      final CollectionSchema collectionSchema = resourceSchema.getCollection();
      visitor.visitCollectionResource(context, collectionSchema);

      processRestMethods(visitor, context, collectionSchema, collectionSchema.getMethods());
      processFinders(visitor, context, collectionSchema, collectionSchema.getFinders());
      processActions(visitor, context, collectionSchema, collectionSchema.getActions());

      processEntitySchema(visitor, context, collectionSchema.getEntity());
    }
    else if (resourceSchema.hasAssociation())
    {
      final AssociationSchema associationSchema = resourceSchema.getAssociation();
      visitor.visitAssociationResource(context, associationSchema);
View Full Code Here

  private void appendCollection(final ResourceSchema resourceSchema,
                                final ResourceModel collectionModel)
  {
    appendCommon(collectionModel, resourceSchema);

    CollectionSchema collectionSchema = new CollectionSchema();
    //HACK: AssociationSchema and CollectionSchema share many common elements, but have no inheritance
    //relationship.  Here, we construct them both as facades on the same DataMap, which allows
    //us to pass strongly typed CollectionSchema objects around, even when we're dealing with
    //an association.
    AssociationSchema associationSchema = new AssociationSchema(collectionSchema.data());

    if (collectionModel.getKeys().size() == 1)
    {
      appendIdentifierNode(collectionSchema, collectionModel);
    }
    else
    {
      appendKeys(associationSchema, collectionModel);
    }

    appendSupportsNodeToCollectionSchema(collectionSchema, collectionModel);
    appendMethodsToCollectionSchema(collectionSchema, collectionModel);
    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);

    switch(collectionModel.getResourceType())
    {
View Full Code Here

  private static RestMethodSchema findRestMethod(ResourceSchema resourceSchema, ResourceMethod method)
  {
    RestMethodSchemaArray methods = null;
    RestMethodSchema methodResult = null;

    final CollectionSchema collectionSchema = resourceSchema.getCollection();
    if (collectionSchema != null)
    {
      methods = collectionSchema.getMethods();
    }

    final AssociationSchema associationSchema = resourceSchema.getAssociation();
    if (associationSchema != null)
    {
View Full Code Here

    return methodResult;
  }

  private static FinderSchema findFinder(ResourceSchema resourceSchema, String finderName)
  {
    final CollectionSchema collectionSchema = resourceSchema.getCollection();
    if (collectionSchema != null)
    {
      final FinderSchemaArray finders = collectionSchema.getFinders();
      if (finders != null)
      {
        for (FinderSchema finderSchema: finders)
        {
          if (finderSchema.getName().equals(finderName))
View Full Code Here

    return null;
  }

  private static ActionSchema findCollectionAction(ResourceSchema resourceSchema, String actionName)
  {
    final CollectionSchema collectionSchema = resourceSchema.getCollection();
    if (collectionSchema != null)
    {
      final ActionSchemaArray actions = collectionSchema.getActions();
      if (actions != null)
      {
        for (ActionSchema actionSchema: actions)
        {
          if (actionSchema.getName().equals(actionName))
View Full Code Here

  private static ActionSchema findEntityAction(ResourceSchema resourceSchema, String actionName)
  {
    ActionSchema actionSchema;

    final CollectionSchema collectionSchema = resourceSchema.getCollection();
    if (collectionSchema != null)
    {
      final EntitySchema entity = collectionSchema.getEntity();
      if (entity != null)
      {
        actionSchema = findActionInEntity(entity, actionName);
        if (actionSchema != null)
        {
View Full Code Here

  {
    _resourceSchema = resourceSchema;

    if(resourceSchema.hasCollection())
    {
      CollectionSchema collection = resourceSchema.getCollection();
      _type = ResourceType.COLLECTION;
      _supports = collection.getSupports();
      _methods = collection.hasMethods() ? collection.getMethods() : new RestMethodSchemaArray(0);
      _finders = collection.hasFinders() ? collection.getFinders() : new FinderSchemaArray(0);
      _actions = collection.hasActions() ? collection.getActions() : new ActionSchemaArray(0);
      _entity = collection.getEntity();

    }
    else if(resourceSchema.hasAssociation())
    {
      _type = ResourceType.ASSOCIATION;
View Full Code Here

   */
  public ResourceSpec translate(ResourceSchema resourceSchema)
  {
    if(resourceSchema.hasCollection())
    {
      CollectionSchema collection = resourceSchema.getCollection();
      return collectionToResourceSpec(resourceSchema, collection);
    }
    else if(resourceSchema.hasAssociation())
    {
      AssociationSchema association = resourceSchema.getAssociation();
View Full Code Here

TOP

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

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.