76 lines
3.4 KiB
Java
76 lines
3.4 KiB
Java
//package eu.eudat.model.builder.filetransformer;
|
|
//
|
|
//import eu.eudat.authorization.AuthorizationFlags;
|
|
//import eu.eudat.convention.ConventionService;
|
|
//import eu.eudat.data.UserContactInfoEntity;
|
|
//import eu.eudat.data.UserEntity;
|
|
//import eu.eudat.file.transformer.enums.ContactInfoType;
|
|
//import eu.eudat.file.transformer.models.user.UserContactInfoFileTransformerModel;
|
|
//import eu.eudat.file.transformer.models.user.UserFileTransformerModel;
|
|
//import eu.eudat.query.UserContactInfoQuery;
|
|
//import gr.cite.tools.data.query.QueryFactory;
|
|
//import gr.cite.tools.exception.MyApplicationException;
|
|
//import gr.cite.tools.logging.LoggerService;
|
|
//import org.slf4j.LoggerFactory;
|
|
//import org.springframework.beans.factory.annotation.Autowired;
|
|
//import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
|
//import org.springframework.context.annotation.Scope;
|
|
//import org.springframework.stereotype.Component;
|
|
//
|
|
//import java.util.*;
|
|
//
|
|
//@Component
|
|
//@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
|
//public class UserFileTransformerBuilder extends BaseFileTransformerBuilder<UserFileTransformerModel, UserEntity> {
|
|
//
|
|
// private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
|
|
// private final QueryFactory queryFactory;
|
|
//
|
|
// @Autowired
|
|
// public UserFileTransformerBuilder(ConventionService conventionService, QueryFactory queryFactory) {
|
|
// super(conventionService, new LoggerService(LoggerFactory.getLogger(UserFileTransformerBuilder.class)));
|
|
// this.queryFactory = queryFactory;
|
|
// }
|
|
//
|
|
// public UserFileTransformerBuilder authorize(EnumSet<AuthorizationFlags> values) {
|
|
// this.authorize = values;
|
|
// return this;
|
|
// }
|
|
//
|
|
// @Override
|
|
// protected List<FileTransformerBuilderItemResponse<UserFileTransformerModel, UserEntity>> buildInternal(List<UserEntity> data) throws MyApplicationException {
|
|
// this.logger.debug("building for {} items ", Optional.ofNullable(data).map(List::size).orElse(0));
|
|
// if (data == null)
|
|
// return new ArrayList<>();
|
|
//
|
|
// List<FileTransformerBuilderItemResponse<UserFileTransformerModel, UserEntity>> models = new ArrayList<>();
|
|
//
|
|
// for (UserEntity d : data) {
|
|
// UserFileTransformerModel m = new UserFileTransformerModel();
|
|
// m.setId(d.getId());
|
|
// m.setName(d.getName());
|
|
// m.setContacts(mapContactInfo(d.getId()));
|
|
// models.add(new FileTransformerBuilderItemResponse<>(m, d));
|
|
// }
|
|
// this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0));
|
|
//
|
|
// return models;
|
|
// }
|
|
//
|
|
// private List<UserContactInfoFileTransformerModel> mapContactInfo(UUID userId) {
|
|
// List<UserContactInfoFileTransformerModel> result = new ArrayList<>();
|
|
// UserContactInfoQuery query = this.queryFactory.query(UserContactInfoQuery.class).userIds(userId);
|
|
// List<UserContactInfoEntity> contactInfos = query.collect();
|
|
// contactInfos.forEach(contactInfo -> {
|
|
// UserContactInfoFileTransformerModel m = new UserContactInfoFileTransformerModel();
|
|
// m.setId(contactInfo.getId());
|
|
// m.setOrdinal(contactInfo.getOrdinal());
|
|
// m.setType(ContactInfoType.of(contactInfo.getType().getValue()));
|
|
// m.setValue(contactInfo.getValue());
|
|
// result.add(m);
|
|
// });
|
|
// return result;
|
|
// }
|
|
//
|
|
//}
|