public override Net.Vpc.Upa.MultiRecord Parse(Net.Vpc.Upa.Persistence.QueryResult result) /* throws Net.Vpc.Upa.Exceptions.UPAException */
 {
     if (forUpdate)
     {
         ResetListeners();
         Net.Vpc.Upa.MultiRecord multiRecord = new Net.Vpc.Upa.Impl.DefaultMultiRecord();
         for (int i = 0; i < columns; i++)
         {
             string             r = recordName[i];
             Net.Vpc.Upa.Record current;
             if (r == null)
             {
                 current = multiRecord.GetPlainRecord(true);
             }
             else
             {
                 current = multiRecord.GetRecord(r);
                 if (current == null)
                 {
                     current = entities[i].GetBuilder().CreateRecord();
                     multiRecord.SetRecord(r, current);
                 }
             }
             current.SetObject(fields[i].GetName(), result.Read <T>(i));
             Net.Vpc.Upa.Impl.Persistence.MultiRecordListTracker tr = Net.Vpc.Upa.Impl.FwkConvertUtils.GetMapValue <string, Net.Vpc.Upa.Impl.Persistence.MultiRecordListTracker>(currentRecords, recordName[i]);
             if (tr == null)
             {
                 Net.Vpc.Upa.PropertyChangeListener li = new Net.Vpc.Upa.Impl.Persistence.MultiRecordListTrackPropertyChangeListener(this, r, result);
                 currentRecords[recordName[i]] = new Net.Vpc.Upa.Impl.Persistence.MultiRecordListTracker(recordName[i], current, li);
                 current.AddPropertyChangeListener(li);
             }
         }
         return(multiRecord);
     }
     else
     {
         ResetListeners();
         Net.Vpc.Upa.MultiRecord multiRecord = new Net.Vpc.Upa.Impl.DefaultMultiRecord();
         for (int i = 0; i < columns; i++)
         {
             string             r = recordName[i];
             Net.Vpc.Upa.Record current;
             if (r == null)
             {
                 current = multiRecord.GetPlainRecord(true);
             }
             else
             {
                 current = multiRecord.GetRecord(r);
                 if (current == null)
                 {
                     current = entities[i].GetBuilder().CreateRecord();
                     multiRecord.SetRecord(r, current);
                 }
             }
             current.SetObject(fields[i].GetName(), result.Read <T>(i));
         }
         return(multiRecord);
     }
 }
Exemple #2
0
 public override bool IsEmpty() /* throws Net.Vpc.Upa.Exceptions.UPAException */
 {
     if (!context.GetPersistenceUnit().GetPersistenceGroup().CurrentSessionExists())
     {
         if (sessionAwareInstance == null)
         {
             sessionAwareInstance = context.GetPersistenceUnit().GetPersistenceGroup().GetContext().MakeSessionAware <Net.Vpc.Upa.Impl.Persistence.DefaultQuery>(this);
         }
         return(sessionAwareInstance.IsEmpty());
     }
     try {
         Net.Vpc.Upa.Impl.Persistence.QueryExecutor queryExecutor = ExecuteQuery(Net.Vpc.Upa.Impl.Util.Filters.Fields2.READ);
         Net.Vpc.Upa.Persistence.QueryResult        r             = null;
         try {
             r = queryExecutor.GetQueryResult();
             return(!r.HasNext());
         } finally {
             if (r != null)
             {
                 r.Close();
             }
         }
     } catch (System.Exception e) {
         throw new Net.Vpc.Upa.Exceptions.FindException(e, new Net.Vpc.Upa.Types.I18NString("FindFailed"));
     }
 }
Exemple #3
0
 public override K Parse(Net.Vpc.Upa.Persistence.QueryResult result) /* throws Net.Vpc.Upa.Exceptions.UPAException */
 {
     object[] keyObj = new object[columns];
     for (int i = 0; i < columns; i++)
     {
         keyObj[i] = result.Read <T>(i);
     }
     return((K)entity.CreateId(keyObj));
 }
Exemple #4
0
        public override T Parse(Net.Vpc.Upa.Persistence.QueryResult result) /* throws Net.Vpc.Upa.Exceptions.UPAException */
        {
            T instance = (T)beanType.NewInstance();

            for (int i = 0; i < columns; i++)
            {
                object v = result.Read <T>(i);
                if (fieldsByExpression[i] != null)
                {
                    beanType.SetProperty(instance, fieldsByExpression[i], v);
                }
            }
            return(instance);
        }
