Beispiel #1
0
 public virtual void Before(Net.Vpc.Upa.EntityPart item, int index)
 {
     Net.Vpc.Upa.EntityPart oldParent = item.GetParent();
     if (oldParent != null)
     {
         if (!(oldParent is Net.Vpc.Upa.Section) && !(oldParent is Net.Vpc.Upa.CompoundField))
         {
             throw new System.ArgumentException("Field Parent is neither a Field Section nor a Field");
         }
     }
     defaultEntity.BeforePartAdded(null, item, index);
     if (oldParent != null)
     {
         if (oldParent is Net.Vpc.Upa.Section)
         {
             Net.Vpc.Upa.Section x = (Net.Vpc.Upa.Section)oldParent;
             x.RemovePartAt(x.IndexOfPart(item));
         }
         else if (oldParent is Net.Vpc.Upa.CompoundField)
         {
             Net.Vpc.Upa.CompoundField x = (Net.Vpc.Upa.CompoundField)oldParent;
             ((Net.Vpc.Upa.Impl.DefaultCompoundField)x).DropFieldAt(x.IndexOfField((Net.Vpc.Upa.PrimitiveField)item));
         }
     }
     //
     Net.Vpc.Upa.Impl.Util.DefaultBeanAdapter a = new Net.Vpc.Upa.Impl.Util.DefaultBeanAdapter(item);
     if (oldParent != null)
     {
         a.InjectNull("parent");
     }
     a.SetProperty("entity", defaultEntity);
 }
Beispiel #2
0
        public virtual void UnregisterSection(Net.Vpc.Upa.Section item)
        {
            Net.Vpc.Upa.Entity  entity = item.GetEntity();
            Net.Vpc.Upa.Package module = entity.GetParent();
            string s = (module == null ? "/" : module.GetPath() + "/") + entity.GetName() + "/" + item.GetPath();

            sections.Remove(s);
        }
Beispiel #3
0
        public virtual bool ContainsSection(Net.Vpc.Upa.Section item)
        {
            Net.Vpc.Upa.Entity  entity = item.GetEntity();
            Net.Vpc.Upa.Package module = entity.GetParent();
            string s = (module == null ? "/" : module.GetPath() + "/") + entity.GetName() + "/" + item.GetPath();

            return(sections.ContainsKey(s));
        }
Beispiel #4
0
 public SectionEvent(Net.Vpc.Upa.Section item, Net.Vpc.Upa.PersistenceUnit persistenceUnit, Net.Vpc.Upa.Entity entity, Net.Vpc.Upa.Section parent, int index, Net.Vpc.Upa.Section oldParent, int oldIndex, Net.Vpc.Upa.EventPhase phase)
 {
     this.persistenceUnit = persistenceUnit;
     this.item            = item;
     this.parent          = parent;
     this.index           = index;
     this.oldParent       = oldParent;
     this.oldIndex        = oldIndex;
     this.entity          = entity;
     this.phase           = phase;
 }
 public virtual void Before(Net.Vpc.Upa.EntityPart child, int index)
 {
     Net.Vpc.Upa.EntityPart oldParent = child.GetParent();
     //        ((DefaultEntity) defaultSection.getEntity()).beforePartAdded(defaultSection, child, index);
     if (oldParent != null && oldParent != defaultSection)
     {
         if (oldParent is Net.Vpc.Upa.Section)
         {
             Net.Vpc.Upa.Section x = (Net.Vpc.Upa.Section)oldParent;
             x.RemovePartAt(x.IndexOfPart(child));
         }
     }
     Net.Vpc.Upa.Impl.Util.DefaultBeanAdapter adapter = new Net.Vpc.Upa.Impl.Util.DefaultBeanAdapter(child);
     if (oldParent != defaultSection)
     {
         adapter.SetProperty("parent", defaultSection);
     }
     adapter.SetProperty("entity", defaultSection.GetEntity());
 }
Beispiel #6
0
 public virtual void After(Net.Vpc.Upa.PrimitiveField child, int index)
 {
     Net.Vpc.Upa.EntityPart oldParent = child.GetParent();
     if (oldParent != null && oldParent != defaultCompoundField)
     {
         if (oldParent is Net.Vpc.Upa.Section)
         {
             Net.Vpc.Upa.Section x = (Net.Vpc.Upa.Section)oldParent;
             x.RemovePartAt(x.IndexOfPart(child));
         }
         else if (oldParent is Net.Vpc.Upa.CompoundField)
         {
             Net.Vpc.Upa.CompoundField x = (Net.Vpc.Upa.CompoundField)oldParent;
             ((Net.Vpc.Upa.Impl.DefaultCompoundField)x).DropFieldAt(x.IndexOfField(child));
         }
     }
     if (oldParent != defaultCompoundField)
     {
         Net.Vpc.Upa.Impl.Util.DefaultBeanAdapter adapter = new Net.Vpc.Upa.Impl.Util.DefaultBeanAdapter(child);
         adapter.SetProperty("parent", defaultCompoundField);
     }
 }
