Package com.webobjects.eocontrol

Examples of com.webobjects.eocontrol.EOEnterpriseObject


            if (sender instanceof ERDObjectSaverInterface) {
                if (((ERDObjectSaverInterface)sender).objectWasSaved()) {
                    // The user saved the object instead of hitting cancel, better hook it up
                    // to the releationship
                    // Have to use our interface as EditPageInterface doesn't have object().
                    EOEnterpriseObject talent = EOUtilities.localInstanceOfObject(movie.editingContext(),
                                                               ((ERDEditPageInterface)sender).object());
                    movie.addObjectToBothSidesOfRelationshipWithKey(talent, "directors");
                }
            } else {
                log.error("Using CreateDirectorDelegate with a sender that does not implement ERDObjectSaverInterface! Sender class: " + sender.getClass().getName());
View Full Code Here


    // Added by Max
    /////////////////////////////////////////////////////////

    public WOComponent newMovieWithPageConfiguration(String pageConfig) {
        EOEditingContext ec = ERXEC.newEditingContext();
        EOEnterpriseObject movie = ERXEOControlUtilities.createAndInsertObject(ec, "Movie");
        EditPageInterface epi = (EditPageInterface)D2W.factory().pageForConfigurationNamed(pageConfig,
                                                                                           session());
        epi.setObject(movie);
        epi.setNextPage(context().page());
        return (WOComponent)epi;       
View Full Code Here

                    NSArray gids = (NSArray) entries.objectForKey(sourceGid);
                    if(gids != null) {
                        NSMutableArray eos = new NSMutableArray(gids.count());
                        for (Enumeration enumerator = gids.objectEnumerator(); enumerator.hasMoreElements();) {
                            EOGlobalID gid = (EOGlobalID) enumerator.nextElement();
                            EOEnterpriseObject eo = ec.faultForGlobalID(gid, ec);
                            eos.addObject(eo);
                        }
                        EOFaultHandler.clearFault(obj);
                        ((NSMutableArray)fault).addObjectsFromArray(eos);
                        return true;
View Full Code Here

    @Override
    public void awake() {

        EOEditingContext ec = ERXEC.newEditingContext();

        EOEnterpriseObject result = EOUtilities.createAndInsertInstance(ec, "Result");

        NSDictionary<String,NSArray<Object>> values = context().request().formValues();

        for (String key : values.allKeys()) {

            if (key.equals("when")) {
                String when = values.objectForKey(key).get(0).toString();
                result.takeValueForKey(when, "whence");
            }

            if (key.equals("timezone")) {
                String when = values.objectForKey(key).get(0).toString();
                result.takeValueForKey(when, "timeZone");
            }

            if (key.equals("duration")) {
                Number duration = Long.valueOf(values.objectForKey(key).get(0).toString());
                result.takeValueForKey(duration, "duration");
            }

            if (key.equals("email")) {
                String email = values.objectForKey(key).get(0).toString();
                result.takeValueForKey(email, "email");
            }

            if (key.startsWith("env")) {
                String env = values.objectForKey(key).get(0).toString();
                NSArray<EOEnterpriseObject> found = EOUtilities.objectsMatchingKeyAndValue(ec, "Environment", "info", env);
                EOEnterpriseObject eo;
                if (found == null || found.size() == 0) {
                    eo = EOUtilities.createAndInsertInstance(ec, "Environment");
                    eo.takeValueForKey(env, "info");
                } else {
                    eo = found.get(0);
                }
                result.addObjectToBothSidesOfRelationshipWithKey(eo, "environments");
            }

            if (key.startsWith("vers")) {
                NSArray<String> parts = NSArray.componentsSeparatedByString(values.objectForKey(key).get(0).toString(), " ");
                EOEnterpriseObject eo = EOUtilities.createAndInsertInstance(ec, "VersionDigest");
                eo.takeValueForKey(parts.get(1), "rname");
                eo.takeValueForKey(parts.get(0), "digest");
                result.addObjectToBothSidesOfRelationshipWithKey(eo, "digests");
            }

            if (key.startsWith("fail")) {
                String message = values.objectForKey(key).get(0).toString();
                EOEnterpriseObject eo = EOUtilities.createAndInsertInstance(ec, "Failure");
                eo.takeValueForKey(message, "message");
                result.addObjectToBothSidesOfRelationshipWithKey(eo, "failures");
            }
        }

        ec.saveChanges();
View Full Code Here

  public static final ERD2WSelectActionDelegate instance = new ERD2WSelectActionDelegate();

  public WOComponent nextPage(WOComponent sender) {
    WOComponent target = D2WEmbeddedComponent.findTarget(sender);
    if(target.hasBinding("selectedObject")){
      EOEnterpriseObject selectedObject = ((SelectPageInterface)sender).selectedObject();
      target.setValueForBinding(selectedObject, "selectedObject");
    }
    return (WOComponent)target.valueForBinding("action");
  }
View Full Code Here

                    // in an shared editing context
                    EOEditingContext ec = ERXEC.newEditingContext();
                    ec.lock();
                    try {
                        ec.setSharedEditingContext(null);
                        EOEnterpriseObject object = EOUtilities.localInstanceOfObject(ec, _object);
                        ec.deleteObject(object);
                        ec.saveChanges();
                    } finally {
                        ec.unlock();
                        ec.dispose();
                    }
                } else {
                  //Place the EO into a nested ec and try to delete there
                  //to prevent the appearance of a successful delete if
                  //validation fails.
                  EOEnterpriseObject eo = ERXEOControlUtilities.editableInstanceOfObject(_object, true);
                  EOEditingContext childEC = eo.editingContext();
                  childEC.deleteObject(eo);
                  childEC.saveChanges();
                 
                    if (ERXEOControlUtilities.isNewObject(_object)) {
                        // This is necessary to force state synching, e.g., for display groups, etc.
                        editingContext.processRecentChanges();
                    } else {
                        // Only save if the object is NOT new.
                        editingContext.saveChanges();
                    }
                    _object = null;
                }
            } catch (EOObjectNotAvailableException e) {
                exception = ERXValidationFactory.defaultFactory().createCustomException(_object, "EOObjectNotAvailableException");
            } catch (EOGeneralAdaptorException e) {
              NSDictionary userInfo = e.userInfo();
              if(userInfo != null) {
                EODatabaseOperation op = (EODatabaseOperation)userInfo.objectForKey(EODatabaseContext.FailedDatabaseOperationKey);
                if(op.databaseOperator() == EODatabaseOperation.DatabaseDeleteOperator) {
                  exception = ERXValidationFactory.defaultFactory().createCustomException(_object, "EOObjectNotAvailableException");
                }
              }
              if(exception == null) {
                exception = ERXValidationFactory.defaultFactory().createCustomException(_object, "Database error: " + e.getMessage());
              }
            } catch (NSValidation.ValidationException e) {
                exception = e;
            }
            if(exception != null) {
                if (exception instanceof ERXValidationException) {
                    ERXValidationException ex = (ERXValidationException) exception;
                    D2WContext context = (D2WContext) sender.valueForKey("d2wContext");
                    Object o = ex.object();

                    if (o instanceof EOEnterpriseObject) {
                        EOEnterpriseObject eo = (EOEnterpriseObject) o;
                        context.takeValueForKey(eo.entityName(), "entityName");
                        context.takeValueForKey(ex.propertyKey(), "propertyKey");
                    }
                    ((ERXValidationException) exception).setContext(context);
                }
                log.info("Validation Exception: " + exception + exception.getMessage());
View Full Code Here

    public Object smartAttribute(D2WContext c) {
        EOAttribute result=null;
        String propertyKey=c.propertyKey();
        Object rawObject=c.valueForKey("object");
        if (rawObject!=null && rawObject instanceof EOEnterpriseObject && propertyKey!=null) {
            EOEnterpriseObject object=(EOEnterpriseObject)rawObject;
            EOEnterpriseObject lastEO=object;
            if (lastEO!=null && propertyKey.indexOf(".")!=-1 && propertyKey.indexOf("@")==-1) {
                String partialKeyPath=KeyValuePath.keyPathWithoutLastProperty(propertyKey);
                Object rawLastEO=object.valueForKeyPath(partialKeyPath);
                lastEO=rawLastEO instanceof EOEnterpriseObject ? (EOEnterpriseObject)rawLastEO : null;
            }
            if (lastEO!=null) {
                EOEntity entity=EOModelGroup.defaultGroup().entityNamed(lastEO.entityName());
                String lastKey=KeyValuePath.lastPropertyKeyInKeyPath(propertyKey);
                result=entity.attributeNamed(lastKey);
            }
        }
        if (result==null) {
View Full Code Here

        Object result = null;
        Object rawObject=c.valueForKey("object");
        String propertyKey=c.propertyKey();
        if(propertyKey != null) {
            if (rawObject!=null && rawObject instanceof EOEnterpriseObject) {
                EOEnterpriseObject object=(EOEnterpriseObject)rawObject;
                EOEnterpriseObject lastEO=object;
                if (propertyKey.indexOf(".")!=-1 && propertyKey.indexOf("@")==-1) {
                    String partialKeyPath=KeyValuePath.keyPathWithoutLastProperty(propertyKey);
                    Object rawLastEO=object.valueForKeyPath(partialKeyPath);
                    lastEO=rawLastEO instanceof EOEnterpriseObject ? (EOEnterpriseObject)rawLastEO : null;
                }
                if (lastEO!=null) {
                    EOEntity entity=EOModelGroup.defaultGroup().entityNamed(lastEO.entityName());
                    String lastKey=KeyValuePath.lastPropertyKeyInKeyPath(propertyKey);
                    result=entity.relationshipNamed(lastKey);
                }
            }
            if (result==null) {
View Full Code Here

    public Object smartAttribute(D2WContext c) {
        EOAttribute result=null;
        String propertyKey=c.propertyKey();
        Object rawObject=c.valueForKey("object");
        if (rawObject!=null && rawObject instanceof EOEnterpriseObject && propertyKey!=null) {
            EOEnterpriseObject object=(EOEnterpriseObject)rawObject;
            EOEnterpriseObject lastEO=object;
            if (lastEO!=null && propertyKey.indexOf(".")!=-1) {
                String partialKeyPath=KeyValuePath.keyPathWithoutLastProperty(propertyKey);
                Object rawLastEO=object.valueForKeyPath(partialKeyPath);
                lastEO=rawLastEO instanceof EOEnterpriseObject ? (EOEnterpriseObject)rawLastEO : null;
            }
            if (lastEO!=null) {
                EOEntity entity=EOModelGroup.defaultGroup().entityNamed(lastEO.entityName());
                String lastKey=KeyValuePath.lastPropertyKeyInKeyPath(propertyKey);
                result=entity.attributeNamed(lastKey);
            }
        }
        if (result==null) {
View Full Code Here

        NSArray someObjects = anEditingContext.objectsWithFetchSpecification(aFetchSpecification);

        System.out.println("Fetch result for '" + aQualifier + "': " + someObjects.valueForKey("name"));

        if (someObjects != null) {
            EOEnterpriseObject anObject = (EOEnterpriseObject) someObjects.lastObject();
            NSArray someFiles = (NSArray) anObject.valueForKey("files");
            NSArray someDirectories = (NSArray) anObject.valueForKey("directories");

            System.out.println("anObject name: " + anObject.valueForKey("name"));
            System.out.println("someFiles.count: " + someFiles.count());
            System.out.println("someFiles.name: " + someFiles.valueForKey("name"));
            System.out.println("someFiles.content.length: " + someFiles.valueForKeyPath("content.length"));
            System.out.println("someDirectories.count: " + someDirectories.count());
            System.out.println("someDirectories.name: " + someDirectories.valueForKey("name"));
        }
        EOClassDescription aClassDescription = EOClassDescription.classDescriptionForEntityName("FSDirectory");
        EOEnterpriseObject anObject = aClassDescription.createInstanceWithEditingContext(anEditingContext, null);
        anObject.takeValueForKey((System.getProperty("user.home") + File.separator + "FSItemInsertTest"), "absolutePath");

        anEditingContext.insertObject(anObject);
        anEditingContext.saveChanges();

        anEditingContext.deleteObject(anObject);
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.