FIDS Documentation
FIDS Documentation
Document
for Supply, Install, Configure, Testing and
Commissioning of Digital Platform and
Application Including Comprehensive
Maintenance for Malaysia Airports (Sepang)
Sdn. Bhd.
Document version: 1.0
Version date: 6th August 2021
Table of Contents
Contents
Table of Contents ........................................................................................................ 2
2. Get APIs........................................................................................................................................ 57
Commercial in Confidence
FIDS APIs Document
Commercial in Confidence
FIDS APIs Document
Acronym Definition
3D 3 Dimensional
B2C Business-to-Consumer
Commercial in Confidence
FIDS APIs Document
1. FIDS ActiveFlight
This section defines a Java package com.mahb.fids.controller to organize classes and provides
necessary imports. The class ActiveFlightController is a Spring RestController responsible for
handling HTTP requests related to active flights. The annotations @Slf4j, @RestController,
@CrossOrigin, and @RequestMapping are used for logging, marking the class as a controller,
allowing cross-origin requests, and specifying the base URL for this controller, respectively.
Commercial in Confidence
FIDS APIs Document
This @PostMapping annotation specifies that this method will handle HTTP POST requests to the
endpoint defined by the @RequestMapping annotation. The addFlightPlan method takes a JSON
request body (message) and processes it.
Inside the method, it logs the incoming message using Java's Logger with the name "fidsMessage".
Then, it attempts to process the message using the fidMessageProcessor instance that was
injected earlier. If an exception occurs during message processing, it sets the hasException flag to
true and logs the error.
After processing the message (or encountering an exception), the method constructs a response
using a HashMap. It includes two key-value pairs: "success" (set to true) and "exception" (set to
the value of the hasException flag). This response is then returned to the client.
Overall, the ActiveFlightController class serves as an entry point for handling incoming HTTP POST
requests related to active flight messages. It logs the received message, processes it using the
IFIDMessageProcessor service, handles exceptions, and responds with a success flag and
exception status. The architecture follows the Spring framework's MVC (Model-View-Controller)
pattern, where the controller handles incoming requests and delegates business logic to the
injected service (IFIDMessageProcessor).
The given code is a Java method that processes incoming messages. Let's break down the code
and explain it step by step, along with a simplified flowchart to help you understand the process:
Commercial in Confidence
FIDS APIs Document
1) The method is named processMessage and takes a single argument fidMessage of type String.
It throws an exception of type Exception.
2) The method begins by calling the getDocument method with the fidMessage to obtain a
Document object. If the doc is null, the method returns false, indicating that the message
processing failed.
3) The method then extracts the msgCode from the doc. If the msgCode is empty, it returns false.
4) The code now checks the value of msgCode and follows different branches based on its value.
There are three possible cases: MSG_CODE_FIDAFS, MSG_CODE_MASBAFS, and other cases.
5) Case MSG_CODE_FIDAFS: If the msgCode is equal to "FIDAFS", it means the message is of type
FIDAFS. It proceeds to convert the fidMessage XML into a FIDAFSMessage object. It then
iterates over each payload in the message.
6) Inside the payload loop, a new TransactionTemplate is created with a new transaction scope.
The updateOrInsertSchedule method is executed within this transaction scope, which handles
updating or inserting schedules based on the payload and message code.
7) If an error occurs during the process, an error status is set, and the exception details are
logged.
8) After processing each payload, a list of process statuses is collected. These statuses indicate
the success or failure of each payload processing.
9) After processing all payloads, the rawMessageProcessor is used to save the raw message and
process statuses. The method then returns true.
10) Case MSG_CODE_MASBAFS: This case is similar to the previous one but for the message code
"MASBAFS". It processes payloads of type MASBAFSPayload using the
updateOrInsertScheduleMASBAFSFlights method.
11) Default Case: If the msgCode does not match any of the above cases, the code enters a loop.
Within this loop, it identifies the specific message type based on the msgCode and executes
the corresponding update method using a TransactionTemplate.
Commercial in Confidence
FIDS APIs Document
13) If any other exception occurs, it is caught, and an error status is set. The details of the
exception are logged.
14) Once the processing is complete, the rawMessageProcessor is used to save the raw message
and process status.
Flowchart
Start
[getDocument]
/ \
[Extract msgCode]
/ \
/ | \
| | |
Commercial in Confidence
FIDS APIs Document
| | |
| | |
| | |
| | |
End
1.2 MSG_CODE_MASBAFS:
The provided code is a Java program that appears to handle the processing of XML messages
related to flight information. It involves parsing XML messages, extracting data, and updating or
inserting flight information into a database. Here's a detailed explanation of the code along with
a simplified flowchart:
• The code starts by checking if the incoming message has a specific message code
("MASBAFS").
• The incoming XML message is parsed into a Java object using JAXB (Java Architecture for
XML Binding).
• The code iterates through the list of payloads within the MASBAFSMessage.
Commercial in Confidence
FIDS APIs Document
• If an exception occurs during the execution of the method, an error status is set for the
payload.
• This method updates or inserts flight information based on the payload data.
• It retrieves an ActiveFlight object from a database using the payload's AFSkey (flight
identifier).
• This method populates an ActiveFlight object with data from the payload.
• If the flight already exists in the database, various attributes of the ActiveFlight object are
updated with payload data.
• If the flight is new, attributes like afsKey, flightNumber, and others are populated.
Flowchart Overview: This flowchart gives an overview of the code's logic and how the different
methods and data processing steps are connected.
In summary, the code processes XML messages containing flight-related information, extracts
data, updates or inserts flight records in a database, and tracks the processing status for each
Commercial in Confidence
FIDS APIs Document
payload. It utilizes a structured approach to handle transactions, error handling, and data
population, ensuring accurate and consistent flight information management.
1.3 MSG_CODE_FIDAFS:
The code is focused on processing XML messages related to flight information. It follows a series
of steps to parse incoming messages, extract relevant data, update or insert flight details into a
database, and handle error scenarios. Here's a high-level overview of the process:
• The code begins with an ‘if’ condition that checks if the incoming message's code matches
a specific value (MSG_CODE_FIDAFS). If the condition is met, the processing of the
message begins.
• The incoming XML message is converted into a ‘FIDAFSMessage’ object using JAXB (Java
Architecture for XML Binding). This class represents the structure of the XML message and
holds information about the flight header and payloads.
• The code iterates through each payload within the incoming message.
• After processing all payloads, the code saves the processed data, including the header, raw
message, and processing statuses, into a database using
rawMessageProcessor.saveFIDSRawMessage().
Commercial in Confidence
FIDS APIs Document
This line retrieves the payload from an asm1Message object. It seems like asm1Message is an
instance of a class that contains some kind of message, possibly related to flight data.
This line retrieves a property named AFSkey from the payload and converts it to a Long data type
after trimming any leading and trailing spaces. It's assuming that the value in AFSkey is a string
representation of a Long.
This line attempts to retrieve an ActiveFlight object from a repository using the afs value obtained
from the previous step. If no object is found with the specified ID, it assigns null to activeFlight.
If the activeFlight object was not found in the repository (i.e., activeFlight is null), a new instance
of ActiveFlight is created.
This line seems to invoke a method named fillFromAFSPayload with three arguments: the
activeFlight object, the payload, and a code obtained from the message header. This method
appears to populate the activeFlight object with data from the payload.
6. activeFlightRepository.save(activeFlight);
This line saves the activeFlight object (either newly created or updated) back to the repository,
presumably persisting it in a database.
A new instance of PayloadProcessStatus is created. This class likely represents some kind of status
or result related to the processing of the payload.
8. setPayloadSuccessStatus(processStatus, activeFlight);
Commercial in Confidence
FIDS APIs Document
It seems like this line invokes a method named setPayloadSuccessStatus with two arguments: the
processStatus object and the activeFlight object. This method likely sets some success status or
metadata in the processStatus object based on the processing outcome.
9. return processStatus;
The processStatus object is returned, possibly to indicate the outcome of the payload processing.
FIDAFSMessage: Represents the structure of the XML message containing flight header and
payloads. It is annotated using JAXB annotations for XML mapping.
FIDAFSPayload: Represents the payload data within the XML message. It holds various flight-
related details.
ActiveFlight: Represents flight-related information and is used for updating or inserting data into
the database.
Flowchart:
Given the complexity of the code and the number of interconnected components, creating a
concise flowchart might be challenging. However, I can provide you with a textual representation
of the flow:
1. Start
Commercial in Confidence
FIDS APIs Document
End transaction
7. End
This flowchart represents the main logic of the provided code, focusing on processing incoming
XML messages related to flight data and updating the database accordingly.
Please note that the actual implementation might involve further complexities, interactions with
database repositories, and potentially additional error handling that is not explicitly detailed in
the provided code snippet. It's recommended to thoroughly review and test the code in a
development environment before deployment.
1.4. MSG_CODE_MASBDLT:
The code appears to be a Java program that processes XML messages related to flight information
using the JAXB library for XML binding. It handles messages of different types, specifically focusing
on the "MASBDLT" message type. This code involves parsing incoming XML messages, extracting
relevant information, and processing the payload data.
Here's a detailed explanation of the code along with a textual representation of the flowchart:
The code is part of a larger program that processes different types of XML messages. It focuses on
the "MASBDLT" message type and performs the following steps:
Commercial in Confidence
FIDS APIs Document
b. The XML message is parsed using JAXB, and an instance of MASBDLTMessage is created from
the XML data.
c. The header and payload data are extracted from the MASBDLTMessage.
• The MASBDLTMessage class is a Java representation of the XML structure for a "MASBDLT"
message. It uses JAXB annotations to map XML elements to Java fields.
• The main method is a test scenario. It creates an example XML message, parses it into a
MASBDLTMessage object, and then prints the value of the AFSkey. It also demonstrates the
conversion of the message object back to XML.
This method is responsible for setting the payload processing status to success and populating
details from the ActiveFlight object.
Flowchart:
Commercial in Confidence
FIDS APIs Document
f. In the deleteFlightForMasb method, the AFS key is used to find and delete the corresponding
flight.
g. The payload processing status is set to success and populated with relevant details. h. The
program ends.
This explanation provides an overview of how the code processes "MASBDLT" messages, extracts
payload data, and deletes corresponding flights. It is advisable to provide additional context and
explanations if this code snippet is part of a larger application.
1.5 MSG_CODE_FIDASM1:
The code appears to be part of a Java application that deals with processing and updating flight
schedule information. The code is related to handling XML messages containing flight schedule
data and updating the corresponding database records. I'll break down the code and provide an
overview along with a simplified flowchart for better understanding.
• The code starts with a conditional block that checks if the received message code is equal
to "FIDASM1".
• The XML message is parsed using the XMLUtils.convertToObject method, which converts
the XML content into a Java object of the FIDASM1Message class. This class has a structure
that matches the XML message's structure.
Commercial in Confidence
FIDS APIs Document
• This method processes the payload of the message and updates flight schedule
information in the database.
• The flight schedule data is stored in the ActiveFlight entity, which represents a record in
the database table tb_activeflight.
• Retrieves an existing ActiveFlight record based on the AFS key (flight key). If the record
doesn't exist, a new one is created.
• Populates the ActiveFlight object with data from the XML payload, updating various
properties such as flight number, departure time, station codes, and more.
• Saves the updated or new ActiveFlight object back to the database using the
activeFlightRepository.
The main method demonstrates the usage of the code by creating an example XML message,
converting it into a FIDASM1Message object, and printing out the message code.
Flowchart:
Commercial in Confidence
FIDS APIs Document
f. Create PayloadProcessStatus
g. Return PayloadProcessStatus
h. End
1.6 MSG_CODE_FIDASM2:
The provided code seems to be a part of a Java application that deals with processing and updating
flight-related information using XML messages.
• The code processes XML messages related to flight information. It appears to handle
messages with a specific message code (FIDASM2).
• When such a message is received, the program extracts the header and payload from the
XML message and processes the payload to update flight cancellation schedules.
• It consists of a header and a payload, both of which have specific attributes like msgCode,
msgSubtype, etc. The getHeader() and getPayload() methods provide access to these
attributes.
Commercial in Confidence
FIDS APIs Document
• This class represents the payload of the XML message. It contains various attributes related
to flight details, such as actionCode, AFSkey, flightNo, etc.
• These attributes are annotated with @XmlElement to specify their XML element names.
• This inner class represents the status of the payload processing. It holds attributes like
flightNumber, afsKey, status, errMsg, and STAD (flight start date).
• This class appears to be an entity class used for persisting flight-related information in a
database.
• It contains a wide range of attributes, including flight details, timings, codes, and flags.
• This method sets success status and payload attributes in the PayloadProcessStatus object.
• The main method simulates the processing of an XML message. It creates a sample XML
message, converts it into a FIDASM2Message object, and prints out the actionCode from
the payload.
Overall Flow:
The program starts by receiving an XML message. It checks if the message code is valid. If valid, it
extracts the payload, updates flight schedules, and sets success status. The program includes
Commercial in Confidence
FIDS APIs Document
entity classes to represent flight data and methods to update and handle various aspects of flight
details.
1.7 MSG_CODE_FIDADMRAD:
The code is a Java program that appears to handle processing and updating of flight-related data
in a database.
• The program seems to be processing messages related to flight data. It looks for specific
message codes and performs corresponding actions.
• The main processing block involves updating the disposition of an aircraft based on the
message received.
• The program receives XML messages. It uses JAXB annotations (@XmlElement) to map
XML elements to Java objects.
• There are two primary classes involved: FIDADMRADMessage and FIDAFSPayload. The
FIDADMRADMessage contains a header (RTMessageHeader) and payload
(FIDAFSPayload).
The XML messages are parsed into instances of these classes.
• The program extracts information from the parsed XML, such as message codes, flight
details, and timestamps.
• The core of the program involves updating the disposition of an active flight. T
• his includes setting various attributes of the ActiveFlight object based on the payload data.
Commercial in Confidence
FIDS APIs Document
• The program includes a utility method getUTCDateValue that parses date values from the
payload using a specified format. The method handles UTC time and converts it into a Java
Date object.
The PayloadProcessStatus class is used to encapsulate the processing status of a payload. It holds
information about the flight, status, error message, and timestamps.
Flowchart:
6. Return Status
1.8 MSG_CODE_FIDCHKALC
The provided code appears to be part of a Java application that handles messages related to
Check-In Counter Allocation/Reallocation in the aviation industry. The code processes XML
messages, extracts relevant information, interacts with a database, and performs various actions
based on the message contents. Below is a detailed explanation of the code along with a simplified
flowchart for better understanding:
Commercial in Confidence
FIDS APIs Document
The application starts by receiving an XML message containing information about Check-In
Counter Allocation/Reallocation. The XML structure consists of a header and payload section.
The header section of the XML message contains metadata about the message. The msgCode field
within the header indicates the type of message, and it is compared to the constant
MSG_CODE_FIDCHKALC to identify the message type.
If the message code matches MSG_CODE_FIDCHKALC, the application proceeds to extract the
payload information from the XML message. The payload includes details about the action to be
performed, flight number, departure time, counter code, scheduled counter open time, and
scheduled counter close time.
The extracted payload data is converted into a Java object of the FIDCHKALCMessage class using
the XMLUtils.convertToObject method.
Once the payload data is converted to an object, the application proceeds to process the data and
perform actions based on the extracted information. The updateCheckInCounter method is called,
which updates the check-in counter based on the provided information.
The updateCheckInCounter method first retrieves the departure date, and then queries the
database to retrieve information about the active flight associated with the provided flight
number and departure date. If the active flight is found, the method further queries the database
to retrieve information about the check-in counter associated with the active flight and counter
code.
Depending on the actionCode extracted from the payload, different actions are taken:
Commercial in Confidence
FIDS APIs Document
• If the action code is "A" (Add), a new check-in counter is created or updated with the
provided open and close times.
• If the action code is "U" (Update), the existing check-in counter is updated with the
provided times.
• If the action code is "D" (Delete), the existing check-in counter is deleted from the
database.
After performing the necessary actions, a PayloadProcessStatus object is created to indicate the
processing status. The setPayloadSuccessStatus method updates the status with information from
the active flight.
The code includes two custom queries, getByFlightAndStad and getByAFSAndCounter, to retrieve
active flight and check-in counter information from the database.
The getUTCDateValue method is responsible for parsing date values from the payload using a
specified date format.
1.8.11. Flowchart:
1. Start
2. XML Input
3. Parse XML
4. Identify Message
5. Extract Payload
6. Convert to object
7. Retrieve Data
Commercial in Confidence
FIDS APIs Document
8. Database Queries
9. Perform Action
1.9 MSG_CODE_FIDDLTFLT
Certainly! The code is a Java application that handles XML messages related to flight data. It
processes a specific type of XML message, namely the FIDDLTFLTMessage.
• The code appears to be a part of a larger system where XML messages are being processed
based on different message codes.
• The MSG_CODE_FIDDLTFLT is being checked against the incoming message's code using
the equalsIgnoreCase method. If it matches, the code proceeds to process the message.
• The incoming XML message is converted into a Java object of type FIDDLTFLTMessage using
the XMLUtils.convertToObject method.
• The FIDDLTFLTMessage class is a representation of the XML structure for the specific
message type.
• It has two main attributes: header and payload, which correspond to the header and
payload of the XML message, respectively.
• The class uses JAXB annotations like @XmlElement to map the XML elements to Java
attributes.
• The main method demonstrates how an XML message string is parsed into a
FIDDLTFLTMessage object using the XMLUtils.convertToObject method.
Commercial in Confidence
FIDS APIs Document
• This method is responsible for processing the payload of the incoming message and
performing specific actions.
• The AFSkey from the payload is used to identify a flight in the system.
• If the flight is found, it is deleted from the repository. Additionally, based on the
flightMode, the flight might be deleted or updated.
• This method is used to set success attributes in the PayloadProcessStatus object based on
the processed flight data.
1.9.6. Flowchart:
1. Start
Commercial in Confidence
FIDS APIs Document
6. Execute deleteFlightSchedule
1.10 MSG_CODE_FIDDLYDET
The code is a Java program that handle XML messages related to flight delay information. It
involves processing XML messages, extracting data from them, and performing certain actions
based on the extracted information.
The main flow of the code seems to be focused on handling XML messages with a specific
msgCode called "FIDDLYDET". Let's go through the main components of the code.
The code starts by processing XML messages. It uses a utility called XMLUtils.convertToObject to
convert an XML message into a Java object of type FIDDLYDETMessage. This class contains the
header information (RTMessageHeader) and payload data (FIDDLYDETPayload) of the XML
message.
Commercial in Confidence
FIDS APIs Document
After extracting the header and payload from the XML message, the code checks if the msgCode
matches "FIDDLYDET". If the condition is met, it proceeds to process the message further.
The updateFlightDelaySchedule method is responsible for processing the payload data and
updating flight delay information in a data repository. It retrieves relevant information from the
payload, searches for a corresponding flight in a repository, and updates its delay status and other
attributes.
The code includes a method called getUTCDateValue that is used to parse date values from the
payload.
It uses a specific date format and handles time zone conversion to UTC.
There's a method called getByFlightAndStadAndLeg that queries a data repository to retrieve flight
information based on flight number, scheduled time, and leg.
The code defines a class called PayloadProcessStatus to store the processing status of the payload.
This class holds details about the flight number, status, error messages, and more.
The code also includes a method called setPayloadSuccessStatus that sets the success status of
the payload processing. It populates the PayloadProcessStatus object with relevant details.
The code defines two main classes for representing the XML structure:
FIDDLYDETMessage: Contains header and payload information. It includes methods for retrieving
and setting header and payload data.
FIDDLYDETPayload: Represents the payload data. It includes methods for retrieving and setting
various payload attributes.
Commercial in Confidence
FIDS APIs Document
The code includes a main method to demonstrate how the XML message parsing and processing
work. It creates an example XML message, converts it to a FIDDLYDETMessage object, and prints
out the action code from the payload.
1.10.11. Flowchart:
3.1. The flight details are retrieved from the payload and used to search for a flight in the data
repository.
This is a high-level overview of the code's flow. It demonstrates how XML messages are processed,
payload data is extracted and used to update flight information, and a status object is created to
represent the processing result.
1.11 MSG_CODE_FIDDSPFLG
The code is a Java program that handles the processing of XML messages related to flight display
flags. The code defines classes and methods to parse and manipulate XML messages, update flight
information, and manage process status.
Commercial in Confidence
FIDS APIs Document
The program starts by parsing an XML message using JAXB (Java Architecture for XML Binding).
The XML message structure consists of a header and a payload, where the payload contains
information about the flight display flag.
The code contains a series of conditional checks using if and else if statements to determine the
type of message based on the msgCode attribute in the XML header. In this case, the code snippet
handles messages with the MSG_CODE_FIDDSPFLG value.
If the message code matches, the program converts the XML message into Java objects using the
XMLUtils.convertToObject method. The header and payload of the message are extracted for
further processing.
The method updateFlightDisplayFlag is called with the extracted payload. Inside this method:
• The program retrieves information from the payload, such as the flight's AFS key, departure
time (STAD), and display flag status.
• If the existing flight mode is either 3 or 6, the flight display flag is updated in the database
using a custom query.
After updating the flight display flag in the database, the program updates the corresponding
ActiveFlight object with the new display flag, update time, and update user ID.
The modified ActiveFlight object is then saved back to the database using the
activeFlightRepository.save method.
Commercial in Confidence
FIDS APIs Document
A PayloadProcessStatus object is created to represent the status of the payload processing. The
status, error message (if any), flight information, and other relevant data are set in this object.
The payload processing status is returned at the end of the updateFlightDisplayFlag method.
The provided main method demonstrates the conversion of an XML message into Java objects,
extraction of payload data, and printing the display flag status.
Commercial in Confidence
FIDS APIs Document
1.12 MSG_CODE_FIDFCCHK
The code is part of a Java program that handles XML message processing related to flight
information, specifically focusing on check-in counter open/close activities. The code consists of
several classes and methods that work together to parse and process XML messages containing
flight-related data.
• The code seems to be part of a larger system where different XML messages are processed
based on their message codes.
• The FIDFCCHKMessage class represents the structure of the XML message. It has a header
and a payload, where the header contains metadata, and the payload contains detailed
information about the check-in counter open/close activity.
• The FIDFCCHKPayload class represents the payload of the XML message, containing
various attributes related to the check-in counter activity.
• The code uses XMLUtils.convertToObject to convert the received XML message into a Java
object of type FIDFCCHKMessage.
• This method takes a FIDFCCHKMessage object as input and processes the payload to
update the status of check-in counters based on the action code.
• It retrieves various attributes from the payload such as flight number, arrival/departure
time, and action code.
• It performs database operations to update the status of check-in counters based on the
action code. • Depending on the actionCode, the counter status is updated to "Open" or
"Close."
• Additionally, it updates flight remark codes based on certain conditions and triggers
secondary updates.
The code includes database update queries to modify the status and timestamps of check-
in counters in the CheckInCounter table.
1.12.6. Annotations:
1. Start Processing
2. Parse XML
3. Extract Header
4. Extract Payload
6. Update Remark
7. Secondary Update
9. Finish Processing
1.13 MSG_CODE_FIDFCLNG1
The code seems is of a Java application that deals with processing XML messages related to lounge
open/close activities for flights. The application involves parsing XML messages, updating flight
information in a database, and performing some additional operations.
• The code appears to be part of a larger system where different types of messages are being
processed. It focuses on messages with a specific message code, FIDFCLNG1, which
indicates lounge open/close activities.
• The FIDFCLNG1Message class represents the structure of the XML message. It includes a
header and a payload section. The FIDFCCHKPayload class represents the payload content.
The payload contains information about flight details, lounge codes, action codes, and
other relevant data.
The main method in the FIDFCLNG1Message class demonstrates how to parse a sample
XML message into a Java object. It creates an instance of FIDFCLNG1Message using the
provided XML and prints out the remarkCode from the payload.
• It checks the actionCode in the payload to determine whether to open or close the lounge.
If the action is to open the lounge (O), it updates various properties of the activeFlight
object and saves it to the database. If the action is to close the lounge (C), similar updates
are performed.
• The method syncSecondaryFlight is called after specific updates to the activeFlight object.
It appears to trigger a synchronization process for secondary flight data.
• It updates various properties of the activeFlight object and performs an update operation
in the database using the updateSecondaryFlights method.
• The code makes use of database queries through JPA annotations. It retrieves an
activeFlight object based on flight details (flight number, STAD, category) using the
getByFlightAndStadAndCategory method.
1.14 MSG_CODE_FIDFCLNG2
The code is part of a Java program that processes XML messages related to facility activities in an
airport. The XML messages contain information about lounge boarding and final call activities for
flights. The code handles the parsing of these XML messages, updates flight status in a database,
and provides status information. Here's an explanation of the code along with a simplified
flowchart:
• The code begins with an if-else block that checks the msgCode attribute of the incoming
XML message.
The incoming XML message is converted into a Java object called FIDFCLNG2Message
using
XML deserialization. This class represents the structure of the XML message and contains
a
• The FIDFCLNG2Message class represents the parsed XML structure. It includes getters and
setters for header and payload.
• The class also has a main method that demonstrates how to parse a sample XML message
using the XMLUtils class.
This method processes the parsed FIDFCLNG2Message and updates the flight status based
on the message payload. It performs the following steps:
b. Retrieves the active flight information from a repository based on flight number, scheduled
departure time (STAD), and category code.
c. Depending on the actionCode in the payload, updates various attributes of the activeFlight
object. The attributes updated include remarks, gate and lounge codes, boarding times, and
more.
d. If the existing flight mode is 3 or 6, triggers a secondary flight update using the
syncSecondaryFlight method.
e. Prepares a PayloadProcessStatus object that stores the processing status, flight information,
and any error message.
• This method updates secondary flight attributes based on the active flight's information.
• It involves updating various attributes of the activeFlight object using a repository method.
• This nested static class represents the status of the payload processing. It contains
attributes such as flight number, status, error message, and more.
• This method sets the payload processing status as successful and populates relevant
attributes in the PayloadProcessStatus object.
1.14.8. Flowchart:
5. Update Active Flight Attributes Based on Payload Action Code and Values
1.15 MSG_CODE_FIDFCRCM1
The code is a Java program that seems to be handling the processing of XML messages related to
facility activities for a certain airline system.
The code begins with an if-else if condition that checks the type of incoming message using a
msgCode.
In this case, it's looking for a specific msgCode called "FIDFCRCM1".
When the condition is met, the incoming XML message is converted to a Java object using the
XMLUtils.convertToObject method. The resulting object is an instance of the FIDFCRCM1Message
class.
The header of the incoming message is extracted from the FIDFCRCM1Message object. Then, a
process is initiated using the template.execute method, where a method called
updateReclaimClose is executed with the incoming message object as an argument.
The FIDFCRCM1Message class is defined. It represents the structure of the XML message. It
includes a header and a payload.
The getHeader() and getPayload() methods are defined within the FIDFCRCM1Message class to
access the header and payload data respectively.
The main method contains a sample XML message as a string. It demonstrates how to deserialize
the XML into a FIDFCRCM1Message object and access the payload's RemarkCode.
The method updateReclaimClose processes the payload of the message. It extracts various
attributes from the payload and uses them to query and update data in a repository for active
flights. It also handles setting various attributes and properties of the activeFlight object.
The method queries the database to find an active flight that matches the flight number,
scheduled arrival/departure time (STAD), and category code. If no match is found, an exception
is thrown.
Otherwise, the relevant attributes of the activeFlight object are updated with payload data.
The PayloadProcessStatus class defines a simple data structure to hold processing status
information.
The method setPayloadSuccessStatus is used to set the success status of the payload processing.
It updates the processStatus object with relevant data.
1. Start Processing
2. Check msgCode
3. Deserialize XML
4. Process Header
5. updateReclaimClose
7. Update Attributes
1.16 MSG_CODE_FIDFCRCM2
The code appears to be a Java program that processes XML messages related to flight information
and updates a database with the processed information.
• The code starts by processing incoming XML messages. It appears that different types of
messages are being handled based on their message codes.
• In this case, if the message code is "FIDFCRCM2", the program extracts relevant
information from the XML and performs further processing.
• The FIDFCRCM2Message class is a Java representation of the XML structure. It has fields
to store the message header and payload data.
• The FIDFCRCM2Message class contains methods to get and set these fields.
• The main function simulates parsing an example XML message and converting it into an
instance of the FIDFCRCM2Message class using the XMLUtils.convertToObject method.
• It then retrieves and prints the remarkCode from the payload of the message.
• The method updateReclaimOpen is responsible for processing the payload of the XML
message and updating a database with the relevant flight information.
• Depending on the actionCode in the payload, different fields of the ActiveFlight entity are
updated.
1.16.5. PayloadProcessStatus:
• PayloadProcessStatus is a data class that holds information about the processing status of
the payload. It contains fields like flight number, status, error message, etc.
• There are classes like FIDFCCHKPayload that represent specific parts of the XML payload.
These classes have methods to get and set the attributes of the payload.
• The code includes methods with annotations such as @Query, @Transactional, and
@Modifying for database operations. These methods update and retrieve data from the
database.
1.16.5. Flowchart:
3. Process Data
4. Update ActiveFlight
1.17 MSG_CODE_FIDTMAIRL
The code is a Java program that appears to be part of a system for processing and updating flight
information messages.
• The code begins with an else if block that checks whether a given msgCode is equal to a
predefined constant MSG_CODE_FIDTMAIRL.
• This class represents a structured format for the incoming message. It contains the header
and payload of the message.
• The class is annotated with JAXB annotations to facilitate XML serialization and
deserialization.
• The RTMessageHeader class represents the header of the incoming message. It contains
various attributes like message code, version, time sent, etc.
• The FIDTMAIRLPayload class represents the payload of the incoming message. It contains
attributes related to flight details, such as flight number, operation time, station codes,
etc.
• The main method in the FIDTMAIRLMessage class demonstrates how to create an example
XML message, deserialize it into a FIDTMAIRLMessage object, and access its payload
attributes for testing purposes.
• It retrieves the payload, processes the flight details, and updates an ActiveFlight object in
the repository.
• This class represents the payload structure of the message. It defines various attributes
that hold flight-related information.
• This inner class defines a data structure to hold the processing status of the payload. It
includes attributes like flight number, status, error message, etc.
• This method sets the payload processing status to indicate success. It populates the
PayloadProcessStatus object with relevant information from the ActiveFlight object.
• This method updates secondary flight information based on the ActiveFlight object and
payload.
It involves updating various attributes related to gate times, delays, codes, etc.
2. If the message code matches, it deserializes the XML message into a FIDTMAIRLMessage
object.
4. If certain conditions are met, the method triggers a secondary flight update using the
syncSecondaryFlight method.
1.18 MSG_CODE_FIDTMATMS
The code is a Java program that appears to be part of a larger software system. It involves handling
and processing messages related to flight information.
The class includes getter and setter methods for both header and payload.
• This class represents the payload of the flight information message. It contains fields that
correspond to various attributes of the flight information.
• The fields include things like action code, flight number, departure/arrival times, station
codes, and more. It is also annotated with XML element names to facilitate XML parsing
and generation.
• This is a nested static class within the FIDTMATMSMessage class. It represents the status
of the payload processing. It includes fields like flight number, AFS key, status, error
message, and STAD (Scheduled Time of Arrival/Departure).
• This method processes the incoming FIDTMATMSMessage object to update flight ETA
(Estimated Time of Arrival) and ETD (Estimated Time of Departure) based on the payload.
• It does so by extracting information from the payload and using it to update the relevant
flight details in a database.
• The method checks the action code to determine whether to update ETA/ETD or ATA/ATD.
• The method also handles cases where the flight mode is either 3 or 6, which triggers a
secondary update using the syncSecondaryFlight method.
• This method is responsible for updating secondary flight information based on the active
flight's data and payload data. It updates various attributes related to gate times, delays,
etc., in the active flight repository.
• This method sets the payload process status to indicate a successful processing outcome.
It updates the status, STAD, flight number, and AFS key in the PayloadProcessStatus object.
• The main method is a test section of the code. It creates a sample XML message, converts
it into a FIDTMATMSMessage object using the XMLUtils.convertToObject method, and
prints out the action code from the payload.
The code implements a process for updating flight information based on incoming messages. It
handles different action codes, updates flight details, and maintains process status. The code
seems to be part of a larger system that interacts with flight data.
1.19 MSG_CODE_FIDUNDOFLT
The provided code seems to be a Java application that processes XML messages related to flight
data.
The code starts with an if-else if block that checks whether the message code (msgCode) is equal
to "FIDUNDOFLT" or "ODBOOBFLT" ignoring the case. If either condition is met, it performs the
following actions:
It converts the incoming XML message (in the fidMessage variable) into a Java object of type
FIDUNDOFLTMessage. The FIDUNDOFLTMessage class is annotated with JAXB
(@XmlRootElement) annotations to specify how XML elements are mapped to Java object
properties.
The code retrieves the header from the FIDUNDOFLTMessage object and stores it in the header
variable.
The code calls the removeFlightRemarkCOde method and passes the FIDUNDOFLTMessage object
to it for further processing.
This class defines the structure of the XML message. It has a header (RTMessageHeader) and a
payload (FIDUNDOFLTPayload). The main method shows an example of how an XML message can
be converted into a FIDUNDOFLTMessage object.
This class represents the payload data structure of the XML message. It includes fields like AFSkey,
flightNo, leg, STAD, and officialFlightDate.
This method processes the payload of the XML message. It retrieves information from the
payload, such as AFSkey, STAD, and flightNo. It then performs various operations on the
activeFlight entity based on conditions and updates its attributes.
The code interacts with an entity called ActiveFlight. It seems to update certain attributes of this
entity based on conditions specified in the removeFlightRemarkCOde method.
1.19.9. Flowchart:
6. If the entity is found, various updates are made to its attributes based on conditions.
8. Remember that this is a high-level explanation and the actual behavior could be
influenced by the details of the ActiveFlightRepository interface and its underlying
implementation, as well as any potential interactions with external systems.
The code is a Java program that seems to handle the processing of XML messages related to flight
data.
• The code begins with several import statements that bring in necessary classes from
different packages.
• This class represents the overall XML message structure for flight data.
• It contains various fields that correspond to different attributes of flight data, such as flight
number, station codes, timestamps, etc.
• Each field has a corresponding getter and setter method annotated with @XmlElement.
• The main method demonstrates the usage of these classes by creating an XML message
string, parsing it, and printing the value of a specific field (STAD) from the payload.
• This method processes the payload data related to flight chock information.
• It extracts relevant data from the payload, updates an ActiveFlight object, and saves it to
a repository.
• Depending on the value of the chockIndicator field, it sets different attributes of the
ActiveFlight object.
• The code includes a getUTCDateValue method that converts a date string in a specific
format to a Date object in UTC timezone.
• This method handles parsing errors and logs any issues encountered during the parsing
process.
• This is a nested class within the main class, used to encapsulate the status of the payload
processing.
• It has fields to store flight-related information, status, error messages, and a timestamp
(STAD).
1.20.9. Flowchart:
Main Flow:
6. It extracts payload data and identifies the flight number, timestamp, and chock indicator.
8. Depending on the chock indicator, it updates the on-block or off-block time for the flight.
1.21 MSG_CODE_GASSNDALC
The code seems to be a part of a Java application that processes XML messages related to flight
information.
• If the condition is true, it indicates that a specific type of message with the code
"GASSNDALC" is being processed.
• The RTMessageHeader class represents the header section of the message. It contains
various attributes such as msgCode, msgSubtype, msgVersion, and so on.
This method processes the incoming FIDGASSNDALCMessage by extracting information from its
payload and performing some database-related operations.
2. Retrieves an ActiveFlight object from the database based on the extracted flight
information.
3. Updates the STANDCODE and potentially the GATELOUNGECODE of the active flight.
5. Checks the existing flight mode and triggers a secondary update under certain conditions.
• The main method demonstrates how to create an XML message, convert it into a
FIDGASSNDALCMessage object, and access attributes from the payload for testing
purposes.
Overall, this code appears to be a part of a larger system that handles messages related to flight
information, processes them, and updates relevant database records. To create a flowchart, you
would need to visually represent the flow of operations, branching conditions, and data
interactions between different components and methods in the code.
1.22 MSG_CODE_FIDTICTY
The code is a Java application that processes XML messages related to city information.
• The code starts with import statements, which bring in classes from different packages.
• It also includes package declarations indicating the package structure of the code.
• The code snippet begins with an if-else if block, which appears to be part of a larger logic
structure.
• FIDTICTYMessage is a class that appears to represent an XML message with a header and
payload. It is annotated with @XmlRootElement and includes methods to set and retrieve
the header and payload.
• RTMessageHeader and FIDTICTYPayload are classes that seem to represent the header
and payload sections of the message. They are not provided in the code snippet, but they
likely follow similar patterns to the FIDTICTYMessage class.
• The main method demonstrates the testing of the XML message parsing and processing.
It constructs an XML message string, converts it into a FIDTICTYMessage object, and then
prints the short name from the payload.
This method takes a FIDTICTYMessage object and updates city information based on the payload
data.
• It retrieves the city code from the payload and attempts to find a city in the repository.
• If the city is not found, a new city is created and initialized with the city code.
• Short and long names are retrieved from the payload and trimmed if they're not empty.
• The city's short and long names are set, and the city is saved in the repository.
• A PayloadProcessStatus object is created, its status is set to success, and it's returned as
the result of the method.
This class seems to represent the payload structure of the FIDTICTY message. It includes methods
to set and retrieve IATA city code, short name, and long name.
This class represents the status of payload processing. It includes fields such as flight number, AFS
key, status, error message, and a date field. This class is annotated with @Data, which likely
generates getter, setter, equals, and hash code methods.
1. Conditional Processing:
• Retrieve the city from the repository or create a new city if not found.
• Update the city's short and long names based on payload data.
5. Return Status:
Please note that the actual implementation and flow might differ based on the missing parts of
the code and the details of the RTMessageHeader, CityRepository, and other classes.
1.23 MSG_CODE_FIDTIAPT
The code is a Java implementation that handles XML messages related to airport information. It
includes classes to represent and process these messages, as well as methods to update airport
data in a repository.
The code seems to process XML messages with different msgCode values. Specifically, it focuses
on messages with the MSG_CODE_FIDTIAPT code.
If the msgCode matches MSG_CODE_FIDTIAPT, the code performs the following steps:
• It converts the incoming XML message into a Java object of type FIDTIAPTMessage.
• Extracts data from the payload, such as IATAAirportCode, IATACityCode, shortName, and
longName.
a) Start
d) Extract Header
e) Call updateAirport
f) Process Payload
g) Update Repository
h) Return ProcessStatus
i) End Processing
1.24 MSG_CODE_FIDTIAIR
The code appears to be a Java program that processes XML messages related to airline
information.
The program processes incoming XML messages, specifically FIDTIAIR messages, which seem to
contain airline information. The main process involves parsing the XML, extracting relevant
information, and updating the airline data.
• The code starts with an if-else if statement that checks if a certain message code
(MSG_CODE_FIDTIAIR) is equal, ignoring the case. If the condition is met, it processes the
FIDTIAIR message.
• The FIDTIAIRMessage class represents the XML structure for FIDTIAIR messages. It has a
header and a payload, both of which are objects of other classes.
• The main method in FIDTIAIRMessage class demonstrates the parsing of an example XML
message using the XMLUtils.convertToObject() method. It extracts and prints the airline
name from the message.
• The updateAirline method takes a FIDTIAIRMessage object as input and processes its
payload. If an exception occurs during processing, it sets the status to error and records
the error message.
• The PayloadProcessStatus class holds information about the processing status, including
flight number, status, error message, and more.
• Constants STATUS_SUCCESS and STATUS_ERROR are used to define success and error
status strings.
1.24.4. Flowchart:
1) Start
2) Main Processing
4) Extract Header and Payload Data Update Payload Data Using updateAirline()
5) Set Process Status and Check If Processed Successfully or with an Error 6) Print Processed
Airline Name
2. Get APIs
2.1 Get-Flights
The API is mapped to the URL path "/get-flights" and accepts only GET requests.
Request Parameters:
code: (Optional) A string parameter that can be either "ARR" (for arrivals), "DEP" (for departures),
or empty. It filters flights based on their arrival or departure status.
flightNumber: (Optional) A string parameter representing the flight number to filter the results.
afskey: (Optional) A long parameter representing an AFS key used as a unique identifier for a
specific flight.
originCityCode: (Optional) A string parameter representing the code of the origin city of the flight.
destinationCityCode: (Optional) A string parameter representing the code of the destination city
of the flight.
skip: (Optional) An integer parameter representing the number of items to skip in the results.
Default value is 0.
take: (Optional) An integer parameter representing the number of items to take (retrieve) in the
results. Default value is 1000.
fromArrivals: (Optional) An integer parameter representing the lower bound of flight arrivals
duration in minutes. Default value is the constant
FlightDurationRange.DEFAULT_FROM_ARRIAVALS_STR which is -75 mins.
toArrivals: (Optional) An integer parameter representing the upper bound of flight arrivals
duration in minutes. Default value is the constant
toDepartures: (Optional) An integer parameter representing the upper bound of flight departures
duration in minutes. Default value is the constant
FlightDurationRange.DEFAULT_TO_DEPARTURES_STR which is 2160 mins.
getFlights Method: This method is the handler for the "/get-flights" API endpoint. It fetches flight
status information based on the provided parameters.
getFlights Service Method: This method is called by the API handler and retrieves flight status
data from the repository or cache.
getFlightsWithLocalCache Method: This method uses local caching to improve performance and
avoid redundant database calls. It checks if flight data is available in the cache based on a key
generated from the provided parameters. If the data is present in the cache, it returns the cached
data; otherwise, it fetches the data from the database, caches it, and returns it.
getFlightsPrivate Method: This method filters and groups the fetched flight data based on airline
operators and other criteria. It returns a list of FlightStatus objects containing the flight status
information.
makeFlightStatus Method: This method converts ActiveFlight objects into FlightStatus objects,
adding relevant information such as terminal, airport name, flight type, status, etc.
FlightStatus Class: This class represents the flight status information with various attributes like
flight number, category, origin, destination, terminal, airline name, etc.
Overall, the API provides a flexible way to retrieve flight status information based on different
parameters and uses caching to improve performance. It converts the raw data into a structured
response containing flight status information, making it easier for clients to consume the data.
2.2 Get-Flights-Cache
This API is designed to retrieve flight statuses from a cache based on various parameters. It allows
clients to query for flights using specific filters like flight code, aircraft operator code,
origin/destination city codes, and time intervals.
The API is an HTTP GET endpoint with the URL path "/get-flights-cache". It accepts several query
parameters, each denoted by the @RequestParam annotation in the method signature. The
parameters include:
"originCityCode" and "destinationCityCode": The codes of the origin and destination cities
respectively.
"skip" and "take": Parameters for pagination, allowing the client to skip a number of results and
take a specified number of results.
The method "getFlightsCache" handles the request and delegates the actual filtering logic to the
"getFlightsWithLocalCache" and "filterFlightsAndCreateResponse" methods. These methods
perform the actual filtering and build the response.
The "getFlightsWithLocalCache" method is responsible for fetching flights from a local cache
based on the provided parameters. It uses the arrival and departure time intervals, along with the
"code" parameter, to filter flights accordingly. It first checks if the desired flights are already
present in the cache and returns them. If not, it queries the database to retrieve the flights, caches
them locally, and then returns the filtered flights.
The "filterFlightsAndCreateResponse" method takes the retrieved flights from the local cache
and applies additional filters based on other query parameters. It filters the flights based on
Finally, the API builds a response of type "FlightStatusResponse" and includes information about
the server, version, count of returned flights, and a list of "FlightStatus" objects. The "FlightStatus"
class represents the details of each flight, including its terminal, flight number, origin, destination,
status, and more.
In summary, this API provides a flexible way to retrieve flight statuses based on various filters, and
it optimizes the response time by caching the flight data locally to avoid repeated database
queries. The response is structured and includes all relevant flight information for the client's
consumption.
2.3 Get-Flight
The code represents a RESTful API endpoint that retrieves flight status information based on the
provided flight number and an optional "afskey" parameter. The "afskey" is a BigDecimal value
used to identify the flight. The API returns a response in JSON format containing the flight status
details.
1. @GetMapping("/get-flight"): This annotation maps the method to the URL path "/get-flight"
for handling HTTP GET requests.
2. The method getFlight is the main API endpoint. It takes two parameters: flightNumber (String):
The flight number for which the status is requested.
3. afskey (BigDecimal, optional): An optional parameter used to uniquely identify the flight.
4. The method attempts to get the flight status based on the provided parameters using the
flightService object.
5. If the flight status is found, the API builds a response (FlightStatusResponse) with the necessary
details like server version, count (number of flights found), and a list of flight statuses. If no
flight status is found, it returns a response with count 0 and no flight statuses.
6. If any exception occurs during the process, it logs the error and returns an HTTP 500 Internal
Server Error response.
7. The FlightStatusResponse class is a data transfer object (DTO) representing the response
structure. It contains fields like "server" (hostname of the server), "version" (API version),
"count" (number of flights found), and "flightStatuses" (list of FlightStatus objects).
8. The FlightStatus class represents individual flight status information and contains various
details like flight number, airport, terminal, gate information, and more. It uses nested classes
to represent complex objects like "Destination," "Belt," "Gate," etc.
9. The getFlightsWithLocalCache method is a helper method responsible for caching and fetching
flight data from the database based on the provided parameters.
10. The getFlightsPrivate method processes the raw data received from the database and
creates a list of FlightStatus objects, filtering and sorting the data based on specific criteria.
11. The makeFlightStatus method is responsible for creating a single FlightStatus object from
the provided data.
12. The code uses constants like "ARRIVAL_CODE," "DEPARTURE_CODE," "KLIA2," and
"EMPTY_CHAR_SPACE" for better readability and maintainability.
13. The code also maintains separate lists of "klia1Terminals" and "klia2Terminals" to
distinguish terminals at different airports.
Overall, this code represents a well-structured and organized API endpoint to fetch flight status
information based on flight numbers with optional parameters for more specific searches.
2.4 Get-Flight-Meta
1. Endpoint Definition:
• The code defines a Spring Boot controller with a single endpoint mapped to the URL "/get-
flight-meta" and accepts HTTP GET requests.
2. Method Signature:
• The method "getFlightMeta" handles the incoming requests for the defined endpoint. It
takes several optional query parameters as inputs.
3. Query Parameters:
The method accepts the following query parameters, all of which are optional:
• "fromArrivals": An integer representing the minimum arrival duration (in minutes) for
filtering flights.
• "toArrivals": An integer representing the maximum arrival duration (in minutes) for
filtering flights.
4. ResponseEntity:
• The method returns a ResponseEntity object, which is used to send the response back to
the client. The response body is of type "BaseResponse," which can be a success or an
error response.
5. Exception Handling:
• If any other exception occurs, it returns an HTTP 500 (Internal Server Error) response.
6. Default Values:
• The code defines default values for the optional query parameters. If any of these
parameters are not provided in the request, the default values will be used.
7. FlightMeta Class:
8. getFlightMetaFromDB Method:
• This method is used to fetch flight metadata from the database based on the provided
filtering criteria (fromArrivals, toArrivals, fromDepartures, toDepartures).
• It uses JPA Query annotations to retrieve relevant ActiveFlight entities from the database.
• These methods are used to convert the retrieved ActiveFlight entities into
FlightMetaFlight, FlightMetaAirportCode, and FlightMetaAirportOperator objects,
respectively.
• They extract relevant information from ActiveFlight and create the corresponding
FlightMeta objects.
Overall, the endpoint fetches flight metadata from the database based on optional filtering
criteria and returns the data in a structured format using the FlightMeta class. If there are any
errors or exceptions during the process, appropriate error responses are returned to the client.
2.5 Get-Flight-Departures
• This method is annotated with @GetMapping and maps to the URL path "/get-flight-
departures".
• It handles HTTP GET requests and returns a list of departure flight statuses.
• It accepts various query parameters that are used to filter and paginate the results.
• Query Parameters:
• skip: An optional integer parameter indicating the number of items to skip from the result
(for pagination).
• take: An optional integer parameter indicating the maximum number of items to take in
the result
(for pagination).
• This method is called by the controller method to fetch the flight statuses based on the
query parameters.
• It calculates the date ranges for arrivals and departures based on the default values or
provided values.
• It retrieves the flights from a local cache (if available) or fetches them from the database
if not present in the cache.
• It also filters the flights based on the provided category and sorts them by flight time and
airline name.
4. FlightStatus Class:
• This class represents the structure of a flight status, including various attributes such as
flight number, terminal, airport name, category, status, etc.
• It contains inner classes to represent nested objects like Destination, Belt, Gate, CheckIn,
CodeShareFlight, and Airline.
• The getFlightsWithLocalCache method uses a local cache to store and retrieve flight data
based on specific time ranges and codes (Arrivals or Departures).
• If the requested flights are already present in the cache, it returns the cached data;
otherwise, it fetches the flights from the database, stores them in the cache, and returns
the result.
7. FlightStatusResponse:
• It includes the server version, a list of flight statuses, and the count of flight statuses in the
response.
8. getFlightResponse:
• This method constructs the final FlightStatusResponse with the appropriate flight statuses
based on the provided skip, take, and terminal parameters.
Overall, this code snippet represents a RESTful API endpoint for fetching departure flight statuses.
It accepts various query parameters for filtering and pagination and uses a local cache mechanism
to optimize database queries. The response includes a list of flight statuses along with relevant
details about the flights.
2.6 Get-Flight-Departures-Cache:
Certainly! The provided code is a Java implementation for a RESTful API endpoint and related
supporting classes to retrieve flight departure information from a cache. Let's break down the
code step by step:
1. Controller:
This part of the code defines a Spring @RestController class that handles HTTP GET requests to
the "/get-flight-departures-cache" endpoint. It takes several optional query parameters (terminal,
skip, take, category) to customize the response.
2. Service:
The service layer contains the getFlightDeparturesCache method, which is responsible for
processing the request and preparing the flight departure data.
• The flight statuses are sorted based on flight time and airline name.
• Finally, it constructs a FlightStatusResponse object containing the filtered and sorted flight
statuses, along with metadata like the cache level.
3. ViewModel:
The FlightStatus class represents flight status information. It contains various fields and nested
classes for different aspects of a flight status, such as destination, belt, gate, check-in, code-share
flights, and airline information.
4. Response Model:
The FlightStatusResponse class is a response model containing information about the flight
statuses returned by the API. It includes fields for the server, version, count of flight statuses, and
a list of FlightStatus objects.
5. Utility Methods:
• The getFlightResponse method filters and paginates the list of flight statuses based on the
given terminal, skip, and take parameters. It creates a FlightStatusResponse object with
the filtered flight statuses and related information.
• The getFlightsWithLocalCache method uses a local cache to store and retrieve flight
statuses based on specific criteria. It checks if the flight statuses are already cached and
retrieves them, or fetches them from a data repository and then caches them.
The getFlightsPrivate method generates flight status objects from a list of active flights. It filters
and processes the active flights, grouping them by certain criteria and creating corresponding
FlightStatus objects.
The makeFlightStatus method creates a FlightStatus object based on the information extracted
from an ActiveFlight object. It sets various properties such as terminal, airport name, flight
number, category, origin, destination, flight type, status, flight time, and more.
8. Explanation:
This code defines a REST API endpoint that retrieves flight departure information, processes the
data, and prepares a response with relevant flight details. It incorporates various classes and
methods for caching, data retrieval, filtering, sorting, and constructing response models.
2.7 Get-Flight-Arrivals:
1. Endpoint Definition:
The code defines an HTTP GET endpoint with the mapping "/get-flight-arrivals". It receives several
query parameters that control the filtering and pagination of flight arrivals data.
• skip: An optional parameter for pagination, indicating how many records to skip,
defaulting to 0.
• take: An optional parameter for pagination, indicating how many records to take,
defaulting to 10.
2. Controller Method:
The getArrivalsFlights method in the controller handles the HTTP GET request. It delegates the
request to the flightService to retrieve flight data based on the provided parameters. If
successful, it returns an HTTP 200 response with the flight data. If an error occurs, it logs the
error and returns an HTTP 500 response.
3. Service Method:
The getArrivalOrDepartureFlights method in the service layer processes the flight data retrieval.
It calculates time ranges for arrivals and departures based on the provided parameters. Then, it
retrieves a list of flights using the getFlightsWithLocalCache method. It filters the flights based
on the specified category and sorts them by flight time and airline name. Finally, it constructs a
FlightStatusResponse object with the paginated flight data.
The getFlightsWithLocalCache method handles caching of flight data based on a generated key. If
the data is already in the cache, it returns it; otherwise, it queries the database to fetch the data,
stores it in the cache, and returns it.
The getFlightsPrivate method takes a list of ActiveFlight objects and processes them to create a
list of FlightStatus objects. It filters the flights based on a list of carriers and terminal, groups
flights by code share and official flight date, and then creates flight status objects for each group.
7. Database Queries:
The code includes several database queries using Spring Data JPA's @Query annotations to fetch
active flight data based on different criteria, such as time ranges for arrivals and departures.
8. Additional Methods:
The code also includes various utility methods to handle data transformation, formatting, and
filtering.
2.8 Get-Flight-Arrivals-Cache:
The provided code appears to be a Java-based web service that retrieves flight arrival data from
a cache. It seems to be part of a larger flight information system.
The code starts with a controller method that handles GET requests to retrieve flight arrival data
from a cache. The method accepts optional query parameters such as terminal, skip, take, and
category. It tries to retrieve flight arrival data from a service and returns it as a JSON response.
The service layer contains a method named getFlightArrivalsCache which retrieves flight arrival
data based on the provided parameters. It calculates time ranges for flight arrivals and
departures, filters and sorts the flight statuses, and constructs a response object.
The response objects are used to structure the data returned by the web service. They contain
various attributes representing flight information, such as flight number, terminal, airport name,
status, gate information, etc. The FlightStatus class is particularly detailed, containing nested
classes to represent various aspects of flight data, such as destinations, belts, gates, etc.
4. Cache Management
The code utilizes a local cache (localFlightsCache) to store flight status data based on specific key
values derived from time ranges and flight types (arrival or departure). If the requested data is
found in the cache, it's directly returned; otherwise, the service fetches the data from a repository
(presumably a database), processes it, and stores it in the cache for future use.
6. Business Logic
The getFlightsPrivate method performs various data processing tasks to generate a list of
FlightStatus objects. It involves filtering, grouping, and transforming data from ActiveFlight
objects to populate the flight status information.
7. Utility Functions
Several utility functions are used throughout the code for tasks like date formatting, string
manipulation, and calculating time differences.
8. Exception Handling
The code includes error handling logic to catch and log exceptions that might occur during the
data retrieval process. If an exception occurs, the web service returns an HTTP 500 Internal
Server Error response.
9. Configuration
Some constants are defined for default values such as time ranges for flight arrivals and
departures.
Architecture Overview:
The code follows a layered architecture pattern, with clear separation between the controller,
service, repository, and utility functions. It interacts with a database (presumably using JPA) to
retrieve flight data. The data retrieval process involves fetching data from the database,
processing it to construct flight status information, and caching the results for improved
performance. The response objects are used to structure and present the flight information to
the client.
2.9 Search-Flight
The given code snippet appears to be part of a Java Spring Boot application, specifically focusing
on handling flight status search and retrieval. It involves web APIs for searching flight details based
on various parameters such as flight code, key, value, terminal, and category. The code to follow
a structured design, separating concerns into different methods and classes.
• This section defines a Spring @RestController which exposes an endpoint for flight
searches.
• The searchFlight method handles incoming requests and invokes the appropriate service
methods based on the provided parameters.
• The searchFlight service method performs the actual flight search and response
generation.
3. Data Validation:
• Data validation is performed for the input parameters (code, key, value, terminal,
category).
• This method searches for flight status based on various criteria using the provided
parameters.
• Flight data is transformed into a list of FlightStatus objects, which represent flight details.
• This method performs flight data retrieval, either from a cache (localFlightsCache) or from
the repository.
• It generates a cache key based on the provided criteria and fetches flight data accordingly.
• If data is fetched from the repository, it is stored in the cache for future use.
• These methods handle the transformation of raw flight data into FlightStatus objects.
• They map relevant data fields from the fetched flight information.
• Additional data manipulation is performed, such as determining the terminal and airport
names.
• This method filters the list of FlightStatus objects based on various search criteria (e.g.,
city, flight, airline).
• The filtered results are sorted by flight time and airline name.
8. Response Generation:
Conclusion
In summary, the provided code demonstrates a structured approach to handling flight status
searches using Spring Boot. It follows a layered architecture, separating concerns into controller,
service, and data transformation layers. The code efficiently retrieves flight data, applies filtering
and sorting, and generates a well-structured response for clients querying flight information
based on various parameters. The use of caching enhances performance by reducing database
queries for repetitive requests.
3. POM.XML of Fids
3.1
This specifies the XML version and encoding used in the file.
3.2
<project xmlns="http://maven.apache.org/POM/4.0.0”
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
The project element is the root element of the Maven POM (Project Object Model) file. It defines
the project's configuration and dependencies. The XML namespace is specified, and
xsi:schemaLocation points to the XSD (XML Schema Definition) file for the Maven POM.
3.3
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.5.2</version>
</parent>
The parent element specifies the parent project's information. In this case, the project inherits its
configuration from the Spring Boot Starter Parent project with version 2.5.2.
3.4
<modelVersion>4.0.0</modelVersion>
This element defines the version of the POM model being used. In this case, it is version 4.0.0.
3.5
<groupId>com.mahb.api</groupId>
<artifactId>fids_api</artifactId>
<version>1.0.61</version>
These elements specify the coordinates of the current project. The groupId represents the group
or organization that owns the project, the artifactId is the name of the project, and the version is
the current version of the project.
The dependencies section contains a list of all the project's dependencies. Each <dependency>
element specifies a dependency artifact with its groupId, artifactId, and version.
1. Spring Boot Starter Web: Provides basic web support for Spring Boot applications.
2. Spring Boot DevTools: Provides additional development tools to improve the development
experience.
3. Spring Boot Starter Data JPA: Provides support for Spring Data JPA, making it easy to interact
with databases.
4. Spring Boot Starter Security: Provides security features for Spring Boot applications.
5. JJWT (JSON Web Token): A library for working with JSON Web Tokens.
7. Google OAuth Client (Jetty): A client library for Google OAuth using Jetty.
9. Spring Boot Starter Actuator: Provides production-ready features to monitor and manage the
application.
10. SLF4J API: Simple Logging Facade for Java, a logging framework.
11. Spring Boot Starter Cache: Provides support for caching in Spring Boot applications.
14. Spring Boot Starter JDBC: Provides support for JDBC-based data access.
16. Microsoft SQL Server JDBC Driver: JDBC driver for Microsoft SQL Server.
17. Apache Commons Lang3: A library of utility classes for common programming tasks.
19. Mockito JUnit Jupiter: Integration between Mockito and JUnit Jupiter (used with scope test).
20. Spring Boot Starter Test: Provides support for testing Spring Boot applications.
21. JUnit Jupiter API: The JUnit 5 Jupiter API for testing.
24. JUnit Jupiter Engine: The JUnit 5 Jupiter test engine (used with scope test).
3.7
<properties>
<java.version>17</java.version>
</properties>
The properties section allows you to define property values that can be referenced throughout
the POM. In this case, it sets the java.version property to 17, indicating that the project should be
compiled using Java 17.
The build section contains configurations for the build process. Here, it lists a couple of Maven
plugins:
1. Spring Boot Maven Plugin: A plugin that provides various features for building and packaging
Spring Boot applications.
2. Maven Surefire Plugin: A plugin used for running tests during the build process.
The pom.xml file provided represents a Maven project for a Spring Boot application with various
dependencies for web development, security, data access, and testing. It also includes external
libraries for Google API integration, logging, CSV processing, and database connections. The
project is set to use Java 17 as the target version for compilation.
6 FIDASM1 1 These columns should get updated FLIGHTNO , Leg, Stad, updated FLIGHTNO , Leg,
and OFFICIALFLIGHTDATE Stad, OFFICIALFLIGHTDATE
Flightmode against afskey
=6
7 FIDASM1 1 These columns should get updated FLIGHTNO , Leg, Stad, These columns should get
and OFFICIALFLIGHTDATE updated FLIGHTNO , Leg,
Flightmode Stad, OFFICIALFLIGHTDATE
=1 to 5
8 FIDASM1 1(As per 1. It should Insert 1 payload details(AFSKEY, FLIGHT NO..)in to 1. Inserted 1 payload
ICD it will "TB_ACTIVEFLIGHT" Table. details(AFSKEY, FLIGHT NO..)in
acceptt 1 2. Header details should insert in the "tb_fids_message" Table. to "TB_ACTIVEFLIGHT" Table.
Payload) 3. 1 Payload details should insert in the "tb_fids_message_payload" 2. Header details inserted in
Table. the "tb_fids_message" Table.
3. 1 Payload details inserted in
the
"tb_fids_message_payload"
Table.
10 FIDADMRA 1 As per payload information (flightno, etc)columns should get updated These columns should get
D updated FLIGHTNO , Leg,
Stad, OFFICIALFLIGHTDATE
12 FIDCHKALC 1 Insert row in the tb_Counter table based on the flight number Inserted row in the
tb_Counter table based on
the flight number
15 FIDDLTFLT 1 Delete from tb_activeflight against afskey provided payload Deleted from tb_activeflight
FIDD+C16: against afskey provided
H16LTFLT payload
and
FlightMode
=3
16 FIDDLTFLT 1 Delete from tb_activeflight against afskey provided payload Deleted from tb_activeflight
FIDD+C16: against afskey provided
H16LTFLT payload
and
FlightMode
=6
17 FIDDSPFLG 1 As per payload information ( DISPFLAG )column should get updated in updated the column DISPFLAG
and table tb_activeflight in the tb_activeflight table
FlightMode
=3
18 FIDDSPFLG 1 As per payload information ( DISPFLAG )column should get updated in updated the column DISPFLAG
and table tb_activeflight in the tb_activeflight table
FlightMode
=6
24 FIDUNDOFL 1 As per payload information ATAD, REMARKCODEFLIGHT columns should Updated ATAD,
T and get updated in table REMARKCODEFLIGHT columns
FlightMode tb_activeflight and will be set to Null in table tb_activeflight
=3
25 FIDUNDOFL 1 As per payload information ATAD, REMARKCODEFLIGHT columns should Updated ATAD,
T and get updated in table REMARKCODEFLIGHT columns
FlightMode tb_activeflight and will be set to Null in table tb_activeflight
=6
28 FIDOOBFLT 1 As per payload information STANDONCHOCKTIME column should get Did not update
and updated in table STANDONCHOCKTIME column
ChockIndic tb_activeflight should get updated in table
ator = 1 tb_activeflight
29 FIDOOBFLT 1 As per payload information STANDONCHOCKTIME column should get Did not update
and updated in table STANDONCHOCKTIME column
ChockIndic tb_activeflight should get updated in table
ator = 1 tb_activeflight
38 FIDTICTY 1 Updates city. IATACityCode,city shortName and city long name Updates city.
IATACityCode,city shortName
and city long name
40 FIDTIAIR 1 As of now no operation is being performed when we recieve this As of now no operation is
message code (carry forward from previous 1.0 logic being performed when we
recieve this message code
(carry forward from previous
1.0 logic
41 MASBAFS 1
(add new 1. Insert the payload data like
flight) (AFSKEY,FLIGHTNO,LEG,STAD,OFFICIALFLIGHTDATE,AIRCRAFTTYPECODE,
SERVICECLASS,AIRCRAFTOPERATORCODE,IATASERVICETYPECODE,CODES
HAREFLIGHT,TRAFFICRIGHT,FLIGHTMODE,MODESEQUENCE,CATEGORYC
ODE,STATION1,STATION2,STATION3,STATION4,STATION5,STATION6,SCHC
OUNTEROPENTIME,SCHCOUNTERCLOSETIME,SCHGATEOPENTIME,SCHG
ATECLOSETIME,SCHGATEBOARDINGTIME,SCHGATEFINALCALLTIME,STAN
DCODE,GATELOUNGECODE,TAILNO,ATMSETAD,SITAETAD,DISPETAD,LAST
UPDTIME,LASTUPDUSERID,SeasonId,IrregularIndicator, Homestation) in
to "TB_ACTIVEFLIGHT" Table.
2. Header details will be insert in the "tb_fids_message" Table.
3. Payload details will insert in the "tb_fids_message_payload" Table.
42 MASBAFS 1
(update 1. Update the payload data like
exsisting (OFFICIALFLIGHTDATE,AIRCRAFTTYPECODE,SERVICECLASS,AIRCRAFTOP
flight ERATORCODE,IATASERVICETYPECODE,CODESHAREFLIGHT,TRAFFICRIGHT,
details) FLIGHTMODE,MODESEQUENCE,CATEGORYCODE,STATION1,STATION2,ST
ATION3,STATION4,STATION5,STATION6,SCHCOUNTEROPENTIME,SCHCO
UNTERCLOSETIME,SCHGATEOPENTIME,SCHGATECLOSETIME,SCHGATEB
OARDINGTIME,SCHGATEFINALCALLTIME,STANDCODE,GATELOUNGECOD
E,TAILNO,ATMSETAD,SITAETAD,DISPETAD,LASTUPDTIME,LASTUPDUSERI
D,SeasonId,IrregularIndicator, Homestation) in to "TB_ACTIVEFLIGHT"
Table.
2. Header details will be insert in the "tb_fids_message" Table.
3. Payload details will insert in the "tb_fids_message_payload" Table.
43 MASBDLT 1 1. Delete the exsisting flight based on the AFSKEY that is received
(delete through the payload
exsisting
flight)
Error handling is typically involving handling exceptions that can occur during the application's
runtime. Spring Boot provides various mechanisms and annotations to help you handle errors
and exceptions effectively. Below, I'll provide an explanation of commonly used error handling
mechanisms in Spring Boot.
@ControllerAdvice is an annotation that allows you to define global exception handling for your
application.
@ExceptionHandler is used within a @ControllerAdvice class to define methods that handle
specific exceptions.
You can create custom exception classes by extending RuntimeException or other exception
classes provided by Java.
Example:
public class ResourceNotFoundException extends RuntimeException {
public ResourceNotFoundException(String message) {
super(message);
}
}
5.3. @ResponseStatus:
Use the @ResponseStatus annotation to specify the HTTP status code to return when an
exception is thrown.
5.4. ErrorController:
You can implement a custom ErrorController to handle uncaught exceptions globally. This is a
fallback mechanism when no specific exception handler is available.
5.5. ResponseEntityExceptionHandler:
This is a built-in class in Spring Boot that you can extend to create a custom exception handler. It
provides various methods to handle exceptions and return ResponseEntity objects.
ClassFormatError When JVM attempts to read a class file and find that the file is
malformed or cannot be interpreted as a class file.
InstantiationError In case an application is trying to use the Java new construct for
instantiating an abstract class or an interface.