/*
* Create the store
*/
AdaptrexSession session = new AdaptrexSession(persistence);
Store store = new Store(session, config);
/*
* Set the model name
*/
String modelName = namespace + ".model." + (name != null ? name : className);
config.setNamespace(namespace);
config.setModelName(modelName);
/*
* If our store doesn't have a class drop out
*/
if (clazz == null) {
write("<!-- Error creating store: Could not find entity for " + className + " -->\n");
return;
}
/*
* Various store options
*/
if (pageSize != null) {
config.setPageSize(Integer.valueOf(pageSize));
}
if (include != null) {
config.include(include);
}
if (exclude != null) {
config.exclude(exclude);
}
if (clearOnPageLoad != null && clearOnPageLoad.equals("true")) {
config.setClearOnPageLoad(true);
}
if (clearRemovedOnLoad != null && clearRemovedOnLoad.equals("true")) {
config.setClearRemovedOnLoad(true);
}
if (autoSync != null && autoSync.equals("true")) {
config.setAutoSync(true);
}
if (autoLoad != null && autoLoad.equals("true")) {
config.setAutoLoad(true);
}
if (remoteGroup != null && remoteGroup.equals("true")) {
config.setRemoteGroup(true);
}
if (remoteSort != null && remoteSort.equals("true")) {
config.setRemoteSort(true);
}
if (remoteFilter != null && remoteFilter.equals("true")) {
config.setRemoteFilter(true);
}
if (sortOnFilter != null && sortOnFilter.equals("true")) {
config.setSortOnFilter(true);
}
/*
* Filtering
*/
if (filter != null) {
for (String filterItem : filter.split(",")) {
String[] parts = filterItem.split("=");
String property = parts[0];
String value = parts.length > 1 ? parts[1] : null;
config.filter(property, value);
}
}
/*
* Grouping
*/
if (group != null) {
for (String groupItem : group.split(",")) {
String[] parts = groupItem.split(":");
String property = parts[0];
String direction = parts.length > 1 ? parts[1] : null;
String root = parts.length > 2 ? parts[2] : null;
config.group(property, direction, root);
}
}
/*
* Sorting
*/
if (sort != null) {
for (String sortItem : sort.split(",")) {
String[] parts = sortItem.split(":");
String property = parts[0];
String direction = parts.length > 1 ? parts[1] : "ASC";
String root = parts.length > 2 ? parts[2] : null;
config.sort(property, direction, root);
}
}
/*
* Buffering
*/
if (buffered != null && buffered.contains("false")) {
config.setBuffered(true);
if (!buffered.equals("true")) {
String[] parts = buffered.split(":");
config.setTrailingBufferZone(Integer.valueOf(parts[0]));
if (parts.length > 1) {
config.setLeadingBufferZone(Integer.valueOf(parts[1]));
}
if (parts.length > 1) {
config.setPurgePageCount(Integer.valueOf(parts[2]));
}
}
}
/*
* Add associations
*/
if (associations != null) {
config.associations(associations);
}
/*
* Load inline data?
*/
if (inline != null && inline.equals("true")) {
config.setInline(true);
}
if (where != null) {
config.setWhere(where);
}
if (param != null) {
for (String p : param.split(",")) {
String[] parts = p.split(":");
config.param(parts[0], parts[1]);
}
}
if (start != null) {
config.setStart(Integer.valueOf(start));
}
/*
* The proxy needs additinoal information from the store. We shouldn't create
* the proxy until the store has been fully configured
*/
if (rest != null) {
String restPath = getRequest().getContextPath() + "/rest/"
+ (rest.equals("true") ? clazz.getSimpleName().toLowerCase() : rest);
config.setProxy(new RestProxy(restPath, config));
}
StoreDefinition storeDefinition = store.getStoreDefinition();
ModelDefinition baseModelDefinition = store.getModelDefinition();
/*
* Write the javascript for this store/model.
*
* During development using Ext.Loader, we need to syncRequire Ext.data.Model.