Changeset 27364 for trunk/ippToPsps/scripts/pspsSchema2xml.pl
- Timestamp:
- Mar 19, 2010, 3:59:49 PM (16 years ago)
- File:
-
- 1 edited
-
trunk/ippToPsps/scripts/pspsSchema2xml.pl (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippToPsps/scripts/pspsSchema2xml.pl
r27363 r27364 42 42 $writer->startTag('tableDescriptions', "type" => "$type"); 43 43 44 if ($type eq "IN") {createInit( $schemaPath);}45 elsif ($type eq "DT") {createDetections( $schemaPath);}46 elsif ($type eq "OB") {createDiffs( $schemaPath);}47 elsif ($type eq "ST") {createStacks( $schemaPath);}44 if ($type eq "IN") {createInit();} 45 elsif ($type eq "DT") {createDetections();} 46 elsif ($type eq "OB") {createDiffs();} 47 elsif ($type eq "ST") {createStacks();} 48 48 49 49 # finish up XML … … 54 54 ######################################################################################3 55 55 56 # finds the schema file containing this table description 57 sub findSchemaFile { 58 my ($tableName) = @_; 59 60 opendir(DIR, $schemaPath) or print "Cannot open '$schemaPath'\n" and return ""; 61 my @files= readdir(DIR); 62 closedir(DIR); 63 64 foreach my $f (@files) { 65 66 if ($f =~ m/.*\.sql$/) { 67 #print "....$f\n"; 68 69 open FILE, "<$schemaPath/$f" or next; 70 71 while (<FILE>) { 72 if ($_ =~ m/.*CREATE TABLE.*$tableName/) { 73 74 close (FILE); 75 return "$schemaPath/$f"; 76 } 77 } 78 79 close (FILE); 80 81 } 82 } 83 84 print "Could not find table '$tableName'\n"; 85 return ""; 86 } 56 87 57 88 # creates detections tables 58 89 sub createInit { 59 my ($schemaPath) = @_; 60 61 parseTable("$schemaPath/PanSTARRS.Tables.Common.sql", "dbo.Filter"); 62 parseTable("$schemaPath/PanSTARRS.Tables.Common.sql", "dbo.FitModel"); 63 parseTable("$schemaPath/PanSTARRS.Tables.Common.sql", "dbo.PhotozRecipe"); 64 parseTable("$schemaPath/PanSTARRS.Tables.Common.sql", "dbo.Survey"); 65 parseTable("$schemaPath/PanSTARRS.Tables.Common.sql", "dbo.CameraConfig"); 66 parseTable("$schemaPath/PanSTARRS.Tables.Common.sql", "dbo.PhotoCal"); 67 parseTable("$schemaPath/PanSTARRS.Tables.Slice.sql", "dbo.SkyCell"); 68 parseTable("$schemaPath/PanSTARRS.Tables.Slice.sql", "dbo.ProjectionCell"); 69 parseTable("$schemaPath/PanSTARRS.Tables.Slice.sql", "dbo.Region"); 70 parseTable("$schemaPath/PanSTARRS.Tables.Slice.sql", "dbo.StackType"); 90 91 parseTable("Filter"); 92 parseTable("FitModel"); 93 parseTable("PhotozRecipe"); 94 parseTable("Survey"); 95 parseTable("CameraConfig"); 96 parseTable("PhotoCal"); 97 parseTable("SkyCell"); 98 parseTable("ProjectionCell"); 99 parseTable("Region"); 100 parseTable("StackType"); 71 101 } 72 102 73 103 # creates init batch tables 74 104 sub createDetections { 75 my ($schemaPath) = @_; 76 77 parseTable("$schemaPath/PanSTARRS.Tables.Slice.sql", "dbo.FrameMeta"); 78 parseTable("$schemaPath/PanSTARRS.Tables.Slice.sql", "dbo.ImageMeta"); 79 parseTable("$schemaPath/PanSTARRS.Tables.Slice.sql", "dbo.Detection"); 80 parseTable("$schemaPath/PanSTARRS.Tables.LoadMerge.sql", "dbo.SkinnyObject"); 81 parseTable("$schemaPath/PanSTARRS.Tables.Common.sql", "dbo.ObjectCalColor"); 105 106 parseTable("FrameMeta"); 107 parseTable("ImageMeta"); 108 parseTable("Detection"); 109 parseTable("SkinnyObject"); 110 parseTable("ObjectCalColor"); 82 111 } 83 112 84 113 # creates diff batch tables 85 114 sub createDiffs { 86 my ($schemaPath) = @_; 87 88 parseTable("$schemaPath/PanSTARRS.Tables.Slice.sql", "dbo.StackMeta"); 89 parseTable("$schemaPath/PanSTARRS.Tables.Slice.sql", "dbo.StackToImage"); 90 parseTable("$schemaPath/PanSTARRS.Tables.Slice.sql", "dbo.StackLowSigDelta"); 91 parseTable("$schemaPath/PanSTARRS.Tables.Slice.sql", "dbo.StackHighSigDelta"); 115 116 parseTable("StackMeta"); 117 parseTable("StackToImage"); 118 parseTable("StackLowSigDelta"); 119 parseTable("StackHighSigDelta"); 92 120 } 93 121 94 122 # creates stack batch tables 95 123 sub createStacks { 96 my ($schemaPath) = @_; 97 98 parseTable("$schemaPath/PanSTARRS.Tables.Slice.sql", "dbo.StackMeta"); 99 parseTable("$schemaPath/PanSTARRS.Tables.Slice.sql", "dbo.StackDetection"); 100 parseTable("$schemaPath/PanSTARRS.Tables.LoadMerge.sql", "dbo.SkinnyObject"); 101 parseTable("$schemaPath/PanSTARRS.Tables.Slice.sql", "dbo.StackOrphan"); 102 parseTable("$schemaPath/PanSTARRS.Tables.Common.sql", "dbo.ObjectCalColor"); 124 125 parseTable("StackMeta"); 126 parseTable("StackDetection"); 127 parseTable("SkinnyObject"); 128 parseTable("StackOrphan"); 129 parseTable("ObjectCalColor"); 103 130 } 104 131 … … 106 133 # parses out a table 107 134 sub parseTable { 108 my ($schemaPath, $tableName, $newName) = @_; 135 my ($tableName, $newName) = @_; 136 137 my $path = findSchemaFile($tableName); 138 139 if ($path eq "") {return;} 109 140 110 141 # sort out table name, either same as in schema or as defined 111 142 my $tableNameOut; 112 143 if ($newName) { $tableNameOut = $newName;} 113 els if($tableName =~ m/dbo\.(.*)/) {$tableNameOut = $1}144 else {$tableNameOut = $tableName} 114 145 115 146 $writer->startTag('table', "name" => $tableNameOut); 116 117 open (SCHEMA, $ schemaPath);147 148 open (SCHEMA, $path); 118 149 119 150 my $reading = 0; … … 124 155 chomp; 125 156 126 if ($_ =~ m/.*CREATE TABLE\s+ ([a-zA-Z0-9.]+)\s*\(/i) {157 if ($_ =~ m/.*CREATE TABLE\s+dbo\.([a-zA-Z0-9.]+)\s*\(/i) { 127 158 128 159 $table = $1; … … 130 161 if ($table eq $tableName) { 131 162 132 my $tableNameOut;133 if ($tableName =~ m/dbo\.(.*)/) {$tableNameOut = $1}134 163 $reading = 1; 135 164 $found = 1;
Note:
See TracChangeset
for help on using the changeset viewer.
