示例#1
0
 public static void PreparePostAdd(Net.Vpc.Upa.PersistenceUnit persistenceUnit, Net.Vpc.Upa.UPAObject item)
 {
     //        DefaultBeanAdapter adapter = new DefaultBeanAdapter(item);
     Net.Vpc.Upa.I18NStringStrategy strategy = persistenceUnit.GetI18NStringStrategy();
     Net.Vpc.Upa.Types.I18NString   s        = null;
     Net.Vpc.Upa.Types.I18NString   t        = null;
     Net.Vpc.Upa.Types.I18NString   d        = null;
     if (item is Net.Vpc.Upa.Package)
     {
         s = strategy.GetPackageString(((Net.Vpc.Upa.Package)item));
         t = s.Append("title");
         d = s.Append("desc");
     }
     else if (item is Net.Vpc.Upa.Relationship)
     {
         s = strategy.GetRelationshipString((Net.Vpc.Upa.Relationship)item);
         t = s.Append("title");
         d = s.Append("desc");
     }
     else if (item is Net.Vpc.Upa.Entity)
     {
         s = strategy.GetEntityString((Net.Vpc.Upa.Entity)item);
         t = s.Append("title");
         d = s.Append("desc");
     }
     else if (item is Net.Vpc.Upa.Section)
     {
         s = strategy.GetSectionString(((Net.Vpc.Upa.Section)item).GetEntity(), item.GetName());
         t = s.Append("title");
         d = s.Append("desc");
     }
     else if (item is Net.Vpc.Upa.Field)
     {
         s = strategy.GetFieldString((Net.Vpc.Upa.Field)item);
         t = s.Append("title");
         d = s.Append("desc");
     }
     else if (item is Net.Vpc.Upa.RelationshipRole)
     {
         Net.Vpc.Upa.RelationshipRole r = (Net.Vpc.Upa.RelationshipRole)item;
         s = strategy.GetRelationshipRoleString(r);
         t = s.Append("title");
         d = (s.Append("desc").Union(r.GetEntity().GetDescription()));
     }
     item.SetI18NString(s);
     item.SetTitle(t);
     item.SetDescription(d);
 }
示例#2
0
 public virtual Net.Vpc.Upa.Entity GetSourceEntity() /* throws Net.Vpc.Upa.Exceptions.UPAException */
 {
     return(sourceRole == null ? null : sourceRole.GetEntity());
 }
