Search in sources :

Example 16 with Collection

use of org.sbolstandard.core2.Collection in project libSBOLj by SynBioDex.

the class SynBioHubFrontend method getSubCollectionMetadata.

/**
 * Search the default store for Collections that are members of the specified Collection
 *
 * @param parentCollectionUri URI for Collection to search for member Collections
 * @return An ArrayList of CollectionMetaData objects with a summary of all matching Collections.
 *
 * @throws SynBioHubException if there was an error communicating with the SynBioHub
 */
public ArrayList<IdentifiedMetadata> getSubCollectionMetadata(URI parentCollectionUri) throws SynBioHubException {
    if (!parentCollectionUri.toString().startsWith(uriPrefix)) {
        throw new SynBioHubException("Object URI does not start with correct URI prefix for this repository.");
    }
    String url = parentCollectionUri + "/subCollections";
    url = url.replace(uriPrefix, backendUrl);
    Gson gson = new Gson();
    HttpGet request = new HttpGet(url);
    request.setHeader("X-authorization", user);
    request.setHeader("Accept", "text/plain");
    try {
        HttpResponse response = client.execute(request);
        checkResponseCode(response);
        InputStream inputStream = response.getEntity().getContent();
        ArrayList<IdentifiedMetadata> metadataList = gson.fromJson(new InputStreamReader(inputStream), new TypeToken<ArrayList<IdentifiedMetadata>>() {
        }.getType());
        return metadataList;
    } catch (Exception e) {
        throw new SynBioHubException(e);
    } finally {
        request.releaseConnection();
    }
}
Also used : InputStreamReader(java.io.InputStreamReader) ByteArrayInputStream(java.io.ByteArrayInputStream) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) TypeToken(com.google.gson.reflect.TypeToken) HttpGet(org.apache.http.client.methods.HttpGet) Gson(com.google.gson.Gson) HttpResponse(org.apache.http.HttpResponse) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) SBOLValidationException(org.sbolstandard.core2.SBOLValidationException)

Aggregations

URI (java.net.URI)8 URIcompliance.createCompliantURI (org.sbolstandard.core2.URIcompliance.createCompliantURI)8 AtlasMapping (io.atlasmap.v2.AtlasMapping)5 Collection (io.atlasmap.v2.Collection)5 ArrayList (java.util.ArrayList)4 HashSet (java.util.HashSet)4 BaseMapping (io.atlasmap.v2.BaseMapping)3 Field (io.atlasmap.v2.Field)3 Mapping (io.atlasmap.v2.Mapping)3 Mappings (io.atlasmap.v2.Mappings)3 QName (javax.xml.namespace.QName)3 Literal (org.sbolstandard.core.datatree.Literal)3 StringifyQName (org.sbolstandard.core.io.json.StringifyQName)3 ConstantField (io.atlasmap.v2.ConstantField)2 FileNotFoundException (java.io.FileNotFoundException)2 IOException (java.io.IOException)2 UnsupportedEncodingException (java.io.UnsupportedEncodingException)2 HttpResponse (org.apache.http.HttpResponse)2 Test (org.junit.Test)2 IdentifiableDocument (org.sbolstandard.core.datatree.IdentifiableDocument)2