Ejemplo n.º 1
0
        protected internal virtual int ValidateCustomFormula(System.Collections.Generic.ISet <Net.Vpc.Upa.Field> fields) /* throws Net.Vpc.Upa.Exceptions.UPAException */
        {
            //                        if (monitor != null) {
            //                            if (monitor.isStopped()) {
            //                                return;
            //                            }
            //                            monitor.stepIn(keysToUpdate.size());
            //                        }
            int x = 0;

            foreach (object aKeysToUpdate in GetKeysToUpdate())
            {
                //                            if (monitor != null) {
                //                                if (monitor.isStopped()) {
                //                                    return;
                //                                }
                //                                monitor.progress(String.valueOf(validationPass.pass), "Passe "
                //                                        + (validationPass.pass + 1), null);
                //                            }
                // System.out.println("ITERATIVE_VALIDATION = " +
                // validationPass.pass+" : "+validationPass.fields+" :
                // "+keysToUpdate[r]);
                Net.Vpc.Upa.Record u = entity.GetBuilder().CreateRecord();
                foreach (Net.Vpc.Upa.Field field in fields)
                {
                    Net.Vpc.Upa.CustomFormula cf = (Net.Vpc.Upa.CustomFormula)(onPersist ? field.GetPersistFormula() : field.GetUpdateFormula());
                    object v = cf.GetValue(field, aKeysToUpdate, context);
                    u.SetObject(field.GetName(), new Net.Vpc.Upa.Expressions.Cast(new Net.Vpc.Upa.Expressions.Param(null, v), field.GetDataType()));
                }
                x += entity.UpdateCore(u, entity.GetBuilder().IdToExpression(aKeysToUpdate, entity.GetName()), context);
            }
            //                        if (monitor != null) {
            //                            monitor.stepOut();
            //                        }
            return(x);
        }
Ejemplo n.º 2
0
        public override void OnPersist(Net.Vpc.Upa.Callbacks.PersistEvent @event) /* throws Net.Vpc.Upa.Exceptions.UPAException */
        {
            object parent_id     = relation.ExtractId(@event.GetPersistedRecord());
            string path          = support.GetHierarchyPathSeparator() + support.ToStringId(@event.GetPersistedId());
            string pathFieldName = support.GetHierarchyPathField();

            Net.Vpc.Upa.Entity entity = relation.GetSourceRole().GetEntity();
            if (parent_id != null)
            {
                Net.Vpc.Upa.Record r = entity.CreateQueryBuilder().ByExpression(entity.GetBuilder().IdToExpression(parent_id, null)).SetFieldFilter(Net.Vpc.Upa.Filters.Fields.ByName(pathFieldName)).GetRecord();
                if (r != null)
                {
                    path = r.GetString(pathFieldName) + path;
                }
            }
            @event.GetPersistedRecord().SetString(pathFieldName, path);
            Net.Vpc.Upa.Persistence.EntityExecutionContext executionContext = @event.GetContext();
            Net.Vpc.Upa.Persistence.EntityExecutionContext updateContext    = executionContext.GetPersistenceUnit().GetFactory().CreateObject <Net.Vpc.Upa.Persistence.EntityExecutionContext>(typeof(Net.Vpc.Upa.Persistence.EntityExecutionContext));
            updateContext.InitPersistenceUnit(executionContext.GetPersistenceUnit(), executionContext.GetPersistenceStore(), Net.Vpc.Upa.Persistence.ContextOperation.UPDATE);
            Net.Vpc.Upa.Record u2 = entity.GetBuilder().CreateRecord();
            u2.SetString(pathFieldName, path);
            entity.UpdateCore(u2, entity.GetBuilder().IdToExpression(@event.GetPersistedId(), entity.GetName()), updateContext);
        }