Examples of AdaptrexPersistenceManager


Examples of com.adaptrex.core.persistence.api.AdaptrexPersistenceManager

 
  public ModelDefinition(ExtConfig extConfig) throws Exception {
    boolean isRoot = extConfig.getParentConfig() == null;
    this.modelName = extConfig.getModelName();

    AdaptrexPersistenceManager orm = extConfig.getORMPersistenceManager();
   
    /*
     * Add the ID field for this model
     */
    this.fields.add(new FieldDefinition(AdaptrexEntityType.ENTITY_ID_NAME, ExtTypeFormatter.AUTO));
   
    includes = extConfig.getIncludes();
    excludes = extConfig.getExcludes();
   
    entityClassIncludes = PersistenceTools.getIncludes(extConfig, extConfig.getModelName());
    entityClassExcludes = PersistenceTools.getExcludes(extConfig, extConfig.getModelName());
   
    AdaptrexEntityType adaptrexEntity = orm.getAdaptrexEntity(extConfig.getEntityClass().getSimpleName());
    Map<String,AdaptrexFieldType> adaptrexFields = adaptrexEntity.getFields();
    Map<String,AdaptrexCollectionType> adaptrexCollections = adaptrexEntity.getCollections();
    Map<String,AdaptrexAssociationType> adaptrexAssociations = adaptrexEntity.getAssociations();

    for (String key : adaptrexFields.keySet()) {
View Full Code Here

Examples of com.adaptrex.core.persistence.api.AdaptrexPersistenceManager

  };
 
 
  public String getJavaScript() throws Exception {
    ExtConfig config = this.extConfig;
    AdaptrexPersistenceManager apm = config.getORMPersistenceManager();
   
    if (config.getEntityClass() == null) {
      String str = "Adaptrex Model Error: Persistent Class Not Found (" + this.extConfig.getClassName() + ")";
      log.warn(str);
      return StringUtilities.getErrorJavaScript(str);
    }
   
    if (this.namespace == null) {
      this.namespace = configComponent.getNamespace();
    }
    String modelName = config.getModelName();
   
    List<String> modelDefinitionStrings = new ArrayList<String>();
    String fullModelName = namespace +  ".model." + modelName;
    boolean isTouch = this.configComponent.isTouch();
   
    /*
     * Get the model definition
     */
    log.debug("Creating model definition for " + fullModelName);
    ModelDefinition modelDefinition = new ModelDefinition(this.extConfig);
   
    /*
     * Add the rest API to the model
     */
    modelDefinition.setProxy(this.restProxy);
    modelDefinitionStrings.add("Ext.define('" + fullModelName + "', " +
        (isTouch ? "{extend:'Ext.data.Model', config:" : "") +
        StringUtilities.json(modelDefinition, this.request.getServletContext()) + (isTouch ? "}" : "") + ");\n");
   
   
    /*
     * Get the model's association definitions
     */
    getAllAssociations(modelDefinition);
    for (Association association : associations) {
      ModelDefinition assocModelDef = association.getModelDefinition();
      if (assocModelDef != null) {
        /*
         * If we have a rest proxy for the parent model, add one for associated models
         */
        if (this.restProxy != null) {
          String restPath = getRestPath(association.getEntityClassName().toLowerCase());
          if (!restPath.equals("false")) {
            RestProxy associatedProxy = new RestProxy(restPath, extConfig, this.configComponent.isTouch());
            assocModelDef.setProxy(associatedProxy);
          }
         
        }

        modelDefinitionStrings.add("Ext.define('" + assocModelDef.getModelName() + "', " +
            (isTouch ? "{extend:'Ext.data.Model', config:" : "") +
            StringUtilities.json(assocModelDef, this.request.getServletContext()) + (isTouch ? "}" : "") + ");\n");
      }
    }
   
   
    /*
     * If we have an entity ID or a key/value configuration on our component,
     * we also return an online instance
     * TODO: We should add the ability to load this via rest to enable associations
     */
    String modelInstanceString = "";
    if (this.entityId != null || entityKey != null) {
      ModelInstance modelInstance = this.entityId != null
          ? apm.getModelInstance(this.extConfig, this.entityId)
          : apm.getModelInstance(this.extConfig, this.entityKey, this.entityValue);
         
//      ModelInstance modelInstance = this.entityId != null
//          ? new ModelInstance(extConfig, this.entityId)
//          : new ModelInstance(extConfig, this.entityKey, this.entityValue);
         
View Full Code Here

Examples of com.adaptrex.core.persistence.api.AdaptrexPersistenceManager

      }
    } else {
     
      String defaultOPMName = this.properties.get(AdaptrexProperties.PERSISTENCE_DEFAULTFACTORY);
      try {
        AdaptrexPersistenceManager opm = getOPMConstructor().newInstance(defaultOPMName);
        this.defaultPersistenceManager = opm;
       
        String defaultKey = defaultOPMName != null
            ? defaultOPMName : AdaptrexPersistenceManager.DEFAULT_NAME;
        persistenceManagers.put(defaultKey, opm);
View Full Code Here

Examples of com.adaptrex.core.persistence.api.AdaptrexPersistenceManager

  public AdaptrexPersistenceManager getPersistenceManager(String factoryName) {
    if (factoryName == null) {
      return this.defaultPersistenceManager;
    }
   
    AdaptrexPersistenceManager opm = this.persistenceManagers.get(factoryName);
    if (opm != null) return opm;

    synchronized(Adaptrex.class) {
      opm = this.persistenceManagers.get(factoryName);
      if (opm != null) return opm;
View Full Code Here

Examples of com.adaptrex.core.persistence.api.AdaptrexPersistenceManager

    log.debug("Creating association for " + parentConfig.getModelName() + " to " + associationName);
    String associationSimpleName = StringUtilities.capitalize(associationName);
   
    Class<?> parentClass = parentConfig.getEntityClass();
   
    AdaptrexPersistenceManager orm = parentConfig.getORMPersistenceManager();
    AdaptrexEntityType adaptrexEntity = orm.getAdaptrexEntity(parentClass.getSimpleName());
   
    AdaptrexAssociationType adaptrexAssociation = adaptrexEntity.getAssociation(associationName);
    if (adaptrexAssociation != null) {
      this.type = BELONGS_TO;
      this.modelName = parentConfig.getModelName() + associationSimpleName;
View Full Code Here

Examples of com.adaptrex.core.persistence.api.AdaptrexPersistenceManager

  };
 
 
  public String getJavaScript() throws Exception {
    ExtConfig config = this.extConfig;
    AdaptrexPersistenceManager apm = config.getORMPersistenceManager();
   
    if (config.getEntityClass() == null) {
      String str = "Adaptrex Model Error: Persistent Class Not Found (" + this.extConfig.getClassName() + ")";
      log.warn(str);
      return StringUtilities.getErrorJavaScript(str);
    }
   
    String namespace = this.configComponent.getNamespace();
    String modelName = config.getModelName();
   
    List<String> modelDefinitionStrings = new ArrayList<String>();
    String fullModelName = namespace +  ".model." + modelName;
    boolean isTouch = this.configComponent.isTouch();
   
    /*
     * Get the model definition
     */
    log.debug("Creating model definition for " + fullModelName);
    ModelDefinition modelDefinition = new ModelDefinition(this.extConfig);
   
    /*
     * Add the rest API to the model
     */
    modelDefinition.setProxy(this.restProxy);
    modelDefinitionStrings.add("Ext.define('" + fullModelName + "', " +
        (isTouch ? "{extend:'Ext.data.Model', config:" : "") +
        StringUtilities.json(modelDefinition, this.request.getServletContext()) + (isTouch ? "}" : "") + ");\n");
   
   
    /*
     * Get the model's association definitions
     */
    getAllAssociations(modelDefinition);
    for (Association association : associations) {
      ModelDefinition assocModelDef = association.getModelDefinition();
      if (assocModelDef != null) {
        /*
         * If we have a rest proxy for the parent model, add one for associated models
         */
        if (this.restProxy != null) {
          String restPath = getRestPath(association.getEntityClassName().toLowerCase());
          if (!restPath.equals("false")) {
            RestProxy associatedProxy = new RestProxy(restPath, extConfig, this.configComponent.isTouch());
            assocModelDef.setProxy(associatedProxy);
          }
         
        }

        modelDefinitionStrings.add("Ext.define('" + assocModelDef.getModelName() + "', " +
            (isTouch ? "{extend:'Ext.data.Model', config:" : "") +
            StringUtilities.json(assocModelDef, this.request.getServletContext()) + (isTouch ? "}" : "") + ");\n");
      }
    }
   
   
    /*
     * If we have an entity ID or a key/value configuration on our component,
     * we also return an online instance
     * TODO: We should add the ability to load this via rest to enable associations
     */
    String modelInstanceString = "";
    if (this.entityId != null || entityKey != null) {
      ModelInstance modelInstance = this.entityId != null
          ? apm.getModelInstance(this.extConfig, this.entityId)
          : apm.getModelInstance(this.extConfig, this.entityKey, this.entityValue);
         
//      ModelInstance modelInstance = this.entityId != null
//          ? new ModelInstance(extConfig, this.entityId)
//          : new ModelInstance(extConfig, this.entityKey, this.entityValue);
         
View Full Code Here

Examples of com.adaptrex.core.persistence.api.AdaptrexPersistenceManager

      }
    } else {
     
      String defaultOPMName = this.properties.get(AdaptrexProperties.PERSISTENCE_DEFAULTFACTORY);
      try {
        AdaptrexPersistenceManager opm = getOPMConstructor().newInstance(defaultOPMName);
        this.defaultPersistenceManager = opm;
       
        String defaultKey = defaultOPMName != null
            ? defaultOPMName : AdaptrexPersistenceManager.DEFAULT_NAME;
        persistenceManagers.put(defaultKey, opm);
View Full Code Here

Examples of com.adaptrex.core.persistence.api.AdaptrexPersistenceManager

  public AdaptrexPersistenceManager getPersistenceManager(String factoryName) {
    if (factoryName == null) {
      return this.defaultPersistenceManager;
    }
   
    AdaptrexPersistenceManager opm = this.persistenceManagers.get(factoryName);
    if (opm != null) return opm;

    synchronized(Adaptrex.class) {
      opm = this.persistenceManagers.get(factoryName);
      if (opm != null) return opm;
View Full Code Here

Examples of com.adaptrex.core.persistence.api.AdaptrexPersistenceManager

    log.debug("Creating association for " + parentConfig.getModelName() + " to " + associationName);
    String associationSimpleName = StringUtilities.capitalize(associationName);
   
    Class<?> parentClass = parentConfig.getEntityClass();
   
    AdaptrexPersistenceManager orm = parentConfig.getORMPersistenceManager();
    AdaptrexEntityType adaptrexEntity = orm.getAdaptrexEntity(parentClass.getSimpleName());
   
    AdaptrexAssociationType adaptrexAssociation = adaptrexEntity.getAssociation(associationName);
    if (adaptrexAssociation != null) {
      this.type = BELONGS_TO;
      this.modelName = parentConfig.getModelName() + associationSimpleName;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.