Examples of AssociationLinks


Examples of org.springframework.data.rest.webmvc.mapping.AssociationLinks

    PersistentEntity<?, ?> entity = persistentEntities.getPersistentEntity(type);
    final List<Descriptor> propertyDescriptors = new ArrayList<Descriptor>();
    final JacksonMetadata jackson = new JacksonMetadata(mapper, type);
    final PropertyMappings propertyMappings = new PropertyMappings(mappings);
    final AssociationLinks associationLinks = new AssociationLinks(mappings);

    entity.doWithProperties(new SimplePropertyHandler() {

      @Override
      public void doWithPersistentProperty(PersistentProperty<?> property) {

        BeanPropertyDefinition propertyDefinition = jackson.getDefinitionFor(property);
        ResourceMapping propertyMapping = propertyMappings.getMappingFor(property);

        if (propertyDefinition != null) {
          propertyDescriptors.add(//
              descriptor(). //
                  type(Type.SEMANTIC).//
                  name(propertyDefinition.getName()).//
                  doc(getDocFor(propertyMapping.getDescription())).//
                  build());
        }
      }
    });

    entity.doWithAssociations(new SimpleAssociationHandler() {

      @Override
      public void doWithAssociation(Association<? extends PersistentProperty<?>> association) {

        PersistentProperty<?> property = association.getInverse();
        ResourceMapping mapping = propertyMappings.getMappingFor(property);

        DescriptorBuilder builder = descriptor().//
            name(mapping.getRel()).doc(getDocFor(mapping.getDescription()));

        if (associationLinks.isLinkableAssociation(property)) {

          ResourceMetadata targetTypeMapping = mappings.getMappingFor(property.getActualType());
          String localPath = targetTypeMapping.getRel().concat("#").concat(targetTypeMapping.getItemResourceRel());
          Link link = ControllerLinkBuilder.linkTo(AlpsController.class).slash(localPath).withSelfRel();
View Full Code Here

Examples of org.springframework.data.rest.webmvc.mapping.AssociationLinks

    PersistentEntity<?, ?> entity = repositories.getPersistentEntity(instance.getClass());

    final List<EmbeddedWrapper> associationProjections = new ArrayList<EmbeddedWrapper>();
    final BeanWrapper<Object> wrapper = BeanWrapper.create(instance, null);
    final AssociationLinks associationLinks = new AssociationLinks(mappings);
    final ResourceMetadata metadata = mappings.getMappingFor(instance.getClass());

    entity.doWithAssociations(new SimpleAssociationHandler() {

      /*
       * (non-Javadoc)
       * @see org.springframework.data.mapping.SimpleAssociationHandler#doWithAssociation(org.springframework.data.mapping.Association)
       */
      @Override
      public void doWithAssociation(Association<? extends PersistentProperty<?>> association) {

        PersistentProperty<?> property = association.getInverse();

        if (!associationLinks.isLinkableAssociation(property)) {
          return;
        }

        if (!projector.hasExcerptProjection(property.getActualType())) {
          return;
View Full Code Here

Examples of org.springframework.data.rest.webmvc.mapping.AssociationLinks

    Assert.notNull(entities, "PersistentEntites must not be null!");
    Assert.notNull(mappings, "ResourceMappings must not be null!");

    this.entities = entities;
    this.associationLinks = new AssociationLinks(mappings);
    this.introspector = new BasicClassIntrospector();
  }
View Full Code Here

Examples of org.springframework.data.rest.webmvc.mapping.AssociationLinks

    });

    Link link = entityLinks.linkToCollectionResource(persistentEntity.getType()).expand();

    LinkCollectingAssociationHandler associationHandler = new LinkCollectingAssociationHandler(repositories, new Path(
        link.getHref()), new AssociationLinks(mappings));
    persistentEntity.doWithAssociations(associationHandler);

    jsonSchema.add(associationHandler.getLinks());

    return jsonSchema;
View Full Code Here

Examples of org.springframework.data.rest.webmvc.mapping.AssociationLinks

    Assert.notNull(mappings, "ResourceMappings must not be null!");
    Assert.notNull(entities, "Repositories must not be null!");
    Assert.notNull(config, "RepositoryRestConfiguration must not be null!");
    Assert.notNull(converter, "UriToEntityConverter must not be null!");

    AssociationLinks associationLinks = new AssociationLinks(mappings);

    addSerializer(new PersistentEntityResourceSerializer(entities, associationLinks));
    setSerializerModifier(new AssociationOmittingSerializerModifier(entities, associationLinks, config));
    setDeserializerModifier(new AssociationUriResolvingDeserializerModifier(entities, converter, associationLinks));
  }
View Full Code Here

Examples of org.springframework.data.rest.webmvc.mapping.AssociationLinks

  ResourceMetadata sampleResourceMetadata;

  @Before
  public void setUp() {

    this.links = new AssociationLinks(mappings);

    this.mappingContext = new MongoMappingContext();
    this.entity = mappingContext.getPersistentEntity(Sample.class);
    this.sampleResourceMetadata = new MappingResourceMetadata(entity);
View Full Code Here

Examples of org.springframework.data.rest.webmvc.mapping.AssociationLinks

  /**
   * @see DATAREST-262
   */
  @Test(expected = IllegalArgumentException.class)
  public void rejectsNullMappings() {
    new AssociationLinks(null);
  }
View Full Code Here

Examples of org.springframework.data.rest.webmvc.mapping.AssociationLinks

    public DynamicPersistentEntityResourceProcessor(GlobalAdministrationConfiguration adminConfiguration, FileResourceStorage fileResourceStorage, DynamicRepositoryEntityLinks entityLinks, DomainEntityLinks domainEntityLinks, ResourceMappings resourceMappings) {
        this.adminConfiguration = adminConfiguration;
        this.domainEntityLinks = domainEntityLinks;
        this.entityLinks = entityLinks;
        this.fileResourceStorage = fileResourceStorage;
        this.associationLinks = new AssociationLinks(resourceMappings);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.