Index: trunk/pstamp/scripts/dqueryparse.pl
===================================================================
--- trunk/pstamp/scripts/dqueryparse.pl	(revision 40747)
+++ trunk/pstamp/scripts/dqueryparse.pl	(revision 41440)
@@ -76,4 +76,5 @@
 
 # Project name is hardcoded to gpc1 for the moment.
+# -- set gpc1 by default and read in PROJECT column to update for actual query
 $project = resolve_project($ipprc,"gpc1",$dbname,$dbserver);
 my $imagedb = $project->{dbname};
@@ -189,4 +190,6 @@
 	my $filter;
 	my $mjd;
+	my $tess_id;
+	my $component_id;
 	# Confirm that we only have one stage/filter/mjd
 	if ($fpa_id ne 'Not_Set') {   # We only need to check things that aren't the known odd case.
@@ -195,4 +198,7 @@
 		$temp_hash{FILTER}{$query{$fpa_id}{FILTER}[$i]} = 1;
 		$temp_hash{'MJD-OBS'}{$query{$fpa_id}{'MJD-OBS'}[$i]} = 1;
+		$temp_hash{PROJECT}{$query{$fpa_id}{PROJECT}[$i]} = 1;
+		$temp_hash{COMPONENT_ID}{$query{$fpa_id}{COMPONENT_ID}[$i]} = 1;
+		$temp_hash{TESS_ID}{$query{$fpa_id}{TESS_ID}[$i]} = 1;
 	    }
 	    if (scalar(keys(%{ $temp_hash{STAGE} })) == 1) {
@@ -214,4 +220,31 @@
 		exit_with_failure(21,"Too many MJD-OBS specified");
 	    }
+	    # add non-error cases/options as well 
+	    if (scalar(keys(%{ $temp_hash{PROJECT} })) == 1) {
+                if ( (keys(%{ $temp_hash{PROJECT} }))[0] ne 'Not_Set') {
+                    $imagedb = (keys(%{ $temp_hash{PROJECT} }))[0];
+                    $project = resolve_project($ipprc,$imagedb,$dbname,$dbserver);
+                    $imagedb = $project->{dbname};
+                    if (!$imagedb) {
+                        my_die("failed to find imagedb for project: $project", $PS_EXIT_CONFIG_ERROR);
+                    }
+                }
+	    }
+            if (scalar(keys(%{ $temp_hash{TESS_ID} })) == 1) {
+                if ( (keys(%{ $temp_hash{TESS_ID} }))[0] ne 'Not_Set') {                
+                    $tess_id = (keys(%{ $temp_hash{TESS_ID} }))[0];
+                }
+		else {
+		    $tess_id = undef;
+                }
+            }
+            if (scalar(keys(%{ $temp_hash{COMPONENT_ID} })) == 1) {
+                if ( (keys(%{ $temp_hash{COMPONENT_ID} }))[0] ne 'Not_Set') { 
+                    $component_id = (keys(%{ $temp_hash{COMPONENT_ID} }))[0];
+                }
+		else {
+		    $component_id = undef;
+                }
+            }
 	}
 
@@ -255,4 +288,5 @@
 
 	# Determine the query style for this fpa_id
+	# fix remove g  for gpc2
 	if ($fpa_id =~ /o.*g.*o/) {
 	    $query_style = 'byexp';
@@ -287,15 +321,24 @@
             $req_filter = $filter . '%';
         }
-	
+	# set defqults if not_set
+#        if ($imagedb eq 'Not_Set') {
+#            $imagedb = 'gpc1';
+#        }
+#        if ($component_id eq 'Not_Set') {
+#            $component_id = undef;
+#        }
+#        if ($tess_id eq 'Not_Set') {
+#            $tess_id = undef;
+#        }
+
 	# Call the PStamp code to find the images that contain the target on the given MJD in the specified filter.
 	my $pstamp_images_ref = locate_images($ipprc,$imagedb,
 					  \@rowList,
 					  $query_style,$stage,
-					  $fpa_id,undef,undef,
+					  $fpa_id,$tess_id,$component_id,
 					  $option_mask,$need_magic,
 					  $mjd_min,$mjd_max,$req_filter,undef,$verbose);  
 	
 	foreach my $this_image_ref (@{ $pstamp_images_ref }) {
-
             # loop over the rows that this component matched
             foreach my $valid_index (@{ $this_image_ref->{row_index} }) {
@@ -308,5 +351,4 @@
                 $query{$fpa_id}{NEED_MAGIC}[$valid_index] = $need_magic;
                 $query{$fpa_id}{BAD_COMPONENT}[$valid_index] = 0;
-                
                 if (exists($this_image_ref->{astrom})) {
                     $query{$fpa_id}{CATALOG}[$valid_index] = $this_image_ref->{astrom};
