Ejemplo n.º 1
0
 public virtual void AfterClose(object source)
 {
     System.Collections.Generic.IList <Net.Vpc.Upa.CloseListener> all = closeListeners;
     if (all != null)
     {
         foreach (Net.Vpc.Upa.CloseListener closeListener in all.ToArray())
         {
             closeListener.AfterClose(source);
         }
     }
 }
Ejemplo n.º 2
0
 public virtual Net.Vpc.Upa.Config.Decoration[] GetFieldDecorations(string type, string field)
 {
     Net.Vpc.Upa.Impl.Config.Decorations.DefaultDecorationRepositoryTypeInfo typeInf = Net.Vpc.Upa.Impl.FwkConvertUtils.GetMapValue <string, Net.Vpc.Upa.Impl.Config.Decorations.DefaultDecorationRepositoryTypeInfo>(decorationsByType, type);
     if (typeInf != null && typeInf.fields != null)
     {
         System.Collections.Generic.IList <Net.Vpc.Upa.Config.Decoration> _deco = Net.Vpc.Upa.Impl.FwkConvertUtils.GetMapValue <string, System.Collections.Generic.IList <Net.Vpc.Upa.Config.Decoration> >(typeInf.fields, field);
         if (_deco != null)
         {
             return(_deco.ToArray());
         }
     }
     return(new Net.Vpc.Upa.Config.Decoration[0]);
 }
 private bool ProcessRelation(bool throwErrors)
 {
     if (!Build(throwErrors))
     {
         return(false);
     }
     Net.Vpc.Upa.PersistenceUnit pu = sourceEntity.GetPersistenceUnit();
     if (relation == null)
     {
         Net.Vpc.Upa.DefaultRelationshipDescriptor rd = new Net.Vpc.Upa.DefaultRelationshipDescriptor();
         rd.SetName(relationDescriptor.GetName());
         rd.SetBaseField(relationDescriptor.GetBaseField());
         rd.SetRelationshipType(relationDescriptor.GetRelationshipType());
         rd.SetSourceEntity(sourceEntity.GetName());
         rd.SetTargetEntity(targetEntity.GetName());
         rd.SetSourceFields(sourceFieldNames.ToArray());
         rd.SetFilter(relationDescriptor.GetFilter());
         rd.SetHierarchy(relationDescriptor.IsHierarchy());
         rd.SetHierarchyPathField(relationDescriptor.GetHierarchyPathField());
         rd.SetHierarchyPathSeparator(relationDescriptor.GetHierarchyPathSeparator());
         rd.SetNullable(relationDescriptor.IsNullable());
         relation = ((Net.Vpc.Upa.Impl.DefaultPersistenceUnit)pu).AddRelationshipImmediate(rd);
     }
     else
     {
         if (!Net.Vpc.Upa.Impl.Util.StringUtils.IsNullOrEmpty(relationDescriptor.GetName()))
         {
             relation.SetName(relationDescriptor.GetName());
         }
         relation.SetRelationshipType(relationDescriptor.GetRelationshipType() == default(Net.Vpc.Upa.RelationshipType) ? Net.Vpc.Upa.RelationshipType.DEFAULT : relationDescriptor.GetRelationshipType());
         relation.GetSourceRole().SetEntityField(manyToOneField);
         relation.GetSourceRole().SetRelationshipUpdateType(sourceUpdateType);
         System.Collections.Generic.IList <Net.Vpc.Upa.Field> slaveFields = new System.Collections.Generic.List <Net.Vpc.Upa.Field>();
         foreach (string n in sourceFieldNames)
         {
             Net.Vpc.Upa.Field f = sourceEntity.GetField(n);
             slaveFields.Add(f);
         }
         relation.GetSourceRole().SetFields(slaveFields.ToArray());
         relation.GetTargetRole().SetEntityField(null);
         relation.GetTargetRole().SetRelationshipUpdateType(Net.Vpc.Upa.Impl.Util.PlatformUtils.GetUndefinedValue <Net.Vpc.Upa.RelationshipUpdateType>(typeof(Net.Vpc.Upa.RelationshipUpdateType)));
         relation.SetFilter(filter);
         relation.SetNullable(nullable);
     }
     return(true);
 }
