Removes some unused imports and formats DatasetManager.

This commit is contained in:
gkolokythas 2019-06-04 17:16:12 +03:00
parent 4532313623
commit b8e08869e5
6 changed files with 29 additions and 52 deletions

View File

@ -4,8 +4,6 @@ package eu.eudat.data.entities;
import eu.eudat.data.converters.DateToUTCConverter;
import eu.eudat.queryable.queryableentity.DataEntity;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.ManyToAny;
import org.hibernate.annotations.Type;
import javax.persistence.*;
import java.util.*;

View File

@ -1,9 +1,7 @@
package eu.eudat.controllers;
import eu.eudat.data.entities.DMPProfile;
import eu.eudat.data.query.items.item.dmpprofile.DataManagementPlanProfileCriteriaRequest;
import eu.eudat.data.query.items.table.dmpprofile.DataManagementPlanProfileTableRequest;
import eu.eudat.logic.managers.AdminManager;
import eu.eudat.logic.managers.DataManagementProfileManager;
import eu.eudat.logic.security.claims.ClaimedAuthorities;
import eu.eudat.logic.services.ApiContext;

View File

@ -11,7 +11,6 @@ import eu.eudat.logic.managers.UserManager;
import eu.eudat.logic.security.claims.ClaimedAuthorities;
import eu.eudat.logic.services.ApiContext;
import eu.eudat.logic.services.forms.VisibilityRuleService;
import eu.eudat.logic.utilities.documents.helpers.FileEnvelope;
import eu.eudat.models.data.datasetwizard.DataManagentPlanListingModel;
import eu.eudat.models.data.datasetwizard.DatasetWizardModel;
import eu.eudat.models.data.dmp.AssociatedProfile;
@ -29,14 +28,11 @@ import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.activation.MimetypesFileTypeMap;
import javax.transaction.Transactional;
import javax.xml.bind.JAXBException;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Files;
import java.util.List;
import java.util.UUID;

View File

@ -5,9 +5,9 @@ import eu.eudat.configurations.dynamicproject.DynamicProjectConfiguration;
import eu.eudat.configurations.dynamicproject.entities.Property;
import eu.eudat.data.dao.criteria.*;
import eu.eudat.data.dao.entities.*;
import eu.eudat.data.entities.*;
import eu.eudat.data.entities.Organisation;
import eu.eudat.data.entities.Researcher;
import eu.eudat.data.entities.*;
import eu.eudat.data.query.items.item.dmp.DataManagementPlanCriteriaRequest;
import eu.eudat.data.query.items.table.dmp.DataManagementPlanTableRequest;
import eu.eudat.data.query.items.table.dmp.DataManagmentPlanPublicTableRequest;
@ -40,7 +40,6 @@ import eu.eudat.models.data.security.Principal;
import eu.eudat.models.data.user.composite.PagedDatasetProfile;
import eu.eudat.models.data.userinfo.UserListingModel;
import eu.eudat.queryable.QueryableList;
import org.apache.poi.xwpf.usermodel.ParagraphAlignment;
import org.apache.poi.xwpf.usermodel.XWPFDocument;
import org.apache.poi.xwpf.usermodel.XWPFParagraph;
import org.apache.poi.xwpf.usermodel.XWPFRun;
@ -53,10 +52,7 @@ import org.springframework.web.client.RestTemplate;
import org.springframework.web.multipart.MultipartFile;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import javax.activation.MimetypesFileTypeMap;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Unmarshaller;

View File

