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.
* If we asynchronously load all of our model's dependencies, they will not be
* available at the time we define our store. If they are not available, our
* model definition will not yet be instantiated and Ext.Loader will attempt (and fail)
* to load it dynamically.
*/
String storeName = namespace + ".store." + StringUtilities.pluralize(config.getSimpleModelName());
String output = ""
+ "Ext.syncRequire(['Ext.data.Model','Ext.data.Store','Ext.data.reader.Json','Ext.data.writer.Json'], function(){;\n"
+ "Ext.define(\"" + modelName + "\"," + StringUtilities.json(baseModelDefinition) + ");\n"
+ "Ext.define(\"" + storeName + "\"," + StringUtilities.json(storeDefinition) + ");\n"
+ "Ext.onReady(function() {Ext.create(\"" + storeName + "\", {storeId:\"" + storeName.split(".store.")[1] + "\"})})\n";
for (Association assoc : getAllAssociations(baseModelDefinition)) {
ModelDefinition associatedModel = assoc.getAssociatedModelDefinition();
if (associatedModel == null) {
continue;
}
output += "Ext.define(\"" + assoc.getModelName() + "\"," + StringUtilities.json(associatedModel) + ");\n";