Ejemplo n.º 4
0
 public virtual T[] ToArrayConstrainted(bool system, string n, T[] arr)
 {
     if (system)
     {
         if (n == null)
         {
             return(allSystem.ToArray());
         }
         else
         {
             System.Collections.Generic.IList <T> sum = new System.Collections.Generic.List <T>();
             System.Collections.Generic.IList <T> v   = Net.Vpc.Upa.Impl.FwkConvertUtils.GetMapValue <string, System.Collections.Generic.IList <T> >(someSystem, n);
             if (v != null)
             {
                 Net.Vpc.Upa.Impl.FwkConvertUtils.ListAddRange(sum, v);
             }
             return(sum.ToArray());
         }
     }
     else
     {
         if (n == null)
         {
             return(allCommun.ToArray());
         }
         else
         {
             System.Collections.Generic.IList <T> sum = new System.Collections.Generic.List <T>();
             System.Collections.Generic.IList <T> v   = Net.Vpc.Upa.Impl.FwkConvertUtils.GetMapValue <string, System.Collections.Generic.IList <T> >(someCommun, n);
             if (v != null)
             {
                 Net.Vpc.Upa.Impl.FwkConvertUtils.ListAddRange(sum, v);
             }
             return(sum.ToArray());
         }
     }
 }
Ejemplo n.º 5
0
 public virtual Net.Vpc.Upa.Expressions.Expression[] GetRight()
 {
     return(right.ToArray());
 }
Ejemplo n.º 6
0
 public virtual Net.Vpc.Upa.Config.DecorationValue[] GetAlternatives()
 {
     return(alternatives.ToArray());
 }
 public virtual Net.Vpc.Upa.Callbacks.PersistenceGroupDefinitionListener[] GetPersistenceGroupDefinitionListeners()
 {
     return(persistenceGroupDefinitionListeners.ToArray());
 }
