DynamoDB fetch query - java

#DynamoDBTable(tableName = "OrderDashboardMetadata")
public class OrderDashBoardMetaData {
private int position;
private Date ETA = null;
private List<String> notes;
#DynamoDBHashKey(attributeName = "queueName")
private String queueName;
#DynamoDBRangeKey(attributeName = "orderId")
private String orderId;
#DynamoDBIndexHashKey(globalSecondaryIndexName = "city")
private String city;
#DynamoDBIndexRangeKey(globalSecondaryIndexName = "city")
private String fcId;
#DynamoDBIndexHashKey(globalSecondaryIndexName = "orderState")
private String orderState;
#DynamoDBAttribute(attributeName = "action")
private String action;
#DynamoDBAttribute(attributeName = "createdTime")
private Date createdTime = new Date();
#DynamoDBAttribute(attributeName = "updatedTime")
private Date updatedTime = new Date();
Hi
I have a table structure like the one above.
What would be query to fetch results only that have
1) queueName -- > PFS
2) ETA --> greater than 1st jan 2017
3)order state -- PO
Kindly suggest full query for the above scenario in JAVA.

Since you have not annotated so assuming ETA is also an DDBAttribute
Map<String, AttributeValue> expValues = new HashMap<>();
expValues.put(":hv", new AttributeValue("PFS"));
expValues.put(":osv", new AttributeValue("PO"));
expValues.put(":etav", new AttributeValue("2017-01-01"));
QueryRequest q = new QueryRequest("OrderDashboardMetadata");
q.setKeyConditionExpression("queueName = :hv");
q.setFilterExpression("orderState = :osv and ETA > :etav");
q.setExpressionAttributeValues(expValues);
QueryResult r = dbClient.query(q);
Note: Dates are stored as S (string type). The Date values are stored as ISO-8601 formatted strings.

Related

java.util.NoSuchElementException: No value present

