Package com.webobjects.eoaccess

Examples of com.webobjects.eoaccess.EOEntity.model()


    public static NSArray sharedObjectsForEntityNamed(String entityName) {
        EOSharedEditingContext sharedEC = EOSharedEditingContext.defaultSharedEditingContext();
        NSArray sharedEos = (NSArray)sharedEC.objectsByEntityName().objectForKey(entityName);
        if (sharedEos == null) { //call registeredDatabaseContextForModel() to trigger loading the model's shared EOs (if set to happen automatically), then try again
            EOEntity entity = ERXEOAccessUtilities.entityNamed(sharedEC, entityName);
            EODatabaseContext.registeredDatabaseContextForModel(entity.model(), sharedEC);
            sharedEos = (NSArray)sharedEC.objectsByEntityName().objectForKey(entityName);
        }

        if (sharedEos == null) {
            log.warn("Unable to find any shared objects for the entity named: " + entityName);
View Full Code Here


     *    entity.
     */
    @SuppressWarnings("unchecked")
    public static NSDictionary<String, Object> newPrimaryKeyDictionaryForEntityNamed(EOEditingContext ec, String entityName) {
        EOEntity entity = ERXEOAccessUtilities.entityNamed(ec, entityName);
        EODatabaseContext dbContext = EODatabaseContext.registeredDatabaseContextForModel(entity.model(), ec);
        NSDictionary<String, Object> primaryKey = null;
        try {
            dbContext.lock();
           
            boolean willRetryAfterHandlingDroppedConnection = true;
View Full Code Here

     *
     * @author David Avendasora
     */
    public static <T extends ERXCopyable<T>> T modelCopy(NSMutableDictionary<EOGlobalID, ERXCopyable<?>> copiedObjects, T source) {
      EOEntity entity = Utility.entity(source);
      EOModel model = entity.model();
      NSDictionary<String, Object> entityUserInfo = entity.userInfo();
      String entityName = entity.name();
      String modelName = model.name();

      if (!entityUserInfo.containsKey(ERXCopyable.ERXCOPYABLE_KEY)) {
View Full Code Here

      NSArray<String> copyTypes = (NSArray<String>) CopyType.copyTypesFor(property).valueForKey("type");
      String validCopyTypes = copyTypes.componentsJoinedByString(", ");
      String propertyName = property.name();
      EOEntity entity = property.entity();
      String entityName = entity.name();
      EOModel model = entity.model();
      String modelName = model.name();
      String exceptionMessage = "ERXCopyable's modelCopy requires the \"" + ERXCopyable.COPY_TYPE_KEY + "\" key must be set in the UserInfo dictionary of \"" + entityName + "." + propertyName + "\" " + propertyType + " in " + modelName + " AND it must be set to one of these values: {" + validCopyTypes + "}. \"" + copyType + "\" is not a valid value.";
      throw new IllegalStateException(exceptionMessage);
    }
View Full Code Here

    // quotes the identifier in the array
   
    String sourceKeyList = quoteArrayContents(sourceColumns).componentsJoinedByString(", ");
    String destinationKeyList = quoteArrayContents(destinationColumns).componentsJoinedByString(", ");
   
    EOModel sourceModel = entity.model();
    EOModel destModel = relationship.destinationEntity().model();
    if (sourceModel != destModel && !sourceModel.connectionDictionary().equals(destModel.connectionDictionary())) {
      throw new IllegalArgumentException(new StringBuilder().append("prepareConstraintStatementForRelationship unable to create a constraint for ").append(relationship.name()).append(" because the source and destination entities reside in different databases").toString());
    }
    setStatement(new StringBuilder()
View Full Code Here

     * @return the EOSQLExpression which the EOFetchSpecification would use
     */
    public static EOSQLExpression sqlExpressionForFetchSpecification(EOEditingContext ec, EOFetchSpecification spec, long start, long end) {
      EOSQLExpression expression = null;
        EOEntity entity = ERXEOAccessUtilities.entityNamed(ec, spec.entityName());
        EOModel model = entity.model();
        EODatabaseContext dbc = EODatabaseContext.registeredDatabaseContextForModel(model, ec);
        dbc.lock();
        try {
          ERXSQLHelper sqlHelper = ERXSQLHelper.newSQLHelper(ec, model.name());
          expression = sqlHelper.sqlExpressionForFetchSpecification(ec, spec, start, end);
View Full Code Here

    public static int rowCountForFetchSpecification(EOEditingContext ec, EOFetchSpecification spec) {
      EOEntity entity = ERXEOAccessUtilities.entityNamed(ec, spec.entityName());
        if (entity == null)
            throw new java.lang.IllegalStateException("entity could not be found for name \""+spec.entityName()+"\". Checked EOModelGroup for loaded models.");

      EOModel model = entity.model();

      EODatabaseContext dbc = EODatabaseContext.registeredDatabaseContextForModel(model, ec);
      int results = 0;

      dbc.lock();
View Full Code Here

        // MS: This "t0." is totally wrong, but it is required. It should be dynamically
        // generated, but this function doesn't have an EOSQLExpression to operate on
        if (entityTableAlias == null) {
          entityTableAlias = "t0";
        }
        aggregate.setReadFormat(ERXSQLHelper.newSQLHelper(entity.model()).readFormatForAggregateFunction(function, entityTableAlias + "." + attribute.columnName(), aggregateName, usesDistinct));
        return aggregate;
    }

    /**
     * Oracle 9 has a maximum length of 30 characters for table names, column names and constraint names.
View Full Code Here

     * @deprecated
     */
    @Deprecated
    public static String createIndexSQLForEntities(NSArray entities, NSArray externalTypesToIgnore) {
        EOEntity ent = (EOEntity)entities.objectAtIndex(0);
        String modelName = ent.model().name();
        return ERXSQLHelper.newSQLHelper(ERXEC.newEditingContext(), modelName).createIndexSQLForEntities(entities, externalTypesToIgnore);
    }

    public static boolean entityUsesSeparateTable(EOEntity entity) {
        if (entity.parentEntity() == null) return true;
View Full Code Here

        EOEditingContext ec = eo.editingContext();
        EOEntity entity = ERXEOAccessUtilities.entityNamed(ec, entityName);
        EORelationship relationship = entity.relationshipNamed(relKey);
        if(relationship.sourceAttributes().count() == 1) {
          EOAttribute attribute = relationship.sourceAttributes().lastObject();
          EODatabaseContext context = EOUtilities.databaseContextForModelNamed(ec, entity.model().name());
          String name = attribute.name();
          for (Enumeration e = eos.objectEnumerator(); e.hasMoreElements();) {
            EOEnterpriseObject target = (EOEnterpriseObject) e.nextElement();
            Object value = (context.snapshotForGlobalID(ec.globalIDForObject(target))).valueForKey(name);
            result.addObject(value);
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.