Ejemplo n.º 8
0
        public static Net.Vpc.Upa.Expressions.FunctionExpression CreateFunction(string name, System.Collections.Generic.IList <Net.Vpc.Upa.Expressions.Expression> args)
        {
            string uniformName = name.ToLower();

            if (uniformName.Equals("average"))
            {
                CheckArgCount(name, args, 1);
                return(new Net.Vpc.Upa.Expressions.Avg(args[0]));
            }
            if (uniformName.Equals("min"))
            {
                CheckArgCount(name, args, 1);
                return(new Net.Vpc.Upa.Expressions.Min(args[0]));
            }
            if (uniformName.Equals("max"))
            {
                CheckArgCount(name, args, 1);
                return(new Net.Vpc.Upa.Expressions.Max(args[0]));
            }
            if (uniformName.Equals("sum"))
            {
                CheckArgCount(name, args, 1);
                return(new Net.Vpc.Upa.Expressions.Sum(args[0]));
            }
            if (uniformName.Equals("count"))
            {
                CheckArgCount(name, args, 1);
                return(new Net.Vpc.Upa.Expressions.Count(args[0]));
            }
            if (uniformName.Equals("d2v"))
            {
                CheckArgCount(name, args, 1);
                return(new Net.Vpc.Upa.Expressions.D2V(args[0]));
            }
            if (uniformName.Equals("i2v"))
            {
                CheckArgCount(name, args, 1);
                return(new Net.Vpc.Upa.Expressions.I2V(args[0]));
            }
            if (uniformName.Equals("concat"))
            {
                return(new Net.Vpc.Upa.Expressions.Concat(args.ToArray()));
            }
            if (uniformName.Equals("cast"))
            {
                CheckArgCount(name, args, 2);
                Net.Vpc.Upa.Expressions.Expression e    = (Net.Vpc.Upa.Expressions.Expression)args[0];
                Net.Vpc.Upa.Expressions.Expression type = (Net.Vpc.Upa.Expressions.Expression)args[1];
                Net.Vpc.Upa.Types.DataType         d    = null;
                if (type is Net.Vpc.Upa.Expressions.Var)
                {
                    string s = ((Net.Vpc.Upa.Expressions.Var)type).GetName();
                    if ("string".Equals(s))
                    {
                        d = Net.Vpc.Upa.Types.TypesFactory.STRING;
                    }
                    else if ("int".Equals(s))
                    {
                        d = Net.Vpc.Upa.Types.TypesFactory.INT;
                    }
                    else if ("double".Equals(s))
                    {
                        d = Net.Vpc.Upa.Types.TypesFactory.DOUBLE;
                    }
                    else if ("float".Equals(s))
                    {
                        d = Net.Vpc.Upa.Types.TypesFactory.FLOAT;
                    }
                    else if ("long".Equals(s))
                    {
                        d = Net.Vpc.Upa.Types.TypesFactory.LONG;
                    }
                    else if ("date".Equals(s))
                    {
                        d = Net.Vpc.Upa.Types.TypesFactory.DATE;
                    }
                    else if ("datetime".Equals(s))
                    {
                        d = Net.Vpc.Upa.Types.TypesFactory.DATETIME;
                    }
                    else if ("boolean".Equals(s))
                    {
                        d = Net.Vpc.Upa.Types.TypesFactory.BOOLEAN;
                    }
                    else
                    {
                        d = new Net.Vpc.Upa.Types.ManyToOneType(name, null, name, true, true);
                    }
                }
                else
                {
                    throw new System.ArgumentException("Unupported cast type");
                }
                return(new Net.Vpc.Upa.Expressions.Cast(e, d));
            }
            if (uniformName.Equals("coalesce"))
            {
                return(new Net.Vpc.Upa.Expressions.Coalesce(args));
            }
            if (uniformName.Equals("decode"))
            {
                return(new Net.Vpc.Upa.Expressions.Decode(args));
            }
            if (uniformName.Equals("sign"))
            {
                CheckArgCount(name, args, 1);
                return(new Net.Vpc.Upa.Expressions.Sign(args[0]));
            }
            if (uniformName.Equals("now") || uniformName.Equals("currenttimestamp"))
            {
                CheckArgCount(name, args, 0);
                return(new Net.Vpc.Upa.Expressions.CurrentTimestamp());
            }
            if (uniformName.Equals("currenttime"))
            {
                CheckArgCount(name, args, 0);
                return(new Net.Vpc.Upa.Expressions.CurrentTime());
            }
            if (uniformName.Equals("today") || uniformName.Equals("currentdate"))
            {
                CheckArgCount(name, args, 0);
                return(new Net.Vpc.Upa.Expressions.CurrentDate());
            }
            if (uniformName.Equals("currentuser"))
            {
                CheckArgCount(name, args, 0);
                return(new Net.Vpc.Upa.Expressions.CurrentUser());
            }
            if (uniformName.Equals("dateadd"))
            {
                CheckArgCount(name, args, 3);
                Net.Vpc.Upa.Expressions.Expression type  = (Net.Vpc.Upa.Expressions.Expression)args[0];
                Net.Vpc.Upa.Expressions.Expression count = (Net.Vpc.Upa.Expressions.Expression)args[1];
                Net.Vpc.Upa.Expressions.Expression date  = (Net.Vpc.Upa.Expressions.Expression)args[2];
                return(new Net.Vpc.Upa.Expressions.DateAdd((Net.Vpc.Upa.Expressions.DatePartType)(System.Enum.Parse(typeof(Net.Vpc.Upa.Expressions.DatePartType), ((Net.Vpc.Upa.Expressions.Var)type).GetName().ToUpper())), count, date));
            }
            if (uniformName.Equals("datediff"))
            {
                CheckArgCount(name, args, 3);
                Net.Vpc.Upa.Expressions.Expression type  = (Net.Vpc.Upa.Expressions.Expression)args[0];
                Net.Vpc.Upa.Expressions.Expression start = (Net.Vpc.Upa.Expressions.Expression)args[1];
                Net.Vpc.Upa.Expressions.Expression end   = (Net.Vpc.Upa.Expressions.Expression)args[2];
                return(new Net.Vpc.Upa.Expressions.DateDiff((Net.Vpc.Upa.Expressions.DatePartType)(System.Enum.Parse(typeof(Net.Vpc.Upa.Expressions.DatePartType), ((Net.Vpc.Upa.Expressions.Var)type).GetName().ToUpper())), start, end));
            }
            if (uniformName.Equals("datetrunc"))
            {
                CheckArgCount(name, args, 2);
                Net.Vpc.Upa.Expressions.Expression type = (Net.Vpc.Upa.Expressions.Expression)args[0];
                Net.Vpc.Upa.Expressions.Expression e    = (Net.Vpc.Upa.Expressions.Expression)args[1];
                return(new Net.Vpc.Upa.Expressions.DateTrunc((Net.Vpc.Upa.Expressions.DatePartType)(System.Enum.Parse(typeof(Net.Vpc.Upa.Expressions.DatePartType), ((Net.Vpc.Upa.Expressions.Var)type).GetName().ToUpper())), e));
            }
            if (uniformName.Equals("datepart"))
            {
                CheckArgCount(name, args, 2);
                Net.Vpc.Upa.Expressions.Expression type = (Net.Vpc.Upa.Expressions.Expression)args[0];
                Net.Vpc.Upa.Expressions.Expression e    = (Net.Vpc.Upa.Expressions.Expression)args[1];
                return(new Net.Vpc.Upa.Expressions.DatePart((Net.Vpc.Upa.Expressions.DatePartType)(System.Enum.Parse(typeof(Net.Vpc.Upa.Expressions.DatePartType), ((Net.Vpc.Upa.Expressions.Var)type).GetName().ToUpper())), e));
            }
            if (uniformName.Equals("monthstart"))
            {
                switch ((args).Count)
                {
                case 0:
                {
                    return(new Net.Vpc.Upa.Expressions.MonthStart());
                }

                case 1:
                {
                    return(new Net.Vpc.Upa.Expressions.MonthStart(args[0]));
                }

                case 2:
                {
                    return(new Net.Vpc.Upa.Expressions.MonthStart(args[0], args[2]));
                }
                }
                CheckArgCount(name, args, 2);
            }
            if (uniformName.Equals("monthend"))
            {
                switch ((args).Count)
                {
                case 0:
                {
                    return(new Net.Vpc.Upa.Expressions.MonthEnd());
                }

                case 1:
                {
                    return(new Net.Vpc.Upa.Expressions.MonthEnd(args[0]));
                }

                case 2:
                {
                    return(new Net.Vpc.Upa.Expressions.MonthEnd(args[0], args[2]));
                }
                }
                CheckArgCount(name, args, 2);
            }
            if (uniformName.Equals("exists"))
            {
                CheckArgCount(name, args, 1);
                return(new Net.Vpc.Upa.Expressions.Exists((Net.Vpc.Upa.Expressions.QueryStatement)args[0]));
            }
            if (uniformName.Equals("ishierarchydescendant"))
            {
                if ((args).Count == 3)
                {
                    return(new Net.Vpc.Upa.Expressions.IsHierarchyDescendent(args[0], args[1], args[2]));
                }
                else if ((args).Count == 2)
                {
                    return(new Net.Vpc.Upa.Expressions.IsHierarchyDescendent(args[0], args[1], null));
                }
                else
                {
                    throw new System.Exception("function " + name + " expects 2 or 3 argument(s) but found " + (args).Count);
                }
            }
            return(new Net.Vpc.Upa.Impl.Uql.QLFunctionExpression(name, args.ToArray()));
        }
