-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DDP-5826-filling the kit history from files #187
base: develop
Are you sure you want to change the base?
Conversation
Added fix for when there is activity in DB
import static org.broadinstitute.dsm.TestHelper.setupDB; | ||
import static org.broadinstitute.dsm.util.tools.TbosUPSKitTool.readFile; | ||
|
||
public class UPSKitToolTest { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made this class to test the methods I made in the migatioonTool
"left join ups_package pack on (ship.ups_shipment_id = pack.ups_shipment_id) " + | ||
"where kit.dsm_kit_request_id = ? and pack.tracking_number = ?"; | ||
|
||
public static Map readFile(String fileName) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
method to read the kits for the participant and build a HashMap
int kitCounter = 0; | ||
for (; kitCounter < kits.size(); kitCounter++) { | ||
Kit kit = kits.get(kitCounter); | ||
Kit outboundKit = getDDBKitBasedOnKitLabel(SQL_SELECT_KIT_BY_KIT_LABEL + SQL_SELECT_OUTBOUND, kit.getKitLabel(), ddpInstance.getDdpInstanceId()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Find the kit info in the DB, so we can find the tracking numbers and also see if there is already activity info for the kit in db
} | ||
} | ||
|
||
public static String decideWhatToInsertForKit(Kit fileKit, Kit dbKit, boolean isRetrun) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method decides what activities from the file is missing in DSM database, if a kit doesn't have any any activity, it inserts all that it is in the file
String insertedShipmentId = null; | ||
if (StringUtils.isBlank(dbKit.getLastActivityDesc())) {//insert everything if the kit doesn't have any shipments in bd | ||
logger.info("Inserting Shipment, Package and all activities for kit " + fileKit.getKitLabel()); | ||
insertedShipmentId = insertKitInDB(fileKit, isRetrun);//most of the kits should end up here |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if a kit has no activity in ups_activity, then we must insert all
String firstActivityTime = isRetrun ? fileKit.getPickedUpAt() : fileKit.getShippedAt(); | ||
String lastActivityTime = isRetrun ? fileKit.getReceivedAt() : fileKit.getDeliveredAt(); | ||
if (StringUtils.isNotBlank(firstActivityTime)) { | ||
if (shouldInsertBasedOnTimeForKit(dbKit, firstActivityTime)) {//last activity in DB is before the shipped at |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here, it checks what is the latest activity in the db for the kit, and if the activity in the file is later than the one we have in the db, then we insert the one in the file. This is because when UPSJob was ran the first time, it inserted every available activity for the all of the valid and not delivered tracking numbers, so if the latest activity we have in db is older than the ones in file, activities before that should also be already in db
return insertedShipmentId; | ||
} | ||
|
||
public static boolean shouldInsertBasedOnTimeForKit(@NonNull Kit dbKit, String utcDateTimeString) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
converts the UTC time in the CSV file and compares it with the EST time in the DB
TbosUPSKitTool.littleMain(fileName); | ||
} | ||
|
||
private static void littleMain(String fileName) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the method that we should call when we want to run this
can we close that one? |
1 similar comment
can we close that one? |
No description provided.