Examples of TableImpl


Examples of com.force.sdk.jpa.table.TableImpl

     * The SchemaWriter's {@code write()} call is made after calling this method.
     */
    private void createSchema(final ClassMetaData cmd, Class cls, final ClassLoaderResolver clr, ForceStoreManager storeManager) {
        synchronized (cmd) {
            ForceManagedConnection mconn = storeManager.createConnection();
            TableImpl table = storeManager.getTable(cmd);
           
            if (PersistenceUtils.hasNoSchema(cmd)) return; //nothing to create
           
            // only create the table if autoCreateTables is true.
            // create the fields without creating the table if the object is already in the organization
            if (storeManager.isAutoCreateTables() && (!table.getTableAlreadyExistsInOrg()
                    || storeManager.isForDelete()) && !PersistenceUtils.isReadOnlySchema(cmd, true)) {
                table.createTableAndFields(cmd, storeManager, mconn);
            } else if (table.getTableAlreadyExistsInOrg() && !PersistenceUtils.isReadOnlySchema(cmd, false)) {
                table.createFields(cmd, storeManager);
            }
           
            // handle the case where autoCreateTables is disabled but the object does not exist in the organization
            if (!storeManager.isAutoCreateTables() && !table.getTableAlreadyExistsInOrg()) {
                StringBuilder msg = new StringBuilder(256);
                msg.append("Table does not exist in force.com and datanucleus.autoCreateTables is false, table: ")
                   .append(table.getTableName().getForceApiName());
                if (storeManager.isAutoCreateWarnOnError()) {
                    LOGGER.warn(msg.toString());
                } else {
                    throw new NucleusUserException(msg.toString());
                }
View Full Code Here

Examples of com.force.sdk.jpa.table.TableImpl

            }
            sb.append(col.getFieldName());
            return;
        }

        TableImpl joinTable = ((ForceStoreManager) forceQuery.getExecutionContext().getStoreManager()).getTable(cmd);

        TableImpl parentTable = this.table;
        AbstractClassMetaData parentCmd = this.acmd;
        this.table = joinTable;
        this.acmd = cmd;
        this.fetchDepth++;
View Full Code Here

Examples of com.force.sdk.jpa.table.TableImpl

   
    private void populateFieldNames(AbstractClassMetaData acmd, OMFContext omf) throws ConnectionException {
        ForceStoreManager storeManager = (ForceStoreManager) omfContext.getStoreManager();
       
        // Grab transactional connection factory
        TableImpl table = storeManager.getTable(acmd);
        // now that we've stored all the Salesforce fields, find the {@code @Entity} definition and register the
        // Java field name on the ColumnImpl.  We'll need this info later
        int[] fieldNumbers =  acmd.getAllMemberPositions();
        if (fieldNumbers != null && fieldNumbers.length > 0) {
            for (int column : fieldNumbers) {
                addColumn(table, acmd.getMetaDataForManagedMemberAtAbsolutePosition(column), omf);
            }
        }
       
        DiscriminatorMetaData dmd = acmd.getDiscriminatorMetaData();
        if (dmd != null && dmd.getColumnName() != null) {
            ColumnImpl col = table.getColumnByForceApiName(dmd.getColumnName());
            if (col != null) {
                String javaFieldName = dmd.getColumnName();
                table.registerJavaColumn(javaFieldName, col);
            }
        }
       
    }
View Full Code Here

Examples of com.force.sdk.jpa.table.TableImpl

        Object delegate = em.getDelegate();
        Assert.assertNotNull(delegate);
        ObjectManagerImpl om = (ObjectManagerImpl) delegate;
        ForceStoreSchemaHandler forceSH = (ForceStoreSchemaHandler) om.getStoreManager().getSchemaHandler();
        // Search for TestEntity
        TableImpl table = forceSH.getTable("TestEntity");
        Assert.assertNotNull(table.getColumnByForceApiName("lastModifiedDate"));
        Assert.assertNull(table.getColumnByForceApiName("unused"));
        // Do the same test with TestEntityMethodAnnotations
        table = forceSH.getTable("TestEntityMethodAnnotations");
        Assert.assertNotNull(table.getColumnByForceApiName("lastModifiedDate"));
        Assert.assertNull(table.getColumnByForceApiName("unused"));
        // Now test the same thing with @Embedded object EmploymentPeriod
        table = forceSH.getTable("EmployeeEntity");
        Assert.assertNotNull(table.getColumnByForceApiName("emp_end__c"));
        Assert.assertNull(table.getColumnByForceApiName("duration__c"));
    }