Ejemplo n.º 9
0
 public virtual Net.Vpc.Upa.Callback[] GetCallbacks(Net.Vpc.Upa.CallbackType nameFilter, Net.Vpc.Upa.ObjectType objectType, string name, bool system, bool preparedOnly, Net.Vpc.Upa.EventPhase phase)
 {
     System.Collections.Generic.IList <Net.Vpc.Upa.Callback> callbackInvokers = listeners.GetCallbacks(nameFilter, objectType, name, system, preparedOnly, phase);
     return(callbackInvokers.ToArray());
 }
Ejemplo n.º 10
0
 public virtual Net.Vpc.Upa.Persistence.ResultMetaData CreateResultMetaData(Net.Vpc.Upa.Expressions.Expression baseExpression, Net.Vpc.Upa.Filters.FieldFilter fieldFilter, System.Collections.Generic.IList <Net.Vpc.Upa.Expressions.QueryStatement> context)
 {
     baseExpression = Net.Vpc.Upa.Impl.Uql.Util.UQLUtils.ParseUserExpressions(baseExpression, pu);
     Net.Vpc.Upa.Impl.Persistence.DefaultResultMetaData m = new Net.Vpc.Upa.Impl.Persistence.DefaultResultMetaData();
     if (baseExpression is Net.Vpc.Upa.Expressions.NonQueryStatement)
     {
         m.SetStatement((Net.Vpc.Upa.Expressions.EntityStatement)baseExpression);
         m.AddField(new Net.Vpc.Upa.Impl.Persistence.DefaultResultField(null, "result", Net.Vpc.Upa.Types.TypesFactory.INT, null, null));
         return(m);
     }
     else
     {
         Net.Vpc.Upa.Expressions.QueryStatement q = (Net.Vpc.Upa.Expressions.QueryStatement)baseExpression;
         if (q is Net.Vpc.Upa.Expressions.Select)
         {
             Net.Vpc.Upa.Expressions.Select qs = (Net.Vpc.Upa.Expressions.Select)q;
             if ((qs.GetFields()).Count == 0)
             {
                 if (!Net.Vpc.Upa.Impl.Util.StringUtils.IsNullOrEmpty(qs.GetEntityAlias()))
                 {
                     qs.Field(new Net.Vpc.Upa.Expressions.Var(qs.GetEntityAlias()));
                 }
                 else if (qs.GetEntityName() != null)
                 {
                     qs.Field(new Net.Vpc.Upa.Expressions.Var(qs.GetEntityName()));
                 }
                 else
                 {
                     throw new Net.Vpc.Upa.Exceptions.UPAException("MissingAlias");
                 }
                 foreach (Net.Vpc.Upa.Expressions.JoinCriteria joinCriteria in qs.GetJoins())
                 {
                     if (!Net.Vpc.Upa.Impl.Util.StringUtils.IsNullOrEmpty(joinCriteria.GetEntityAlias()))
                     {
                         qs.Field(new Net.Vpc.Upa.Expressions.Var(joinCriteria.GetEntityAlias()));
                     }
                     else if (joinCriteria.GetEntityName() != null)
                     {
                         qs.Field(new Net.Vpc.Upa.Expressions.Var(joinCriteria.GetEntityName()));
                     }
                     else
                     {
                         throw new Net.Vpc.Upa.Exceptions.UPAException("MissingAlias");
                     }
                 }
             }
             System.Collections.Generic.IList <Net.Vpc.Upa.Expressions.QueryField>     oldFields  = new System.Collections.Generic.List <Net.Vpc.Upa.Expressions.QueryField>(q.GetFields());
             System.Collections.Generic.IList <Net.Vpc.Upa.Expressions.QueryField>     newFields  = new System.Collections.Generic.List <Net.Vpc.Upa.Expressions.QueryField>();
             System.Collections.Generic.IList <Net.Vpc.Upa.Persistence.ResultField>    newResults = new System.Collections.Generic.List <Net.Vpc.Upa.Persistence.ResultField>();
             System.Collections.Generic.IList <Net.Vpc.Upa.Expressions.QueryStatement> context2   = new System.Collections.Generic.List <Net.Vpc.Upa.Expressions.QueryStatement>();
             Net.Vpc.Upa.Impl.FwkConvertUtils.ListAddRange(context2, context);
             context2.Add(q);
             foreach (Net.Vpc.Upa.Expressions.QueryField f in oldFields)
             {
                 Net.Vpc.Upa.Expressions.Expression expression = f.GetExpression();
                 string oldAlias = f.GetAlias();
                 System.Collections.Generic.IList <Net.Vpc.Upa.Persistence.ResultField> newVal = CreateResultFields(expression, oldAlias, fieldFilter, context2);
                 Net.Vpc.Upa.Impl.FwkConvertUtils.ListAddRange(newResults, newVal);
                 if ((newVal).Count == 0)
                 {
                 }
                 else if ((newVal).Count == 1)
                 {
                     f.SetExpression(newVal[0].GetExpression());
                     f.SetAlias(Net.Vpc.Upa.Impl.Util.StringUtils.IsNullOrEmpty(oldAlias) ? oldAlias : newVal[0].GetAlias());
                     newFields.Add(f);
                 }
                 else
                 {
                     foreach (Net.Vpc.Upa.Persistence.ResultField nf in newVal)
                     {
                         Net.Vpc.Upa.Expressions.QueryField f2 = new Net.Vpc.Upa.Expressions.QueryField(Net.Vpc.Upa.Impl.Util.StringUtils.IsNullOrEmpty(oldAlias) ? oldAlias : nf.GetAlias(), nf.GetExpression());
                         newFields.Add(f2);
                     }
                 }
             }
             qs.ClearFields();
             foreach (Net.Vpc.Upa.Expressions.QueryField newField in newFields)
             {
                 qs.Field(newField);
             }
             m.SetStatement(qs);
             foreach (Net.Vpc.Upa.Persistence.ResultField newResult in newResults)
             {
                 m.AddField(newResult);
             }
         }
         else if (q is Net.Vpc.Upa.Expressions.Union)
         {
             System.Collections.Generic.IList <Net.Vpc.Upa.Expressions.QueryStatement> context2 = new System.Collections.Generic.List <Net.Vpc.Upa.Expressions.QueryStatement>();
             Net.Vpc.Upa.Impl.FwkConvertUtils.ListAddRange(context2, context);
             context2.Add(q);
             Net.Vpc.Upa.Expressions.Union         u0     = (Net.Vpc.Upa.Expressions.Union)q;
             Net.Vpc.Upa.Expressions.Union         u      = new Net.Vpc.Upa.Expressions.Union();
             Net.Vpc.Upa.Persistence.ResultField[] fields = null;
             foreach (Net.Vpc.Upa.Expressions.QueryStatement qs in u0.GetQueryStatements())
             {
                 Net.Vpc.Upa.Persistence.ResultMetaData resultMetaData = CreateResultMetaData(qs, fieldFilter, context2);
                 u.Add((Net.Vpc.Upa.Expressions.QueryStatement)resultMetaData.GetStatement());
                 System.Collections.Generic.IList <Net.Vpc.Upa.Persistence.ResultField> f = resultMetaData.GetFields();
                 if (fields == null)
                 {
                     fields = f.ToArray();
                 }
                 else
                 {
                     if (fields.Length != (f).Count)
                     {
                         throw new Net.Vpc.Upa.Exceptions.UPAException("InvalidUnion");
                     }
                     for (int i = 0; i < fields.Length; i++)
                     {
                         fields[i] = Merge(fields[i], f[i]);
                     }
                 }
             }
             m.SetStatement(u);
             if (fields != null)
             {
                 foreach (Net.Vpc.Upa.Persistence.ResultField field in fields)
                 {
                     m.AddField(field);
                 }
             }
         }
         else
         {
             throw new System.Exception();
         }
     }
     return(m);
 }
