示例#1
0
        /// <summary>
        /// Receive the current class info (loaded from current java classes present on classpath
        /// and check against the persisted meta model
        /// </summary>
        /// <param name="currentCIs"></param>
        public override CheckMetaModelResult CheckMetaModelCompatibility(System.Collections.Generic.IDictionary <string, ClassInfo> currentCIs)
        {
            ClassInfo persistedCI         = null;
            ClassInfo currentCI           = null;
            ClassInfoCompareResult result = null;
            CheckMetaModelResult   checkMetaModelResult = new CheckMetaModelResult();
            // User classes
            IEnumerator <ClassInfo> iterator = GetMetaModel().GetUserClasses().GetEnumerator();

            while (iterator.MoveNext())
            {
                persistedCI = iterator.Current;
                currentCI   = currentCIs[persistedCI.GetFullClassName()];
                result      = persistedCI.ExtractDifferences(currentCI, true);
                if (!result.IsCompatible())
                {
                    throw new NeoDatis.Odb.ODBRuntimeException(NeoDatis.Odb.Core.NeoDatisError.IncompatibleMetamodel
                                                               .AddParameter(result.ToString()));
                }
                if (result.HasCompatibleChanges())
                {
                    checkMetaModelResult.Add(result);
                }
            }
            // System classes
            iterator = GetMetaModel().GetSystemClasses().GetEnumerator();
            while (iterator.MoveNext())
            {
                persistedCI = iterator.Current;
                currentCI   = currentCIs[persistedCI.GetFullClassName()];
                result      = persistedCI.ExtractDifferences(currentCI, true);
                if (!result.IsCompatible())
                {
                    throw new NeoDatis.Odb.ODBRuntimeException(NeoDatis.Odb.Core.NeoDatisError.IncompatibleMetamodel
                                                               .AddParameter(result.ToString()));
                }
                if (result.HasCompatibleChanges())
                {
                    checkMetaModelResult.Add(result);
                }
            }
            for (int i = 0; i < checkMetaModelResult.Size(); i++)
            {
                result = checkMetaModelResult.GetResults()[i];
                NeoDatis.Tool.DLogger.Info("Class " + result.GetFullClassName() + " has changed :"
                                           );
                NeoDatis.Tool.DLogger.Info(result.ToString());
            }
            if (!checkMetaModelResult.GetResults().IsEmpty())
            {
                UpdateMetaModel();
                checkMetaModelResult.SetModelHasBeenUpdated(true);
            }
            return(checkMetaModelResult);
        }
		/// <summary>
		/// Receive the current class info (loaded from current java classes present on classpath
		/// and check against the persisted meta model
		/// </summary>
		/// <param name="currentCIs"></param>
		public override CheckMetaModelResult CheckMetaModelCompatibility(System.Collections.Generic.IDictionary<string, ClassInfo> currentCIs)
		{
			ClassInfo persistedCI = null;
			ClassInfo currentCI = null;
			ClassInfoCompareResult result = null;
			CheckMetaModelResult checkMetaModelResult = new CheckMetaModelResult();
			// User classes
			IEnumerator<ClassInfo> iterator = GetMetaModel().GetUserClasses().GetEnumerator();
			while (iterator.MoveNext())
			{
				persistedCI = iterator.Current;
				currentCI = currentCIs[persistedCI.GetFullClassName()];
				result = persistedCI.ExtractDifferences(currentCI, true);
				if (!result.IsCompatible())
				{
					throw new NeoDatis.Odb.ODBRuntimeException(NeoDatis.Odb.Core.NeoDatisError.IncompatibleMetamodel
						.AddParameter(result.ToString()));
				}
				if (result.HasCompatibleChanges())
				{
					checkMetaModelResult.Add(result);
				}
			}
			// System classes
			iterator = GetMetaModel().GetSystemClasses().GetEnumerator();
			while (iterator.MoveNext())
			{
				persistedCI = iterator.Current;
				currentCI = currentCIs[persistedCI.GetFullClassName()];
				result = persistedCI.ExtractDifferences(currentCI, true);
				if (!result.IsCompatible())
				{
					throw new NeoDatis.Odb.ODBRuntimeException(NeoDatis.Odb.Core.NeoDatisError.IncompatibleMetamodel
						.AddParameter(result.ToString()));
				}
				if (result.HasCompatibleChanges())
				{
					checkMetaModelResult.Add(result);
				}
			}
			for (int i = 0; i < checkMetaModelResult.Size(); i++)
			{
				result = checkMetaModelResult.GetResults()[i];
				NeoDatis.Tool.DLogger.Info("Class " + result.GetFullClassName() + " has changed :"
					);
				NeoDatis.Tool.DLogger.Info(result.ToString());
			}
			if (!checkMetaModelResult.GetResults().IsEmpty())
			{
				UpdateMetaModel();
				checkMetaModelResult.SetModelHasBeenUpdated(true);
			}
			return checkMetaModelResult;
		}