public virtual Net.Vpc.Upa.Record KeyToRecord(Net.Vpc.Upa.Key key) /* throws Net.Vpc.Upa.Exceptions.UPAException */ { if (key == null) { return(null); } Net.Vpc.Upa.Record ur = CreateRecord(); System.Collections.Generic.IList <Net.Vpc.Upa.Field> primaryFields = GetEntity().GetPrimaryFields(); if (key == null) { foreach (Net.Vpc.Upa.Field aF in primaryFields) { ur.SetObject(aF.GetName(), null); } } else { object[] uk = key.GetValue(); for (int i = 0; i < (primaryFields).Count; i++) { ur.SetObject(primaryFields[i].GetName(), uk[i]); } } return(ur); }
public override string GetDescription() { if (desc == null) { try { Net.Vpc.Upa.Entity _entity = GetEntity(); Net.Vpc.Upa.Key ukey = _entity.GetBuilder().IdToKey(key); System.Collections.Generic.IList <Net.Vpc.Upa.Field> f = _entity.GetPrimaryFields(); System.Text.StringBuilder descsb = new System.Text.StringBuilder(); object[] values = ukey.GetValue(); for (int i = 0; i < (f).Count; i++) { if (i > 0) { descsb.Append(" "); descsb.Append(" and "); descsb.Append(" "); } if (values[i] == null) { descsb.Append(f[i].GetI18NString()).Append(" undefined operator "); } else { descsb.Append(f[i].GetI18NString()).Append(" = ").Append(new Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledLiteral(values[i], Net.Vpc.Upa.Impl.Util.UPAUtils.GetTypeTransformOrIdentity(f[i])).ToString()); } } desc = descsb.ToString(); } catch (Net.Vpc.Upa.Exceptions.UPAException ex) { desc = ""; } } return(desc); }
public virtual object GetId(Net.Vpc.Upa.Key unstructuredKey) { if (unstructuredKey == null) { return(null); } return(CreateId(unstructuredKey.GetValue())); }
public virtual object GetId(Net.Vpc.Upa.Key unstructuredKey) { if (nfo.GetPlatformType().IsInstanceOfType(unstructuredKey)) { return(unstructuredKey); } Net.Vpc.Upa.Key o = (Net.Vpc.Upa.Key)nfo.NewInstance(); o.SetValue(unstructuredKey.GetValue()); return(o); }
public virtual string ToStringKey(Net.Vpc.Upa.Key key) /* throws Net.Vpc.Upa.Exceptions.UPAException */ { if (key == null) { return(""); } System.Text.StringBuilder s = new System.Text.StringBuilder(); object[] kvalue = key.GetValue(); for (int i = 0; i < kvalue.Length; i++) { if (i > 0) { s.Append(GetHierarchyPathSeparator()); } s.Append(kvalue[i].ToString()); } return(s.ToString()); }
public virtual Net.Vpc.Upa.Impl.Uql.Compiledexpression.DefaultCompiledExpression TranslateExpression(object x, Net.Vpc.Upa.Impl.Uql.ExpressionTranslationManager manager, Net.Vpc.Upa.Impl.Uql.ExpressionDeclarationList declarations) /* throws Net.Vpc.Upa.Exceptions.UPAException */ { Net.Vpc.Upa.Expressions.IdExpression o = (Net.Vpc.Upa.Expressions.IdExpression)x; Net.Vpc.Upa.Impl.Uql.Compiledexpression.DefaultCompiledExpression ret = null; Net.Vpc.Upa.Entity entity = null; if (o.GetEntity() != null) { entity = o.GetEntity(); } Net.Vpc.Upa.PersistenceUnit persistenceUnit = manager.GetPersistenceUnit(); if (entity == null && o.GetEntityName() != null) { entity = persistenceUnit.GetEntity(o.GetEntityName()); } if (entity == null && o.GetAlias() != null) { //check if alias System.Collections.Generic.IList <Net.Vpc.Upa.Impl.Uql.ExpressionDeclaration> dvalues = declarations.GetDeclarations(null); if (dvalues != null) { foreach (Net.Vpc.Upa.Impl.Uql.ExpressionDeclaration @ref in dvalues) { switch (@ref.GetReferrerType()) { case Net.Vpc.Upa.Impl.Uql.DecObjectType.ENTITY: { entity = persistenceUnit.GetEntity((string)@ref.GetReferrerName()); break; } } } } } if (entity == null && o.GetAlias() != null) { //check if entity if (persistenceUnit.ContainsEntity(o.GetAlias())) { entity = persistenceUnit.GetEntity(o.GetAlias()); } } if (entity == null) { throw new System.ArgumentException("Key enumeration must by associated to and entity"); } Net.Vpc.Upa.Key key = entity.GetBuilder().IdToKey(o.GetId()); object[] values = key == null ? null : key.GetValue(); Net.Vpc.Upa.Entity entity1 = o.GetEntity(); System.Collections.Generic.IList <Net.Vpc.Upa.PrimitiveField> f = entity1.ToPrimitiveFields <Net.Vpc.Upa.Field>(entity1.GetPrimaryFields()); for (int i = 0; i < (f).Count; i++) { Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledVar ppp = o.GetAlias() == null ? null : new Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledVar(o.GetAlias()); if (ppp == null) { ppp = new Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledVar(f[i].GetName()); } else { ppp.SetChild(new Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledVar(f[i].GetName())); } Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledEquals e = new Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledEquals(ppp, new Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledLiteral(values == null ? null : values[i], Net.Vpc.Upa.Impl.Util.UPAUtils.GetTypeTransformOrIdentity(f[i]))); ret = (ret == null) ? ((Net.Vpc.Upa.Impl.Uql.Compiledexpression.DefaultCompiledExpression)(e)) : new Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledAnd(ret, e); } if (ret == null) { ret = new Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledEquals(new Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledLiteral(1), new Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledLiteral(1)); } return(ret); }
public virtual Net.Vpc.Upa.Expressions.Expression GetSourceCondition(Net.Vpc.Upa.Expressions.Expression targetCondition, string sourceAlias, string targetAlias) /* throws Net.Vpc.Upa.Exceptions.UPAException */ { //Key Rkey=getTargetTable().getKeyForExpression(targetCondition); Net.Vpc.Upa.Field[] sourceFields = GetSourceRole().GetFields().ToArray(); Net.Vpc.Upa.Field[] targetFields = GetTargetRole().GetFields().ToArray(); if (targetCondition is Net.Vpc.Upa.Expressions.IdExpression) { Net.Vpc.Upa.Key Rkey = targetRole.GetEntity().GetBuilder().IdToKey(((Net.Vpc.Upa.Expressions.IdExpression)targetCondition).GetId()); if (sourceFields.Length == 1) { Net.Vpc.Upa.Expressions.Var lvar = (sourceAlias == null) ? new Net.Vpc.Upa.Expressions.Var(sourceFields[0].GetName()) : new Net.Vpc.Upa.Expressions.Var(new Net.Vpc.Upa.Expressions.Var(sourceAlias), sourceFields[0].GetName()); return(new Net.Vpc.Upa.Expressions.Equals(lvar, new Net.Vpc.Upa.Expressions.Literal(Rkey == null ? null : Rkey.GetValue()[0], targetFields[0].GetDataType()))); } else { Net.Vpc.Upa.Expressions.Expression a = null; for (int i = 0; i < sourceFields.Length; i++) { Net.Vpc.Upa.Expressions.Var lvar = (sourceAlias == null) ? new Net.Vpc.Upa.Expressions.Var(sourceFields[i].GetName()) : new Net.Vpc.Upa.Expressions.Var(new Net.Vpc.Upa.Expressions.Var(sourceAlias), sourceFields[i].GetName()); Net.Vpc.Upa.Expressions.Expression rvar = new Net.Vpc.Upa.Expressions.Literal(Rkey == null ? null : Rkey.GetObjectAt(i), targetFields[i].GetDataType()); Net.Vpc.Upa.Expressions.Expression e = new Net.Vpc.Upa.Expressions.Equals(lvar, rvar); a = a == null ? e : a; } return(a); } } else if (tuningMaxInline > 0) { Net.Vpc.Upa.Expressions.Var[] lvar = new Net.Vpc.Upa.Expressions.Var[sourceFields.Length]; Net.Vpc.Upa.Expressions.Var[] rvar = new Net.Vpc.Upa.Expressions.Var[targetFields.Length]; for (int i = 0; i < lvar.Length; i++) { lvar[i] = new Net.Vpc.Upa.Expressions.Var((sourceAlias == null) ? null : new Net.Vpc.Upa.Expressions.Var(sourceAlias), sourceFields[i].GetName()); rvar[i] = new Net.Vpc.Upa.Expressions.Var((targetAlias == null) ? null : new Net.Vpc.Upa.Expressions.Var(targetAlias), targetFields[i].GetName()); } try { System.Collections.Generic.IList <Net.Vpc.Upa.Record> list = GetTargetRole().GetEntity().CreateQuery(new Net.Vpc.Upa.Expressions.Select().Uplet(rvar, "rval").Where(targetCondition)).GetRecordList(); int j = 0; Net.Vpc.Upa.Expressions.IdCollectionExpression inCollection = new Net.Vpc.Upa.Expressions.IdCollectionExpression(lvar); foreach (Net.Vpc.Upa.Record r in list) { j++; if (j > tuningMaxInline) { return(new Net.Vpc.Upa.Expressions.InSelection(lvar, new Net.Vpc.Upa.Expressions.Select().From(GetTargetRole().GetEntity().GetName()).Uplet(rvar).Where(targetCondition))); } inCollection.Add(new Net.Vpc.Upa.Expressions.Param(null, r.GetSingleResult <T>())); } //inCollection.add(new Litteral(rs.getObject(1))); return(inCollection); } catch (Net.Vpc.Upa.Exceptions.UPAException e) { return(new Net.Vpc.Upa.Expressions.InSelection(lvar, new Net.Vpc.Upa.Expressions.Select().From(GetTargetRole().GetEntity().GetName()).Uplet(rvar).Where(targetCondition))); } } else { Net.Vpc.Upa.Expressions.Var[] lvar = new Net.Vpc.Upa.Expressions.Var[sourceFields.Length]; Net.Vpc.Upa.Expressions.Var[] rvar = new Net.Vpc.Upa.Expressions.Var[targetFields.Length]; for (int i = 0; i < lvar.Length; i++) { lvar[i] = new Net.Vpc.Upa.Expressions.Var((sourceAlias == null) ? null : new Net.Vpc.Upa.Expressions.Var(sourceAlias), sourceFields[i].GetName()); rvar[i] = new Net.Vpc.Upa.Expressions.Var((targetAlias == null) ? null : new Net.Vpc.Upa.Expressions.Var(targetAlias), targetFields[i].GetName()); } return(new Net.Vpc.Upa.Expressions.InSelection(lvar, new Net.Vpc.Upa.Expressions.Select().From(GetTargetRole().GetEntity().GetName()).Uplet(rvar).Where(targetCondition))); } }