Exemple #5
0
 protected internal virtual Net.Vpc.Upa.Impl.Persistence.QueryExecutor ExecuteQuery(Net.Vpc.Upa.Filters.FieldFilter fieldFilter)
 {
     //        if (result != null) {
     //            throw new FindException("QueryAlreadyExecutedException");
     //        }
     Net.Vpc.Upa.Impl.Persistence.QueryExecutor queryExecutor = CreateNativeSQL(fieldFilter);
     //        DefaultResultMetaData m = new DefaultResultMetaData();
     //        for (NativeField x : queryExecutor.getFields()) {
     //            m.addField(x.getName(), x.getTypeTransform(), x.getField());
     //        }
     //        this.metadata = m;
     queryExecutor.Execute();
     result = queryExecutor.GetQueryResult();
     return(queryExecutor);
 }
Exemple #6
0
 // This Method is added by J2CS UPA Portable Framework.  Do Not Edit
 public abstract R Parse(Net.Vpc.Upa.Persistence.QueryResult arg1);
 public UpdatableObjectInterceptor(Net.Vpc.Upa.Impl.Persistence.Result.TypeInfo singleEntityQueryResult, object @object, Net.Vpc.Upa.Persistence.QueryResult result)
 {
     this.singleEntityQueryResult = singleEntityQueryResult;
     this.@object = @object;
     this.result  = result;
 }
 public override T Parse(Net.Vpc.Upa.Persistence.QueryResult result) /* throws Net.Vpc.Upa.Exceptions.UPAException */
 {
     System.Collections.Generic.IDictionary <string, object> groupValues = new System.Collections.Generic.Dictionary <string, object>();
     Net.Vpc.Upa.Impl.Persistence.Result.ResultColumn[]      values      = new Net.Vpc.Upa.Impl.Persistence.Result.ResultColumn[(metaData.GetFields()).Count];
     for (int i = 0; i < values.Length; i++)
     {
         values[i] = new Net.Vpc.Upa.Impl.Persistence.Result.ResultColumn();
     }
     foreach (Net.Vpc.Upa.Impl.Persistence.Result.TypeInfo typeInfo in typeInfos)
     {
         typeInfo.entityObject = null;
         typeInfo.entityRecord = null;
         typeInfo.entityResult = null;
     }
     foreach (Net.Vpc.Upa.Impl.Persistence.Result.TypeInfo typeInfo in typeInfos)
     {
         if (typeInfo.entity == null)
         {
             foreach (Net.Vpc.Upa.Impl.Persistence.Result.FieldInfo f in typeInfo.allFields)
             {
                 object fieldValue = result.Read <T>(f.dbIndex);
                 groupValues[f.nativeField.GetFullBinding()] = fieldValue;
                 groupValues[f.nativeField.GetExprString()]  = fieldValue;
                 UpdateRow(values, f, f.nativeField.GetExprString(), fieldValue);
             }
         }
         else if (typeInfo.leadPrimaryField == null)
         {
             if (typeInfo.record)
             {
                 object             entityObject = null;
                 Net.Vpc.Upa.Record entityRecord = typeInfo.entityFactory == null ? ((Net.Vpc.Upa.Record)(ofactory.CreateObject <Net.Vpc.Upa.Record>(typeof(Net.Vpc.Upa.Record)))) : typeInfo.entityFactory.CreateRecord();
                 typeInfo.entityObject = entityObject;
                 typeInfo.entityRecord = entityRecord;
                 typeInfo.entityResult = entityRecord;
             }
             else
             {
                 object             entityObject = typeInfo.entityFactory.CreateObject <R>();
                 Net.Vpc.Upa.Record entityRecord = typeInfo.entityConverter.ObjectToRecord(entityObject, true);
                 typeInfo.entityObject = entityObject;
                 typeInfo.entityRecord = entityRecord;
                 typeInfo.entityResult = entityObject;
             }
             groupValues[typeInfo.binding] = typeInfo.entityResult;
             UpdateRow(values, typeInfo, typeInfo.binding, typeInfo.entityResult);
             foreach (Net.Vpc.Upa.Impl.Persistence.Result.FieldInfo f in typeInfo.allFields)
             {
                 object fieldValue = result.Read <T>(f.dbIndex);
                 groupValues[f.nativeField.GetFullBinding()] = fieldValue;
                 typeInfo.entityRecord.SetObject(f.name, fieldValue);
                 UpdateRow(values, f, f.nativeField.GetExprString(), fieldValue);
             }
         }
         else
         {
             object leadPK = result.Read <T>(typeInfo.leadPrimaryField.dbIndex);
             if (leadPK != null)
             {
                 //create new instances
                 if (typeInfo.record)
                 {
                     typeInfo.entityRecord = typeInfo.entityFactory == null ? ((Net.Vpc.Upa.Record)(ofactory.CreateObject <Net.Vpc.Upa.Record>(typeof(Net.Vpc.Upa.Record)))) : typeInfo.entityFactory.CreateRecord();
                     typeInfo.entityResult = typeInfo.entityRecord;
                 }
                 else
                 {
                     object             entityObject = typeInfo.entityFactory.CreateObject <R>();
                     Net.Vpc.Upa.Record entityRecord = typeInfo.entityConverter.ObjectToRecord(entityObject, true);
                     typeInfo.entityObject = entityObject;
                     typeInfo.entityRecord = entityRecord;
                     typeInfo.entityResult = entityObject;
                 }
                 groupValues[typeInfo.binding] = typeInfo.entityResult;
                 UpdateRow(values, typeInfo, typeInfo.binding, typeInfo.entityResult);
                 foreach (Net.Vpc.Upa.Impl.Persistence.Result.FieldInfo f in typeInfo.allFields)
                 {
                     object fieldValue = result.Read <T>(f.dbIndex);
                     groupValues[f.nativeField.GetFullBinding()] = fieldValue;
                     UpdateRow(values, f, f.nativeField.GetExprString(), fieldValue);
                     typeInfo.entityRecord.SetObject(f.name, fieldValue);
                 }
                 if (loadManyToOneRelations)
                 {
                     foreach (Net.Vpc.Upa.Relationship relationship in typeInfo.manyToOneRelations)
                     {
                         object extractedId = relationship.ExtractIdByForeignFields(typeInfo.entityRecord);
                         if (extractedId != null)
                         {
                             object @value = loader.LoadObject(relationship.GetTargetEntity(), extractedId, relationAsRecord, loaderContext);
                             typeInfo.entityRecord.SetObject(relationship.GetSourceRole().GetEntityField().GetName(), @value);
                             groupValues[typeInfo.binding + "." + relationship.GetSourceRole().GetEntityField().GetName()] = @value;
                         }
                     }
                 }
             }
             else
             {
                 typeInfo.entityObject = null;
                 typeInfo.entityRecord = null;
             }
         }
     }
     foreach (Net.Vpc.Upa.Impl.Persistence.Result.TypeInfo typeInfo in typeInfos)
     {
         if (typeInfo.parentBinding != null)
         {
             Net.Vpc.Upa.Impl.Persistence.Result.TypeInfo pp = Net.Vpc.Upa.Impl.FwkConvertUtils.GetMapValue <string, Net.Vpc.Upa.Impl.Persistence.Result.TypeInfo>(bindingToTypeInfos, typeInfo.parentBinding);
             if (pp == null)
             {
             }
             else if (pp.entityRecord != null)
             {
                 pp.entityRecord.SetObject(typeInfo.bindingName, typeInfo.entityResult);
             }
         }
     }
     if (updatable)
     {
         foreach (Net.Vpc.Upa.Impl.Persistence.Result.TypeInfo typeInfo in typeInfos)
         {
             if (typeInfo.record)
             {
                 Net.Vpc.Upa.Impl.Persistence.Result.QueryResultUpdaterPropertyChangeListener li = new Net.Vpc.Upa.Impl.Persistence.Result.QueryResultUpdaterPropertyChangeListener(typeInfo, result);
                 typeInfo.entityRecord.AddPropertyChangeListener(li);
             }
             else
             {
                 typeInfo.entityUpdatable      = Net.Vpc.Upa.Impl.Util.PlatformUtils.CreateObjectInterceptor <object>(typeInfo.entityType, new Net.Vpc.Upa.Impl.Persistence.Result.UpdatableObjectInterceptor(typeInfo, typeInfo.entityObject, result));
                 groupValues[typeInfo.binding] = typeInfo.entityUpdatable;
                 int index = typeInfo.allFields[0].nativeField.GetIndex();
                 if (values[index].GetValue() == typeInfo.entityType)
                 {
                     values[index].SetValue(typeInfo.entityUpdatable);
                 }
             }
         }
     }
     return((T)this.resultBuilder.CreateResult(values, metaData));
 }
 public QueryResultUpdaterPropertyChangeListener(Net.Vpc.Upa.Impl.Persistence.Result.TypeInfo typeInfo, Net.Vpc.Upa.Persistence.QueryResult result)
 {
     this.result   = result;
     this.typeInfo = typeInfo;
 }
Exemple #10
0
 public virtual void SetQueryResult(Net.Vpc.Upa.Persistence.QueryResult r)
 {
     returnValue = r;
 }
 public MultiRecordListTrackPropertyChangeListener(Net.Vpc.Upa.Impl.Persistence.MultiRecordList multiRecords, string r, Net.Vpc.Upa.Persistence.QueryResult result)
 {
     this.multiRecords = multiRecords;
     this.r            = r;
     this.result       = result;
 }
Exemple #12
0
 public override T Parse(Net.Vpc.Upa.Persistence.QueryResult result) /* throws Net.Vpc.Upa.Exceptions.UPAException */
 {
     return(result.Read <T>(index));
 }
Exemple #13
0
 public QueryResultReader(Net.Vpc.Upa.Persistence.QueryResult resultSet, Net.Vpc.Upa.Persistence.QueryResultParser <T> queryResultParser)
 {
     this.queryResult       = resultSet;
     this.queryResultParser = queryResultParser;
 }