Example usage for org.springframework.data.rest.core.mapping ResourceMetadata isExported

List of usage examples for org.springframework.data.rest.core.mapping ResourceMetadata isExported

Introduction

In this page you can find the example usage for org.springframework.data.rest.core.mapping ResourceMetadata isExported.

Prototype

boolean isExported();

Source Link

Document

Returns whether the component shall be exported at all.

Usage

From source file:org.moserp.common.structure.ApplicationStructureController.java

@RequestMapping(value = BASE_PATH, method = RequestMethod.GET)
public HttpEntity<Map<String, ResourceSupport>> listRepositories() {

    Map<String, ResourceSupport> groups = new HashMap<>();
    for (Class<?> domainType : repositories) {
        ResourceMetadata metadata = mappings.getMetadataFor(domainType);
        if (!metadata.isExported()) {
            continue;
        }/*from  w  ww . ja  v a2  s  .  c om*/
        String group = groupResolver.resolveGroup(domainType);
        ResourceSupport resource = groups.get(group);
        if (resource == null) {
            resource = new ResourceSupport();
            groups.put(group, resource);
        }
        resource.add(new Link(getPath(metadata), metadata.getRel()));
    }
    return new ResponseEntity<>(groups, HttpStatus.OK);
}

From source file:org.moserp.common.structure.factories.AssociationPropertyFactoryTest.java

@Before
public void setup() {
    when(persistentProperty.isAssociation()).thenReturn(true);
    when(persistentProperty.getActualType()).thenReturn((Class) OtherRepositoryClass.class);
    when(persistentProperty.getType()).thenReturn((Class) OtherRepositoryClass.class);

    ResourceMappings mappings = mock(ResourceMappings.class);
    ResourceMetadata metaData = mock(ResourceMetadata.class);
    when(metaData.getPath()).thenReturn(new Path("otherRepositoryClasses"));
    when(metaData.isExported()).thenReturn(true);
    when(mappings.getMetadataFor(eq(OtherRepositoryClass.class))).thenReturn(metaData);

    ModuleRegistry moduleRegistry = mock(ModuleRegistry.class);
    when(moduleRegistry.getModuleForResource(anyString())).thenReturn("environment-module");

    propertyFactory = new AssociationPropertyFactory(createConfiguration(), mappings, moduleRegistry);
}