Esempio n. 1
0
 public EntityBeanFactory(Net.Vpc.Upa.Entity entity, Net.Vpc.Upa.ObjectFactory objectFactory)
 {
     this.entity        = entity;
     this.nfo           = entity.GetBeanType();
     this.objectFactory = objectFactory;
     System.Collections.Generic.IList <Net.Vpc.Upa.Field> fields = entity.GetFields();
 }
Esempio n. 2
0
 /**
  * Thread Safe retrieval of UPAContext
  *
  * @return current UPAContext
  */
 public static Net.Vpc.Upa.UPAContext GetContext() /* throws Net.Vpc.Upa.Exceptions.UPAException */
 {
     Net.Vpc.Upa.UPAContextProvider contextProvider = null;
     Net.Vpc.Upa.UPAContext         context         = contextProvider.GetContext();
     //Double Checking Lock will/should work here because we are not about to instantiate the object,
     //this is the responsibility of the contextProvider
     if (context == null)
     {
         lock (typeof(Net.Vpc.Upa.UPAContext)) {
             context = contextProvider.GetContext();
             if (context == null)
             {
                 Net.Vpc.Upa.ObjectFactory bootstrapFactory = GetBootstrapFactory();
                 context = bootstrapFactory.CreateObject <Net.Vpc.Upa.UPAContext>(typeof(Net.Vpc.Upa.UPAContext));
                 context.Start(bootstrapFactory);
                 contextProvider.SetContext(context);
             }
         }
     }
     return(context);
 }
 public virtual Net.Vpc.Upa.TransactionManager CreateTransactionManager(Net.Vpc.Upa.Persistence.ConnectionProfile connectionProfile, Net.Vpc.Upa.ObjectFactory factory, Net.Vpc.Upa.Properties parameters)
 {
     //        ConnectionDriver connectionDriver = connectionProfile.getConnectionDriver();
     //        if(connectionDriver==ConnectionDriver.datasource){
     //            throw new UPAException("Not yet supported");
     //        }
     return(new Net.Vpc.Upa.Impl.Transaction.DefaultTransactionManager());
 }
 public DefaultUPAContextFactory(Net.Vpc.Upa.ObjectFactory baseFactory)
 {
     this.baseFactory = baseFactory;
 }
 public virtual void SetParentFactory(Net.Vpc.Upa.ObjectFactory factory)
 {
     baseFactory.SetParentFactory(factory);
 }
 public DefaultObjectQueryResultLazyList(Net.Vpc.Upa.Impl.Persistence.QueryExecutor queryExecutor, bool loadManyToOneRelations, bool defaultsToRecord, bool relationAsRecord, bool supportCache, bool updatable, Net.Vpc.Upa.Impl.Persistence.Result.QueryResultRelationLoader loader, Net.Vpc.Upa.Impl.Persistence.Result.QueryResultItemBuilder resultBuilder)  : base(queryExecutor)
 {
     this.resultBuilder          = resultBuilder;
     this.loader                 = loader;
     this.defaultsToRecord       = defaultsToRecord;
     this.relationAsRecord       = relationAsRecord;
     this.loadManyToOneRelations = loadManyToOneRelations;
     metaData = queryExecutor.GetMetaData();
     hints    = queryExecutor.GetHints();
     if (hints == null)
     {
         hints = new System.Collections.Generic.Dictionary <string, object>();
     }
     else
     {
         hints = new System.Collections.Generic.Dictionary <string, object>(hints);
     }
     if (supportCache)
     {
         Net.Vpc.Upa.Impl.Util.CacheMap <Net.Vpc.Upa.NamedId, object> sharedCache = (Net.Vpc.Upa.Impl.Util.CacheMap <Net.Vpc.Upa.NamedId, object>)Net.Vpc.Upa.Impl.FwkConvertUtils.GetMapValue <string, object>(hints, "queryCache");
         if (sharedCache == null)
         {
             sharedCache         = new Net.Vpc.Upa.Impl.Util.CacheMap <Net.Vpc.Upa.NamedId, object>(1000);
             hints["queryCache"] = sharedCache;
         }
         referencesCache = sharedCache;
     }
     loaderContext = new Net.Vpc.Upa.Impl.Persistence.Result.LoaderContext(referencesCache, hints);
     System.Collections.Generic.Dictionary <string, Net.Vpc.Upa.Impl.Persistence.Result.TypeInfo> bindingToTypeInfos0 = new System.Collections.Generic.Dictionary <string, Net.Vpc.Upa.Impl.Persistence.Result.TypeInfo>();
     ofactory = Net.Vpc.Upa.UPA.GetPersistenceUnit().GetFactory();
     Net.Vpc.Upa.Impl.Persistence.NativeField[] fields = queryExecutor.GetFields();
     for (int i = 0; i < fields.Length; i++)
     {
         Net.Vpc.Upa.Impl.Persistence.NativeField      nativeField = fields[i];
         Net.Vpc.Upa.Impl.Persistence.Result.FieldInfo f           = new Net.Vpc.Upa.Impl.Persistence.Result.FieldInfo();
         f.dbIndex     = i;
         f.nativeField = nativeField;
         f.name        = nativeField.GetName();
         string gn = nativeField.GetGroupName();
         if (gn == null)
         {
             gn = nativeField.GetExprString();
         }
         Net.Vpc.Upa.Impl.Persistence.Result.TypeInfo t = Net.Vpc.Upa.Impl.FwkConvertUtils.GetMapValue <string, Net.Vpc.Upa.Impl.Persistence.Result.TypeInfo>(bindingToTypeInfos0, gn);
         if (t == null)
         {
             if (nativeField.GetField() != null)
             {
                 t        = new Net.Vpc.Upa.Impl.Persistence.Result.TypeInfo(gn, nativeField.GetField().GetEntity());
                 t.record = gn.Contains(".") ? relationAsRecord : defaultsToRecord;
                 bindingToTypeInfos0[gn] = t;
             }
             else
             {
                 t        = new Net.Vpc.Upa.Impl.Persistence.Result.TypeInfo(gn, null);
                 t.record = false;
                 //n.contains(".") ? relationAsRecord : defaultsToRecord;
                 bindingToTypeInfos0[gn] = t;
             }
         }
         //                if(!bindingToTypeInfos0.containsKey(nativeField.getExprString())) {
         //                    bindingToTypeInfos0.put(nativeField.getExprString(), t);
         //                }else{
         //                    System.out.println("why");
         //                }
         f.field = nativeField.GetField();
         if (loadManyToOneRelations)
         {
             if (f.field != null)
             {
                 if (f.field.GetDataType() is Net.Vpc.Upa.Types.ManyToOneType)
                 {
                     Net.Vpc.Upa.Entity r = ((Net.Vpc.Upa.Types.ManyToOneType)f.field.GetDataType()).GetTargetEntity();
                     f.referencedEntity = r;
                 }
                 foreach (Net.Vpc.Upa.Relationship relationship in f.field.GetManyToOneRelationships())
                 {
                     if (relationship.GetSourceRole().GetEntityField() != null)
                     {
                         t.manyToOneRelations.Add(relationship);
                     }
                 }
             }
         }
         f.typeInfo = t;
         t.allFields.Add(f);
         if (t.leadPrimaryField == null && f.nativeField.GetField() != null && f.nativeField.GetField().IsId())
         {
             t.leadPrimaryField = f;
         }
         if (t.leadField == null)
         {
             t.leadField = f;
         }
         f.setterMethodName           = Net.Vpc.Upa.Impl.Util.PlatformUtils.SetterName(nativeField.GetName());
         t.fields[f.setterMethodName] = f;
     }
     bindingToTypeInfos = bindingToTypeInfos0;
     typeInfos          = (bindingToTypeInfos0).Values.ToArray();
     // all indexes to fill with values from the query
     System.Collections.Generic.ISet <int?> allIndexes = new System.Collections.Generic.HashSet <int?>();
     for (int i = 0; i < (metaData.GetFields()).Count; i++)
     {
         allIndexes.Add(i);
     }
     // map expression to relative TypeInfo/FieldInfo
     System.Collections.Generic.IDictionary <string, object> visitedIndexes = new System.Collections.Generic.Dictionary <string, object>();
     for (int i = 0; i < typeInfos.Length; i++)
     {
         Net.Vpc.Upa.Impl.Persistence.Result.TypeInfo typeInfo = typeInfos[i];
         //            if (aliasName.equals(typeInfo.binding)) {
         //                entityIndex = i;
         //            }
         typeInfo.infosArray = typeInfo.allFields.ToArray();
         typeInfo.update     = false;
         foreach (Net.Vpc.Upa.Impl.Persistence.Result.FieldInfo field in typeInfo.infosArray)
         {
             if (!field.nativeField.IsExpanded() && field.nativeField.GetIndex() >= 0)
             {
                 field.update = true;
                 field.indexesToUpdate.Add(field.nativeField.GetIndex());
                 allIndexes.Remove(field.nativeField.GetIndex());
                 visitedIndexes[field.nativeField.GetExprString()] = field;
             }
         }
         if (typeInfo.entity == null)
         {
             typeInfo.update = true;
         }
         else
         {
             System.Collections.Generic.IList <Net.Vpc.Upa.Persistence.ResultField> fields1 = metaData.GetFields();
             for (int i1 = 0; i1 < (fields1).Count; i1++)
             {
                 Net.Vpc.Upa.Persistence.ResultField resultField = fields1[i1];
                 if (resultField.GetExpression().ToString().Equals(typeInfo.binding))
                 {
                     typeInfo.update = true;
                     typeInfo.indexesToUpdate.Add(i1);
                     allIndexes.Remove(i1);
                     visitedIndexes[typeInfo.binding] = typeInfo;
                     break;
                 }
             }
         }
     }
     //when an expression is to be expanded twice, implementation ignores second expansion
     // so we must find the equivalent expression index to handle
     foreach (int?remaining in allIndexes)
     {
         string k = metaData.GetFields()[(remaining).Value].GetExpression().ToString();
         object o = Net.Vpc.Upa.Impl.FwkConvertUtils.GetMapValue <string, object>(visitedIndexes, k);
         if (o is Net.Vpc.Upa.Impl.Persistence.Result.TypeInfo)
         {
             ((Net.Vpc.Upa.Impl.Persistence.Result.TypeInfo)o).indexesToUpdate.Add(remaining);
         }
         else if (o is Net.Vpc.Upa.Impl.Persistence.Result.FieldInfo)
         {
             ((Net.Vpc.Upa.Impl.Persistence.Result.FieldInfo)o).indexesToUpdate.Add(remaining);
         }
         else
         {
             throw new Net.Vpc.Upa.Exceptions.UPAException("Unsupported");
         }
     }
     this.updatable = updatable;
 }
