Examples of ObjEntity


Examples of org.apache.cayenne.map.ObjEntity

        // filter out excluded entities...
        Iterator<ObjEntity> it = entities.iterator();

        while (it.hasNext()) {
            ObjEntity e = it.next();
            if (e.isGeneric()) {
                it.remove();
            }
            else if (client && !e.isClientAllowed()) {
                it.remove();
            }
            else if (!nameFilter.isIncluded(e.getName())) {
                it.remove();
            }
        }

        return entities;
View Full Code Here

Examples of org.apache.cayenne.map.ObjEntity

        object.setDataContext(null);
    }

    private void processDeleteRules(DataObject object, int oldState)
            throws DeleteDenyException {
        ObjEntity entity = dataContext.getEntityResolver().lookupObjEntity(object);
        Iterator it = entity.getRelationships().iterator();
        while (it.hasNext()) {
            ObjRelationship relationship = (ObjRelationship) it.next();

            boolean processFlattened = relationship.isFlattened()
                    && relationship.isToDependentEntity();
View Full Code Here

Examples of org.apache.cayenne.map.ObjEntity

            List mainRows = response.firstList();
            if (mainRows != null && !mainRows.isEmpty()) {

                List objects;
                ObjEntity entity = metadata.getObjEntity();
                PrefetchTreeNode prefetchTree = metadata.getPrefetchTree();

                // take a shortcut when no prefetches exist...
                if (prefetchTree == null) {
                    objects = new ObjectResolver(context, entity, metadata
View Full Code Here

Examples of org.apache.cayenne.map.ObjEntity

    public Persistent newObject(Class persistentClass) {
        if (persistentClass == null) {
            throw new NullPointerException("Persistent class can't be null.");
        }

        ObjEntity entity = getEntityResolver().lookupObjEntity(persistentClass);
        if (entity == null) {
            throw new CayenneRuntimeException("No entity mapped for class: "
                    + persistentClass);
        }

        synchronized (graphManager) {
            return createNewObject(new ObjectId(entity.getName()));
        }
    }
View Full Code Here

Examples of org.apache.cayenne.map.ObjEntity

     * this object.
     */
    protected void unsetReverseRelationship(String relName, DataObject val) {

        EntityResolver resolver = objectContext.getEntityResolver();
        ObjEntity entity = resolver.lookupObjEntity(objectId.getEntityName());

        if (entity == null) {
            throw new IllegalStateException("DataObject's entity is unmapped, objectId: "
                    + objectId);
        }

        ObjRelationship rel = (ObjRelationship) entity.getRelationship(relName);
        ObjRelationship revRel = rel.getReverseRelationship();
        if (revRel != null) {
            if (revRel.isToMany())
                val.removeToManyTarget(revRel.getName(), this, false);
            else
View Full Code Here

Examples of org.apache.cayenne.map.ObjEntity

     *
     * @since 1.1
     */
    protected void validateForSave(ValidationResult validationResult) {

        ObjEntity objEntity = getDataContext().getEntityResolver().lookupObjEntity(this);
        if (objEntity == null) {
            throw new CayenneRuntimeException(
                    "No ObjEntity mapping found for DataObject " + getClass().getName());
        }

        DataNode node = getDataContext().getParentDataDomain().lookupDataNode(
                objEntity.getDataMap());
        if (node == null) {
            throw new CayenneRuntimeException("No DataNode found for objEntity: "
                    + objEntity.getName());
        }

        ExtendedTypeMap types = node.getAdapter().getExtendedTypes();

        // validate mandatory attributes

        // handling a special case - meaningful mandatory FK... defer failures until
        // relationship validation is done... This is just a temporary solution, as
        // handling meaningful keys within the object lifecycle requires something more,
        // namely read/write methods for relationships and direct values should be
        // synchronous with each other..
        Map failedDbAttributes = null;

        Iterator attributes = objEntity.getAttributes().iterator();
        while (attributes.hasNext()) {
            ObjAttribute objAttribute = (ObjAttribute) attributes.next();
            DbAttribute dbAttribute = objAttribute.getDbAttribute();

            Object value = this.readPropertyDirectly(objAttribute.getName());
            if (dbAttribute.isMandatory()) {
                ValidationFailure failure = BeanValidationFailure.validateNotNull(
                        this,
                        objAttribute.getName(),
                        value);

                if (failure != null) {

                    if (failedDbAttributes == null) {
                        failedDbAttributes = new HashMap();
                    }

                    failedDbAttributes.put(dbAttribute.getName(), failure);
                    continue;
                }
            }

            if (value != null) {

                // TODO: should we pass null values for validation as well?
                // if so, class can be obtained from ObjAttribute...

                types.getRegisteredType(value.getClass()).validateProperty(
                        this,
                        objAttribute.getName(),
                        value,
                        dbAttribute,
                        validationResult);
            }
        }

        // validate mandatory relationships
        Iterator relationships = objEntity.getRelationships().iterator();
        while (relationships.hasNext()) {
            ObjRelationship relationship = (ObjRelationship) relationships.next();

            if (relationship.isSourceIndependentFromTargetChange()) {
                continue;
View Full Code Here

Examples of org.apache.cayenne.map.ObjEntity

     *
     * @since 1.2
     */
    public void encodeAsXML(XMLEncoder encoder) {
        EntityResolver er = getDataContext().getEntityResolver();
        ObjEntity object = er.lookupObjEntity(getClass());

        String[] fields = this.getClass().getName().split("\\.");
        encoder.setRoot(fields[fields.length - 1], this.getClass().getName());

        for (Iterator it = object.getDeclaredAttributes().iterator(); it.hasNext();) {
            ObjAttribute att = (ObjAttribute) it.next();
            String name = att.getName();
            encoder.encodeProperty(name, readNestedProperty(name));
        }
    }
View Full Code Here

Examples of org.apache.cayenne.map.ObjEntity

            encoder.encodeProperty(name, readNestedProperty(name));
        }
    }

    public void decodeFromXML(XMLDecoder decoder) {
        ObjEntity object = null;

        // TODO: relying on singleton Configuration is a bad idea...
        // Probably decoder itself can optionally store a DataContext or an EntityResolver
        // to provide "context" appropriate for a given environment
        for (Iterator it = Configuration
                .getSharedConfiguration()
                .getDomain()
                .getDataNodes()
                .iterator(); it.hasNext();) {
            DataNode dn = (DataNode) it.next();

            EntityResolver er = dn.getEntityResolver();
            object = er.lookupObjEntity(getClass());

            if (null != object) {
                break;
            }
        }

        for (Iterator it = object.getDeclaredAttributes().iterator(); it.hasNext();) {
            ObjAttribute att = (ObjAttribute) it.next();
            String name = att.getName();
            writeProperty(name, decoder.decodeObject(name));
        }
    }
View Full Code Here

Examples of org.apache.cayenne.map.ObjEntity

     * </p>
     *
     * @since 1.1
     */
    public DataRow currentSnapshot(DataObject object) {
        ObjEntity entity = getEntityResolver().lookupObjEntity(object);

        // for a HOLLOW object return snapshot from cache
        if (object.getPersistenceState() == PersistenceState.HOLLOW
                && object.getDataContext() != null) {

            return getObjectStore().getSnapshot(object.getObjectId());
        }

        DataRow snapshot = new DataRow(10);

        Iterator attributes = entity.getAttributeMap().entrySet().iterator();
        while (attributes.hasNext()) {
            Map.Entry entry = (Map.Entry) attributes.next();
            String attrName = (String) entry.getKey();
            ObjAttribute objAttr = (ObjAttribute) entry.getValue();

            // processing compound attributes correctly
            snapshot.put(objAttr.getDbAttributePath(), object
                    .readPropertyDirectly(attrName));
        }

        Iterator relationships = entity.getRelationshipMap().entrySet().iterator();
        while (relationships.hasNext()) {
            Map.Entry entry = (Map.Entry) relationships.next();
            ObjRelationship rel = (ObjRelationship) entry.getValue();

            // if target doesn't propagates its key value, skip it
View Full Code Here

Examples of org.apache.cayenne.map.ObjEntity

    public List objectsFromDataRows(
            Class objectClass,
            List dataRows,
            boolean refresh,
            boolean resolveInheritanceHierarchy) {
        ObjEntity entity = this.getEntityResolver().lookupObjEntity(objectClass);

        if (entity == null) {
            throw new CayenneRuntimeException("Unmapped Java class: " + objectClass);
        }
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.