com.eurodyn.qlack.fuse.aaa.mappers.UserDetailsMapperImpl Maven / Gradle / Ivy
package com.eurodyn.qlack.fuse.aaa.mappers;
import com.eurodyn.qlack.fuse.aaa.dto.OperationDTO;
import com.eurodyn.qlack.fuse.aaa.dto.ResourceDTO;
import com.eurodyn.qlack.fuse.aaa.dto.UserDetailsDTO;
import com.eurodyn.qlack.fuse.aaa.dto.UserGroupDTO;
import com.eurodyn.qlack.fuse.aaa.dto.UserHasOperationDTO;
import com.eurodyn.qlack.fuse.aaa.model.Operation;
import com.eurodyn.qlack.fuse.aaa.model.Resource;
import com.eurodyn.qlack.fuse.aaa.model.User;
import com.eurodyn.qlack.fuse.aaa.model.UserGroup;
import com.eurodyn.qlack.fuse.aaa.model.UserHasOperation;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import javax.annotation.Generated;
import org.springframework.stereotype.Component;
@Generated(
value = "org.mapstruct.ap.MappingProcessor",
date = "2019-05-03T08:55:23+0000",
comments = "version: 1.3.0.Final, compiler: javac, environment: Java 1.8.0_161 (Oracle Corporation)"
)
@Component
public class UserDetailsMapperImpl implements UserDetailsMapper {
@Override
public UserDetailsDTO mapToDTO(User user, UserGroupHasOperationMapper userGroupHasOperationMapper) {
if ( user == null ) {
return null;
}
UserDetailsDTO userDetailsDTO = new UserDetailsDTO();
userDetailsDTO.setUserGroupHasOperations( mapUserGroupHasOperations( user.getUserGroups(), userGroupHasOperationMapper ) );
userDetailsDTO.setId( user.getId() );
userDetailsDTO.setUsername( user.getUsername() );
userDetailsDTO.setPassword( user.getPassword() );
userDetailsDTO.setSalt( user.getSalt() );
userDetailsDTO.setStatus( user.getStatus() );
userDetailsDTO.setSuperadmin( user.isSuperadmin() );
userDetailsDTO.setExternal( user.isExternal() );
userDetailsDTO.setUserHasOperations( userHasOperationListToUserHasOperationDTOList( user.getUserHasOperations(), userGroupHasOperationMapper ) );
userDetailsDTO.setUserGroups( userGroupListToUserGroupDTOList( user.getUserGroups(), userGroupHasOperationMapper ) );
return userDetailsDTO;
}
protected OperationDTO operationToOperationDTO(Operation operation, UserGroupHasOperationMapper userGroupHasOperationMapper) {
if ( operation == null ) {
return null;
}
OperationDTO operationDTO = new OperationDTO();
operationDTO.setId( operation.getId() );
operationDTO.setName( operation.getName() );
operationDTO.setDynamic( operation.isDynamic() );
operationDTO.setDynamicCode( operation.getDynamicCode() );
operationDTO.setDescription( operation.getDescription() );
return operationDTO;
}
protected ResourceDTO resourceToResourceDTO(Resource resource, UserGroupHasOperationMapper userGroupHasOperationMapper) {
if ( resource == null ) {
return null;
}
ResourceDTO resourceDTO = new ResourceDTO();
resourceDTO.setId( resource.getId() );
resourceDTO.setName( resource.getName() );
resourceDTO.setDescription( resource.getDescription() );
resourceDTO.setObjectId( resource.getObjectId() );
return resourceDTO;
}
protected UserHasOperationDTO userHasOperationToUserHasOperationDTO(UserHasOperation userHasOperation, UserGroupHasOperationMapper userGroupHasOperationMapper) {
if ( userHasOperation == null ) {
return null;
}
UserHasOperationDTO userHasOperationDTO = new UserHasOperationDTO();
userHasOperationDTO.setId( userHasOperation.getId() );
userHasOperationDTO.setOperation( operationToOperationDTO( userHasOperation.getOperation(), userGroupHasOperationMapper ) );
userHasOperationDTO.setResource( resourceToResourceDTO( userHasOperation.getResource(), userGroupHasOperationMapper ) );
userHasOperationDTO.setDeny( userHasOperation.isDeny() );
return userHasOperationDTO;
}
protected List userHasOperationListToUserHasOperationDTOList(List list, UserGroupHasOperationMapper userGroupHasOperationMapper) {
if ( list == null ) {
return null;
}
List list1 = new ArrayList( list.size() );
for ( UserHasOperation userHasOperation : list ) {
list1.add( userHasOperationToUserHasOperationDTO( userHasOperation, userGroupHasOperationMapper ) );
}
return list1;
}
protected Set userGroupListToUserGroupDTOSet(List list, UserGroupHasOperationMapper userGroupHasOperationMapper) {
if ( list == null ) {
return null;
}
Set set = new HashSet( Math.max( (int) ( list.size() / .75f ) + 1, 16 ) );
for ( UserGroup userGroup : list ) {
set.add( userGroupToUserGroupDTO( userGroup, userGroupHasOperationMapper ) );
}
return set;
}
protected UserGroupDTO userGroupToUserGroupDTO(UserGroup userGroup, UserGroupHasOperationMapper userGroupHasOperationMapper) {
if ( userGroup == null ) {
return null;
}
UserGroupDTO userGroupDTO = new UserGroupDTO();
userGroupDTO.setId( userGroup.getId() );
userGroupDTO.setName( userGroup.getName() );
userGroupDTO.setObjectId( userGroup.getObjectId() );
userGroupDTO.setDescription( userGroup.getDescription() );
userGroupDTO.setChildren( userGroupListToUserGroupDTOSet( userGroup.getChildren(), userGroupHasOperationMapper ) );
return userGroupDTO;
}
protected List userGroupListToUserGroupDTOList(List list, UserGroupHasOperationMapper userGroupHasOperationMapper) {
if ( list == null ) {
return null;
}
List list1 = new ArrayList( list.size() );
for ( UserGroup userGroup : list ) {
list1.add( userGroupToUserGroupDTO( userGroup, userGroupHasOperationMapper ) );
}
return list1;
}
}