77 makeFieldErrorList , getPanelPrefix , LableSaptail , makePanelStatusUpdater ,
88 Width_Column , DebugObsCore , makeCollapsibleCheckHeader , SpatialWidth
99} from 'firefly/ui/tap/TableSearchHelpers' ;
10- import { tapHelpId } from 'firefly/ui/tap/TapUtil' ;
10+ import { getTableNameAlias , makeFullyQualifiedColumn , tapHelpId } from 'firefly/ui/tap/TapUtil' ;
1111import { ValidationField } from 'firefly/ui/ValidationField' ;
1212import PropTypes , { bool , string , object , shape , arrayOf } from 'prop-types' ;
1313import { FieldGroupCtx , ForceFieldGroupValid } from '../FieldGroup.jsx' ;
@@ -22,15 +22,16 @@ const panelValue = 'ObsCore';
2222const panelPrefix = getPanelPrefix ( panelValue ) ;
2323
2424
25- const multiConstraint = ( value , columnName , siaName , quote , checkForNull ) => {
25+ const multiConstraint = ( value , preFix , columnName , siaName , quote , checkForNull ) => {
2626 const multiConstraint = [ ] ;
2727 const siaConstraints = [ ] ;
2828 const valueList = value . split ( ',' ) ;
29+ const col = makeFullyQualifiedColumn ( preFix , columnName ) ;
2930 valueList . forEach ( ( value ) => {
3031 if ( checkForNull && value === 'null' ) {
31- multiConstraint . push ( `${ columnName } IS NULL` ) ;
32+ multiConstraint . push ( `${ col } IS NULL` ) ;
3233 } else {
33- multiConstraint . push ( `${ columnName } = ${ quote } ${ value } ${ quote } ` ) ;
34+ multiConstraint . push ( `${ col } = ${ quote } ${ value } ${ quote } ` ) ;
3435 }
3536 siaConstraints . push ( `${ siaName } =${ value } ` ) ;
3637 } ) ;
@@ -44,9 +45,11 @@ const multiConstraint = (value, columnName, siaName, quote, checkForNull) => {
4445 *
4546 * @param hasSubType
4647 * @param fldObj
48+ * @param {boolean } doingUpload
49+ * @param {string } tableName
4750 * @returns {InputConstraints }
4851 */
49- const makeConstraints = function ( hasSubType , fldObj ) {
52+ const makeConstraints = function ( hasSubType , fldObj , doingUpload , tableName ) {
5053 const errList = makeFieldErrorList ( ) ;
5154 const adqlConstraintsAry = [ ] ;
5255 const siaConstraints = [ ] ;
@@ -58,16 +61,17 @@ const makeConstraints = function(hasSubType, fldObj) {
5861 obsCoreSubType, obsCoreInstrumentName, siaFacility} = fldObj ;
5962
6063 // const {obsCoreCollection, obsCoreCalibrationLevel, obsCoreTypeSelection, obsCoreSubType, obsCoreInstrumentName} = fields;
64+ const preFix = doingUpload ? getTableNameAlias ( tableName ) : '' ;
6165 errList . checkForError ( obsCoreCollection ) ;
6266 if ( obsCoreCollection ?. value ?. length > 0 ) {
63- const mcResult = multiConstraint ( obsCoreCollection . value , 'obs_collection' , 'COLLECTION' , '\'' ) ;
67+ const mcResult = multiConstraint ( obsCoreCollection . value , preFix , 'obs_collection' , 'COLLECTION' , '\'' ) ;
6468 adqlConstraintsAry . push ( mcResult . adqlConstraint ) ;
6569 siaConstraints . push ( ...mcResult . siaConstraints ) ;
6670 }
6771
6872 errList . checkForError ( obsCoreCalibrationLevel ) ;
6973 if ( obsCoreCalibrationLevel ?. value ) {
70- const mcResult = multiConstraint ( obsCoreCalibrationLevel . value , 'calib_level' , 'CALIB' , '' ) ;
74+ const mcResult = multiConstraint ( obsCoreCalibrationLevel . value , preFix , 'calib_level' , 'CALIB' , '' ) ;
7175 adqlConstraintsAry . push ( mcResult . adqlConstraint ) ;
7276 siaConstraints . push ( ...mcResult . siaConstraints ) ;
7377 }
@@ -76,15 +80,15 @@ const makeConstraints = function(hasSubType, fldObj) {
7680 if ( siaFacility ) {
7781 errList . checkForError ( siaFacility ) ;
7882 if ( siaFacility ?. value ) {
79- const mcResult = multiConstraint ( siaFacility . value , 'facility' , 'FACILITY' , '' ) ;
83+ const mcResult = multiConstraint ( siaFacility . value , preFix , 'facility' , 'FACILITY' , '' ) ;
8084 adqlConstraintsAry . push ( mcResult . adqlConstraint ) ;
8185 siaConstraints . push ( ...mcResult . siaConstraints ) ;
8286 }
8387 }
8488
8589 errList . checkForError ( obsCoreTypeSelection ) ;
8690 if ( obsCoreTypeSelection ?. value ) {
87- const mcResult = multiConstraint ( obsCoreTypeSelection . value , 'dataproduct_type' , 'DPTYPE' , '\'' , true ) ;
91+ const mcResult = multiConstraint ( obsCoreTypeSelection . value , preFix , 'dataproduct_type' , 'DPTYPE' , '\'' , true ) ;
8892 adqlConstraintsAry . push ( mcResult . adqlConstraint ) ;
8993
9094 const siaErrorFields = [ 'visibility' , 'event' , 'null' ] ;
@@ -95,7 +99,7 @@ const makeConstraints = function(hasSubType, fldObj) {
9599
96100 errList . checkForError ( obsCoreInstrumentName ) ;
97101 if ( obsCoreInstrumentName ?. value ?. length ) {
98- const mcResult = multiConstraint ( obsCoreInstrumentName . value , 'instrument_name' , 'INSTRUMENT' , '\'' , true ) ;
102+ const mcResult = multiConstraint ( obsCoreInstrumentName . value , preFix , 'instrument_name' , 'INSTRUMENT' , '\'' , true ) ;
99103 adqlConstraintsAry . push ( mcResult . adqlConstraint ) ;
100104 siaHasErrors ( obsCoreInstrumentName . value , [ 'null' ] )
101105 ? siaConstraintErrors . push ( 'null is not a valid SIA INSTRUMENT option' )
@@ -105,7 +109,7 @@ const makeConstraints = function(hasSubType, fldObj) {
105109 if ( hasSubType ) {
106110 errList . checkForError ( obsCoreSubType ) ;
107111 if ( obsCoreSubType ?. value ?. length > 0 ) {
108- const mcResult = multiConstraint ( obsCoreSubType . value , 'dataproduct_subtype' , 'DPSUBTYPE' , '\'' ) ;
112+ const mcResult = multiConstraint ( obsCoreSubType . value , preFix , 'dataproduct_subtype' , 'DPSUBTYPE' , '\'' ) ;
109113 adqlConstraintsAry . push ( mcResult . adqlConstraint ) ;
110114 siaConstraints . push ( ...mcResult . siaConstraints ) ;
111115 }
@@ -162,11 +166,11 @@ const fldListAry= ['obsCoreCalibrationLevel', 'obsCoreTypeSelection', 'obsCoreSu
162166
163167export function ObsCoreSearch ( { sx, cols, obsCoreMetadataModel, serviceId,
164168 useCalibrationLevel= true , useProductType= true , useFacility= true ,
165- useSubtype= true ,
169+ useSubtype= true , tableName ,
166170 useInstrumentName= true , useCollection= true ,
167171 initArgs= { } , useSIAv2, slotProps= { } } ) {
168172 const { urlApi= { } } = initArgs ;
169- const { setConstraintFragment} = useContext ( ConstraintContext ) ;
173+ const { setConstraintFragment, doingUpload = false } = useContext ( ConstraintContext ) ;
170174 const { makeFldObj} = useContext ( FieldGroupCtx ) ;
171175 const obsCoreCollectionOptions = getDataServiceOption ( 'obsCoreCollection' , serviceId , { } ) ;
172176 const obsCoreCalibrationLevelOptions = getDataServiceOption ( 'obsCoreCalibrationLevel' , serviceId , { } ) ;
@@ -204,7 +208,7 @@ export function ObsCoreSearch({sx, cols, obsCoreMetadataModel, serviceId,
204208
205209
206210 useEffect ( ( ) => {
207- updatePanelStatus ( makeConstraints ( hasSubType , makeFldObj ( fldListAry ) ) , constraintResult , setConstraintResult , useSIAv2 ) ;
211+ updatePanelStatus ( makeConstraints ( hasSubType , makeFldObj ( fldListAry ) , doingUpload , tableName ) , constraintResult , setConstraintResult , useSIAv2 ) ;
208212 } ) ;
209213
210214 useEffect ( ( ) => {
0 commit comments