public CompiledBinaryOperatorExpression(Net.Vpc.Upa.Expressions.BinaryOperator @operator, Net.Vpc.Upa.Impl.Uql.Compiledexpression.DefaultCompiledExpression left, Net.Vpc.Upa.Impl.Uql.Compiledexpression.DefaultCompiledExpression right) { this.left = left; this.right = right; Net.Vpc.Upa.Types.DataTypeTransform leftType = null; Net.Vpc.Upa.Types.DataTypeTransform rightType = null; if (left != null && left.GetTypeTransform() != null && !left.GetTypeTransform().GetSourceType().GetPlatformType().Equals(typeof(object))) { leftType = left.GetTypeTransform(); } if (right != null && right.GetTypeTransform() != null && !right.GetTypeTransform().GetSourceType().GetPlatformType().Equals(typeof(object))) { rightType = right.GetTypeTransform(); } if (leftType == null && rightType != null) { left.SetTypeTransform(rightType); } else if (rightType == null && leftType != null) { right.SetTypeTransform(leftType); } this.@operator = @operator; PrepareChildren(left, right); }
public override Net.Vpc.Upa.Types.DataTypeTransform GetEffectiveDataType() { Net.Vpc.Upa.Types.DataTypeTransform d = GetTypeTransform(); Net.Vpc.Upa.Impl.Uql.Compiledexpression.DefaultCompiledExpression p = GetParentExpression(); if (p is Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledVarVal) { Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledVarOrMethod v = ((Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledVarVal)p).GetVar(); v = ((Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledVarOrMethod)v).GetFinest(); object r = v.GetReferrer(); if (r is Net.Vpc.Upa.Field) { return(Net.Vpc.Upa.Impl.Util.UPAUtils.GetTypeTransformOrIdentity((Net.Vpc.Upa.Field)r)); } } else if ((p is Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledEquals) || (p is Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledDifferent)) { Net.Vpc.Upa.Impl.Uql.Compiledexpression.DefaultCompiledExpression o = ((Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledBinaryOperatorExpression)p).GetOther(this); if (o is Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledVarOrMethod) { o = ((Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledVarOrMethod)o).GetFinest(); object r = ((Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledVarOrMethod)o).GetReferrer(); if (r is Net.Vpc.Upa.Field) { return(Net.Vpc.Upa.Impl.Util.UPAUtils.GetTypeTransformOrIdentity((Net.Vpc.Upa.Field)r)); } } } return(d); }
public static bool IsPasswordTransform(Net.Vpc.Upa.Types.DataTypeTransform t) { if (t == null) { return(false); } if (t is Net.Vpc.Upa.Impl.Transform.IdentityDataTypeTransform) { return(false); } if (t is Net.Vpc.Upa.Impl.Transform.PasswordDataTypeTransform) { return(true); } if (t is Net.Vpc.Upa.Impl.Transform.DataTypeTransformList) { foreach (Net.Vpc.Upa.Types.DataTypeTransform x in ((Net.Vpc.Upa.Impl.Transform.DataTypeTransformList)t)) { if (IsPasswordTransform(x)) { return(true); } } } return(false); }
public CompiledLiteral(object @value, Net.Vpc.Upa.Types.DataTypeTransform type) { // if ( // value != null // && !(value instanceof String) // && !(value instanceof Number) // && !(value instanceof Date) // && !(value instanceof Boolean) // ) { // throw new RuntimeException("bad sql value : " + value.getClass().getName() + " ==> " + value); // } else { this.@value = @value; if (type == null) { if (@value == null) { type = Net.Vpc.Upa.Impl.Transform.IdentityDataTypeTransform.OBJECT; } else { type = Net.Vpc.Upa.Impl.Transform.IdentityDataTypeTransform.ForNativeType(@value.GetType()); } } this.type = type; }
public virtual Net.Vpc.Upa.Types.DataTypeTransform CreateTypeTransform(Net.Vpc.Upa.PersistenceUnit pu, Net.Vpc.Upa.Types.DataType source, Net.Vpc.Upa.Types.DataTypeTransformConfig[] configs) /* throws Net.Vpc.Upa.Exceptions.UPAException */ { Net.Vpc.Upa.Types.DataTypeTransform t = null; Net.Vpc.Upa.Types.DataType s = source; if (configs != null) { foreach (Net.Vpc.Upa.Types.DataTypeTransformConfig c in configs) { if (c != null) { Net.Vpc.Upa.Types.DataTypeTransform tt = CreateTypeTransform(pu, s, c); if (t == null) { t = tt; } else { t = t.Chain(tt); } s = t.GetTargetType(); } } } return(t); }
public static Net.Vpc.Upa.Impl.Util.ExprTypeInfo ResolveExprTypeInfo(Net.Vpc.Upa.Impl.Uql.Compiledexpression.DefaultCompiledExpression e, bool byBrother) { if (e is Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledVarOrMethod) { e = ((Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledVarOrMethod)e).GetFinest(); object r = ((Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledVarOrMethod)e).GetReferrer(); if (r is Net.Vpc.Upa.Field) { Net.Vpc.Upa.Types.DataTypeTransform tr = GetTypeTransformOrIdentity(((Net.Vpc.Upa.Field)r)); Net.Vpc.Upa.Impl.Util.ExprTypeInfo i = new Net.Vpc.Upa.Impl.Util.ExprTypeInfo(); i.SetReferrer(r); i.SetTransform(tr); if (e is Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledVar) { Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledVar cv = (Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledVar)e; i.SetOldReferrer(cv.GetOldReferrer()); } return(i); } } if (e is Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledVarVal) { Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledVarOrMethod v = ((Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledVarVal)e).GetVar(); return(ResolveExprTypeInfo(v)); } Net.Vpc.Upa.Types.DataTypeTransform typeTransform = e.GetTypeTransform(); if (e is Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledParam || e is Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledLiteral) { Net.Vpc.Upa.Impl.Uql.Compiledexpression.DefaultCompiledExpression p = e.GetParentExpression(); if (p is Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledVarVal) { return(ResolveExprTypeInfo(p)); } else { object @object = (e is Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledParam) ? ((Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledParam)e).GetValue() : ((Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledLiteral)e).GetValue(); Net.Vpc.Upa.Types.DataType sourceType = typeTransform.GetSourceType(); Net.Vpc.Upa.Types.DataTypeTransform bestType = typeTransform; if ((p is Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledBinaryOperatorExpression) && (((Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledBinaryOperatorExpression)p).IsSameOperandsType())) { Net.Vpc.Upa.Impl.Uql.Compiledexpression.DefaultCompiledExpression o = ((Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledBinaryOperatorExpression)p).GetOther(e); if (byBrother) { return(ResolveExprTypeInfo(o, false)); } } if (@object != null && (typeTransform.Equals(Net.Vpc.Upa.Impl.Transform.IdentityDataTypeTransform.OBJECT) || !sourceType.IsInstance(@object))) { bestType = Net.Vpc.Upa.Impl.Transform.IdentityDataTypeTransform.ForNativeType(@object.GetType()); } Net.Vpc.Upa.Impl.Util.ExprTypeInfo typeInfo1 = new Net.Vpc.Upa.Impl.Util.ExprTypeInfo(); typeInfo1.SetTransform(bestType); return(typeInfo1); } } Net.Vpc.Upa.Impl.Util.ExprTypeInfo typeInfo2 = new Net.Vpc.Upa.Impl.Util.ExprTypeInfo(); typeInfo2.SetTransform(typeTransform); return(typeInfo2); }
public virtual Net.Vpc.Upa.Impl.Persistence.TypeMarshaller GetTypeMarshaller(Net.Vpc.Upa.Types.DataTypeTransform p) { if (p is Net.Vpc.Upa.Impl.Transform.IdentityDataTypeTransform) { return(GetTypeMarshaller(((Net.Vpc.Upa.Impl.Transform.IdentityDataTypeTransform)p).GetSourceType())); } return(new Net.Vpc.Upa.Impl.Persistence.Shared.DataTypeTransformMarshaller(p, GetTypeMarshaller(p.GetTargetType()))); }
public Net.Vpc.Upa.Types.DataTypeTransform Chain(Net.Vpc.Upa.Types.DataTypeTransform other) { if (other == null) { return(this); } return(other); }
public static Net.Vpc.Upa.Types.DataTypeTransform GetTypeTransformOrIdentity(Net.Vpc.Upa.Field f) { Net.Vpc.Upa.Types.DataTypeTransform t = f.GetTypeTransform(); if (t == null) { return(new Net.Vpc.Upa.Impl.Transform.IdentityDataTypeTransform(f.GetDataType())); } return(t); }
public override Net.Vpc.Upa.Types.DataTypeTransform GetTypeTransform() { if ((fields).Count == 1) { Net.Vpc.Upa.Types.DataTypeTransform type = fields[0].GetExpression().GetTypeTransform(); return(type == null ? Net.Vpc.Upa.Impl.Transform.IdentityDataTypeTransform.VOID : type); } return(Net.Vpc.Upa.Impl.Transform.IdentityDataTypeTransform.VOID); }
private void SetValue(object o) { this.@value = o; if (o == null) { type = Net.Vpc.Upa.Impl.Transform.IdentityDataTypeTransform.OBJECT; } type = Net.Vpc.Upa.Impl.Transform.IdentityDataTypeTransform.ForNativeType(o.GetType()); }
public virtual Net.Vpc.Upa.Impl.Persistence.QueryExecutor Execute() /* throws Net.Vpc.Upa.Exceptions.UPAException */ { string logString = null; try { errorTrace = null; this.currentStatementIndex = 0; // log.log(Level.FINE,"NATIVE QUERY : " + query); // Log.log(PersistenceUnitManager.DB_QUERY_LOG, "RETURN :=" + query); switch (GetStatementType()) { case Net.Vpc.Upa.Impl.Persistence.NativeStatementType.SELECT: { Net.Vpc.Upa.Types.DataTypeTransform[] types = new Net.Vpc.Upa.Types.DataTypeTransform[fields.Length]; for (int i = 0; i < types.Length; i++) { types[i] = fields[i].GetTypeTransform(); } SetQueryResult(connection.ExecuteQuery(query, types, queryParameters, updatable)); break; } case Net.Vpc.Upa.Impl.Persistence.NativeStatementType.UPDATE: { if (generatedKeys != null && (generatedKeys).Count > 0) { int updates = connection.ExecuteNonQuery(query, queryParameters, generatedKeys); SetResultCount(updates); } else { SetResultCount(connection.ExecuteNonQuery(query, queryParameters, null)); } break; } default: throw new System.Exception("Unexpected QueryExecutor type " + GetStatementType()); } } catch (System.Exception e) { errorTrace = "--ERROR-EXEC--" + "\n" + " full query =" + query + "\n" + " statement index =" + GetCurrentStatementIndex() + "\n" + " execution-context =" + this + "\n" + " exception =" + e + "\n" + " stacktrace =" + "\n"; // Log.log(PersistenceUnitManager.DB_ERROR_LOG,errorTrace); throw new Net.Vpc.Upa.Exceptions.UPAException(e, new Net.Vpc.Upa.Types.I18NString("NativeException"), errorTrace); } finally { // if (errorTrace == null){ // switch (createExecutor.getDataType()) { // case 2: // '\002' // Log.log(DatabaseAdapter.DB_UPDATE_LOG,"[COUNT=?] " + getResultCount()); // break; // } // } Dispose(); } return(this); }
public virtual Net.Vpc.Upa.Types.DataTypeTransform CreateTypeTransform(Net.Vpc.Upa.PersistenceUnit pu, Net.Vpc.Upa.Types.DataType source, Net.Vpc.Upa.Types.DataTypeTransformConfig transformConfig) { if (transformConfig == null) { return(null); } if (transformConfig is Net.Vpc.Upa.Types.DataTypeTransform) { return((Net.Vpc.Upa.Types.DataTypeTransform)transformConfig); } else if ((transformConfig is Net.Vpc.Upa.Types.CustomExpressionDataTypeTransform)) { Net.Vpc.Upa.Types.CustomExpressionDataTypeTransform c = (Net.Vpc.Upa.Types.CustomExpressionDataTypeTransform)transformConfig; return(CreateTypeTransform(pu, source, CreateDataTypeTransformConfigArray(c.GetExpression()))); } else if ((transformConfig is Net.Vpc.Upa.Types.CustomTypeDataTypeTransform)) { Net.Vpc.Upa.Types.CustomTypeDataTypeTransform c = (Net.Vpc.Upa.Types.CustomTypeDataTypeTransform)transformConfig; return(pu.GetFactory().CreateObject <T>(c.GetCustomType())); } else if ((transformConfig is Net.Vpc.Upa.Types.CustomInstanceDataTypeTransform)) { Net.Vpc.Upa.Types.CustomInstanceDataTypeTransform c = (Net.Vpc.Upa.Types.CustomInstanceDataTypeTransform)transformConfig; Net.Vpc.Upa.Types.DataTypeTransform i = c.GetInstance(); return(i); } else if (transformConfig is Net.Vpc.Upa.PasswordTransformConfig) { Net.Vpc.Upa.PasswordTransformConfig p = (Net.Vpc.Upa.PasswordTransformConfig)transformConfig; return(CreatePasswordTransform(pu, source, p)); } else if (transformConfig is Net.Vpc.Upa.Types.SecretTransformConfig) { Net.Vpc.Upa.Types.SecretTransformConfig p = (Net.Vpc.Upa.Types.SecretTransformConfig)transformConfig; return(CreateSecretTransform(pu, source, p)); } else if (transformConfig is Net.Vpc.Upa.Types.StringEncoderTransformConfig) { Net.Vpc.Upa.Types.StringEncoderTransformConfig p = (Net.Vpc.Upa.Types.StringEncoderTransformConfig)transformConfig; return(CreateStringEncoderTransform(pu, source, p)); } else if (transformConfig is Net.Vpc.Upa.Types.ByteArrayEncoderTransformConfig) { Net.Vpc.Upa.Types.ByteArrayEncoderTransformConfig p = (Net.Vpc.Upa.Types.ByteArrayEncoderTransformConfig)transformConfig; return(CreateByteArrayEncoderTransform(pu, source, p)); } else if (transformConfig is Net.Vpc.Upa.Types.CharArrayEncoderTransformConfig) { Net.Vpc.Upa.Types.CharArrayEncoderTransformConfig p = (Net.Vpc.Upa.Types.CharArrayEncoderTransformConfig)transformConfig; return(CreateCharArrayEncoderTransform(pu, source, p)); } throw new Net.Vpc.Upa.Exceptions.UPAException("Unsupported Transform Method", source); }
public override Net.Vpc.Upa.Types.DataTypeTransform GetTypeTransform() { foreach (Net.Vpc.Upa.Impl.Uql.Compiledexpression.DefaultCompiledExpression a in GetArguments()) { Net.Vpc.Upa.Types.DataTypeTransform t = a.GetEffectiveDataType(); if (t != null && !t.GetTargetType().GetPlatformType().Equals(typeof(object))) { return(t); } } return(base.GetTypeTransform()); }
public virtual int ExecuteNonQuery(string query, System.Collections.Generic.IList <Net.Vpc.Upa.Persistence.Parameter> queryParameters, System.Collections.Generic.IList <Net.Vpc.Upa.Persistence.Parameter> generatedKeys) /* throws Net.Vpc.Upa.Exceptions.UPAException */ { if (closed) { throw new System.ArgumentException("Connection closed"); } System.Exception error = null; int count = -1; bool gen = generatedKeys != null && (generatedKeys).Count > 0; long startTime = System.DateTime.Now.Ticks; try { System.Data.IDbCommand s = null; s = connection.CreateCommand(); s.CommandText = query; s.CommandType = System.Data.CommandType.Text; int index = 1; if (queryParameters != null) { foreach (Net.Vpc.Upa.Persistence.Parameter @value in queryParameters) { Net.Vpc.Upa.Types.DataTypeTransform chain = @value.GetTypeTransform(); Net.Vpc.Upa.Impl.Persistence.TypeMarshaller typeMarshaller = marshallManager.GetTypeMarshaller(chain); typeMarshaller.Write(@value.GetValue(), index, s); index += typeMarshaller.GetSize(); } } count = s.ExecuteNonQuery(); } catch (System.Exception ee) { error = ee; // Log.log(PersistenceUnitManager.DB_ERROR_LOG,"[Error] "+currentQueryInfo+" :=" + currentQuery); throw CreateUPAException(ee, "ExecuteUpdateFailedException", query); } finally { if (/*IsLoggable=*/ true) { if (error != null) { log.TraceEvent(System.Diagnostics.TraceEventType.Error, 100, Net.Vpc.Upa.Impl.FwkConvertUtils.LogMessageExceptionFormatter(nameDebugString + " [Error] executeNonQuery " + query + " :: parameters = " + queryParameters, error)); } else { log.TraceEvent(System.Diagnostics.TraceEventType.Verbose, 60, Net.Vpc.Upa.Impl.FwkConvertUtils.LogMessageExceptionFormatter("{0} executeNonQuery {1}" + ((queryParameters != null && !(queryParameters.Count == 0)) ? "\n\tqueryParameters={2}" : "") + " ;; time = {3}", null, new object[] { nameDebugString, query, queryParameters, (System.DateTime.Now.Ticks - startTime) })); } } } // Log.log(PersistenceUnitManager.DB_NATIVE_UPDATE_LOG,"[TIME="+Log.DELTA_FORMAT.format(endTime-startTime)+" ; COUNT="+count+"] "+debug+" :=" + currentQuery); return(count); }
public virtual void PrepareFieldForPersist(Net.Vpc.Upa.Field field, object @value, Net.Vpc.Upa.Record userRecord, Net.Vpc.Upa.Record persistentRecord, Net.Vpc.Upa.Persistence.EntityExecutionContext executionContext, System.Collections.Generic.ISet <Net.Vpc.Upa.Field> insertNonNullable, System.Collections.Generic.ISet <Net.Vpc.Upa.Field> insertWithDefaultValue) /* throws Net.Vpc.Upa.Exceptions.UPAException */ { object userValue = null; bool userValueFound = false; if (!(@value is Net.Vpc.Upa.Expressions.Expression)) { userValueFound = true; userValue = @value; } else if (@value is Net.Vpc.Upa.Expressions.Param) { object o = ((Net.Vpc.Upa.Expressions.Param)@value).GetValue(); // if (o instanceof String) { userValue = o; userValueFound = true; } else if (@value is Net.Vpc.Upa.Expressions.Literal) { object o = ((Net.Vpc.Upa.Expressions.Literal)@value).GetValue(); // if (o instanceof String) { userValue = o; userValueFound = true; } // } if (userValueFound) { Net.Vpc.Upa.Types.DataTypeTransform typeTransform = Net.Vpc.Upa.Impl.Util.UPAUtils.GetTypeTransformOrIdentity(field); Net.Vpc.Upa.Impl.Transform.PasswordDataTypeTransform t = Net.Vpc.Upa.Impl.Util.UPAUtils.FindPasswordTransform(typeTransform); object v = ConvertCypherValue(t.GetCipherValue(), field.GetDataType()); if (Net.Vpc.Upa.Impl.Util.UPAUtils.Equals(userValue, v)) { return; } //ignore insert userRecord.SetObject(field.GetName(), v); } else { log.TraceEvent(System.Diagnostics.TraceEventType.Error, 100, Net.Vpc.Upa.Impl.FwkConvertUtils.LogMessageExceptionFormatter("Inserting non user value to password, hashing will be ignored", null)); } Net.Vpc.Upa.Expressions.Expression valueExpression = (@value is Net.Vpc.Upa.Expressions.Expression) ? ((Net.Vpc.Upa.Expressions.Expression)((Net.Vpc.Upa.Expressions.Expression)@value)) : new Net.Vpc.Upa.Expressions.Param(field.GetName(), @value); persistentRecord.SetObject(field.GetName(), valueExpression); }
public CompiledParam(object @value, string name, Net.Vpc.Upa.Types.DataTypeTransform type, bool unspecified) { this.@value = @value; this.name = name; this.unspecified = unspecified; if (type == null) { if (@value == null) { SetTypeTransform(Net.Vpc.Upa.Impl.Transform.IdentityDataTypeTransform.OBJECT); } else { SetTypeTransform(Net.Vpc.Upa.Impl.Transform.IdentityDataTypeTransform.ForNativeType(@value.GetType())); } } else { SetTypeTransform(type); } }
public override Net.Vpc.Upa.Types.DataTypeTransform GetTypeTransform() { Net.Vpc.Upa.Impl.Uql.Compiledexpression.DefaultCompiledExpression expression = GetExpression(); Net.Vpc.Upa.Types.DataTypeTransform dd = expression.GetEffectiveDataType(); if (dd != null) { System.Type c = dd.GetTargetType().GetPlatformType(); if (c.Equals(typeof(int?)) || c.Equals(typeof(byte?)) || c.Equals(typeof(short?))) { c = typeof(double?); } else if (c.Equals(typeof(int?)) || c.Equals(typeof(byte)) || c.Equals(typeof(short))) { c = typeof(double); } return(Net.Vpc.Upa.Impl.Transform.IdentityDataTypeTransform.ForNativeType(c)); } else { return(Net.Vpc.Upa.Impl.Transform.IdentityDataTypeTransform.DOUBLE); } }
public override string GetSQL(object oo, Net.Vpc.Upa.Persistence.EntityExecutionContext qlContext, Net.Vpc.Upa.Impl.Persistence.SQLManager sqlManager, Net.Vpc.Upa.Impl.Uql.ExpressionDeclarationList declarations) { Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledLiteral o = (Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledLiteral)oo; Net.Vpc.Upa.Impl.Util.ExprTypeInfo ei = Net.Vpc.Upa.Impl.Util.UPAUtils.ResolveExprTypeInfo(o); object objectValue = o.GetValue(); Net.Vpc.Upa.Types.DataTypeTransform d = null; if (ei.GetOldReferrer() != null) { Net.Vpc.Upa.Field oldField = (Net.Vpc.Upa.Field)ei.GetOldReferrer(); if (oldField.GetDataType() is Net.Vpc.Upa.Types.ManyToOneType) { Net.Vpc.Upa.Types.ManyToOneType et = (Net.Vpc.Upa.Types.ManyToOneType)oldField.GetDataType(); objectValue = et.GetRelationship().GetTargetEntity().GetBuilder().ObjectToId(objectValue); } } else if (ei.GetReferrer() != null && ei.GetReferrer() is Net.Vpc.Upa.Field) { Net.Vpc.Upa.Field field = (Net.Vpc.Upa.Field)ei.GetReferrer(); if (field.GetDataType() is Net.Vpc.Upa.Types.ManyToOneType) { Net.Vpc.Upa.Types.ManyToOneType et = (Net.Vpc.Upa.Types.ManyToOneType)field.GetDataType(); objectValue = et.GetRelationship().GetTargetEntity().GetBuilder().ObjectToId(objectValue); System.Collections.Generic.IList <Net.Vpc.Upa.Field> tf = et.GetRelationship().GetTargetEntity().GetPrimaryFields(); if ((tf).Count != 1) { throw new System.ArgumentException("Unsupported"); } d = Net.Vpc.Upa.Impl.Util.UPAUtils.GetTypeTransformOrIdentity(tf[0]); } } if (d == null) { d = o.GetEffectiveDataType(); } Net.Vpc.Upa.Impl.Persistence.TypeMarshaller mm = sqlManager.GetMarshallManager().GetTypeMarshaller(d); return(mm.ToSQLLiteral(objectValue)); }
public NativeField(string name, string groupName, string exprString, int index, bool expanded, Net.Vpc.Upa.Field field, Net.Vpc.Upa.Types.DataTypeTransform typeChain) { this.groupName = groupName; this.expanded = expanded; this.index = index; this.exprString = exprString; this.name = name; if (Net.Vpc.Upa.Impl.Util.StringUtils.IsNullOrEmpty(groupName)) { fullBinding = name; } else { fullBinding = groupName + "." + name; } this.field = field; this.typeTransform = typeChain; //REMOVE ME if (typeChain == null) { throw new System.ArgumentException("Null DataType"); } }
public virtual void SetTransform(Net.Vpc.Upa.Types.DataTypeTransform transform) { this.transform = transform; }
public override void SetTypeTransform(Net.Vpc.Upa.Types.DataTypeTransform type) { this.type = type; }
public UserCompiledExpression(string qlString, Net.Vpc.Upa.Types.DataTypeTransform type) { this.expression = qlString; this.type = type; }
public CompiledQLFunctionExpression(string name, Net.Vpc.Upa.Impl.Uql.Compiledexpression.DefaultCompiledExpression[] arguments, Net.Vpc.Upa.Types.DataTypeTransform type, Net.Vpc.Upa.Function handler) : base(name) { foreach (Net.Vpc.Upa.Impl.Uql.Compiledexpression.DefaultCompiledExpression a in arguments) { ProtectedAddArgument(a); } this.handler = handler; SetTypeTransform(type); }
public CompiledCast(Net.Vpc.Upa.Impl.Uql.Compiledexpression.DefaultCompiledExpression @value, Net.Vpc.Upa.Types.DataTypeTransform primitiveType) : base("Cast") { ProtectedAddArgument(@value); ProtectedAddArgument(new Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledTypeName(primitiveType)); }
public virtual void SetTypeTransform(Net.Vpc.Upa.Types.DataTypeTransform type) { this.type = type; }
public DataTypeTransformMarshaller(Net.Vpc.Upa.Types.DataTypeTransform dataTypeTransform, Net.Vpc.Upa.Impl.Persistence.TypeMarshaller targetMarshaller) { this.dataTypeTransform = dataTypeTransform; this.targetMarshaller = targetMarshaller; }
public virtual Net.Vpc.Upa.Persistence.QueryResult ExecuteQuery(string query, Net.Vpc.Upa.Types.DataTypeTransform[] types, System.Collections.Generic.IList <Net.Vpc.Upa.Persistence.Parameter> queryParameters, bool updatable) /* throws Net.Vpc.Upa.Exceptions.UPAException */ { if (closed) { throw new System.ArgumentException("Connection closed"); } long startTime = System.DateTime.Now.Ticks; System.Exception error = null; try { try { System.Data.IDbCommand s = null; s = connection.CreateCommand(); s.CommandText = query; s.CommandType = System.Data.CommandType.Text; int mi = 0; int index = 1; if (queryParameters != null) { foreach (Net.Vpc.Upa.Persistence.Parameter @value in queryParameters) { Net.Vpc.Upa.Types.DataTypeTransform transform = @value.GetTypeTransform(); Net.Vpc.Upa.Impl.Persistence.TypeMarshaller marshaller = marshallManager.GetTypeMarshaller(transform); marshaller.Write(@value.GetValue(), index, s); index += marshaller.GetSize(); mi++; } } System.Data.IDataReader resultSet = s.ExecuteReader(); if (types == null) { int columnCount; System.Type[] colTypes; columnCount = resultSet.FieldCount; colTypes = new System.Type[columnCount]; for (int i = 0; i < columnCount; i++) { colTypes[i] = resultSet.GetFieldType(i); } types = new Net.Vpc.Upa.Types.DataTypeTransform[columnCount]; for (int i = 0; i < types.Length; i++) { types[i] = new Net.Vpc.Upa.Impl.Transform.IdentityDataTypeTransform(Net.Vpc.Upa.Types.TypesFactory.ForPlatformType(colTypes[i])); } } Net.Vpc.Upa.Impl.Persistence.TypeMarshaller[] marshallers = new Net.Vpc.Upa.Impl.Persistence.TypeMarshaller[types.Length]; for (int i = 0; i < marshallers.Length; i++) { marshallers[i] = marshallManager.GetTypeMarshaller(types[i]); } // Log.log(PersistenceUnitManager.DB_PRE_NATIVE_QUERY_LOG,"[BEFORE] "+currentQueryInfo+" :=" + currentQuery); return(new Net.Vpc.Upa.Impl.Persistence.DefaultQueryResult(resultSet, s, marshallers, types)); } catch (System.Exception ee) { error = ee; throw ee; } finally { if (/*IsLoggable=*/ true) { if (error != null) { log.TraceEvent(System.Diagnostics.TraceEventType.Error, 100, Net.Vpc.Upa.Impl.FwkConvertUtils.LogMessageExceptionFormatter(nameDebugString + " [Error] executeQuery " + query + " :: parameters = " + queryParameters, error)); } else { log.TraceEvent(System.Diagnostics.TraceEventType.Verbose, 60, Net.Vpc.Upa.Impl.FwkConvertUtils.LogMessageExceptionFormatter("{0} executeQuery {1} ;; parameters = {2} ;; time = {3}", null, new object[] { nameDebugString, query, queryParameters, (System.DateTime.Now.Ticks - startTime) })); } } } } catch (System.Exception ex) { throw CreateUPAException(ex, "ExecuteQueryFailedException", query); } }
public virtual Net.Vpc.Upa.Types.DataTypeTransform Chain(Net.Vpc.Upa.Types.DataTypeTransform other) { return(Net.Vpc.Upa.Impl.Transform.DataTypeTransformList.Chain(this, other)); }
public virtual Net.Vpc.Upa.Types.DataTypeTransform CreateSecretTransform(Net.Vpc.Upa.PersistenceUnit pu, Net.Vpc.Upa.Types.DataType source, Net.Vpc.Upa.Types.SecretTransformConfig p) { if (p == null) { p = new Net.Vpc.Upa.Types.SecretTransformConfig(); } object s = p.GetSecretStrategy(); if (s == null) { s = Net.Vpc.Upa.SecretStrategyType.DEFAULT; } if (s is Net.Vpc.Upa.SecretStrategyType) { switch (((Net.Vpc.Upa.SecretStrategyType)s)) { case Net.Vpc.Upa.SecretStrategyType.BASE64: { s = Net.Vpc.Upa.Impl.Transform.Base64SecretStrategy.INSTANCE; break; } case Net.Vpc.Upa.SecretStrategyType.DEFAULT: { s = new Net.Vpc.Upa.Impl.Transform.DefaultSecretStrategy(); break; } default: { throw new Net.Vpc.Upa.Exceptions.UPAException("Unsupported", s); } } } else if (s is string) { string ss = (string)s; if (!Net.Vpc.Upa.Impl.Util.StringUtils.IsNullOrEmpty(ss)) { s = (Net.Vpc.Upa.SecretStrategy)pu.GetFactory().CreateObject <T>((string)s); } else { //use default s = new Net.Vpc.Upa.Impl.Transform.DefaultSecretStrategy(); } } else if (s is System.Type) { s = (Net.Vpc.Upa.SecretStrategy)pu.GetFactory().CreateObject <object>((System.Type)s); } else if (s is Net.Vpc.Upa.SecretStrategy) { s = (Net.Vpc.Upa.SecretStrategy)s; } else { throw new System.ArgumentException("Unsupported SecretStrategy " + s); } Net.Vpc.Upa.SecretStrategy st = (Net.Vpc.Upa.SecretStrategy)s; st.Init(pu, p.GetEncodeKey(), p.GetDecodeKey()); p.SetSecretStrategy(st); if (!(source is Net.Vpc.Upa.Types.ByteArrayType)) { Net.Vpc.Upa.Types.DataTypeTransform t = null; t = CreateByteArrayEncoderTransform(pu, source, null); Net.Vpc.Upa.Impl.Transform.SecretDataTypeTransform t2 = new Net.Vpc.Upa.Impl.Transform.SecretDataTypeTransform(st, t.GetTargetType(), p.GetSize()); return(t.Chain(t2)); } return(new Net.Vpc.Upa.Impl.Transform.SecretDataTypeTransform(st, source, p.GetSize())); }