public virtual Net.Vpc.Upa.PersistenceUnit AddPersistenceUnit(string name) /* throws Net.Vpc.Upa.Exceptions.UPAException */ { if (name == null) { name = ""; } Net.Vpc.Upa.PersistenceUnit persistenceUnit = GetFactory().CreateObject <Net.Vpc.Upa.PersistenceUnit>(typeof(Net.Vpc.Upa.PersistenceUnit)); // persistenceUnit.setName(name); // persistenceUnit.setPersistenceGroup(this); persistenceUnit.Init(name, this); lock (persistenceUnits) { if (persistenceUnits.ContainsKey(name)) { throw new Net.Vpc.Upa.Exceptions.PersistenceUnitAlreadyExistsException(name); } listeners.FireOnCreatePersistenceUnit(new Net.Vpc.Upa.Callbacks.PersistenceUnitEvent(persistenceUnit, this, Net.Vpc.Upa.EventPhase.BEFORE)); persistenceUnits[name] = persistenceUnit; Net.Vpc.Upa.PersistenceUnit oldPersistenceUnit = GetPersistenceUnitProvider().GetPersistenceUnit(this); if (oldPersistenceUnit == null) { SetPersistenceUnit(persistenceUnit.GetName()); } listeners.FireOnCreatePersistenceUnit(new Net.Vpc.Upa.Callbacks.PersistenceUnitEvent(persistenceUnit, this, Net.Vpc.Upa.EventPhase.AFTER)); } log.TraceEvent(System.Diagnostics.TraceEventType.Verbose, 60, Net.Vpc.Upa.Impl.FwkConvertUtils.LogMessageExceptionFormatter("Create PersistenceUnit {0}/{1}", null, new object[] { GetName(), persistenceUnit.GetName() })); return(persistenceUnit); }
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 DefaultExpressionManager(Net.Vpc.Upa.PersistenceUnit persistenceUnit) { this.persistenceUnit = persistenceUnit; translationManager = new Net.Vpc.Upa.Impl.Uql.ExpressionTranslationManager(this, persistenceUnit); validationManager = new Net.Vpc.Upa.Impl.Uql.ExpressionValidationManager(persistenceUnit); expressionMetadataBuilder = new Net.Vpc.Upa.Impl.Uql.ExpressionMetadataBuilder(this, persistenceUnit); parser = persistenceUnit.GetFactory().CreateObject <Net.Vpc.Upa.QLExpressionParser>(typeof(Net.Vpc.Upa.QLExpressionParser)); }
public ScanEvent(Net.Vpc.Upa.UPAContext context, Net.Vpc.Upa.PersistenceGroup persistenceGroup, Net.Vpc.Upa.PersistenceUnit persistenceUnit, System.Type contract, System.Type type, object instance) { this.context = context; this.persistenceGroup = persistenceGroup; this.persistenceUnit = persistenceUnit; this.contract = contract; this.visitedType = type; this.userObject = instance; }
public virtual void SetPersistenceUnit(string name) /* throws Net.Vpc.Upa.Exceptions.UPAException */ { Net.Vpc.Upa.PersistenceUnit newPU = GetPersistenceUnit(name); Net.Vpc.Upa.PersistenceUnit oldPU = GetPersistenceUnitProvider().GetPersistenceUnit(this); if (oldPU != newPU) { GetPersistenceUnitProvider().SetPersistenceUnit(this, GetPersistenceUnit(name)); } }
public virtual T GetParam <T>(Net.Vpc.Upa.PersistenceUnit persistenceUnit, System.Type type, string name, T defaultValue) { object o = Net.Vpc.Upa.Impl.FwkConvertUtils.GetMapValue <Net.Vpc.Upa.Impl.Context.PersistenceUnitKey, object>(map, new Net.Vpc.Upa.Impl.Context.PersistenceUnitKey(persistenceUnit, name)); if (o != null) { return((T)o); } return(defaultValue); }
public virtual T GetImmediateParam <T>(Net.Vpc.Upa.PersistenceUnit persistenceUnit, System.Type type, string name, T defaultValue) { System.Collections.Generic.IList <Net.Vpc.Upa.SessionContext> v = stack; Net.Vpc.Upa.SessionContext m = v[(v).Count - 1]; if (m.ContainsParam(persistenceUnit, name)) { return(m.GetParam <T>(persistenceUnit, type, name, defaultValue)); } return(defaultValue); }
public virtual object Eval(Net.Vpc.Upa.EvalContext evalContext) { Net.Vpc.Upa.PersistenceUnit pu = evalContext.GetPersistenceUnit(); if (pu == null) { pu = Net.Vpc.Upa.UPA.GetPersistenceUnit(); } Net.Vpc.Upa.UserPrincipal user = pu.GetUserPrincipal(); return(user == null ? "anonymous" : user.GetName()); }
public EntityEvent(Net.Vpc.Upa.Entity entity, Net.Vpc.Upa.PersistenceUnit persistenceUnit, Net.Vpc.Upa.Package parent, int index, Net.Vpc.Upa.Package oldParent, int oldIndex, Net.Vpc.Upa.EventPhase phase) { this.persistenceUnit = persistenceUnit; this.entity = entity; this.parent = parent; this.index = index; this.oldParent = oldParent; this.oldIndex = oldIndex; this.phase = phase; }
public PackageEvent(Net.Vpc.Upa.Package item, Net.Vpc.Upa.PersistenceUnit persistenceUnit, Net.Vpc.Upa.Package parent, int index, Net.Vpc.Upa.Package oldParent, int oldIndex, Net.Vpc.Upa.EventPhase phase) { this.persistenceUnit = persistenceUnit; this.item = item; this.parent = parent; this.index = index; this.oldParent = oldParent; this.oldIndex = oldIndex; this.phase = phase; }
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 SectionEvent(Net.Vpc.Upa.Section item, Net.Vpc.Upa.PersistenceUnit persistenceUnit, Net.Vpc.Upa.Entity entity, Net.Vpc.Upa.Section parent, int index, Net.Vpc.Upa.Section oldParent, int oldIndex, Net.Vpc.Upa.EventPhase phase) { this.persistenceUnit = persistenceUnit; this.item = item; this.parent = parent; this.index = index; this.oldParent = oldParent; this.oldIndex = oldIndex; this.entity = entity; this.phase = phase; }
public virtual Net.Vpc.Upa.PersistenceUnit GetPersistenceUnit(string name) /* throws Net.Vpc.Upa.Exceptions.UPAException */ { lock (persistenceUnits) { Net.Vpc.Upa.PersistenceUnit persistenceUnit = Net.Vpc.Upa.Impl.FwkConvertUtils.GetMapValue <string, Net.Vpc.Upa.PersistenceUnit>(persistenceUnits, name); if (persistenceUnit == null) { throw new Net.Vpc.Upa.Exceptions.NoSuchPersistenceUnitException(name); } return(persistenceUnit); } }
public FieldEvent(Net.Vpc.Upa.Field field, Net.Vpc.Upa.PersistenceUnit persistenceUnit, Net.Vpc.Upa.Entity entity, Net.Vpc.Upa.EntityPart parent, int index, Net.Vpc.Upa.EntityPart oldParent, int oldIndex, Net.Vpc.Upa.EventPhase phase) { this.persistenceUnit = persistenceUnit; this.field = field; this.parent = parent; this.index = index; this.oldParent = oldParent; this.oldIndex = oldIndex; this.entity = entity; this.phase = phase; }
private void Process(Net.Vpc.Upa.PersistenceUnit u, Net.Vpc.Upa.Filters.EntityFilter filter, Net.Vpc.Upa.Impl.Config.EntityConfigurator configurator) { this.filter = filter; this.configurator = configurator; System.Collections.Generic.IList <Net.Vpc.Upa.Entity> f = u.GetEntities(filter); foreach (Net.Vpc.Upa.Entity f1 in f) { configurator.Install(f1); } u.AddDefinitionListener(this); }
public ScanEvent(Net.Vpc.Upa.UPAContext context, Net.Vpc.Upa.PersistenceGroup persistenceGroup, Net.Vpc.Upa.PersistenceUnit persistenceUnit, System.Type contract, System.Type type, System.Reflection.MethodInfo method, Net.Vpc.Upa.Field field, Net.Vpc.Upa.Config.Decoration decoration, object instance) { this.context = context; this.persistenceGroup = persistenceGroup; this.persistenceUnit = persistenceUnit; this.contract = contract; this.visitedType = type; this.visitedMethod = method; this.visitedField = field; this.visitedDecoration = decoration; this.userObject = instance; }
public static Net.Vpc.Upa.Impl.Util.DefaultBeanAdapter PreparePreAdd(Net.Vpc.Upa.PersistenceUnit persistenceUnit, Net.Vpc.Upa.Entity entity, Net.Vpc.Upa.UPAObject item, string name) { Net.Vpc.Upa.Impl.Util.DefaultBeanAdapter adapter = new Net.Vpc.Upa.Impl.Util.DefaultBeanAdapter(item); adapter.SetProperty("persistenceUnit", persistenceUnit); item.SetName(name); adapter.SetProperty("persistenceState", Net.Vpc.Upa.PersistenceState.DIRTY); if (item is Net.Vpc.Upa.EntityPart) { adapter.SetProperty("entity", entity); } return(adapter); }
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 RelationshipDescriptorProcessor(Net.Vpc.Upa.PersistenceUnit persistenceUnit, Net.Vpc.Upa.RelationshipDescriptor relationInfo) { this.persistenceUnit = persistenceUnit; this.relationDescriptor = relationInfo; if (Net.Vpc.Upa.Impl.Util.StringUtils.IsNullOrEmpty(relationDescriptor.GetTargetEntity()) && relationDescriptor.GetTargetEntityType() == null) { throw new Net.Vpc.Upa.Exceptions.UPAException("NoneOfTargetEntityAndTargetEntityTypeDefined"); } if (Net.Vpc.Upa.Impl.Util.StringUtils.IsNullOrEmpty(relationDescriptor.GetSourceEntity()) && relationDescriptor.GetSourceEntityType() == null) { throw new Net.Vpc.Upa.Exceptions.UPAException("NoneOfSourceEntityAndSourceEntityTypeDefined"); } }
public virtual void SetPersistenceUnit(Net.Vpc.Upa.PersistenceGroup persistenceGroup, Net.Vpc.Upa.PersistenceUnit persistenceUnit) { string k = System.Convert.ToString(System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(persistenceGroup)); if (persistenceUnit == null) { GetMap().Remove(k); } else { GetMap()[k] = persistenceUnit; } }
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 System.Collections.Generic.IEnumerable <System.Type> ToIterable(object context) { System.Collections.Generic.IList <Net.Vpc.Upa.Config.ScanFilter> _filters = new System.Collections.Generic.List <Net.Vpc.Upa.Config.ScanFilter>(); if (context is Net.Vpc.Upa.UPAContext) { Net.Vpc.Upa.UPAContext pg = (Net.Vpc.Upa.UPAContext)context; Net.Vpc.Upa.Impl.FwkConvertUtils.ListAddRange(_filters, new System.Collections.Generic.List <Net.Vpc.Upa.Config.ScanFilter>(pg.GetContextAnnotationStrategyFilters())); } else if (context is Net.Vpc.Upa.PersistenceGroup) { Net.Vpc.Upa.PersistenceGroup pg = (Net.Vpc.Upa.PersistenceGroup)context; foreach (Net.Vpc.Upa.Config.ScanFilter filter in pg.GetContext().GetContextAnnotationStrategyFilters()) { if (filter.IsPropagate()) { _filters.Add(filter); } } Net.Vpc.Upa.Impl.FwkConvertUtils.ListAddRange(_filters, new System.Collections.Generic.List <Net.Vpc.Upa.Config.ScanFilter>(pg.GetContextAnnotationStrategyFilters())); } else if (context is Net.Vpc.Upa.PersistenceUnit) { Net.Vpc.Upa.PersistenceUnit pu = (Net.Vpc.Upa.PersistenceUnit)context; foreach (Net.Vpc.Upa.Config.ScanFilter filter in pu.GetPersistenceGroup().GetContext().GetContextAnnotationStrategyFilters()) { if (filter.IsPropagate()) { _filters.Add(filter); } } foreach (Net.Vpc.Upa.Config.ScanFilter filter in pu.GetPersistenceGroup().GetContextAnnotationStrategyFilters()) { if (filter.IsPropagate()) { _filters.Add(filter); } } foreach (Net.Vpc.Upa.Config.ScanFilter filter in pu.GetContextAnnotationStrategyFilters()) { _filters.Add(filter); } } else { throw new System.ArgumentException("Unsupported context " + context); } return(new Net.Vpc.Upa.Impl.Util.Classpath.URLClassIterable(Net.Vpc.Upa.Impl.Util.Classpath.ClassPathUtils.ResolveClassPathLibs(), new Net.Vpc.Upa.Impl.Util.Classpath.DefaultConfigFilter(_filters.ToArray()), null)); }
public static void PreparePostAdd(Net.Vpc.Upa.PersistenceUnit persistenceUnit, Net.Vpc.Upa.UPAObject item) { // DefaultBeanAdapter adapter = new DefaultBeanAdapter(item); Net.Vpc.Upa.I18NStringStrategy strategy = persistenceUnit.GetI18NStringStrategy(); Net.Vpc.Upa.Types.I18NString s = null; Net.Vpc.Upa.Types.I18NString t = null; Net.Vpc.Upa.Types.I18NString d = null; if (item is Net.Vpc.Upa.Package) { s = strategy.GetPackageString(((Net.Vpc.Upa.Package)item)); t = s.Append("title"); d = s.Append("desc"); } else if (item is Net.Vpc.Upa.Relationship) { s = strategy.GetRelationshipString((Net.Vpc.Upa.Relationship)item); t = s.Append("title"); d = s.Append("desc"); } else if (item is Net.Vpc.Upa.Entity) { s = strategy.GetEntityString((Net.Vpc.Upa.Entity)item); t = s.Append("title"); d = s.Append("desc"); } else if (item is Net.Vpc.Upa.Section) { s = strategy.GetSectionString(((Net.Vpc.Upa.Section)item).GetEntity(), item.GetName()); t = s.Append("title"); d = s.Append("desc"); } else if (item is Net.Vpc.Upa.Field) { s = strategy.GetFieldString((Net.Vpc.Upa.Field)item); t = s.Append("title"); d = s.Append("desc"); } else if (item is Net.Vpc.Upa.RelationshipRole) { Net.Vpc.Upa.RelationshipRole r = (Net.Vpc.Upa.RelationshipRole)item; s = strategy.GetRelationshipRoleString(r); t = s.Append("title"); d = (s.Append("desc").Union(r.GetEntity().GetDescription())); } item.SetI18NString(s); item.SetTitle(t); item.SetDescription(d); }
private bool ProcessRelation(bool throwErrors) { if (!Build(throwErrors)) { return(false); } Net.Vpc.Upa.PersistenceUnit pu = sourceEntity.GetPersistenceUnit(); if (relation == null) { Net.Vpc.Upa.DefaultRelationshipDescriptor rd = new Net.Vpc.Upa.DefaultRelationshipDescriptor(); rd.SetName(relationDescriptor.GetName()); rd.SetBaseField(relationDescriptor.GetBaseField()); rd.SetRelationshipType(relationDescriptor.GetRelationshipType()); rd.SetSourceEntity(sourceEntity.GetName()); rd.SetTargetEntity(targetEntity.GetName()); rd.SetSourceFields(sourceFieldNames.ToArray()); rd.SetFilter(relationDescriptor.GetFilter()); rd.SetHierarchy(relationDescriptor.IsHierarchy()); rd.SetHierarchyPathField(relationDescriptor.GetHierarchyPathField()); rd.SetHierarchyPathSeparator(relationDescriptor.GetHierarchyPathSeparator()); rd.SetNullable(relationDescriptor.IsNullable()); relation = ((Net.Vpc.Upa.Impl.DefaultPersistenceUnit)pu).AddRelationshipImmediate(rd); } else { if (!Net.Vpc.Upa.Impl.Util.StringUtils.IsNullOrEmpty(relationDescriptor.GetName())) { relation.SetName(relationDescriptor.GetName()); } relation.SetRelationshipType(relationDescriptor.GetRelationshipType() == default(Net.Vpc.Upa.RelationshipType) ? Net.Vpc.Upa.RelationshipType.DEFAULT : relationDescriptor.GetRelationshipType()); relation.GetSourceRole().SetEntityField(manyToOneField); relation.GetSourceRole().SetRelationshipUpdateType(sourceUpdateType); System.Collections.Generic.IList <Net.Vpc.Upa.Field> slaveFields = new System.Collections.Generic.List <Net.Vpc.Upa.Field>(); foreach (string n in sourceFieldNames) { Net.Vpc.Upa.Field f = sourceEntity.GetField(n); slaveFields.Add(f); } relation.GetSourceRole().SetFields(slaveFields.ToArray()); relation.GetTargetRole().SetEntityField(null); relation.GetTargetRole().SetRelationshipUpdateType(Net.Vpc.Upa.Impl.Util.PlatformUtils.GetUndefinedValue <Net.Vpc.Upa.RelationshipUpdateType>(typeof(Net.Vpc.Upa.RelationshipUpdateType))); relation.SetFilter(filter); relation.SetNullable(nullable); } return(true); }
public virtual void Insert(Net.Vpc.Upa.Entity entity, Net.Vpc.Upa.Record originalRecord, Net.Vpc.Upa.Record record, Net.Vpc.Upa.Persistence.EntityExecutionContext context) /* throws Net.Vpc.Upa.Exceptions.UPAException */ { Net.Vpc.Upa.PersistenceUnit pu = context.GetPersistenceUnit(); Net.Vpc.Upa.Expressions.Insert insert = new Net.Vpc.Upa.Expressions.Insert().Into(entity.GetName()); foreach (System.Collections.Generic.KeyValuePair <string, object> entry in record.EntrySet()) { object @value = (entry).Value; string key = (entry).Key; Net.Vpc.Upa.Field field = entity.FindField(key); //should process specific entity fields if ((field.GetDataType() is Net.Vpc.Upa.Types.ManyToOneType)) { Net.Vpc.Upa.Types.ManyToOneType e = (Net.Vpc.Upa.Types.ManyToOneType)field.GetDataType(); if (e.IsUpdatable()) { Net.Vpc.Upa.Entity masterEntity = pu.GetEntity(e.GetTargetEntityName()); Net.Vpc.Upa.Key k = null; if (@value is Net.Vpc.Upa.Record) { k = masterEntity.GetBuilder().RecordToKey((Net.Vpc.Upa.Record)@value); } else { k = masterEntity.GetBuilder().ObjectToKey(@value); } int x = 0; foreach (Net.Vpc.Upa.Field fk in e.GetRelationship().GetSourceRole().GetFields()) { insert.Set(fk.GetName(), new Net.Vpc.Upa.Expressions.Param(fk.GetName(), k.GetObjectAt(x))); x++; } } } else { 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); insert.Set(key, valueExpression); } } context.GetPersistenceStore().CreateQuery(insert, context).ExecuteNonQuery(); }
public virtual void DropPersistenceUnit(string name) /* throws Net.Vpc.Upa.Exceptions.UPAException */ { if (name == null) { name = ""; } lock (persistenceUnits) { if (!persistenceUnits.ContainsKey(name)) { throw new Net.Vpc.Upa.Exceptions.NoSuchPersistenceUnitException(name); } Net.Vpc.Upa.PersistenceUnit persistenceUnit = Net.Vpc.Upa.Impl.FwkConvertUtils.GetMapValue <string, Net.Vpc.Upa.PersistenceUnit>(persistenceUnits, name); if (!persistenceUnit.IsClosed()) { persistenceUnit.Close(); } listeners.FireOnDropPersistenceUnit(new Net.Vpc.Upa.Callbacks.PersistenceUnitEvent(persistenceUnit, this, Net.Vpc.Upa.EventPhase.BEFORE)); persistenceUnits.Remove(name); listeners.FireOnDropPersistenceUnit(new Net.Vpc.Upa.Callbacks.PersistenceUnitEvent(persistenceUnit, this, Net.Vpc.Upa.EventPhase.AFTER)); } }
public virtual Net.Vpc.Upa.PersistenceUnit GetPersistenceUnit() /* throws Net.Vpc.Upa.Exceptions.UPAException */ { Net.Vpc.Upa.PersistenceUnit persistenceUnit = GetPersistenceUnitProvider().GetPersistenceUnit(this); if (persistenceUnit == null) { System.Collections.Generic.IList <Net.Vpc.Upa.PersistenceUnit> persistenceUnitsCurr = GetPersistenceUnits(); if ((persistenceUnitsCurr).Count > 0) { foreach (Net.Vpc.Upa.PersistenceUnit s in persistenceUnitsCurr) { persistenceUnit = s; break; } GetPersistenceUnitProvider().SetPersistenceUnit(this, persistenceUnit); } else { throw new Net.Vpc.Upa.Exceptions.MissingDefaultPersistenceUnitException(); } } return(persistenceUnit); }
public virtual T GetImmediateParam <T>(Net.Vpc.Upa.PersistenceUnit persistenceUnit, System.Type type, string name, T defaultValue) { return(session.GetImmediateParam <T>(persistenceUnit, type, name, defaultValue)); }
public virtual void SetParam(Net.Vpc.Upa.PersistenceUnit persistenceUnit, string name, object @value) { session.SetParam(persistenceUnit, name, @value); }
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()); }