So my problem is in a Test, when I call the method to test it gives this error:
java.util.NoSuchElementException: No value present
at java.base/java.util.Optional.get(Optional.java:143)
at com.MD.Medicine.Services.SaveService.savePlans(SaveService.java:57)
at com.MD.Medicine.Services.SaveServiceTest.testSavePlans_failPills(SaveServiceTest.java:99)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
My test:
#SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
public class SaveServiceTest {
#MockBean
private MedsRepo medsRepo;
#MockBean
private PlansRepo plansRepo;
#MockBean
private PlanDayRepo planDayRepo;
#Autowired
private SaveService saveService;
#Test
void testSavePlans_failPills() {
LocalDate date = LocalDate.now();
Date date3 = new Date(1673740800000L);
Set<PlanDay> setPlans = new HashSet<>();
Plans plans = new Plans(1, setPlans);
BigDecimal price = new BigDecimal(8.00);
Meds meds = new Meds(1, "Brufen", price, "Pain", 200, date, setPlans);
when(medsRepo.getReferenceById(meds.getMedsId())).thenReturn(meds);
int pillNumber = meds.getPillNumber();
List<PlanDay> planList3 = new ArrayList<PlanDay>();
PlanDay planDay3 = new PlanDay(1, date3, "Tuesday", plans, meds, 50000);
planList3.add(planDay3);
String expected3 = saveService.savePlans(planList3);
assertThat(expected3).isEqualTo("Error: No piils available (Existing Pills: " + pillNumber + ")");
}
When it gets in * String expected3 = saveService.savePlans(planList3);* it stops and prints the error.
The method:
public String savePlans(List<PlanDay> plans) throws Error {
//long planIdVerify = plans.get(0).getPlanDaysId();
Date firstDate = plans.get(0).getPlanDate();
long todayMili = System.currentTimeMillis();
long dateLimitMili = firstDate.getTime() + 604800000;
long planId = plans.get(0).getPlans().getPlanId();
Plans plansWithId = new Plans();
plansWithId.setPlanId(planId);
plansRepo.save(plansWithId);
for (int i = 0; i < plans.size(); i++) {
long planDateInMili = plans.get(i).getPlanDate().getTime();
//long planIdMultiVerify = plans.get(i).getPlanDaysId();
if (planDateInMili <= dateLimitMili && todayMili<planDateInMili ) {
PlanDay planDay = plans.get(i);
long medsId = planDay.getMeds().getMedsId();
int medsToTake = planDay.getMedsToTake();
int pillNumber = medsRepo.getReferenceById(medsId).getPillNumber();
int pillUpdate = pillNumber - medsToTake;
Meds updatePlanDay = medsRepo.findById(medsId).get();
if (pillUpdate > 0) {
updatePlanDay.setPillNumber(pillUpdate);
} else {
return "Error: No piils available (Existing Pills: " + pillNumber + ")";
}
planDayRepo.save(planDay);
} else {
return "Week time interval not correct/Invalid planId (only one plan can be saved)";
}
}
return "Saved Successfully";
}
and my entities:
#Data
#AllArgsConstructor
#NoArgsConstructor
#Entity
#Table(name = "meds")
#JsonIgnoreProperties(value = { "days" })
public class Meds {
#Id
#GeneratedValue(strategy = GenerationType.IDENTITY)
private long medsId;
#Column
private String medsName;
#Column
private BigDecimal price;
#Column
private String category;
#Column
private int pillNumber;
#Column
#CreationTimestamp
private LocalDate medsDate;
#OneToMany(mappedBy = "meds", cascade = {CascadeType.REMOVE}, fetch = FetchType.LAZY)
#OnDelete(action = OnDeleteAction.CASCADE)
private Set<PlanDay> days = new HashSet<PlanDay>();
}
#Data
#AllArgsConstructor
#NoArgsConstructor
#Entity
#Table(name = "planDay")
#JsonIgnoreProperties(value = { "planDaysId" })
public class PlanDay {
#Id
#GeneratedValue(strategy = GenerationType.IDENTITY)
private long planDaysId;
#Column
private Date planDate;
#Column
private String weekday;
#ManyToOne
#JoinColumn(name = "planId", nullable = false)
private Plans plans;
#ManyToOne
#JoinColumn(name = "medsId", nullable = false)
private Meds meds;
#Column
private int medsToTake;
}
I have been looking for a solution and the orElse() method was one of the options but I can't make it work.. What would be a solution for this problem?
Kind Regards.
MedsRepo is a MockBean when you call medsRepo.findById(medsId) it will return an empty optional because you have no when for that method.
int pillNumber = medsRepo.getReferenceById(medsId).getPillNumber(); //extract the Meds as a variable and keep using this
int pillUpdate = pillNumber - medsToTake;
Meds updatePlanDay = medsRepo.findById(medsId).get(); //trying to get the same as you did above
Should be
Meds updatePlanDay = medsRepo.getReferenceById(medsId);
int pillNumber = updatePlanDay.getPillNumber();
int pillUpdate = pillNumber - medsToTake;
//Meds updatePlanDay = medsRepo.findById(medsId).get(); no longer needed
Also on a different note you should look into the difference between findById and getReferenceById and what happens when there is no Meds with that medsId

JPA CriteriaBuilder with CONCAT_WS function throws NullPointerException

I have the following CriteriaQuery that I use to filter orders.
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<OrderReducedDTO> cq = cb.createQuery(OrderReducedDTO.class);
Root<Order> root = cq.from(Order.class);
Join<Order, Customer> joinCustomer = root.join(Order_.customer);
Join<Order, Shipment> joinShipment = root.join(Order_.shipment);
Join<Shipment, Carrier> joinCarrier = joinShipment.join(Shipment_.carrier);
Join<Order, Payment> joinPayment = root.join(Order_.payment);
Join<Payment, PaymentMethod> joinPaymentMethod = joinPayment.join(Payment_.paymentMethod);
Join<Shipment, Country> joinCountry = joinShipment.join(Shipment_.country);
cq.select(cb.construct(
OrderReducedDTO.class,
root.get(Order_.id),
root.get(Order_.incrementId),
root.get(Order_.state),
root.get(Order_.couponCode),
root.get(Order_.totalDiscount),
root.get(Order_.total),
root.get(Order_.originChannel),
root.get(Order_.branchOffice),
joinCarrier.get(Carrier_.carrierCode),
cb.function("CONCAT_WS", String.class,
cb.literal(","),
joinShipment.get(Shipment_.streetName),
joinShipment.get(Shipment_.streetNumber),
joinShipment.get(Shipment_.city),
joinCountry.get(Country_.name),
joinShipment.get(Shipment_.zipCode)
),
joinPaymentMethod.get(PaymentMethod_.code),
joinPayment.get(Payment_.paymentDate),
root.get(Order_.createdAt),
root.get(Order_.updatedAt),
root.get(Order_.externalId),
joinCustomer.get(Customer_.fullName)
));
... filters and predicates...
The part that's giving me trouble and causing a NPE to be thrown is this
cb.function("CONCAT_WS", String.class,
cb.literal(","),
joinShipment.get(Shipment_.streetName),
joinShipment.get(Shipment_.streetNumber),
joinShipment.get(Shipment_.city),
joinCountry.get(Country_.name),
joinShipment.get(Shipment_.zipCode)
)
More, specifically, when I use the CONCAT_WS function. If I use CONCAT, it works.
This is the stacktrace I get:
java.lang.NullPointerException: null
at org.hibernate.hql.internal.NameGenerator.generateColumnNames(NameGenerator.java:27)
at org.hibernate.hql.internal.ast.util.SessionFactoryHelper.generateColumnNames(SessionFactoryHelper.java:434)
at org.hibernate.hql.internal.ast.tree.SelectClause.initializeColumnNames(SelectClause.java:270)
at org.hibernate.hql.internal.ast.tree.SelectClause.finishInitialization(SelectClause.java:260)
at org.hibernate.hql.internal.ast.tree.SelectClause.initializeExplicitSelectClause(SelectClause.java:255)
at org.hibernate.hql.internal.ast.HqlSqlWalker.useSelectClause(HqlSqlWalker.java:1026)
...
This is my OrderReducedDTO
#Getter
public class OrderReducedDTO {
#JsonProperty("order_id")
private Integer orderId;
#JsonProperty("increment_id")
private String incrementId;
private OrderStates state;
#JsonProperty("coupon_code")
private String couponCode;
#JsonProperty("total_discount")
private BigDecimal totalDiscount;
private BigDecimal total;
#JsonProperty("origin_channel")
private String originChannel;
#JsonProperty("branch_office")
private String branchOffice;
#JsonProperty("shipping_method")
private String shippingMethod;
#JsonProperty("shipping_address")
private String shippingAddress;
#JsonProperty("payment_method")
private String paymentMethod;
#JsonProperty("payment_date")
private Timestamp paymentDate;
#JsonProperty("created_at")
private Timestamp createdAt;
#JsonProperty("updated_at")
private Timestamp updatedAt;
#JsonProperty("external_id")
private String externalId;
#JsonProperty("customer_full_name")
private String customerFullName;
#Setter
private List<OrderProductReducedDTO> products;
public OrderReducedDTO(Integer orderId,
String incrementId,
OrderStates state,
String couponCode,
BigDecimal totalDiscount,
BigDecimal total,
String originChannel,
String branchOffice,
String shippingMethod,
String shippingAddress,
String paymentMethod,
Object paymentDate,
Object createdAt,
Object updatedAt,
String externalId,
String customerFullName) {
this.orderId = orderId;
this.incrementId = incrementId;
this.state = state;
this.couponCode = couponCode;
this.totalDiscount = totalDiscount;
this.total = total;
this.originChannel = originChannel;
this.branchOffice = branchOffice;
this.shippingMethod = shippingMethod;
this.shippingAddress = shippingAddress;
this.paymentMethod = paymentMethod;
this.paymentDate = (Timestamp) paymentDate;
this.createdAt = (Timestamp) createdAt; //https://hibernate.atlassian.net/browse/HHH-4179
this.updatedAt = (Timestamp) updatedAt;
this.externalId = externalId;
this.customerFullName = customerFullName;
}
}
What I mainly want to know is if I'm using the function method correctly. I assume I am because CONCAT works.
After hours of debugging within Hibernate, I finally arrived at the root of the problem:
org/hibernate/hql/internal/ast/tree/ConstructorNode.java
private Type[] resolveConstructorArgumentTypes() throws SemanticException {
SelectExpression[] argumentExpressions = this.collectSelectExpressions();
if (argumentExpressions == null) {
return new Type[0];
} else {
Type[] types = new Type[argumentExpressions.length];
for(int x = 0; x < argumentExpressions.length; ++x) {
types[x] = argumentExpressions[x].getDataType();
}
return types;
}
}
argumentExpressions[x].getDataType() was returning null.
I googled and found out that this could be caused by Hibernate not knowing the actual return type of the given SQL function (apparently it only knows the most common ones).
I then followed this answer and implemented a custom MetadataBuilderContributor like so:
public class SqlFunctionsMetadataBuilderContributor implements MetadataBuilderContributor {
#Override
public void contribute(MetadataBuilder metadataBuilder) {
metadataBuilder.applySqlFunction(
"concat_ws",
new StandardSQLFunction("concat_ws", StandardBasicTypes.STRING)
);
}
}
And on my application.properties I added:
spring.jpa.properties.hibernate.metadata_builder_contributor=ar.com.glamit.glamitoms.config.hibernate.SqlFunctionsMetadataBuilderContributor
After relaunching the app, argumentExpressions[x].getDataType() now returns a StringType and the NullPointerException is gone.

How to Convert MongoDB Query to Spring Data Query

I'm trying to convert the following Mongo query for use with Spring data.
db.product.aggregate([
{$unwind: '$barcodes'},
{$project: {
_id: 0,
productId: '$_id',
productTitle: '$title',
productVariation: '$variation',
barcode: '$barcodes'
}}])
This is what I've been trying so far. It returns the aggregation, but with null values:
UnwindOperation unwindOperation = Aggregation.unwind("barcodes");
ProjectionOperation projectStage = Aggregation.project().and("productId").as("_id").and("productTitle")
.as("title")
.and("productVariation").as("variation")
.and("barcodeTitle").as("barcodes.title")
.and("barcodeValue").as("barcodes.value")
.and("barcodeType").as("barcodes.type")
.and("codeStandard").as("barcodes.codeStandard")
.and("quantity").as("barcodes.quantity")
.and("status").as("barcodes.status");
SortOperation sortOperation = Aggregation.sort(Sort.by(Sort.Direction.DESC, "title"));
Aggregation agg = Aggregation.newAggregation(unwindOperation, projectStage, sortOperation);
AggregationResults<BarcodeAggregateList> results = mongoTemplate.aggregate(agg, "product", BarcodeAggregateList.class);
What it is returning:
The class I am mapping to (has getters/setters):
public class BarcodeAggregateList {
private String productId;
private String productTitle;
private String productVariation;
private String barcodeTitle;
private String barcodeValue;
private String barcodeType;
private String codeStandard;
private int quantity;
private String status;
}
Product class that the data is coming from:
public class Product implements Serializable {
private static final long serialVersionUID = -998149317494604215L;
private String id;
private String title;
private String description;
private String SKU;
private double cost;
private double retailPrice;
private String status;
private LocalDate launchDate;
private LocalDate discontinueDate;
private String discontinueReason;
private String salesChannel;
private List<Barcode> barcodes;
private ProductVariation variation;
private List<Supplier> supplier;
private Product parentProduct;
private boolean updateChildren;
private Label label;
private int secondaryStockLevel;
private int primaryStockLevel;
private Date createdDate;
private Date modifiedDate;
private List<Dimension> dimensions;
private boolean isDeleted = false;
}
Barcode class
public class Barcode {
private String type;
private String title;
private String value;
private String status;
private String codeStandard;
private int quantity;
}
I appreciate any help with this or resources to help me better understand how to perform these types of conversions.
For anyone trying to solve similar issues, I've found the following resources somewhat helpful:
https://docs.spring.io/spring-data/mongodb/docs/current/reference/html/#mongo.query
https://xpadro.com/2016/04/data-aggregation-with-spring-data-mongodb-and-spring-boot.html
https://www.tutorialspoint.com/get-fields-from-multiple-sub-documents-that-match-a-condition-in-mongodb
BarcodeAggregateList class fields are null because there is a minor issue in ProjectionOperation's and() and as() methods. The correct syntax is
Aggregation.project().and(SOURCE_FIELD).as(TARGET_FIELD)
You have written and("productId").as("_id") , which is wrong
You need to write this as and("_id").as("productId") , because source field is _id
complete code:
UnwindOperation unwindOperation = Aggregation.unwind("barcodes");
ProjectionOperation projectStage = Aggregation.project()
.and("_id").as("productId")
.and("title").as("productTitle")
.and("variation").as("productVariation")
.and("barcodes.title").as("barcodeTitle")
.and("barcodes.value").as("barcodeValue")
.and("barcodes.type").as("barcodeType")
.and("barcodes.codeStandard").as("codeStandard")
.and("barcodes.quantity").as("quantity")
.and("barcodes.status").as("status");
SortOperation sortOperation = Aggregation.sort(Sort.by(Sort.Direction.DESC, "productTitle"));
Aggregation agg = Aggregation.newAggregation(unwindOperation, projectStage, sortOperation);
AggregationResults<BarcodeAggregateList> results = mongoTemplate.aggregate(agg, "product", BarcodeAggregateList.class);

Lucene Index on Document is not working by ClassBridge hook

Problem : When I am uploading a word document, I am able to search on title(Entered while uploading the document) and summary, but when I search using the some text in document I am getting the result.
I am using "hibernate-search-engine : 4.3.0.Final, lucene-core : 3.6.2"
POM.XML
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-search-orm</artifactId>
<version>${hibernate.search.version}</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-search-engine</artifactId>
<version>${hibernate.search.version}</version>
</dependency>
<dependency>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-core</artifactId>
<version>3.6.2</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-queries</artifactId>
<version>3.6.2</version>
<scope>runtime</scope>
</dependency>
Classes
#Entity
#SequenceGenerator(name = "sitepagecontent_seq", sequenceName = "SITEPAGECONTENT_SEQ")
#Indexed(index = "SitePageContent")
#FullTextFilterDef(name = "condition1", impl = StatusFilterFactory.class) //Filter factory with parameters
#Analyzer (impl = StandardAnalyzer.class)
#ClassBridge(name = "splitcontentfileupload",
index = Index.YES,
store = Store.YES,
impl = WordDocHandlerBridge.class,
params = #org.hibernate.search.annotations.Parameter(name = "padding", value = " ")
)
#Table(name = "SITE_PAGE_CONTENT")
public class SitePageContent extends BaseObject implements Comparable<SitePageContent> {
// Fields
private static final long serialVersionUID = -7424477214552600300L;
private Long id;
#IndexedEmbedded
private Content content;
#IndexedEmbedded
private SitePage sitePage;
private Long sequence;
Content.java
#Entity
#SequenceGenerator(name = "content_seq", sequenceName = "CONTENT_SEQ")
#Table(name = "CONTENT")
#VersionSupportModel
public class Content extends BaseObject implements Comparable<Content> {
// ------------------------------ FIELDS ------------------------------
// Fields
private static final long serialVersionUID = 1441591301055742001L;
private Long id;
#IndexedEmbedded
private UploadedFile uploadedFile;
#IndexedEmbedded
private ContentType contentType;
#Field(index = Index.YES, store = Store.YES, analyzer = #Analyzer(impl = StandardAnalyzer.class))
private String title;
private String prevTitle;
#Field(index = Index.YES, store = Store.YES, analyzer = #Analyzer(impl = StandardAnalyzer.class))
private String teaser;
private String prevTeaser;
private String linkedContentType;
private String linkedUrl;
private Boolean linkedContentPopup;
#Field(index = Index.YES, store = Store.YES)
private String status;
private EcommUser createdBy;
private EcommUser modifiedBy;
#Temporal(TemporalType.DATE)
private Date createdDate;
#Temporal(TemporalType.DATE)
private Date modifiedDate;
private String shared;
private String statusTemp;
private Set<Request> requests = new HashSet<Request>(0);
#ContainedIn
private Set<SitePageContent> sitePageContents = new HashSet<SitePageContent>(0);
private Integer version;
private Integer articleId;
private String summary;
#Field(index = Index.YES, store = Store.YES, analyzer = #Analyzer(impl = StandardAnalyzer.class))
private String description;
#Field(index = Index.YES, store = Store.YES, analyzer = #Analyzer(impl = StandardAnalyzer.class))
private String contactName;
#Field(index = Index.YES, store = Store.YES, analyzer = #Analyzer(impl = StandardAnalyzer.class))
private String contactPhone;
#Field(index = Index.YES, store = Store.YES, analyzer = #Analyzer(impl = StandardAnalyzer.class))
private String contactEmail;
#Field(index = Index.YES, store = Store.YES, analyzer = #Analyzer(impl = StandardAnalyzer.class))
private String contactPostalAddress;
WordDocHandlerBridge.java
public class WordDocHandlerBridge implements FieldBridge, ParameterizedBridge {
protected final Log log = LogFactory.getLog(getClass());
public static String paddingProperty = "padding";
private String padding = "";
public void setParameterValues(Map arg0) {
Object padding = arg0.get( paddingProperty );
if (padding != null) {
this.padding = (String) padding;
}
}
public void set(String name, Object value, Document document, LuceneOptions luceneOptions) {
String fieldValue = "";
SitePageContent sitCont = (SitePageContent) value;
Content cont = sitCont.getContent();
UploadedFile upF = cont.getUploadedFile();
if (upF != null) {
String fieldValue1 = upF.getFileContentType();
if ( fieldValue1 == null ) {
fieldValue1 = "";
}
byte[] fieldValue2 = upF.getFileContent();
if ( fieldValue2 == null ) {
fieldValue2 = new byte[0];
}
fieldValue = convertFile2String(fieldValue1, fieldValue2);
} else {
fieldValue = "";
}
Field field = new Field( name, fieldValue, luceneOptions.getStore(), luceneOptions.getIndex(), luceneOptions.getTermVector() );
field.setBoost( luceneOptions.getBoost() );
document.add( field );
}
private String convertFile2String(String type, byte[] content) {
}
When I debugged "WordDocHandlerBridge.java", I am able to see my content is set in Field and added to document, but when I search I am not getting it.
Note : There is a standolne program which recreates the Index for me, If I recreated , I can see the result.
Can any one please help me resolve this.
I solved this, Method in WordDocHandlerBridge this class "convertFile2String", actually opens the file and reads the file and create a String to set the value in the Field, problem is Code is not closing the "File" and some how Luecene is not updating , but when I added close to the PDF and POI files it all started working.
Point here is it used to work with Luecene 2.4, this might be new feature in Lucene 3.6, which is good one.

GeoSpatial Radius Search Using Objectify

I am developing an application using GeoModel. I need to perform search in a particular radius based on the given latitude and longitude. I am able to generate the GeoCells in the datastore using Objectify, but not able to get back the results in a particular radius.
I am sharing my code below.
Entity Class
#Entity
public class NewsFeed implements Serializable {
private static final long serialVersionUID = 1L;
#Id
#Index
private Long feedID;
#Index
private String topic;
#Index
private String title;
private String description;
#Index
private Date createDate;
private String imageOrVideo;
private String imageUrl;
private String blobKey;
#Latitude
private Double latitude;
#Longitude
private Double longitude;
#Geocells
private List<String> cells;
// getter and setters ...
}
Custom GeocellQueryEngine Class From This Source
public class ObjectifyGeocellQueryEngine implements GeocellQueryEngine {
private String geocellsProperty;
private Objectify ofy;
public static final String DEFAULT_GEOCELLS_PROPERTY = "cells";
public ObjectifyGeocellQueryEngine(Objectify ofy) {
this(ofy, DEFAULT_GEOCELLS_PROPERTY);
}
public ObjectifyGeocellQueryEngine(Objectify ofy, String geocellsProperty) {
this.ofy = ofy;
this.geocellsProperty = geocellsProperty;
}
#Override
public <T> List<T> query(GeocellQuery baseQuery, List<String> geocells, Class<T> entityClass) {
StringTokenizer st;
int tokenNo = 0;
Query<T> query = ofy.query(entityClass);
if (baseQuery != null) {
st = new StringTokenizer(baseQuery.getBaseQuery(), ",");
while (st.hasMoreTokens()) {
query.filter(st.nextToken(), baseQuery.getParameters().get(tokenNo++));
}
}
return query.filter(geocellsProperty + " IN", geocells).list();
}
}
Fetching Data Here
Point p = new Point(24.8993714, 79.5839124);
// Generates the list of GeoCells
List<String> cells = GeocellManager.generateGeoCell(p);
List<Object> params = new ArrayList<Object>();
params.add("Movies");
GeocellQuery baseQuery = new GeocellQuery("topic == topic", "String topic",params);
ObjectifyGeocellQueryEngine objectifyGeocellQueryEngine = new ObjectifyGeocellQueryEngine(ofy(), "cells");
List<NewsFeed> list = objectifyGeocellQueryEngine.query(baseQuery, cells, NewsFeed.class);
List<NewsFeed> list2 = GeocellManager.proximitySearch(p, 10, 10000,NewsFeed.class, baseQuery, objectifyGeocellQueryEngine, GeocellManager.MAX_GEOCELL_RESOLUTION);
System.out.println(list+" : "+list2);
Now the problem is I am not getting any results out from here. Can you people please help me with this as I am not getting any exception, just getting the empty list.
I have done a workaround for this situation I have added a parallel JDO Class to store and retrieve the geospatial results.

Categories

Resources