Пример #1
0
 public virtual void MergeHierarchy(Net.Vpc.Upa.Config.Decoration gid)
 {
     if (gid.GetConfig().GetOrder() >= hierarchyConfigOrder)
     {
         specified    = true;
         hierarchy    = true;
         manyToOne    = true;
         targetEntity = baseFieldInfo.GetEntityInfo().GetName();
         System.Type entityType = baseFieldInfo.GetEntityInfo().GetEntityType();
         targetEntityType = entityType;
         if (Net.Vpc.Upa.Impl.Util.PlatformUtils.IsUndefinedValue <Net.Vpc.Upa.RelationshipType>(typeof(Net.Vpc.Upa.RelationshipType), relationType))
         {
             relationType = Net.Vpc.Upa.RelationshipType.COMPOSITION;
         }
         System.Type nativeClass = GetFieldType();
         if (!nativeClass.Equals(entityType))
         {
             throw new System.ArgumentException("Hierarchy Relationship invalid as " + nativeClass + " <> " + entityType);
         }
         if ((gid.GetString("path")).Length > 0)
         {
             hierarchyPathField = gid.GetString("path");
         }
         if ((gid.GetString("separator")).Length > 0)
         {
             hierarchyPathSeparator = gid.GetString("separator");
         }
         if (gid.GetConfig().GetOrder() > hierarchyConfigOrder)
         {
             hierarchyConfigOrder = gid.GetConfig().GetOrder();
         }
     }
 }
Пример #2
0
 public virtual Net.Vpc.Upa.DeletionTraceElement[] GetTrace(Net.Vpc.Upa.RelationshipType type)
 {
     System.Collections.Generic.IDictionary <string, long?>             m        = Net.Vpc.Upa.Impl.FwkConvertUtils.GetMapValue <Net.Vpc.Upa.RelationshipType, System.Collections.Generic.IDictionary <string, long?> >(infos, type);
     System.Collections.Generic.List <Net.Vpc.Upa.DeletionTraceElement> elements = new System.Collections.Generic.List <Net.Vpc.Upa.DeletionTraceElement>();
     if (m != null)
     {
         foreach (System.Collections.Generic.KeyValuePair <string, long?> e2 in new System.Collections.Generic.HashSet <System.Collections.Generic.KeyValuePair <string, long?> >(m))
         {
             string tabName  = (e2).Key;
             long   tabCount = ((e2).Value).Value;
             if (tabCount > 0)
             {
                 elements.Add(new Net.Vpc.Upa.Impl.DefaultDeletionTraceElement(type, tabName, tabCount));
             }
         }
     }
     return(elements.ToArray());
 }
Пример #3
0
 public virtual Net.Vpc.Upa.DeletionTraceElement[] GetTrace()
 {
     System.Collections.Generic.IList <Net.Vpc.Upa.DeletionTraceElement> elements = new System.Collections.Generic.List <Net.Vpc.Upa.DeletionTraceElement>();
     foreach (System.Collections.Generic.KeyValuePair <Net.Vpc.Upa.RelationshipType, System.Collections.Generic.IDictionary <string, long?> > e in new System.Collections.Generic.HashSet <System.Collections.Generic.KeyValuePair <Net.Vpc.Upa.RelationshipType, System.Collections.Generic.IDictionary <string, long?> > >(infos))
     {
         Net.Vpc.Upa.RelationshipType type = (e).Key;
         foreach (System.Collections.Generic.KeyValuePair <string, long?> e2 in new System.Collections.Generic.HashSet <System.Collections.Generic.KeyValuePair <string, long?> >((e).Value))
         {
             string tabName  = (e2).Key;
             long   tabCount = ((e2).Value).Value;
             if (tabCount > 0)
             {
                 elements.Add(new Net.Vpc.Upa.Impl.DefaultDeletionTraceElement(type, tabName, tabCount));
             }
         }
     }
     return(elements.ToArray());
 }
Пример #4
0
        public virtual long GetRemoveCount(Net.Vpc.Upa.RelationshipType type)
        {
            long count = 0;

            foreach (System.Collections.Generic.KeyValuePair <Net.Vpc.Upa.RelationshipType, System.Collections.Generic.IDictionary <string, long?> > e in new System.Collections.Generic.HashSet <System.Collections.Generic.KeyValuePair <Net.Vpc.Upa.RelationshipType, System.Collections.Generic.IDictionary <string, long?> > >(infos))
            {
                Net.Vpc.Upa.RelationshipType k = (e).Key;
                if (k == type)
                {
                    foreach (System.Collections.Generic.KeyValuePair <string, long?> e2 in new System.Collections.Generic.HashSet <System.Collections.Generic.KeyValuePair <string, long?> >((e).Value))
                    {
                        long tabCount = ((e2).Value).Value;
                        count += tabCount;
                    }
                }
            }
            return(count);
        }
