Skip to content

Commit

Permalink
fix: merge conflit
Browse files Browse the repository at this point in the history
  • Loading branch information
Xiao Peng authored and Xiao Peng committed Nov 19, 2024
2 parents 91b2ea6 + 9017ecd commit 764bfd4
Show file tree
Hide file tree
Showing 17 changed files with 2,456 additions and 4,947 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -208,4 +208,6 @@ sync/data/
schemaspy/output

# local testing
*.bat
*.bat

oracle-api/config
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ public class ParentTreeService {
//CHECKSTYLE:OFF: VariableDeclarationUsageDistance
public PtCalculationResDto calculatePtVals(PtValsCalReqDto ptVals) {
SparLog.info(
"Started calculation for parent tree contribution values. Number of rchard parent received:"
+ " {}. Number of SMP mix parent tree received: {}.",
"Started calculation for parent tree contribution values. Number of orchard parent"
+ " received: {}. Number of SMP mix parent tree received: {}.",
ptVals.orchardPtVals().size(),
ptVals.smpMixIdAndProps().size());

Expand Down
7,258 changes: 2,373 additions & 4,885 deletions frontend/package-lock.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions frontend/src/components/ClientAndCodeInput/definitions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ type ClientAndCodeInputProps = {
readOnly?: boolean,
maxInputColSize?: number,
checkBoxInput?: BooleanInputType
shouldSelectDefaultValue?: boolean
}

export default ClientAndCodeInputProps;
27 changes: 17 additions & 10 deletions frontend/src/components/ClientAndCodeInput/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import './styles.scss';
const ClientAndCodeInput = ({
checkboxId, clientInput, locationCodeInput, textConfig, defaultClientNumber,
defaultLocCode, setClientAndCode, readOnly, showCheckbox, maxInputColSize,
checkBoxInput
checkBoxInput, shouldSelectDefaultValue = false
}: ClientAndCodeInputProps) => {
const getIsDefaultVal = () => (
checkBoxInput === undefined
Expand All @@ -38,9 +38,16 @@ const ClientAndCodeInput = ({
const clientInputRef = useRef<HTMLInputElement>(null);
const locCodeInputRef = useRef<HTMLInputElement>(null);
const [isDefault, setIsDefault] = useState<boolean>(
() => getIsDefaultVal()
!shouldSelectDefaultValue ? false : () => getIsDefaultVal()
);

const [isChecked, setIsChecked] = useState<boolean>(() => {
if (!shouldSelectDefaultValue) {
return false;
}
return checkBoxInput ? checkBoxInput.value : isDefault;
});

const [showClientValidationStatus, setShowClientValidationStatus] = useState<boolean>(true);

const [showLocCodeValidationStatus, setShowLocCodeValidationStatus] = useState<boolean>(false);
Expand All @@ -60,7 +67,9 @@ const ClientAndCodeInput = ({
useEffect(() => {
const areValsDefault = getIsDefaultVal();

setIsDefault(areValsDefault);
if (shouldSelectDefaultValue) {
setIsDefault(areValsDefault);
}

// Do not show validation status if isDefault is true
if (areValsDefault) {
Expand Down Expand Up @@ -223,10 +232,8 @@ const ClientAndCodeInput = ({
}
: undefined
);

if (!checkBoxInput) {
setIsDefault(checked);
}
setIsDefault(checked);
setIsChecked(checked);
};

const [openAgnTooltip, setOpenAgnTooltip] = useState<boolean>(false);
Expand Down Expand Up @@ -343,7 +350,7 @@ const ClientAndCodeInput = ({
name={textConfig.useDefaultCheckbox.name}
labelText={textConfig.useDefaultCheckbox.labelText}
readOnly={readOnly}
checked={checkBoxInput ? checkBoxInput.value : isDefault}
checked={isChecked}
onChange={(e: React.ChangeEvent<HTMLInputElement>) => {
handleDefaultCheckBox(e.target.checked);
}}
Expand All @@ -363,7 +370,7 @@ const ClientAndCodeInput = ({
id={clientInput.id}
autoCapitalize="on"
labelText={textConfig.agencyInput.titleText}
defaultValue={forestClientQuery.data?.acronym}
defaultValue={shouldSelectDefaultValue ? forestClientQuery.data?.acronym : ''}
helperText={
(readOnly || (showCheckbox && isDefault))
? null
Expand Down Expand Up @@ -406,7 +413,7 @@ const ClientAndCodeInput = ({
id={locationCodeInput.id}
ref={locCodeInputRef}
name={textConfig.locationCode.name}
defaultValue={locationCodeInput.value}
defaultValue={shouldSelectDefaultValue ? locationCodeInput.value : ''}
type="number"
maxCount={LOCATION_CODE_LIMIT}
enableCounter
Expand Down
1 change: 1 addition & 0 deletions frontend/src/components/LotApplicantAndInfoForm/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ const LotApplicantAndInfoForm = ({
}
readOnly={isEdit}
maxInputColSize={6}
shouldSelectDefaultValue
/>
<Row className="agency-email-row">
<Column sm={4} md={8} lg={16} xlg={12}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@ export const fieldsConfig = {
},
volumePerContainers: {
name: 'volumePerContainers',
labelText: 'Volume per Containers (HI)',
labelText: 'Volume per containers (hl)',
invalidText: 'Invalid entry. Number must be between 0 and 10,000 and up to 3 decimal places.'
},
volumeOfCones: {
name: 'volumeOfCones',
labelText: 'Volume of Cones (HI)',
labelText: 'Volume of cones (hl)',
invalidText: 'Number has more than 3 decimals.',
helperText: 'This value must be the "Volume per container" X "Number of containers".',
warnText: 'The total volume of cones does not equal, please note that this value must be the "Volume per container" x "Number of containers"'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,12 +219,13 @@ export const geneticWorthDict: GeneticWorthDictType = {
PW: ['dsb'],
DR: ['gvo'],
EP: ['gvo'],
FDI: ['gvo'],
FDI: ['gvo', 'wwd'],
HW: ['gvo'],
LW: ['gvo'],
PY: ['gvo'],
SS: ['gvo', 'iws'],
SX: ['gvo', 'iws'],
YC: ['gvo'],
UNKNOWN: ['gvo']
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,21 @@ export type NotifCtrlType = {
}
}

type SpeciesWithGenWorth = 'CW'| 'PLI' |'FDC' | 'PW' | 'DR' | 'EP' | 'FDI' | 'HW' | 'LW' | 'PY' | 'SS' | 'SX' | 'UNKNOWN';
type SpeciesWithGenWorth =
'CW'
|'PLI'
|'FDC'
|'PW'
|'DR'
|'EP'
|'FDI'
|'HW'
|'LW'
|'PY'
|'SS'
|'SX'
|'YC'
|'UNKNOWN';

export type GeneticWorthDictType = {
[key in SpeciesWithGenWorth]: string[]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -270,8 +270,7 @@ const ParentTreeStep = ({ isReviewDisplay, isReviewRead }: ParentTreeStepProps)
setHeaderConfig,
weightedGwInfoItems,
setWeightedGwInfoItems,
setApplicableGenWorths,
isReviewDisplay ?? false
setApplicableGenWorths
), [seedlotSpecies]);

const uploadCompostion = useMutation({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -545,8 +545,7 @@ export const configHeaderOpt = (
setHeaderConfig: Function,
weightedGwInfoItems: Record<keyof RowItem, InfoDisplayObj>,
setWeightedGwInfoItems: Function,
setApplicableGenWorths: Function,
isReview: boolean
setApplicableGenWorths: Function
) => {
const speciesKey = Object.keys(geneticWorthDict).includes(seedlotSpecies.code)
? seedlotSpecies.code.toUpperCase()
Expand All @@ -562,10 +561,8 @@ export const configHeaderOpt = (
// Enable option in the column customization
clonedHeaders[optionIndex].isAnOption = true;

// When on review mode, display all columns
if (isReview) {
clonedHeaders[optionIndex].enabled = true;
}
// Display all columns by default
clonedHeaders[optionIndex].enabled = true;

// Enable weighted option in mix tab
const weightedIndex = headerConfig.findIndex((header) => header.id === `w_${opt}`);
Expand Down Expand Up @@ -751,7 +748,10 @@ export const generatePtValCalcPayload = (
coneCount: Number(row.coneCount.value),
pollenCount: Number(row.pollenCount.value),
smpSuccessPerc: Number(row.smpSuccessPerc.value),
nonOrchardPollenContamPct: Number(row.nonOrchardPollenContam.value),
nonOrchardPollenContamPct:
row.nonOrchardPollenContam.value
? Number(row.nonOrchardPollenContam.value)
: 0,
geneticTraits: []
};
// Populate geneticTraits array
Expand Down Expand Up @@ -920,15 +920,11 @@ export const isMissingSecondaryOrchard = (orchardStepData: OrchardForm): boolean
* Check if orchards selections are valid.
*/
export const areOrchardsValid = (orchardStepData: OrchardForm): boolean => {
let isValid = true;
const { orchards } = orchardStepData;

if (!orchards.primaryOrchard.value.code) {
isValid = false;
}
if (isMissingSecondaryOrchard(orchardStepData)) {
isValid = false;
return false;
}

return isValid;
return true;
};
6 changes: 3 additions & 3 deletions frontend/src/types/SeedlotType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,9 +207,9 @@ export type CollectionFormSubmitType = {
collectionLocnCode: string,
collectionStartDate: string,
collectionEndDate: string,
noOfContainers: number,
volPerContainer: number,
clctnVolume: number,
noOfContainers: string,
volPerContainer: string,
clctnVolume: string,
seedlotComment: string,
coneCollectionMethodCodes: Array<number>
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,9 @@ export const emptyCollectionStep: CollectionFormSubmitType = {
collectionLocnCode: '',
collectionStartDate: '',
collectionEndDate: '',
noOfContainers: 1,
volPerContainer: 1,
clctnVolume: 1,
noOfContainers: '',
volPerContainer: '',
clctnVolume: '',
seedlotComment: '',
coneCollectionMethodCodes: []
};
Expand Down
6 changes: 3 additions & 3 deletions frontend/src/views/Seedlot/ContextContainerClassA/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -852,9 +852,9 @@ export const convertCollection = (collectionData: CollectionForm): CollectionFor
// Assume the date values are present as validation has occurred before payload is generated
collectionStartDate: localDateToUtcFormat(collectionData.startDate.value)!,
collectionEndDate: localDateToUtcFormat(collectionData.endDate.value)!,
noOfContainers: +collectionData.numberOfContainers.value,
volPerContainer: +collectionData.volumePerContainers.value,
clctnVolume: +collectionData.volumeOfCones.value,
noOfContainers: `${+collectionData.numberOfContainers.value}`,
volPerContainer: `${+collectionData.volumePerContainers.value}`,
clctnVolume: `${+collectionData.volumeOfCones.value}`,
seedlotComment: collectionData.comments.value,
coneCollectionMethodCodes: collectionData
.selectedCollectionCodes.value.map((code) => parseInt(code, 10))
Expand Down
27 changes: 9 additions & 18 deletions frontend/src/views/Seedlot/SeedlotReview/SeedlotReviewContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -550,24 +550,15 @@ const SeedlotReviewContent = () => {
}
/>

{
// Seedlots that have 'CUS' or 'UPT' as source should not be edited.
seedlotData?.seedlotSource.seedlotSourceCode === 'TPT'
? (
<Button
kind="secondary"
size="md"
className="edit-save-btn"
renderIcon={isReadMode ? Edit : Save}
onClick={handleEditSaveBtn}
disabled={getSeedlotBySeedlotNumberQuery.isSuccess
&& getSeedlotBySeedlotNumberQuery.data.data.originalSeedQty > 0}
>
{isReadMode ? 'Edit seedlot' : 'Save edit'}
</Button>
)
: null
}
<Button
kind="secondary"
size="md"
className="edit-save-btn"
renderIcon={isReadMode ? Edit : Save}
onClick={handleEditSaveBtn}
>
{isReadMode ? 'Edit seedlot' : 'Save edit'}
</Button>

<Breadcrumbs
crumbs={
Expand Down
10 changes: 9 additions & 1 deletion sync/src/module/data_synchronization.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,6 @@ def process_seedlots(oracle_config, postgres_config, track_config, track_db_conn
logger.debug('Main driver SEEDLOT data loaded on in-memory dataframe')

processes = [[{"interface_id":"SEEDLOT_EXTRACT","execution_id":"101","execution_order":"10","source_file":"/SQL/SPAR/POSTGRES_SEEDLOT_EXTRACT.sql","source_table":"spar.seedlot","source_db_type":"POSTGRES","target_table":"the.seedlot","target_primary_key":"seedlot_number","target_db_type":"ORACLE","run_mode":"UPSERT","ignore_columns_on_update":"extraction_st_date,extraction_end_date,seed_store_client_number,seed_store_client_locn,temporary_storage_start_date,temporary_storage_end_date,seedlot_status_code"}]
,[{"interface_id":"SEEDLOT_OWNER_QUANTITY_EXTRACT","execution_id":"102","execution_order":"20","source_file":"/SQL/SPAR/POSTGRES_SEEDLOT_OWNER_QUANTITY_EXTRACT.sql","source_table":"spar.seedlot_owner_quantity","source_db_type":"POSTGRES","target_table":"the.seedlot_owner_quantity","target_primary_key":"seedlot_number,client_number,client_locn_code","target_db_type":"ORACLE","run_mode":"UPSERT","ignore_columns_on_update":"qty_reserved,qty_rsrvd_cmtd_pln,qty_rsrvd_cmtd_apr,qty_surplus,qty_srpls_cmtd_pln,qty_srpls_cmtd_apr"}]
,[{"interface_id":"SEEDLOT_SEED_PLAN_ZONE_EXTRACT","execution_id":"103","execution_order":"30","source_file":"/SQL/SPAR/POSTGRES_SEEDLOT_SEED_PLAN_ZONE_EXTRACT.sql","source_table":"spar.seedlot_seed_plan_zone","source_db_type":"POSTGRES","target_table":"the.seedlot_plan_zone","target_primary_key":"seedlot_number,seed_plan_zone_code","target_db_type":"ORACLE","run_mode":"UPSERT_WITH_DELETE","ignore_columns_on_update":""}]
,[{"interface_id":"SEEDLOT_GENETIC_WORTH_EXTRACT","execution_id":"104","execution_order":"40","source_file":"/SQL/SPAR/POSTGRES_SEEDLOT_GENETIC_WORTH_EXTRACT.sql","source_table":"spar.seedlot_genetic_worth","source_db_type":"POSTGRES","target_table":"the.seedlot_genetic_worth","target_primary_key":"seedlot_number,genetic_worth_code","target_db_type":"ORACLE","run_mode":"UPSERT_WITH_DELETE","ignore_columns_on_update":""}]
,[{"interface_id":"SEEDLOT_PARENT_TREE_EXTRACT","execution_id":"105","execution_order":"50","source_file":"/SQL/SPAR/POSTGRES_SEEDLOT_PARENT_TREE_EXTRACT.sql","source_table":"spar.seedlot_parent_tree","source_db_type":"POSTGRES","target_table":"the.seedlot_parent_tree","target_primary_key":"seedlot_number,parent_tree_id","target_db_type":"ORACLE","run_mode":"UPSERT_WITH_DELETE","ignore_columns_on_update":""}]
Expand All @@ -319,6 +318,7 @@ def process_seedlots(oracle_config, postgres_config, track_config, track_db_conn
,[{"interface_id":"SMP_MIX_EXTRACT","execution_id":"108","execution_order":"80","source_file":"/SQL/SPAR/POSTGRES_SMP_MIX_EXTRACT.sql","source_table":"spar.smp_mix","source_db_type":"POSTGRES","target_table":"the.smp_mix","target_primary_key":"seedlot_number,parent_tree_id","target_db_type":"ORACLE","run_mode":"UPSERT_WITH_DELETE","ignore_columns_on_update":""}]
,[{"interface_id":"SMP_MIX_GEN_QLTY_EXTRACT","execution_id":"109","execution_order":"90","source_file":"/SQL/SPAR/POSTGRES_SMP_MIX_GEN_QLTY_EXTRACT.sql","source_table":"spar.smp_mix_gen_qlty","source_db_type":"POSTGRES","target_table":"the.smp_mix_gen_qlty","target_primary_key":"seedlot_number,parent_tree_id,genetic_type_code,genetic_worth_code","target_db_type":"ORACLE","run_mode":"UPSERT_WITH_DELETE","ignore_columns_on_update":""}]
]

with db_conn.database_connection(oracle_config) as target_db_conn:
try:
seedlotlst = []
Expand All @@ -327,6 +327,14 @@ def process_seedlots(oracle_config, postgres_config, track_config, track_db_conn
seedlot_metrics['step'] = "Seedlot"
seedlot_metrics['seedlot_number'] = seedlot.seedlot_number

original_seed_qty_query = "SELECT ORIGINAL_SEED_QTY FROM the.seedlot WHERE seedlot_number = :seedlot_number"
result = target_db_conn.execute(original_seed_qty_query, params={"seedlot_number": seedlot.seedlot_number})

if result is not None:
original_seed_qty = result.fetchone()
if original_seed_qty and not original_seed_qty[0]:
processes.append([{"interface_id":"SEEDLOT_OWNER_QUANTITY_EXTRACT","execution_id":"102","execution_order":"20","source_file":"/SQL/SPAR/POSTGRES_SEEDLOT_OWNER_QUANTITY_EXTRACT.sql","source_table":"spar.seedlot_owner_quantity","source_db_type":"POSTGRES","target_table":"the.seedlot_owner_quantity","target_primary_key":"seedlot_number,client_number,client_locn_code","target_db_type":"ORACLE","run_mode":"UPSERT","ignore_columns_on_update":"qty_reserved,qty_rsrvd_cmtd_pln,qty_rsrvd_cmtd_apr,qty_surplus,qty_srpls_cmtd_pln,qty_srpls_cmtd_apr"}])

#delete all tables in RI order (reversing order of processes dataframe)
#note - special handling for seedlot_owner_quantity
delete_metrics = delete_seedlot_child_tables(seedlot_number=seedlot.seedlot_number,
Expand Down
5 changes: 3 additions & 2 deletions sync/src/module/database_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,12 @@ def __exit__(self, exc_type, exc_val, exc_tb):

def execute(self, query, params):
""" Runs a SQL statement. """
self.conn.execute(text(query), params)
result = self.conn.execute(text(query), params or {})
return result

def select(self, query, params=None):
""" Runs a SQL statement. """
result = self.conn.execute(text(query), params)
result = self.conn.execute(text(query), params or {})
return result

def health_check(self) -> bool:
Expand Down

0 comments on commit 764bfd4

Please sign in to comment.