Skip to content

Instantly share code, notes, and snippets.

@shankybnl
Created June 6, 2018 13:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shankybnl/060120bd2b72ada9c2d670f5a222ae94 to your computer and use it in GitHub Desktop.
Save shankybnl/060120bd2b72ada9c2d670f5a222ae94 to your computer and use it in GitHub Desktop.
PilotSteps.java
@And("^Get all active \"([^\"]*)\" of pilots$")
public void getAllActiveOfPilots(String activityOrDuty) throws Throwable {
session = CrudOperations.createHibernateConnection();
if (activityOrDuty.equalsIgnoreCase("duties")) {
activePilotDutiesMap = new HashMap<>();
List<PilotDuty> pilotDuty = session.createQuery("from PilotDuty where isActive=true order by id desc").list();
for (int i = 0; i < pilotDuty.size(); i++) {
List<Long> duties = null;
if (activePilotDutiesMap.containsKey(pilotDuty.get(i).getPilotId())) {
duties = activePilotDutiesMap.get(pilotDuty.get(i).getPilotId());
duties.add(pilotDuty.get(i).getId());
activePilotDutiesMap.put(pilotDuty.get(i).getPilotId(), duties);
} else {
int pilot = pilotDuty.get(i).getPilotId().intValue();
duties = activePilotDutiesMap.get(pilot);
if (duties == null) {
duties = new ArrayList<Long>();
Long dutyId = pilotDuty.get(i).getId();
activePilotDutiesMap.put(pilotDuty.get(i).getPilotId(), duties);
duties.add(pilotDuty.get(i).getId());
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment