public ComposedToFlatFieldPersister(Net.Vpc.Upa.Field field)
 {
     this.field = field;
     Net.Vpc.Upa.Types.ManyToOneType t       = (Net.Vpc.Upa.Types.ManyToOneType)field.GetDataType();
     Net.Vpc.Upa.Entity           master     = t.GetRelationship().GetTargetRole().GetEntity();
     Net.Vpc.Upa.RelationshipRole detailRole = t.GetRelationship().GetSourceRole();
     flatFields = detailRole.GetFields();
     relationshipTargetConverter = master.GetBuilder();
 }
Exemplo n.º 2
0
 public DefaultRelationship()
 {
     targetRole = new Net.Vpc.Upa.Impl.DefaultRelationshipRole();
     targetRole.SetRelationship(this);
     targetRole.SetRelationshipRoleType(Net.Vpc.Upa.RelationshipRoleType.TARGET);
     sourceRole = new Net.Vpc.Upa.Impl.DefaultRelationshipRole();
     sourceRole.SetRelationship(this);
     sourceRole.SetRelationshipRoleType(Net.Vpc.Upa.RelationshipRoleType.SOURCE);
 }
Exemplo n.º 3
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);
 }
Exemplo n.º 4
0
        public virtual Net.Vpc.Upa.Types.I18NString GetRelationshipRoleString(Net.Vpc.Upa.RelationshipRole role)
        {
            switch (role.GetRelationshipRoleType())
            {
            case Net.Vpc.Upa.RelationshipRoleType.TARGET:
            {
                return(GetRelationshipString(role.GetRelationship()).Append("Target"));
            }

            case Net.Vpc.Upa.RelationshipRoleType.SOURCE:
            {
                return(GetRelationshipString(role.GetRelationship()).Append("Source"));
            }
            }
            return(GetRelationshipString(role.GetRelationship()).Append(Key(null)));
        }
Exemplo n.º 5
0
        public virtual Net.Vpc.Upa.Expressions.Expression CreateFindEntityByMainPathExpression(string mainFieldPath, string entityAlias)
        {
            Net.Vpc.Upa.Entity           entity     = GetEntity();
            Net.Vpc.Upa.RelationshipRole detailRole = GetTreeRelationship().GetSourceRole();
            if (Net.Vpc.Upa.Impl.Util.StringUtils.IsNullOrEmpty(mainFieldPath))
            {
                return(null);
            }
            string mainFieldName  = entity.GetMainField().GetName();
            object mainFieldValue = null;
            object parent         = null;

            string[] parentAndName = Net.Vpc.Upa.Impl.Util.StringUtils.Split(mainFieldPath, GetHierarchyPathSeparator()[0], false);
            if (parentAndName != null)
            {
                parent         = FindEntityByMainPath(parentAndName[0]);
                mainFieldValue = parentAndName[1];
            }
            else
            {
                mainFieldValue = mainFieldPath;
            }
            Net.Vpc.Upa.Expressions.Expression expr = null;
            if (entityAlias == null)
            {
                entityAlias = entity.GetName();
            }
            expr = new Net.Vpc.Upa.Expressions.Equals(new Net.Vpc.Upa.Expressions.Var(new Net.Vpc.Upa.Expressions.Var(entityAlias), mainFieldName), mainFieldValue);
            Net.Vpc.Upa.Key entityToKey = parent == null ? null : entity.GetBuilder().ObjectToKey(parent);
            System.Collections.Generic.IList <Net.Vpc.Upa.Field> primaryFields = detailRole.GetFields();
            for (int index = 0; index < (primaryFields).Count; index++)
            {
                Net.Vpc.Upa.Field field = primaryFields[index];
                expr = new Net.Vpc.Upa.Expressions.And(expr, new Net.Vpc.Upa.Expressions.Equals(new Net.Vpc.Upa.Expressions.Var(new Net.Vpc.Upa.Expressions.Var(entityAlias), field.GetName()), entityToKey == null ? null : entityToKey.GetObjectAt(index)));
            }
            return(expr);
        }
