Java Code Examples for org.apache.commons.beanutils.PropertyUtilsBean#copyProperties()

The following examples show how to use org.apache.commons.beanutils.PropertyUtilsBean#copyProperties() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RecommendationService.java    From mapr-music with Apache License 2.0 6 votes vote down vote up
private AlbumDto albumToDto(Album album) {

        AlbumDto albumDto = new AlbumDto();
        PropertyUtilsBean propertyUtilsBean = new PropertyUtilsBean();
        try {
            propertyUtilsBean.copyProperties(albumDto, album);
        } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
            throw new RuntimeException("Can not create album Data Transfer Object", e);
        }

        String slug = slugService.getSlugForAlbum(album);
        albumDto.setSlug(slug);

        if (album.getArtists() != null && !album.getArtists().isEmpty()) {

            List<ArtistDto> artistDtoList = album.getArtists().stream()
                    .map(this::artistShortInfoToDto)
                    .collect(toList());

            albumDto.setArtistList(artistDtoList);
        }

        return albumDto;
    }
 
Example 2
Source File: ArtistService.java    From mapr-music with Apache License 2.0 6 votes vote down vote up
private Artist dtoToArtist(ArtistDto artistDto) {
    Artist artist = new Artist();
    PropertyUtilsBean propertyUtilsBean = new PropertyUtilsBean();
    try {
        propertyUtilsBean.copyProperties(artist, artistDto);
    } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
        throw new RuntimeException("Can not create Artist from Data Transfer Object", e);
    }

    if (artistDto.getAlbums() != null) {
        List<Album.ShortInfo> albums = artistDto.getAlbums().stream()
                .map(this::albumDtoToShortInfo)
                .collect(Collectors.toList());
        artist.setAlbums(albums);
    }

    if (artistDto.getBeginDateDay() != null) {
        artist.setBeginDate(new ODate(artistDto.getBeginDateDay()));
    }

    if (artistDto.getEndDateDay() != null) {
        artist.setEndDate(new ODate(artistDto.getEndDateDay()));
    }

    return artist;
}
 
Example 3
Source File: ArtistService.java    From mapr-music with Apache License 2.0 6 votes vote down vote up
private ArtistDto artistToDto(Artist artist) {
    ArtistDto artistDto = new ArtistDto();
    PropertyUtilsBean propertyUtilsBean = new PropertyUtilsBean();
    try {
        propertyUtilsBean.copyProperties(artistDto, artist);
    } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
        throw new RuntimeException("Can not create artist Data Transfer Object", e);
    }

    String slug = slugService.getSlugForArtist(artist);
    artistDto.setSlug(slug);

    if (artist.getBeginDate() != null) {
        artistDto.setBeginDateDay(artist.getBeginDate().toDate());
    }

    if (artist.getEndDate() != null) {
        artistDto.setEndDateDay(artist.getEndDate().toDate());
    }

    return artistDto;
}
 
Example 4
Source File: UserService.java    From mapr-music with Apache License 2.0 5 votes vote down vote up
private User dtoToUser(UserDto userDto) {

        User user = new User();
        PropertyUtilsBean propertyUtilsBean = new PropertyUtilsBean();
        try {
            propertyUtilsBean.copyProperties(user, userDto);
        } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
            throw new RuntimeException("Can not create user from Data Transfer Object", e);
        }

        user.setId(userDto.getUsername());

        return user;
    }
 
Example 5
Source File: BeanConfigurator.java    From sailfish-core with Apache License 2.0 5 votes vote down vote up
public static void copyBean(Object beanOrig, Object beanClone)
{
	PropertyUtilsBean beanUtils = new PropertyUtilsBean();
	
	try
	{
		beanUtils.copyProperties(beanClone, beanOrig);
	}
	catch ( Exception e )
	{
		throw new EPSCommonException(e);
	}
	
}
 
