// On teste un preparestatement mappé sur un type dynamique DTList.
  @Test
  public void testDynSelect() throws Exception {
    // On crée les données
    createDatas();
    // ----
    final Domain domain = new Domain("DO_TEST", DataType.DtList);
    final SqlQueryResult result = executeQuery(domain, "select * from movie");

    Assert.assertEquals(3, result.getSQLRowCount());
    final DtList<DtObject> dynMovies = (DtList<DtObject>) result.getValue();
    Assert.assertEquals(3, dynMovies.size());

    for (final DtObject dynMovie : dynMovies) {
      final long id = (Long) getValue(dynMovie, "ID");
      final String title = (String) getValue(dynMovie, "TITLE");
      checkTitle(id, title);
    }
  }
  // On teste un preparestatement mappé sur un type statique (Class famille)
  @Test
  public void testSelectList() throws Exception {
    // On crée les données
    createDatas();
    // ----
    final Domain domain = Home.getDefinitionSpace().resolve("DO_DT_MOVIE_DTC", Domain.class);
    final SqlQueryResult result = executeQuery(domain, "select * from movie");

    Assert.assertEquals(3, result.getSQLRowCount());

    final DtList<Movie> movies = (DtList<Movie>) result.getValue();
    Assert.assertEquals(3, movies.size());

    for (final Movie movie : movies) {
      final long id = movie.getId();
      final String title = movie.getTitle();
      checkTitle(id, title);
    }
  }
  @GET("/contactView/{conId}")
  public ContactView readContactView(@PathParam("conId") final long conId) {
    final Contact contact = contactDao.get(conId);
    if (contact == null) {
      // 404 ?
      throw new VUserException(new MessageText("Contact #" + conId + " unknown", null));
    }
    final DtList<Address> addresses = new DtList<>(Address.class);
    addresses.add(contact.getAddress());
    addresses.add(contact.getAddress());
    addresses.add(contact.getAddress()); // we sheet and use 3 times the same address.

    final ContactView contactView = new ContactView();
    contactView.setName(contact.getName());
    contactView.setFirstName(contact.getFirstName());
    contactView.setHonorificCode(contact.getHonorificCode());
    contactView.setEmail(contact.getEmail());
    contactView.setBirthday(contact.getBirthday());
    contactView.setAddresses(addresses);
    // 200
    return contactView;
  }
Exemple #4
0
 private <D extends DtObject> DtList<D> doLoadList(
     final DtDefinition dtDefinition, final DtListURI listUri) {
   Assertion.checkNotNull(listUri);
   // -----
   final DtList<D> dtc;
   if (listUri instanceof DtListURIForMasterData) {
     dtc = loadMDList((DtListURIForMasterData) listUri);
   } else if (listUri instanceof DtListURIForSimpleAssociation) {
     dtc =
         getPhysicalStore(dtDefinition)
             .loadList(dtDefinition, (DtListURIForSimpleAssociation) listUri);
   } else if (listUri instanceof DtListURIForNNAssociation) {
     dtc =
         getPhysicalStore(dtDefinition)
             .loadList(dtDefinition, (DtListURIForNNAssociation) listUri);
   } else if (listUri instanceof DtListURIForCriteria<?>) {
     dtc =
         getPhysicalStore(dtDefinition).loadList(dtDefinition, (DtListURIForCriteria<D>) listUri);
   } else {
     throw new IllegalArgumentException("cas non traité " + listUri);
   }
   dtc.setURI(listUri);
   return dtc;
 }