use of org.glassfish.jersey.examples.flight.model.AircraftType in project jersey by jersey.
the class DataStore method generateAircraft.
private static Aircraft generateAircraft() {
final Aircraft aircraft = new Aircraft();
final Iterator<AircraftType> iterator = aircraftTypes.iterator();
int i = rnd.nextInt(aircraftTypes.size());
AircraftType type = null;
while (iterator.hasNext()) {
type = iterator.next();
if (--i < 0) {
break;
}
}
aircraft.setType(type);
aircraft.setLocation(generateLocation(SimEngine.X_BOUND, SimEngine.Y_BOUND));
return aircraft;
}
use of org.glassfish.jersey.examples.flight.model.AircraftType in project jersey by jersey.
the class DataStore method initAircraftTypes.
private static Set<AircraftType> initAircraftTypes() {
Set<AircraftType> ats = new LinkedHashSet<>();
// Airbus
// Short-range
ats.add(new AircraftType("Airbus", "A318-100", 107));
ats.add(new AircraftType("Airbus", "A319-100", 124));
ats.add(new AircraftType("Airbus", "A320-200", 150));
ats.add(new AircraftType("Airbus", "A321-200", 185));
ats.add(new AircraftType("Airbus", "A330-200", 253));
ats.add(new AircraftType("Airbus", "A330-300", 295));
ats.add(new AircraftType("Airbus", "A330-500", 222));
ats.add(new AircraftType("Airbus", "A330-500", 222));
// Medium-range
ats.add(new AircraftType("Airbus", "A340-200", 240));
ats.add(new AircraftType("Airbus", "A340-300", 295));
ats.add(new AircraftType("Airbus", "A340-500", 313));
ats.add(new AircraftType("Airbus", "A340-600", 380));
// Long-range
ats.add(new AircraftType("Airbus", "A350-800", 270));
ats.add(new AircraftType("Airbus", "A350-900", 314));
ats.add(new AircraftType("Airbus", "A350-1000", 350));
ats.add(new AircraftType("Airbus", "A380-800", 525));
// Boeing
// Short-range
ats.add(new AircraftType("Boeing", "737-200", 97));
ats.add(new AircraftType("Boeing", "737-500", 146));
ats.add(new AircraftType("Boeing", "737-900", 177));
// Medium-range
ats.add(new AircraftType("Boeing", "767-200", 181));
ats.add(new AircraftType("Boeing", "767-300", 218));
ats.add(new AircraftType("Boeing", "767-400", 245));
// Long-range
ats.add(new AircraftType("Boeing", "777-200", 314));
ats.add(new AircraftType("Boeing", "777-300", 386));
ats.add(new AircraftType("Boeing", "787-8", 242));
ats.add(new AircraftType("Boeing", "787-9", 280));
ats.add(new AircraftType("Boeing", "787-10", 323));
return Collections.unmodifiableSet(ats);
}
use of org.glassfish.jersey.examples.flight.model.AircraftType in project jersey by jersey.
the class AircraftsResource method create.
@POST
@Consumes(APPLICATION_FORM_URLENCODED)
@RolesAllowed("admin")
@Detail
public Aircraft create(@FormParam("manufacturer") String manufacturer, @FormParam("type") String type, @FormParam("capacity") Integer capacity, @DefaultValue("0") @FormParam("x-pos") Integer x, @DefaultValue("0") @FormParam("y-pos") Integer y) {
if (manufacturer == null || type == null || capacity == null) {
throw new BadRequestException("Incomplete data.");
}
Aircraft aircraft = new Aircraft();
aircraft.setType(new AircraftType(manufacturer, type, capacity));
aircraft.setLocation(SimEngine.bound(new Location(x, y)));
if (!DataStore.addAircraft(aircraft)) {
throw new InternalServerErrorException("Unable to add new aircraft.");
}
return aircraft;
}
Aggregations