Beispiel #7
0
 public virtual Net.Vpc.Upa.Section AddSection(string name, string parentPath, int index) /* throws Net.Vpc.Upa.Exceptions.UPAException */
 {
     if (name == null)
     {
         throw new System.NullReferenceException();
     }
     if (name.Contains("/"))
     {
         throw new System.ArgumentException("Name cannot contain '/'");
     }
     string[]            canonicalPathArray = Net.Vpc.Upa.Impl.Util.UPAUtils.GetCanonicalPathArray(parentPath);
     Net.Vpc.Upa.Section parentModule       = null;
     foreach (string n in canonicalPathArray)
     {
         Net.Vpc.Upa.Section next = null;
         if (parentModule == null)
         {
             next = GetSection(n);
         }
         else
         {
             next = parentModule.GetSection(n);
         }
         parentModule = next;
     }
     Net.Vpc.Upa.Section currentModule          = GetPersistenceUnit().GetFactory().CreateObject <Net.Vpc.Upa.Section>(typeof(Net.Vpc.Upa.Section));
     Net.Vpc.Upa.Impl.Util.DefaultBeanAdapter a = Net.Vpc.Upa.Impl.Util.UPAUtils.Prepare(GetPersistenceUnit(), currentModule, name);
     if (parentModule == null)
     {
         AddPart(currentModule, index);
     }
     else
     {
         parentModule.AddPart(currentModule, index);
     }
     //invalidateStructureCache();
     return(currentModule);
 }
Beispiel #8
0
        public virtual Net.Vpc.Upa.Section GetSection(string path, Net.Vpc.Upa.MissingStrategy missingStrategy) /* throws Net.Vpc.Upa.Exceptions.UPAException */
        {
            if (path == null)
            {
                throw new System.NullReferenceException();
            }
            string[] canonicalPathArray = Net.Vpc.Upa.Impl.Util.UPAUtils.GetCanonicalPathArray(path);
            if (canonicalPathArray.Length == 0)
            {
                throw new System.ArgumentException("invalid module path " + path);
            }
            Net.Vpc.Upa.Section module = null;
            foreach (string n in canonicalPathArray)
            {
                Net.Vpc.Upa.Section next = null;
                if (module == null)
                {
                    foreach (Net.Vpc.Upa.EntityPart schemaItem in parts)
                    {
                        if (schemaItem is Net.Vpc.Upa.Section)
                        {
                            if (schemaItem.GetName().Equals(n))
                            {
                                next = (Net.Vpc.Upa.Section)schemaItem;
                                break;
                            }
                        }
                    }
                    if (next == null)
                    {
                        switch (missingStrategy)
                        {
                        case Net.Vpc.Upa.MissingStrategy.ERROR:
                        {
                            throw new Net.Vpc.Upa.Exceptions.NoSuchSectionException(path);
                        }

                        case Net.Vpc.Upa.MissingStrategy.CREATE:
                        {
                            next = AddSection(n, null);
                            break;
                        }

                        case Net.Vpc.Upa.MissingStrategy.NULL:
                        {
                            return(null);
                        }

                        default:
                        {
                            throw new System.Exception();
                        }
                        }
                    }
                }
                else
                {
                    try {
                        next = module.GetSection(n);
                    } catch (Net.Vpc.Upa.Exceptions.NoSuchSectionException e) {
                        switch (missingStrategy)
                        {
                        case Net.Vpc.Upa.MissingStrategy.ERROR:
                        {
                            throw new Net.Vpc.Upa.Exceptions.NoSuchSectionException(path);
                        }

                        case Net.Vpc.Upa.MissingStrategy.CREATE:
                        {
                            next = AddSection(n, module.GetPath());
                            break;
                        }

                        case Net.Vpc.Upa.MissingStrategy.NULL:
                        {
                            return(null);
                        }

                        default:
                        {
                            throw new System.Exception();
                        }
                        }
                    }
                }
                module = next;
            }
            return(module);
        }