Package com.webobjects.eoaccess

Examples of com.webobjects.eoaccess.EOEntity


         *   that needs the class description.
         */
        public void classDescriptionNeededForEntityName(NSNotification n) {
            log.debug("classDescriptionNeededForEntityName: " + (String)n.object());
            String name = (String)n.object();
            EOEntity e = ERXEOAccessUtilities.entityNamed(null,name);
            if(e == null) log.error("Entity " + name + " not found in the default model group!");
            if (e != null) {
              registerDescriptionForEntity(e);
            }
        }
View Full Code Here


         * @param model that contains all of the entities to be registerd
         */
        protected void registerDescriptionForEntitiesInModel(EOModel model) {
            if (!_registeredModelNames.containsObject(model.name())) {
                for (Enumeration e = model.entities().objectEnumerator(); e.hasMoreElements();) {
                    EOEntity eoentity = (EOEntity)e.nextElement();
                    String className = eoentity.className();

                    prepareEntityForRegistration(eoentity);

                    NSMutableArray array = (NSMutableArray)_entitiesForClass.objectForKey(className);
                    if(array == null) {
                        array = new NSMutableArray();
                    }
                    if (log.isDebugEnabled())
                        log.debug("Adding entity " +eoentity.name()+ " with class " + eoentity.className());
                    array.addObject(eoentity);
                    _entitiesForClass.setObjectForKey(array, eoentity.className());

                    //HACK ALERT: (ak) We work around classDescriptionForNewInstances() of EOEntity being broken here...
                    registerDescriptionForEntity(eoentity);
                }
                _registeredModelNames.addObject(model.name());
View Full Code Here

    public EOEntity entityWithEntityAndKeyPath(EOEntity entity, String keyPath) {
        NSArray keys = NSArray.componentsSeparatedByString(keyPath, ".");
        Enumeration keysEnumerator = keys.objectEnumerator();
        String key = null;
        EOEntity result = entity;

        while (keysEnumerator.hasMoreElements()) {
            key = (String) keysEnumerator.nextElement();
            result = result.relationshipNamed(key).destinationEntity();
        }

        return result;
    }
View Full Code Here

            NSArray entities = (NSArray)_entitiesForClass.objectForKey(class1.getName());
            if (entities != null) {
                if (log.isDebugEnabled())
                    log.debug("Registering descriptions for class: " + class1.getName() + " found entities: " + entities.valueForKey("name"));
                for (Enumeration e = entities.objectEnumerator(); e.hasMoreElements();) {
                    EOEntity entity = (EOEntity)e.nextElement();
                    ERXEntityClassDescription cd = newClassDescriptionForEntity(entity);
                    EOClassDescription.registerClassDescription(cd, class1);
                    _setClassDescriptionOnEntity(entity, cd);
                }
            } else {
View Full Code Here

            setDataSource((EODatabaseDataSource) _WOJExtensionsUtil.valueForBindingOrNull("dataSource", this));

            if (dataSource() == null) {
                String anEntityName = _localSourceEntityName();
                EOModelGroup aModelGroup = EOModelGroup.defaultGroup();
                EOEntity anEntity = aModelGroup.entityNamed(anEntityName);

                if (anEntity == null) {
                    throw new IllegalStateException("<" + getClass().getName() + " could not find entity named " + anEntityName + ">");
                }
               
                EOEntity destinationEntity = entityWithEntityAndKeyPath(anEntity, _localRelationshipKey());
                Object _source = _localSourceObject();
                EOEditingContext anEditingContext = null;

                if (_source instanceof EOEnterpriseObject) {
                    anEditingContext = ((EOEnterpriseObject) _source).editingContext();
                }

                if (anEditingContext == null) {
                    anEditingContext = session().defaultEditingContext();
                }

                EODatabaseDataSource aDatabaseDataSource = new EODatabaseDataSource(anEditingContext, destinationEntity.name());
                setDataSource(aDatabaseDataSource);
            }

        }
View Full Code Here

    }

    protected WOComponent pageWithContextTaskEntity(D2WContext d2wcontext, String s, String s1, WOContext wocontext) {
        myCheckRules();
        d2wcontext.setTask(s);
        EOEntity eoentity = s1 != null ? EOModelGroup.defaultGroup().entityNamed(s1) : null;
        if (eoentity == null && s1 != null && !s1.equals("") && !s1.equals("*all*")) { throw new IllegalArgumentException(
                "Could not find entity named " + s1); }
        d2wcontext.setEntity(eoentity);
        WOComponent wocomponent = WOApplication.application().pageWithName(d2wcontext.pageName(), wocontext);
        if (wocomponent instanceof D2WComponent) {
View Full Code Here

                    break;
                }
            }
            // In the case we have a self join relationship we have to be more clever
            if(_destinationRelationship==null){
                EOEntity originEntity = EOModelGroup.defaultGroup().entityNamed(originEntityName);
                EORelationship originRelationship = originEntity.relationshipNamed(relationshipKey());
                EORelationship inverseOriginRelationship = originRelationship.inverseRelationship();
                for (Enumeration e=joinRelationships.objectEnumerator(); e.hasMoreElements();) {
                    EORelationship r=(EORelationship)e.nextElement();
                    if (r!=inverseOriginRelationship) {
                        _destinationRelationship=r;
View Full Code Here

    public EOFetchSpecification fetchSpecificationFromRequest(String entityName) {
      EOFetchSpecification fs = null;
      if(context().request().formValueKeys().containsObject(fetchSpecificationKey)) {
        String fsName = context().request().stringFormValueForKey(fetchSpecificationKey);
        if(ERXStringUtilities.stringIsNullOrEmpty(fsName)) {
          EOEntity rootEntity = ERXEOAccessUtilities.entityNamed(session().defaultEditingContext(), entityName);
         
          NSMutableArray qualifiers = new NSMutableArray();
          for(Enumeration e = context().request().formValueKeys().objectEnumerator(); e.hasMoreElements(); ) {
            String key = (String)e.nextElement();
            EOEntity entity = rootEntity;
            EOAttribute attribute = null;
            String attributeName = key;
            if(key.indexOf(".") > 0) {
              String path = ERXStringUtilities.keyPathWithoutLastProperty(key);
              attributeName = ERXStringUtilities.lastPropertyKeyInKeyPath(key);
              entity = ERXEOAccessUtilities.destinationEntityForKeyPath(rootEntity, path);
            }
            if(entity != null) {
              attribute = entity.attributeNamed(attributeName);
              if(attribute != null) {
                String stringValue = context().request().stringFormValueForKey(key);
                if(stringValue != null) {
                  Object value = null;
                  NSSelector selector = EOKeyValueQualifier.QualifierOperatorEqual;
View Full Code Here

        EOEditingContext ec = session().defaultEditingContext();
        //ak: this check could be better...but anyway, as we edit, we should get a peer context
        if(lpi instanceof ERD2WEditableListPage) {
            ec = ERXEC.newEditingContext(session().defaultEditingContext().parentObjectStore());
        }
        EOEntity entity = ERXEOAccessUtilities.entityNamed(ec, entityName);
        EODataSource ds = relationshipArrayFromRequest(ec, entity.classDescriptionForInstances());
        if(ds == null) {
            ds = new EODatabaseDataSource(ec, entityName);
            EOFetchSpecification fs = fetchSpecificationFromRequest(entityName);
            if(fs == null) {
                fs = new EOFetchSpecification(entityName, null, null);
View Full Code Here

            context = ((D2WPage)newPage).d2wContext();
        } else {
            context = ERD2WContext.newContext(session());
            context.setDynamicPage(anActionName);
        }
        EOEntity entity = context.entity();

        if(entity != null) {
            String entityName = entity.name();
            String taskName = context.task();

            if(newPage instanceof EditPageInterface && taskName.equals("edit")) {
                prepareEditPage(context, (EditPageInterface)newPage, entityName);
            } else if(newPage instanceof InspectPageInterface) {
View Full Code Here

TOP

Related Classes of com.webobjects.eoaccess.EOEntity

Copyright © 2018 www.massapicom. 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.