Ejemplo n.º 11
0
 public virtual string[] GetFieldNames()
 {
     return(fieldsNames.ToArray());
 }
Ejemplo n.º 12
0
 public virtual Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledJoinCriteria[] GetJoins()
 {
     System.Collections.Generic.IList <Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledJoinCriteria> values = joinsTables;
     return(values.ToArray());
 }
Ejemplo n.º 13
0
        public virtual void CommitModelChanged() /* throws Net.Vpc.Upa.Exceptions.UPAException */
        {
            Net.Vpc.Upa.Entity sourceEntity = GetSourceRole().GetEntity();
            Net.Vpc.Upa.Entity targetEntity = GetTargetRole().GetEntity();
            if (sourceEntity == null || targetEntity == null)
            {
                throw new Net.Vpc.Upa.Exceptions.UPAException("InvalidRelationDefinition");
            }
            if (!sourceEntity.GetUserExcludeModifiers().Contains(Net.Vpc.Upa.EntityModifier.VALIDATE_PERSIST))
            {
                sourceEntity.GetModifiers().Add(Net.Vpc.Upa.EntityModifier.VALIDATE_PERSIST);
            }
            if (!sourceEntity.GetUserExcludeModifiers().Contains(Net.Vpc.Upa.EntityModifier.VALIDATE_UPDATE))
            {
                sourceEntity.GetModifiers().Add(Net.Vpc.Upa.EntityModifier.VALIDATE_UPDATE);
            }
            System.Collections.Generic.IList <Net.Vpc.Upa.Field> sourceFieldsList = sourceRole.GetFields();
            Net.Vpc.Upa.Field[] sourceFields = sourceFieldsList.ToArray();
            Net.Vpc.Upa.KeyType keyType      = new Net.Vpc.Upa.KeyType(targetEntity, filter, false);
            SetDataType(keyType);
            tuningMaxInline = GetPersistenceUnit().GetProperties().GetInt((typeof(Net.Vpc.Upa.Relationship)).FullName + ".maxInline", 10);
            System.Collections.Generic.IList <Net.Vpc.Upa.Field> targetFieldsList = targetEntity.GetPrimaryFields();
            Net.Vpc.Upa.Field[] targetFields = targetFieldsList.ToArray();
            ;
            // some checks
            if (sourceFields.Length == 0)
            {
                throw new System.ArgumentException("No source fields are specified");
            }
            if (targetFields.Length == 0)
            {
                throw new System.ArgumentException("Target Entity " + targetEntity.GetName() + " has no primary fields");
            }
            if (sourceFields.Length != targetFields.Length)
            {
                throw new System.ArgumentException("source fields and target fields have not the same count");
            }
            sourceEntity.AddDependencyOnEntity(targetEntity.GetName());
            if (dataType == null)
            {
                dataType = targetEntity.GetDataType();
            }
            if (dataType.IsNullable() != nullable)
            {
                Net.Vpc.Upa.Types.DataType trCloned = (Net.Vpc.Upa.Types.DataType)dataType.Copy();
                trCloned.SetNullable(nullable);
                dataType = trCloned;
            }
            this.sourceToTargetKeyMap = new System.Collections.Generic.Dictionary <string, string>(sourceFields.Length);
            this.targetToSourceKeyMap = new System.Collections.Generic.Dictionary <string, string>(sourceFields.Length);
            //        if ((theSourceTable  instanceof View))
            //            this.type = 0;
            for (int i = 0; i < sourceFields.Length; i++)
            {
                if (sourceFields[i].GetModifiers().Contains(Net.Vpc.Upa.FieldModifier.TRANSIENT) && this.relationType != Net.Vpc.Upa.RelationshipType.TRANSIENT)
                {
                    //Log. System.err.println("Type should be VIEW for " + getName());
                    this.relationType = Net.Vpc.Upa.RelationshipType.TRANSIENT;
                }
                else if (sourceFields[i].GetUpdateFormula() != null && this.relationType != Net.Vpc.Upa.RelationshipType.TRANSIENT && this.relationType != Net.Vpc.Upa.RelationshipType.SHADOW_ASSOCIATION)
                {
                    // Log. System.err.println("Type should be either VIEW or SHADOW for " + name);
                    this.relationType = Net.Vpc.Upa.RelationshipType.SHADOW_ASSOCIATION;
                }
                this.sourceToTargetKeyMap[sourceFields[i].GetName()] = targetFields[i].GetName();
                this.targetToSourceKeyMap[targetFields[i].GetName()] = sourceFields[i].GetName();
                //            targetFields[i].addManyToOneRelation(this);
                ((Net.Vpc.Upa.Impl.AbstractField)sourceFields[i]).SetEffectiveModifiers(sourceFields[i].GetModifiers().Add(Net.Vpc.Upa.FieldModifier.FOREIGN));
                ((Net.Vpc.Upa.Impl.AbstractField)targetFields[i]).SetEffectiveModifiers(targetFields[i].GetModifiers().Add(Net.Vpc.Upa.FieldModifier.REFERENCED));
                //            if (sourceFields[i].getTitle() == null) {
                //                sourceFields[i].setTitle(targetFields[i].getTitle());
                //            }
                if (sourceFields[i].GetDataType() == null)
                {
                    Net.Vpc.Upa.Types.DataType tr = targetFields[i].GetDataType();
                    if (tr.IsNullable() == nullable)
                    {
                        sourceFields[i].SetDataType(tr);
                    }
                    else
                    {
                        Net.Vpc.Upa.Types.DataType trCloned = (Net.Vpc.Upa.Types.DataType)tr.Copy();
                        trCloned.SetNullable(nullable);
                        sourceFields[i].SetDataType(trCloned);
                    }
                }
            }
            if (GetSourceRole().GetEntityField() != null)
            {
                Net.Vpc.Upa.Field          sourceEntityField = GetSourceRole().GetEntityField();
                Net.Vpc.Upa.Types.DataType dt = sourceEntityField.GetDataType();
                if (dt is Net.Vpc.Upa.Types.ManyToOneType)
                {
                    Net.Vpc.Upa.Types.ManyToOneType edt = (Net.Vpc.Upa.Types.ManyToOneType)dt;
                    edt.SetRelationship(this);
                }
            }
            if (GetTargetRole().GetEntityField() != null)
            {
                Net.Vpc.Upa.Field          targetEntityField = GetTargetRole().GetEntityField();
                Net.Vpc.Upa.Types.DataType dt = targetEntityField.GetDataType();
                if (dt is Net.Vpc.Upa.Types.ManyToOneType)
                {
                    Net.Vpc.Upa.Types.ManyToOneType edt = (Net.Vpc.Upa.Types.ManyToOneType)dt;
                    edt.SetRelationship(this);
                }
            }
            this.sourceToTargetKeyMap = Net.Vpc.Upa.Impl.Util.PlatformUtils.UnmodifiableMap <string, string>(sourceToTargetKeyMap);
            this.targetToSourceKeyMap = Net.Vpc.Upa.Impl.Util.PlatformUtils.UnmodifiableMap <string, string>(targetToSourceKeyMap);
            SetI18NString(new Net.Vpc.Upa.Types.I18NString("Relationship").Append(GetName()));
            SetTitle(GetI18NString().Append(".title"));
            SetDescription(GetI18NString().Append(".desc"));
            System.Text.StringBuilder preferredPersistenceName = new System.Text.StringBuilder((GetName()).Length);
            for (int i = 0; i < (GetName()).Length; i++)
            {
                if (Net.Vpc.Upa.Expressions.ExpressionHelper.IsIdentifierPart(GetName()[i]))
                {
                    preferredPersistenceName.Append(GetName()[i]);
                }
                else
                {
                    preferredPersistenceName.Append('_');
                }
            }
            SetPersistenceName(preferredPersistenceName.ToString());
            if (GetRelationshipType() == Net.Vpc.Upa.RelationshipType.COMPOSITION)
            {
                ((Net.Vpc.Upa.Impl.DefaultEntity)sourceEntity).SetCompositionRelationship(this);
            }
            targetRole.SetFields(targetFields);
            Net.Vpc.Upa.Impl.Util.UPAUtils.Prepare(GetPersistenceUnit(), targetRole, this.GetName() + "_" + targetRole.GetRelationshipRoleType());
            Net.Vpc.Upa.Impl.Util.UPAUtils.Prepare(GetPersistenceUnit(), sourceRole, this.GetName() + "_" + sourceRole.GetRelationshipRoleType());
            if ((((GetTargetRole().GetEntity().GetExtensionDefinitions <Net.Vpc.Upa.Extensions.ViewEntityExtensionDefinition>(typeof(Net.Vpc.Upa.Extensions.ViewEntityExtensionDefinition))).Count > 0) || ((GetSourceRole().GetEntity().GetExtensionDefinitions <Net.Vpc.Upa.Extensions.ViewEntityExtensionDefinition>(typeof(Net.Vpc.Upa.Extensions.ViewEntityExtensionDefinition))).Count > 0)) && relationType != Net.Vpc.Upa.RelationshipType.TRANSIENT)
            {
                throw new System.ArgumentException(this + " : Relationship Type must be TYPE_VIEW");
            }
            if (((GetTargetRole().GetEntity().GetShield().IsTransient()) || (GetSourceRole().GetEntity().GetShield().IsTransient())) && relationType != Net.Vpc.Upa.RelationshipType.TRANSIENT)
            {
                throw new System.ArgumentException(this + " : Relationship Type must be TYPE_VIEW");
            }
            Net.Vpc.Upa.FlagSet <Net.Vpc.Upa.FieldModifier> modifierstoRemove = Net.Vpc.Upa.FlagSets.OfType <Net.Vpc.Upa.FieldModifier>().AddAll(Net.Vpc.Upa.FieldModifier.PERSIST, Net.Vpc.Upa.FieldModifier.PERSIST_DEFAULT, Net.Vpc.Upa.FieldModifier.PERSIST_FORMULA, Net.Vpc.Upa.FieldModifier.PERSIST_SEQUENCE, Net.Vpc.Upa.FieldModifier.UPDATE, Net.Vpc.Upa.FieldModifier.UPDATE_DEFAULT, Net.Vpc.Upa.FieldModifier.UPDATE_FORMULA, Net.Vpc.Upa.FieldModifier.UPDATE_SEQUENCE);
            switch (GetSourceRole().GetRelationshipUpdateType())
            {
            case Net.Vpc.Upa.RelationshipUpdateType.FLAT:
            {
                Net.Vpc.Upa.Field f = GetSourceRole().GetEntityField();
                if (f != null)
                {
                    ((Net.Vpc.Upa.Impl.AbstractField)f).SetEffectiveModifiers(f.GetModifiers().RemoveAll(modifierstoRemove));
                }
                break;
            }

            case Net.Vpc.Upa.RelationshipUpdateType.COMPOSED:
            {
                System.Collections.Generic.IList <Net.Vpc.Upa.Field> fields = GetSourceRole().GetFields();
                if (fields != null)
                {
                    foreach (Net.Vpc.Upa.Field f in fields)
                    {
                        ((Net.Vpc.Upa.Impl.AbstractField)f).SetEffectiveModifiers(f.GetModifiers().RemoveAll(modifierstoRemove));
                    }
                }
                break;
            }
            }
        }
