/// <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()); } }
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); } }
public void ClearTest() { var store = new ValueStore(); IniAdapter.Load(store, ini); var node = store.AddRoot("Superfluous", "Value"); node.AddChild("Child", "Value"); var profile = new RuntimeProfile(); profile.Store = store; profile.CleanStore(); Assert.IsNull(profile.GetOption("Superfluous/Child")); Assert.IsNull(profile.GetOption("Superfluous")); var option = profile.GetOption("ParentDummy"); Assert.IsNotNull(option); Assert.IsTrue(option.Save() == "no"); option = profile.GetOption("ParentDummy/Child2:Child2Variant2/Child3/Child4/Child5:Default1"); Assert.IsNotNull(option); Assert.IsNotNull(option.Save() == "Child5Default1Value"); }
/// <summary> /// Create or update the main runtime profile with the appropriate value store. /// </summary> static void CreateOrUpdateMainRuntimeProfile() { if (!Application.isPlaying) { Debug.LogError("Cannot create main runtime profile when not playing."); return; } ValueStore currentStore = null; if (Instance.EditorSourceProfile != null) { currentStore = Instance.EditorSourceProfile.Store; } else if (Instance.PlayModeStore != null) { currentStore = Instance.PlayModeStore; } else { currentStore = Instance.store; } if (currentStore != null) { currentStore = currentStore.Clone(); } RuntimeProfile.CreateMain(currentStore); RuntimeProfile.Main.CleanStore(); }
public static void Init(string configPath = "../../../../config.yml", string tokenPath = "../../../../token.txt") { var deserializer = new Deserializer(); var configRaw = System.IO.File.ReadAllText(configPath); _map = deserializer.Deserialize <Map>(configRaw); DevEnv = _map.DevEnv; Profile = DevEnv ? _map.DevProfile : _map.ProdProfile; Admins = _map.Admins; Token = System.IO.File.ReadAllText(tokenPath); if (DevEnv) { Console.WriteLine("!!! In developer mode !!!"); Console.WriteLine("!!! Real bot not online !!!\n"); } }
public void Test() { var store = new ValueStore(); IniAdapter.Load(store, ini); var node = store.AddRoot("Superfluous", "Value"); node.AddChild("Child", "Value"); var profile = new RuntimeProfile(); profile.Store = store; profile.SaveToStore(); var newIni = IniAdapter.Save(profile.Store); System.IO.File.WriteAllText("/Users/adrian/Desktop/orig.ini", SortAndTrim(ini)); System.IO.File.WriteAllText("/Users/adrian/Desktop/new.ini", SortAndTrim(newIni)); Assert.True(SortAndTrim(ini) == SortAndTrim(newIni)); }
/// <summary>Adds a table of comments to a Conformance Message Class</summary> /// <param name="genClass">a GeneratedConformanceMessage /// </param> /// <param name="runtimeProfile">the runtimeProfile for which the comments are being added to /// </param> public void decorateConformanceMessage(GeneratedConformanceMessage genClass, RuntimeProfile runtimeProfile) { genClass.addToClassComments("This class is the primary access class for the HL7 " + runtimeProfile.getHL7Version() + " " + runtimeProfile.Message.MsgType + " Conformance"); genClass.addToClassComments("Class Set. This message has the following attributes:<br>"); genClass.addToClassComments("<table>"); genClass.addToClassComments("<tr><td>Message Type</td><td>" + runtimeProfile.Message.MsgType + "</td></tr>"); genClass.addToClassComments("<tr><td>Event Type</td><td>" + runtimeProfile.Message.EventType + "</td></tr>"); genClass.addToClassComments("<tr><td>HL7 Version</td><td>" + runtimeProfile.getHL7Version() + "</td></tr>"); genClass.addToClassComments("</table><br><br>"); genClass.addToClassComments("<b>Purpose</b><br>"); genClass.addToClassComments(runtimeProfile.Message.EventDesc); }
/// <summary>This method builds a Conformance Message Class</summary> /// <param name="runtimeProfile">the profile which to genrate Conformance Classes for /// </param> /// <param name="depManager">the DeploymentManager /// </param> public virtual void buildClass(RuntimeProfile runtimeProfile, DeploymentManager depManager) { this.depManager = depManager; this.runtimeProfile = runtimeProfile; this.msg = runtimeProfile.Message; this.confMsg = new GeneratedConformanceMessage(); ProfileName profileName = new ProfileName(msg.MsgStructID, ProfileName.PS_MSG); String version = Regex.Replace(runtimeProfile.getHL7Version(), "\\.", ""); System.String underlyingDataType = "Genetibase.NuGenHL7.model." + version + ".message." + msg.MsgStructID; ConformanceSegmentBuilder confSegBuilder = new ConformanceSegmentBuilder(packageName, version, depManager); ConformanceSegGroupBuilder confSegGroupBuilder = new ConformanceSegGroupBuilder(packageName, version, depManager, msg.MsgStructID); DocumentationBuilder docBuilder = DocumentationBuilder.getDocumentationBuilder(); // Add class package and imports confMsg.ClassPackage = packageName; confMsg.addClassImport("Genetibase.NuGenHL7.conf.classes.abs.*"); confMsg.addClassImport("Genetibase.NuGenHL7.conf.classes.exceptions.*"); // Set class properties confMsg.Name = profileName.ClassName; confMsg.Properties = "extends AbstractConformanceContainer"; // Decorate the class with comments docBuilder.decorateConformanceMessage(confMsg, runtimeProfile); docBuilder.decorateConstructor(confMsg.Constructor, msg.MsgType); // add hapi message confMsg.addHAPIMessage(underlyingDataType); for (int i = 1; i <= msg.Children; i++) { //don't build not supported, backward, or unknown types System.String usage = msg.getChild(i).Usage; if (usage.Equals("X") || usage.Equals("B") || usage.Equals("U")) { continue; } if (msg.getChild(i) is Seg) { ProfileName childProfileName = profileName.newInstance(msg.getChild(i).Name, ProfileName.PS_SEG); // Add the member variable vector to hold them confMsg.addMemberVariable("private FiniteList " + childProfileName.MemberName + ";"); confMsg.Constructor.addToBody(childProfileName.MemberName + " = new FiniteList( " + childProfileName.ClassName + ".class, hapiMessage );"); UnderlyingAccessor childAccessor = new UnderlyingAccessor(underlyingDataType, childProfileName.AccessorName); GeneratedRepGetter repGetter = new GeneratedRepGetter(childProfileName, childAccessor.AcceptsRep); docBuilder.decorateRepGetter(repGetter, (Seg)msg.getChild(i), childProfileName.AccessorName); confMsg.addMethod(repGetter); if (depManager.Verbose) { System.Console.Out.WriteLine("Generating Segment: " + packageName + "." + confMsg.Name); } confSegBuilder.buildClass((Seg)msg.getChild(i), underlyingDataType, childProfileName.clearNameMap()); } else if (msg.getChild(i) is SegGroup) { ProfileName childProfileName = profileName.newInstance(msg.getChild(i).Name, ProfileName.PS_SEGG); // Add the member variable vector to hold them confMsg.addMemberVariable("private FiniteList " + childProfileName.MemberName + ";"); confMsg.Constructor.addToBody(childProfileName.MemberName + " = new FiniteList( " + childProfileName.ClassName + ".class, hapiMessage );"); System.String underlyingAccessorName = "get" + msg.MsgStructID + "_" + ConformanceSegGroupBuilder.generateSegGroupName((SegGroup)msg.getChild(i)); UnderlyingAccessor childAccessor = new UnderlyingAccessor(underlyingDataType, underlyingAccessorName); GeneratedRepGetter repGetter = new GeneratedRepGetter(childProfileName, childAccessor.AcceptsRep); docBuilder.decorateRepGetter(repGetter, (SegGroup)msg.getChild(i), childProfileName.OriginalName); confMsg.addMethod(repGetter); if (depManager.Verbose) { System.Console.Out.WriteLine("Generating SegGroup: " + packageName + "." + confMsg.Name); } confSegGroupBuilder.buildClass((SegGroup)msg.getChild(i), underlyingDataType, childProfileName.clearNameMap()); } } depManager.generateFile(confMsg, packageName, profileName.ClassName); }