Examples of IdentifierFactory


Examples of org.jpox.store.mapped.IdentifierFactory

    public BooleanExpression containsValueMethod(ScalarExpression expr)
    {
        // mt... = "map table"
        // vt... = "value table"

        IdentifierFactory idFactory = qs.getStoreManager().getIdentifierFactory();
        if (expr instanceof UnboundVariable)
        {
            UnboundVariable var = (UnboundVariable)expr;
            if (var.getVariableType() == null)
            {
                // Set the variable type to be the element type for this collection
                var.setVariableType(qs.getClassLoaderResolver().classForName(mapStore.getValueType()));
            }
            String vtIdentifier = "UNBOUND" + '.' + var.getVariableName();
            String mtIdentifier = idFactory.newIdentifier(idFactory.newIdentifier(te.getAlias(), fieldName), var.getVariableName()).getIdentifier();

            DatastoreIdentifier mtRangeVar = idFactory.newIdentifier(IdentifierFactory.TABLE, mtIdentifier);
            DatastoreIdentifier vtRangeVar = idFactory.newIdentifier(IdentifierFactory.TABLE, vtIdentifier);

            QueryExpression qexpr = getBackingStoreQueryable().getExistsSubquery(qs, mapping, te, mtRangeVar);
            var.bindTo(getBackingStoreQueryable().joinValuesTo(qexpr,
                                           qs,
                                           mapping,
                                           te,
                                           mtRangeVar,
                                           var.getVariableType(),
                                           expr,
                                           vtRangeVar));
            return new ExistsExpression(qs, qexpr, true);           
        }
        else if (expr instanceof Literal)
        {
            String mtIdentifier = idFactory.newIdentifier(te.getAlias(), fieldName).getIdentifier();
            DatastoreIdentifier mtRangeVar = idFactory.newIdentifier(IdentifierFactory.TABLE, mtIdentifier);
            DatastoreIdentifier vtRangeVar;
            int n = 0;

            do
            {
                String vtIdentifier = mtIdentifier + '.' + (++n);
                vtRangeVar = idFactory.newIdentifier(IdentifierFactory.TABLE, vtIdentifier);
            } while (qs.getTableExpression(vtRangeVar) != null);

            ClassLoaderResolver clr = qs.getClassLoaderResolver();
            QueryExpression qexpr = getBackingStoreQueryable().getExistsSubquery(qs, mapping, te, mtRangeVar);
            ScalarExpression joinValuesExpr = getBackingStoreQueryable().joinValuesTo(qexpr,
                                           qs,
                                           mapping,
                                           te,
                                           mtRangeVar,
                                           clr.classForName(expr.getMapping().getType()),
                                           expr,
                                           vtRangeVar);
            qexpr.andCondition(expr.eq(joinValuesExpr));
            return new ExistsExpression(qs, qexpr, true);
        }       
        else
        {
            String mtIdentifier = idFactory.newIdentifier(te.getAlias(), fieldName).getIdentifier();
            DatastoreIdentifier mtRangeVar = idFactory.newIdentifier(IdentifierFactory.TABLE, mtIdentifier);
            DatastoreIdentifier vtRangeVar;

            if (expr.te == null) // literals
            {
                int n = 0;

                do
                {
                    String vtIdentifier = mtIdentifier + '.' + (++n);
                    vtRangeVar = idFactory.newIdentifier(IdentifierFactory.TABLE, vtIdentifier);
                } while (qs.getTableExpression(vtRangeVar) != null);
            }
            else
            {
                vtRangeVar = expr.te.getAlias();
View Full Code Here

Examples of org.jpox.store.mapped.IdentifierFactory

     *          "map.isEmpty()".
     **/
    public BooleanExpression isEmptyMethod()
    {
        // mt... = "map table"
        IdentifierFactory idFactory = qs.getStoreManager().getIdentifierFactory();
        String mtIdentifier = idFactory.newIdentifier(te.getAlias(), fieldName).getIdentifier();
        DatastoreIdentifier mtRangeVar = idFactory.newIdentifier(IdentifierFactory.TABLE, mtIdentifier);

        return new ExistsExpression(qs, getBackingStoreQueryable().getExistsSubquery(qs, mapping, te, mtRangeVar), false);
    }
View Full Code Here

Examples of org.jpox.store.mapped.IdentifierFactory

     **/
    public ScalarExpression getMethod(ScalarExpression expr)
    {
        // mt... = "map table"
        // vt... = "value table"
        IdentifierFactory idFactory = qs.getStoreManager().getIdentifierFactory();
        String mtIdentifier = idFactory.newIdentifier(te.getAlias(), fieldName).getIdentifier();

        DatastoreIdentifier mtRangeVar;
        DatastoreIdentifier ktRangeVar;
        DatastoreIdentifier vtRangeVar;
        int n = 0;
        if (expr instanceof UnboundVariable)
        {
            UnboundVariable var = (UnboundVariable)expr;
            if (var.getVariableType() == null)
            {
                // Set the variable type to be the element type for this collection
                var.setVariableType(qs.getClassLoaderResolver().classForName(mapStore.getKeyType()));
            }
            String ktIdentifier = "UNBOUND" + '.' + var.getVariableName();
            String vtIdentifier = "UNBOUNDVALUE" + '.' + var.getVariableName();

            mtRangeVar = idFactory.newIdentifier(IdentifierFactory.TABLE, mtIdentifier);
            ktRangeVar = idFactory.newIdentifier(IdentifierFactory.TABLE, ktIdentifier);
            vtRangeVar = idFactory.newIdentifier(IdentifierFactory.TABLE, vtIdentifier);
        }
        else
        {
            mtRangeVar = idFactory.newIdentifier(IdentifierFactory.TABLE, mtIdentifier);

            do
            {
                String ktJavaName = mtIdentifier + '.' + (++n);
                ktRangeVar = idFactory.newIdentifier(IdentifierFactory.TABLE, ktJavaName);
            } while (qs.getTableExpression(ktRangeVar) != null);

            n = 0;

            do
            {
                String vtIdentifier = mtIdentifier + '.' + (++n);
                vtRangeVar = idFactory.newIdentifier(IdentifierFactory.TABLE, vtIdentifier);
            } while (qs.getTableExpression(vtRangeVar) != null || vtRangeVar.equals(ktRangeVar));
        }
           
        /* QueryExpression qexpr = */ getBackingStoreQueryable().getExistsSubquery(qs, mapping, te, mtRangeVar);
        ClassLoaderResolver clr=qs.getClassLoaderResolver();
View Full Code Here

Examples of org.jpox.store.mapped.IdentifierFactory

     * Executed when the size() method is found in a query filter.
     * @return  The NumericExpression resulting from the size() method.
     */
    public NumericExpression sizeMethod()
    {
        IdentifierFactory idFactory = qs.getStoreManager().getIdentifierFactory();
        String ctIdentifier = idFactory.newIdentifier(te.getAlias(), fieldName).getIdentifier();
        DatastoreIdentifier ctRangeVar = idFactory.newIdentifier(IdentifierFactory.TABLE, ctIdentifier);

        return new ContainerSizeExpression(qs, getBackingStoreQueryable().getSizeSubquery(qs, mapping, te, ctRangeVar));
    }
View Full Code Here

Examples of org.jpox.store.mapped.IdentifierFactory

     * @param expr The ScalarExpression passed as a parameter to contains().
     * @return The BooleanExpression resulting from the contains() method.
     */
    public BooleanExpression containsMethod(ScalarExpression expr)
    {
        IdentifierFactory idFactory = qs.getStoreManager().getIdentifierFactory();
        ClassLoaderResolver clr = qs.getClassLoaderResolver();
        if (expr instanceof NullLiteral)
        {
            // JPOX doesn't currently support querying for nulls in Collections so just return "1 = 0"
            // TODO Add support for querying for nulls in collections
            return new BooleanLiteral(qs, mapping, false).eq(new BooleanLiteral(qs, mapping, true));
        }
        else if (expr instanceof UnboundVariable)
        {
            UnboundVariable var = (UnboundVariable)expr;
            if (var.getVariableType() == null)
            {
                // Set the variable type to be the element type for this collection
                // implicit variable type. We now set the type to the collection type
                var.setVariableType(clr.classForName(collStore.getElementType()));
            }

            // Get the exists query of the collection table
            String existsTableId = idFactory.newIdentifier(
                idFactory.newIdentifier(te.getAlias(), fieldName), var.getVariableName()).getIdentifier();
            DatastoreIdentifier existsTableAlias = idFactory.newIdentifier(IdentifierFactory.TABLE, existsTableId);
            QueryExpression qexpr = getBackingStoreQueryable().getExistsSubquery(qs, mapping, te, existsTableAlias);

            // Join from the collection table to the element table
            DatastoreIdentifier elementTableAlias = null;
            if (expr.te == null)
            {
                String elementTableId = "UNBOUND" + '.' + var.getVariableName();
                elementTableAlias = idFactory.newIdentifier(IdentifierFactory.TABLE, elementTableId);
            }
            else
            {
                elementTableAlias = expr.te.getAlias();
            }
            ScalarExpression joinExpr = getBackingStoreQueryable().joinElementsTo(qexpr, qs, mapping, te,
                existsTableAlias, var.getVariableType(), expr, elementTableAlias, true);

            var.bindTo(joinExpr);

            //START see JDOQLContainerTest.testContainsResultVariable
            LogicSetExpression elementTblExpr = qs.getTableExpression(elementTableAlias);
            if (qs.hasCrossJoin(elementTblExpr))
            {
                // Perhaps some description about what this is supposed to be doing and WHY ????
                qexpr.andCondition(joinExpr.eq(expr.mapping.newScalarExpression(qs, elementTblExpr)));
            }
            //END see JDOQLContainerTest.

            return new ExistsExpression(qs, qexpr, true);
        }
        else
        {
            // "contains(Literal)", "contains(Expression)"
            String existsTableId = idFactory.newIdentifier(te.getAlias(), fieldName).getIdentifier();
            DatastoreIdentifier existsTableAlias = idFactory.newIdentifier(IdentifierFactory.TABLE, existsTableId);

            DatastoreIdentifier elementTableAlias;
            if (expr.te == null) // literals
            {
                int n = 0;
                do
                {
                    String elementTableId = existsTableId + '.' + (++n);
                    elementTableAlias = idFactory.newIdentifier(IdentifierFactory.TABLE, elementTableId);
                } while (qs.getTableExpression(elementTableAlias) != null);
            }
            else // expressions
            {
                elementTableAlias = expr.te.getAlias();
View Full Code Here

Examples of org.jpox.store.mapped.IdentifierFactory

     * Return the BooleanExpression for a query filter in the form "collection.isEmpty()".
     * @return The BooleanExpression for a query filter in the form "collection.isEmpty()".
     */
    public BooleanExpression isEmptyMethod()
    {
        IdentifierFactory idFactory = qs.getStoreManager().getIdentifierFactory();
        String existsTableId = idFactory.newIdentifier(te.getAlias(), fieldName).getIdentifier();
        DatastoreIdentifier existsTableAlias = idFactory.newIdentifier(IdentifierFactory.TABLE, existsTableId);
        QueryExpression qexpr = getBackingStoreQueryable().getExistsSubquery(qs, mapping, te, existsTableAlias);

        return new ExistsExpression(qs, qexpr, false);
    }
View Full Code Here

Examples of org.jpox.store.mapped.IdentifierFactory

     */
    public NumericExpression sizeMethod()
    {
        if (arrayStore != null)
        {
            IdentifierFactory idFactory = qs.getStoreManager().getIdentifierFactory();
            String ctIdentifier = idFactory.newIdentifier(te.getAlias(), fieldName).getIdentifier();
            DatastoreIdentifier ctRangeVar = idFactory.newIdentifier(IdentifierFactory.TABLE, ctIdentifier);

            return new ContainerSizeExpression(qs, getBackingStoreQueryable().getSizeSubquery(qs, mapping, te, ctRangeVar));
        }
        else
        {
View Full Code Here

Examples of org.jpox.store.mapped.IdentifierFactory

    public BooleanExpression containsMethod(ScalarExpression expr)
    {
        // ct... = "collection table"
        // et... = "element table"

        IdentifierFactory idFactory = qs.getStoreManager().getIdentifierFactory();
        if (expr instanceof NullLiteral)
        {
            // JPOX doesn't currently support storing nulls in Collections so just return "1 = 0"
            // TODO Add support for storing nulls in collections and querying for this situation
            return new BooleanLiteral(qs, mapping, false).eq(new BooleanLiteral(qs, mapping, true));
        }
        else if( exprs != null )
        {
            BooleanExpression bExpr = null;
            for( int i=0; i<exprs.length; i++)
            {
                if( bExpr == null )
                {
                    bExpr = exprs[i].eq(expr);
                }
                else
                {
                    bExpr = bExpr.ior(exprs[i].eq(expr));
                }
            }
            bExpr.encloseWithInParentheses();
            return bExpr;
        }
        else if (expr instanceof UnboundVariable)
        {
            UnboundVariable var = (UnboundVariable)expr;
            if (var.getVariableType() == null)
            {
                //Set the variable type to be the element type for this collection
                //implicit variable type. We now set the type to the collection type
                var.setVariableType(qs.getClassLoaderResolver().classForName(arrayStore.getElementType()));
            }
            //ctJavaName += + '.' + var.getVariableName();
            //String etJavaName = qs.getDefaultTableExpression().getRangeVariable().getJavaName() + '.' + var.getVariableName();

            String etIdentifier = "UNBOUND" + '.' + var.getVariableName();
            String ctIdentifier = idFactory.newIdentifier(idFactory.newIdentifier(te.getAlias(), fieldName), var.getVariableName()).getIdentifier();

            DatastoreIdentifier ctRangeVar = idFactory.newIdentifier(IdentifierFactory.TABLE, ctIdentifier);
            DatastoreIdentifier etRangeVar = idFactory.newIdentifier(IdentifierFactory.TABLE, etIdentifier);
            QueryExpression qexpr = getBackingStoreQueryable().getExistsSubquery(qs, mapping, te, ctRangeVar);
            var.bindTo(getBackingStoreQueryable().joinElementsTo(qexpr,
                qs,
                mapping,
                te,
                ctRangeVar,
                var.getVariableType(),
                expr,
                expr.te == null ? etRangeVar : expr.te.getAlias()));

            return new ExistsExpression(qs, qexpr, true);

        }
        else if (expr instanceof Literal)
        {
            String ctIdentifier = idFactory.newIdentifier(te.getAlias(), fieldName).getIdentifier();
            DatastoreIdentifier ctRangeVar = qs.getStoreManager().getIdentifierFactory().newIdentifier(IdentifierFactory.TABLE, ctIdentifier);
            DatastoreIdentifier etRangeVar;            
            if (expr.te == null) // literals
            {
                int n = 0;

                do
                {
                    String etIdentifier = ctIdentifier + '.' + (++n);
                    etRangeVar = qs.getStoreManager().getIdentifierFactory().newIdentifier(IdentifierFactory.TABLE, etIdentifier);
                } while (qs.getTableExpression(etRangeVar) != null);
            }
            else
            {
                etRangeVar = expr.te.getAlias();
            }

            ClassLoaderResolver clr=qs.getClassLoaderResolver();
            QueryExpression qexpr = getBackingStoreQueryable().getExistsSubquery(qs, mapping, te, ctRangeVar);
            ScalarExpression expr1 = getBackingStoreQueryable().joinElementsTo(qexpr,
                qs,
                   mapping,
                   te,
                ctRangeVar,
                clr.classForName(expr.getMapping().getType()),
                expr,
                expr.te == null ? etRangeVar : expr.te.getAlias());
            qexpr.andCondition(expr.eq(expr1));
            return new ExistsExpression(qs, qexpr, true);
        }       
        else
        {
            String ctIdentifier = idFactory.newIdentifier(te.getAlias(), fieldName).getIdentifier();
            DatastoreIdentifier ctRangeVar = qs.getStoreManager().getIdentifierFactory().newIdentifier(IdentifierFactory.TABLE, ctIdentifier);
            DatastoreIdentifier etRangeVar;            
            if (expr.te == null) // literals
            {
                int n = 0;
View Full Code Here

Examples of org.jpox.store.mapped.IdentifierFactory

             *
             * So even though the caller may have been looking for column FOO
             * relative to rangevar THIS he may actually get back something like
             * THIS_1.FOO.
             */
            IdentifierFactory idFactory = qs.getStoreManager().getIdentifierFactory();
            alias = idFactory.newIdentifier(mainAlias, String.valueOf(aliasesByTable.size()));
            aliasesByTable.put(table, alias);

            /* mt... = "main table" */
            /* st... = "secondary table" */
            DatastoreClass mt = (DatastoreClass)mainTable;
View Full Code Here

Examples of org.jpox.store.mapped.IdentifierFactory

        ObjectExpression objectCast;
        LogicSetExpression te = qs.getTableExpression(this.qs.getStoreManager().getDatastoreClass(castType.getName(), qs.getClassLoaderResolver()).getIdentifier());
        DatastoreClass dc = this.qs.getStoreManager().getDatastoreClass(castType.getName(), qs.getClassLoaderResolver());
        if (te == null)
        {
            IdentifierFactory idFactory = qs.getStoreManager().getIdentifierFactory();
            String jtIdentifier = this.te.getAlias().getIdentifier();
            if (castType != null && !castType.getName().equals(mapping.getType()))
            {
                String castTypeName = castType.getName();
                jtIdentifier = idFactory.newIdentifier(this.te.getAlias(), castTypeName.substring(castTypeName.lastIndexOf('.') + 1)).getIdentifier();
            }

            DatastoreIdentifier jtRangeVar = idFactory.newIdentifier(IdentifierFactory.TABLE, jtIdentifier);
            LogicSetExpression jtTblExpr = qs.getTableExpression(jtRangeVar);

            if (jtTblExpr == null)
            {
                jtTblExpr = qs.newTableExpression(dc, jtRangeVar);
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.