Package org.company.recordshop.service.dto

Examples of org.company.recordshop.service.dto.PersonDto


    PersonExample example = personDtoTranslator.exampleFromDto(filter);
    found = customerServiceModelDomainService.findPersonByExample(example);

    for (Person object : found) {
      PersonDto item = personDtoTranslator.toDto(object);
      result.add(item);
    }
    return result;
  }
View Full Code Here


        .findPersonByExampleCount(example, firstResult, maxResults,
            sortProperty, isAscending);
    List<PersonDto> result = new ArrayList<PersonDto>();

    for (Person object : range) {
      PersonDto item = personDtoTranslator.toDto(object);
      result.add(item);
    }
    return result;
  }
View Full Code Here

  PersonDto toDto(final Person source, final Map<Object, Object> translated) {
    if (translated.containsKey((source))) {
      return (PersonDto) translated.get(source);
    }
    Assert.notNull(source, "argument [source] may not be null");
    PersonDto result = new PersonDto(source.getId(), source.getVersion());
    result.setFirstName(source.getFirstName());
    result.setLastName(source.getLastName());
    result.setBirthDate(source.getBirthDate());

    translated.put(source, result);

    for (Relation element : source.getRelationsFrom()) {
      result.addToRelationsFrom(relationDtoTranslator.toDto(element,
          translated));
    }

    for (Relation element : source.getRelationsTo()) {
      result.addToRelationsTo(relationDtoTranslator.toDto(element,
          translated));
    }

    return result;
  }
View Full Code Here

    private CustomerServiceModelLocalService customerServiceModelService;

    @Test
    public void testCreateCrossRelations() {

        PersonDto manDto = new PersonDto();
        manDto.setLastName("Johnson");
        manDto.setFirstName("John");
        manDto.setBirthDate(new DateTime());
        Long manId = customerServiceModelService.createPerson(manDto);

        PersonDto womanDto = new PersonDto();
        womanDto.setLastName("Butterfly");
        womanDto.setFirstName("Susan");
        womanDto.setBirthDate(new DateTime());
        Long womanId = customerServiceModelService.createPerson(womanDto);
        flush();

        /* Husband: Relation from man to woman */
        RelationDto husbandDto = new RelationDto();
        husbandDto.setName("Husband");
        husbandDto.setPersonFrom(customerServiceModelService.readPersonAsPersonDto(manId));
        husbandDto.setPersonTo(customerServiceModelService.readPersonAsPersonDto(womanId));
        Long husbandId = customerServiceModelService.createRelation(husbandDto);
        flush();
        husbandDto = customerServiceModelService.readRelationAsRelationDto(husbandId);

        Assert.assertTrue(husbandId > 0);
        Assert.assertEquals(0, husbandDto.getVersion().intValue());
        Assert.assertEquals(1, husbandDto.getPersonFrom().getVersion().intValue());
        Assert.assertEquals(1, husbandDto.getPersonTo().getVersion().intValue());

        /*
         * Within the create service the opposite of a bi-directional association is updated, so we
         * always need to get the latest version of the associated object after the transaction has
         * finished. Here it's not sufficient to do: manDto = husbandRelationDto.getPersonFrom();
         * Because the man Person object is flushed at the end of the transaction and a new version
         * is born. So in these situations you'll need to use the read serivce method to get the
         * latest version from the store. If you forget to do this you will run into a
         * ConcurrentUpdateException.
         */
        manDto = customerServiceModelService.readPersonAsPersonDto(manId);
        womanDto = customerServiceModelService.readPersonAsPersonDto(womanId);
        Assert.assertEquals(1, manDto.getVersion().intValue());
        Assert.assertEquals(1, womanDto.getVersion().intValue());

        /* Wife: Relation form woman to man */
        RelationDto wifeDto = new RelationDto();
        wifeDto.setName("Wife");
        wifeDto.setPersonFrom(husbandDto.getPersonTo());
        wifeDto.setPersonTo(husbandDto.getPersonFrom());
        Long wifeRelationId = customerServiceModelService.createRelation(wifeDto);
        flush();

        wifeDto = customerServiceModelService.readRelationAsRelationDto(wifeRelationId);

        Assert.assertEquals(womanId, wifeDto.getPersonFrom().getId());
        Assert.assertEquals(manId, wifeDto.getPersonTo().getId());

        manDto = customerServiceModelService.readPersonAsPersonDto(manDto.getId());
        womanDto = customerServiceModelService.readPersonAsPersonDto(womanDto.getId());
        Assert.assertEquals(2, manDto.getVersion().intValue());
        Assert.assertEquals(2, womanDto.getVersion().intValue());
    }
View Full Code Here

     *
     */
    @Test
    public void testUpdateCrossRelations() {

        PersonDto manDto = new PersonDto();
        manDto.setLastName("Johnson");
        manDto.setFirstName("John");
        manDto.setBirthDate(new DateTime());
        Long manId = customerServiceModelService.createPerson(manDto);

        PersonDto womanDto = new PersonDto();
        womanDto.setLastName("Butterfly");
        womanDto.setFirstName("Susan");
        womanDto.setBirthDate(new DateTime());
        Long womanId = customerServiceModelService.createPerson(womanDto);

        /* Husband: Relation from man to woman */
        RelationDto husbandRelationDto = new RelationDto();
        husbandRelationDto.setName("Husband");
View Full Code Here

TOP

Related Classes of org.company.recordshop.service.dto.PersonDto

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.