/// <summary> <p>Creates skeletal source code (without correct data structure but no business /// logic) for all data types found in the normative database. For versions > 2.2, Primitive data types /// are not generated, because they are coded manually (as of HAPI 0.3). /// </summary> public static void makeAll(System.String baseDirectory, System.String version) { //make base directory if (!(baseDirectory.EndsWith("\\") || baseDirectory.EndsWith("/"))) { baseDirectory = baseDirectory + "/"; } System.IO.FileInfo targetDir = SourceGenerator.makeDirectory(baseDirectory + SourceGenerator.getVersionPackageDirectory(version) + "datatype"); SourceGenerator.makeDirectory(baseDirectory + SourceGenerator.getVersionPackageDirectory(version) + "datatype"); //get list of data types System.Collections.ArrayList types = new System.Collections.ArrayList(); //UPGRADE_NOTE: There are other database providers or managers under System.Data namespace which can be used optionally to better fit the application requirements. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1208'" System.Data.OleDb.OleDbConnection conn = NormativeDatabase.Instance.Connection; //UPGRADE_TODO: Method 'java.sql.Connection.createStatement' was converted to 'SupportClass.TransactionManager.manager.CreateStatement' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javasqlConnectioncreateStatement'" System.Data.OleDb.OleDbCommand stmt = SupportClass.TransactionManager.manager.CreateStatement(conn); //get normal data types ... //UPGRADE_TODO: Interface 'java.sql.ResultSet' was converted to 'System.Data.OleDb.OleDbDataReader' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javasqlResultSet'" System.Data.OleDb.OleDbCommand temp_OleDbCommand; temp_OleDbCommand = stmt; temp_OleDbCommand.CommandText = "select data_type_code from HL7DataTypes, HL7Versions where HL7Versions.version_id = HL7DataTypes.version_id and HL7Versions.hl7_version = '" + version + "'"; System.Data.OleDb.OleDbDataReader rs = temp_OleDbCommand.ExecuteReader(); while (rs.Read()) { types.Add(System.Convert.ToString(rs[1 - 1])); } rs.Close(); //get CF, CK, CM, CN, CQ sub-types ... System.Data.OleDb.OleDbCommand temp_OleDbCommand2; temp_OleDbCommand2 = stmt; temp_OleDbCommand2.CommandText = "select data_structure from HL7DataStructures, HL7Versions where (" + "data_type_code = 'CF' or " + "data_type_code = 'CK' or " + "data_type_code = 'CM' or " + "data_type_code = 'CN' or " + "data_type_code = 'CQ') and " + "HL7Versions.version_id = HL7DataStructures.version_id and HL7Versions.hl7_version = '" + version + "'"; rs = temp_OleDbCommand2.ExecuteReader(); while (rs.Read()) { types.Add(System.Convert.ToString(rs[1 - 1])); } //UPGRADE_ISSUE: Method 'java.sql.Statement.close' was not converted. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1000_javasqlStatementclose'" stmt.Dispose(); NormativeDatabase.Instance.returnConnection(conn); System.Console.Out.WriteLine("Generating " + types.Count + " datatypes for version " + version); if (types.Count == 0) { //UPGRADE_ISSUE: Method 'java.lang.System.getProperty' was not converted. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1000_javalangSystem'" log.warn("No version " + version + " data types found in database " + conn.Database); } for (int i = 0; i < types.Count; i++) { if (!((String)types[i]).Equals("*")) { make(targetDir, (System.String)types[i], version); } } }
/// <summary> <p>Creates source code for a Group and returns a GroupDef object that /// describes the Group's name, optionality, repeatability. The source /// code is written under the given directory.</p> /// <p>The structures list may contain [] and {} pairs representing /// nested groups and their optionality and repeastability. In these cases /// this method is called recursively.</p> /// <p>If the given structures list begins and ends with repetition and/or /// optionality markers the repetition and optionality of the returned /// GroupDef are set accordingly.</p> /// </summary> /// <param name="structures">a list of the structures that comprise this group - must /// be at least 2 long /// </param> /// <param name="baseDirectory">the directory to which files should be written /// </param> /// <param name="message">the message to which this group belongs /// </param> /// <throws> HL7Exception if the repetition and optionality markers are not </throws> /// <summary> properly nested. /// </summary> public static GroupDef writeGroup(StructureDef[] structures, System.String groupName, System.String baseDirectory, System.String version, System.String message) { //make base directory if (!(baseDirectory.EndsWith("\\") || baseDirectory.EndsWith("/"))) { baseDirectory = baseDirectory + "/"; } System.IO.FileInfo targetDir = SourceGenerator.makeDirectory(baseDirectory + SourceGenerator.getVersionPackageDirectory(version) + "group"); GroupDef group = getGroupDef(structures, groupName, baseDirectory, version, message); //UPGRADE_WARNING: At least one expression was used more than once in the target code. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1181'" //UPGRADE_TODO: Constructor 'java.io.FileWriter.FileWriter' was converted to 'System.IO.StreamWriter' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaioFileWriterFileWriter_javalangString_boolean'" //UPGRADE_TODO: Class 'java.io.FileWriter' was converted to 'System.IO.StreamWriter' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaioFileWriter'" using (System.IO.StreamWriter out_Renamed = new System.IO.StreamWriter(targetDir.FullName + "/" + group.Name + ".cs")) { out_Renamed.Write(makePreamble(group, version)); out_Renamed.Write(makeConstructor(group, version)); StructureDef[] shallow = group.Structures; for (int i = 0; i < shallow.Length; i++) { out_Renamed.Write(makeAccessor(group, i)); } out_Renamed.Write("}\r\n"); //Closing class out_Renamed.Write("}\r\n"); //Closing namespace } return(group); }