Exemple #1
0
        /// <summary>This method generates a Java representation of an XML profile message</summary>
        /// <param name="xml">an XML representation of a profile message
        /// </param>
        public virtual void  generate(System.String xml)
        {
            try
            {
                ProfileParser  pp   = new ProfileParser(false);
                AntGenerator   an   = new AntGenerator();
                RuntimeProfile spec = pp.parse(xml);

                if (spec.getHL7Version() == null || spec.getHL7Version().Equals(""))
                {
                    throw new ConformanceException("Error: Runtime Profile does not specify HL7Version");
                }

                if (spec.Message.MsgStructID == null || spec.Message.MsgStructID.Equals(""))
                {
                    throw new ConformanceException("Error: Runtime Profile does not specify MsgStructID");
                }

                this.confMsgBuilder.buildClass(spec, this);
                an.createAnt(fg.BasePath, packageName);
            }
            catch (Genetibase.NuGenHL7.conf.NuGenProfileException e)
            {
                SupportClass.WriteStackTrace(e, Console.Error);
                System.Console.Out.WriteLine(e.InnerException);
                System.Console.Out.WriteLine("ProfileException: " + e.ToString());
            }
        }
Exemple #2
0
        public static void  Main(System.String[] args)
        {
            if (args.Length != 2)
            {
                System.Console.Out.WriteLine("Usage: DefaultValidator message_file profile_file");
                System.Environment.Exit(1);
            }

            NuGenDefaultValidator val = new NuGenDefaultValidator();

            try
            {
                System.String msgString = loadFile(args[0]);
                NuGenParser   parser    = new NuGenGenericParser();
                Message       message   = parser.parse(msgString);

                System.String  profileString = loadFile(args[1]);
                ProfileParser  profParser    = new ProfileParser(true);
                RuntimeProfile profile       = profParser.parse(profileString);

                NuGenHL7Exception[] exceptions = val.validate(message, profile.Message);

                System.Console.Out.WriteLine("Exceptions: ");
                for (int i = 0; i < exceptions.Length; i++)
                {
                    System.Console.Out.WriteLine((i + 1) + ". " + exceptions[i].Message);
                }
            }
            catch (System.Exception e)
            {
                SupportClass.WriteStackTrace(e, Console.Error);
            }
        }
        private NuGenValidationException[] testAgainstProfile(Message message, System.String id)
        {
            NuGenHL7Exception[] exceptions = null;
            DefaultValidator    val        = new DefaultValidator();

            try
            {
                System.String profileString = ProfileStoreFactory.ProfileStore.getProfile(id);
                if (profileString != null)
                {
                    ProfileParser  profParser = new ProfileParser(true);
                    RuntimeProfile profile    = profParser.parse(profileString);

                    exceptions = val.validate(message, profile.Message);
                }
                else
                {
                    throw new ProfileException("Unable to find the profile " + id);
                }
            }
            catch (System.IO.IOException e)
            {
                throw new ProfileException("Error retreiving profile " + id, e);
            }

            NuGenValidationException[] result = new NuGenValidationException[exceptions.Length];
            for (int i = 0; i < exceptions.Length; i++)
            {
                result[i] = new NuGenValidationException(exceptions[i].Message, exceptions[i]);
            }
            return(result);
        }
		/// <summary>This method generates a Java representation of an XML profile message</summary>
		/// <param name="xml">an XML representation of a profile message
		/// </param>
		public virtual void  generate(System.String xml)
		{
			try
			{
				ProfileParser pp = new ProfileParser(false);
				AntGenerator an = new AntGenerator();
				RuntimeProfile spec = pp.parse(xml);
				
				if (spec.getHL7Version() == null || spec.getHL7Version().Equals(""))
					throw new ConformanceException("Error: Runtime Profile does not specify HL7Version");
				
				if (spec.Message.MsgStructID == null || spec.Message.MsgStructID.Equals(""))
					throw new ConformanceException("Error: Runtime Profile does not specify MsgStructID");
				
				this.confMsgBuilder.buildClass(spec, this);
				an.createAnt(fg.BasePath, packageName);
			}
			catch (Genetibase.NuGenHL7.conf.NuGenProfileException e)
			{
				SupportClass.WriteStackTrace(e, Console.Error);
				System.Console.Out.WriteLine(e.InnerException);
				System.Console.Out.WriteLine("ProfileException: " + e.ToString());
			}
		}
		private NuGenValidationException[] testAgainstProfile(Message message, System.String id)
		{
			NuGenHL7Exception[] exceptions = null;
			DefaultValidator val = new DefaultValidator();
			try
			{
				System.String profileString = ProfileStoreFactory.ProfileStore.getProfile(id);
				if (profileString != null)
				{
					ProfileParser profParser = new ProfileParser(true);
					RuntimeProfile profile = profParser.parse(profileString);
					
					exceptions = val.validate(message, profile.Message);
				}
				else
				{
					throw new ProfileException("Unable to find the profile " + id);
				}
			}
			catch (System.IO.IOException e)
			{
				throw new ProfileException("Error retreiving profile " + id, e);
			}
			
			NuGenValidationException[] result = new NuGenValidationException[exceptions.Length];
			for (int i = 0; i < exceptions.Length; i++)
			{
				result[i] = new NuGenValidationException(exceptions[i].Message, exceptions[i]);
			}
			return result;
		}
		public static void  Main(System.String[] args)
		{
			
			if (args.Length != 2)
			{
				System.Console.Out.WriteLine("Usage: DefaultValidator message_file profile_file");
				System.Environment.Exit(1);
			}
			
			NuGenDefaultValidator val = new NuGenDefaultValidator();
			try
			{
				System.String msgString = loadFile(args[0]);
				NuGenParser parser = new NuGenGenericParser();
				Message message = parser.parse(msgString);
				
				System.String profileString = loadFile(args[1]);
				ProfileParser profParser = new ProfileParser(true);
				RuntimeProfile profile = profParser.parse(profileString);
				
				NuGenHL7Exception[] exceptions = val.validate(message, profile.Message);
				
				System.Console.Out.WriteLine("Exceptions: ");
				for (int i = 0; i < exceptions.Length; i++)
				{
					System.Console.Out.WriteLine((i + 1) + ". " + exceptions[i].Message);
				}
			}
			catch (System.Exception e)
			{
				SupportClass.WriteStackTrace(e, Console.Error);
			}
		}