private Notification.PathTokens getPathTokens(List<ServiceParameter> parameters){ Notification.PathTokens pathTokens = new Notification.PathTokens(); pathTokens.setApplicationRef((SimpleEntityRef)em.getApplicationRef()); // first parameter is always collection name, start parsing after that for (int i = 0; i < parameters.size() - 1; i += 2 ) { String collection = pluralize(parameters.get(i).getName()); Identifier identifier = null; String ql = null; ServiceParameter sp = parameters.get(i + 1); // if the next param is a query, add a token with the query if(sp.isQuery()){ ql = sp.getQuery().getQl().get(); pathTokens.getPathTokens().add(new Notification.PathToken( collection, ql)); }else{ // if the next param is "notifications", it's the end let identifier be null if(sp.isName() && !sp.getName().equalsIgnoreCase("notifications") || sp.isId()){ identifier = sp.getIdentifier(); } pathTokens.getPathTokens().add(new Notification.PathToken( collection, identifier)); } } return pathTokens; }
final PathQuery<Device> pathQuery = notification.getPathQuery().buildPathQuery(); //devices query final AtomicInteger deviceCount = new AtomicInteger(); //count devices so you can make a judgement on batching final ConcurrentLinkedQueue<String> errorMessages = new ConcurrentLinkedQueue<>(); //build up list of issues
@JsonIgnore public PathQuery<Device> buildPathQuery() { PathQuery pathQuery = null; List<PathToken> pathTokens = getPathTokens(); for (PathToken pathToken : pathTokens) { String collection = pathToken.getCollection(); pathQuery = new PathQuery(getApplicationRef(), query);
public Notification() { pathQuery = new PathTokens(); }