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) /* throws Net.Vpc.Upa.Exceptions.UPAException */ { Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledUplet o = (Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledUplet)oo; // PersistenceUnitManager queryLanguageManager = qlContext.getPersistenceUnitManager(); Net.Vpc.Upa.Impl.Uql.Compiledexpression.DefaultCompiledExpression sql; Net.Vpc.Upa.Impl.Uql.Compiledexpression.DefaultCompiledExpression[] expressions = o.GetExpressions(); if (expressions.Length > 1) { Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledConcat concat = new Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledConcat(); for (int i = 0; i < expressions.Length; i++) { if (i > 0) { concat.Add(new Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledLiteral('~')); } concat.Add(expressions[i]); } sql = concat; } else { sql = expressions[0]; } return(sqlManager.GetSQL(sql, qlContext, declarations)); }
public override string GetSQL(object oo, Net.Vpc.Upa.Persistence.EntityExecutionContext context, Net.Vpc.Upa.Impl.Persistence.SQLManager sqlManager, Net.Vpc.Upa.Impl.Uql.ExpressionDeclarationList declarations) /* throws Net.Vpc.Upa.Exceptions.UPAException */ { Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledInsert o = (Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledInsert)oo; // PersistenceUnitManager persistenceManager = context.getPersistenceStore(); Net.Vpc.Upa.Entity entity = context.GetPersistenceUnit().GetEntity(o.GetEntity().GetName()); string n = context.GetPersistenceStore().GetValidIdentifier(context.GetPersistenceStore().GetPersistenceName(entity)); System.Text.StringBuilder sb = new System.Text.StringBuilder("Insert Into " + n); sb.Append("("); System.Text.StringBuilder sbVals = new System.Text.StringBuilder(); bool isFirst = true; int max = o.CountFields(); for (int i = 0; i < max; i++) { if (isFirst) { isFirst = false; } else { sb.Append(", "); sbVals.Append(", "); } sb.Append(sqlManager.GetSQL(o.GetField(i), context, declarations)); sbVals.Append(sqlManager.GetSQL(o.GetFieldValue(i), context, declarations)); } return(sb.Append(") Values (").Append(sbVals).Append(")").ToString()); }
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) /* throws Net.Vpc.Upa.Exceptions.UPAException */ { Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledBetween o = (Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledBetween)oo; string s = sqlManager.GetSQL(o.GetLeft(), qlContext, declarations) + " Between " + sqlManager.GetSQL(o.GetMin(), qlContext, declarations) + " And " + sqlManager.GetSQL(o.GetMax(), qlContext, declarations); return("(" + s + ")"); }
public override sealed void OnPreRemove(Net.Vpc.Upa.Callbacks.RemoveEvent @event) /* throws Net.Vpc.Upa.Exceptions.UPAException */ { Net.Vpc.Upa.Persistence.EntityExecutionContext executionContext = @event.GetContext(); if (AcceptDeleteTableHelper(@event)) { executionContext.SetObject(@event.GetTrigger().GetName() + ":toDelete", CreateUpdatedCollection(@event.GetEntity(), @event.GetFilterExpression())); } }
public virtual void AfterPersist(Net.Vpc.Upa.Record record, Net.Vpc.Upa.Persistence.EntityExecutionContext context) { if (new System.Nullable <bool>(false).Equals(context.GetConnection().GetProperty(identityConstraintsEnabledProperty))) { return; } record.SetObject(field.GetName(), context.GetGeneratedValue(field.GetName()).GetValue()); }
public override void Persist(Net.Vpc.Upa.Persistence.EntityExecutionContext executionContext, Net.Vpc.Upa.PersistenceState status) /* throws System.Exception, Net.Vpc.Upa.Exceptions.UPAException */ { Net.Vpc.Upa.Entity entity = (Net.Vpc.Upa.Entity)@object; Net.Vpc.Upa.Impl.Persistence.DefaultPersistenceStore persistenceUnitManager = (Net.Vpc.Upa.Impl.Persistence.DefaultPersistenceStore)executionContext.GetPersistenceStore(); log.TraceEvent(System.Diagnostics.TraceEventType.Verbose, 60, Net.Vpc.Upa.Impl.FwkConvertUtils.LogMessageExceptionFormatter("Commit {0} / {1} : found {2}, persist", null, new object[] { @object, typedObject, status })); Net.Vpc.Upa.Persistence.UConnection b = executionContext.GetConnection(); b.ExecuteNonQuery(persistenceUnitManager.GetCreateTableStatement(entity, executionContext), null, null); }
public virtual int Delete(Net.Vpc.Upa.Entity entity, Net.Vpc.Upa.Persistence.EntityExecutionContext context, Net.Vpc.Upa.Expressions.Expression condition, bool recurse, Net.Vpc.Upa.RemoveTrace deleteInfo) /* throws Net.Vpc.Upa.Exceptions.UPAException */ { for (int i = 0; i < (updatableTables).Count; i++) { updatableTables[i].Remove(Net.Vpc.Upa.RemoveOptions.ForExpression(defaultUnionEntityExtensionSupport.GetViewElementExpressionAt(i, condition)).SetFollowLinks(recurse).SetSimulate(false).SetRemoveTrace(deleteInfo)); } return(0); }
public virtual void BeforePersist(Net.Vpc.Upa.Record record, Net.Vpc.Upa.Persistence.EntityExecutionContext context) /* throws Net.Vpc.Upa.Exceptions.UPAException */ { //K key = entity.getBuilder().recordToId(record); Net.Vpc.Upa.Entity entity = context.GetEntity(); object key = entity.NextId <K>(); entity.GetBuilder().SetRecordId(record, key); }
protected internal virtual void ValidateChildren(object key, Net.Vpc.Upa.Persistence.EntityExecutionContext executionContext) /* throws Net.Vpc.Upa.Exceptions.UPAException */ { Net.Vpc.Upa.Record r = GetEntity().CreateQueryBuilder().ByExpression(GetEntity().GetBuilder().IdToExpression(key, null)).SetFieldFilter(Net.Vpc.Upa.Filters.Fields.ByName(GetHierarchyPathField())).GetRecord(); System.Collections.Generic.IList <Net.Vpc.Upa.Field> lfs = GetTreeRelationship().GetSourceRole().GetFields(); Net.Vpc.Upa.Expressions.Concat concat = new Net.Vpc.Upa.Expressions.Concat(); concat.Add(new Net.Vpc.Upa.Expressions.Literal(r.GetString(GetHierarchyPathField()), GetEntity().GetField(GetHierarchyPathField()).GetDataType())); System.Collections.Generic.IList <Net.Vpc.Upa.Field> primaryFields = GetEntity().GetPrimaryFields(); foreach (Net.Vpc.Upa.Field f in primaryFields) { concat.Add(new Net.Vpc.Upa.Expressions.Literal(GetHierarchyPathSeparator())); Net.Vpc.Upa.Types.DataType t = f.GetDataType(); Net.Vpc.Upa.Expressions.Var var = new Net.Vpc.Upa.Expressions.Var(f.GetName()); Net.Vpc.Upa.Expressions.Expression svar = null; if (t is Net.Vpc.Upa.Types.StringType) { svar = var; } else if (t is Net.Vpc.Upa.Types.IntType) { svar = new Net.Vpc.Upa.Expressions.I2V(var); } else if (t is Net.Vpc.Upa.Types.LongType) { svar = new Net.Vpc.Upa.Expressions.I2V(var); } else if (t is Net.Vpc.Upa.Types.DoubleType) { svar = new Net.Vpc.Upa.Expressions.D2V(var); } else if (t is Net.Vpc.Upa.Types.FloatType) { svar = new Net.Vpc.Upa.Expressions.D2V(var); } else { throw new System.ArgumentException("Unsupported "); } concat.Add(svar); } Net.Vpc.Upa.Record s = GetEntity().GetBuilder().CreateRecord(); s.SetObject(GetHierarchyPathField(), concat); Net.Vpc.Upa.Expressions.Expression p = null; Net.Vpc.Upa.Relationship rel = GetTreeRelationship(); object[] kvalue = GetEntity().GetBuilder().IdToKey(key).GetValue(); for (int i = 0; i < rel.Size(); i++) { Net.Vpc.Upa.Field field = lfs[i]; Net.Vpc.Upa.Expressions.Expression e = (new Net.Vpc.Upa.Expressions.Equals(new Net.Vpc.Upa.Expressions.Var(field.GetName()), new Net.Vpc.Upa.Expressions.Literal(kvalue[i], field.GetDataType()))); p = p == null ? ((Net.Vpc.Upa.Expressions.Expression)(e)) : new Net.Vpc.Upa.Expressions.And(p, e); } GetEntity().UpdateCore(s, p, executionContext); System.Collections.Generic.IList <object> children = GetEntity().CreateQueryBuilder().ByExpression(p).GetIdList <K>(); foreach (object aChildren in children) { ValidateChildren(aChildren, executionContext); } }
public virtual int Reset(Net.Vpc.Upa.Entity entity, Net.Vpc.Upa.Persistence.EntityExecutionContext context) /* throws Net.Vpc.Upa.Exceptions.UPAException */ { if (entity.GetShield().IsTransient()) { return(0); } Net.Vpc.Upa.Expressions.Delete stmt = (new Net.Vpc.Upa.Expressions.Delete()).From(entity.GetName()); return(context.GetPersistenceStore().CreateQuery(stmt, context).ExecuteNonQuery()); }
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) /* throws Net.Vpc.Upa.Exceptions.UPAException */ { Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledPlus o = (Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledPlus)oo; System.Type t1 = o.GetLeft().GetTypeTransform().GetTargetType().GetPlatformType(); System.Type t2 = o.GetRight().GetTypeTransform().GetTargetType().GetPlatformType(); bool s0 = o.GetTypeTransform().GetTargetType().GetPlatformType().Equals(typeof(string)); bool s1 = t1.Equals(typeof(string)); bool s2 = t2.Equals(typeof(string)); if (s0 || s1 || s2) { Net.Vpc.Upa.Impl.Uql.Compiledexpression.DefaultCompiledExpression c1 = o.GetLeft().Copy(); Net.Vpc.Upa.Impl.Uql.Compiledexpression.DefaultCompiledExpression c2 = o.GetRight().Copy(); c1.SetParentExpression(null); c2.SetParentExpression(null); if (!s1) { if (Net.Vpc.Upa.Impl.Util.PlatformUtils.IsAnyInteger(t1)) { c1 = new Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledI2V(c1.Copy()); } else if (Net.Vpc.Upa.Impl.Util.PlatformUtils.IsAnyFloat(t1)) { c1 = new Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledI2V(c1.Copy()); } else { throw new System.ArgumentException("Unsupported"); } } if (!s2) { if (Net.Vpc.Upa.Impl.Util.PlatformUtils.IsAnyInteger(t2)) { c2 = new Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledI2V(c2.Copy()); } else if (Net.Vpc.Upa.Impl.Util.PlatformUtils.IsAnyFloat(t2)) { c2 = new Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledI2V(c2.Copy()); } else { throw new System.ArgumentException("Unsupported"); } } Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledConcat cc = new Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledConcat(c1, c2); return(sqlManager.GetSQL(cc, qlContext, declarations)); } string leftValue = o.GetLeft() != null?sqlManager.GetSQL(o.GetLeft(), qlContext, declarations) : "NULL"; string rightValue = o.GetRight() != null?sqlManager.GetSQL(o.GetRight(), qlContext, declarations) : "NULL"; string s = null; s = leftValue + " + " + rightValue; return("(" + s + ")"); }
public virtual int Delete(Net.Vpc.Upa.Entity entity, Net.Vpc.Upa.Persistence.EntityExecutionContext context, Net.Vpc.Upa.Expressions.Expression condition, bool recurse, Net.Vpc.Upa.RemoveTrace deleteInfo) /* throws Net.Vpc.Upa.Exceptions.UPAException */ { if (entity.GetShield().IsTransient()) { return(0); } Net.Vpc.Upa.Expressions.Delete stmt = (new Net.Vpc.Upa.Expressions.Delete()).From(entity.GetName()).Where(condition); return(context.GetPersistenceStore().CreateQuery(stmt, context).ExecuteNonQuery()); }
public virtual string Simplify(Net.Vpc.Upa.Persistence.EntityExecutionContext ctx, Net.Vpc.Upa.Impl.Persistence.SQLManager sqlManager, Net.Vpc.Upa.Impl.Uql.ExpressionDeclarationList declarations, params Net.Vpc.Upa.Impl.Uql.Compiledexpression.DefaultCompiledExpression [] @params) /* throws Net.Vpc.Upa.Exceptions.UPAException */ { string[] p = new string[@params.Length]; for (int i = 0; i < p.Length; i++) { p[i] = sqlManager.GetSQL(@params[i], ctx, declarations); } return(Simplify((GetExpressionType()).Name, p, null)); }
public virtual void BeforePersist(Net.Vpc.Upa.Record record, Net.Vpc.Upa.Persistence.EntityExecutionContext context) /* throws Net.Vpc.Upa.Exceptions.UPAException */ { if (new System.Nullable <bool>(false).Equals(context.GetConnection().GetProperty(identityConstraintsEnabledProperty))) { return; } context.AddGeneratedValue(field.GetName(), field.GetDataType()); //manual id values are ignored record.Remove(field.GetName()); }
public EntityEvent(Net.Vpc.Upa.Persistence.EntityExecutionContext context, Net.Vpc.Upa.EventPhase phase) { this.context = context; this.entity = context.GetEntity(); this.parent = entity.GetParent(); this.persistenceUnit = context.GetPersistenceUnit(); this.index = -1; this.oldIndex = -1; this.phase = phase; }
public override void Persist(Net.Vpc.Upa.Persistence.EntityExecutionContext executionContext, Net.Vpc.Upa.PersistenceState status) /* throws System.Exception, Net.Vpc.Upa.Exceptions.UPAException */ { Net.Vpc.Upa.Relationship relation = (Net.Vpc.Upa.Relationship)@object; Net.Vpc.Upa.Impl.Persistence.DefaultPersistenceStore persistenceUnitManager = (Net.Vpc.Upa.Impl.Persistence.DefaultPersistenceStore)executionContext.GetPersistenceStore(); log.TraceEvent(System.Diagnostics.TraceEventType.Verbose, 60, Net.Vpc.Upa.Impl.FwkConvertUtils.LogMessageExceptionFormatter("Commit {0} / {1} : found {2}, persist", null, new object[] { @object, typedObject, status })); if (!relation.IsTransient() && persistenceUnitManager.IsReferencingSupported()) { Net.Vpc.Upa.Persistence.UConnection b = executionContext.GetConnection(); b.ExecuteNonQuery(persistenceUnitManager.GetCreateRelationshipStatement(relation), null, null); } }
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) /* throws Net.Vpc.Upa.Exceptions.UPAException */ { Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledBinaryOperatorExpression o = (Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledBinaryOperatorExpression)oo; System.Text.StringBuilder sb = new System.Text.StringBuilder(); sb.Append('('); sb.Append(sqlManager.GetSQL(o.GetLeft(), qlContext, declarations)); sb.Append(GetOperatorString(o)); sb.Append(sqlManager.GetSQL(o.GetRight(), qlContext, declarations)); sb.Append(')'); return(sb.ToString()); }
public virtual string GetSQL(object oo, Net.Vpc.Upa.Persistence.EntityExecutionContext qlContext, Net.Vpc.Upa.Impl.Persistence.SQLManager sqlManager, Net.Vpc.Upa.Impl.Uql.ExpressionDeclarationList declarations) /* throws Net.Vpc.Upa.Exceptions.UPAException */ { Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledQLFunctionExpression o = (Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledQLFunctionExpression)oo; int argumentsCount = o.GetArgumentsCount(); object[] args = new object[argumentsCount]; for (int i = 0; i < args.Length; i++) { args[i] = Eval(o.GetArgument(i), qlContext); } return(sqlManager.GetMarshallManager().FormatSqlValue(o.GetHandler().Eval(new Net.Vpc.Upa.EvalContext(o.GetName(), args, qlContext.GetPersistenceUnit())))); }
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) /* throws Net.Vpc.Upa.Exceptions.UPAException */ { Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledInCollection o = (Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledInCollection)oo; Net.Vpc.Upa.Persistence.PersistenceStore qlm = qlContext.GetPersistenceStore(); System.Text.StringBuilder sb = new System.Text.StringBuilder(); int mySize = o.GetRightSize(); if (mySize == 0) { sb.Append("1 <> 1"); } else { if (mySize == 1) { sb.Append(sqlManager.GetSQL(o.GetLeft(), qlContext, declarations)); Net.Vpc.Upa.Impl.Uql.Compiledexpression.DefaultCompiledExpression e = o.GetRight(0); if (e == null || (e is Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledLiteral && ((Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledLiteral)e).GetValue() == null)) { sb.Append(" Is Null"); } else { sb.Append(" = "); sb.Append(sqlManager.GetSQL(e, qlContext, declarations)); } } else { sb.Append(sqlManager.GetSQL(o.GetLeft(), qlContext, declarations)); sb.Append(" In ("); for (int i = 0; i < mySize; i++) { if (i > 0) { sb.Append(","); } Net.Vpc.Upa.Impl.Uql.Compiledexpression.DefaultCompiledExpression e = o.GetRight(i); if (e == null) { sb.Append("Null"); } else { sb.Append(sqlManager.GetSQL(e, qlContext, declarations)); } } sb.Append(")"); } } return('(' + sb.ToString() + ')'); }
public override sealed void OnPreUpdate(Net.Vpc.Upa.Callbacks.UpdateEvent @event) /* throws Net.Vpc.Upa.Exceptions.UPAException */ { string name = @event.GetTrigger().GetName(); Net.Vpc.Upa.Persistence.EntityExecutionContext executioncontext = @event.GetContext(); if (AcceptUpdateTableHelper(@event)) { System.Collections.Generic.ICollection <Net.Vpc.Upa.Key> v = CreateUpdatedCollection(@event.GetEntity(), @event.GetFilterExpression()); if (!(v.Count == 0)) { executioncontext.SetObject(name + ":toUpdate", v); } } }
public virtual void CommitStorage(Net.Vpc.Upa.Persistence.EntityExecutionContext context) /* throws Net.Vpc.Upa.Exceptions.UPAException */ { Net.Vpc.Upa.Persistence.PersistenceStore persistenceStore = context.GetPersistenceStore(); Net.Vpc.Upa.Persistence.StructureStrategy option = persistenceStore.GetConnectionProfile().GetStructureStrategy(); switch (option) { case Net.Vpc.Upa.Persistence.StructureStrategy.DROP: { if (!persistenceStore.IsCreatedStorage()) { persistenceStore.CreateStorage(context); } else { persistenceStore.DropStorage(context); persistenceStore.DropStorage(context); persistenceStore.CreateStorage(context); } break; } case Net.Vpc.Upa.Persistence.StructureStrategy.CREATE: case Net.Vpc.Upa.Persistence.StructureStrategy.SYNCHRONIZE: { if (!persistenceStore.IsCreatedStorage()) { persistenceStore.CreateStorage(context); } break; } case Net.Vpc.Upa.Persistence.StructureStrategy.MANDATORY: { if (!persistenceStore.IsCreatedStorage()) { throw new Net.Vpc.Upa.Exceptions.NoSuchPersistenceUnitException(context.GetPersistenceUnit().GetName()); } // if (!isValidPersistenceUnit()) { // throw new NoSuchPersistenceUnitException(getName(), null); // } break; } case Net.Vpc.Upa.Persistence.StructureStrategy.IGNORE: { //do nothing break; } } }
public override string GetSQL(object oo, Net.Vpc.Upa.Persistence.EntityExecutionContext context, Net.Vpc.Upa.Impl.Persistence.SQLManager sqlManager, Net.Vpc.Upa.Impl.Uql.ExpressionDeclarationList declarations) /* throws Net.Vpc.Upa.Exceptions.UPAException */ { Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledSelect o = (Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledSelect)oo; System.Text.StringBuilder sb = new System.Text.StringBuilder("Select "); AppendDistinct(o, sb, context, sqlManager, declarations); AppendFields(o, sb, context, sqlManager, declarations); AppendFrom(o, sb, context, sqlManager, declarations); AppendJoins(o, sb, context, sqlManager, declarations); AppendWhere(o, sb, context, sqlManager, declarations); AppendGroupBy(o, sb, context, sqlManager, declarations); AppendHaving(o, sb, context, sqlManager, declarations); AppendOrderBy(o, sb, context, sqlManager, declarations); return(sb.ToString()); }
public FormulaUpdateProcessor(bool onPersist, System.Collections.Generic.IList <Net.Vpc.Upa.Field> fields, Net.Vpc.Upa.Expressions.Expression expr, Net.Vpc.Upa.Persistence.EntityExecutionContext context, Net.Vpc.Upa.Entity entity, Net.Vpc.Upa.Persistence.EntityOperationManager epm) { this.entityOperationManager = epm; this.entity = entity; this.expr = expr; this.context = context; this.onPersist = onPersist; this.persistenceUnit = entity.GetPersistenceUnit(); foreach (Net.Vpc.Upa.Field field in fields) { AddField(field); } isUpdateComplexValuesStatementSupported = persistenceUnit.GetPersistenceStore().GetProperties().GetBoolean("isUpdateComplexValuesStatementSupported", false); isUpdateComplexValuesIncludingUpdatedTableSupported = persistenceUnit.GetPersistenceStore().GetProperties().GetBoolean("isUpdateComplexValuesIncludingUpdatedTableSupported", false); }
public override string GetSQL(object oo, Net.Vpc.Upa.Persistence.EntityExecutionContext context, Net.Vpc.Upa.Impl.Persistence.SQLManager sqlManager, Net.Vpc.Upa.Impl.Uql.ExpressionDeclarationList declarations) /* throws Net.Vpc.Upa.Exceptions.UPAException */ { Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledDelete o = (Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledDelete)oo; Net.Vpc.Upa.Entity entityManager = context.GetPersistenceUnit().GetEntity(o.GetEntity().GetName()); System.Text.StringBuilder sb = new System.Text.StringBuilder("Delete From " + sqlManager.GetSQL(new Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledEntityName(o.GetEntity().GetName()), context, declarations)); if (o.GetEntityAlias() != null) { sb.Append(" ").Append(sqlManager.GetSQL(new Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledVar(o.GetEntityAlias()), context, declarations)); } if (o.GetCondition() != null && o.GetCondition().IsValid()) { sb.Append(" Where ").Append(sqlManager.GetSQL(o.GetCondition(), context, declarations)); } return(sb.ToString()); }
public override void Persist(Net.Vpc.Upa.Persistence.EntityExecutionContext executionContext, Net.Vpc.Upa.PersistenceState status) /* throws System.Exception, Net.Vpc.Upa.Exceptions.UPAException */ { Net.Vpc.Upa.Index index = (Net.Vpc.Upa.Index)@object; Net.Vpc.Upa.Impl.Persistence.DefaultPersistenceStore persistenceUnitManager = (Net.Vpc.Upa.Impl.Persistence.DefaultPersistenceStore)executionContext.GetPersistenceStore(); if (!persistenceUnitManager.IsView(index.GetEntity())) { log.TraceEvent(System.Diagnostics.TraceEventType.Verbose, 60, Net.Vpc.Upa.Impl.FwkConvertUtils.LogMessageExceptionFormatter("Commit {0} / {1} : found {2}, persist", null, new object[] { @object, typedObject, status })); Net.Vpc.Upa.Persistence.UConnection b = executionContext.GetConnection(); if (status == Net.Vpc.Upa.PersistenceState.DIRTY) { b.ExecuteNonQuery(persistenceUnitManager.GetDropIndexStatement(index), null, null); } b.ExecuteNonQuery(persistenceUnitManager.GetCreateIndexStatement(index), null, null); } }
public virtual bool CommitStructure() /* throws Net.Vpc.Upa.Exceptions.UPAException */ { Net.Vpc.Upa.Persistence.EntityExecutionContext context = ((Net.Vpc.Upa.Impl.DefaultPersistenceUnit)persistenceUnit).CreateContext(Net.Vpc.Upa.Persistence.ContextOperation.CREATE_PERSISTENCE_NAME, null); Net.Vpc.Upa.Impl.FwkConvertUtils.ListSort(storage, structureCommitComparator); bool someCommit = false; foreach (Net.Vpc.Upa.Impl.Persistence.StructureCommit next in storage) { if (next.Commit(context)) { someCommit = true; } } storage.Clear(); return(someCommit); }
public CustomUpdateQueryExecutor(Net.Vpc.Upa.Impl.Persistence.DefaultPersistenceStore defaultPersistenceStore, System.Collections.Generic.IDictionary <string, object> finalHints, Net.Vpc.Upa.Expressions.Update baseExpression, System.Collections.Generic.IDictionary <string, object> parametersByName, System.Collections.Generic.IDictionary <int?, object> parametersByIndex, bool updatable, Net.Vpc.Upa.Filters.FieldFilter defaultFieldFilter, Net.Vpc.Upa.Persistence.EntityExecutionContext context, System.Collections.Generic.IList <Net.Vpc.Upa.Expressions.VarVal> complexVals, Net.Vpc.Upa.Entity entity, string entityName, Net.Vpc.Upa.Persistence.ResultMetaData metadata) { this.defaultPersistenceStore = defaultPersistenceStore; this.finalHints = finalHints; this.baseExpression = baseExpression; this.parametersByName = parametersByName; this.parametersByIndex = parametersByIndex; this.updatable = updatable; this.defaultFieldFilter = defaultFieldFilter; this.context = context; this.complexVals = complexVals; this.entity = entity; this.entityName = entityName; this.metadata = metadata; this.connection = context.GetConnection(); }
public override string GetSQL(object oo, Net.Vpc.Upa.Persistence.EntityExecutionContext context, Net.Vpc.Upa.Impl.Persistence.SQLManager sqlManager, Net.Vpc.Upa.Impl.Uql.ExpressionDeclarationList declarations) /* throws Net.Vpc.Upa.Exceptions.UPAException */ { Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledEntityName o = (Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledEntityName)oo; Net.Vpc.Upa.Persistence.PersistenceStore persistenceStore = context.GetPersistenceStore(); string entityName = o.GetName(); Net.Vpc.Upa.Entity e = context.GetPersistenceUnit().GetEntity(entityName); if (o.IsUseView() && e.NeedsView() && persistenceStore.IsViewSupported()) { return(persistenceStore.GetValidIdentifier(persistenceStore.GetPersistenceName(e, Net.Vpc.Upa.Persistence.PersistenceNameType.IMPLICIT_VIEW))); } else { return(persistenceStore.GetValidIdentifier(persistenceStore.GetPersistenceName(e))); } }
public override sealed void OnRemove(Net.Vpc.Upa.Callbacks.RemoveEvent @event) /* throws Net.Vpc.Upa.Exceptions.UPAException */ { Net.Vpc.Upa.Persistence.EntityExecutionContext executionContext = @event.GetContext(); string name = @event.GetTrigger().GetName(); System.Collections.Generic.ICollection <Net.Vpc.Upa.Key> collection = (System.Collections.Generic.ICollection <Net.Vpc.Upa.Key>)executionContext.GetObject <T>(name + ":toDelete"); if (collection == null) { return; } executionContext.Remove(name + ":toDelete"); if (!(collection.Count == 0)) { AfterDeleteHelper(@event, CreateInCollection(@event.GetEntity(), collection)); } }
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) /* throws Net.Vpc.Upa.Exceptions.UPAException */ { Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledInSelection o = (Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledInSelection)oo; Net.Vpc.Upa.Impl.Uql.Compiledexpression.DefaultCompiledExpression[] left = o.GetLeft(); Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledSelect query = o.GetSelection(); if (left.Length == 1) { string q = sqlManager.GetSQL(left[0], qlContext, declarations) + " in (" + sqlManager.GetSQL(query, qlContext, declarations) + ")"; return('(' + q + ')'); } Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledUplet uplet = new Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledUplet(left); System.Text.StringBuilder stringBuffer = new System.Text.StringBuilder(sqlManager.GetSQL(uplet, qlContext, declarations)); stringBuffer.Append(" In ("); stringBuffer.Append(sqlManager.GetSQL(query, qlContext, declarations)); stringBuffer.Append(")"); return('(' + stringBuffer.ToString() + ')'); }