/** * * @param field * @param id * @param object * @return * @throws UPAException */ public virtual bool IsAllowedWrite(Net.Vpc.Upa.Field field, object id, object @object) /* throws Net.Vpc.Upa.Exceptions.UPAException */ { Net.Vpc.Upa.EntitySecurityManager s = field.GetEntity().GetEntitySecurityManager(); if (s != null) { return(s.IsAllowedWrite(field, id, @object)); } return(IsAllowedKey(field.GetEntity(), "Update")); }
public virtual bool IsAllowedRead(Net.Vpc.Upa.Field field) /* throws Net.Vpc.Upa.Exceptions.UPAException */ { Net.Vpc.Upa.EntitySecurityManager s = field.GetEntity().GetEntitySecurityManager(); if (s != null) { return(s.IsAllowedRead(field)); } return(IsAllowedKey(field.GetEntity(), "Load")); }
public virtual Net.Vpc.Upa.Impl.Persistence.RebuildExpressionInfo RebuildExpression(Net.Vpc.Upa.ExpressionFormula persistFormula) { Net.Vpc.Upa.Expressions.Expression e = ((Net.Vpc.Upa.ExpressionFormula)persistFormula).GetExpression(); Net.Vpc.Upa.Impl.Persistence.RebuildExpressionInfo rr = new Net.Vpc.Upa.Impl.Persistence.RebuildExpressionInfo(); rr.initialFormula = ((Net.Vpc.Upa.ExpressionFormula)persistFormula); Net.Vpc.Upa.Expressions.Expression e0 = e; Net.Vpc.Upa.Persistence.ExpressionCompilerConfig config = new Net.Vpc.Upa.Persistence.ExpressionCompilerConfig(); config.SetExpandEntityFilter(false); //this is needed not to fire "this" alias usage exception config.SetThisAlias("this"); config.BindAliastoEntity("this", field.GetEntity().GetName()); Net.Vpc.Upa.Impl.Uql.Compiledexpression.DefaultCompiledExpression ce = null; Net.Vpc.Upa.ExpressionManager expressionManager = field.GetEntity().GetPersistenceUnit().GetExpressionManager(); try { ce = (Net.Vpc.Upa.Impl.Uql.Compiledexpression.DefaultCompiledExpression)expressionManager.CompileExpression(e, config); } catch (System.ArgumentException ex) { if ((ex).Message.StartsWith("No enclosing Select found for")) { Net.Vpc.Upa.Expressions.Select ss = new Net.Vpc.Upa.Expressions.Select(); ss.Field(e).From(field.GetEntity().GetName(), "this2"); Net.Vpc.Upa.Expressions.Expression w = null; foreach (Net.Vpc.Upa.Field primaryField in field.GetEntity().GetPrimaryFields()) { Net.Vpc.Upa.Expressions.Expression pfe = new Net.Vpc.Upa.Expressions.Equals(new Net.Vpc.Upa.Expressions.UserExpression("this." + primaryField.GetName()), new Net.Vpc.Upa.Expressions.UserExpression("this2." + primaryField.GetName())); if (w == null) { w = pfe; } else { w = new Net.Vpc.Upa.Expressions.And(w, pfe); } } Net.Vpc.Upa.Impl.Uql.Util.UQLUtils.ReplaceThisVar(ss, "this2", expressionManager); ss.Where(w); e = ss; } else { throw ex; } } //throw new IllegalArgumentException("No enclosing Select found for " + v) if (ce == null) { ce = (Net.Vpc.Upa.Impl.Uql.Compiledexpression.DefaultCompiledExpression)expressionManager.CompileExpression(e, config); rr.compiledExpression = ce; rr.rebuiltFormula = (new Net.Vpc.Upa.ExpressionFormula(e)); } else { rr.compiledExpression = ce; } rr.expression = e; return(rr); }
public virtual int CompareTo(object other) { if (other == this) { return(0); } if (other == null) { return(1); } Net.Vpc.Upa.Field f = (Net.Vpc.Upa.Field)other; Net.Vpc.Upa.NamingStrategy comp = GetEntity().GetPersistenceUnit().GetNamingStrategy(); string s1 = entity != null?comp.GetUniformValue(entity.GetName()) : ""; string s2 = f.GetName() != null?comp.GetUniformValue(f.GetEntity().GetName()) : ""; int i = s1.CompareTo(s2); if (i != 0) { return(i); } else { string s3 = GetName() != null?comp.GetUniformValue(GetName()) : ""; string s4 = f.GetName() != null?comp.GetUniformValue(f.GetName()) : ""; i = s3.CompareTo(s4); return(i); } }
public virtual string GetNewValue(Net.Vpc.Upa.Field field) /* throws Net.Vpc.Upa.Exceptions.UPAException */ { Net.Vpc.Upa.Entity entity = field.GetEntity(); string idName = field.GetName(); string goodId = null; for (int i = 0; i < asynchNbrTry; i++) { System.Collections.Generic.SortedSet <string> requestedIds = new System.Collections.Generic.SortedSet <string>(); Net.Vpc.Upa.Expressions.InCollection idsSet = new Net.Vpc.Upa.Expressions.InCollection(new Net.Vpc.Upa.Expressions.Var(idName)); for (int j = 0; j < synchNbrTry; j++) { string id = (string)GenerateValue(field); idsSet.Add(new Net.Vpc.Upa.Expressions.Literal(id)); requestedIds.Add(id); } System.Collections.Generic.IList <Net.Vpc.Upa.Record> recordList = entity.CreateQuery((new Net.Vpc.Upa.Expressions.Select()).From(entity.GetName()).Field(new Net.Vpc.Upa.Expressions.Var(idName)).Where(idsSet)).GetRecordList(); System.Collections.Generic.SortedSet <string> foundIds = new System.Collections.Generic.SortedSet <string>(); foreach (Net.Vpc.Upa.Record record in recordList) { foundIds.Add(record.GetString()); } Net.Vpc.Upa.Impl.FwkConvertUtils.SetRemoveRange(requestedIds, foundIds); if ((requestedIds.Count == 0)) { continue; } goodId = Net.Vpc.Upa.Impl.FwkConvertUtils.CollectionSetFirst <string>(requestedIds); break; } return(goodId); }
public virtual Net.Vpc.Upa.Types.I18NString GetFieldString(Net.Vpc.Upa.Field field) { Net.Vpc.Upa.Entity entityName = (field != null) ? (field.GetEntity() != null) ? field.GetEntity() : field.GetEntity() : null; string fieldName = (field != null) ? field.GetName() : null; return(GetFieldListString(entityName).Append(Key(fieldName))); }
public virtual bool ContainsField(Net.Vpc.Upa.Field item) { Net.Vpc.Upa.Entity entity = item.GetEntity(); Net.Vpc.Upa.Package module = entity.GetParent(); string s = (module == null ? "/" : module.GetPath() + "/") + entity.GetName() + "/" + item.GetName(); return(fields.ContainsKey(s)); }
public virtual void UnregisterField(Net.Vpc.Upa.Field item) { Net.Vpc.Upa.Entity entity = item.GetEntity(); Net.Vpc.Upa.Package module = entity.GetParent(); string s = (module == null ? "/" : module.GetPath() + "/") + entity.GetName() + "/" + item.GetName(); fields.Remove(s); }
private void BindRelation(Net.Vpc.Upa.Entity masterEntity) { Net.Vpc.Upa.Types.DataType dataType = field.GetDataType(); if (dataType is Net.Vpc.Upa.Impl.SerializableOrManyToOneType) { field.SetDataType(new Net.Vpc.Upa.Types.ManyToOneType(dataType.GetName(), dataType.GetPlatformType(), masterEntity.GetName(), true, dataType.IsNullable())); field.SetTypeTransform(null); field.SetTypeTransform(new Net.Vpc.Upa.Impl.Transform.IdentityDataTypeTransform(field.GetDataType())); Net.Vpc.Upa.DefaultRelationshipDescriptor relationDescriptor = new Net.Vpc.Upa.DefaultRelationshipDescriptor(); relationDescriptor.SetBaseField(field.GetName()); relationDescriptor.SetTargetEntityType(masterEntity.GetEntityType()); relationDescriptor.SetTargetEntity(masterEntity.GetName()); relationDescriptor.SetSourceEntityType(field.GetEntity().GetEntityType()); relationDescriptor.SetSourceEntity(field.GetEntity().GetName()); field.GetPersistenceUnit().AddRelationship(relationDescriptor); } }
public virtual void RegisterField(Net.Vpc.Upa.Field item) { Net.Vpc.Upa.Impl.DefaultEntity entity = (Net.Vpc.Upa.Impl.DefaultEntity)item.GetEntity(); Net.Vpc.Upa.Package module = entity.GetParent(); string s = (module == null ? "/" : module.GetPath() + "/") + entity.GetName() + "/" + item.GetName(); fields[s] = item; entity.fieldsMap[entity.GetPersistenceUnit().GetNamingStrategy().GetUniformValue(item.GetName())] = (Net.Vpc.Upa.Field)item; }
public virtual string Convert(string v) { if (v.Equals("#")) { return(System.Convert.ToString(replacement)); } if (record != null && record.IsSet(v)) { return(System.Convert.ToString(record.GetObject <T>(v))); } Net.Vpc.Upa.Expressions.Select s = new Net.Vpc.Upa.Expressions.Select(); s.Field(new Net.Vpc.Upa.Expressions.UserExpression(v), "customValue"); return(System.Convert.ToString(field.GetEntity().GetPersistenceUnit().CreateQuery(s).GetSingleValue())); }
protected internal virtual object GetNewValue(Net.Vpc.Upa.Field field, Net.Vpc.Upa.Record record, Net.Vpc.Upa.Persistence.EntityExecutionContext executionContext) /* throws Net.Vpc.Upa.Exceptions.UPAException */ { Net.Vpc.Upa.Entity entity = field.GetEntity(); Net.Vpc.Upa.Entity seq = entity.GetPersistenceUnit().GetEntity(Net.Vpc.Upa.Impl.PrivateSequence.ENTITY_NAME); Net.Vpc.Upa.Impl.SequenceManager sm = new Net.Vpc.Upa.Impl.EntitySequenceManager(seq); string groupString = Eval(this.group, "{#}", record); // String fieldName = field.getName(); // while (true) { object nextValue = GetNewValue(sm, groupString, record); // long count = entity.getEntityCount(new Equals(new Var(fieldName), nextValue)); // if (count == 0) { return(nextValue); }
public virtual long GetNewValue(Net.Vpc.Upa.Field field) /* throws Net.Vpc.Upa.Exceptions.UPAException */ { Net.Vpc.Upa.Entity entity = field.GetEntity(); Net.Vpc.Upa.Expressions.Select s = new Net.Vpc.Upa.Expressions.Select().From(entity.GetName()); s.Field(new Net.Vpc.Upa.Expressions.Plus(new Net.Vpc.Upa.Expressions.Coalesce(new Net.Vpc.Upa.Expressions.Max(new Net.Vpc.Upa.Expressions.Var(field.GetName())), new Net.Vpc.Upa.Expressions.Literal(0)), new Net.Vpc.Upa.Expressions.Literal(1)), "next"); Net.Vpc.Upa.Record next = field.GetPersistenceUnit().CreateQuery(s).GetRecord(); if (next != null) { return(next.GetLong("next")); } else { return(0); } }
private string GetNewValue(Net.Vpc.Upa.Field field) /* throws Net.Vpc.Upa.Exceptions.UPAException */ { Net.Vpc.Upa.Entity entity = field.GetEntity(); string idName = field.GetName(); Net.Vpc.Upa.Entity seq = entity.GetPersistenceUnit().GetEntity(Net.Vpc.Upa.Impl.PrivateSequence.ENTITY_NAME); Net.Vpc.Upa.Impl.SequenceManager sm = new Net.Vpc.Upa.Impl.EntitySequenceManager(seq); string sequenceGroup = Eval(field, this.group, "{#}"); while (true) { string nextIdString = Eval(field, this.format, sm.NextValue(name, sequenceGroup, this.initialValue, this.allocationSize)); long count = entity.GetEntityCount(new Net.Vpc.Upa.Expressions.Equals(new Net.Vpc.Upa.Expressions.Var(idName), nextIdString)); if (count == 0) { return(nextIdString); } } }
public TableSequenceIdentityPersister(Net.Vpc.Upa.Field field, Net.Vpc.Upa.Sequence sequence) { this.initialValue = sequence == null ? 1 : sequence.GetInitialValue(); this.allocationSize = (sequence == null) ? 50 : sequence.GetAllocationSize(); this.name = (sequence == null) ? null : sequence.GetName(); this.group = (sequence == null) ? null : sequence.GetGroup(); this.format = (sequence == null) ? null : sequence.GetFormat(); this.field = field; if (this.format == null) { this.format = "{#}"; } if (this.group == null) { this.group = format; } if (this.name == null) { this.name = field.GetEntity().GetName() + "." + field.GetName(); } }
public MultiRecordList(Net.Vpc.Upa.Impl.Persistence.QueryExecutor queryExecutor, bool forUpdate) : base(queryExecutor) { this.forUpdate = forUpdate; this.fields = queryExecutor.GetFields(); this.entities = new Net.Vpc.Upa.Entity[this.fields.Length]; this.recordName = new string[this.fields.Length]; this.currentRecords = new System.Collections.Generic.Dictionary <string, Net.Vpc.Upa.Impl.Persistence.MultiRecordListTracker>(); this.setterToProp = new System.Collections.Generic.Dictionary <string, System.Collections.Generic.IDictionary <string, Net.Vpc.Upa.Impl.Persistence.FieldTracking> >(); int fieldsCount = fields.Length; for (int i = 0; i < fieldsCount; i++) { Net.Vpc.Upa.Impl.Persistence.NativeField namedExpression = fields[i]; Net.Vpc.Upa.Field field = namedExpression.GetField(); entities[i] = field == null ? null : field.GetEntity(); if (namedExpression.GetGroupName() != null) { recordName[i] = namedExpression.GetGroupName(); } else if (entities[i] != null) { recordName[i] = entities[i].GetName(); } System.Collections.Generic.IDictionary <string, Net.Vpc.Upa.Impl.Persistence.FieldTracking> stringFieldTrackingMap = Net.Vpc.Upa.Impl.FwkConvertUtils.GetMapValue <string, System.Collections.Generic.IDictionary <string, Net.Vpc.Upa.Impl.Persistence.FieldTracking> >(setterToProp, recordName[i]); if (stringFieldTrackingMap == null) { stringFieldTrackingMap = new System.Collections.Generic.Dictionary <string, Net.Vpc.Upa.Impl.Persistence.FieldTracking>(); setterToProp[recordName[i]] = stringFieldTrackingMap; } if (field != null) { Net.Vpc.Upa.Impl.Persistence.FieldTracking t = new Net.Vpc.Upa.Impl.Persistence.FieldTracking(field.GetName(), Net.Vpc.Upa.Impl.Util.PlatformUtils.SetterName(field.GetName()), i); stringFieldTrackingMap[t.GetSetterMethodName()] = t; } } columns = this.fields.Length; }
public virtual bool IsAllowedWrite(Net.Vpc.Upa.Field field, object id, object @object) /* throws Net.Vpc.Upa.Exceptions.UPAException */ { return(IsAllowedKey(field.GetEntity(), "Update")); }
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.CompiledUpdate o = (Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledUpdate)oo; Net.Vpc.Upa.Persistence.PersistenceStore persistenceStore = context.GetPersistenceStore(); Net.Vpc.Upa.PersistenceUnit pu = context.GetPersistenceUnit(); Net.Vpc.Upa.Entity entity = pu.GetEntity(o.GetEntity().GetName()); // String persistenceName = persistenceStore.getPersistenceName(entity); System.Text.StringBuilder sb = new System.Text.StringBuilder("Update " + sqlManager.GetSQL(new Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledEntityName(entity.GetName()), context, declarations)); string tableAlias = o.GetEntityAlias(); if (tableAlias != null) { sb.Append(" "); sb.Append(sqlManager.GetSQL(new Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledVar(tableAlias), context, declarations)); } sb.Append(" Set "); bool isFirst = true; int max = o.CountFields(); for (int i = 0; i < max; i++) { Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledVar vv = o.GetField(i); Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledVar ev = null; Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledVar fv = null; if (vv.GetChild() == null) { ev = null; fv = vv; } else { ev = vv; fv = (Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledVar)vv.GetChild(); } Net.Vpc.Upa.Impl.Uql.Compiledexpression.DefaultCompiledExpression fieldValue = o.GetFieldValue(i); // Object referrer = vv.getReferrer(); Net.Vpc.Upa.Field f = ((Net.Vpc.Upa.Field)fv.GetReferrer()); Net.Vpc.Upa.Entity entityManager = f.GetEntity(); System.Collections.Generic.IList <Net.Vpc.Upa.PrimitiveField> primFields = entityManager.ToPrimitiveFields <Net.Vpc.Upa.EntityPart>(new System.Collections.Generic.List <Net.Vpc.Upa.EntityPart>(new[] { (Net.Vpc.Upa.EntityPart)f })); foreach (Net.Vpc.Upa.PrimitiveField primField in primFields) { if (isFirst) { isFirst = false; } else { sb.Append(", "); } if (ev != null) { sb.Append(sqlManager.GetSQL(new Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledVar(ev.GetName()), context, declarations)).Append("."); } sb.Append(sqlManager.GetSQL(new Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledVar(primField), context, declarations)); sb.Append("=").Append("(").Append(sqlManager.GetSQL(fieldValue, context, declarations)).Append(")"); } } if (o.GetCondition() != null && o.GetCondition().IsValid()) { sb.Append(" Where ").Append(sqlManager.GetSQL(o.GetCondition(), context, declarations)); } if (persistenceStore.IsViewSupported() && entity.NeedsView() && o.GetEntity().IsUseView()) { string implicitTableAlias = persistenceStore.GetPersistenceName("IT_" + entity.GetName(), Net.Vpc.Upa.Persistence.PersistenceNameType.ALIAS); sb.Append(" "); sb.Append(sqlManager.GetSQL(new Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledEntityName(entity.GetName()), context, declarations)).Append(" ").Append(implicitTableAlias).Append(",").Append(sqlManager.GetSQL(new Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledEntityName(entity.GetName(), true), context, declarations)).Append(" ").Append(sqlManager.GetSQL(new Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledVar(tableAlias), context, declarations)); } // if (extraFrom != null) return(sb.ToString()); }
public virtual bool IsAllowedRead(Net.Vpc.Upa.Field field) /* throws Net.Vpc.Upa.Exceptions.UPAException */ { return(IsAllowedKey(field.GetEntity(), "Load")); }
public DatabaseIdentityPersister(Net.Vpc.Upa.Field field) { this.field = field; identityConstraintsEnabledProperty = "IdentityConstraintsEnabled." + field.GetEntity().GetName(); }
public virtual bool AddField(Net.Vpc.Upa.Field f) { if (inUseFields.Contains(f)) { return(false); } Net.Vpc.Upa.Formula formula = onPersist ? f.GetPersistFormula() : f.GetUpdateFormula(); Net.Vpc.Upa.Impl.Persistence.ValidationPass pass = null; int formulaPassInteger = onPersist ? f.GetPersistFormulaOrder() : f.GetUpdateFormulaOrder(); // passIndexes.add(formulaPassInteger); Net.Vpc.Upa.Impl.Persistence.ValidationPass[] passArray = Net.Vpc.Upa.Impl.FwkConvertUtils.GetMapValue <int?, Net.Vpc.Upa.Impl.Persistence.ValidationPass[]>(orderedPasses, formulaPassInteger); if (passArray == null) { orderedPasses[formulaPassInteger] = passArray = new Net.Vpc.Upa.Impl.Persistence.ValidationPass[((Net.Vpc.Upa.Impl.Persistence.ValidationPassType[])System.Enum.GetValues(typeof(Net.Vpc.Upa.Impl.Persistence.ValidationPassType))).Length]; } int pass1 = formulaPassInteger; if (formula is Net.Vpc.Upa.CustomUpdaterFormula) { pass = passArray[((int)Net.Vpc.Upa.Impl.Persistence.ValidationPassType.MANUAL_VALIDATION)]; if (pass == null) { pass = passArray[((int)Net.Vpc.Upa.Impl.Persistence.ValidationPassType.MANUAL_VALIDATION)] = new Net.Vpc.Upa.Impl.Persistence.ValidationPass(pass1, Net.Vpc.Upa.Impl.Persistence.ValidationPassType.MANUAL_VALIDATION); size++; } } else if (formula is Net.Vpc.Upa.CustomFormula) { pass = passArray[((int)Net.Vpc.Upa.Impl.Persistence.ValidationPassType.CUSTOM_VALIDATION)]; if (pass == null) { pass = passArray[((int)Net.Vpc.Upa.Impl.Persistence.ValidationPassType.CUSTOM_VALIDATION)] = new Net.Vpc.Upa.Impl.Persistence.ValidationPass(pass1, Net.Vpc.Upa.Impl.Persistence.ValidationPassType.CUSTOM_VALIDATION); size++; } } else if (!entityOperationManager.GetPersistenceStore().IsComplexSelectSupported()) { Net.Vpc.Upa.Expressions.Expression fe = GetFieldExpression(f, onPersist); Net.Vpc.Upa.Impl.Uql.Compiledexpression.DefaultCompiledExpression ce = (Net.Vpc.Upa.Impl.Uql.Compiledexpression.DefaultCompiledExpression)entity.Compile(fe); bool found = ce.FindFirstExpression <T>(Net.Vpc.Upa.Impl.Uql.Compiledfilters.CompiledExpressionHelper.QUERY_STATEMENT_FILTER) != default(T); if (found) { pass = passArray[((int)Net.Vpc.Upa.Impl.Persistence.ValidationPassType.ITERATIVE_VALIDATION)]; if (pass == null) { pass = passArray[((int)Net.Vpc.Upa.Impl.Persistence.ValidationPassType.ITERATIVE_VALIDATION)] = new Net.Vpc.Upa.Impl.Persistence.ValidationPass(pass1, Net.Vpc.Upa.Impl.Persistence.ValidationPassType.ITERATIVE_VALIDATION); size++; } } else { pass = passArray[((int)Net.Vpc.Upa.Impl.Persistence.ValidationPassType.DEFAULT_VALIDATION)]; if (pass == null) { pass = passArray[((int)Net.Vpc.Upa.Impl.Persistence.ValidationPassType.DEFAULT_VALIDATION)] = new Net.Vpc.Upa.Impl.Persistence.ValidationPass(pass1, Net.Vpc.Upa.Impl.Persistence.ValidationPassType.DEFAULT_VALIDATION); size++; } } } else { pass = passArray[((int)Net.Vpc.Upa.Impl.Persistence.ValidationPassType.DEFAULT_VALIDATION)]; if (pass == null) { pass = passArray[((int)Net.Vpc.Upa.Impl.Persistence.ValidationPassType.DEFAULT_VALIDATION)] = new Net.Vpc.Upa.Impl.Persistence.ValidationPass(pass1, Net.Vpc.Upa.Impl.Persistence.ValidationPassType.DEFAULT_VALIDATION); size++; } } pass.GetFields().Add(f); inUseFields.Add(f); System.Collections.Generic.ICollection <Net.Vpc.Upa.PrimitiveField> dependency = (System.Collections.Generic.ICollection <Net.Vpc.Upa.PrimitiveField>)f.GetProperties().GetObject <T>(onPersist ? Net.Vpc.Upa.Impl.DefaultEntity.PERSIST_DEPENDENT_FIELDS : Net.Vpc.Upa.Impl.DefaultEntity.UPDATE_DEPENDENT_FIELDS); if (dependency != null) { foreach (Net.Vpc.Upa.PrimitiveField aDependency in dependency) { Net.Vpc.Upa.PrimitiveField df = (Net.Vpc.Upa.PrimitiveField)aDependency; //include only dependent fields from the same entity if (df.GetEntity().GetName().Equals(f.GetEntity().GetName())) { // add only formulas fields that are validateSupported if (onPersist) { Net.Vpc.Upa.Formula ff = df.GetPersistFormula(); if (ff != null && df.GetModifiers().Contains(Net.Vpc.Upa.FieldModifier.PERSIST_FORMULA)) { AddField(df); } } else { Net.Vpc.Upa.Formula ff = df.GetUpdateFormula(); if (ff != null && df.GetModifiers().Contains(Net.Vpc.Upa.FieldModifier.UPDATE_FORMULA)) { AddField(df); } } } } } return(true); }
public virtual Net.Vpc.Upa.Expressions.CompiledExpression CreateConditionForDeepSearch(Net.Vpc.Upa.Impl.Uql.Compiledexpression.DefaultCompiledExpression alias, Net.Vpc.Upa.Impl.Uql.Compiledexpression.DefaultCompiledExpression id, bool includeId, Net.Vpc.Upa.Field field, string pathSep) /* throws Net.Vpc.Upa.Exceptions.UPAException */ { alias = alias.Copy(); if (alias is Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledVar) { Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledVar cv = (Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledVar)alias; if (cv.GetReferrer() is Net.Vpc.Upa.Entity) { Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledVar v = new Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledVar(field.GetName()); ((Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledVar)alias).SetChild(v); } else { throw new System.ArgumentException("Expected " + field.GetEntity().GetName() + " var name"); } } else { throw new System.ArgumentException("Expected " + field.GetEntity().GetName() + " var name"); } id = id.Copy(); System.Collections.Generic.IList <Net.Vpc.Upa.Field> primaryFields = field.GetEntity().GetPrimaryFields(); if ((primaryFields).Count > 1) { throw new System.ArgumentException("Composite ID unsupported for function treeancestor"); } Net.Vpc.Upa.Types.DataType pkType = primaryFields[0].GetDataType(); Net.Vpc.Upa.Impl.Uql.Compiledexpression.DefaultCompiledExpression strId = null; if (pkType is Net.Vpc.Upa.Types.IntType) { strId = new Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledI2V(id); } else if (pkType is Net.Vpc.Upa.Types.LongType) { strId = new Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledI2V(id); } else if (pkType is Net.Vpc.Upa.Types.ShortType) { strId = new Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledI2V(id); } else if (pkType is Net.Vpc.Upa.Types.ByteType) { strId = new Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledI2V(id); } else if (pkType is Net.Vpc.Upa.Types.FloatType) { strId = new Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledD2V(id); } else if (pkType is Net.Vpc.Upa.Types.DoubleType) { strId = new Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledD2V(id); } else if (pkType is Net.Vpc.Upa.Types.StringType) { strId = id; } else { strId = new Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledCast(id, Net.Vpc.Upa.Impl.Transform.IdentityDataTypeTransform.STRING); } if (includeId) { return(new Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledOr(new Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledLike(alias.Copy(), new Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledConcat(new Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledLiteral("%" + pathSep), strId.Copy())), new Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledLike(alias.Copy(), new Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledConcat(new Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledLiteral("%" + pathSep), strId.Copy(), new Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledLiteral(pathSep + "%"))))); } else { return(new Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledLike(alias.Copy(), new Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledConcat(new Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledLiteral("%" + pathSep), strId.Copy(), new Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledLiteral(pathSep + "%")))); } }
public virtual string GetPersistenceName(object source, Net.Vpc.Upa.Persistence.PersistenceNameType spec) /* throws Net.Vpc.Upa.Exceptions.UPAException */ { System.Collections.Generic.IList <Net.Vpc.Upa.Persistence.PersistenceNameType> types = new System.Collections.Generic.List <Net.Vpc.Upa.Persistence.PersistenceNameType>(); Net.Vpc.Upa.Impl.Persistence.UPAObjectAndSpec upaObjectAndSpec = new Net.Vpc.Upa.Impl.Persistence.UPAObjectAndSpec(source, spec); if (source is Net.Vpc.Upa.Entity) { Net.Vpc.Upa.Entity v = (Net.Vpc.Upa.Entity)source; if (spec == null) { string p = v.GetPersistenceName(); if (p == null) { p = v.GetName(); } foreach (Net.Vpc.Upa.Extensions.EntityExtensionDefinition extension in v.GetExtensionDefinitions()) { if (extension is Net.Vpc.Upa.Extensions.ViewEntityExtensionDefinition) { types.Add(Net.Vpc.Upa.Persistence.PersistenceNameType.VIEW); } if (extension is Net.Vpc.Upa.Extensions.UnionEntityExtensionDefinition) { types.Add(Net.Vpc.Upa.Persistence.PersistenceNameType.UNION_TABLE); } } types.Add(Net.Vpc.Upa.Persistence.PersistenceNameType.TABLE); return(ValidatePersistenceName(p, Net.Vpc.Upa.Persistence.PersistenceNameType.TABLE, v.GetName(), upaObjectAndSpec, types)); } if (Net.Vpc.Upa.Persistence.PersistenceNameType.PK_CONSTRAINT.Equals(spec)) { string p = v.GetShortName(); if (p == null) { p = v.GetPersistenceName(); } if (p == null) { p = v.GetName(); } types.Add(Net.Vpc.Upa.Persistence.PersistenceNameType.PK_CONSTRAINT); return(ValidatePersistenceName("PK_" + p, Net.Vpc.Upa.Persistence.PersistenceNameType.PK_CONSTRAINT, v.GetName(), upaObjectAndSpec, types)); } if (Net.Vpc.Upa.Persistence.PersistenceNameType.IMPLICIT_VIEW.Equals(spec)) { string p = v.GetPersistenceName(); if (p == null) { p = v.GetName(); } types.Add(Net.Vpc.Upa.Persistence.PersistenceNameType.IMPLICIT_VIEW); types.Add(Net.Vpc.Upa.Persistence.PersistenceNameType.TABLE); return(ValidatePersistenceName(p + "_IV", Net.Vpc.Upa.Persistence.PersistenceNameType.IMPLICIT_VIEW, v.GetName(), upaObjectAndSpec, types)); } } if (source is Net.Vpc.Upa.Index) { Net.Vpc.Upa.Index v = (Net.Vpc.Upa.Index)source; string p = v.GetPersistenceName(); if (p == null) { p = v.GetName(); } if (p == null) { string sn = v.GetEntity().GetShortName(); if (sn == null) { sn = v.GetEntity().GetName(); } System.Text.StringBuilder sb = new System.Text.StringBuilder("IX_").Append(sn); foreach (string field in v.GetFieldNames()) { sb.Append("_").Append(field); } p = sb.ToString(); } types.Add(Net.Vpc.Upa.Persistence.PersistenceNameType.INDEX); return(ValidatePersistenceName(p, Net.Vpc.Upa.Persistence.PersistenceNameType.INDEX, v.GetName(), upaObjectAndSpec, types)); } if (source is Net.Vpc.Upa.Relationship) { Net.Vpc.Upa.Relationship v = (Net.Vpc.Upa.Relationship)source; string p = v.GetPersistenceName(); if (p == null) { p = v.GetName(); } types.Add(Net.Vpc.Upa.Persistence.PersistenceNameType.FK_CONSTRAINT); return(ValidatePersistenceName(p, Net.Vpc.Upa.Persistence.PersistenceNameType.FK_CONSTRAINT, v.GetName(), upaObjectAndSpec, types)); } if (source is Net.Vpc.Upa.PrimitiveField) { Net.Vpc.Upa.Field v = (Net.Vpc.Upa.Field)source; string p = v.GetPersistenceName(); if (p == null) { p = v.GetName(); } types.Add(Net.Vpc.Upa.Persistence.PersistenceNameType.COLUMN); return(ValidatePersistenceName(p, Net.Vpc.Upa.Persistence.PersistenceNameType.COLUMN, v.GetEntity().GetName() + "." + v.GetName(), upaObjectAndSpec, types)); } if (source is string) { if (Net.Vpc.Upa.Persistence.PersistenceNameType.ALIAS.Equals(spec)) { return(ValidatePersistenceName((string)source, Net.Vpc.Upa.Persistence.PersistenceNameType.ALIAS, "aliasName", upaObjectAndSpec, types)); } else { return(ValidatePersistenceName((string)source, Net.Vpc.Upa.Persistence.PersistenceNameType.ALIAS, null, upaObjectAndSpec, types)); } } throw new System.ArgumentException("No Supported"); }