View Full Code Here

Examples of org.datanucleus.store.rdbms.table.TableImpl

                }

                Iterator tablesIter = baseTablesByName.values().iterator();
                while (tablesIter.hasNext())
                {
                    TableImpl tbl = (TableImpl)tablesIter.next();
                    if (writer != null)
                    {
                        try
                        {
                            if (tbl instanceof ClassTable)
                            {
                                writer.write("-- Constraints for ClassTable " + tbl.toString() +
                                    " for classes " + StringUtils.objectArrayToString(((ClassTable)tbl).getManagedClasses()) + "\n");
                            }
                            else if (tbl instanceof JoinTable)
                            {
                                writer.write("-- Constraints for JoinTable " + tbl.toString() + " for join relationship\n");
                            }
                        }
                        catch (IOException ioe)
                        {
                            NucleusLogger.DATASTORE_SCHEMA.error("error writing DDL into file", ioe);
                        }
                    }

                    tbl.dropConstraints(getCurrentConnection());
                }

                tablesIter = baseTablesByName.values().iterator();
                while (tablesIter.hasNext())
                {
                    TableImpl tbl = (TableImpl)tablesIter.next();
                    if (writer != null)
                    {
                        try
                        {
                            if (tbl instanceof ClassTable)
                            {
                                writer.write("-- ClassTable " + tbl.toString() +
                                    " for classes " + StringUtils.objectArrayToString(((ClassTable)tbl).getManagedClasses()) + "\n");
                            }
                            else if (tbl instanceof JoinTable)
                            {
                                writer.write("-- JoinTable " + tbl.toString() + " for join relationship\n");
                            }
                        }
                        catch (IOException ioe)
                        {
                            NucleusLogger.DATASTORE_SCHEMA.error("error writing DDL into file", ioe);
                        }
                    }

                    tbl.drop(getCurrentConnection());
                }
            }
            catch (Exception e)
            {
                success = false;
View Full Code Here

Examples of org.datanucleus.store.rdbms.table.TableImpl

            // b). If autocreate, create the table if necessary
            // c). If validate, validate the table
            Iterator i = tablesToValidate.iterator();
            while (i.hasNext())
            {
                TableImpl t = (TableImpl) i.next();

                boolean columnsValidated = false;
                if (checkExistTablesOrViews)
                {
                    if (ddlWriter != null)
                    {
                        try
                        {
                            if (t instanceof ClassTable)
                            {
                                ddlWriter.write("-- Table " + t.toString() +
                                    " for classes " + StringUtils.objectArrayToString(((ClassTable)t).getManagedClasses()) + "\n");
                            }
                            else if (t instanceof JoinTable)
                            {
                                ddlWriter.write("-- Table " + t.toString() + " for join relationship\n");
                            }
                        }
                        catch (IOException ioe)
                        {
                            NucleusLogger.DATASTORE_SCHEMA.error("error writing DDL into file", ioe);
                        }
                    }

                    if (!tablesCreated.contains(t) && t.exists(getCurrentConnection(), autoCreateTables))
                    {
                        // Table has been created so add to our list so we dont process it multiple times
                        // Any subsequent instance of this table in the list will have the columns checked only
                        tablesCreated.add(t);
                        columnsValidated = true;
                    }
                    else
                    {
                        // Table wasn't just created, so do any autocreate of columns necessary
                        if (t.isInitializedModified() || autoCreateColumns)
                        {
                            // Check for existence of the required columns and add where required
                            t.validateColumns(getCurrentConnection(), false, autoCreateColumns, autoCreateErrors);
                            columnsValidated = true;
                        }
                    }
                }

                if (validateTables && !columnsValidated) // Table not just created and validation requested
                {
                    // Check down to the column structure where required
                    t.validate(getCurrentConnection(), validateColumns, false, autoCreateErrors);
                }
                else if (!columnsValidated)
                {
                    // Validation not requested but allow initialisation of the column information
                    String initInfo = getStringProperty("datanucleus.rdbms.initializeColumnInfo");
                    if (initInfo.equalsIgnoreCase("PK"))
                    {
                        // Initialise the PK columns only
                        t.initializeColumnInfoForPrimaryKeyColumns(getCurrentConnection());
                    }
                    else if (initInfo.equalsIgnoreCase("ALL"))
                    {
                        // Initialise all columns
                        t.initializeColumnInfoFromDatastore(getCurrentConnection());
                    }
                }

                // Discard any cached column info used to validate the table
                invalidateColumnInfoForTable(t);
            }

            // Table constraint existence and validation
            // a). Check for existence of the constraint
            // b). If autocreate, create the constraint if necessary
            // c). If validate, validate the constraint
            // Constraint processing is done as a separate step from table processing
            // since the constraints are dependent on tables being available
            i = tablesToValidate.iterator();
            while (i.hasNext())
            {
                TableImpl t = (TableImpl) i.next();
                if (validateConstraints || autoCreateConstraints)
                {
                    if (ddlWriter != null)
                    {
                        try
                        {
                            if (t instanceof ClassTable)
                            {
                                ddlWriter.write("-- Constraints for table " + t.toString() +
                                    " for class(es) " + StringUtils.objectArrayToString(((ClassTable)t).getManagedClasses()) + "\n");
                            }
                            else
                            {
                                ddlWriter.write("-- Constraints for table " + t.toString() + "\n");
                            }
                        }
                        catch (IOException ioe)
                        {
                            NucleusLogger.DATASTORE_SCHEMA.error("error writing DDL into file", ioe);
                        }
                    }
                    // TODO : split this method into checkExistsConstraints and validateConstraints
                    // TODO : if duplicated entries on the list, we need to validate before.
                    if (tablesCreated.contains(t) && !hasDuplicateTablesFromList(tablesToValidate))
                    {
                        if (t.createConstraints(getCurrentConnection(), autoCreateErrors, clr))
                        {
                            tableConstraintsCreated.add(t);
                        }
                    }
                    else if (t.validateConstraints(getCurrentConnection(), autoCreateConstraints, autoCreateErrors, clr))
                    {
                        tableConstraintsCreated.add(t);
                    }
                    if (ddlWriter != null)
                    {
View Full Code Here

Examples of org.eclipse.persistence.internal.jpa.config.tables.TableImpl

        getMetadata().setPrimaryKeyForeignKey(new PrimaryKeyForeignKeyMetadata(foreignKey.getMetadata()));
        return foreignKey;
    }

    public Table setTable() {
        TableImpl table = new TableImpl();
        getMetadata().setTable(table.getMetadata());
        return table;
    }
View Full Code Here

Examples of org.jpox.store.rdbms.table.TableImpl

            // b). If autocreate, create the table if necessary
            // c). If validate, validate the table
            Iterator i = tablesToValidate.iterator();
            while (i.hasNext())
            {
                TableImpl t = (TableImpl) i.next();

                boolean columnsValidated = false;
                if (checkExistTablesOrViews)
                {
                    if (ddlWriter != null)
                    {
                        try
                        {
                            if (t instanceof ClassTable)
                            {
                                ddlWriter.write("-- Table " + t.toString() +
                                    " for classes " + StringUtils.objectArrayToString(((ClassTable)t).getManagedClasses()) + "\n");
                            }
                            else if (t instanceof JoinTable)
                            {
                                ddlWriter.write("-- Table " + t.toString() + " for join relationship\n");
                            }
                        }
                        catch (IOException ioe)
                        {
                            JPOXLogger.DATASTORE_SCHEMA.error("error writing DDL into file", ioe);
                        }
                    }

                    if (!tablesCreated.contains(t) && t.exists(getCurrentConnection(), autoCreateTables))
                    {
                        // Table has been created so add to our list so we dont process it multiple times
                        // Any subsequent instance of this table in the list will have the columns checked only
                        tablesCreated.add(t);
                        columnsValidated = true;
                    }
                    else
                    {
                        // Table wasn't just created, so do any autocreate of columns necessary
                        if (t.isInitializedModified() || autoCreateColumns)
                        {
                            // Check for existence of the required columns and add where required
                            t.validateColumns(getCurrentConnection(), false, autoCreateColumns, autoCreateErrors);
                            columnsValidated = true;
                        }
                    }
                }

                if (validateTables && !columnsValidated) // Table not just created and validation requested
                {
                    // Check down to the column structure where required
                    t.validate(getCurrentConnection(), validateColumns, false, autoCreateErrors);
                }
                else if (!columnsValidated)
                {
                    // Validation not requested but allow initialisation of the column information
                    String initInfo = omfContext.getPersistenceConfiguration().getStringProperty("org.jpox.rdbms.initializeColumnInfo");
                    if (initInfo.equalsIgnoreCase("PK"))
                    {
                        // Initialise the PK columns only
                        t.initializeColumnInfoForPrimaryKeyColumns(getCurrentConnection());
                    }
                    else if (initInfo.equalsIgnoreCase("ALL"))
                    {
                        // Initialise all columns
                        t.initializeColumnInfoFromDatastore(getCurrentConnection());
                    }
                }

                // Discard any cached column info used to validate the table
                columnInfoByTableName.remove(t.getDatastoreIdentifierFullyQualified());
            }

            // Table constraint existence and validation
            // a). Check for existence of the constraint
            // b). If autocreate, create the constraint if necessary
            // c). If validate, validate the constraint
            // Constraint processing is done as a separate step from table processing
            // since the constraints are dependent on tables being available
            i = tablesToValidate.iterator();
            while (i.hasNext())
            {
                TableImpl t = (TableImpl) i.next();
                if (validateConstraints || autoCreateConstraints)
                {
                    if (ddlWriter != null)
                    {
                        try
                        {
                            if (t instanceof ClassTable)
                            {
                                ddlWriter.write("-- Constraints for table " + t.toString() +
                                    " for class(es) " + StringUtils.objectArrayToString(((ClassTable)t).getManagedClasses()) + "\n");
                            }
                            else
                            {
                                ddlWriter.write("-- Constraints for table " + t.toString() + "\n");
                            }
                        }
                        catch (IOException ioe)
                        {
                            JPOXLogger.DATASTORE_SCHEMA.error("error writing DDL into file", ioe);
                        }
                    }
                    // TODO : split this method into checkExistsConstraints and validateConstraints
                    // TODO : if duplicated entries on the list, we need to validate before.
                    if (tablesCreated.contains(t) && !hasDuplicateTablesFromList(tablesToValidate))
                    {
                        if (t.createConstraints(getCurrentConnection(), autoCreateErrors, clr))
                        {
                            tableConstraintsCreated.add(t);
                        }
                    }
                    else if (t.validateConstraints(getCurrentConnection(), autoCreateConstraints, autoCreateErrors, clr))
                    {
                        tableConstraintsCreated.add(t);
                    }
                    if (ddlWriter != null)
                    {
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.