示例#3
0
 public virtual Net.Vpc.Upa.Expressions.Expression GetSourceCondition(Net.Vpc.Upa.Expressions.Expression targetCondition, string sourceAlias, string targetAlias) /* throws Net.Vpc.Upa.Exceptions.UPAException */
 {
     //Key Rkey=getTargetTable().getKeyForExpression(targetCondition);
     Net.Vpc.Upa.Field[] sourceFields = GetSourceRole().GetFields().ToArray();
     Net.Vpc.Upa.Field[] targetFields = GetTargetRole().GetFields().ToArray();
     if (targetCondition is Net.Vpc.Upa.Expressions.IdExpression)
     {
         Net.Vpc.Upa.Key Rkey = targetRole.GetEntity().GetBuilder().IdToKey(((Net.Vpc.Upa.Expressions.IdExpression)targetCondition).GetId());
         if (sourceFields.Length == 1)
         {
             Net.Vpc.Upa.Expressions.Var lvar = (sourceAlias == null) ? new Net.Vpc.Upa.Expressions.Var(sourceFields[0].GetName()) : new Net.Vpc.Upa.Expressions.Var(new Net.Vpc.Upa.Expressions.Var(sourceAlias), sourceFields[0].GetName());
             return(new Net.Vpc.Upa.Expressions.Equals(lvar, new Net.Vpc.Upa.Expressions.Literal(Rkey == null ? null : Rkey.GetValue()[0], targetFields[0].GetDataType())));
         }
         else
         {
             Net.Vpc.Upa.Expressions.Expression a = null;
             for (int i = 0; i < sourceFields.Length; i++)
             {
                 Net.Vpc.Upa.Expressions.Var        lvar = (sourceAlias == null) ? new Net.Vpc.Upa.Expressions.Var(sourceFields[i].GetName()) : new Net.Vpc.Upa.Expressions.Var(new Net.Vpc.Upa.Expressions.Var(sourceAlias), sourceFields[i].GetName());
                 Net.Vpc.Upa.Expressions.Expression rvar = new Net.Vpc.Upa.Expressions.Literal(Rkey == null ? null : Rkey.GetObjectAt(i), targetFields[i].GetDataType());
                 Net.Vpc.Upa.Expressions.Expression e    = new Net.Vpc.Upa.Expressions.Equals(lvar, rvar);
                 a = a == null ? e : a;
             }
             return(a);
         }
     }
     else if (tuningMaxInline > 0)
     {
         Net.Vpc.Upa.Expressions.Var[] lvar = new Net.Vpc.Upa.Expressions.Var[sourceFields.Length];
         Net.Vpc.Upa.Expressions.Var[] rvar = new Net.Vpc.Upa.Expressions.Var[targetFields.Length];
         for (int i = 0; i < lvar.Length; i++)
         {
             lvar[i] = new Net.Vpc.Upa.Expressions.Var((sourceAlias == null) ? null : new Net.Vpc.Upa.Expressions.Var(sourceAlias), sourceFields[i].GetName());
             rvar[i] = new Net.Vpc.Upa.Expressions.Var((targetAlias == null) ? null : new Net.Vpc.Upa.Expressions.Var(targetAlias), targetFields[i].GetName());
         }
         try {
             System.Collections.Generic.IList <Net.Vpc.Upa.Record> list = GetTargetRole().GetEntity().CreateQuery(new Net.Vpc.Upa.Expressions.Select().Uplet(rvar, "rval").Where(targetCondition)).GetRecordList();
             int j = 0;
             Net.Vpc.Upa.Expressions.IdCollectionExpression inCollection = new Net.Vpc.Upa.Expressions.IdCollectionExpression(lvar);
             foreach (Net.Vpc.Upa.Record r in list)
             {
                 j++;
                 if (j > tuningMaxInline)
                 {
                     return(new Net.Vpc.Upa.Expressions.InSelection(lvar, new Net.Vpc.Upa.Expressions.Select().From(GetTargetRole().GetEntity().GetName()).Uplet(rvar).Where(targetCondition)));
                 }
                 inCollection.Add(new Net.Vpc.Upa.Expressions.Param(null, r.GetSingleResult <T>()));
             }
             //inCollection.add(new Litteral(rs.getObject(1)));
             return(inCollection);
         } catch (Net.Vpc.Upa.Exceptions.UPAException e) {
             return(new Net.Vpc.Upa.Expressions.InSelection(lvar, new Net.Vpc.Upa.Expressions.Select().From(GetTargetRole().GetEntity().GetName()).Uplet(rvar).Where(targetCondition)));
         }
     }
     else
     {
         Net.Vpc.Upa.Expressions.Var[] lvar = new Net.Vpc.Upa.Expressions.Var[sourceFields.Length];
         Net.Vpc.Upa.Expressions.Var[] rvar = new Net.Vpc.Upa.Expressions.Var[targetFields.Length];
         for (int i = 0; i < lvar.Length; i++)
         {
             lvar[i] = new Net.Vpc.Upa.Expressions.Var((sourceAlias == null) ? null : new Net.Vpc.Upa.Expressions.Var(sourceAlias), sourceFields[i].GetName());
             rvar[i] = new Net.Vpc.Upa.Expressions.Var((targetAlias == null) ? null : new Net.Vpc.Upa.Expressions.Var(targetAlias), targetFields[i].GetName());
         }
         return(new Net.Vpc.Upa.Expressions.InSelection(lvar, new Net.Vpc.Upa.Expressions.Select().From(GetTargetRole().GetEntity().GetName()).Uplet(rvar).Where(targetCondition)));
     }
 }