Search in sources :

Example 6 with DozerBeanMapper

use of org.dozer.DozerBeanMapper in project camel by apache.

the class DozerEndpoint method createDozerBeanMapper.

private DozerBeanMapper createDozerBeanMapper() throws Exception {
    DozerBeanMapper answer = DozerComponent.createDozerBeanMapper(Collections.<String>emptyList());
    InputStream mapStream = null;
    try {
        LOG.info("Loading Dozer mapping file {}.", configuration.getMappingFile());
        // create the mapper instance and add the mapping file
        mapStream = ResourceHelper.resolveMandatoryResourceAsInputStream(getCamelContext(), configuration.getMappingFile());
        answer.addMapping(mapStream);
    } finally {
        IOHelper.close(mapStream);
    }
    return answer;
}
Also used : InputStream(java.io.InputStream) DozerBeanMapper(org.dozer.DozerBeanMapper)

Example 7 with DozerBeanMapper

use of org.dozer.DozerBeanMapper in project camel by apache.

the class DozerTypeConverterDTOTest method setUp.

@Override
public void setUp() throws Exception {
    super.setUp();
    DozerBeanMapper mapper = createCleanMapper();
    DozerTypeConverterLoader loader = new DozerTypeConverterLoader(context, mapper);
    loader.addMapping(new BeanMappingBuilder() {

        @Override
        protected void configure() {
            mapping(CustomerDTO.class, Customer.class);
        }
    });
}
Also used : DozerTestArtifactsFactory.createDtoCustomer(org.apache.camel.converter.dozer.DozerTestArtifactsFactory.createDtoCustomer) Customer(org.apache.camel.converter.dozer.model.Customer) BeanMappingBuilder(org.dozer.loader.api.BeanMappingBuilder) CustomerDTO(org.apache.camel.converter.dozer.dto.CustomerDTO) DozerBeanMapper(org.dozer.DozerBeanMapper)

Example 8 with DozerBeanMapper

use of org.dozer.DozerBeanMapper in project useful-java-links by Vedenin.

the class DozerHelloWorldApi method main.

public static void main(String[] args) {
    // init mapper
    BeanMappingBuilder builder = new BeanMappingBuilder() {

        protected void configure() {
            mapping(Source.class, Destination.class).fields("message", "text");
        }
    };
    DozerBeanMapper mapper = new DozerBeanMapper();
    mapper.addMapping(builder);
    // convert
    Source source = new Source("Hello World!");
    Destination destObject = mapper.map(source, Destination.class);
    // print Hello World!
    destObject.print();
}
Also used : BeanMappingBuilder(org.dozer.loader.api.BeanMappingBuilder) DozerBeanMapper(org.dozer.DozerBeanMapper)

Example 9 with DozerBeanMapper

use of org.dozer.DozerBeanMapper in project mastering-java by Kingminghuang.

the class Mapping method main.

public static void main(String[] args) {
    SorterDto sorterDto1 = SorterDto.builder().sort_field("name").field_type(FieldType.STRING).field_order(2).direction(Direction.DESCENDING).case_sensitive(true).build();
    SorterDto sorterDto2 = SorterDto.builder().sort_field("id").field_type(FieldType.LONG).field_order(1).direction(Direction.ASCENDING).case_sensitive(false).build();
    SorterCriteriaDto sorterCriteriaDto = new SorterCriteriaDto("sort by", AssetType.ISSUE, Arrays.asList(sorterDto1, sorterDto2));
    FilterDto filterDto1 = FilterDto.builder().filter_field("name").value("Peek").operator(FilterOperator.CONTAINS).field_type(FieldType.STRING).field_order(1).is_and_condition(true).is_or_condition(false).has_open_parenthesis(true).has_close_parenthesis(false).build();
    FilterDto filterDto2 = FilterDto.builder().filter_field("platform").value("Linux").operator(FilterOperator.EQUALS).field_type(FieldType.STRING).field_order(2).is_and_condition(false).is_or_condition(false).has_open_parenthesis(false).has_close_parenthesis(true).build();
    FilterCriteriaDto filterCriteriaDto = new FilterCriteriaDto("filter", AssetType.REQUIREMENT, Arrays.asList(filterDto1, filterDto2));
    DozerBeanMapper mapper = new DozerBeanMapper();
    mapper.setMappingFiles(Arrays.asList("dozerBeanMapping.xml"));
    SorterCriteria sorterCriteria = mapper.map(sorterCriteriaDto, SorterCriteria.class);
    System.out.println(sorterCriteria);
    FilterCriteria filterCriteria = mapper.map(filterCriteriaDto, FilterCriteria.class);
    System.out.println(filterCriteria);
}
Also used : DozerBeanMapper(org.dozer.DozerBeanMapper)

Aggregations

DozerBeanMapper (org.dozer.DozerBeanMapper)9 BeanMappingBuilder (org.dozer.loader.api.BeanMappingBuilder)2 InputStream (java.io.InputStream)1 Field (java.lang.reflect.Field)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 DozerTestArtifactsFactory.createDtoCustomer (org.apache.camel.converter.dozer.DozerTestArtifactsFactory.createDtoCustomer)1 DozerThreadContextClassLoader (org.apache.camel.converter.dozer.DozerThreadContextClassLoader)1 CustomerDTO (org.apache.camel.converter.dozer.dto.CustomerDTO)1 Customer (org.apache.camel.converter.dozer.model.Customer)1 TypeConverterRegistry (org.apache.camel.spi.TypeConverterRegistry)1 Mapper (org.dozer.Mapper)1 ClassMap (org.dozer.classmap.ClassMap)1 GlobalSettings (org.dozer.config.GlobalSettings)1 DozerClassLoader (org.dozer.util.DozerClassLoader)1