Package com.webobjects.eocontrol

Examples of com.webobjects.eocontrol.EOEnterpriseObject


   
    @Override
    public void setMasterObjectAndRelationshipKey(EOEnterpriseObject eo, String relationshipKey) {
        EOEditingContext ec = ERXEC.newEditingContext(eo.editingContext(), false); // no validation;
        setEditingContext(ec);
        EOEnterpriseObject localEO = EOUtilities.localInstanceOfObject(ec, eo);
        setObject(localEO);
        _relationshipKey = relationshipKey;
        if (object().isToManyKey(relationshipKey))
            isRelationshipToMany = true;
        else
View Full Code Here


     */
    public static Object valueForKey(EOEditingContext ec, String key) {
        Object result = valueForKey(key);
        if(result != null) {
            if (result instanceof EOEnterpriseObject) {
                EOEnterpriseObject eo = (EOEnterpriseObject) result;
                if(eo.editingContext() != null && eo.editingContext() != ec) {
                  eo.editingContext().lock();
                  try {
                    result = ERXEOControlUtilities.localInstanceOfObject(ec, eo);
                  } finally {
                    eo.editingContext().unlock();
                  }
                }
            } else {
               throw new ClassCastException("Expected EO, got : " + result.getClass().getName() + ", " + result);
            }
View Full Code Here

        }
       
        @Override
        public WOComponent runWithPageConfiguration(String value) {
            WOComponent start = super.runWithPageConfiguration(value);
            EOEnterpriseObject eo;
            EOEditingContext ec = ERXEC.newEditingContext();
            //this.log.debug("runWithPageConfiguration: pc <" + value + "> - " + d2wContext().entity());
            eo = EOUtilities.createAndInsertInstance(ec, d2wContext().entity().name());
            setObject(eo);
            start.takeValueForKey(object(), "object");
View Full Code Here

        // add new values to relationship, remove old values
        Object aSourceObject = _localSourceObject();
        boolean isDictionary = (aSourceObject instanceof NSMutableDictionary);
        NSMutableDictionary _dictionary = (isDictionary) ? (NSMutableDictionary) aSourceObject : null;
        EOEnterpriseObject _eo = (!isDictionary) ? (EOEnterpriseObject) aSourceObject : null;
        String masterKey = _localRelationshipKey();
        NSMutableArray currentValues = (NSMutableArray) NSKeyValueCoding.Utility.valueForKey(aSourceObject, masterKey);
        int count = currentValues.count();
        EOEnterpriseObject o;

        for (int i = count - 1; i >= 0; i--) {
            o = (EOEnterpriseObject) currentValues.objectAtIndex(i);

            if (newValues == null || newValues.indexOfIdenticalObject(o) == NSArray.NotFound) { // not found
View Full Code Here

    EOEditingContext ec = ERXEC.newEditingContext();
    ec.lock();
    try {
      Random random = new Random(12);
      for (int i = 0; i < 100; i++) {
        EOEnterpriseObject eo = EOUtilities.createAndInsertInstance(ec, "LuceneAsset");
        eo.takeValueForKey(new NSTimestamp().timestampByAddingGregorianUnits(0, 0, -random.nextInt(2500), 0, 0, 0), "creationDate");
        eo.takeValueForKey(ERXLoremIpsumGenerator.randomSentence(), "contents");
        eo.takeValueForKey(random.nextDouble(), "price");
        eo.takeValueForKey(Long.valueOf(random.nextInt(2500)), "userCount");
      }
      ec.saveChanges();
    } finally {
      ec.unlock();
    }
View Full Code Here

    public NSArray browserSelections;
    public String sortedObjects;

    public void setMasterObjectAndRelationshipKey(EOEnterpriseObject eo, String relationshipKey) {
      EOEditingContext ec = ERXEC.newEditingContext(eo.editingContext(), false)// a non-validating context
        EOEnterpriseObject newObject=EOUtilities.localInstanceOfObject(ec,eo);
        setObject(newObject);
        _relationshipKey = relationshipKey;

        if (!object().isToManyKey(relationshipKey))
            throw new RuntimeException(relationshipKey+" is not a to-many relationship");
View Full Code Here

        _state = LIST;
        return context().page();
    }

    public WOComponent selectAction() {
        EOEnterpriseObject _localEoToAddToRelationship = _eoToAddToRelationship != null ?
        EOUtilities.localInstanceOfObject(editingContext(),_eoToAddToRelationship) : null;

        if (_localEoToAddToRelationship != null) {
            // we create a join
            EOEnterpriseObject joinEO=ERXEOControlUtilities.createAndInsertObject(editingContext(), entity().name());

            NSArray sortedObjects=relationshipDisplayGroup.displayedObjects();
            if(isSortedRelationship()){
                Number lastIndex = null;
                if (sortedObjects!=null && sortedObjects.count()>0) {
                    EOEnterpriseObject lastObject=(EOEnterpriseObject)relationshipDisplayGroup.displayedObjects().lastObject();
                    lastIndex=(Number)lastObject.valueForKey(indexKey());
                }
                int newIndex = lastIndex!=null ? lastIndex.intValue()+1 : 0;
                joinEO.takeValueForKey(ERXConstant.integerForInt(newIndex),indexKey());               
            }
            joinEO.addObjectToBothSidesOfRelationshipWithKey(_localEoToAddToRelationship,
View Full Code Here

    public WOComponent removeFromToManyRelationshipAction() {
        if(((ERXSession)session()).javaScriptEnabled())
            updateEOsOrdering();    
        if (browserSelections != null) {
            for (Enumeration e = browserSelections.objectEnumerator(); e.hasMoreElements();) {
                EOEnterpriseObject object=(EOEnterpriseObject)e.nextElement();
                EOEnterpriseObject _localEoToRremoveFromRelationship =
                    (EOEnterpriseObject)object.valueForKey(destinationRelationship().name());
                object.removeObjectFromBothSidesOfRelationshipWithKey(_localEoToRremoveFromRelationship,
                                                                    destinationRelationship().name());
                object().removeObjectFromBothSidesOfRelationshipWithKey(object,
                                                                      relationshipKey());
                if(((object instanceof ERXGuardedObjectInterface) && ((ERXGuardedObjectInterface)object).canDelete())
                    || !(object instanceof ERXGuardedObjectInterface)) {
                     editingContext().deleteObject(object);
                }
            }
            relationshipDisplayGroup.fetch(); // updateDisplayedObjects is not doing the trick
            if (isSortedRelationship()) {
                //Now need to reindex the joins if the relationship is sorted
                int i = 0;
                for(Enumeration e = relationshipDisplayGroup.displayedObjects().objectEnumerator();
                    e.hasMoreElements();){
                    EOEnterpriseObject object = (EOEnterpriseObject)e.nextElement();
                    object.takeValueForKey(ERXConstant.integerForInt(i), indexKey());
                    i++;
                }
            }
        }
        return null;
View Full Code Here

    public WOComponent removeAllFromToManyRelationship(){
        if(((ERXSession)session()).javaScriptEnabled())
            updateEOsOrdering();
        for (Enumeration e = relationshipDisplayGroup.displayedObjects().immutableClone().objectEnumerator(); e.hasMoreElements();) {
            EOEnterpriseObject joinObject=(EOEnterpriseObject)e.nextElement();
            EOEnterpriseObject _localEoToRremoveFromRelationship =
                (EOEnterpriseObject)joinObject.valueForKey(destinationRelationship().name());
            joinObject.removeObjectFromBothSidesOfRelationshipWithKey(_localEoToRremoveFromRelationship,
                                                                  destinationRelationship().name());
            object().removeObjectFromBothSidesOfRelationshipWithKey(joinObject,
                                                                    relationshipKey());
View Full Code Here

            if(hiddenFieldValues != null){
                int i = 0;
                for(Enumeration e = hiddenFieldValues.objectEnumerator(); e.hasMoreElements();){
                    String objectForHashCode = (String)e.nextElement();
                    if(log.isDebugEnabled()) log.debug("objectForHashCode = "+objectForHashCode);
                    EOEnterpriseObject eo = objectForHashCode(objectForHashCode);
                    if(eo!=null){
                        eo.takeValueForKey(ERXConstant.integerForInt(i), indexKey());
                    }else{
                        log.warn("objectForHashCode: "+objectForHashCode+" doesn't have a corresponding object");
                    }
                    i++;
                }
View Full Code Here

TOP

Related Classes of com.webobjects.eocontrol.EOEnterpriseObject

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.