public static void main(String[] args) { Address a = new Address(); Dao.save(a); a.setZip(null); Dao.save(a); a.setZip("75001"); Dao.save(a); Dao.save(a); }
public static Customer createCustomerAddress(EntityManagerFactory factory) { System.out.println("Create 1st Customer"); Customer cust = new Customer(); cust.setFirstName("Bill"); cust.setLastName("Burke"); Address address = new Address(); address.setStreet("Beacon Street"); address.setCity("Boston"); address.setState("MA"); address.setZip("02115"); cust.setAddress(address); EntityManager manager = factory.createEntityManager(); try { manager.getTransaction().begin(); manager.persist(cust); manager.getTransaction().commit(); } finally { manager.close(); } System.out.println("Address was also persisted with auto-generated key: " + address.getId()); System.out.println("Return detached Customer instance: " + cust.getId()); return cust; }
@Test public void testBuildMessageFromMpiPatient_MultiAddress() { System.out.println("testBuildMessageFromMpiPatient_MultiAddress"); II subjectId = new II(); subjectId.setRoot("2.16.840.1.113883.3.200"); subjectId.setExtension("1234"); String firstExpectedName = "Joe"; String lastExpectedName = "Smith"; String middleExpectedName = "Middle"; String expectedTitle = "Title"; String expectedSuffix = "Suffix"; PRPAIN201305UV02 query = TestHelper.build201305( firstExpectedName, lastExpectedName, "M", "March 1, 1956", subjectId); Identifier patId = new Identifier(); patId.setId("1234"); patId.setOrganizationId("2.16.840.1.113883.3.200"); Patient patient = TestHelper.createMpiPatient( firstExpectedName, lastExpectedName, middleExpectedName, "M", "March 1, 1956", patId); patient.getName().setSuffix(expectedSuffix); patient.getName().setTitle(expectedTitle); Address add = new Address(); add.setCity("Chantilly"); add.setState("VA"); add.setStreet1("5155 Parkstone Drive"); add.setStreet2("Att:Developer"); add.setZip("20151"); Address add2 = new Address(); add2.setCity("Melbourne"); add2.setState("FL"); add2.setStreet1("1025 West NASA Boulevard"); add2.setStreet2("Att:Developer"); add2.setZip("32919-0001"); patient.getAddresses().add(add); patient.getAddresses().add(add2); PRPAIN201306UV02 result = HL7Parser201306.BuildMessageFromMpiPatient(patient, query); // TODO review the generated test code and remove the default call to fail. PRPAMT201310UV02Person person = result .getControlActProcess() .getSubject() .get(0) .getRegistrationEvent() .getSubject1() .getPatient() .getPatientPerson() .getValue(); assertEquals(2, person.getAddr().size()); assertEquals(5, person.getAddr().get(0).getContent().size()); assertEquals(5, person.getAddr().get(1).getContent().size()); // assertEquals("5155 Parkstone Drive", person.getAddr().get(0).getUse().get(0)); // assertEquals("1025 West NASA Boulevard", person.getAddr().get(1).getUse().get(0)); }
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // Loginse user bilgilerini al, textboxlari readonly yap, degilse textboxtakileri al User user = (User) request.getSession().getAttribute("user"); if (user == null) { String name = request.getParameter("reservation-name"); String lastName = request.getParameter("reservation-lastname"); String email = request.getParameter("reservation-email"); String phone = request.getParameter("reservation-phone"); } else { String name = user.getFirstName(); String lastName = user.getLastName(); String email = user.getEmail(); String phone = user.getPhoneNumber(); } Address pickup = new Address(); pickup.setBuildingNo(Integer.parseInt(request.getParameter("pickupbuilding-no"))); pickup.setStreet(request.getParameter("pickupstreet")); pickup.setCity(request.getParameter("pickuphomecity")); pickup.setState(request.getParameter("pickupstate")); pickup.setZip(Integer.parseInt(request.getParameter("pickuphomezip"))); pickup.setCountry(request.getParameter("pickupcountry")); Address destination = new Address(); destination.setBuildingNo(Integer.parseInt(request.getParameter("destinationbuilding-no"))); destination.setStreet(request.getParameter("destinationstreet")); destination.setCity(request.getParameter("destinationhomecity")); destination.setState(request.getParameter("destinationstate")); destination.setZip(Integer.parseInt(request.getParameter("destinationzip"))); destination.setCountry(request.getParameter("destinationcountry")); int passengerNo = Integer.parseInt(request.getParameter("passenger-no")); int luggageNo = Integer.parseInt(request.getParameter("luggage-no")); double fareMultiplier = 0; String vehicleType = request.getParameter("vehicle-radio"); if ("sedan".equals(vehicleType)) { fareMultiplier = 3; } else if ("suv".equals(vehicleType)) { fareMultiplier = 5; } else if ("blackcar".equals(vehicleType)) { fareMultiplier = 4.5; } ReservationService service = new ReservationService(); double distance = service.calculateDistance(pickup, destination); double initialFare = 10; double amount = fareMultiplier * distance + initialFare; boolean isPet = false; // isPet is going to be retrieved from checkbox // boolean isCash = request.getParameter("payment-method"); boolean isCash = false; Payment payment = new Payment(isCash); payment.setAmount(amount); if (!isCash) { if (!payment.isPaid()) { // chargeCustormer(); } // payment.setCredit() } Reservation reservation = new Reservation(); reservation.setComment("Write a comment"); }
/** * Run the entry addition system. Asks the user for values for all fields and then fills them in. * * @param args Command line arguments; this is expected to be empty. * @return Exit status code for the application; 0 indicates success. * @throws IOException If an error contacting Kiji occurs. * @throws InterruptedException If the process is interrupted while performing I/O. */ @Override public int run(String[] args) throws IOException, InterruptedException { final ConsolePrompt console = new ConsolePrompt(); // Interactively prompt the user for the record fields from the console. final String first = console.readLine("First name: "); final String last = console.readLine("Last name: "); final String email = console.readLine("Email address: "); final String telephone = console.readLine("Telephone: "); final Address addr = new Address(); addr.setAddr1(console.readLine("Address line 1: ")); // Optional: apartment. final String aptNumStr = console.readLine("Apartment: "); if (!aptNumStr.isEmpty()) { addr.setApt(aptNumStr); } // Optional: address line 2. addr.setAddr2(console.readLine("Address line 2: ")); if (addr.getAddr2().length() == 0) { addr.setAddr2(null); } addr.setCity(console.readLine("City: ")); addr.setState(console.readLine("State: ")); addr.setZip(Integer.valueOf(console.readLine("Zip: "))); Kiji kiji = null; KijiTable table = null; KijiTableWriter writer = null; try { // Load HBase configuration before connecting to Kiji. setConf(HBaseConfiguration.addHbaseResources(getConf())); // Connect to Kiji and open the table. kiji = Kiji.Factory.open( new KijiConfiguration(getConf(), KijiConfiguration.DEFAULT_INSTANCE_NAME)); table = kiji.openTable(TABLE_NAME); writer = table.openTableWriter(); // Create a row ID with the first and last name. final EntityId user = table.getEntityId(first + "," + last); // Write the record fields to appropriate table columns in the row. // The column names are specified as constants in the Fields.java class. final long timestamp = System.currentTimeMillis(); writer.put(user, Fields.INFO_FAMILY, Fields.FIRST_NAME, timestamp, first); writer.put(user, Fields.INFO_FAMILY, Fields.LAST_NAME, timestamp, last); writer.put(user, Fields.INFO_FAMILY, Fields.EMAIL, timestamp, email); writer.put(user, Fields.INFO_FAMILY, Fields.TELEPHONE, timestamp, telephone); writer.put(user, Fields.INFO_FAMILY, Fields.ADDRESS, timestamp, addr); } catch (KijiTableNotFoundException e) { System.out.println("Could not find Kiji table: " + TABLE_NAME); return 1; } finally { // Safely free up resources by closing in reverse order. IOUtils.closeQuietly(writer); IOUtils.closeQuietly(table); ReferenceCountableUtils.releaseQuietly(kiji); IOUtils.closeQuietly(console); } return 0; }