Пример #5
0
        private void Add(Net.Vpc.Upa.RelationshipType type, string table, long count)
        {
            System.Collections.Generic.IDictionary <string, long?> tabInfos = Net.Vpc.Upa.Impl.FwkConvertUtils.GetMapValue <Net.Vpc.Upa.RelationshipType, System.Collections.Generic.IDictionary <string, long?> >(infos, type);
            if (tabInfos == null)
            {
                tabInfos    = new System.Collections.Generic.Dictionary <string, long?>();
                infos[type] = tabInfos;
            }
            long?l = Net.Vpc.Upa.Impl.FwkConvertUtils.GetMapValue <string, long?>(tabInfos, table);

            if (l == null)
            {
                tabInfos[table] = count;
            }
            else
            {
                tabInfos[table] = l + count;
            }
        }
Пример #6
0
        public override string ToString()
        {
            System.Text.StringBuilder sb = new System.Text.StringBuilder();
            bool first = true;

            sb.Append("DeleteInfo : ");
            foreach (System.Collections.Generic.KeyValuePair <Net.Vpc.Upa.RelationshipType, System.Collections.Generic.IDictionary <string, long?> > e in new System.Collections.Generic.HashSet <System.Collections.Generic.KeyValuePair <Net.Vpc.Upa.RelationshipType, System.Collections.Generic.IDictionary <string, long?> > >(infos))
            {
                Net.Vpc.Upa.RelationshipType k = (Net.Vpc.Upa.RelationshipType)(e).Key;
                string typeName = k.ToString();
                sb.Append("[").Append(typeName).Append("]=").Append("{");
                foreach (System.Collections.Generic.KeyValuePair <string, long?> e2 in new System.Collections.Generic.HashSet <System.Collections.Generic.KeyValuePair <string, long?> >((e).Value))
                {
                    string tabName  = (e2).Key;
                    long   tabCount = ((e2).Value).Value;
                    if (tabCount > 0)
                    {
                        if (first)
                        {
                            first = false;
                        }
                        else
                        {
                            sb.Append(" ; ");
                        }
                        sb.Append(tabCount).Append(" ").Append(tabName);
                    }
                }
            }
            sb.Append("\n");
            sb.Append("\tStackTrace={");
            sb.Append("\n");
            foreach (string aStackTrace in stackTrace)
            {
                sb.Append("\t\t");
                sb.Append(aStackTrace);
                sb.Append("\n");
            }
            sb.Append("\t}");
            sb.Append("\n");
            return(sb.ToString());
        }
 public virtual Net.Vpc.Upa.DefaultRelationshipDescriptor SetRelationshipType(Net.Vpc.Upa.RelationshipType relationshipType)
 {
     this.relationshipType = relationshipType;
     return(this);
 }
Пример #8
0
 public DefaultDeletionTraceElement(Net.Vpc.Upa.RelationshipType relationType, string entityName, long count)
 {
     this.name         = entityName;
     this.count        = count;
     this.relationType = relationType;
 }
Пример #9
0
 public virtual void SetRelationshipType(Net.Vpc.Upa.RelationshipType relationType)
 {
     this.relationType = relationType;
 }
