public override bool Equals(object o) { if (this == o) { return(true); } if (o == null || GetType() != o.GetType()) { return(false); } Net.Vpc.Upa.Impl.Persistence.UPAObjectAndSpec that = (Net.Vpc.Upa.Impl.Persistence.UPAObjectAndSpec)o; if (@object != null ? [email protected](that.@object) : that.@object != null) { return(false); } if (spec != null ? !spec.Equals(that.spec) : that.spec != null) { return(false); } return(true); }
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"); }
protected internal virtual string ValidatePersistenceName(string persistenceName, Net.Vpc.Upa.Persistence.PersistenceNameType defaultType, string absoluteName, Net.Vpc.Upa.Impl.Persistence.UPAObjectAndSpec e, System.Collections.Generic.IList <Net.Vpc.Upa.Persistence.PersistenceNameType> types) /* throws Net.Vpc.Upa.Exceptions.UPAException */ { // String varName = "*"; string confPrefix = ""; //UPA.CONNECTION_STRING+"."; string persistenceNamePattern = null; Net.Vpc.Upa.Properties parameters = GetPersistenceUnit().GetProperties(); if (absoluteName != null) { persistenceNamePattern = GetParamValue(confPrefix, defaultType, absoluteName, parameters); } if (persistenceNamePattern == null) { foreach (Net.Vpc.Upa.Persistence.PersistenceNameType t in types) { persistenceNamePattern = GetParamValue(confPrefix, t, absoluteName, parameters); if (persistenceNamePattern != null) { break; } } } bool noPatternDefined = true; if (persistenceNamePattern == null) { persistenceNamePattern = GetParamValue(confPrefix, "PERSISTENCE_NAME", parameters); } if (persistenceNamePattern != null) { persistenceNamePattern = persistenceNamePattern.Trim(); if ((persistenceNamePattern).Length > 0) { noPatternDefined = false; persistenceName = ReplacePersistenceName(persistenceNamePattern, persistenceName); } } if (defaultType.IsGlobal()) { persistenceNamePattern = GetParamValue(confPrefix, "GLOBAL_PERSISTENCE_NAME", parameters); } else { persistenceNamePattern = GetParamValue(confPrefix, "LOCAL_PERSISTENCE_NAME", parameters); } if (persistenceNamePattern != null) { persistenceNamePattern = persistenceNamePattern.Trim(); if ((persistenceNamePattern).Length > 0) { noPatternDefined = false; persistenceName = ReplacePersistenceName(persistenceNamePattern, persistenceName); } } if (noPatternDefined) { //use default pattern... persistenceName = ReplacePersistenceName("*", persistenceName); } if (GetPersistenceStore().IsReservedKeyword(persistenceName)) { if (escapedNamePattern == null) { escapedNamePattern = GetParamValue(confPrefix, "PERSISTENCE_NAME_ESCAPE", parameters); if (escapedNamePattern == null) { escapedNamePattern = ""; } escapedNamePattern = escapedNamePattern.Trim(); if ((escapedNamePattern).Length > 0) { if (!escapedNamePattern.Contains("*")) { escapedNamePattern = escapedNamePattern + "*"; } } } if ((escapedNamePattern).Length > 0) { persistenceName = ReplacePersistenceName(escapedNamePattern, persistenceName); } } return(persistenceName); }