Example 6
Source File: UserService.java    From mapr-music with Apache License 2.0 5 votes vote down vote up
private UserDto userToDto(User user) {

        UserDto userDto = new UserDto();
        PropertyUtilsBean propertyUtilsBean = new PropertyUtilsBean();
        try {
            propertyUtilsBean.copyProperties(userDto, user);
        } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
            throw new RuntimeException("Can not create user Data Transfer Object", e);
        }

        userDto.setUsername(user.getId());

        return userDto;
    }
 
Example 7
Source File: RecommendationService.java    From mapr-music with Apache License 2.0 5 votes vote down vote up
private ArtistDto artistToDto(Artist artist) {

        ArtistDto artistDto = new ArtistDto();
        PropertyUtilsBean propertyUtilsBean = new PropertyUtilsBean();
        try {
            propertyUtilsBean.copyProperties(artistDto, artist);
        } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
            throw new RuntimeException("Can not create artist Data Transfer Object", e);
        }

        String slug = slugService.getSlugForArtist(artist);
        artistDto.setSlug(slug);

        return artistDto;
    }
 
Example 8
Source File: RecommendationService.java    From mapr-music with Apache License 2.0 5 votes vote down vote up
private ArtistDto artistShortInfoToDto(Artist.ShortInfo artistShortInfo) {

        ArtistDto artistDto = new ArtistDto();
        PropertyUtilsBean propertyUtilsBean = new PropertyUtilsBean();
        try {
            propertyUtilsBean.copyProperties(artistDto, artistShortInfo);
        } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
            throw new RuntimeException("Can not create artist Data Transfer Object", e);
        }

        return artistDto;
    }
 
Example 9
Source File: ArtistService.java    From mapr-music with Apache License 2.0 5 votes vote down vote up
private Album.ShortInfo albumDtoToShortInfo(AlbumDto albumDto) {

        Album.ShortInfo albumShortInfo = new Album.ShortInfo();
        PropertyUtilsBean propertyUtilsBean = new PropertyUtilsBean();
        try {
            propertyUtilsBean.copyProperties(albumShortInfo, albumDto);
        } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
            throw new RuntimeException("Can not create album Data Transfer Object", e);
        }

        return albumShortInfo;
    }
 
Example 10
Source File: ArtistService.java    From mapr-music with Apache License 2.0 5 votes vote down vote up
private AlbumDto shortInfoToAlbumDto(Album.ShortInfo albumShortInfo) {

        AlbumDto albumDto = new AlbumDto();
        PropertyUtilsBean propertyUtilsBean = new PropertyUtilsBean();
        try {
            propertyUtilsBean.copyProperties(albumDto, albumShortInfo);
        } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
            throw new RuntimeException("Can not create album Data Transfer Object", e);
        }

        return albumDto;
    }
 
Example 11
Source File: RateService.java    From mapr-music with Apache License 2.0 5 votes vote down vote up
private RateDto albumRateToDto(AlbumRate albumRate) {

        RateDto rateDto = new RateDto();
        PropertyUtilsBean propertyUtilsBean = new PropertyUtilsBean();
        try {
            propertyUtilsBean.copyProperties(rateDto, albumRate);
        } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
            throw new RuntimeException("Can not create album rate Data Transfer Object", e);
        }

        return rateDto;
    }
 
Example 12
Source File: RateService.java    From mapr-music with Apache License 2.0 5 votes vote down vote up
private RateDto artistRateToDto(ArtistRate artistRate) {

        RateDto rateDto = new RateDto();
        PropertyUtilsBean propertyUtilsBean = new PropertyUtilsBean();
        try {
            propertyUtilsBean.copyProperties(rateDto, artistRate);
        } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
            throw new RuntimeException("Can not create artist rate Data Transfer Object", e);
        }

        return rateDto;
    }
 
Example 13
Source File: AlbumService.java    From mapr-music with Apache License 2.0 5 votes vote down vote up
private Artist.ShortInfo artistDtoToShortInfo(ArtistDto artistDto) {

        Artist.ShortInfo artistShortInfo = new Artist.ShortInfo();
        PropertyUtilsBean propertyUtilsBean = new PropertyUtilsBean();
        try {
            propertyUtilsBean.copyProperties(artistShortInfo, artistDto);
        } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
            throw new RuntimeException("Can not create album Data Transfer Object", e);
        }

        return artistShortInfo;
    }
 