Ejemplo n.º 14
0
 public virtual Net.Vpc.Upa.Config.ScanFilter[] GetFilters()
 {
     return(filters.ToArray());
 }
Ejemplo n.º 15
0
 public virtual Net.Vpc.Upa.UPAObjectListener[] GetObjectListeners()
 {
     return(objectListeners == null ? ((Net.Vpc.Upa.UPAObjectListener[])(new Net.Vpc.Upa.UPAObjectListener[0])) : objectListeners.ToArray());
 }
Ejemplo n.º 16
0
 public override Net.Vpc.Upa.Impl.Uql.Compiledexpression.DefaultCompiledExpression[] GetSubExpressions()
 {
     return(queryStatements.ToArray());
 }
Ejemplo n.º 17
0
 public virtual Net.Vpc.Upa.Expressions.JoinCriteria[] GetJoins()
 {
     System.Collections.Generic.IList <Net.Vpc.Upa.Expressions.JoinCriteria> values = joinsEntities;
     return((Net.Vpc.Upa.Expressions.JoinCriteria[])values.ToArray());
 }
Ejemplo n.º 18
0
 public override string ToString()
 {
     return("ConstraintsEvent{" + (GetType()).FullName + "[source=" + source + "]" + __concatPaths(errors.ToArray(), ",\n", true) + '}');
 }
Ejemplo n.º 19
0
 /// <summary>Return the clauses whose spans are matched. </summary>
 public virtual SpanQuery[] GetClauses()
 {
     // Return a copy
     return(clauses.ToArray());
 }
Ejemplo n.º 20
0
 public virtual Net.Vpc.Upa.Config.ScanFilter[] GetContextAnnotationStrategyFilters()
 {
     return(filters.ToArray());
 }