Commit 5955fade authored by Rostislav Dublin (EPAM)'s avatar Rostislav Dublin (EPAM)
Browse files

Merge branch 'gcp-bring-sonar-update-with-int-master' into 'master'

Gcp bring sonar update with int master

See merge request !35
parents 5478473c 9c79a0ae
Pipeline #12068 passed with stages
in 34 minutes and 8 seconds
...@@ -109,7 +109,25 @@ ...@@ -109,7 +109,25 @@
</execution> </execution>
</executions> </executions>
</plugin> </plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.7.7.201606060606</version>
<executions>
<execution>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>report</id>
<phase>prepare-package</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins> </plugins>
</build> </build>
</project> </project>
package org.opengroup.osdu.schema.impl.schemainfostore; package org.opengroup.osdu.schema.impl.schemainfostore;
import java.util.Collections; import java.util.Collections;
import java.util.HashSet; import java.util.HashSet;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.Set; import java.util.Set;
import java.util.TreeMap; import java.util.TreeMap;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import org.opengroup.osdu.core.common.logging.JaxRsDpsLog; import org.opengroup.osdu.core.common.logging.JaxRsDpsLog;
import org.opengroup.osdu.core.common.model.http.DpsHeaders; import org.opengroup.osdu.core.common.model.http.DpsHeaders;
import org.opengroup.osdu.core.common.model.tenant.TenantInfo; import org.opengroup.osdu.core.common.model.tenant.TenantInfo;
import org.opengroup.osdu.core.common.provider.interfaces.ITenantFactory; import org.opengroup.osdu.core.common.provider.interfaces.ITenantFactory;
import org.opengroup.osdu.core.gcp.multitenancy.DatastoreFactory; import org.opengroup.osdu.core.gcp.multitenancy.DatastoreFactory;
import org.opengroup.osdu.schema.constants.SchemaConstants; import org.opengroup.osdu.schema.constants.SchemaConstants;
import org.opengroup.osdu.schema.enums.SchemaScope; import org.opengroup.osdu.schema.enums.SchemaScope;
import org.opengroup.osdu.schema.enums.SchemaStatus; import org.opengroup.osdu.schema.enums.SchemaStatus;
import org.opengroup.osdu.schema.exceptions.ApplicationException; import org.opengroup.osdu.schema.exceptions.ApplicationException;
import org.opengroup.osdu.schema.exceptions.BadRequestException; import org.opengroup.osdu.schema.exceptions.BadRequestException;
import org.opengroup.osdu.schema.exceptions.NotFoundException; import org.opengroup.osdu.schema.exceptions.NotFoundException;
import org.opengroup.osdu.schema.model.QueryParams; import org.opengroup.osdu.schema.model.QueryParams;
import org.opengroup.osdu.schema.model.SchemaIdentity; import org.opengroup.osdu.schema.model.SchemaIdentity;
import org.opengroup.osdu.schema.model.SchemaInfo; import org.opengroup.osdu.schema.model.SchemaInfo;
import org.opengroup.osdu.schema.model.SchemaRequest; import org.opengroup.osdu.schema.model.SchemaRequest;
import org.opengroup.osdu.schema.provider.interfaces.schemainfostore.ISchemaInfoStore; import org.opengroup.osdu.schema.provider.interfaces.schemainfostore.ISchemaInfoStore;
import org.opengroup.osdu.schema.util.VersionHierarchyUtil; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value;
import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Repository;
import org.springframework.stereotype.Repository;
import com.google.cloud.Timestamp;
import com.google.cloud.Timestamp; import com.google.cloud.datastore.Blob;
import com.google.cloud.datastore.Blob; import com.google.cloud.datastore.BlobValue;
import com.google.cloud.datastore.BlobValue; import com.google.cloud.datastore.Datastore;
import com.google.cloud.datastore.Datastore; import com.google.cloud.datastore.DatastoreException;
import com.google.cloud.datastore.DatastoreException; import com.google.cloud.datastore.Entity;
import com.google.cloud.datastore.Entity; import com.google.cloud.datastore.EntityQuery;
import com.google.cloud.datastore.EntityQuery; import com.google.cloud.datastore.Key;
import com.google.cloud.datastore.Key; import com.google.cloud.datastore.KeyFactory;
import com.google.cloud.datastore.KeyFactory; import com.google.cloud.datastore.Query;
import com.google.cloud.datastore.Query; import com.google.cloud.datastore.QueryResults;
import com.google.cloud.datastore.QueryResults; import com.google.cloud.datastore.StructuredQuery.CompositeFilter;
import com.google.cloud.datastore.StructuredQuery.CompositeFilter; import com.google.cloud.datastore.StructuredQuery.Filter;
import com.google.cloud.datastore.StructuredQuery.Filter; import com.google.cloud.datastore.StructuredQuery.PropertyFilter;
import com.google.cloud.datastore.StructuredQuery.PropertyFilter; import com.google.gson.Gson;
import com.google.gson.Gson;
/**
/** * Repository class to to register Schema in Google store.
* Repository class to to register Schema in Google store. *
* */
*/
@Repository
@Repository public class GoogleSchemaInfoStore implements ISchemaInfoStore {
public class GoogleSchemaInfoStore implements ISchemaInfoStore {
@Autowired
@Autowired private DpsHeaders headers;
private DpsHeaders headers;
@Autowired
@Autowired private DatastoreFactory dataStoreFactory;
private DatastoreFactory dataStoreFactory;
@Autowired
@Autowired private ITenantFactory tenantFactory;
private ITenantFactory tenantFactory;
@Autowired
@Autowired JaxRsDpsLog log;
JaxRsDpsLog log;
@Value("${account.id.common.project}")
@Value("${account.id.common.project}") private String commonAccountId;
private String commonAccountId;
/**
/** * Method to get schemaInfo from google store
* Method to get schemaInfo from google store *
* * @param schemaId
* @param schemaId * @return schemaInfo object
* @return schemaInfo object * @throws ApplicationException
* @throws ApplicationException * @throws NotFoundException
* @throws NotFoundException */
*/ @Override
@Override public SchemaInfo getSchemaInfo(String schemaId) throws ApplicationException, NotFoundException {
public SchemaInfo getSchemaInfo(String schemaId) throws ApplicationException, NotFoundException { Datastore datastore = dataStoreFactory.getDatastore(headers.getPartitionId(), SchemaConstants.NAMESPACE);
Datastore datastore = dataStoreFactory.getDatastore(headers.getPartitionId(), SchemaConstants.NAMESPACE); Key key = datastore.newKeyFactory().setNamespace(SchemaConstants.NAMESPACE).setKind(SchemaConstants.SCHEMA_KIND)
Key key = datastore.newKeyFactory().setNamespace(SchemaConstants.NAMESPACE).setKind(SchemaConstants.SCHEMA_KIND) .newKey(schemaId);
.newKey(schemaId); Entity entity = datastore.get(key);
Entity entity = datastore.get(key); if (entity != null) {
if (entity != null) { return getSchemaInfoObject(entity, datastore);
return getSchemaInfoObject(entity, datastore); }
} throw new NotFoundException(SchemaConstants.SCHEMA_NOT_PRESENT);
throw new NotFoundException(SchemaConstants.SCHEMA_NOT_PRESENT);
}
}
/**
/** * Method to Create schema in google store of tenantId GCP
* Method to Create schema in google store of tenantId GCP *
* * @param schema
* @param schema * @param tenantId
* @param tenantId * @return schemaInfo object
* @return schemaInfo object * @throws ApplicationException
* @throws ApplicationException * @throws BadRequestException
* @throws BadRequestException */
*/ @Override
@Override public SchemaInfo createSchemaInfo(SchemaRequest schema) throws ApplicationException, BadRequestException {
public SchemaInfo createSchemaInfo(SchemaRequest schema) throws ApplicationException, BadRequestException { Datastore datastore = dataStoreFactory.getDatastore(headers.getPartitionId(), SchemaConstants.NAMESPACE);
Datastore datastore = dataStoreFactory.getDatastore(headers.getPartitionId(), SchemaConstants.NAMESPACE); KeyFactory keyFactory = datastore.newKeyFactory().setNamespace(SchemaConstants.NAMESPACE)
KeyFactory keyFactory = datastore.newKeyFactory().setNamespace(SchemaConstants.NAMESPACE) .setKind(SchemaConstants.SCHEMA_KIND);
.setKind(SchemaConstants.SCHEMA_KIND); Entity entity = getEntityObject(schema, datastore, keyFactory);
Entity entity = getEntityObject(schema, datastore, keyFactory); try {
try { datastore.add(entity);
datastore.add(entity); } catch (DatastoreException ex) {
} catch (DatastoreException ex) { if (SchemaConstants.ALREADY_EXISTS.equals(ex.getReason())) {
if (SchemaConstants.ALREADY_EXISTS.equals(ex.getReason())) { log.warning(SchemaConstants.SCHEMA_ID_EXISTS);
log.warning(SchemaConstants.SCHEMA_ID_EXISTS); throw new BadRequestException(SchemaConstants.SCHEMA_ID_EXISTS);
throw new BadRequestException(SchemaConstants.SCHEMA_ID_EXISTS); } else {
} else { log.error(SchemaConstants.OBJECT_INVALID);
log.error(SchemaConstants.OBJECT_INVALID); throw new ApplicationException(SchemaConstants.SCHEMA_CREATION_FAILED_INVALID_OBJECT);
throw new ApplicationException(SchemaConstants.SCHEMA_CREATION_FAILED_INVALID_OBJECT); }
} }
} log.info(SchemaConstants.SCHEMA_INFO_CREATED);
log.info(SchemaConstants.SCHEMA_INFO_CREATED); return getSchemaInfoObject(entity, datastore);
return getSchemaInfoObject(entity, datastore); }
}
/**
/** * Method to update schema in google store of tenantId GCP
* Method to update schema in google store of tenantId GCP *
* * @param schema
* @param schema * @param tenantId
* @param tenantId * @return schemaInfo object
* @return schemaInfo object * @throws ApplicationException
* @throws ApplicationException * @throws BadRequestException
* @throws BadRequestException */
*/ @Override
@Override public SchemaInfo updateSchemaInfo(SchemaRequest schema) throws ApplicationException, BadRequestException {
public SchemaInfo updateSchemaInfo(SchemaRequest schema) throws ApplicationException, BadRequestException { Datastore datastore = dataStoreFactory.getDatastore(headers.getPartitionId(), SchemaConstants.NAMESPACE);
Datastore datastore = dataStoreFactory.getDatastore(headers.getPartitionId(), SchemaConstants.NAMESPACE); KeyFactory keyFactory = datastore.newKeyFactory().setNamespace(SchemaConstants.NAMESPACE)
KeyFactory keyFactory = datastore.newKeyFactory().setNamespace(SchemaConstants.NAMESPACE) .setKind(SchemaConstants.SCHEMA_KIND);
.setKind(SchemaConstants.SCHEMA_KIND); Entity entity = getEntityObject(schema, datastore, keyFactory);
Entity entity = getEntityObject(schema, datastore, keyFactory); try {
try { datastore.put(entity);
datastore.put(entity); } catch (DatastoreException ex) {
} catch (DatastoreException ex) { log.error(SchemaConstants.OBJECT_INVALID);
log.error(SchemaConstants.OBJECT_INVALID); throw new ApplicationException("Invalid object, updation failed");
throw new ApplicationException("Invalid object, updation failed"); }
} log.info(SchemaConstants.SCHEMA_INFO_UPDATED);
log.info(SchemaConstants.SCHEMA_INFO_UPDATED); return getSchemaInfoObject(entity, datastore);
return getSchemaInfoObject(entity, datastore); }
}
/**
/** * Method to clean schemaInfo in google datastore of tenantId GCP
* Method to clean schemaInfo in google datastore of tenantId GCP *
* * @param schemaId
* @param schemaId * @return status
* @return status * @throws ApplicationException
* @throws ApplicationException */
*/ @Override
@Override public boolean cleanSchema(String schemaId) throws ApplicationException {
public boolean cleanSchema(String schemaId) throws ApplicationException { Datastore datastore = dataStoreFactory.getDatastore(headers.getPartitionId(), SchemaConstants.NAMESPACE);
Datastore datastore = dataStoreFactory.getDatastore(headers.getPartitionId(), SchemaConstants.NAMESPACE); KeyFactory keyFactory = datastore.newKeyFactory().setNamespace(SchemaConstants.NAMESPACE)
KeyFactory keyFactory = datastore.newKeyFactory().setNamespace(SchemaConstants.NAMESPACE) .setKind(SchemaConstants.SCHEMA_KIND);
.setKind(SchemaConstants.SCHEMA_KIND); Key key = keyFactory.newKey(schemaId);
Key key = keyFactory.newKey(schemaId); try {
try { datastore.delete(key);
datastore.delete(key); return true;
return true; } catch (DatastoreException ex) {
} catch (DatastoreException ex) { return false;
return false; }
} }
}
@Override
@Override public String getLatestMinorVerSchema(SchemaInfo schemaInfo) throws ApplicationException {
public String getLatestMinorVerSchema(SchemaInfo schemaInfo) throws ApplicationException { Datastore datastore = dataStoreFactory.getDatastore(headers.getPartitionId(), SchemaConstants.NAMESPACE);
Datastore datastore = dataStoreFactory.getDatastore(headers.getPartitionId(), SchemaConstants.NAMESPACE); Query<Entity> query = Query.newEntityQueryBuilder().setNamespace(SchemaConstants.NAMESPACE)
Query<Entity> query = Query.newEntityQueryBuilder().setNamespace(SchemaConstants.NAMESPACE) .setKind(SchemaConstants.SCHEMA_KIND)
.setKind(SchemaConstants.SCHEMA_KIND) .setFilter(CompositeFilter.and(
.setFilter(CompositeFilter.and( PropertyFilter.eq(SchemaConstants.AUTHORITY, schemaInfo.getSchemaIdentity().getAuthority()),
PropertyFilter.eq(SchemaConstants.AUTHORITY, schemaInfo.getSchemaIdentity().getAuthority()), PropertyFilter.eq(SchemaConstants.ENTITY_TYPE, schemaInfo.getSchemaIdentity().getEntityType()),
PropertyFilter.eq(SchemaConstants.ENTITY_TYPE, schemaInfo.getSchemaIdentity().getEntityType()), PropertyFilter.eq(SchemaConstants.MAJOR_VERSION,
PropertyFilter.eq(SchemaConstants.MAJOR_VERSION, schemaInfo.getSchemaIdentity().getSchemaVersionMajor()),
schemaInfo.getSchemaIdentity().getSchemaVersionMajor()), PropertyFilter.eq(SchemaConstants.SOURCE, schemaInfo.getSchemaIdentity().getSource())))
PropertyFilter.eq(SchemaConstants.SOURCE, schemaInfo.getSchemaIdentity().getSource()))) .build();
.build();
QueryResults<Entity> result = datastore.run(query);
QueryResults<Entity> result = datastore.run(query); TreeMap<Long, Blob> sortedMap = new TreeMap<>(Collections.reverseOrder());
TreeMap<Long, Blob> sortedMap = new TreeMap<>(Collections.reverseOrder()); while (result.hasNext()) {
while (result.hasNext()) { Entity entity = result.next();
Entity entity = result.next(); sortedMap.put(entity.getLong(SchemaConstants.MINOR_VERSION), entity.getBlob(SchemaConstants.SCHEMA));
sortedMap.put(entity.getLong(SchemaConstants.MINOR_VERSION), entity.getBlob(SchemaConstants.SCHEMA)); }
} if (sortedMap.size() != 0) {
if (sortedMap.size() != 0) { Entry<Long, Blob> blob = sortedMap.firstEntry();
Entry<Long, Blob> blob = sortedMap.firstEntry(); return new String(blob.getValue().toByteArray());
return new String(blob.getValue().toByteArray()); }
} return new String();
return new String(); }
}
private SchemaInfo getSchemaInfoObject(Entity entity, Datastore datastore) {
private SchemaInfo getSchemaInfoObject(Entity entity, Datastore datastore) {
SchemaIdentity superSededBy = null;
SchemaIdentity superSededBy = null; if (entity.contains(SchemaConstants.SUPERSEDED_BY)) {
if (entity.contains(SchemaConstants.SUPERSEDED_BY)) { KeyFactory keyFactory = datastore.newKeyFactory().setNamespace(SchemaConstants.NAMESPACE)
KeyFactory keyFactory = datastore.newKeyFactory().setNamespace(SchemaConstants.NAMESPACE) .setKind(SchemaConstants.SCHEMA_KIND);
.setKind(SchemaConstants.SCHEMA_KIND); Entity superSededEntity = datastore.get(keyFactory.newKey(entity.getString(SchemaConstants.SUPERSEDED_BY)));
Entity superSededEntity = datastore.get(keyFactory.newKey(entity.getString(SchemaConstants.SUPERSEDED_BY))); superSededBy = getSchemaIdentity(superSededEntity);
superSededBy = getSchemaIdentity(superSededEntity); }
}
return SchemaInfo.builder().createdBy(entity.getString(SchemaConstants.CREATED_BY))
return SchemaInfo.builder().createdBy(entity.getString(SchemaConstants.CREATED_BY)) .dateCreated(entity.getTimestamp(SchemaConstants.DATE_CREATED).toDate())
.dateCreated(entity.getTimestamp(SchemaConstants.DATE_CREATED).toDate()) .scope(SchemaScope.valueOf(entity.getString(SchemaConstants.SCOPE)))
.scope(SchemaScope.valueOf(entity.getString(SchemaConstants.SCOPE))) .status(SchemaStatus.valueOf(entity.getString(SchemaConstants.STATUS)))
.status(SchemaStatus.valueOf(entity.getString(SchemaConstants.STATUS))) .schemaIdentity(getSchemaIdentity(entity)).supersededBy(superSededBy).build();
.schemaIdentity(getSchemaIdentity(entity)).supersededBy(superSededBy).build();
}
}
private Entity getEntityObject(SchemaRequest schema, Datastore datastore, KeyFactory keyFactory)
private Entity getEntityObject(SchemaRequest schema, Datastore datastore, KeyFactory keyFactory) throws BadRequestException, ApplicationException {
throws BadRequestException, ApplicationException {
Key key = keyFactory.newKey(schema.getSchemaInfo().getSchemaIdentity().getId());
Key key = keyFactory.newKey(schema.getSchemaInfo().getSchemaIdentity().getId());
Entity.Builder entityBuilder = Entity.newBuilder(key);
Entity.Builder entityBuilder = Entity.newBuilder(key); if (schema.getSchemaInfo().getSupersededBy() != null) {
if (schema.getSchemaInfo().getSupersededBy() != null) { if (schema.getSchemaInfo().getSupersededBy().getId() == null
if (schema.getSchemaInfo().getSupersededBy().getId() == null || datastore.get(keyFactory.newKey(schema.getSchemaInfo().getSupersededBy().getId())) == null) {
|| datastore.get(keyFactory.newKey(schema.getSchemaInfo().getSupersededBy().getId())) == null) { log.error(SchemaConstants.INVALID_SUPERSEDEDBY_ID);
log.error(SchemaConstants.INVALID_SUPERSEDEDBY_ID); throw new BadRequestException(SchemaConstants.INVALID_SUPERSEDEDBY_ID);
throw new BadRequestException(SchemaConstants.INVALID_SUPERSEDEDBY_ID); }
} entityBuilder.set(SchemaConstants.SUPERSEDED_BY, schema.getSchemaInfo().getSupersededBy().getId());
entityBuilder.set(SchemaConstants.SUPERSEDED_BY, schema.getSchemaInfo().getSupersededBy().getId()); }
}
entityBuilder.set(SchemaConstants.DATE_CREATED, Timestamp.now());
entityBuilder.set(SchemaConstants.DATE_CREATED, Timestamp.now()); entityBuilder.set(SchemaConstants.CREATED_BY, headers.getUserEmail());
entityBuilder.set(SchemaConstants.CREATED_BY, headers.getUserEmail()); entityBuilder.set(SchemaConstants.AUTHORITY, schema.getSchemaInfo().getSchemaIdentity().getAuthority());
entityBuilder.set(SchemaConstants.AUTHORITY, schema.getSchemaInfo().getSchemaIdentity().getAuthority()); entityBuilder.set(SchemaConstants.SOURCE, schema.getSchemaInfo().getSchemaIdentity().getSource());
entityBuilder.set(SchemaConstants.SOURCE, schema.getSchemaInfo().getSchemaIdentity().getSource()); entityBuilder.set(SchemaConstants.ENTITY_TYPE, schema.getSchemaInfo().getSchemaIdentity().getEntityType());
entityBuilder.set(SchemaConstants.ENTITY_TYPE, schema.getSchemaInfo().getSchemaIdentity().getEntityType()); entityBuilder.set(SchemaConstants.MAJOR_VERSION,
entityBuilder.set(SchemaConstants.MAJOR_VERSION, schema.getSchemaInfo().getSchemaIdentity().getSchemaVersionMajor());
schema.getSchemaInfo().getSchemaIdentity().getSchemaVersionMajor()); entityBuilder.set(SchemaConstants.MINOR_VERSION,
entityBuilder.set(SchemaConstants.MINOR_VERSION, schema.getSchemaInfo().getSchemaIdentity().getSchemaVersionMinor());
schema.getSchemaInfo().getSchemaIdentity().getSchemaVersionMinor()); entityBuilder.set(SchemaConstants.PATCH_VERSION,
entityBuilder.set(SchemaConstants.PATCH_VERSION, schema.getSchemaInfo().getSchemaIdentity().getSchemaVersionPatch());
schema.getSchemaInfo().getSchemaIdentity().getSchemaVersionPatch()); entityBuilder.set(SchemaConstants.SCOPE, schema.getSchemaInfo().getScope().name());
entityBuilder.set(SchemaConstants.SCOPE, schema.getSchemaInfo().getScope().name()); entityBuilder.set(SchemaConstants.STATUS, schema.getSchemaInfo().getStatus().name());
entityBuilder.set(SchemaConstants.STATUS, schema.getSchemaInfo().getStatus().name()); Gson gson = new Gson();
Gson gson = new Gson(); Blob schemaBlob = Blob.copyFrom(gson.toJson(schema.getSchema()).getBytes());
Blob schemaBlob = Blob.copyFrom(gson.toJson(schema.getSchema()).getBytes()); entityBuilder.set(SchemaConstants.SCHEMA, BlobValue.newBuilder(schemaBlob).setExcludeFromIndexes(true).build());
entityBuilder.set(SchemaConstants.SCHEMA, BlobValue.newBuilder(schemaBlob).setExcludeFromIndexes(true).build());
return entityBuilder.build();
return entityBuilder.build(); }
}
private SchemaIdentity getSchemaIdentity(Entity entity) {
private SchemaIdentity getSchemaIdentity(Entity entity) {
return SchemaIdentity.builder().id(entity.getKey().getName())
return SchemaIdentity.builder().id(entity.getKey().getName()) .authority(entity.getString(SchemaConstants.AUTHORITY)).source(entity.getString(SchemaConstants.SOURCE))
.authority(entity.getString(SchemaConstants.AUTHORITY)).source(entity.getString(SchemaConstants.SOURCE)) .entityType(entity.getString(SchemaConstants.ENTITY_TYPE))
.entityType(entity.getString(SchemaConstants.ENTITY_TYPE)) .schemaVersionMajor(entity.getLong(SchemaConstants.MAJOR_VERSION))
.schemaVersionMajor(entity.getLong(SchemaConstants.MAJOR_VERSION)) .schemaVersionMinor(entity.getLong(SchemaConstants.MINOR_VERSION))
.schemaVersionMinor(entity.getLong(SchemaConstants.MINOR_VERSION)) .schemaVersionPatch(entity.getLong(SchemaConstants.PATCH_VERSION)).build();
.schemaVersionPatch(entity.getLong(SchemaConstants.PATCH_VERSION)).build();
}
}
@Override
@Override public List<SchemaInfo> getSchemaInfoList(QueryParams queryParams, String tenantId) throws ApplicationException {
public List<SchemaInfo> getSchemaInfoList(QueryParams queryParams, String tenantId) throws ApplicationException { Datastore datastore = dataStoreFactory.getDatastore(tenantId, SchemaConstants.NAMESPACE);
Datastore datastore = dataStoreFactory.getDatastore(tenantId, SchemaConstants.NAMESPACE); List<Filter> filterList = getFilters(queryParams);
List<Filter> filterList = getFilters(queryParams);
EntityQuery.Builder queryBuilder = Query.newEntityQueryBuilder().setNamespace(SchemaConstants.NAMESPACE)
EntityQuery.Builder queryBuilder = Query.newEntityQueryBuilder().setNamespace(SchemaConstants.NAMESPACE) .setKind(SchemaConstants.SCHEMA_KIND);
.setKind(SchemaConstants.SCHEMA_KIND);
if (!filterList.isEmpty()) {
if (!filterList.isEmpty()) { queryBuilder.setFilter(
queryBuilder.setFilter( CompositeFilter.and(filterList.get(0), filterList.toArray(new Filter[filterList.size()])));
CompositeFilter.and(filterList.get(0), filterList.toArray(new Filter[filterList.size()]))); }
}
QueryResults<Entity> result = datastore.run(queryBuilder.build());
QueryResults<Entity> result = datastore.run(queryBuilder.build()); List<SchemaInfo> schemaList = new LinkedList<>();
List<SchemaInfo> schemaList = new LinkedList<>(); while (result.hasNext()) {
while (result.hasNext()) { Entity entity = result.next();
Entity entity = result.next(); schemaList.add(getSchemaInfoObject(entity, datastore));
schemaList.add(getSchemaInfoObject(entity, datastore)); }
}