Example 14
Source File: AlbumService.java    From mapr-music with Apache License 2.0 5 votes vote down vote up
private ArtistDto artistShortInfoToDto(Artist.ShortInfo artistShortInfo) {

        ArtistDto artistDto = new ArtistDto();
        PropertyUtilsBean propertyUtilsBean = new PropertyUtilsBean();
        try {
            propertyUtilsBean.copyProperties(artistDto, artistShortInfo);
        } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
            throw new RuntimeException("Can not create artist Data Transfer Object", e);
        }

        return artistDto;
    }
 
Example 15
Source File: AlbumService.java    From mapr-music with Apache License 2.0 5 votes vote down vote up
private Album dtoToAlbum(AlbumDto albumDto) {

        Album album = new Album();
        PropertyUtilsBean propertyUtilsBean = new PropertyUtilsBean();
        try {
            propertyUtilsBean.copyProperties(album, albumDto);
        } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
            throw new RuntimeException("Can not create album Data Transfer Object", e);
        }

        if (albumDto.getTrackList() != null && !albumDto.getTrackList().isEmpty()) {

            List<Track> trackList = albumDto.getTrackList().stream()
                    .map(this::dtoToTrack)
                    .collect(toList());

            album.setTrackList(trackList);
        }

        if (albumDto.getArtistList() != null && !albumDto.getArtistList().isEmpty()) {

            List<Artist.ShortInfo> artistShortInfoList = albumDto.getArtistList().stream()
                    .map(this::artistDtoToShortInfo)
                    .collect(toList());

            album.setArtists(artistShortInfoList);
        }

        if (albumDto.getReleasedDateDay() != null) {
            album.setReleasedDate(new ODate(albumDto.getReleasedDateDay()));
        }

        return album;
    }
 
Example 16
Source File: AlbumService.java    From mapr-music with Apache License 2.0 5 votes vote down vote up
private Track dtoToTrack(TrackDto trackDto) {

        Track track = new Track();
        PropertyUtilsBean propertyUtilsBean = new PropertyUtilsBean();
        try {
            propertyUtilsBean.copyProperties(track, trackDto);
        } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
            throw new RuntimeException("Can not create track from Data Transfer Object", e);
        }

        return track;
    }
 
Example 17
Source File: AlbumService.java    From mapr-music with Apache License 2.0 5 votes vote down vote up
private TrackDto trackToDto(Track track) {

        TrackDto trackDto = new TrackDto();
        PropertyUtilsBean propertyUtilsBean = new PropertyUtilsBean();
        try {
            propertyUtilsBean.copyProperties(trackDto, track);
        } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
            throw new RuntimeException("Can not create track Data Transfer Object", e);
        }

        return trackDto;
    }
 
Example 18
Source File: AlbumService.java    From mapr-music with Apache License 2.0 5 votes vote down vote up
private AlbumDto albumToDto(Album album) {

        AlbumDto albumDto = new AlbumDto();
        PropertyUtilsBean propertyUtilsBean = new PropertyUtilsBean();
        try {
            propertyUtilsBean.copyProperties(albumDto, album);
        } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
            throw new RuntimeException("Can not create album Data Transfer Object", e);
        }

        String slug = slugService.getSlugForAlbum(album);
        albumDto.setSlug(slug);

        if (album.getTrackList() != null && !album.getTrackList().isEmpty()) {

            List<TrackDto> trackDtoList = album.getTrackList().stream()
                    .map(this::trackToDto)
                    .collect(toList());

            albumDto.setTrackList(trackDtoList);
        }

        if (album.getArtists() != null && !album.getArtists().isEmpty()) {

            List<ArtistDto> artistDtoList = album.getArtists().stream()
                    .map(this::artistShortInfoToDto)
                    .collect(toList());

            albumDto.setArtistList(artistDtoList);
        }

        if (album.getReleasedDate() != null) {
            albumDto.setReleasedDateDay(album.getReleasedDate().toDate());
        }

        return albumDto;
    }