Пример #10
0
 public virtual void MergeManyToOne(Net.Vpc.Upa.Config.Decoration gid)
 {
     if (gid.GetConfig().GetOrder() >= manyToOneConfigOrder)
     {
         specified = true;
         manyToOne = true;
         System.Type nativeClass = GetFieldType();
         if ((nativeClass).IsArray)
         {
             throw new System.ArgumentException("Invalid Array type " + nativeClass + " for ManyToOne");
         }
         if (typeof(System.Type).IsAssignableFrom(nativeClass))
         {
             throw new System.ArgumentException("Invalid Collection type " + nativeClass + " for ManyToOne");
         }
         if ((nativeClass).IsEnum)
         {
             throw new System.ArgumentException("Enumerations are not supported in Relations");
         }
         if ((gid.GetString("name")).Length > 0)
         {
             name = gid.GetString("name");
         }
         string[] _mappedTo = gid.GetPrimitiveArray <string>("mappedTo", typeof(string));
         if (_mappedTo.Length != 0)
         {
             mappedTo = _mappedTo;
         }
         if (!System.Collections.Generic.EqualityComparer <Net.Vpc.Upa.RelationshipType> .Default.Equals(gid.GetEnum <Net.Vpc.Upa.RelationshipType>("type", typeof(Net.Vpc.Upa.RelationshipType)), Net.Vpc.Upa.RelationshipType.DEFAULT))
         {
             relationType = gid.GetEnum <Net.Vpc.Upa.RelationshipType>("type", typeof(Net.Vpc.Upa.RelationshipType));
         }
         if ((gid.GetString("filter")).Length > 0)
         {
             filter = gid.GetString("filter");
         }
         entityField = (fieldsList[0]).Name;
         string      _targetEntity     = gid.GetString("targetEntity");
         System.Type _targetEntityType = gid.GetType("targetEntityType");
         if ((_targetEntity).Length > 0 && !_targetEntityType.Equals(typeof(void)))
         {
             //problem
             throw new System.ArgumentException("Could not support both targetEntity and targetEntityType");
         }
         else if ((_targetEntity).Length > 0)
         {
             targetEntity     = _targetEntity;
             targetEntityType = null;
         }
         else if (!_targetEntityType.Equals(typeof(void)))
         {
             targetEntity     = null;
             targetEntityType = _targetEntityType;
         }
         if (Net.Vpc.Upa.Impl.Util.UPAUtils.IsSimpleFieldType(nativeClass))
         {
             if ((targetEntityType == null || targetEntityType.Equals(typeof(void))) && targetEntity == null)
             {
                 throw new System.ArgumentException("Missing targetEntityType in field " + baseFieldInfo.GetEntityInfo().GetName() + "." + name);
             }
         }
         if (gid.GetConfig().GetOrder() > manyToOneConfigOrder)
         {
             manyToOneConfigOrder = gid.GetConfig().GetOrder();
         }
     }
 }
Пример #11
0
 public virtual void Add(Net.Vpc.Upa.RelationshipType type, Net.Vpc.Upa.Entity entity, long count)
 {
     Add(type, entity.GetName(), count);
 }
