Beispiel #1
0
 public virtual string GetEntityName()
 {
     if (entity != null && entity is Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledEntityName)
     {
         Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledEntityName s = (Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledEntityName)entity;
         return(s.GetName());
     }
     return(null);
 }
Beispiel #2
0
        public override string GetSQL(object oo, Net.Vpc.Upa.Persistence.EntityExecutionContext context, Net.Vpc.Upa.Impl.Persistence.SQLManager sqlManager, Net.Vpc.Upa.Impl.Uql.ExpressionDeclarationList declarations) /* throws Net.Vpc.Upa.Exceptions.UPAException */
        {
            Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledEntityName o = (Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledEntityName)oo;
            Net.Vpc.Upa.Persistence.PersistenceStore persistenceStore    = context.GetPersistenceStore();
            string entityName = o.GetName();

            Net.Vpc.Upa.Entity e = context.GetPersistenceUnit().GetEntity(entityName);
            if (o.IsUseView() && e.NeedsView() && persistenceStore.IsViewSupported())
            {
                return(persistenceStore.GetValidIdentifier(persistenceStore.GetPersistenceName(e, Net.Vpc.Upa.Persistence.PersistenceNameType.IMPLICIT_VIEW)));
            }
            else
            {
                return(persistenceStore.GetValidIdentifier(persistenceStore.GetPersistenceName(e)));
            }
        }
Beispiel #3
0
 public virtual Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledInsert AddQuery(Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledInsert other)
 {
     if (other == null)
     {
         return(this);
     }
     if (other.entity != null)
     {
         entity = (Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledEntityName)other.entity.Copy();
         ExportDeclaration(null, Net.Vpc.Upa.Impl.Uql.DecObjectType.ENTITY, entity.GetName(), null);
         PrepareChildren(entity);
     }
     for (int i = 0; i < (other.fields).Count; i++)
     {
         Set(other.GetField(i).GetName(), other.GetFieldValue(i).Copy());
     }
     return(this);
 }
