예제 #1
0
 public virtual Net.Vpc.Upa.Impl.PrivateSequence GetOrCreateSequence(string name, string pattern, int initialValue, int increment) /* throws Net.Vpc.Upa.Exceptions.UPAException */
 {
     //        System.out.println(">>>>>>>>>>>>>>>>>>> getOrCreateSequence("+name+","+pattern+")");
     Net.Vpc.Upa.Impl.PrivateSequence r = entity.CreateQueryBuilder().ById(entity.CreateId(name, pattern)).GetEntity <R>();
     if (r == null)
     {
         CreateSequence(name, pattern, initialValue, increment);
         r = entity.CreateQueryBuilder().ById(entity.CreateId(name, pattern)).GetEntity <R>();
     }
     return(r);
 }
예제 #2
0
 private System.Collections.Generic.IList <object> GetKeysToUpdate()
 {
     if (keysToUpdate == null)
     {
         keysToUpdate = entity.CreateQueryBuilder().ByExpression(expr).OrderBy(entity.GetUpdateFormulasOrder()).GetIdList <K>();
         if ((keysToUpdate.Count == 0))
         {
             nothingToValidate = true;
         }
     }
     return(keysToUpdate);
 }
예제 #3
0
        public virtual object LoadObject(Net.Vpc.Upa.Entity e, object id, bool record, Net.Vpc.Upa.Impl.Persistence.Result.LoaderContext context)
        {
            Net.Vpc.Upa.NamedId cacheId = new Net.Vpc.Upa.NamedId(id, e.GetName());
            Net.Vpc.Upa.Impl.Util.CacheMap <Net.Vpc.Upa.NamedId, object> referencesCache = context.GetReferencesCache();
            object existingValue = referencesCache.Get(cacheId);

            if (existingValue == null && !referencesCache.ContainsKey(cacheId))
            {
                Net.Vpc.Upa.Query query = e.CreateQueryBuilder().ById(id).SetHints(context.GetHints());
                existingValue = record ? ((object)(query.GetRecord())) : query.GetEntity <object>();
                referencesCache.Put(cacheId, existingValue);
            }
            return(existingValue);
        }
예제 #4
0
 /**
  * @param oldId
  * @param newId
  * @throws net.vpc.upa.exceptions.UPAException
  * CloneRecordNotAllowedException, CloneRecordNotAllowedException,
  * CloneRecordNotAllowedException, CloneRecordOldKeyNotFoundException,
  * CloneRecordNewKeyInUseException
  */
 public virtual void CheckClone(object oldId, object newId) /* throws Net.Vpc.Upa.Exceptions.UPAException */
 {
     if (!entity.GetPersistenceUnit().GetSecurityManager().IsAllowedClone(entity))
     {
         throw new Net.Vpc.Upa.Exceptions.CloneRecordNotAllowedException(entity);
     }
     if (!IsCloneSupported())
     {
         throw new Net.Vpc.Upa.Exceptions.CloneRecordNotAllowedException(entity);
     }
     if (oldId != null)
     {
         Net.Vpc.Upa.Expressions.Expression e = GetFullNonCloneableRecordsExpression();
         if (e != null && e.IsValid())
         {
             Net.Vpc.Upa.Expressions.And a = new Net.Vpc.Upa.Expressions.And(entity.GetBuilder().IdToExpression(oldId, null), e);
             if (entity.GetEntityCount(a) > 0)
             {
                 throw new Net.Vpc.Upa.Exceptions.CloneRecordNotAllowedException(entity);
             }
         }
         object o = entity.CreateQueryBuilder().ById(oldId).SetFieldFilter(Net.Vpc.Upa.Impl.Util.Filters.Fields2.PERSISTENT_NON_FORMULA).GetEntity <R>();
         if (o == null)
         {
             throw new Net.Vpc.Upa.Exceptions.CloneRecordOldKeyNotFoundException(entity);
         }
     }
     if (newId != null)
     {
         if (entity.Contains(newId))
         {
             throw new Net.Vpc.Upa.Exceptions.CloneRecordNewKeyInUseException(entity);
         }
     }
     CheckVeto(Net.Vpc.Upa.VetoableOperation.checkClone, oldId, newId);
 }
예제 #5
0
        public override void OnPreUpdate(Net.Vpc.Upa.Callbacks.UpdateEvent @event) /* throws Net.Vpc.Upa.Exceptions.UPAException */
        {
            Net.Vpc.Upa.Persistence.EntityExecutionContext       executionContext = @event.GetContext();
            System.Collections.Generic.IList <Net.Vpc.Upa.Field> updateTreeFields = GetUpdateTreeFields();
            Net.Vpc.Upa.Record updates = @event.GetUpdatesRecord();
            if (!updates.IsSet(updateTreeFields[0].GetName()))
            {
                return;
            }
            object val = updates.GetObject <T>(updateTreeFields[0].GetName());

            if (val is Net.Vpc.Upa.Expressions.Literal)
            {
                val = ((Net.Vpc.Upa.Expressions.Literal)val).GetValue();
            }
            else if (val is Net.Vpc.Upa.Expressions.Expression)
            {
                //                    Log.bug("1232123");
                return;
            }
            if (val != null)
            {
                object parentId = relation.ExtractId(updates);
                if (parentId != null)
                {
                    Net.Vpc.Upa.Entity entity = @event.GetEntity();
                    string             k      = "recurse";
                    if (!executionContext.IsSet(k))
                    {
                        System.Collections.Generic.IList <object> idList = entity.CreateQueryBuilder().ByExpression(@event.GetFilterExpression()).OrderBy(entity.GetUpdateFormulasOrder()).GetIdList <K>();
                        executionContext.SetObject(k, idList);
                    }
                    System.Collections.Generic.IList <object> r = (System.Collections.Generic.IList <object>)executionContext.GetObject <T>("recurse");
                    foreach (object aR in r)
                    {
                        if (support.IsEqualOrIsParent(aR, parentId))
                        {
                            throw new Net.Vpc.Upa.Exceptions.UPAException("RedundancyProblem");
                        }
                    }
                }
            }
        }
예제 #6
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);
        }
예제 #7
0
 public virtual object Run()
 {
     return(e.CreateQueryBuilder().ById(id).SetHints(hints).GetEntity <R>());
 }
예제 #8
0
 public virtual object FindEntityByKeyPath(Net.Vpc.Upa.Key[] keyPath) /* throws Net.Vpc.Upa.Exceptions.UPAException */
 {
     Net.Vpc.Upa.Entity entity = GetEntity();
     return(entity.CreateQueryBuilder().ByExpression(CreateFindEntityByKeyPathExpression(keyPath, null)).GetEntity <R>());
 }
예제 #9
0
 public virtual object FindEntityByMainPath(string mainFieldPath)
 {
     Net.Vpc.Upa.Entity entity = GetEntity();
     return(entity.CreateQueryBuilder().ByExpression(CreateFindEntityByMainPathExpression(mainFieldPath, null)).GetEntity <R>());
 }
 private System.Collections.Generic.ICollection <Net.Vpc.Upa.Key> CreateUpdatedCollection(Net.Vpc.Upa.Entity entity, Net.Vpc.Upa.Expressions.Expression expression) /* throws Net.Vpc.Upa.Exceptions.UPAException */
 {
     return(entity.CreateQueryBuilder().ByExpression(TranslateExpression(expression)).GetKeyList());
 }