public class DomainObject {
private Long id;
private Map<String, Object> details;
public Long getId() {
return id;
}
public Map<String, Object> getDetails {
return details;
}
public Object getDetail(String key) {
return details.get(key);
}
}
--
-- You received this message because you are subscribed to the "cqengine-discuss" group.
http://groups.google.com/group/cqengine-discuss
---
You received this message because you are subscribed to the Google Groups "cqengine-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cqengine-discu...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
public static void main(String[] args) {
IndexedCollection<WorkItem> workItems = CQEngine.newInstance();
workItems.add(new WorkItem(1L, "Timesheet for Joe"));
workItems.add(new WorkItem(2L, "Timesheet for Jane"));
IndexedCollection<WorkItemEntry> workItemEntries = CQEngine.newInstance();
workItemEntries.add(new WorkItemEntry(1L, 1L, "monday", 7.0));
workItemEntries.add(new WorkItemEntry(1L, 1L, "tuesday", 6.5));
workItemEntries.add(new WorkItemEntry(2L, 2L, "tuesday", 2.0)); // Jane also worked on tuesday, but for < 3 hrs
IndexedCollection<Address> addresses = CQEngine.newInstance();
addresses.add(new Address(1L, 1L, "Timesheet", "Create Timesheet"));
addresses.add(new Address(2L, 2L, "Timesheet", "Create Timesheet"));
ResultSet<WorkItem> results = workItems.retrieve(
and(
existsIn(workItemEntries,
WorkItem.WORK_ITEM_ID,
WorkItemEntry.WORK_ITEM_ID,
and(
equal(WorkItemEntry.DAY, "tuesday"),
greaterThan(WorkItemEntry.TIME, 3.0)
)
),
existsIn(addresses,
WorkItem.WORK_ITEM_ID,
Address.WORK_ITEM_ID,
equal(Address.STEP, "Create Timesheet")
)
)
);
System.out.println(results.uniqueResult().getDescription()); // "Timesheet for Joe"
}
@RequestMapping(value = "/", method = RequestMethod.GET) protected ModelAndView testGet( @RequestParam(required = false) String filter , @RequestParam(defaultValue = MODEL_ADDRESS) String type) { // Set defaults if (filter == null) if (MODEL_PROCESS.equals(type)) filter = "equal(" + MODEL_PROCESS + "[state],\"active\")"; else if (MODEL_WORKITEM.equals(type)) filter = "equal(" + MODEL_WORKITEM + "[queueType],\"next\")"; else filter = "hasPermission(" + MODEL_ADDRESS + "[threadIdentity],CLAIM)";
// Create an input stream from the query text... ANTLRInputStream input = new ANTLRInputStream(filter); // The lexer is injected. lexer.setInputStream(input); CommonTokenStream tokens = new CommonTokenStream(lexer); tokens.fill();
// The visitor is injected. NativeQueryVisitorImpl visitor = (NativeQueryVisitorImpl) parseTreeVisitor;
/* Create 'context' providers. The key is the name of the context in the query. For example, in the following query we have 'Workitem' and 'Address' contexts. The providers return both Attributes and IndexedCollections to the visitor to enable it to create it's queries.
and( equal( Workitem[queueType] , "next" ) , existsIn( Address , Workitem[id] , Address[id]
, not( has( Address[lockedBy] ) ) )) */ Map<String, Provider> providers = new HashMap<String, Provider>(); providers.put(MODEL_PROCESS, new ProviderImpl( processAttributes , processCollection )); providers.put(MODEL_WORKITEM, new ProviderImpl( workitemAttributes , workitemCollection )); providers.put(MODEL_ADDRESS, new ProviderImpl( addressAttributes , addressCollection ));
visitor.setProviders(providers);
// Give the parser the tokens created by the lexer... parser.setTokenStream(tokens); // Create a parse tree. ParserRuleContext tree = ((NativeQueryParser) parser).startRule(); // Visit the nodes in the parse tree creating the query Query query = (Query) parseTreeVisitor.visit(tree);
// Use it... ResultSet<Model> resultSet = providers.get(type).getCollection().retrieve(query);
Map<String, Object> model = new HashMap<String, Object>(); model.put("filter", filter); model.put("type", type); model.put("items", resultSet.iterator()); return new ModelAndView(type.toLowerCase() + "List", model); }
You received this message because you are subscribed to a topic in the Google Groups "cqengine-discuss" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/cqengine-discuss/I6p39HeYr0I/unsubscribe.
To unsubscribe from this group and all its topics, send an email to cqengine-discu...@googlegroups.com.
<CQEngineGenericListController.java>