Beispiel #1
0
        public virtual void Merge()
        {
            System.Collections.Generic.IList <object> ok           = new System.Collections.Generic.List <object>();
            Net.Vpc.Upa.Config.DecorationValue[]      alternatives = GetAlternatives();
            foreach (Net.Vpc.Upa.Config.DecorationValue alternative in alternatives)
            {
                Net.Vpc.Upa.Impl.Config.Decorations.DecorationPrimitiveValue d = (Net.Vpc.Upa.Impl.Config.Decorations.DecorationPrimitiveValue)alternative;
                switch (d.GetConfig().GetConfigAction())
                {
                case Net.Vpc.Upa.Config.ConfigAction.DELETE:
                {
                    ok.Clear();
                    break;
                }

                case Net.Vpc.Upa.Config.ConfigAction.MERGE:
                case Net.Vpc.Upa.Config.ConfigAction.REPLACE:
                {
                    ok.Clear();
                    ok.Add(d.GetValue());
                    break;
                }
                }
            }
            Net.Vpc.Upa.Config.DecorationValue last = alternatives[alternatives.Length - 1];
            if ((ok.Count == 0))
            {
                @value     = null;
                configInfo = new Net.Vpc.Upa.Config.ConfigInfo(last.GetConfig().GetOrder(), Net.Vpc.Upa.Config.ConfigAction.DELETE, last.GetConfig().GetPersistenceGroup(), last.GetConfig().GetPersistenceUnit());
            }
            else
            {
                @value     = ok[(ok).Count - 1];
                configInfo = new Net.Vpc.Upa.Config.ConfigInfo(last.GetConfig().GetOrder(), Net.Vpc.Upa.Config.ConfigAction.MERGE, last.GetConfig().GetPersistenceGroup(), last.GetConfig().GetPersistenceUnit());
            }
        }
 internal virtual void ParseEntityType(Net.Vpc.Upa.Impl.Config.Annotationparser.EntityInfo entityInfo, System.Type type, bool parseFields, bool parseModifiers, bool parseExtensions, Net.Vpc.Upa.ObjectFactory factory)
 {
     Net.Vpc.Upa.Config.Decoration ue = repo.GetTypeDecoration(type, typeof(Net.Vpc.Upa.Config.Entity));
     entityInfo.idType = Net.Vpc.Upa.Impl.Config.Annotationparser.AnnotationParserUtils.ValidClass(ue == null ? null : ue.GetType("idType"), entityInfo.idType, typeof(object));
     if (ue != null && !ue.GetType("entityType").Equals(typeof(void)))
     {
         entityInfo.entityType.SetBetterValue(ue.GetType("entityType"), ue.GetConfig().GetOrder());
     }
     entityInfo.name      = Net.Vpc.Upa.Impl.Config.Annotationparser.AnnotationParserUtils.ValidStr(Net.Vpc.Upa.Impl.Config.Annotationparser.AnnotationParserUtils.ValidStr(ue == null ? null : ue.GetString("name"), entityInfo.name), (type).Name);
     entityInfo.shortName = Net.Vpc.Upa.Impl.Config.Annotationparser.AnnotationParserUtils.ValidStr(ue == null ? null : ue.GetString("shortName"), entityInfo.shortName);
     if (parseModifiers && ue != null)
     {
         System.Collections.Generic.List <Net.Vpc.Upa.EntityModifier> all = new System.Collections.Generic.List <Net.Vpc.Upa.EntityModifier>();
         foreach (Net.Vpc.Upa.Config.DecorationValue v in ue.GetArray("modifiers"))
         {
             Net.Vpc.Upa.Impl.Config.Decorations.DecorationPrimitiveValue pv = (Net.Vpc.Upa.Impl.Config.Decorations.DecorationPrimitiveValue)v;
             all.Add(Net.Vpc.Upa.Impl.Util.PlatformUtils.Convert <Net.Vpc.Upa.EntityModifier>(pv.GetValue(), typeof(Net.Vpc.Upa.EntityModifier)));
         }
         entityInfo.AddModifiers(all);
         all = new System.Collections.Generic.List <Net.Vpc.Upa.EntityModifier>();
         foreach (Net.Vpc.Upa.Config.DecorationValue v in ue.GetArray("excludeModifiers"))
         {
             Net.Vpc.Upa.Impl.Config.Decorations.DecorationPrimitiveValue pv = (Net.Vpc.Upa.Impl.Config.Decorations.DecorationPrimitiveValue)v;
             all.Add(Net.Vpc.Upa.Impl.Util.PlatformUtils.Convert <Net.Vpc.Upa.EntityModifier>(pv.GetValue(), typeof(Net.Vpc.Upa.EntityModifier)));
         }
         entityInfo.AddExcludeModifiers(all);
     }
     if (ue != null && ue.GetString("path") != null && (ue.GetString("path")).Length > 0)
     {
         entityInfo.path.SetBetterValue(ue.GetString("path"), ue.GetConfig().GetOrder());
     }
     if (ue != null && ue.GetString("listOrder") != null && (ue.GetString("listOrder")).Length > 0)
     {
         entityInfo.listOrder.SetBetterValue(ue.GetString("listOrder"), ue.GetConfig().GetOrder());
     }
     if (ue != null && ue.GetString("archivingOrder") != null && (ue.GetString("archivingOrder")).Length > 0)
     {
         entityInfo.archivingOrder.SetBetterValue(ue.GetString("archivingOrder"), ue.GetConfig().GetOrder());
     }
     Net.Vpc.Upa.Config.Decoration path = (Net.Vpc.Upa.Config.Decoration)repo.GetTypeDecoration(type, typeof(Net.Vpc.Upa.Config.Path));
     if (path != null)
     {
         if ((path.GetString("value")).Length > 0)
         {
             entityInfo.path.SetBetterValue(path.GetString("value"), path.GetConfig().GetOrder());
         }
         if (path.GetInt("position") != System.Int32.MinValue)
         {
             entityInfo.pathPosition.SetBetterValue(path.GetInt("position"), path.GetConfig().GetOrder());
         }
     }
     foreach (Net.Vpc.Upa.Config.Decoration indexAnn in FindIndexAnnotation(type))
     {
         //net.vpc.upa.config.Index
         System.Collections.Generic.IList <string> rr = new System.Collections.Generic.List <string>();
         Net.Vpc.Upa.Impl.FwkConvertUtils.ListAddRange(rr, new System.Collections.Generic.List <string>(indexAnn.GetPrimitiveArray <string>("fields", typeof(string))));
         entityInfo.AddIndex(indexAnn.GetString("name"), rr, indexAnn.GetBoolean("unique"), indexAnn.GetConfig().GetOrder());
     }
     //        net.vpc.upa.config.Sequence gue = (net.vpc.upa.config.Sequence) type.getAnnotation(Sequence.class);
     //        if (gue != null) {
     //            if (privateInfo.generatedIdInfo == null) {
     //                privateInfo.generatedIdInfo = new SequenceInfo();
     //            }
     //            privateInfo.generatedIdInfo.merge(gue);
     //        }
     if (parseFields)
     {
         System.Collections.Generic.IList <Net.Vpc.Upa.Impl.Config.Annotationparser.FieldInfo> fieldInfos = new System.Collections.Generic.List <Net.Vpc.Upa.Impl.Config.Annotationparser.FieldInfo>();
         if (!typeof(Net.Vpc.Upa.Record).IsAssignableFrom(type))
         {
             System.Type c = type;
             while (c != null)
             {
                 System.Collections.Generic.IList <Net.Vpc.Upa.Impl.Config.Annotationparser.FieldInfo> cfields = new System.Collections.Generic.List <Net.Vpc.Upa.Impl.Config.Annotationparser.FieldInfo>();
                 foreach (System.Reflection.FieldInfo field in c.GetFields(System.Reflection.BindingFlags.Default))
                 {
                     if (AcceptField(field))
                     {
                         string fieldName = GetFieldName(field);
                         Net.Vpc.Upa.Config.Decoration ignored = repo.GetFieldDecoration(field, typeof(Net.Vpc.Upa.Config.Ignore));
                         if (ignored != null)
                         {
                             Net.Vpc.Upa.Impl.Config.Annotationparser.FieldInfo oldValue = Net.Vpc.Upa.Impl.FwkConvertUtils.GetMapValue <string, Net.Vpc.Upa.Impl.Config.Annotationparser.FieldInfo>(entityInfo.fieldsMap, fieldName);
                             if (oldValue != null)
                             {
                                 oldValue.valid = false;
                             }
                         }
                         else
                         {
                             Net.Vpc.Upa.Impl.Config.Annotationparser.FieldInfo oldValue = Net.Vpc.Upa.Impl.FwkConvertUtils.GetMapValue <string, Net.Vpc.Upa.Impl.Config.Annotationparser.FieldInfo>(entityInfo.fieldsMap, fieldName);
                             if (oldValue == null)
                             {
                                 oldValue = new Net.Vpc.Upa.Impl.Config.Annotationparser.FieldInfo(fieldName, entityInfo, repo);
                                 cfields.Add(oldValue);
                             }
                             oldValue.RegisterField(field);
                         }
                     }
                 }
                 Net.Vpc.Upa.Impl.FwkConvertUtils.ListInsertRange(fieldInfos, 0, cfields);
                 c = (c).BaseType;
             }
         }
         foreach (Net.Vpc.Upa.Impl.Config.Annotationparser.FieldInfo fieldInfo in fieldInfos)
         {
             string name = fieldInfo.name;
             Net.Vpc.Upa.Impl.Config.Annotationparser.FieldInfo old = Net.Vpc.Upa.Impl.FwkConvertUtils.GetMapValue <string, Net.Vpc.Upa.Impl.Config.Annotationparser.FieldInfo>(entityInfo.fieldsMap, name);
             if (old != null)
             {
                 throw new System.ArgumentException("Should never happen");
             }
             entityInfo.fieldsMap[name] = fieldInfo;
         }
     }
     if (parseExtensions)
     {
         Net.Vpc.Upa.Config.Decoration unionEntity = repo.GetTypeDecoration(type, typeof(Net.Vpc.Upa.Config.UnionEntity));
         if (unionEntity != null)
         {
             if (unionEntity.GetType("spec").Equals(typeof(Net.Vpc.Upa.Extensions.UnionEntityExtensionDefinition)))
             {
                 string discriminator = unionEntity.GetString("discriminator");
                 //                    String[] fields = unionEntity.fields();
                 //                    UnionEntityEntry[] entities = unionEntity.entities();
                 Net.Vpc.Upa.Config.DecorationValue[]      entities  = unionEntity.GetArray("entities");
                 System.Collections.Generic.IList <string> _entities = new System.Collections.Generic.List <string>();
                 System.Collections.Generic.IList <string> _fields   = new System.Collections.Generic.List <string>();
                 Net.Vpc.Upa.Impl.FwkConvertUtils.ListAddRange(_fields, new System.Collections.Generic.List <string>(unionEntity.GetPrimitiveArray <string>("fields", typeof(string))));
                 string     _entityFieldName = discriminator;
                 string[][] _mapping         = (string[][])Net.Vpc.Upa.Impl.FwkConvertUtils.CreateMultiArray(typeof(string), entities.Length, (_fields).Count);
                 int        ientity          = 0;
                 foreach (Net.Vpc.Upa.Config.DecorationValue entity0 in entities)
                 {
                     Net.Vpc.Upa.Config.Decoration entity = (Net.Vpc.Upa.Config.Decoration)entity0;
                     //UnionEntityEntry
                     _entities.Add(entity.GetString("entity"));
                     int ifield = 0;
                     foreach (string field in _fields)
                     {
                         string   f       = null;
                         string[] efields = entity.GetPrimitiveArray <string>("fields", typeof(string));
                         if (ifield < efields.Length)
                         {
                             f = efields[ifield];
                         }
                         if (f == null)
                         {
                             f = field;
                         }
                         _mapping[ientity][ifield] = f;
                         ifield++;
                     }
                     ientity++;
                 }
                 entityInfo.specs.Add(new Net.Vpc.Upa.Extensions.DefaultUnionEntityExtensionDefinition(new Net.Vpc.Upa.Extensions.UnionQueryInfo(_entities, _fields, _entityFieldName, _mapping)));
             }
             else
             {
                 entityInfo.specs.Add((Net.Vpc.Upa.Extensions.EntityExtensionDefinition)factory.CreateObject <T>(unionEntity.GetType("spec")));
             }
         }
         Net.Vpc.Upa.Config.Decoration view = (Net.Vpc.Upa.Config.Decoration)repo.GetTypeDecoration(type, typeof(Net.Vpc.Upa.Config.View));
         if (view != null)
         {
             System.Type spec = view.GetType("spec");
             if (spec.Equals(typeof(Net.Vpc.Upa.Extensions.ViewEntityExtensionDefinition)))
             {
                 throw new System.ArgumentException("Unsupported");
             }
             else
             {
                 entityInfo.specs.Add(factory.CreateObject <Net.Vpc.Upa.Extensions.ViewEntityExtensionDefinition>(spec));
             }
         }
     }
 }