Search in sources :

Example 1 with ResourceWrapper

use of ca.corefacility.bioinformatics.irida.model.remote.resource.ResourceWrapper in project irida by phac-nml.

the class RemoteRepositoryImpl method read.

/**
 * {@inheritDoc}
 */
@Override
public Type read(String uri, RemoteAPI remoteAPI) {
    OAuthTokenRestTemplate restTemplate = new OAuthTokenRestTemplate(tokenService, remoteAPI);
    ResponseEntity<ResourceWrapper<Type>> exchange = restTemplate.exchange(uri, HttpMethod.GET, HttpEntity.EMPTY, objectTypeReference);
    Type resource = exchange.getBody().getResource();
    resource = setRemoteStatus(resource, remoteAPI);
    return resource;
}
Also used : ResourceWrapper(ca.corefacility.bioinformatics.irida.model.remote.resource.ResourceWrapper) ListResourceWrapper(ca.corefacility.bioinformatics.irida.model.remote.resource.ListResourceWrapper) OAuthTokenRestTemplate(ca.corefacility.bioinformatics.irida.repositories.remote.resttemplate.OAuthTokenRestTemplate)

Example 2 with ResourceWrapper

use of ca.corefacility.bioinformatics.irida.model.remote.resource.ResourceWrapper in project irida by phac-nml.

the class SampleRemoteRepositoryImpl method getSampleMetadata.

/**
 * {@inheritDoc}
 */
public Map<String, MetadataEntry> getSampleMetadata(Sample sample) {
    logger.trace("Requesting sample metadata for sample " + sample.getSelfHref());
    RemoteAPI remoteAPI = sample.getRemoteStatus().getApi();
    OAuthTokenRestTemplate restTemplate = new OAuthTokenRestTemplate(tokenService, remoteAPI);
    // get the metadata link
    Link metadataLink = sample.getLink(METADATA_REL);
    // request metadata response
    ResponseEntity<ResourceWrapper<SampleMetadataWrapper>> exchange = restTemplate.exchange(metadataLink.getHref(), HttpMethod.GET, HttpEntity.EMPTY, metadataTypeReference);
    // pull metadata response from request
    Map<String, MetadataEntry> resource = exchange.getBody().getResource().getMetadata();
    return resource;
}
Also used : RemoteAPI(ca.corefacility.bioinformatics.irida.model.RemoteAPI) ResourceWrapper(ca.corefacility.bioinformatics.irida.model.remote.resource.ResourceWrapper) ListResourceWrapper(ca.corefacility.bioinformatics.irida.model.remote.resource.ListResourceWrapper) MetadataEntry(ca.corefacility.bioinformatics.irida.model.sample.metadata.MetadataEntry) Link(org.springframework.hateoas.Link) OAuthTokenRestTemplate(ca.corefacility.bioinformatics.irida.repositories.remote.resttemplate.OAuthTokenRestTemplate)

Aggregations

ListResourceWrapper (ca.corefacility.bioinformatics.irida.model.remote.resource.ListResourceWrapper)2 ResourceWrapper (ca.corefacility.bioinformatics.irida.model.remote.resource.ResourceWrapper)2 OAuthTokenRestTemplate (ca.corefacility.bioinformatics.irida.repositories.remote.resttemplate.OAuthTokenRestTemplate)2 RemoteAPI (ca.corefacility.bioinformatics.irida.model.RemoteAPI)1 MetadataEntry (ca.corefacility.bioinformatics.irida.model.sample.metadata.MetadataEntry)1 Link (org.springframework.hateoas.Link)1