Examples of EntityResult


Examples of org.broadleafcommerce.openadmin.dto.EntityResult

    }


    @Override
    public Entity add(PersistencePackage persistencePackage) throws ServiceException {
        EntityResult entityResult = add(persistencePackage, false);
        return entityResult.getEntity();
    }
View Full Code Here

Examples of org.broadleafcommerce.openadmin.dto.EntityResult

        return entityResult.getEntity();
    }

    @Override
    public EntityResult add(PersistencePackage persistencePackage, boolean includeRealEntityObject) throws ServiceException {
        EntityResult entityResult = new EntityResult();
        Entity entity = persistencePackage.getEntity();
        PersistencePerspective persistencePerspective = persistencePackage.getPersistencePerspective();
        ForeignKey foreignKey = (ForeignKey) persistencePerspective.getPersistencePerspectiveItems().get(PersistencePerspectiveItemType.FOREIGNKEY);
        if (foreignKey != null && !foreignKey.getMutable()) {
            throw new SecurityServiceException("Entity not mutable");
        }
        try {
            Class<?>[] entities = persistenceManager.getPolymorphicEntities(persistencePackage.getCeilingEntityFullyQualifiedClassname());
            Map<String, FieldMetadata> mergedUnfilteredProperties = persistenceManager.getDynamicEntityDao().getMergedProperties(
                persistencePackage.getCeilingEntityFullyQualifiedClassname(),
                entities,
                foreignKey,
                persistencePerspective.getAdditionalNonPersistentProperties(),
                persistencePerspective.getAdditionalForeignKeys(),
                MergedPropertyType.PRIMARY,
                persistencePerspective.getPopulateToOneFields(),
                persistencePerspective.getIncludeFields(),
                persistencePerspective.getExcludeFields(),
                persistencePerspective.getConfigurationKey(),
                ""
            );
            Map<String, FieldMetadata> mergedProperties = filterOutCollectionMetadata(mergedUnfilteredProperties);

            String idProperty = null;
            for (String property : mergedProperties.keySet()) {
                if (((BasicFieldMetadata) mergedProperties.get(property)).getFieldType() == SupportedFieldType.ID) {
                    idProperty = property;
                    break;
                }
            }
            if (idProperty == null) {
                throw new RuntimeException("Could not find a primary key property in the passed entity with type: " + entity.getType()[0]);
            }
            Object primaryKey = null;
            try {
                primaryKey = getPrimaryKey(entity, mergedProperties);
            } catch (Exception e) {
                //don't do anything - this is a valid case
            }
            if (primaryKey == null) {
                Serializable instance = (Serializable) Class.forName(entity.getType()[0]).newInstance();
                instance = createPopulatedInstance(instance, entity, mergedProperties, false);

                instance = persistenceManager.getDynamicEntityDao().merge(instance);
                if (includeRealEntityObject) {
                    entityResult.setEntityBackingObject(instance);
                }
                List<Serializable> entityList = new ArrayList<Serializable>(1);
                entityList.add(instance);

                entity = getRecords(mergedProperties, entityList, null, null)[0];
                entityResult.setEntity(entity);
                return entityResult;
            } else {
                return update(persistencePackage, primaryKey, includeRealEntityObject);
            }
        } catch (Exception e) {
View Full Code Here

Examples of org.eclipse.persistence.queries.EntityResult

        // Initialize a new SqlResultSetMapping (with the metadata name)
        SQLResultSetMapping mapping = new SQLResultSetMapping(getName());
       
        // Process the entity results.
        for (EntityResultMetadata eResult : m_entityResults) {
            EntityResult entityResult = new EntityResult(MetadataHelper.getClassForName(eResult.getEntityClass().getName(), loader));
       
            // Process the field results.
            if (eResult.hasFieldResults()) {
                for (FieldResultMetadata fResult : eResult.getFieldResults()) {
                    entityResult.addFieldResult(new FieldResult(fResult.getName(), fResult.getColumn()));
                }
            }
       
            // Process the discriminator value;
            entityResult.setDiscriminatorColumn(eResult.getDiscriminatorColumn());
       
            // Add the result to the SqlResultSetMapping.
            mapping.addResult(entityResult);
        }
       
View Full Code Here

Examples of org.eclipse.persistence.queries.EntityResult

     * INTERNAL:
     * Process the entity result for the given sql result set mapping.
     */
    public EntityResult process(ClassLoader loader) {
        // Create a new entity result.
        EntityResult entityResult = new EntityResult(MetadataHelper.getClassForName(getEntityClass().getName(), loader));
   
        // Process the field results.
        for (FieldResultMetadata fieldResult : getFieldResults()) {
            entityResult.addFieldResult(fieldResult.process());
        }
   
        // Process the discriminator value;
        if (getDiscriminatorColumn() != null) {
            DatabaseField discriminatorField = new DatabaseField();
           
            // Process the name (taking into consideration delimiters etc.)
            setFieldName(discriminatorField, getDiscriminatorColumn());
           
            // Set the discriminator column on the entity result.
            entityResult.setDiscriminatorColumn(discriminatorField);
        }
   
        // Return the entity result to the caller.
        return entityResult;
    }
View Full Code Here

Examples of org.eclipse.persistence.queries.EntityResult

        // Initialize a new SqlResultSetMapping (with the metadata name)
        SQLResultSetMapping mapping = new SQLResultSetMapping(getName());
       
        // Process the entity results.
        for (EntityResultMetadata eResult : m_entityResults) {
            EntityResult entityResult = new EntityResult(MetadataHelper.getClassForName(eResult.getEntityClass().getName(), loader));
       
            // Process the field results.
            if (eResult.hasFieldResults()) {
                for (FieldResultMetadata fResult : eResult.getFieldResults()) {
                    FieldResult fieldResult = new FieldResult(fResult.getName(), fResult.getColumn());
                    if (project.useDelimitedIdentifier()) {
                        fieldResult.getColumn().setUseDelimiters(true);
                    } else if (project.getShouldForceFieldNamesToUpperCase() && !fieldResult.getColumn().shouldUseDelimiters()) {
                        fieldResult.getColumn().useUpperCaseForComparisons(true);
                    }
                    entityResult.addFieldResult(fieldResult);
                }
            }
       
            // Process the discriminator value;
            if (eResult.getDiscriminatorColumn() !=null){
                DatabaseField descriminatorField = new DatabaseField(eResult.getDiscriminatorColumn());
                if (project.useDelimitedIdentifier()) {
                    descriminatorField.setUseDelimiters(true);
                } else if (project.getShouldForceFieldNamesToUpperCase() && !descriminatorField.shouldUseDelimiters()){
                    descriminatorField.useUpperCaseForComparisons(true);
                }
                entityResult.setDiscriminatorColumn(descriminatorField);
            }
       
            // Add the result to the SqlResultSetMapping.
            mapping.addResult(entityResult);
        }
View Full Code Here

Examples of org.eclipse.persistence.queries.EntityResult

        // Initialize a new SqlResultSetMapping (with the metadata name)
        SQLResultSetMapping mapping = new SQLResultSetMapping(getName());
       
        // Process the entity results.
        for (EntityResultMetadata eResult : m_entityResults) {
            EntityResult entityResult = new EntityResult(MetadataHelper.getClassForName(eResult.getEntityClass().getName(), loader));
       
            // Process the field results.
            if (eResult.hasFieldResults()) {
                for (FieldResultMetadata fResult : eResult.getFieldResults()) {
                    entityResult.addFieldResult(new FieldResult(fResult.getName(), fResult.getColumn()));
                }
            }
       
            // Process the discriminator value;
            entityResult.setDiscriminatorColumn(eResult.getDiscriminatorColumn());
       
            // Add the result to the SqlResultSetMapping.
            mapping.addResult(entityResult);
        }
       
View Full Code Here

Examples of org.eclipse.persistence.queries.EntityResult

        // Initialize a new SqlResultSetMapping (with the metadata name)
        SQLResultSetMapping mapping = new SQLResultSetMapping(getName());
       
        // Process the entity results.
        for (EntityResultMetadata eResult : m_entityResults) {
            EntityResult entityResult = new EntityResult(MetadataHelper.getClassForName(eResult.getEntityClass().getName(), loader));
       
            // Process the field results.
            if (eResult.hasFieldResults()) {
                for (FieldResultMetadata fResult : eResult.getFieldResults()) {
                    FieldResult fieldResult = new FieldResult(fResult.getName(), fResult.getColumn());
                    if (project.useDelimitedIdentifier()) {
                        fieldResult.getColumn().setUseDelimiters(true);
                    } else if (project.getShouldForceFieldNamesToUpperCase() && !fieldResult.getColumn().shouldUseDelimiters()) {
                        fieldResult.getColumn().useUpperCaseForComparisons(true);
                    }
                    entityResult.addFieldResult(fieldResult);
                }
            }
       
            // Process the discriminator value;
            if (eResult.getDiscriminatorColumn() !=null){
                DatabaseField descriminatorField = new DatabaseField(eResult.getDiscriminatorColumn());
                if (project.useDelimitedIdentifier()) {
                    descriminatorField.setUseDelimiters(true);
                } else if (project.getShouldForceFieldNamesToUpperCase() && !descriminatorField.shouldUseDelimiters()){
                    descriminatorField.useUpperCaseForComparisons(true);
                }
                entityResult.setDiscriminatorColumn(descriminatorField);
            }
       
            // Add the result to the SqlResultSetMapping.
            mapping.addResult(entityResult);
        }
View Full Code Here

Examples of org.eclipse.persistence.queries.EntityResult

        // Initialize a new SqlResultSetMapping (with the metadata name)
        SQLResultSetMapping mapping = new SQLResultSetMapping(getName());
       
        // Process the entity results.
        for (EntityResultMetadata eResult : m_entityResults) {
            EntityResult entityResult = new EntityResult(MetadataHelper.getClassForName(eResult.getEntityClass().getName(), loader));
       
            // Process the field results.
            if (eResult.hasFieldResults()) {
                for (FieldResultMetadata fResult : eResult.getFieldResults()) {
                    FieldResult fieldResult = new FieldResult(fResult.getName(), fResult.getColumn());
                    if (project.useDelimitedIdentifier()) {
                        fieldResult.getColumn().setUseDelimiters(true);
                    } else if (project.getShouldForceFieldNamesToUpperCase() && !fieldResult.getColumn().shouldUseDelimiters()) {
                        //done directly as this field's name should be in uppercase.
                        fieldResult.getColumn().setName(fieldResult.getColumn().getName().toUpperCase());
                    }
                    entityResult.addFieldResult(fieldResult);
                }
            }
       
            // Process the discriminator value;
            if (eResult.getDiscriminatorColumn() !=null){
                DatabaseField descriminatorField = new DatabaseField(eResult.getDiscriminatorColumn());
                if (project.useDelimitedIdentifier()) {
                    descriminatorField.setUseDelimiters(true);
                } else if (project.getShouldForceFieldNamesToUpperCase() && !descriminatorField.shouldUseDelimiters()){
                    descriminatorField.setName(descriminatorField.getName().toUpperCase());
                }
                entityResult.setDiscriminatorColumn(descriminatorField);
            }
       
            // Add the result to the SqlResultSetMapping.
            mapping.addResult(entityResult);
        }
View Full Code Here

Examples of org.eclipse.persistence.queries.EntityResult

        // Initialize a new SqlResultSetMapping (with the metadata name)
        SQLResultSetMapping mapping = new SQLResultSetMapping(getName());
       
        // Process the entity results.
        for (EntityResultMetadata eResult : m_entityResults) {
            EntityResult entityResult = new EntityResult(MetadataHelper.getClassForName(eResult.getEntityClass().getName(), loader));
       
            // Process the field results.
            if (eResult.hasFieldResults()) {
                for (FieldResultMetadata fResult : eResult.getFieldResults()) {
                    entityResult.addFieldResult(new FieldResult(fResult.getName(), fResult.getColumn()));
                }
            }
       
            // Process the discriminator value;
            entityResult.setDiscriminatorColumn(eResult.getDiscriminatorColumn());
       
            // Add the result to the SqlResultSetMapping.
            mapping.addResult(entityResult);
        }
       
View Full Code Here

Examples of org.eclipse.persistence.queries.EntityResult

        // Initialize a new SqlResultSetMapping (with the metadata name)
        SQLResultSetMapping mapping = new SQLResultSetMapping(getName());
       
        // Process the entity results.
        for (EntityResultMetadata eResult : m_entityResults) {
            EntityResult entityResult = new EntityResult(MetadataHelper.getClassForName(eResult.getEntityClass().getName(), loader));
       
            // Process the field results.
            if (eResult.hasFieldResults()) {
                for (FieldResultMetadata fResult : eResult.getFieldResults()) {
                    entityResult.addFieldResult(new FieldResult(fResult.getName(), fResult.getColumn()));
                }
            }
       
            // Process the discriminator value;
            entityResult.setDiscriminatorColumn(eResult.getDiscriminatorColumn());
       
            // Add the result to the SqlResultSetMapping.
            mapping.addResult(entityResult);
        }
       
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.