use of com.hortonworks.registries.common.QueryParam in project registry by hortonworks.
the class DefaultSchemaRegistry method getSchemaBranch.
private SchemaBranch getSchemaBranch(Long id) throws SchemaBranchNotFoundException {
List<QueryParam> schemaBranchQueryParam = new ArrayList<>();
schemaBranchQueryParam.add(new QueryParam(SchemaBranchStorable.ID, id.toString()));
Collection<SchemaBranchStorable> schemaBranchStorables = storageManager.find(SchemaBranchStorable.NAME_SPACE, schemaBranchQueryParam);
if (schemaBranchStorables == null || schemaBranchStorables.isEmpty())
throw new SchemaBranchNotFoundException(String.format("Schema branch with id : '%s' not found", id.toString()));
// size of the collection will always be less than 2, as ID is a primary key, so no need handle the case where size > 1
return schemaBranchStorables.iterator().next().toSchemaBranch();
}
use of com.hortonworks.registries.common.QueryParam in project registry by hortonworks.
the class DefaultSchemaRegistry method getSchemaKey.
private SchemaVersionKey getSchemaKey(Long schemaId) {
SchemaVersionKey schemaVersionKey = null;
List<QueryParam> queryParams = Collections.singletonList(new QueryParam(SchemaVersionStorable.ID, schemaId.toString()));
Collection<SchemaVersionStorable> versionedSchemas = storageManager.find(SchemaVersionStorable.NAME_SPACE, queryParams);
if (versionedSchemas != null && !versionedSchemas.isEmpty()) {
SchemaVersionStorable storable = versionedSchemas.iterator().next();
schemaVersionKey = new SchemaVersionKey(storable.getName(), storable.getVersion());
}
return schemaVersionKey;
}
use of com.hortonworks.registries.common.QueryParam in project registry by hortonworks.
the class DefaultSchemaRegistry method getSchemaBranch.
private SchemaBranch getSchemaBranch(SchemaBranchKey schemaBranchKey) throws SchemaBranchNotFoundException {
List<QueryParam> queryParams = new ArrayList<>();
queryParams.add(new QueryParam(SchemaBranchStorable.NAME, schemaBranchKey.getSchemaBranchName()));
queryParams.add(new QueryParam(SchemaBranchStorable.SCHEMA_METADATA_NAME, schemaBranchKey.getSchemaMetadataName()));
Collection<SchemaBranchStorable> schemaBranchStorables = storageManager.find(SchemaBranchStorable.NAME_SPACE, queryParams);
if (schemaBranchStorables == null || schemaBranchStorables.isEmpty())
throw new SchemaBranchNotFoundException(String.format("Schema branch with key : %s not found", schemaBranchKey));
else if (schemaBranchStorables.size() > 1)
throw new SchemaBranchNotFoundException(String.format("Failed to unique determine a schema branch with key : %s", schemaBranchKey));
return schemaBranchStorables.iterator().next().toSchemaBranch();
}
use of com.hortonworks.registries.common.QueryParam in project registry by hortonworks.
the class StorableTest method buildQueryParamsForPrimaryKey.
protected List<QueryParam> buildQueryParamsForPrimaryKey(Storable storable) {
final Map<Schema.Field, Object> fieldsToVal = storable.getPrimaryKey().getFieldsToVal();
final List<QueryParam> queryParams = new ArrayList<>(fieldsToVal.size());
for (Schema.Field field : fieldsToVal.keySet()) {
QueryParam qp = new QueryParam(field.getName(), fieldsToVal.get(field).toString());
queryParams.add(qp);
}
return queryParams;
}
use of com.hortonworks.registries.common.QueryParam in project registry by hortonworks.
the class AbstractStoreManagerTest method testFind_NonExistentQueryParams_EmptyList.
@Test
public void testFind_NonExistentQueryParams_EmptyList() {
for (StorableTest test : storableTests) {
test.addAllToStorage();
List<QueryParam> queryParams = new ArrayList<QueryParam>() {
{
add(new QueryParam("NON_EXISTING_FIELD_1", "NON_EXISTING_VAL_1"));
add(new QueryParam("NON_EXISTING_FIELD_2", "NON_EXISTING_VAL_2"));
}
};
final Collection<Storable> allMatchingQueryParamsFilter = getStorageManager().find(test.getNameSpace(), queryParams);
assertIterators(Collections.EMPTY_LIST, allMatchingQueryParamsFilter);
}
}
Aggregations