Esempio n. 7
0
 public virtual void SetParentFactory(Net.Vpc.Upa.ObjectFactory factory)
 {
     this.parentFactory = factory;
 }
 public DecorationEntityDescriptorResolver(Net.Vpc.Upa.Impl.Config.Decorations.DecorationRepository decorationRepository, Net.Vpc.Upa.ObjectFactory factory)
 {
     this.repo    = decorationRepository;
     this.factory = factory;
 }
 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));
             }
         }
     }
 }
Esempio n. 10
0
 public EntitySubclassUnstructuredFactory(System.Type recordType, Net.Vpc.Upa.ObjectFactory objectFactory, Net.Vpc.Upa.Entity entity)
 {
     this.recordType    = recordType;
     this.objectFactory = objectFactory;
     this.entity        = entity;
 }
Esempio n. 11
0
 public virtual Net.Vpc.Upa.Persistence.PersistenceStore CreatePersistenceStore(Net.Vpc.Upa.Persistence.ConnectionProfile connectionProfile, Net.Vpc.Upa.ObjectFactory factory, Net.Vpc.Upa.Properties parameters)
 {
     return(factory.CreateObject <Net.Vpc.Upa.Persistence.PersistenceStore>(GetDialectPersistenceUnitManager(connectionProfile.GetDatabaseProduct())));
 }
Esempio n. 12
0
 public EntityInfo(Net.Vpc.Upa.Impl.Config.Decorations.DecorationRepository repo, Net.Vpc.Upa.ObjectFactory factory)
 {
     this.repo    = repo;
     this.factory = factory;
 }