Пример #12
0
        public virtual void CommitModelChanged() /* throws Net.Vpc.Upa.Exceptions.UPAException */
        {
            Net.Vpc.Upa.Entity sourceEntity = GetSourceRole().GetEntity();
            Net.Vpc.Upa.Entity targetEntity = GetTargetRole().GetEntity();
            if (sourceEntity == null || targetEntity == null)
            {
                throw new Net.Vpc.Upa.Exceptions.UPAException("InvalidRelationDefinition");
            }
            if (!sourceEntity.GetUserExcludeModifiers().Contains(Net.Vpc.Upa.EntityModifier.VALIDATE_PERSIST))
            {
                sourceEntity.GetModifiers().Add(Net.Vpc.Upa.EntityModifier.VALIDATE_PERSIST);
            }
            if (!sourceEntity.GetUserExcludeModifiers().Contains(Net.Vpc.Upa.EntityModifier.VALIDATE_UPDATE))
            {
                sourceEntity.GetModifiers().Add(Net.Vpc.Upa.EntityModifier.VALIDATE_UPDATE);
            }
            System.Collections.Generic.IList <Net.Vpc.Upa.Field> sourceFieldsList = sourceRole.GetFields();
            Net.Vpc.Upa.Field[] sourceFields = sourceFieldsList.ToArray();
            Net.Vpc.Upa.KeyType keyType      = new Net.Vpc.Upa.KeyType(targetEntity, filter, false);
            SetDataType(keyType);
            tuningMaxInline = GetPersistenceUnit().GetProperties().GetInt((typeof(Net.Vpc.Upa.Relationship)).FullName + ".maxInline", 10);
            System.Collections.Generic.IList <Net.Vpc.Upa.Field> targetFieldsList = targetEntity.GetPrimaryFields();
            Net.Vpc.Upa.Field[] targetFields = targetFieldsList.ToArray();
            ;
            // some checks
            if (sourceFields.Length == 0)
            {
                throw new System.ArgumentException("No source fields are specified");
            }
            if (targetFields.Length == 0)
            {
                throw new System.ArgumentException("Target Entity " + targetEntity.GetName() + " has no primary fields");
            }
            if (sourceFields.Length != targetFields.Length)
            {
                throw new System.ArgumentException("source fields and target fields have not the same count");
            }
            sourceEntity.AddDependencyOnEntity(targetEntity.GetName());
            if (dataType == null)
            {
                dataType = targetEntity.GetDataType();
            }
            if (dataType.IsNullable() != nullable)
            {
                Net.Vpc.Upa.Types.DataType trCloned = (Net.Vpc.Upa.Types.DataType)dataType.Copy();
                trCloned.SetNullable(nullable);
                dataType = trCloned;
            }
            this.sourceToTargetKeyMap = new System.Collections.Generic.Dictionary <string, string>(sourceFields.Length);
            this.targetToSourceKeyMap = new System.Collections.Generic.Dictionary <string, string>(sourceFields.Length);
            //        if ((theSourceTable  instanceof View))
            //            this.type = 0;
            for (int i = 0; i < sourceFields.Length; i++)
            {
                if (sourceFields[i].GetModifiers().Contains(Net.Vpc.Upa.FieldModifier.TRANSIENT) && this.relationType != Net.Vpc.Upa.RelationshipType.TRANSIENT)
                {
                    //Log. System.err.println("Type should be VIEW for " + getName());
                    this.relationType = Net.Vpc.Upa.RelationshipType.TRANSIENT;
                }
                else if (sourceFields[i].GetUpdateFormula() != null && this.relationType != Net.Vpc.Upa.RelationshipType.TRANSIENT && this.relationType != Net.Vpc.Upa.RelationshipType.SHADOW_ASSOCIATION)
                {
                    // Log. System.err.println("Type should be either VIEW or SHADOW for " + name);
                    this.relationType = Net.Vpc.Upa.RelationshipType.SHADOW_ASSOCIATION;
                }
                this.sourceToTargetKeyMap[sourceFields[i].GetName()] = targetFields[i].GetName();
                this.targetToSourceKeyMap[targetFields[i].GetName()] = sourceFields[i].GetName();
                //            targetFields[i].addManyToOneRelation(this);
                ((Net.Vpc.Upa.Impl.AbstractField)sourceFields[i]).SetEffectiveModifiers(sourceFields[i].GetModifiers().Add(Net.Vpc.Upa.FieldModifier.FOREIGN));
                ((Net.Vpc.Upa.Impl.AbstractField)targetFields[i]).SetEffectiveModifiers(targetFields[i].GetModifiers().Add(Net.Vpc.Upa.FieldModifier.REFERENCED));
                //            if (sourceFields[i].getTitle() == null) {
                //                sourceFields[i].setTitle(targetFields[i].getTitle());
                //            }
                if (sourceFields[i].GetDataType() == null)
                {
                    Net.Vpc.Upa.Types.DataType tr = targetFields[i].GetDataType();
                    if (tr.IsNullable() == nullable)
                    {
                        sourceFields[i].SetDataType(tr);
                    }
                    else
                    {
                        Net.Vpc.Upa.Types.DataType trCloned = (Net.Vpc.Upa.Types.DataType)tr.Copy();
                        trCloned.SetNullable(nullable);
                        sourceFields[i].SetDataType(trCloned);
                    }
                }
            }
            if (GetSourceRole().GetEntityField() != null)
            {
                Net.Vpc.Upa.Field          sourceEntityField = GetSourceRole().GetEntityField();
                Net.Vpc.Upa.Types.DataType dt = sourceEntityField.GetDataType();
                if (dt is Net.Vpc.Upa.Types.ManyToOneType)
                {
                    Net.Vpc.Upa.Types.ManyToOneType edt = (Net.Vpc.Upa.Types.ManyToOneType)dt;
                    edt.SetRelationship(this);
                }
            }
            if (GetTargetRole().GetEntityField() != null)
            {
                Net.Vpc.Upa.Field          targetEntityField = GetTargetRole().GetEntityField();
                Net.Vpc.Upa.Types.DataType dt = targetEntityField.GetDataType();
                if (dt is Net.Vpc.Upa.Types.ManyToOneType)
                {
                    Net.Vpc.Upa.Types.ManyToOneType edt = (Net.Vpc.Upa.Types.ManyToOneType)dt;
                    edt.SetRelationship(this);
                }
            }
            this.sourceToTargetKeyMap = Net.Vpc.Upa.Impl.Util.PlatformUtils.UnmodifiableMap <string, string>(sourceToTargetKeyMap);
            this.targetToSourceKeyMap = Net.Vpc.Upa.Impl.Util.PlatformUtils.UnmodifiableMap <string, string>(targetToSourceKeyMap);
            SetI18NString(new Net.Vpc.Upa.Types.I18NString("Relationship").Append(GetName()));
            SetTitle(GetI18NString().Append(".title"));
            SetDescription(GetI18NString().Append(".desc"));
            System.Text.StringBuilder preferredPersistenceName = new System.Text.StringBuilder((GetName()).Length);
            for (int i = 0; i < (GetName()).Length; i++)
            {
                if (Net.Vpc.Upa.Expressions.ExpressionHelper.IsIdentifierPart(GetName()[i]))
                {
                    preferredPersistenceName.Append(GetName()[i]);
                }
                else
                {
                    preferredPersistenceName.Append('_');
                }
            }
            SetPersistenceName(preferredPersistenceName.ToString());
            if (GetRelationshipType() == Net.Vpc.Upa.RelationshipType.COMPOSITION)
            {
                ((Net.Vpc.Upa.Impl.DefaultEntity)sourceEntity).SetCompositionRelationship(this);
            }
            targetRole.SetFields(targetFields);
            Net.Vpc.Upa.Impl.Util.UPAUtils.Prepare(GetPersistenceUnit(), targetRole, this.GetName() + "_" + targetRole.GetRelationshipRoleType());
            Net.Vpc.Upa.Impl.Util.UPAUtils.Prepare(GetPersistenceUnit(), sourceRole, this.GetName() + "_" + sourceRole.GetRelationshipRoleType());
            if ((((GetTargetRole().GetEntity().GetExtensionDefinitions <Net.Vpc.Upa.Extensions.ViewEntityExtensionDefinition>(typeof(Net.Vpc.Upa.Extensions.ViewEntityExtensionDefinition))).Count > 0) || ((GetSourceRole().GetEntity().GetExtensionDefinitions <Net.Vpc.Upa.Extensions.ViewEntityExtensionDefinition>(typeof(Net.Vpc.Upa.Extensions.ViewEntityExtensionDefinition))).Count > 0)) && relationType != Net.Vpc.Upa.RelationshipType.TRANSIENT)
            {
                throw new System.ArgumentException(this + " : Relationship Type must be TYPE_VIEW");
            }
            if (((GetTargetRole().GetEntity().GetShield().IsTransient()) || (GetSourceRole().GetEntity().GetShield().IsTransient())) && relationType != Net.Vpc.Upa.RelationshipType.TRANSIENT)
            {
                throw new System.ArgumentException(this + " : Relationship Type must be TYPE_VIEW");
            }
            Net.Vpc.Upa.FlagSet <Net.Vpc.Upa.FieldModifier> modifierstoRemove = Net.Vpc.Upa.FlagSets.OfType <Net.Vpc.Upa.FieldModifier>().AddAll(Net.Vpc.Upa.FieldModifier.PERSIST, Net.Vpc.Upa.FieldModifier.PERSIST_DEFAULT, Net.Vpc.Upa.FieldModifier.PERSIST_FORMULA, Net.Vpc.Upa.FieldModifier.PERSIST_SEQUENCE, Net.Vpc.Upa.FieldModifier.UPDATE, Net.Vpc.Upa.FieldModifier.UPDATE_DEFAULT, Net.Vpc.Upa.FieldModifier.UPDATE_FORMULA, Net.Vpc.Upa.FieldModifier.UPDATE_SEQUENCE);
            switch (GetSourceRole().GetRelationshipUpdateType())
            {
            case Net.Vpc.Upa.RelationshipUpdateType.FLAT:
            {
                Net.Vpc.Upa.Field f = GetSourceRole().GetEntityField();
                if (f != null)
                {
                    ((Net.Vpc.Upa.Impl.AbstractField)f).SetEffectiveModifiers(f.GetModifiers().RemoveAll(modifierstoRemove));
                }
                break;
            }

            case Net.Vpc.Upa.RelationshipUpdateType.COMPOSED:
            {
                System.Collections.Generic.IList <Net.Vpc.Upa.Field> fields = GetSourceRole().GetFields();
                if (fields != null)
                {
                    foreach (Net.Vpc.Upa.Field f in fields)
                    {
                        ((Net.Vpc.Upa.Impl.AbstractField)f).SetEffectiveModifiers(f.GetModifiers().RemoveAll(modifierstoRemove));
                    }
                }
                break;
            }
            }
        }