Beispiel #4
0
 protected internal virtual void AppendFrom(Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledSelect o, System.Text.StringBuilder sb, Net.Vpc.Upa.Persistence.EntityExecutionContext context, Net.Vpc.Upa.Impl.Persistence.SQLManager sqlManager, Net.Vpc.Upa.Impl.Uql.ExpressionDeclarationList declarations)
 {
     Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledNameOrSelect entity = o.GetEntity();
     if (entity == null)
     {
         string fns = GetFromNullString();
         if (fns != null)
         {
             sb.Append(" ");
             sb.Append(fns);
         }
     }
     else
     {
         sb.Append(" From ");
         if (entity is Net.Vpc.Upa.Expressions.Select)
         {
             sb.Append(sqlManager.GetSQL(entity, context, declarations));
         }
         else
         {
             Net.Vpc.Upa.Persistence.PersistenceStore persistenceStore             = context.GetPersistenceStore();
             Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledEntityName entityName = (Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledEntityName)entity;
             Net.Vpc.Upa.Entity e = context.GetPersistenceUnit().GetEntity(entityName.GetName());
             if (entityName.IsUseView() && e.NeedsView() && persistenceStore.IsViewSupported())
             {
                 Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledEntityName v = new Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledEntityName(e.GetName(), true);
                 sb.Append(sqlManager.GetSQL(v, context, declarations));
             }
             else
             {
                 sb.Append(sqlManager.GetSQL(entityName, context, declarations));
             }
         }
     }
     if (o.GetEntityAlias() != null)
     {
         Net.Vpc.Upa.Persistence.PersistenceStore store = context.GetPersistenceStore();
         sb.Append(" ").Append(sqlManager.GetSQL(new Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledVar(o.GetEntityAlias()), context, declarations));
     }
 }
        public virtual Net.Vpc.Upa.Expressions.CompiledExpression Update(Net.Vpc.Upa.Expressions.CompiledExpression e)
        {
            Net.Vpc.Upa.Impl.Uql.Compiledexpression.IsHierarchyDescendentCompiled o = (Net.Vpc.Upa.Impl.Uql.Compiledexpression.IsHierarchyDescendentCompiled)e;
            Net.Vpc.Upa.Impl.Uql.Compiledexpression.DefaultCompiledExpression     c = o.GetChildExpression();
            Net.Vpc.Upa.Impl.Uql.Compiledexpression.DefaultCompiledExpression     p = o.GetAncestorExpression();
            Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledEntityName            n = o.GetEntityName();
            Net.Vpc.Upa.Entity treeEntity = null;
            Net.Vpc.Upa.Field  treeField  = null;
            if (c is Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledVar)
            {
                object childReferrer = ((Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledVar)c).GetFinest().GetReferrer();
                if (childReferrer != null)
                {
                    if (childReferrer is Net.Vpc.Upa.Entity)
                    {
                        if (treeEntity == null)
                        {
                            treeEntity = (Net.Vpc.Upa.Entity)childReferrer;
                        }
                        else
                        {
                            if (!treeEntity.GetName().Equals(((Net.Vpc.Upa.Entity)childReferrer).GetName()))
                            {
                                throw new System.ArgumentException("Ambiguous or Invalid Type " + treeEntity.GetName() + " in TreeEntity near " + e);
                            }
                        }
                    }
                }
            }
            else if (c is Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledParam)
            {
                object co = ((Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledParam)c).GetValue();
                if (co != null && persistenceUnit.ContainsEntity(co.GetType()))
                {
                    Net.Vpc.Upa.Entity rr = persistenceUnit.GetEntity(co.GetType());
                    if (treeEntity == null)
                    {
                        treeEntity = rr;
                    }
                    ((Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledParam)c).SetValue(rr.GetBuilder().ObjectToId(co));
                }
            }
            //            Object co = ((CompiledParam) c).getEffectiveDataType();
            if (p is Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledVar)
            {
                object parentReferrer = ((Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledVar)p).GetFinest().GetReferrer();
                if (parentReferrer != null)
                {
                    if (parentReferrer is Net.Vpc.Upa.Entity)
                    {
                        if (treeEntity == null)
                        {
                            treeEntity = (Net.Vpc.Upa.Entity)parentReferrer;
                        }
                        else
                        {
                            if (!treeEntity.GetName().Equals(((Net.Vpc.Upa.Entity)parentReferrer).GetName()))
                            {
                                throw new System.ArgumentException("Ambiguous or Invalid Type " + treeEntity.GetName() + " in TreeEntity near " + e);
                            }
                        }
                    }
                }
            }
            else if (p is Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledParam)
            {
                object co = ((Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledParam)p).GetValue();
                if (co != null && persistenceUnit.ContainsEntity(co.GetType()))
                {
                    Net.Vpc.Upa.Entity rr = persistenceUnit.FindEntity(co.GetType());
                    if (treeEntity == null)
                    {
                        treeEntity = rr;
                    }
                    ((Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledParam)p).SetValue(rr.GetBuilder().ObjectToId(co));
                    if ((rr.GetPrimaryFields()).Count > 1)
                    {
                        throw new System.ArgumentException("Not supported");
                    }
                    ((Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledParam)p).SetTypeTransform(Net.Vpc.Upa.Impl.Util.UPAUtils.GetTypeTransformOrIdentity(rr.GetPrimaryFields()[0]));
                }
            }
            //            Object co = ((CompiledParam) c).getEffectiveDataType();
            if (treeEntity == null)
            {
                treeEntity = persistenceUnit.GetEntity(n.GetName());
            }
            Net.Vpc.Upa.Relationship t = Net.Vpc.Upa.Impl.Extension.HierarchicalRelationshipSupport.GetTreeRelationName(treeEntity);
            if (t == null)
            {
                throw new System.ArgumentException("Hierarchy Relationship not found");
            }
            Net.Vpc.Upa.Extensions.HierarchyExtension s = t.GetHierarchyExtension();
            if (s == null)
            {
                throw new System.ArgumentException("Not a valid TreeEntity");
            }
            Net.Vpc.Upa.Field pathField = treeEntity.GetField(s.GetHierarchyPathField());
            string            pathSep   = s.GetHierarchyPathSeparator();

            return(CreateConditionForDeepSearch(c, (Net.Vpc.Upa.Impl.Uql.Compiledexpression.DefaultCompiledExpression)p, true, pathField, pathSep));
        }
Beispiel #6
0
 public string GetEntityAlias()
 {
     return(entityAlias == null?entityName.GetName() : entityAlias);
 }