Exemplo n.º 6
0
 public virtual void Synchronize()
 {
     if (field.GetDataType() is Net.Vpc.Upa.Types.ManyToOneType)
     {
         Net.Vpc.Upa.Types.ManyToOneType t        = (Net.Vpc.Upa.Types.ManyToOneType)field.GetDataType();
         Net.Vpc.Upa.Relationship        relation = t.GetRelationship();
         if (relation == null)
         {
             throw new Net.Vpc.Upa.Exceptions.UPAException("MissingRelationForField", field);
         }
         Net.Vpc.Upa.RelationshipRole       detailRole = relation.GetSourceRole();
         Net.Vpc.Upa.RelationshipUpdateType u          = detailRole.GetRelationshipUpdateType();
         if (u == Net.Vpc.Upa.RelationshipUpdateType.COMPOSED)
         {
             persistFieldPersister = new Net.Vpc.Upa.Impl.Persistence.ComposedToFlatFieldPersister(field);
             updateFieldPersister  = new Net.Vpc.Upa.Impl.Persistence.ComposedToFlatFieldPersister(field);
         }
         persistFormulaPass = 0;
         updateFormulaPass  = 0;
         postPersistFormula = false;
         postUpdateFormula  = false;
         return;
     }
     Net.Vpc.Upa.Formula persistFormula = field.GetPersistFormula();
     if (persistFormula != null)
     {
         if (persistFormula is Net.Vpc.Upa.Sequence)
         {
             persistFieldPersister = UpdateFieldPersister(persistFieldPersister, persistenceStore.CreatePersistSequenceGenerator(field));
             persistFormulaPass    = 0;
             postPersistFormula    = false;
         }
         else if (persistFormula is Net.Vpc.Upa.ExpressionFormula)
         {
             Net.Vpc.Upa.Impl.Persistence.RebuildExpressionInfo re = RebuildExpression((Net.Vpc.Upa.ExpressionFormula)persistFormula);
             if (re.rebuiltFormula != null)
             {
                 field.SetPersistFormula(re.rebuiltFormula);
             }
             bool complex = re.compiledExpression.FindFirstExpression <T>(Net.Vpc.Upa.Impl.Uql.Compiledfilters.CompiledExpressionHelper.THIS_VAR_FILTER) != default(T);
             persistFormulaPass = field.GetPersistFormulaOrder();
             if (!complex && persistFormulaPass == 0)
             {
                 insertExpression      = re.expression;
                 persistFieldPersister = UpdateFieldPersister(persistFieldPersister, new Net.Vpc.Upa.Impl.Persistence.ExpressionFieldPersister(field.GetName(), re.expression));
                 postPersistFormula    = false;
             }
             else
             {
                 postPersistFormula = true;
             }
         }
         else
         {
             postPersistFormula = true;
         }
     }
     else
     {
         postPersistFormula = false;
     }
     Net.Vpc.Upa.Formula updateFormula = field.GetUpdateFormula();
     if (updateFormula != null)
     {
         if (updateFormula is Net.Vpc.Upa.Sequence)
         {
             updateFieldPersister = UpdateFieldPersister(updateFieldPersister, persistenceStore.CreateUpdateSequenceGenerator(field));
             updateFormulaPass    = 0;
             postUpdateFormula    = false;
         }
         else if (updateFormula is Net.Vpc.Upa.ExpressionFormula)
         {
             Net.Vpc.Upa.Impl.Persistence.RebuildExpressionInfo re = RebuildExpression((Net.Vpc.Upa.ExpressionFormula)persistFormula);
             if (re.rebuiltFormula != null)
             {
                 field.SetUpdateFormula(re.rebuiltFormula);
             }
             //                List<DefaultCompiledExpression> complex = re.compiledExpression.findExpressionsList(CompiledExpressionHelper.THIS_VAR_FILTER);
             updateFormulaPass = field.GetUpdateFormulaOrder();
             if (updateFormulaPass == 0)
             {
                 updateExpression     = re.expression;
                 updateFieldPersister = UpdateFieldPersister(updateFieldPersister, new Net.Vpc.Upa.Impl.Persistence.ExpressionFieldPersister(field.GetName(), re.expression));
                 postUpdateFormula    = false;
             }
             else
             {
                 postUpdateFormula = true;
             }
         }
         else
         {
             postUpdateFormula = true;
         }
     }
     else
     {
         postUpdateFormula = true;
     }
     Net.Vpc.Upa.Formula selectFormula = field.GetSelectFormula();
     if (selectFormula != null)
     {
         if (selectFormula is Net.Vpc.Upa.ExpressionFormula)
         {
             findtExpression = ((Net.Vpc.Upa.ExpressionFormula)selectFormula).GetExpression();
         }
         else if (selectFormula is Net.Vpc.Upa.Sequence)
         {
             throw new System.ArgumentException("Sequences are not supported as Select Expressions");
         }
         else if (updateFormula is Net.Vpc.Upa.CustomUpdaterFormula)
         {
             throw new System.ArgumentException("CustomUpdaterFormulas are not supported as Select Expressions");
         }
     }
 }