@ -1,7 +1,9 @@
package eu.eudat.logic.managers;
import eu.eudat.data.dao.criteria.*;
import eu.eudat.data.dao.entities.*;
import eu.eudat.data.dao.entities.DataRepositoryDao;
import eu.eudat.data.dao.entities.DatasetDao;
import eu.eudat.data.dao.entities.RegistryDao;
import eu.eudat.data.entities.*;
import eu.eudat.data.query.items.table.dataset.DatasetPublicTableRequest;
import eu.eudat.data.query.items.table.dataset.DatasetTableRequest;
@ -17,13 +19,13 @@ import eu.eudat.logic.utilities.documents.types.ParagraphStyle;
import eu.eudat.logic.utilities.documents.word.WordBuilder;
import eu.eudat.logic.utilities.documents.xml.ExportXmlBuilder;
import eu.eudat.models.HintedModelFactory;
import eu.eudat.models.data.datasetImport.*;
import eu.eudat.models.data.datasetImport.DatasetImportField;
import eu.eudat.models.data.datasetImport.DatasetImportPagedDatasetProfile;
import eu.eudat.models.data.datasetwizard.DatasetWizardModel;
import eu.eudat.models.data.dmp.AssociatedProfile;
import eu.eudat.models.data.helpers.common.DataTableData;
import eu.eudat.models.data.listingmodels.DatasetListingModel;
import eu.eudat.models.data.security.Principal;
import eu.eudat.models.data.user.composite.DatasetProfilePage;
import eu.eudat.models.data.user.composite.PagedDatasetProfile;
import eu.eudat.queryable.QueryableList;
import org.apache.commons.io.IOUtils;
@ -33,20 +35,15 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.core.io.FileSystemResource;
import org.springframework.http.*;
import org.springframework.http.converter.ByteArrayHttpMessageConverter;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
import org.springframework.stereotype.Component;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.multipart.MultipartFile;
import javax.activation.MimetypesFileTypeMap;
import javax.mail.Multipart;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Unmarshaller;
import org.springframework.web.multipart.MultipartFile;
import java.io.*;
import java.math.BigInteger;
import java.net.URL;
@ -84,19 +81,17 @@ public class DatasetManager {
try {
datasets = datasetCriteria.getTags() != null && datasetCriteria.getTags().size() > 0 && datasetRepository.exists() ?
datasetRepository.query(datasetCriteria) : new LinkedList<>();
}
catch (Exception ex){
} catch (Exception ex) {
datasets = null;
}
UserInfo userInfo = builderFactory.getBuilder(UserInfoBuilder.class).id(principal.getId()).build();
QueryableList<eu.eudat.data.entities.Dataset> items = databaseRepository.getDatasetDao().getWithCriteria(datasetTableRequest.getCriteria()).withHint(HintedModelFactory.getHint(DatasetListingModel.class));
if (datasets != null && datasetTableRequest.getCriteria().getTags() != null && !datasetTableRequest.getCriteria().getTags().isEmpty()) {
if (!datasets.isEmpty()){
if (!datasets.isEmpty()) {
List<eu.eudat.elastic.entities.Dataset> finalDatasets = datasets;
items.where((builder, root) -> root.get("id").in(finalDatasets.stream().map(x -> UUID.fromString(x.getId())).collect(Collectors.toList())));
}
else
} else
items.where((builder, root) -> root.get("id").in(new UUID[]{UUID.randomUUID()}));
}
QueryableList<eu.eudat.data.entities.Dataset> authItems = databaseRepository.getDatasetDao().getAuthenticated(items, userInfo);
@ -121,11 +116,10 @@ public class DatasetManager {
DatasetCriteria datasetCriteria = new DatasetCriteria();
datasetCriteria.setTags(datasetTableRequest.getCriteria().getTags());
List<eu.eudat.elastic.entities.Dataset> datasets;
try{
try {
datasets = datasetCriteria.getTags() != null && datasetCriteria.getTags().size() > 0 && datasetRepository.exists() ?
datasetRepository.query(datasetCriteria) : new LinkedList<>();
}
catch (Exception ex){
} catch (Exception ex) {
datasets = null;
}
datasetTableRequest.setQuery(databaseRepository.getDatasetDao().asQueryable().withHint(HintedModelFactory.getHint(DatasetListingModel.class)));
@ -134,8 +128,7 @@ public class DatasetManager {
if (!datasets.isEmpty()) {
List<eu.eudat.elastic.entities.Dataset> finalDatasets = datasets;
items.where((builder, root) -> root.get("id").in(finalDatasets.stream().map(x -> UUID.fromString(x.getId())).collect(Collectors.toList())));
}
else
} else
items.where((builder, root) -> root.get("id").in(new UUID[]{UUID.randomUUID()}));
}
QueryableList<eu.eudat.data.entities.Dataset> pagedItems = PaginationManager.applyPaging(items, datasetTableRequest);
@ -158,11 +151,10 @@ public class DatasetManager {
DatasetWizardModel dataset = new DatasetWizardModel();
eu.eudat.data.entities.Dataset datasetEntity = databaseRepository.getDatasetDao().find(UUID.fromString(id), HintedModelFactory.getHint(DatasetWizardModel.class));
eu.eudat.elastic.entities.Dataset datasetElastic;
try{
try {
datasetElastic = datasetRepository.exists() ?
datasetRepository.findDocument(id) : new eu.eudat.elastic.entities.Dataset();
}
catch (Exception ex){
} catch (Exception ex) {
datasetElastic = new eu.eudat.elastic.entities.Dataset();
}
dataset.setDatasetProfileDefinition(getPagedProfile(dataset, datasetEntity));
@ -182,9 +174,9 @@ public class DatasetManager {
List<DatasetProfile> profileVersionsIncluded = new LinkedList<>();
// Iterate through the versions and remove those that are not included in the DMP of the dataset in question.
for(DatasetProfile version : profileVersions) {
for(AssociatedProfile p : dataset.getDmp().getProfiles()){
if(version.getId().toString().equals(p.getId().toString())) {
for (DatasetProfile version : profileVersions) {
for (AssociatedProfile p : dataset.getDmp().getProfiles()) {
if (version.getId().toString().equals(p.getId().toString())) {
profileVersionsIncluded.add(version);
}
}
@ -208,12 +200,11 @@ public class DatasetManager {
DatasetWizardModel dataset = new DatasetWizardModel();
eu.eudat.data.entities.Dataset datasetEntity = databaseRepository.getDatasetDao().isPublicDataset(UUID.fromString(id));
if (datasetEntity != null && datasetEntity.getStatus() == 1 && datasetEntity.getDmp().getStatus() == 1){
if (datasetEntity != null && datasetEntity.getStatus() == 1 && datasetEntity.getDmp().getStatus() == 1) {
dataset.setDatasetProfileDefinition(getPagedProfile(dataset, datasetEntity));
dataset.fromDataModel(datasetEntity);
return dataset;
}
else {
} else {
throw new Exception("Selected dataset is not public");
}
}
@ -465,7 +456,7 @@ public class DatasetManager {
InputStream in = importFile.getInputStream();
jaxbContext = JAXBContext.newInstance(DatasetImportPagedDatasetProfile.class);
Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
DatasetImportPagedDatasetProfile datasetImport = (DatasetImportPagedDatasetProfile)jaxbUnmarshaller.unmarshal(in);
DatasetImportPagedDatasetProfile datasetImport = (DatasetImportPagedDatasetProfile) jaxbUnmarshaller.unmarshal(in);
importModel = datasetImport;
} catch (IOException e) {
e.printStackTrace();
@ -487,12 +478,12 @@ public class DatasetManager {
Map<String, String> importMap = importModel.getPages().stream()
.flatMap(s -> s.getSections().getSection().stream()
.flatMap(cFields -> cFields.getCompositeFields().stream()
.flatMap(cField -> cField.getCompositeField().stream()
.filter(Objects::nonNull)
.flatMap(fields -> fields.getFields().stream()
.flatMap(field -> field.getField().stream()
.filter(f -> f.getValue() != null)
)))))
.flatMap(cField -> cField.getCompositeField().stream()
.filter(Objects::nonNull)
.flatMap(fields -> fields.getFields().stream()
.flatMap(field -> field.getField().stream()
.filter(f -> f.getValue() != null)
)))))
.collect(Collectors.toMap(DatasetImportField::getId, DatasetImportField::getValue));
// Transforms map into json file.
@ -533,11 +524,10 @@ public class DatasetManager {
DatasetWizardModel dataset = new DatasetWizardModel();
eu.eudat.data.entities.Dataset datasetEntity = databaseRepository.getDatasetDao().find(UUID.fromString(id), HintedModelFactory.getHint(DatasetWizardModel.class));
eu.eudat.elastic.entities.Dataset datasetElastic;
try{
try {
datasetElastic = datasetRepository.exists() ?
datasetRepository.findDocument(id) : new eu.eudat.elastic.entities.Dataset();
}
catch (Exception ex){
} catch (Exception ex) {
datasetElastic = new eu.eudat.elastic.entities.Dataset();
}
dataset.setDatasetProfileDefinition(getPagedProfile(dataset, datasetEntity));

View File

@ -2,7 +2,6 @@ package eu.eudat.models.data.dmp;
import eu.eudat.data.entities.DMP;
import eu.eudat.data.entities.UserDMP;
import eu.eudat.models.DataModel;
import java.util.Date;
import java.util.UUID;