no message
This commit is contained in:
parent
cc5e080219
commit
af8991b97a
|
@ -5,6 +5,11 @@ import eu.eudat.queryable.queryableentity.DataEntity;
|
|||
|
||||
|
||||
public class DatabaseAccess<T extends DataEntity> {
|
||||
|
||||
public DatabaseAccess(DatabaseService<T> databaseService) {
|
||||
this.databaseService = databaseService;
|
||||
}
|
||||
|
||||
private DatabaseService<T> databaseService;
|
||||
|
||||
public DatabaseService<T> getDatabaseService() {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package eu.eudat.data.dao.databaselayer.context;
|
||||
|
||||
import eu.eudat.queryable.QueryableList;
|
||||
import eu.eudat.queryable.hibernatequeryablelist.QueryableHibernateList;
|
||||
import eu.eudat.queryable.jpa.hibernatequeryablelist.QueryableHibernateList;
|
||||
import eu.eudat.queryable.queryableentity.DataEntity;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
|
|
@ -25,7 +25,7 @@ public class DatabaseService<T extends DataEntity> {
|
|||
}
|
||||
|
||||
public QueryableList<T> getQueryable(Set<String> hints, Class<T> tClass) {
|
||||
return this.databaseCtx.getQueryable(tClass).setHints(hints);
|
||||
return this.databaseCtx.getQueryable(tClass);
|
||||
}
|
||||
|
||||
public T createOrUpdate(T item, Class<T> tClass) {
|
||||
|
|
|
@ -18,7 +18,7 @@ public class ContentDaoImpl extends DatabaseAccess<Content> implements ContentDa
|
|||
|
||||
@Autowired
|
||||
public ContentDaoImpl(DatabaseService<Content> databaseService) {
|
||||
this.setDatabaseService(databaseService);
|
||||
super(databaseService);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -22,7 +22,7 @@ public class DMPDaoImpl extends DatabaseAccess<DMP> implements DMPDao {
|
|||
|
||||
@Autowired
|
||||
public DMPDaoImpl(DatabaseService<DMP> databaseService) {
|
||||
this.setDatabaseService(databaseService);
|
||||
super(databaseService);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -19,7 +19,7 @@ public class DMPProfileDaoImpl extends DatabaseAccess<DMPProfile> implements DMP
|
|||
|
||||
@Autowired
|
||||
public DMPProfileDaoImpl(DatabaseService<DMPProfile> databaseService) {
|
||||
this.setDatabaseService(databaseService);
|
||||
super(databaseService);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -16,7 +16,7 @@ public class DataRepositoryDaoImpl extends DatabaseAccess<DataRepository> implem
|
|||
|
||||
@Autowired
|
||||
public DataRepositoryDaoImpl(DatabaseService<DataRepository> databaseService) {
|
||||
this.setDatabaseService(databaseService);
|
||||
super(databaseService);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -8,6 +8,7 @@ import eu.eudat.data.entities.UserInfo;
|
|||
import eu.eudat.queryable.QueryableList;
|
||||
import eu.eudat.queryable.types.FieldSelectionType;
|
||||
import eu.eudat.queryable.types.SelectionField;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
@ -17,8 +18,9 @@ import java.util.concurrent.CompletableFuture;
|
|||
@Component("datasetDao")
|
||||
public class DatasetDaoImpl extends DatabaseAccess<Dataset> implements DatasetDao {
|
||||
|
||||
@Autowired
|
||||
public DatasetDaoImpl(DatabaseService<Dataset> databaseService) {
|
||||
this.setDatabaseService(databaseService);
|
||||
super(databaseService);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
package eu.eudat.data.dao.entities;
|
||||
|
||||
import eu.eudat.data.dao.DatabaseAccessLayer;
|
||||
import eu.eudat.data.entities.DatasetExternalDataset;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Created by ikalyvas on 5/22/2018.
|
||||
*/
|
||||
public interface DatasetExternalDatasetDao extends DatabaseAccessLayer<DatasetExternalDataset, UUID> {
|
||||
|
||||
}
|
|
@ -0,0 +1,55 @@
|
|||
package eu.eudat.data.dao.entities;
|
||||
|
||||
import eu.eudat.data.dao.DatabaseAccess;
|
||||
import eu.eudat.data.dao.databaselayer.service.DatabaseService;
|
||||
import eu.eudat.data.entities.DatasetExternalDataset;
|
||||
import eu.eudat.data.entities.DatasetProfile;
|
||||
import eu.eudat.queryable.QueryableList;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
/**
|
||||
* Created by ikalyvas on 5/22/2018.
|
||||
*/
|
||||
@Component("datasetExternalDatasetDao")
|
||||
public class DatasetExternalDatasetDaoImpl extends DatabaseAccess<DatasetExternalDataset> implements DatasetExternalDatasetDao {
|
||||
|
||||
@Autowired
|
||||
public DatasetExternalDatasetDaoImpl(DatabaseService<DatasetExternalDataset> databaseService) {
|
||||
super(databaseService);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DatasetExternalDataset createOrUpdate(DatasetExternalDataset item) {
|
||||
return this.getDatabaseService().createOrUpdate(item,DatasetExternalDataset.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<DatasetExternalDataset> createOrUpdateAsync(DatasetExternalDataset item) {
|
||||
return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item));
|
||||
}
|
||||
|
||||
@Override
|
||||
public DatasetExternalDataset find(UUID id) {
|
||||
return getDatabaseService().getQueryable(DatasetExternalDataset.class).where((builder, root) -> builder.equal(root.get("id"), id)).getSingle();
|
||||
}
|
||||
|
||||
@Override
|
||||
public DatasetExternalDataset find(UUID id, String hint) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void delete(DatasetExternalDataset item) {
|
||||
this.getDatabaseService().delete(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public QueryableList<DatasetExternalDataset> asQueryable() {
|
||||
return this.getDatabaseService().getQueryable(DatasetExternalDataset.class);
|
||||
}
|
||||
}
|
|
@ -16,7 +16,7 @@ public class DatasetProfileDaoImpl extends DatabaseAccess<DatasetProfile> implem
|
|||
|
||||
@Autowired
|
||||
public DatasetProfileDaoImpl(DatabaseService<DatasetProfile> databaseService) {
|
||||
this.setDatabaseService(databaseService);
|
||||
super(databaseService);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
package eu.eudat.data.dao.entities;
|
||||
|
||||
import eu.eudat.data.dao.DatabaseAccessLayer;
|
||||
import eu.eudat.data.entities.DatasetProfile;
|
||||
import eu.eudat.data.entities.DatasetService;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Created by ikalyvas on 5/22/2018.
|
||||
*/
|
||||
public interface DatasetServiceDao extends DatabaseAccessLayer<DatasetService, UUID> {
|
||||
}
|
|
@ -0,0 +1,55 @@
|
|||
package eu.eudat.data.dao.entities;
|
||||
|
||||
import eu.eudat.data.dao.DatabaseAccess;
|
||||
import eu.eudat.data.dao.databaselayer.service.DatabaseService;
|
||||
import eu.eudat.data.entities.DatasetExternalDataset;
|
||||
import eu.eudat.data.entities.DatasetProfile;
|
||||
import eu.eudat.data.entities.DatasetService;
|
||||
import eu.eudat.queryable.QueryableList;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
/**
|
||||
* Created by ikalyvas on 5/22/2018.
|
||||
*/
|
||||
@Component("datasetServiceDao")
|
||||
public class DatasetServiceDaoImpl extends DatabaseAccess<DatasetService> implements DatasetServiceDao {
|
||||
|
||||
@Autowired
|
||||
public DatasetServiceDaoImpl(DatabaseService<DatasetService> databaseService) {
|
||||
super(databaseService);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DatasetService createOrUpdate(DatasetService item) {
|
||||
return this.getDatabaseService().createOrUpdate(item, DatasetService.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<DatasetService> createOrUpdateAsync(DatasetService item) {
|
||||
return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item));
|
||||
}
|
||||
|
||||
@Override
|
||||
public DatasetService find(UUID id) {
|
||||
return getDatabaseService().getQueryable(DatasetService.class).where((builder, root) -> builder.equal(root.get("id"), id)).getSingle();
|
||||
}
|
||||
|
||||
@Override
|
||||
public DatasetService find(UUID id, String hint) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(DatasetService item) {
|
||||
this.getDatabaseService().delete(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public QueryableList<DatasetService> asQueryable() {
|
||||
return this.getDatabaseService().getQueryable(DatasetService.class);
|
||||
}
|
||||
}
|
|
@ -17,7 +17,7 @@ public class ExternalDatasetDaoImpl extends DatabaseAccess<ExternalDataset> impl
|
|||
|
||||
@Autowired
|
||||
public ExternalDatasetDaoImpl(DatabaseService<ExternalDataset> databaseService) {
|
||||
this.setDatabaseService(databaseService);
|
||||
super(databaseService);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -17,7 +17,7 @@ public class InvitationDaoImpl extends DatabaseAccess<Invitation> implements Inv
|
|||
|
||||
@Autowired
|
||||
public InvitationDaoImpl(DatabaseService<Invitation> databaseService) {
|
||||
this.setDatabaseService(databaseService);
|
||||
super(databaseService);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -16,7 +16,7 @@ public class OrganisationDaoImpl extends DatabaseAccess<Organisation> implements
|
|||
|
||||
@Autowired
|
||||
public OrganisationDaoImpl(DatabaseService<Organisation> databaseService) {
|
||||
this.setDatabaseService(databaseService);
|
||||
super(databaseService);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -9,6 +9,7 @@ import eu.eudat.queryable.QueryableList;
|
|||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.persistence.criteria.JoinType;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
|
@ -17,7 +18,7 @@ public class ProjectDaoImpl extends DatabaseAccess<Project> implements ProjectDa
|
|||
|
||||
@Autowired
|
||||
public ProjectDaoImpl(DatabaseService<Project> databaseService) {
|
||||
this.setDatabaseService(databaseService);
|
||||
super(databaseService);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -56,7 +57,7 @@ public class ProjectDaoImpl extends DatabaseAccess<Project> implements ProjectDa
|
|||
}
|
||||
|
||||
public QueryableList<Project> getAuthenticated(QueryableList<Project> query, UserInfo principal) {
|
||||
query.where((builder, root) -> builder.or(builder.equal(root.get("creationUser"), principal), builder.isMember(principal, root.join("dmps").get("users")))).distinct();
|
||||
query.where((builder, root) -> builder.or(builder.equal(root.get("creationUser"), principal), builder.isMember(principal, root.join("dmps", JoinType.LEFT).get("users")))).distinct();
|
||||
return query;
|
||||
}
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ public class RegistryDaoImpl extends DatabaseAccess<Registry> implements Registr
|
|||
|
||||
@Autowired
|
||||
public RegistryDaoImpl(DatabaseService<Registry> databaseService) {
|
||||
this.setDatabaseService(databaseService);
|
||||
super(databaseService);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -16,7 +16,7 @@ public class ResearcherDaoImpl extends DatabaseAccess<Researcher> implements Res
|
|||
|
||||
@Autowired
|
||||
public ResearcherDaoImpl(DatabaseService<Researcher> databaseService) {
|
||||
this.setDatabaseService(databaseService);
|
||||
super(databaseService);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -16,7 +16,7 @@ public class ServiceDaoImpl extends DatabaseAccess<Service> implements ServiceDa
|
|||
|
||||
@Autowired
|
||||
public ServiceDaoImpl(DatabaseService<Service> databaseService) {
|
||||
this.setDatabaseService(databaseService);
|
||||
super(databaseService);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -18,7 +18,7 @@ public class UserDmpDaoImpl extends DatabaseAccess<UserDMP> implements UserDmpDa
|
|||
|
||||
@Autowired
|
||||
public UserDmpDaoImpl(DatabaseService<UserDMP> databaseService) {
|
||||
this.setDatabaseService(databaseService);
|
||||
super(databaseService);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -16,7 +16,7 @@ public class UserInfoDaoImpl extends DatabaseAccess<UserInfo> implements UserInf
|
|||
|
||||
@Autowired
|
||||
public UserInfoDaoImpl(DatabaseService<UserInfo> databaseService) {
|
||||
this.setDatabaseService(databaseService);
|
||||
super(databaseService);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -19,7 +19,7 @@ public class UserRoleDaoImpl extends DatabaseAccess<UserRole> implements UserRol
|
|||
|
||||
@Autowired
|
||||
public UserRoleDaoImpl(DatabaseService<UserRole> databaseService) {
|
||||
this.setDatabaseService(databaseService);
|
||||
super(databaseService);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -16,7 +16,7 @@ public class CredentialDaoImpl extends DatabaseAccess<Credential> implements Cre
|
|||
|
||||
@Autowired
|
||||
public CredentialDaoImpl(DatabaseService<Credential> databaseService) {
|
||||
this.setDatabaseService(databaseService);
|
||||
super(databaseService);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -16,7 +16,7 @@ public class UserTokenDaoImpl extends DatabaseAccess<UserToken> implements UserT
|
|||
|
||||
@Autowired
|
||||
public UserTokenDaoImpl(DatabaseService<UserToken> databaseService) {
|
||||
this.setDatabaseService(databaseService);
|
||||
super(databaseService);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -38,12 +38,8 @@ public class DataRepository implements Serializable, DataEntity<DataRepository,U
|
|||
private String definition;
|
||||
|
||||
|
||||
@OneToMany(fetch = FetchType.LAZY)
|
||||
@JoinTable(name = "\"DatasetDataRepository\"",
|
||||
joinColumns = {@JoinColumn(name = "\"DataRepository\"", referencedColumnName = "\"ID\"")},
|
||||
inverseJoinColumns = {@JoinColumn(name = "\"Dataset\"", referencedColumnName = "\"ID\"")}
|
||||
)
|
||||
private Set<Dataset> datasets;
|
||||
@OneToMany(mappedBy = "dataRepository", cascade = CascadeType.ALL, orphanRemoval = true)
|
||||
private Set<DatasetDataRepository> datasetDataRepositories;
|
||||
|
||||
|
||||
@Column(name = "\"Status\"", nullable = false)
|
||||
|
@ -134,12 +130,12 @@ public class DataRepository implements Serializable, DataEntity<DataRepository,U
|
|||
this.definition = definition;
|
||||
}
|
||||
|
||||
public Set<Dataset> getDatasets() {
|
||||
return datasets;
|
||||
public Set<DatasetDataRepository> getDatasetDataRepositories() {
|
||||
return datasetDataRepositories;
|
||||
}
|
||||
|
||||
public void setDatasets(Set<Dataset> datasets) {
|
||||
this.datasets = datasets;
|
||||
public void setDatasetDataRepositories(Set<DatasetDataRepository> datasetDataRepositories) {
|
||||
this.datasetDataRepositories = datasetDataRepositories;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -7,18 +7,19 @@ import org.hibernate.annotations.Type;
|
|||
|
||||
import javax.persistence.*;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Entity
|
||||
@Table(name = "\"Dataset\"")
|
||||
@NamedEntityGraphs({
|
||||
@NamedEntityGraph(
|
||||
name = "datasetListingModel",
|
||||
attributeNodes = {@NamedAttributeNode("services"), @NamedAttributeNode("dataRepositories"), @NamedAttributeNode("externalDatasets"), @NamedAttributeNode("registries"),
|
||||
attributeNodes = {@NamedAttributeNode("services"), @NamedAttributeNode("datasetDataRepositories"), @NamedAttributeNode("datasetExternalDatasets"), @NamedAttributeNode("registries"),
|
||||
@NamedAttributeNode(value = "dmp", subgraph = "dmp"), @NamedAttributeNode("profile"), @NamedAttributeNode("creator")},
|
||||
subgraphs = @NamedSubgraph(name = "dmp", attributeNodes = {@NamedAttributeNode("creator"), @NamedAttributeNode("users")})),
|
||||
@NamedEntityGraph(
|
||||
name = "datasetWizardModel",
|
||||
attributeNodes = {@NamedAttributeNode("services"), @NamedAttributeNode("dataRepositories"), @NamedAttributeNode("externalDatasets"), @NamedAttributeNode("registries"),
|
||||
attributeNodes = {@NamedAttributeNode("services"), @NamedAttributeNode("datasetDataRepositories"), @NamedAttributeNode("datasetExternalDatasets"), @NamedAttributeNode("registries"),
|
||||
@NamedAttributeNode("dmp"), @NamedAttributeNode("profile"), @NamedAttributeNode("creator")}),
|
||||
@NamedEntityGraph(
|
||||
name = "datasetRecentActivity",
|
||||
|
@ -91,14 +92,6 @@ public class Dataset implements DataEntity<Dataset, UUID> {
|
|||
@Column(name = "\"Reference\"", columnDefinition = "xml", nullable = true)
|
||||
private String reference;
|
||||
|
||||
@OneToMany(fetch = FetchType.LAZY)
|
||||
@JoinTable(name = "\"DatasetDataRepository\"",
|
||||
joinColumns = {@JoinColumn(name = "\"Dataset\"", referencedColumnName = "\"ID\"")},
|
||||
inverseJoinColumns = {@JoinColumn(name = "\"DataRepository\"", referencedColumnName = "\"ID\"")}
|
||||
)
|
||||
private Set<DataRepository> dataRepositories;
|
||||
|
||||
|
||||
@OneToMany(fetch = FetchType.LAZY)
|
||||
@JoinTable(name = "\"DatasetRegistry\"",
|
||||
joinColumns = {@JoinColumn(name = "\"Dataset\"", referencedColumnName = "\"ID\"")},
|
||||
|
@ -107,19 +100,15 @@ public class Dataset implements DataEntity<Dataset, UUID> {
|
|||
private Set<Registry> registries;
|
||||
|
||||
|
||||
@OneToMany(fetch = FetchType.LAZY)
|
||||
@JoinTable(name = "\"DatasetService\"",
|
||||
joinColumns = {@JoinColumn(name = "\"Dataset\"", referencedColumnName = "\"ID\"")},
|
||||
inverseJoinColumns = {@JoinColumn(name = "\"Service\"", referencedColumnName = "\"ID\"")}
|
||||
)
|
||||
private Set<Service> services;
|
||||
@OneToMany(mappedBy = "dataset", cascade = CascadeType.ALL, orphanRemoval = true)
|
||||
private Set<DatasetDataRepository> datasetDataRepositories;
|
||||
|
||||
@OneToMany(fetch = FetchType.LAZY)
|
||||
@JoinTable(name = "\"DatasetExternalDataset\"",
|
||||
joinColumns = {@JoinColumn(name = "\"Dataset\"", referencedColumnName = "\"ID\"")},
|
||||
inverseJoinColumns = {@JoinColumn(name = "\"ExternalDataset\"", referencedColumnName = "\"Id\"")}
|
||||
)
|
||||
private Set<ExternalDataset> externalDatasets;
|
||||
|
||||
@OneToMany(mappedBy = "dataset", cascade = CascadeType.ALL, orphanRemoval = true)
|
||||
private Set<DatasetService> services;
|
||||
|
||||
@OneToMany(mappedBy = "dataset", cascade = CascadeType.ALL, orphanRemoval = true)
|
||||
private Set<DatasetExternalDataset> datasetExternalDatasets;
|
||||
|
||||
|
||||
@Column(name = "\"Status\"", nullable = false)
|
||||
|
@ -198,17 +187,14 @@ public class Dataset implements DataEntity<Dataset, UUID> {
|
|||
this.registries = registries;
|
||||
}
|
||||
|
||||
|
||||
public Set<Service> getServices() {
|
||||
public Set<DatasetService> getServices() {
|
||||
return services;
|
||||
}
|
||||
|
||||
|
||||
public void setServices(Set<Service> services) {
|
||||
public void setServices(Set<DatasetService> services) {
|
||||
this.services = services;
|
||||
}
|
||||
|
||||
|
||||
public UUID getId() {
|
||||
return id;
|
||||
}
|
||||
|
@ -269,16 +255,14 @@ public class Dataset implements DataEntity<Dataset, UUID> {
|
|||
}
|
||||
|
||||
|
||||
public Set<DataRepository> getDataRepositories() {
|
||||
return dataRepositories;
|
||||
public Set<DatasetDataRepository> getDatasetDataRepositories() {
|
||||
return datasetDataRepositories;
|
||||
}
|
||||
|
||||
|
||||
public void setDataRepositories(Set<DataRepository> dataRepositories) {
|
||||
this.dataRepositories = dataRepositories;
|
||||
public void setDatasetDataRepositories(Set<DatasetDataRepository> datasetDataRepositories) {
|
||||
this.datasetDataRepositories = datasetDataRepositories;
|
||||
}
|
||||
|
||||
|
||||
public String getReference() {
|
||||
return reference;
|
||||
}
|
||||
|
@ -288,12 +272,12 @@ public class Dataset implements DataEntity<Dataset, UUID> {
|
|||
this.reference = reference;
|
||||
}
|
||||
|
||||
public Set<ExternalDataset> getExternalDatasets() {
|
||||
return externalDatasets;
|
||||
public Set<DatasetExternalDataset> getDatasetExternalDatasets() {
|
||||
return datasetExternalDatasets;
|
||||
}
|
||||
|
||||
public void setExternalDatasets(Set<ExternalDataset> externalDatasets) {
|
||||
this.externalDatasets = externalDatasets;
|
||||
public void setDatasetExternalDatasets(Set<DatasetExternalDataset> datasetExternalDatasets) {
|
||||
this.datasetExternalDatasets = datasetExternalDatasets;
|
||||
}
|
||||
|
||||
public boolean isPublic() {
|
||||
|
@ -307,11 +291,19 @@ public class Dataset implements DataEntity<Dataset, UUID> {
|
|||
@Override
|
||||
public void update(Dataset entity) {
|
||||
this.setRegistries(entity.getRegistries());
|
||||
this.setDataRepositories(entity.getDataRepositories());
|
||||
this.getDatasetDataRepositories().removeAll(this.getDatasetDataRepositories());
|
||||
this.getDatasetDataRepositories().addAll(entity.getDatasetDataRepositories().stream().map(item->{
|
||||
item.setDataset(this);
|
||||
return item;
|
||||
}).collect(Collectors.toList()));
|
||||
this.setDescription(entity.getDescription());
|
||||
this.setLabel(entity.getLabel());
|
||||
this.setProperties(entity.getProperties());
|
||||
this.setExternalDatasets(entity.getExternalDatasets());
|
||||
this.getDatasetExternalDatasets().removeAll(this.getDatasetExternalDatasets());
|
||||
this.getDatasetExternalDatasets().addAll(entity.getDatasetExternalDatasets().stream().map(item -> {
|
||||
item.setDataset(this);
|
||||
return item;
|
||||
}).collect(Collectors.toList()));
|
||||
this.setStatus(entity.getStatus());
|
||||
this.setProfile(entity.getProfile());
|
||||
this.setModified(new Date());
|
||||
|
|
|
@ -0,0 +1,90 @@
|
|||
package eu.eudat.data.entities;
|
||||
|
||||
import eu.eudat.queryable.queryableentity.DataEntity;
|
||||
import org.hibernate.annotations.GenericGenerator;
|
||||
import org.hibernate.annotations.Type;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Created by ikalyvas on 5/22/2018.
|
||||
*/
|
||||
|
||||
@Entity
|
||||
@Table(name = "\"DatasetDataRepository\"")
|
||||
public class DatasetDataRepository implements DataEntity<DatasetDataRepository,UUID> {
|
||||
|
||||
@Id
|
||||
@GeneratedValue
|
||||
@GenericGenerator(name = "uuid2", strategy = "uuid2")
|
||||
@Column(name = "\"ID\"", updatable = false, nullable = false, columnDefinition = "BINARY(16)")
|
||||
private UUID id;
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "\"Dataset\"", nullable = false)
|
||||
private Dataset dataset;
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "\"DataRepository\"", nullable = false)
|
||||
private DataRepository dataRepository;
|
||||
|
||||
@Column(name = "\"Role\"")
|
||||
private Integer role;
|
||||
|
||||
|
||||
@Column(name = "\"Data\"")
|
||||
private String data;
|
||||
|
||||
public UUID getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(UUID id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Dataset getDataset() {
|
||||
return dataset;
|
||||
}
|
||||
|
||||
public void setDataset(Dataset dataset) {
|
||||
this.dataset = dataset;
|
||||
}
|
||||
|
||||
public DataRepository getDataRepository() {
|
||||
return dataRepository;
|
||||
}
|
||||
|
||||
public void setDataRepository(DataRepository dataRepository) {
|
||||
this.dataRepository = dataRepository;
|
||||
}
|
||||
|
||||
public Integer getRole() {
|
||||
return role;
|
||||
}
|
||||
|
||||
public void setRole(Integer role) {
|
||||
this.role = role;
|
||||
}
|
||||
|
||||
public String getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public void setData(String data) {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(DatasetDataRepository entity) {
|
||||
this.dataset = entity.getDataset();
|
||||
this.dataRepository = entity.getDataRepository();
|
||||
this.role = entity.getRole();
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getKeys() {
|
||||
return this.id;
|
||||
}
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
package eu.eudat.data.entities;
|
||||
|
||||
import eu.eudat.queryable.queryableentity.DataEntity;
|
||||
import org.hibernate.annotations.GenericGenerator;
|
||||
import org.hibernate.annotations.Type;
|
||||
|
||||
|
@ -9,7 +10,7 @@ import java.util.UUID;
|
|||
|
||||
@Entity
|
||||
@Table(name = "\"DatasetExternalDataset\"")
|
||||
public class DatasetExternalDataset {
|
||||
public class DatasetExternalDataset implements DataEntity<DatasetExternalDataset,UUID> {
|
||||
|
||||
@Id
|
||||
@GeneratedValue
|
||||
|
@ -18,17 +19,21 @@ public class DatasetExternalDataset {
|
|||
private UUID id;
|
||||
|
||||
|
||||
@Type(type = "org.hibernate.type.PostgresUUIDType") //DEPWARN dependency to Hibernate and PostgreSQL
|
||||
@Column(name = "\"Dataset\"", nullable = false)
|
||||
private UUID dataset;
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "\"Dataset\"", nullable = false)
|
||||
private Dataset dataset;
|
||||
|
||||
@Type(type = "org.hibernate.type.PostgresUUIDType") //DEPWARN dependency to Hibernate and PostgreSQL
|
||||
@Column(name = "\"ExternalDataset\"", nullable = false)
|
||||
private UUID externalDataset;
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "\"ExternalDataset\"", nullable = false)
|
||||
private ExternalDataset externalDataset;
|
||||
|
||||
@Column(name = "\"Role\"")
|
||||
private Integer role;
|
||||
|
||||
@Column(name = "\"Data\"")
|
||||
private String data;
|
||||
|
||||
|
||||
public UUID getId() {
|
||||
return id;
|
||||
}
|
||||
|
@ -37,19 +42,19 @@ public class DatasetExternalDataset {
|
|||
this.id = id;
|
||||
}
|
||||
|
||||
public UUID getDataset() {
|
||||
public Dataset getDataset() {
|
||||
return dataset;
|
||||
}
|
||||
|
||||
public void setDataset(UUID dataset) {
|
||||
public void setDataset(Dataset dataset) {
|
||||
this.dataset = dataset;
|
||||
}
|
||||
|
||||
public UUID getExternalDataset() {
|
||||
public ExternalDataset getExternalDataset() {
|
||||
return externalDataset;
|
||||
}
|
||||
|
||||
public void setExternalDataset(UUID externalDataset) {
|
||||
public void setExternalDataset(ExternalDataset externalDataset) {
|
||||
this.externalDataset = externalDataset;
|
||||
}
|
||||
|
||||
|
@ -60,4 +65,24 @@ public class DatasetExternalDataset {
|
|||
public void setRole(Integer role) {
|
||||
this.role = role;
|
||||
}
|
||||
|
||||
public String getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public void setData(String data) {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(DatasetExternalDataset entity) {
|
||||
this.dataset = entity.getDataset();
|
||||
this.externalDataset = entity.getExternalDataset();
|
||||
this.role = entity.getRole();
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getKeys() {
|
||||
return this.id;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,6 +31,9 @@ public class DatasetRegistry {
|
|||
@Column(name = "\"Role\"")
|
||||
private Integer role;
|
||||
|
||||
@Column(name = "\"Data\"")
|
||||
private String data;
|
||||
|
||||
public UUID getId() {
|
||||
return id;
|
||||
}
|
||||
|
@ -63,5 +66,11 @@ public class DatasetRegistry {
|
|||
this.role = role;
|
||||
}
|
||||
|
||||
public String getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public void setData(String data) {
|
||||
this.data = data;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package eu.eudat.data.entities;
|
||||
|
||||
|
||||
import eu.eudat.queryable.queryableentity.DataEntity;
|
||||
import org.hibernate.annotations.GenericGenerator;
|
||||
import org.hibernate.annotations.Type;
|
||||
|
||||
|
@ -11,7 +12,7 @@ import java.util.UUID;
|
|||
|
||||
@Entity
|
||||
@Table(name = "\"DatasetService\"")
|
||||
public class DatasetService {
|
||||
public class DatasetService implements DataEntity<DatasetService, UUID> {
|
||||
|
||||
@Id
|
||||
@GeneratedValue
|
||||
|
@ -20,17 +21,21 @@ public class DatasetService {
|
|||
private UUID id;
|
||||
|
||||
|
||||
@Type(type = "org.hibernate.type.PostgresUUIDType") //DEPWARN dependency to Hibernate and PostgreSQL
|
||||
@Column(name = "\"Dataset\"", nullable = false)
|
||||
private UUID dataset;
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "\"Dataset\"", nullable = false)
|
||||
private Dataset dataset;
|
||||
|
||||
@Type(type = "org.hibernate.type.PostgresUUIDType") //DEPWARN dependency to Hibernate and PostgreSQL
|
||||
@Column(name = "\"Service\"", nullable = false)
|
||||
private UUID service;
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "\"Service\"", nullable = false)
|
||||
private Service service;
|
||||
|
||||
@Column(name = "\"Role\"")
|
||||
private Integer role;
|
||||
|
||||
@Column(name = "\"Data\"")
|
||||
private String data;
|
||||
|
||||
|
||||
public UUID getId() {
|
||||
return id;
|
||||
}
|
||||
|
@ -39,19 +44,19 @@ public class DatasetService {
|
|||
this.id = id;
|
||||
}
|
||||
|
||||
public UUID getDataset() {
|
||||
public Dataset getDataset() {
|
||||
return dataset;
|
||||
}
|
||||
|
||||
public void setDataset(UUID dataset) {
|
||||
public void setDataset(Dataset dataset) {
|
||||
this.dataset = dataset;
|
||||
}
|
||||
|
||||
public UUID getService() {
|
||||
public Service getService() {
|
||||
return service;
|
||||
}
|
||||
|
||||
public void setService(UUID service) {
|
||||
public void setService(Service service) {
|
||||
this.service = service;
|
||||
}
|
||||
|
||||
|
@ -63,5 +68,23 @@ public class DatasetService {
|
|||
this.role = role;
|
||||
}
|
||||
|
||||
public String getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public void setData(String data) {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(DatasetService entity) {
|
||||
this.dataset = entity.getDataset();
|
||||
this.service = entity.getService();
|
||||
this.role = entity.getRole();
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getKeys() {
|
||||
return this.id;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,12 +34,8 @@ public class ExternalDataset implements DataEntity<ExternalDataset,UUID> {
|
|||
@Column(name = "\"Modified\"", nullable = false)
|
||||
private Date modified;
|
||||
|
||||
@OneToMany(fetch = FetchType.LAZY)
|
||||
@JoinTable(name = "\"DatasetExternalDataset\"",
|
||||
joinColumns = {@JoinColumn(name = "\"ExternalDataset\"", referencedColumnName = "\"Id\"")},
|
||||
inverseJoinColumns = {@JoinColumn(name = "\"Dataset\"", referencedColumnName = "\"ID\"")}
|
||||
)
|
||||
private Set<Dataset> datasets;
|
||||
@OneToMany(mappedBy = "externalDataset", cascade = CascadeType.ALL, orphanRemoval = true)
|
||||
private Set<DatasetExternalDataset> datasets;
|
||||
|
||||
public UUID getId() {
|
||||
return id;
|
||||
|
@ -89,11 +85,11 @@ public class ExternalDataset implements DataEntity<ExternalDataset,UUID> {
|
|||
this.modified = modified;
|
||||
}
|
||||
|
||||
public Set<Dataset> getDatasets() {
|
||||
public Set<DatasetExternalDataset> getDatasets() {
|
||||
return datasets;
|
||||
}
|
||||
|
||||
public void setDatasets(Set<Dataset> datasets) {
|
||||
public void setDatasets(Set<DatasetExternalDataset> datasets) {
|
||||
this.datasets = datasets;
|
||||
}
|
||||
|
||||
|
|
|
@ -39,12 +39,8 @@ public class Service implements DataEntity<Service, UUID> {
|
|||
private String definition;
|
||||
|
||||
|
||||
@OneToMany(fetch = FetchType.LAZY)
|
||||
@JoinTable(name = "\"DatasetService\"",
|
||||
joinColumns = {@JoinColumn(name = "\"Service\"", referencedColumnName = "\"ID\"")},
|
||||
inverseJoinColumns = {@JoinColumn(name = "\"Dataset\"", referencedColumnName = "\"ID\"")}
|
||||
)
|
||||
private Set<Dataset> datasets;
|
||||
@OneToMany(mappedBy = "service", cascade = CascadeType.ALL, orphanRemoval = true)
|
||||
private Set<DatasetService> services;
|
||||
|
||||
|
||||
@Column(name = "\"Status\"", nullable = false)
|
||||
|
@ -136,15 +132,14 @@ public class Service implements DataEntity<Service, UUID> {
|
|||
this.definition = definition;
|
||||
}
|
||||
|
||||
public Set<Dataset> getDatasets() {
|
||||
return datasets;
|
||||
public Set<DatasetService> getServices() {
|
||||
return services;
|
||||
}
|
||||
|
||||
public void setDatasets(Set<Dataset> datasets) {
|
||||
this.datasets = datasets;
|
||||
public void setServices(Set<DatasetService> services) {
|
||||
this.services = services;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void update(Service entity) {
|
||||
|
||||
|
|
|
@ -52,7 +52,7 @@ public class UserInfo implements DataEntity<UserInfo, UUID> {
|
|||
|
||||
|
||||
@Type(type = "eu.eudat.typedefinition.XMLType")
|
||||
@Column(name = "additionalinfo", columnDefinition = "xml", nullable = true)
|
||||
@Column(name = "additionalinfo", nullable = true)
|
||||
private String additionalinfo;
|
||||
|
||||
@OneToMany(fetch = FetchType.LAZY)
|
||||
|
|
|
@ -13,7 +13,7 @@ import java.util.Collection;
|
|||
* Created by ikalyvas on 3/21/2018.
|
||||
*/
|
||||
public class PaginationService {
|
||||
public static <T extends DataEntity> QueryableList<T> applyPaging(QueryableList<T> items, TableQuery tableRequest) throws Exception {
|
||||
public static <T extends DataEntity> QueryableList<T> applyPaging(QueryableList<T> items, TableQuery tableRequest) {
|
||||
if (tableRequest.getOrderings() != null) applyOrder(items, tableRequest);
|
||||
if (tableRequest.getLength() != null) items.take(tableRequest.getLength());
|
||||
if (tableRequest.getOffset() != null) items.skip(tableRequest.getOffset());
|
||||
|
@ -22,7 +22,7 @@ public class PaginationService {
|
|||
return items;
|
||||
}
|
||||
|
||||
public static <T extends DataEntity> void applyOrder(QueryableList<T> items, TableQuery tableRequest) throws Exception {
|
||||
public static <T extends DataEntity> void applyOrder(QueryableList<T> items, TableQuery tableRequest) {
|
||||
ColumnOrderings columnOrderings = tableRequest.getOrderings();
|
||||
for (Ordering ordering : columnOrderings.getFieldOrderings()) {
|
||||
if (ordering.getOrderByType() == Ordering.OrderByType.ASC)
|
||||
|
|
|
@ -11,6 +11,11 @@ public abstract class Query<C extends Criteria<T>, T extends DataEntity> impleme
|
|||
public static class QueryBuilder<C extends Criteria<T>, T extends DataEntity, Q extends Query<C, T>> {
|
||||
private C criteria;
|
||||
private QueryableList<T> query;
|
||||
private Class<Q> tClass;
|
||||
|
||||
public QueryBuilder(Class<Q> tClass) {
|
||||
this.tClass = tClass;
|
||||
}
|
||||
|
||||
public QueryBuilder<C, T, Q> criteria(C criteria) {
|
||||
this.criteria = criteria;
|
||||
|
@ -22,11 +27,18 @@ public abstract class Query<C extends Criteria<T>, T extends DataEntity> impleme
|
|||
return this;
|
||||
}
|
||||
|
||||
public Q build(Class<Q> qClass) throws IllegalAccessException, InstantiationException {
|
||||
Q q = qClass.newInstance();
|
||||
public Q build() {
|
||||
try {
|
||||
Q q = tClass.newInstance();
|
||||
q.setCriteria(criteria);
|
||||
q.setQuery(query);
|
||||
return q;
|
||||
} catch (InstantiationException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -47,12 +59,12 @@ public abstract class Query<C extends Criteria<T>, T extends DataEntity> impleme
|
|||
}
|
||||
|
||||
@Override
|
||||
public QueryableList<T> collect() throws Exception {
|
||||
public QueryableList<T> collect() {
|
||||
return this.applyCriteria();
|
||||
}
|
||||
|
||||
@Override
|
||||
public QueryableList<T> collect(QueryableList<T> repo) throws Exception {
|
||||
public QueryableList<T> collect(QueryableList<T> repo) {
|
||||
this.query = repo;
|
||||
return this.applyCriteria();
|
||||
}
|
||||
|
|
|
@ -8,5 +8,5 @@ import eu.eudat.queryable.queryableentity.DataEntity;
|
|||
* Created by ikalyvas on 3/21/2018.
|
||||
*/
|
||||
public interface TableCriteriaQuery<C extends Criteria<T>, T extends DataEntity> extends CriteriaQuery<C, T> {
|
||||
QueryableList<T> applyPaging(QueryableList<T> items) throws Exception;
|
||||
QueryableList<T> applyPaging(QueryableList<T> items) ;
|
||||
}
|
||||
|
|
|
@ -47,12 +47,12 @@ public abstract class TableQuery<C extends Criteria<T>, T extends DataEntity<T,
|
|||
}
|
||||
|
||||
@Override
|
||||
public QueryableList<T> collect() throws Exception {
|
||||
public QueryableList<T> collect() {
|
||||
return this.applyPaging(super.collect());
|
||||
}
|
||||
|
||||
@Override
|
||||
public QueryableList<T> collect(QueryableList<T> repo) throws Exception {
|
||||
public QueryableList<T> collect(QueryableList<T> repo) {
|
||||
return this.applyPaging(super.collect(repo));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ public class ColumnOrderings {
|
|||
this.fields = fields;
|
||||
}
|
||||
|
||||
public Ordering[] getFieldOrderings() throws Exception {
|
||||
public Ordering[] getFieldOrderings() {
|
||||
List<Ordering> orderings = new LinkedList<>();
|
||||
for (String field : fields) {
|
||||
orderings.add(this.orderingFromString(field));
|
||||
|
@ -24,7 +24,7 @@ public class ColumnOrderings {
|
|||
return orderings.toArray(new Ordering[orderings.size()]);
|
||||
}
|
||||
|
||||
private Ordering orderingFromString(String field) throws Exception {
|
||||
private Ordering orderingFromString(String field) {
|
||||
Ordering ordering = new Ordering(field);
|
||||
if (ordering.getFieldName().contains("+"))
|
||||
ordering.fieldName(ordering.getFieldName().replace("+", "")).orderByType(Ordering.OrderByType.ASC);
|
||||
|
|
|
@ -32,7 +32,7 @@ public class DataManagementPlanTableRequest extends TableQuery<DataManagementPla
|
|||
}
|
||||
|
||||
@Override
|
||||
public QueryableList<DMP> applyPaging(QueryableList<DMP> items) throws Exception {
|
||||
public QueryableList<DMP> applyPaging(QueryableList<DMP> items) {
|
||||
return PaginationService.applyPaging(items, this);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ public class DataManagementPlanProfileTableRequest extends TableQuery<DataManage
|
|||
}
|
||||
|
||||
@Override
|
||||
public QueryableList<DMPProfile> applyPaging(QueryableList<DMPProfile> items) throws Exception {
|
||||
public QueryableList<DMPProfile> applyPaging(QueryableList<DMPProfile> items) {
|
||||
return PaginationService.applyPaging(items, this);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,11 +13,11 @@ public abstract class DataRepository_ {
|
|||
|
||||
public static volatile SingularAttribute<DataRepository, String> reference;
|
||||
public static volatile SingularAttribute<DataRepository, Date> created;
|
||||
public static volatile SetAttribute<DataRepository, DatasetDataRepository> datasetDataRepositories;
|
||||
public static volatile SingularAttribute<DataRepository, Date> modified;
|
||||
public static volatile SingularAttribute<DataRepository, String> definition;
|
||||
public static volatile SingularAttribute<DataRepository, UUID> id;
|
||||
public static volatile SingularAttribute<DataRepository, String> label;
|
||||
public static volatile SetAttribute<DataRepository, Dataset> datasets;
|
||||
public static volatile SingularAttribute<DataRepository, String> abbreviation;
|
||||
public static volatile SingularAttribute<DataRepository, String> uri;
|
||||
public static volatile SingularAttribute<DataRepository, Short> status;
|
||||
|
|
|
@ -9,10 +9,11 @@ import javax.persistence.metamodel.StaticMetamodel;
|
|||
@StaticMetamodel(DatasetExternalDataset.class)
|
||||
public abstract class DatasetExternalDataset_ {
|
||||
|
||||
public static volatile SingularAttribute<DatasetExternalDataset, UUID> externalDataset;
|
||||
public static volatile SingularAttribute<DatasetExternalDataset, ExternalDataset> externalDataset;
|
||||
public static volatile SingularAttribute<DatasetExternalDataset, Integer> role;
|
||||
public static volatile SingularAttribute<DatasetExternalDataset, String> data;
|
||||
public static volatile SingularAttribute<DatasetExternalDataset, UUID> id;
|
||||
public static volatile SingularAttribute<DatasetExternalDataset, UUID> dataset;
|
||||
public static volatile SingularAttribute<DatasetExternalDataset, Dataset> dataset;
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@ public abstract class DatasetRegistry_ {
|
|||
|
||||
public static volatile SingularAttribute<DatasetRegistry, UUID> registry;
|
||||
public static volatile SingularAttribute<DatasetRegistry, Integer> role;
|
||||
public static volatile SingularAttribute<DatasetRegistry, String> data;
|
||||
public static volatile SingularAttribute<DatasetRegistry, UUID> id;
|
||||
public static volatile SingularAttribute<DatasetRegistry, UUID> dataset;
|
||||
|
||||
|
|
|
@ -10,9 +10,10 @@ import javax.persistence.metamodel.StaticMetamodel;
|
|||
public abstract class DatasetService_ {
|
||||
|
||||
public static volatile SingularAttribute<DatasetService, Integer> role;
|
||||
public static volatile SingularAttribute<DatasetService, UUID> service;
|
||||
public static volatile SingularAttribute<DatasetService, String> data;
|
||||
public static volatile SingularAttribute<DatasetService, Service> service;
|
||||
public static volatile SingularAttribute<DatasetService, UUID> id;
|
||||
public static volatile SingularAttribute<DatasetService, UUID> dataset;
|
||||
public static volatile SingularAttribute<DatasetService, Dataset> dataset;
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -15,14 +15,14 @@ public abstract class Dataset_ {
|
|||
public static volatile SingularAttribute<Dataset, DMP> dmp;
|
||||
public static volatile SingularAttribute<Dataset, Date> created;
|
||||
public static volatile SingularAttribute<Dataset, DatasetProfile> profile;
|
||||
public static volatile SetAttribute<Dataset, DatasetDataRepository> datasetDataRepositories;
|
||||
public static volatile SetAttribute<Dataset, DatasetExternalDataset> datasetExternalDatasets;
|
||||
public static volatile SingularAttribute<Dataset, String> description;
|
||||
public static volatile SingularAttribute<Dataset, String> label;
|
||||
public static volatile SetAttribute<Dataset, Registry> registries;
|
||||
public static volatile SetAttribute<Dataset, Service> services;
|
||||
public static volatile SetAttribute<Dataset, DatasetService> services;
|
||||
public static volatile SingularAttribute<Dataset, String> uri;
|
||||
public static volatile SingularAttribute<Dataset, String> reference;
|
||||
public static volatile SetAttribute<Dataset, ExternalDataset> externalDatasets;
|
||||
public static volatile SetAttribute<Dataset, DataRepository> dataRepositories;
|
||||
public static volatile SingularAttribute<Dataset, Boolean> isPublic;
|
||||
public static volatile SingularAttribute<Dataset, Date> modified;
|
||||
public static volatile SingularAttribute<Dataset, UUID> id;
|
||||
|
|
|
@ -16,7 +16,7 @@ public abstract class ExternalDataset_ {
|
|||
public static volatile SingularAttribute<ExternalDataset, Date> modified;
|
||||
public static volatile SingularAttribute<ExternalDataset, UUID> id;
|
||||
public static volatile SingularAttribute<ExternalDataset, String> label;
|
||||
public static volatile SetAttribute<ExternalDataset, Dataset> datasets;
|
||||
public static volatile SetAttribute<ExternalDataset, DatasetExternalDataset> datasets;
|
||||
public static volatile SingularAttribute<ExternalDataset, String> abbreviation;
|
||||
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ public abstract class Service_ {
|
|||
public static volatile SingularAttribute<Service, String> definition;
|
||||
public static volatile SingularAttribute<Service, UUID> id;
|
||||
public static volatile SingularAttribute<Service, String> label;
|
||||
public static volatile SetAttribute<Service, Dataset> datasets;
|
||||
public static volatile SetAttribute<Service, DatasetService> services;
|
||||
public static volatile SingularAttribute<Service, String> abbreviation;
|
||||
public static volatile SingularAttribute<Service, String> uri;
|
||||
public static volatile SingularAttribute<Service, Short> status;
|
||||
|
|
|
@ -1,12 +1,11 @@
|
|||
package eu.eudat.queryable;
|
||||
|
||||
import eu.eudat.queryable.predicates.*;
|
||||
import eu.eudat.queryable.jpa.predicates.*;
|
||||
import eu.eudat.queryable.queryableentity.DataEntity;
|
||||
import eu.eudat.queryable.types.SelectionField;
|
||||
|
||||
import javax.persistence.criteria.Subquery;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
public interface QueryableList<T extends DataEntity> {
|
||||
|
@ -38,8 +37,6 @@ public interface QueryableList<T extends DataEntity> {
|
|||
|
||||
QueryableList<T> orderBy(OrderByPredicate<T> predicate);
|
||||
|
||||
QueryableList<T> setHints(Set<String> hints);
|
||||
|
||||
QueryableList<T> withHint(String hint);
|
||||
|
||||
Long count();
|
||||
|
|
|
@ -1,13 +1,12 @@
|
|||
package eu.eudat.queryable.hibernatequeryablelist;
|
||||
package eu.eudat.queryable.jpa.hibernatequeryablelist;
|
||||
|
||||
import eu.eudat.queryable.QueryableList;
|
||||
import eu.eudat.queryable.exceptions.NotSingleResultException;
|
||||
import eu.eudat.queryable.predicates.*;
|
||||
import eu.eudat.queryable.jpa.predicates.*;
|
||||
import eu.eudat.queryable.queryableentity.DataEntity;
|
||||
import eu.eudat.queryable.types.FieldSelectionType;
|
||||
import eu.eudat.queryable.types.SelectionField;
|
||||
|
||||
import javax.persistence.EntityGraph;
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.persistence.TypedQuery;
|
||||
import javax.persistence.criteria.*;
|
||||
|
@ -51,11 +50,6 @@ public class QueryableHibernateList<T extends DataEntity> implements QueryableLi
|
|||
return this;
|
||||
}
|
||||
|
||||
public QueryableList<T> setHints(Set<String> hints) {
|
||||
this.hints = hints;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public QueryableList<T> withFields(List<String> fields) {
|
||||
this.fields = fields;
|
|
@ -1,4 +1,4 @@
|
|||
package eu.eudat.queryable.predicates;
|
||||
package eu.eudat.queryable.jpa.predicates;
|
||||
|
||||
import javax.persistence.criteria.CriteriaBuilder;
|
||||
import javax.persistence.criteria.Predicate;
|
|
@ -1,4 +1,4 @@
|
|||
package eu.eudat.queryable.predicates;
|
||||
package eu.eudat.queryable.jpa.predicates;
|
||||
|
||||
import javax.persistence.criteria.CriteriaBuilder;
|
||||
import javax.persistence.criteria.Order;
|
|
@ -1,4 +1,4 @@
|
|||
package eu.eudat.queryable.predicates;
|
||||
package eu.eudat.queryable.jpa.predicates;
|
||||
|
||||
/**
|
||||
* Created by ikalyvas on 2/7/2018.
|
|
@ -1,4 +1,4 @@
|
|||
package eu.eudat.queryable.predicates;
|
||||
package eu.eudat.queryable.jpa.predicates;
|
||||
|
||||
public interface SelectPredicate<T, R> {
|
||||
R applySelection(T item);
|
|
@ -1,4 +1,4 @@
|
|||
package eu.eudat.queryable.predicates;
|
||||
package eu.eudat.queryable.jpa.predicates;
|
||||
|
||||
import javax.persistence.criteria.CriteriaBuilder;
|
||||
import javax.persistence.criteria.Predicate;
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -17,6 +17,7 @@ public class PrincipalBuilder extends Builder<Principal> {
|
|||
private UUID token;
|
||||
private String name;
|
||||
private Date expiresAt;
|
||||
private String avatarUrl;
|
||||
private Set<Authorities> authorities;
|
||||
|
||||
public PrincipalBuilder id(UUID id) {
|
||||
|
@ -44,6 +45,11 @@ public class PrincipalBuilder extends Builder<Principal> {
|
|||
return this;
|
||||
}
|
||||
|
||||
public PrincipalBuilder avatarUrl(String avatarUrl) {
|
||||
this.avatarUrl = avatarUrl;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Principal build() {
|
||||
Principal principal = new Principal();
|
||||
|
@ -52,6 +58,7 @@ public class PrincipalBuilder extends Builder<Principal> {
|
|||
principal.setExpiresAt(expiresAt);
|
||||
principal.setToken(token);
|
||||
principal.setId(id);
|
||||
principal.setAvatarUrl(avatarUrl);
|
||||
return principal;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,7 +13,6 @@ public class RecentActivityDataBuilder extends Builder<RecentActivityData> {
|
|||
private String label;
|
||||
private String id;
|
||||
private Date timestamp;
|
||||
private Integer type;
|
||||
|
||||
public String getLabel() {
|
||||
return label;
|
||||
|
@ -42,22 +41,12 @@ public class RecentActivityDataBuilder extends Builder<RecentActivityData> {
|
|||
return this;
|
||||
}
|
||||
|
||||
public Integer getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public RecentActivityDataBuilder type(Integer type) {
|
||||
this.type = type;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RecentActivityData build() {
|
||||
RecentActivityData recentActivityData = new RecentActivityData();
|
||||
recentActivityData.setLabel(label);
|
||||
recentActivityData.setTimestamp(timestamp);
|
||||
recentActivityData.setId(id);
|
||||
recentActivityData.setType(type);
|
||||
return recentActivityData;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,8 +2,10 @@ package eu.eudat.controllers;
|
|||
|
||||
import eu.eudat.dynamicproject.DynamicProjectConfiguration;
|
||||
import eu.eudat.dynamicproject.entities.Language;
|
||||
import eu.eudat.managers.CommonsManager;
|
||||
import eu.eudat.models.externalurl.ExternalSourcesConfiguration;
|
||||
import eu.eudat.models.helpers.responses.ResponseItem;
|
||||
import eu.eudat.models.security.Principal;
|
||||
import eu.eudat.proxy.config.configloaders.ConfigLoader;
|
||||
import eu.eudat.types.ApiMessageCode;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
|
@ -21,10 +23,12 @@ import java.util.List;
|
|||
public class CommonController {
|
||||
|
||||
private DynamicProjectConfiguration dynamicProjectConfiguration;
|
||||
private ConfigLoader configLoader;
|
||||
|
||||
@Autowired
|
||||
public CommonController(DynamicProjectConfiguration dynamicProjectConfiguration) {
|
||||
public CommonController(DynamicProjectConfiguration dynamicProjectConfiguration, ConfigLoader configLoader) {
|
||||
this.dynamicProjectConfiguration = dynamicProjectConfiguration;
|
||||
this.configLoader = configLoader;
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET, value = {"/language"}, produces = "application/json")
|
||||
|
@ -38,4 +42,16 @@ public class CommonController {
|
|||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<List<Language>>().status(ApiMessageCode.DEFAULT_ERROR_MESSAGE).message(ex.getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET, value = {"/externalSourcesConfiguration"}, produces = "application/json")
|
||||
public @ResponseBody
|
||||
ResponseEntity<ResponseItem<ExternalSourcesConfiguration>> getExternalSourcesConfiguration() {
|
||||
try {
|
||||
ExternalSourcesConfiguration configuration = CommonsManager.getExternalSourcesConfiguration(configLoader);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<ExternalSourcesConfiguration>().status(ApiMessageCode.NO_MESSAGE).payload(configuration));
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<ExternalSourcesConfiguration>().status(ApiMessageCode.DEFAULT_ERROR_MESSAGE).message(ex.getMessage()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@ import eu.eudat.data.query.items.item.dmp.DataManagementPlanCriteriaRequest;
|
|||
import eu.eudat.data.query.items.table.dmp.DataManagementPlanTableRequest;
|
||||
import eu.eudat.dynamicproject.DynamicProjectConfiguration;
|
||||
import eu.eudat.exceptions.datamanagementplan.DMPWithDatasetsException;
|
||||
import eu.eudat.exceptions.security.UnauthorisedException;
|
||||
import eu.eudat.managers.DataManagementPlanManager;
|
||||
import eu.eudat.models.dmp.DataManagementPlan;
|
||||
import eu.eudat.models.helpermodels.Tuple;
|
||||
|
@ -62,7 +63,10 @@ public class DMPs extends BaseController {
|
|||
eu.eudat.models.dmp.DataManagementPlan dataManagementPlan = new DataManagementPlanManager().getSingle(this.getApiContext().getOperationsContext().getDatabaseRepository().getDmpDao(), id, principal, this.dynamicProjectConfiguration);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataManagementPlan>().status(ApiMessageCode.NO_MESSAGE).payload(dataManagementPlan));
|
||||
|
||||
} catch (Exception ex) {
|
||||
}catch (UnauthorisedException ex) {
|
||||
throw ex;
|
||||
}
|
||||
catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<DataManagementPlan>().status(ApiMessageCode.DEFAULT_ERROR_MESSAGE).message(ex.getMessage()));
|
||||
}
|
||||
|
|
|
@ -26,9 +26,11 @@ public class DataRepositories extends BaseController {
|
|||
|
||||
@RequestMapping(method = RequestMethod.GET, value = {"/external/datarepos"}, produces = "application/json")
|
||||
public @ResponseBody
|
||||
ResponseEntity<ResponseItem<List<Map<String, String>>>> listExternalDataRepositories(@RequestParam(value = "query", required = false) String query) {
|
||||
ResponseEntity<ResponseItem<List<Map<String, String>>>> listExternalDataRepositories(
|
||||
@RequestParam(value = "query", required = false) String query,@RequestParam(value = "type", required = false) String type
|
||||
) {
|
||||
try {
|
||||
List<Map<String, String>> remoteRepos = this.getApiContext().getOperationsContext().getRemoteFetcher().getRepositories(query);
|
||||
List<Map<String, String>> remoteRepos = this.getApiContext().getOperationsContext().getRemoteFetcher().getRepositories(query,type);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<Map<String, String>>>().status(ApiMessageCode.NO_MESSAGE).payload(remoteRepos));
|
||||
} catch (NoURLFound ex) {
|
||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<List<Map<String, String>>>().status(ApiMessageCode.ERROR_MESSAGE).message(ex.getMessage()).payload(null));
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
package eu.eudat.controllers;
|
||||
|
||||
import eu.eudat.data.query.items.table.externaldataset.ExternalDatasetTableRequest;
|
||||
import eu.eudat.managers.ExternalDatasetManager;
|
||||
import eu.eudat.models.externaldataset.ExternalDatasetListingModel;
|
||||
import eu.eudat.data.query.items.table.externaldataset.ExternalDatasetTableRequest;
|
||||
import eu.eudat.models.helpers.common.DataTableData;
|
||||
import eu.eudat.models.helpers.responses.ResponseItem;
|
||||
import eu.eudat.models.security.Principal;
|
||||
|
@ -42,7 +42,9 @@ public class ExternalDatasets extends BaseController {
|
|||
|
||||
@RequestMapping(method = RequestMethod.GET, value = {"/external/datasets"}, produces = "application/json")
|
||||
public @ResponseBody
|
||||
ResponseEntity<ResponseItem<List<ExternalDatasetListingModel>>> getWithExternal(@RequestParam(value = "query", required = false) String query, Principal principal) {
|
||||
ResponseEntity<ResponseItem<List<ExternalDatasetListingModel>>> getWithExternal(
|
||||
@RequestParam(value = "query", required = false) String query, @RequestParam(value = "type", required = false) String type, Principal principal
|
||||
) {
|
||||
try {
|
||||
List<ExternalDatasetListingModel> dataTable = new ExternalDatasetManager().getWithExternal(this.getApiContext(), query, this.getApiContext().getOperationsContext().getRemoteFetcher());
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<ExternalDatasetListingModel>>().payload(dataTable).status(ApiMessageCode.NO_MESSAGE));
|
||||
|
|
|
@ -27,9 +27,11 @@ public class Organisations extends BaseController {
|
|||
|
||||
@RequestMapping(method = RequestMethod.GET, value = {"/external/organisations"}, produces = "application/json")
|
||||
public @ResponseBody
|
||||
ResponseEntity<ResponseItem<OrganisationsExternalSourcesModel>> listExternalOrganisations(@RequestParam(value = "query", required = false) String query) {
|
||||
ResponseEntity<ResponseItem<OrganisationsExternalSourcesModel>> listExternalOrganisations(
|
||||
@RequestParam(value = "query", required = false) String query,@RequestParam(value = "type", required = false) String type
|
||||
) {
|
||||
try {
|
||||
List<Map<String, String>> remoteRepos = this.getApiContext().getOperationsContext().getRemoteFetcher().getOrganisations(query);
|
||||
List<Map<String, String>> remoteRepos = this.getApiContext().getOperationsContext().getRemoteFetcher().getOrganisations(query,type);
|
||||
OrganisationsExternalSourcesModel projectsExternalSourcesModel = new OrganisationsExternalSourcesModel().fromExternalItem(remoteRepos);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<OrganisationsExternalSourcesModel>().payload(projectsExternalSourcesModel).status(ApiMessageCode.SUCCESS_MESSAGE));
|
||||
} catch (NoURLFound ex) {
|
||||
|
|
|
@ -27,9 +27,10 @@ public class Registries extends BaseController {
|
|||
|
||||
@RequestMapping(method = RequestMethod.GET, value = {"/external/registries"}, produces = "application/json")
|
||||
public @ResponseBody
|
||||
ResponseEntity<ResponseItem<RegistriesExternalSourcesModel>> listExternalRegistries(@RequestParam(value = "query", required = false) String query) {
|
||||
ResponseEntity<ResponseItem<RegistriesExternalSourcesModel>> listExternalRegistries(@RequestParam(value = "query", required = false) String query
|
||||
,@RequestParam(value = "type", required = false) String type) {
|
||||
try {
|
||||
List<Map<String, String>> remoteRepos = this.getApiContext().getOperationsContext().getRemoteFetcher().getRegistries(query);
|
||||
List<Map<String, String>> remoteRepos = this.getApiContext().getOperationsContext().getRemoteFetcher().getRegistries(query,type);
|
||||
RegistriesExternalSourcesModel registriesExternalSourcesModel = new RegistriesExternalSourcesModel().fromExternalItem(remoteRepos);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<RegistriesExternalSourcesModel>().payload(registriesExternalSourcesModel).status(ApiMessageCode.NO_MESSAGE));
|
||||
} catch (NoURLFound ex) {
|
||||
|
|
|
@ -34,9 +34,10 @@ public class Researchers extends BaseController {
|
|||
|
||||
@RequestMapping(method = RequestMethod.GET, value = {"/external/researchers"}, produces = "application/json")
|
||||
public @ResponseBody
|
||||
ResponseEntity<ResponseItem<ResearchersExternalSourcesModel>> listExternalResearchers(@RequestParam(value = "query", required = false) String query) {
|
||||
ResponseEntity<ResponseItem<ResearchersExternalSourcesModel>> listExternalResearchers(
|
||||
@RequestParam(value = "query", required = false) String query,@RequestParam(value = "type", required = false) String type) {
|
||||
try {
|
||||
List<Map<String, String>> remoteRepos = this.getApiContext().getOperationsContext().getRemoteFetcher().getResearchers(query);
|
||||
List<Map<String, String>> remoteRepos = this.getApiContext().getOperationsContext().getRemoteFetcher().getResearchers(query,type);
|
||||
ResearchersExternalSourcesModel researchersExternalSourcesModel = new ResearchersExternalSourcesModel().fromExternalItem(remoteRepos);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<ResearchersExternalSourcesModel>().payload(researchersExternalSourcesModel).status(ApiMessageCode.NO_MESSAGE));
|
||||
} catch (NoURLFound ex) {
|
||||
|
|
|
@ -27,9 +27,11 @@ public class Services extends BaseController {
|
|||
|
||||
@RequestMapping(method = RequestMethod.GET, value = {"/external/services"}, produces = "application/json")
|
||||
public @ResponseBody
|
||||
ResponseEntity<ResponseItem<ServiceExternalSourcesModel>> listExternalServices(@RequestParam(value = "query", required = false) String query) {
|
||||
ResponseEntity<ResponseItem<ServiceExternalSourcesModel>> listExternalServices(
|
||||
@RequestParam(value = "query", required = false) String query,@RequestParam(value = "type", required = false) String type
|
||||
) {
|
||||
try {
|
||||
List<Map<String, String>> remoteRepos = this.getApiContext().getOperationsContext().getRemoteFetcher().getServices(query);
|
||||
List<Map<String, String>> remoteRepos = this.getApiContext().getOperationsContext().getRemoteFetcher().getServices(query,type);
|
||||
ServiceExternalSourcesModel serviceExternalSourcesModel = new ServiceExternalSourcesModel().fromExternalItem(remoteRepos);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<ServiceExternalSourcesModel>().payload(serviceExternalSourcesModel).status(ApiMessageCode.NO_MESSAGE));
|
||||
} catch (NoURLFound ex) {
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
package eu.eudat.managers;
|
||||
|
||||
import eu.eudat.models.externalurl.ExternalSourcesConfiguration;
|
||||
import eu.eudat.proxy.config.configloaders.ConfigLoader;
|
||||
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* Created by ikalyvas on 5/17/2018.
|
||||
*/
|
||||
public class CommonsManager {
|
||||
|
||||
public static ExternalSourcesConfiguration getExternalSourcesConfiguration(ConfigLoader configLoader){
|
||||
ExternalSourcesConfiguration externalSourcesConfiguration = new ExternalSourcesConfiguration();
|
||||
externalSourcesConfiguration.setDataRepositories(configLoader.getExternalUrls().getRepositories().getUrls().stream()
|
||||
.map(item-> new ExternalSourcesConfiguration.ExternalSourcesUrlModel(item.getKey(),item.getLabel())).collect(Collectors.toList()));
|
||||
externalSourcesConfiguration.setExternalDatasets(configLoader.getExternalUrls().getDatasets().getUrls().stream()
|
||||
.map(item-> new ExternalSourcesConfiguration.ExternalSourcesUrlModel(item.getKey(),item.getLabel())).collect(Collectors.toList()));
|
||||
externalSourcesConfiguration.setRegistries(configLoader.getExternalUrls().getRegistries().getUrls().stream()
|
||||
.map(item-> new ExternalSourcesConfiguration.ExternalSourcesUrlModel(item.getKey(),item.getLabel())).collect(Collectors.toList()));
|
||||
externalSourcesConfiguration.setServices(configLoader.getExternalUrls().getServices().getUrls().stream()
|
||||
.map(item-> new ExternalSourcesConfiguration.ExternalSourcesUrlModel(item.getKey(),item.getLabel())).collect(Collectors.toList()));
|
||||
return externalSourcesConfiguration;
|
||||
}
|
||||
}
|
|
@ -4,9 +4,13 @@ import eu.eudat.builders.model.models.RecentActivityDataBuilder;
|
|||
import eu.eudat.data.dao.entities.DMPDao;
|
||||
import eu.eudat.data.dao.entities.DatasetDao;
|
||||
import eu.eudat.data.dao.entities.ProjectDao;
|
||||
import eu.eudat.data.entities.DMP;
|
||||
import eu.eudat.data.entities.Dataset;
|
||||
import eu.eudat.data.entities.UserInfo;
|
||||
import eu.eudat.data.dao.criteria.DataManagementPlanCriteria;
|
||||
import eu.eudat.data.dao.criteria.DatasetCriteria;
|
||||
import eu.eudat.data.query.definition.Query;
|
||||
import eu.eudat.data.query.items.table.dataset.DatasetTableRequest;
|
||||
import eu.eudat.models.dashboard.recent.RecentActivity;
|
||||
import eu.eudat.models.dashboard.recent.RecentActivityData;
|
||||
import eu.eudat.models.dashboard.statistics.DashBoardStatistics;
|
||||
|
@ -62,7 +66,6 @@ public class DashBoardManager {
|
|||
RecentActivity activity = new RecentActivity();
|
||||
UserInfo user = new UserInfo();
|
||||
user.setId(principal.getId());
|
||||
List<RecentActivityData> activities = new LinkedList<>();
|
||||
|
||||
RecentActivityDataBuilder recentActivityDataBuilder = apiContext.getOperationsContext().getBuilderFactory().getBuilder(RecentActivityDataBuilder.class);
|
||||
|
||||
|
@ -70,27 +73,24 @@ public class DashBoardManager {
|
|||
.withHint("dmpRecentActivity")
|
||||
.orderBy((builder, root) -> builder.desc(root.get("modified")))
|
||||
.take(numberofactivities)
|
||||
.selectAsync(item -> recentActivityDataBuilder.label(item.getLabel()).timestamp(item.getModified()).id(item.getId().toString()).type(RecentActivityData.RecentActivityType.DMP.getValue()).build())
|
||||
.whenComplete((dmpActivities, throwable) -> activities.addAll(dmpActivities));
|
||||
.selectAsync(item -> recentActivityDataBuilder.label(item.getLabel()).timestamp(item.getModified()).id(item.getId().toString()).build())
|
||||
.whenComplete((dmpActivities, throwable) -> activity.setRecentDmpActivities(dmpActivities));
|
||||
|
||||
CompletableFuture<List<RecentActivityData>> datasets = datasetRepository.getAuthenticated(datasetRepository.asQueryable(), user)
|
||||
.withHint("datasetRecentActivity")
|
||||
.orderBy((builder, root) -> builder.desc(root.get("modified")))
|
||||
.take(numberofactivities)
|
||||
.selectAsync(item -> recentActivityDataBuilder.label(item.getLabel()).timestamp(item.getModified()).id(item.getId().toString()).type(RecentActivityData.RecentActivityType.DATASET.getValue()).build())
|
||||
.whenComplete((datasetActivities, throwable) -> activities.addAll(datasetActivities));
|
||||
.selectAsync(item -> recentActivityDataBuilder.label(item.getLabel()).timestamp(item.getModified()).id(item.getId().toString()).build())
|
||||
.whenComplete((datasetActivities, throwable) -> activity.setRecentDatasetActivities(datasetActivities));
|
||||
|
||||
CompletableFuture<List<RecentActivityData>> projects = projectRepository.getAuthenticated(projectRepository.asQueryable(), user)
|
||||
.withHint("projectRecentActivity")
|
||||
.orderBy((builder, root) -> builder.desc(root.get("modified")))
|
||||
.take(numberofactivities)
|
||||
.selectAsync(item -> recentActivityDataBuilder.label(item.getLabel()).timestamp(item.getModified()).id(item.getId().toString()).type(RecentActivityData.RecentActivityType.PROJECT.getValue()).build())
|
||||
.whenComplete((projectActivities, throwable) -> activities.addAll(projectActivities));
|
||||
.selectAsync(item -> recentActivityDataBuilder.label(item.getLabel()).timestamp(item.getModified()).id(item.getId().toString()).build())
|
||||
.whenComplete((projectActivities, throwable) -> activity.setRecentProjectActivities(projectActivities));
|
||||
|
||||
CompletableFuture.allOf(projects, dmps, datasets).join();
|
||||
Collections.sort(activities, Comparator.comparing(RecentActivityData::getTimestamp).reversed());
|
||||
activity.setRecentActivities(activities.subList(0, numberofactivities));
|
||||
|
||||
return activity;
|
||||
}
|
||||
|
||||
|
|
|
@ -235,19 +235,26 @@ public class DataManagementPlanManager {
|
|||
newDataset.update(entityDataset);
|
||||
newDataset.setDmp(newDmp);
|
||||
newDataset.setStatus(Dataset.Status.SAVED.getValue());
|
||||
if (newDataset.getDataRepositories() != null) {
|
||||
newDataset.setDataRepositories(newDataset.getDataRepositories().stream().map(item -> {
|
||||
if (newDataset.getDatasetDataRepositories() != null) {
|
||||
newDataset.setDatasetDataRepositories(newDataset.getDatasetDataRepositories().stream().map(item -> {
|
||||
DataRepository dataRepository = new DataRepository();
|
||||
dataRepository.setId(item.getId());
|
||||
return dataRepository;
|
||||
|
||||
DatasetDataRepository datasetDataRepository = new DatasetDataRepository();
|
||||
datasetDataRepository.setDataRepository(dataRepository);
|
||||
datasetDataRepository.setDataset(newDataset);
|
||||
return datasetDataRepository;
|
||||
}).collect(Collectors.toSet()));
|
||||
}
|
||||
|
||||
if (newDataset.getExternalDatasets() != null) {
|
||||
newDataset.setExternalDatasets(newDataset.getExternalDatasets().stream().map(item -> {
|
||||
if (newDataset.getDatasetExternalDatasets() != null) {
|
||||
newDataset.setDatasetExternalDatasets(newDataset.getDatasetExternalDatasets().stream().map(item -> {
|
||||
ExternalDataset externalDataset = new ExternalDataset();
|
||||
externalDataset.setId(item.getId());
|
||||
return externalDataset;
|
||||
DatasetExternalDataset datasetExternalDataset = new DatasetExternalDataset();
|
||||
datasetExternalDataset.setExternalDataset(externalDataset);
|
||||
datasetExternalDataset.setDataset(newDataset);
|
||||
return datasetExternalDataset;
|
||||
}).collect(Collectors.toSet()));
|
||||
}
|
||||
|
||||
|
@ -263,7 +270,10 @@ public class DataManagementPlanManager {
|
|||
newDataset.setServices(newDataset.getServices().stream().map(item -> {
|
||||
Service service = new Service();
|
||||
service.setId(item.getId());
|
||||
return service;
|
||||
DatasetService datasetService = new DatasetService();
|
||||
datasetService.setService(service);
|
||||
datasetService.setDataset(newDataset);
|
||||
return datasetService;
|
||||
}).collect(Collectors.toSet()));
|
||||
}
|
||||
newDataset.setCreated(new Date());
|
||||
|
|
|
@ -2,10 +2,10 @@ package eu.eudat.managers;
|
|||
|
||||
import eu.eudat.builders.entity.UserInfoBuilder;
|
||||
import eu.eudat.data.dao.entities.*;
|
||||
import eu.eudat.data.entities.*;
|
||||
import eu.eudat.documents.helpers.FileEnvelope;
|
||||
import eu.eudat.documents.word.WordBuilder;
|
||||
import eu.eudat.documents.xml.ExportXmlBuilder;
|
||||
import eu.eudat.data.entities.UserInfo;
|
||||
import eu.eudat.models.HintedModelFactory;
|
||||
import eu.eudat.data.dao.criteria.DataRepositoryCriteria;
|
||||
import eu.eudat.data.dao.criteria.ExternalDatasetCriteria;
|
||||
|
@ -187,8 +187,8 @@ public class DatasetManager {
|
|||
dataset.setCreator(userInfo);
|
||||
createRegistriesIfTheyDontExist(apiContext.getOperationsContext().getDatabaseRepository().getRegistryDao(), dataset);
|
||||
createDataRepositoriesIfTheyDontExist(apiContext.getOperationsContext().getDatabaseRepository().getDataRepositoryDao(), dataset);
|
||||
createServicesIfTheyDontExist(apiContext.getOperationsContext().getDatabaseRepository().getServiceDao(), dataset);
|
||||
createExternalDatasetsIfTheyDontExist(apiContext.getOperationsContext().getDatabaseRepository().getExternalDatasetDao(), dataset);
|
||||
createServicesIfTheyDontExist(apiContext.getOperationsContext().getDatabaseRepository().getDatasetServiceDao(),apiContext.getOperationsContext().getDatabaseRepository().getServiceDao(), dataset);
|
||||
createExternalDatasetsIfTheyDontExist(apiContext.getOperationsContext().getDatabaseRepository().getDatasetExternalDatasetDao(),apiContext.getOperationsContext().getDatabaseRepository().getExternalDatasetDao(), dataset);
|
||||
return apiContext.getOperationsContext().getDatabaseRepository().getDatasetDao().createOrUpdate(dataset);
|
||||
}
|
||||
|
||||
|
@ -213,38 +213,69 @@ public class DatasetManager {
|
|||
}
|
||||
}
|
||||
|
||||
private static void createServicesIfTheyDontExist(ServiceDao serviceDao, eu.eudat.data.entities.Dataset dataset) {
|
||||
if (dataset.getServices() != null && !dataset.getServices().isEmpty()) {
|
||||
for (eu.eudat.data.entities.Service service : dataset.getServices()) {
|
||||
ServiceCriteria criteria = new ServiceCriteria();
|
||||
criteria.setLike(service.getReference());
|
||||
List<eu.eudat.data.entities.Service> entries = serviceDao.getWithCriteria(criteria).toList();
|
||||
if (entries != null && !entries.isEmpty()) service.setId(entries.get(0).getId());
|
||||
else service = serviceDao.createOrUpdate(service);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void createDataRepositoriesIfTheyDontExist(DataRepositoryDao dataRepositoryDao, eu.eudat.data.entities.Dataset dataset) {
|
||||
if (dataset.getDataRepositories() != null && !dataset.getDataRepositories().isEmpty()) {
|
||||
for (eu.eudat.data.entities.DataRepository dataRepo : dataset.getDataRepositories()) {
|
||||
Set<DatasetDataRepository> datasetDataRepositories = dataset.getDatasetDataRepositories();
|
||||
dataset.setDatasetDataRepositories(new HashSet<>());
|
||||
|
||||
if (datasetDataRepositories != null && !datasetDataRepositories.isEmpty()) {
|
||||
for (eu.eudat.data.entities.DatasetDataRepository datasetDataRepository : datasetDataRepositories) {
|
||||
DataRepositoryCriteria criteria = new DataRepositoryCriteria();
|
||||
criteria.setLike(dataRepo.getReference());
|
||||
criteria.setLike(datasetDataRepository.getDataRepository().getReference());
|
||||
List<eu.eudat.data.entities.DataRepository> entries = dataRepositoryDao.getWithCriteria(criteria).toList();
|
||||
if (entries != null && !entries.isEmpty()) dataRepo.setId(entries.get(0).getId());
|
||||
else dataRepo = dataRepositoryDao.createOrUpdate(dataRepo);
|
||||
if (entries != null && !entries.isEmpty()) {
|
||||
datasetDataRepository.getDataRepository().setId(entries.get(0).getId());
|
||||
datasetDataRepository.setDataset(dataset);
|
||||
dataset.getDatasetDataRepositories().add(datasetDataRepository);
|
||||
}
|
||||
else {
|
||||
DataRepository dataRepository = dataRepositoryDao.createOrUpdate(datasetDataRepository.getDataRepository());
|
||||
datasetDataRepository.setDataRepository(dataRepository);
|
||||
dataset.getDatasetDataRepositories().add(datasetDataRepository);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void createExternalDatasetsIfTheyDontExist(ExternalDatasetDao externalDatasetDao, eu.eudat.data.entities.Dataset dataset) {
|
||||
if (dataset.getExternalDatasets() != null && !dataset.getExternalDatasets().isEmpty()) {
|
||||
for (eu.eudat.data.entities.ExternalDataset externalDataset : dataset.getExternalDatasets()) {
|
||||
private static void createServicesIfTheyDontExist(DatasetServiceDao datasetServiceDao,ServiceDao serviceDao, eu.eudat.data.entities.Dataset dataset) {
|
||||
Set<DatasetService> services = dataset.getServices();
|
||||
dataset.setServices(new HashSet<>());
|
||||
if (services != null && !services.isEmpty()) {
|
||||
for (eu.eudat.data.entities.DatasetService datasetService : services) {
|
||||
ServiceCriteria criteria = new ServiceCriteria();
|
||||
criteria.setLike(datasetService.getService().getLabel());
|
||||
List<eu.eudat.data.entities.Service> entries = serviceDao.getWithCriteria(criteria).toList();
|
||||
if (entries != null && !entries.isEmpty()){
|
||||
datasetService.getService().setId(entries.get(0).getId());
|
||||
datasetService.setDataset(dataset);
|
||||
dataset.getServices().add(datasetService);
|
||||
}
|
||||
else {
|
||||
Service service = serviceDao.createOrUpdate(datasetService.getService());
|
||||
datasetService.setService(service );
|
||||
dataset.getServices().add(datasetService);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void createExternalDatasetsIfTheyDontExist(DatasetExternalDatasetDao datasetExternalDatasetDao,ExternalDatasetDao externalDatasetDao, eu.eudat.data.entities.Dataset dataset) {
|
||||
Set<DatasetExternalDataset> externalDatasets = dataset.getDatasetExternalDatasets();
|
||||
dataset.setDatasetExternalDatasets(new HashSet<>());
|
||||
if (externalDatasets != null && !externalDatasets.isEmpty()) {
|
||||
for (eu.eudat.data.entities.DatasetExternalDataset datasetExternalDataset : externalDatasets) {
|
||||
ExternalDatasetCriteria criteria = new ExternalDatasetCriteria();
|
||||
criteria.setLike(externalDataset.getReference());
|
||||
criteria.setLike(datasetExternalDataset.getExternalDataset().getLabel());
|
||||
List<eu.eudat.data.entities.ExternalDataset> entries = externalDatasetDao.getWithCriteria(criteria).toList();
|
||||
if (entries != null && !entries.isEmpty()) externalDataset.setId(entries.get(0).getId());
|
||||
else externalDataset = externalDatasetDao.createOrUpdate(externalDataset);
|
||||
if (entries != null && !entries.isEmpty()) {
|
||||
datasetExternalDataset.getExternalDataset().setId(entries.get(0).getId());
|
||||
datasetExternalDataset.setDataset(dataset);
|
||||
dataset.getDatasetExternalDatasets().add(datasetExternalDataset);
|
||||
}
|
||||
else {
|
||||
ExternalDataset externalDataset = externalDatasetDao.createOrUpdate(datasetExternalDataset.getExternalDataset());
|
||||
datasetExternalDataset.setExternalDataset(externalDataset);
|
||||
dataset.getDatasetExternalDatasets().add(datasetExternalDataset);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,7 +43,6 @@ public class ProjectManager {
|
|||
|
||||
QueryableList<eu.eudat.data.entities.Project> pagedItems = PaginationManager.applyPaging(authItems, projectTableRequest);
|
||||
DataTableData<eu.eudat.models.project.ProjectListingModel> dataTable = new DataTableData<>();
|
||||
|
||||
CompletableFuture projectsFuture = pagedItems.withHint(HintedModelFactory.getHint(ProjectListingModel.class)).selectAsync(item -> {
|
||||
item.setDmps(item.getDmps().stream().filter(
|
||||
dmp -> dmp.getCreator().getId().equals(principal.getId()) || dmp.getUsers().stream().filter(user -> user.getId().equals(principal.getId())).collect(Collectors.toList()).size() > 0)
|
||||
|
@ -118,7 +117,7 @@ public class ProjectManager {
|
|||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
projectEntity.setType(eu.eudat.data.entities.Project.ProjectType.INTERNAL.getValue());
|
||||
projectEntity.setCreationUser(userInfoRepository.find(principal.getId()));
|
||||
projectRepository.createOrUpdate(projectEntity);
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ public class ResearcherManager {
|
|||
|
||||
QueryableList<eu.eudat.data.entities.Researcher> items = apiContext.getOperationsContext().getDatabaseRepository().getResearcherDao().getWithCriteria(researcherCriteriaRequest.getCriteria());
|
||||
List<eu.eudat.models.dmp.Researcher> researchers = items.select(item -> new eu.eudat.models.dmp.Researcher().fromDataModel(item));
|
||||
List<Map<String, String>> remoteRepos = remoteFetcher.getResearchers(researcherCriteriaRequest.getCriteria().getLike());
|
||||
List<Map<String, String>> remoteRepos = remoteFetcher.getResearchers(researcherCriteriaRequest.getCriteria().getLike(),null);
|
||||
ResearchersExternalSourcesModel researchersExternalSourcesModel = new ResearchersExternalSourcesModel().fromExternalItem(remoteRepos);
|
||||
for (ExternalSourcesItemModel externalListingItem : researchersExternalSourcesModel) {
|
||||
eu.eudat.models.dmp.Researcher researcher = apiContext.getOperationsContext().getBuilderFactory().getBuilder(ResearcherBuilder.class)
|
||||
|
|
|
@ -6,13 +6,31 @@ import java.util.List;
|
|||
* Created by ikalyvas on 3/14/2018.
|
||||
*/
|
||||
public class RecentActivity {
|
||||
private List<RecentActivityData> recentActivities;
|
||||
private List<RecentActivityData> recentProjectActivities;
|
||||
private List<RecentActivityData> recentDatasetActivities;
|
||||
private List<RecentActivityData> recentDmpActivities;
|
||||
|
||||
public List<RecentActivityData> getRecentActivities() {
|
||||
return recentActivities;
|
||||
public List<RecentActivityData> getRecentProjectActivities() {
|
||||
return recentProjectActivities;
|
||||
}
|
||||
|
||||
public void setRecentActivities(List<RecentActivityData> recentActivities) {
|
||||
this.recentActivities = recentActivities;
|
||||
public void setRecentProjectActivities(List<RecentActivityData> recentProjectActivities) {
|
||||
this.recentProjectActivities = recentProjectActivities;
|
||||
}
|
||||
|
||||
public List<RecentActivityData> getRecentDatasetActivities() {
|
||||
return recentDatasetActivities;
|
||||
}
|
||||
|
||||
public void setRecentDatasetActivities(List<RecentActivityData> recentDatasetActivities) {
|
||||
this.recentDatasetActivities = recentDatasetActivities;
|
||||
}
|
||||
|
||||
public List<RecentActivityData> getRecentDmpActivities() {
|
||||
return recentDmpActivities;
|
||||
}
|
||||
|
||||
public void setRecentDmpActivities(List<RecentActivityData> recentDmpActivities) {
|
||||
this.recentDmpActivities = recentDmpActivities;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,37 +7,9 @@ import java.util.Date;
|
|||
*/
|
||||
public class RecentActivityData {
|
||||
|
||||
public enum RecentActivityType {
|
||||
PROJECT(0), DATASET(1), DMP(2);
|
||||
|
||||
private Integer value;
|
||||
|
||||
public Integer getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
private RecentActivityType(int value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public static RecentActivityType fromValue(Integer value) {
|
||||
switch (value) {
|
||||
case 0:
|
||||
return PROJECT;
|
||||
case 1:
|
||||
return DATASET;
|
||||
case 2:
|
||||
return DMP;
|
||||
default:
|
||||
throw new RuntimeException("Unsupported Recent Activity Status");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private String label;
|
||||
private String id;
|
||||
private Date timestamp;
|
||||
private Integer type;
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
|
@ -47,14 +19,6 @@ public class RecentActivityData {
|
|||
this.id = id;
|
||||
}
|
||||
|
||||
public Integer getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(Integer type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public Date getTimestamp() {
|
||||
return timestamp;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package eu.eudat.models.dataset;
|
||||
|
||||
import eu.eudat.models.DataModel;
|
||||
import eu.eudat.utilities.builders.XmlBuilder;
|
||||
import eu.eudat.utilities.helpers.LabelGenerator;
|
||||
|
||||
import java.util.Date;
|
||||
|
@ -9,6 +10,7 @@ public class DataRepository implements DataModel<eu.eudat.data.entities.DataRepo
|
|||
private String pid;
|
||||
private String name;
|
||||
private String uri;
|
||||
private String info;
|
||||
|
||||
public String getPid() {
|
||||
return pid;
|
||||
|
@ -34,6 +36,14 @@ public class DataRepository implements DataModel<eu.eudat.data.entities.DataRepo
|
|||
this.uri = uri;
|
||||
}
|
||||
|
||||
public String getInfo() {
|
||||
return info;
|
||||
}
|
||||
|
||||
public void setInfo(String info) {
|
||||
this.info = info;
|
||||
}
|
||||
|
||||
public DataRepository fromDataModel(eu.eudat.data.entities.DataRepository entity) {
|
||||
this.pid = entity.getReference();
|
||||
this.name = entity.getLabel();
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package eu.eudat.models.dataset;
|
||||
|
||||
import eu.eudat.data.entities.DatasetDataRepository;
|
||||
import eu.eudat.data.entities.DatasetService;
|
||||
import eu.eudat.models.DataModel;
|
||||
import eu.eudat.models.datasetprofile.DatasetProfileListingModel;
|
||||
import eu.eudat.models.dmp.DataManagementPlan;
|
||||
|
@ -138,8 +140,8 @@ public class Dataset implements DataModel<eu.eudat.data.entities.Dataset, Datase
|
|||
this.profile = new DatasetProfileListingModel();
|
||||
this.profile.fromDataModel(entity.getProfile());
|
||||
this.registries = entity.getRegistries().stream().map(item -> new Registry().fromDataModel(item)).collect(Collectors.toList());
|
||||
this.dataRepositories = entity.getDataRepositories().stream().map(item -> new DataRepository().fromDataModel(item)).collect(Collectors.toList());
|
||||
this.services = entity.getServices().stream().map(item -> new Service().fromDataModel(item)).collect(Collectors.toList());
|
||||
this.dataRepositories = entity.getDatasetDataRepositories().stream().map(item -> new DataRepository().fromDataModel(item.getDataRepository())).collect(Collectors.toList());
|
||||
this.services = entity.getServices().stream().map(item -> new Service().fromDataModel(item.getService())).collect(Collectors.toList());
|
||||
this.created = entity.getCreated();
|
||||
return this;
|
||||
}
|
||||
|
@ -165,16 +167,22 @@ public class Dataset implements DataModel<eu.eudat.data.entities.Dataset, Datase
|
|||
}
|
||||
|
||||
if (!this.dataRepositories.isEmpty()) {
|
||||
entity.setDataRepositories(new HashSet<eu.eudat.data.entities.DataRepository>());
|
||||
for (DataRepository dataRepository : this.dataRepositories) {
|
||||
entity.getDataRepositories().add(dataRepository.toDataModel());
|
||||
entity.setDatasetDataRepositories(new HashSet<>());
|
||||
for (DataRepository dataRepositoryModel : this.dataRepositories) {
|
||||
DatasetDataRepository datasetDataRepository = new DatasetDataRepository();
|
||||
eu.eudat.data.entities.DataRepository dataRepository = dataRepositoryModel.toDataModel();
|
||||
datasetDataRepository.setDataRepository(dataRepository);
|
||||
entity.getDatasetDataRepositories().add(datasetDataRepository);
|
||||
}
|
||||
}
|
||||
|
||||
if (!this.services.isEmpty()) {
|
||||
entity.setServices(new HashSet<eu.eudat.data.entities.Service>());
|
||||
for (Service service : this.services) {
|
||||
entity.getServices().add(service.toDataModel());
|
||||
entity.setServices(new HashSet<DatasetService>());
|
||||
for (Service serviceModel : this.services) {
|
||||
eu.eudat.data.entities.Service service = serviceModel.toDataModel();
|
||||
DatasetService datasetService = new DatasetService();
|
||||
datasetService.setService(service);
|
||||
entity.getServices().add(datasetService);
|
||||
}
|
||||
}
|
||||
return entity;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package eu.eudat.models.datasetwizard;
|
||||
|
||||
import eu.eudat.data.entities.Dataset;
|
||||
import eu.eudat.data.entities.*;
|
||||
import eu.eudat.models.DataModel;
|
||||
import eu.eudat.models.dataset.DataRepository;
|
||||
import eu.eudat.models.dataset.Registry;
|
||||
|
@ -9,11 +9,11 @@ import eu.eudat.models.datasetprofile.DatasetProfileListingModel;
|
|||
import eu.eudat.models.dmp.DataManagementPlan;
|
||||
import eu.eudat.models.externaldataset.ExternalDatasetListingModel;
|
||||
import eu.eudat.models.user.composite.PagedDatasetProfile;
|
||||
import eu.eudat.types.externalsourcetype.ExternalDatasetType;
|
||||
import eu.eudat.utilities.builders.XmlBuilder;
|
||||
import net.minidev.json.JSONValue;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
|
@ -157,11 +157,28 @@ public class DatasetWizardModel implements DataModel<Dataset, DatasetWizardModel
|
|||
this.uri = entity.getUri();
|
||||
this.profile.fromDataModel(entity.getProfile());
|
||||
this.registries = entity.getRegistries().stream().map(item -> new Registry().fromDataModel(item)).collect(Collectors.toList());
|
||||
this.dataRepositories = entity.getDataRepositories().stream().map(item -> new DataRepository().fromDataModel(item)).collect(Collectors.toList());
|
||||
this.services = entity.getServices().stream().map(item -> new Service().fromDataModel(item)).collect(Collectors.toList());
|
||||
this.dataRepositories = entity.getDatasetDataRepositories().stream().map(item -> {
|
||||
DataRepository dataRepository = new DataRepository().fromDataModel(item.getDataRepository());
|
||||
if(item.getData()!=null) {
|
||||
Map<String, Map<String, String>> data = (Map<String, Map<String, String>>) JSONValue.parse(item.getData());
|
||||
Map<String, String> values = data.get("data");
|
||||
dataRepository.setInfo(values.get("info"));
|
||||
}
|
||||
return dataRepository;
|
||||
}).collect(Collectors.toList());
|
||||
this.services = entity.getServices().stream().map(item -> new Service().fromDataModel(item.getService())).collect(Collectors.toList());
|
||||
this.created = entity.getCreated();
|
||||
this.dmp = new DataManagementPlan().fromDataModel(entity.getDmp());
|
||||
this.externalDatasets = entity.getExternalDatasets().stream().map(item -> new ExternalDatasetListingModel().fromDataModel(item)).collect(Collectors.toList());
|
||||
this.externalDatasets = entity.getDatasetExternalDatasets().stream().map(item -> {
|
||||
ExternalDatasetListingModel externalDatasetListingModel = new ExternalDatasetListingModel().fromDataModel(item.getExternalDataset());
|
||||
if(item.getData()!=null) {
|
||||
Map<String, Map<String, String>> data = (Map<String, Map<String, String>>) JSONValue.parse(item.getData());
|
||||
Map<String, String> values = data.get("data");
|
||||
externalDatasetListingModel.setInfo(values.get("info"));
|
||||
externalDatasetListingModel.setType(Integer.parseInt(values.get("type")));
|
||||
}
|
||||
return externalDatasetListingModel;
|
||||
}).collect(Collectors.toList());
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -186,23 +203,43 @@ public class DatasetWizardModel implements DataModel<Dataset, DatasetWizardModel
|
|||
}
|
||||
|
||||
if (this.dataRepositories != null && !this.dataRepositories.isEmpty()) {
|
||||
entity.setDataRepositories(new HashSet<eu.eudat.data.entities.DataRepository>());
|
||||
for (DataRepository dataRepository : this.dataRepositories) {
|
||||
entity.getDataRepositories().add(dataRepository.toDataModel());
|
||||
entity.setDatasetDataRepositories(new HashSet<DatasetDataRepository>());
|
||||
for (DataRepository dataRepositoryModel : this.dataRepositories) {
|
||||
eu.eudat.data.entities.DataRepository dataRepository = dataRepositoryModel.toDataModel();
|
||||
DatasetDataRepository datasetDataRepository = new DatasetDataRepository();
|
||||
datasetDataRepository.setDataRepository(dataRepository);
|
||||
Map<String,Map<String,String>> data = new HashMap<>();
|
||||
Map<String,String> values = new HashMap<>();
|
||||
values.put("info",dataRepositoryModel.getInfo());
|
||||
data.put("data",values);
|
||||
datasetDataRepository.setData(JSONValue.toJSONString(data));
|
||||
entity.getDatasetDataRepositories().add(datasetDataRepository);
|
||||
}
|
||||
}
|
||||
|
||||
if (this.services != null && !this.services.isEmpty()) {
|
||||
entity.setServices(new HashSet<eu.eudat.data.entities.Service>());
|
||||
for (Service service : this.services) {
|
||||
entity.getServices().add(service.toDataModel());
|
||||
entity.setServices(new HashSet<DatasetService>());
|
||||
for (Service serviceModel : this.services) {
|
||||
eu.eudat.data.entities.Service service = serviceModel.toDataModel();
|
||||
DatasetService datasetService = new DatasetService();
|
||||
datasetService.setService(service);
|
||||
entity.getServices().add(datasetService);
|
||||
}
|
||||
}
|
||||
|
||||
if (this.externalDatasets != null && !this.externalDatasets.isEmpty()) {
|
||||
entity.setExternalDatasets(new HashSet<eu.eudat.data.entities.ExternalDataset>());
|
||||
entity.setDatasetExternalDatasets(new HashSet<DatasetExternalDataset>());
|
||||
for (ExternalDatasetListingModel externalDataset : this.externalDatasets) {
|
||||
entity.getExternalDatasets().add(externalDataset.toDataModel());
|
||||
ExternalDataset externalDatasetEntity = externalDataset.toDataModel();
|
||||
DatasetExternalDataset datasetExternalDataset = new DatasetExternalDataset();
|
||||
datasetExternalDataset.setExternalDataset(externalDatasetEntity);
|
||||
Map<String,Map<String,String>> data = new HashMap<>();
|
||||
Map<String,String> values = new HashMap<>();
|
||||
values.put("info",externalDataset.getInfo());
|
||||
values.put("type",externalDataset.getType().toString());
|
||||
data.put("data",values);
|
||||
datasetExternalDataset.setData(JSONValue.toJSONString(data));
|
||||
entity.getDatasetExternalDatasets().add(datasetExternalDataset);
|
||||
}
|
||||
}
|
||||
return entity;
|
||||
|
|
|
@ -2,11 +2,11 @@ package eu.eudat.models.externaldataset;
|
|||
|
||||
import eu.eudat.data.entities.ExternalDataset;
|
||||
import eu.eudat.models.DataModel;
|
||||
import eu.eudat.types.externalsourcetype.ExternalDatasetType;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.UUID;
|
||||
|
||||
|
||||
public class ExternalDatasetListingModel implements DataModel<ExternalDataset, ExternalDatasetListingModel> {
|
||||
|
||||
private UUID id;
|
||||
|
@ -15,6 +15,8 @@ public class ExternalDatasetListingModel implements DataModel<ExternalDataset, E
|
|||
private String reference;
|
||||
private Date created;
|
||||
private Date modified;
|
||||
private String info;
|
||||
private ExternalDatasetType type;
|
||||
|
||||
public UUID getId() {
|
||||
return id;
|
||||
|
@ -64,6 +66,22 @@ public class ExternalDatasetListingModel implements DataModel<ExternalDataset, E
|
|||
this.modified = modified;
|
||||
}
|
||||
|
||||
public Integer getType() {
|
||||
return type != null ? type.getValue() : null;
|
||||
}
|
||||
|
||||
public void setType(Integer type) {
|
||||
this.type = ExternalDatasetType.fromInteger(type);
|
||||
}
|
||||
|
||||
public String getInfo() {
|
||||
return info;
|
||||
}
|
||||
|
||||
public void setInfo(String info) {
|
||||
this.info = info;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExternalDatasetListingModel fromDataModel(ExternalDataset entity) {
|
||||
this.id = entity.getId();
|
||||
|
|
|
@ -0,0 +1,72 @@
|
|||
package eu.eudat.models.externalurl;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by ikalyvas on 5/17/2018.
|
||||
*/
|
||||
public class ExternalSourcesConfiguration {
|
||||
|
||||
public static class ExternalSourcesUrlModel{
|
||||
private String key;
|
||||
private String label;
|
||||
|
||||
public ExternalSourcesUrlModel(String key, String label) {
|
||||
this.key = key;
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
public void setKey(String key) {
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
public String getLabel() {
|
||||
return label;
|
||||
}
|
||||
|
||||
public void setLabel(String label) {
|
||||
this.label = label;
|
||||
}
|
||||
}
|
||||
|
||||
private List<ExternalSourcesUrlModel> registries;
|
||||
private List<ExternalSourcesUrlModel> dataRepositories;
|
||||
private List<ExternalSourcesUrlModel> services;
|
||||
private List<ExternalSourcesUrlModel> externalDatasets;
|
||||
|
||||
public List<ExternalSourcesUrlModel> getRegistries() {
|
||||
return registries;
|
||||
}
|
||||
|
||||
public void setRegistries(List<ExternalSourcesUrlModel> registries) {
|
||||
this.registries = registries;
|
||||
}
|
||||
|
||||
public List<ExternalSourcesUrlModel> getDataRepositories() {
|
||||
return dataRepositories;
|
||||
}
|
||||
|
||||
public void setDataRepositories(List<ExternalSourcesUrlModel> dataRepositories) {
|
||||
this.dataRepositories = dataRepositories;
|
||||
}
|
||||
|
||||
public List<ExternalSourcesUrlModel> getServices() {
|
||||
return services;
|
||||
}
|
||||
|
||||
public void setServices(List<ExternalSourcesUrlModel> services) {
|
||||
this.services = services;
|
||||
}
|
||||
|
||||
public List<ExternalSourcesUrlModel> getExternalDatasets() {
|
||||
return externalDatasets;
|
||||
}
|
||||
|
||||
public void setExternalDatasets(List<ExternalSourcesUrlModel> externalDatasets) {
|
||||
this.externalDatasets = externalDatasets;
|
||||
}
|
||||
}
|
|
@ -111,8 +111,8 @@ public class DatasetListingModel implements DataModel<Dataset, DatasetListingMod
|
|||
this.description = entity.getDescription();
|
||||
this.status = "" + entity.getStatus();
|
||||
this.registries = LabelBuilder.getLabel(entity.getRegistries().stream().map(item -> new eu.eudat.models.dataset.Registry().fromDataModel(item)).collect(Collectors.toList()));
|
||||
this.dataRepositories = LabelBuilder.getLabel(entity.getDataRepositories().stream().map(item -> new DataRepository().fromDataModel(item)).collect(Collectors.toList()));
|
||||
this.services = LabelBuilder.getLabel(entity.getServices().stream().map(item -> new Service().fromDataModel(item)).collect(Collectors.toList()));
|
||||
this.dataRepositories = LabelBuilder.getLabel(entity.getDatasetDataRepositories().stream().map(item -> new DataRepository().fromDataModel(item.getDataRepository())).collect(Collectors.toList()));
|
||||
this.services = LabelBuilder.getLabel(entity.getServices().stream().map(item -> new Service().fromDataModel(item.getService())).collect(Collectors.toList()));
|
||||
return this;
|
||||
}
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@ public class LoginProviderUser {
|
|||
private String id;
|
||||
private String email;
|
||||
private String secret;
|
||||
private String avatarUrl;
|
||||
private boolean isVerified;
|
||||
private TokenValidatorFactoryImpl.LoginProvider provider;
|
||||
|
||||
|
@ -58,4 +59,12 @@ public class LoginProviderUser {
|
|||
public void setSecret(String secret) {
|
||||
this.secret = secret;
|
||||
}
|
||||
|
||||
public String getAvatarUrl() {
|
||||
return avatarUrl;
|
||||
}
|
||||
|
||||
public void setAvatarUrl(String avatarUrl) {
|
||||
this.avatarUrl = avatarUrl;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,6 +19,8 @@ public class Project implements DataModel<eu.eudat.data.entities.Project, Projec
|
|||
|
||||
private String label;
|
||||
|
||||
private int type;
|
||||
|
||||
private String abbreviation;
|
||||
|
||||
private String reference;
|
||||
|
@ -52,6 +54,14 @@ public class Project implements DataModel<eu.eudat.data.entities.Project, Projec
|
|||
this.id = id;
|
||||
}
|
||||
|
||||
public int getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(int type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public List<DataManagementPlan> getDmps() {
|
||||
return dmps;
|
||||
}
|
||||
|
@ -171,6 +181,7 @@ public class Project implements DataModel<eu.eudat.data.entities.Project, Projec
|
|||
this.abbreviation = entity.getAbbreviation();
|
||||
this.reference = entity.getReference();
|
||||
this.uri = entity.getUri();
|
||||
this.type = entity.getType();
|
||||
this.definition = entity.getDefinition();
|
||||
this.startDate = entity.getStartdate();
|
||||
this.endDate = entity.getEnddate();
|
||||
|
@ -188,6 +199,7 @@ public class Project implements DataModel<eu.eudat.data.entities.Project, Projec
|
|||
entity.setId(this.id);
|
||||
entity.setAbbreviation(this.abbreviation);
|
||||
entity.setLabel(this.label);
|
||||
entity.setType(this.type);
|
||||
entity.setReference(this.reference == null ? "dmp:" + this.label : this.reference);
|
||||
entity.setUri(this.uri);
|
||||
entity.setDefinition(this.definition);
|
||||
|
|
|
@ -12,6 +12,7 @@ public class Principal {
|
|||
private UUID token;
|
||||
private String name;
|
||||
private Date expiresAt;
|
||||
private String avatarUrl;
|
||||
private Set<Authorities> authorities;
|
||||
|
||||
public UUID getId() {
|
||||
|
@ -46,6 +47,14 @@ public class Principal {
|
|||
this.expiresAt = expiresAt;
|
||||
}
|
||||
|
||||
public String getAvatarUrl() {
|
||||
return avatarUrl;
|
||||
}
|
||||
|
||||
public void setAvatarUrl(String avatarUrl) {
|
||||
this.avatarUrl = avatarUrl;
|
||||
}
|
||||
|
||||
public Set<Integer> getAuthorities() {
|
||||
return authorities.stream().map(authz -> authz.getValue()).collect(Collectors.toSet());
|
||||
}
|
||||
|
|
|
@ -5,11 +5,30 @@ import javax.xml.bind.annotation.XmlElement;
|
|||
|
||||
public class UrlConfig {
|
||||
|
||||
private String key;
|
||||
private String label;
|
||||
private Integer ordinal;
|
||||
private String url;
|
||||
private String dataPath;
|
||||
private String paginationPath;
|
||||
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
@XmlElement(name = "key")
|
||||
public void setKey(String key) {
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
public String getLabel() {
|
||||
return label;
|
||||
}
|
||||
|
||||
@XmlElement(name = "label")
|
||||
public void setLabel(String label) {
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
public String getUrl() {
|
||||
return url;
|
||||
|
|
|
@ -17,6 +17,7 @@ import java.net.HttpURLConnection;
|
|||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
public class RemoteFetcher {
|
||||
|
@ -32,8 +33,10 @@ public class RemoteFetcher {
|
|||
}
|
||||
|
||||
@Cacheable("repositories")
|
||||
public List<Map<String, String>> getRepositories(String query) throws NoURLFound, HugeResultSet {
|
||||
List<UrlConfig> urlConfigs = configLoader.getExternalUrls().getRepositories().getUrls();
|
||||
public List<Map<String, String>> getRepositories(String query, String key) throws NoURLFound, HugeResultSet {
|
||||
List<UrlConfig> urlConfigs =
|
||||
key != null ? configLoader.getExternalUrls().getRepositories().getUrls().stream().filter(item -> item.getKey().equals(key)).collect(Collectors.toList())
|
||||
: configLoader.getExternalUrls().getRepositories().getUrls();
|
||||
FetchStrategy fetchStrategy = configLoader.getExternalUrls().getRepositories().getFetchMode();
|
||||
return getAll(urlConfigs, fetchStrategy, query);
|
||||
}
|
||||
|
@ -46,36 +49,46 @@ public class RemoteFetcher {
|
|||
}
|
||||
|
||||
@Cacheable("organisations")
|
||||
public List<Map<String, String>> getOrganisations(String query) throws NoURLFound, HugeResultSet {
|
||||
List<UrlConfig> urlConfigs = configLoader.getExternalUrls().getOrganisations().getUrls();
|
||||
public List<Map<String, String>> getOrganisations(String query, String key) throws NoURLFound, HugeResultSet {
|
||||
List<UrlConfig> urlConfigs =
|
||||
key != null ? configLoader.getExternalUrls().getOrganisations().getUrls().stream().filter(item -> item.getKey().equals(key)).collect(Collectors.toList())
|
||||
: configLoader.getExternalUrls().getOrganisations().getUrls();
|
||||
FetchStrategy fetchStrategy = configLoader.getExternalUrls().getOrganisations().getFetchMode();
|
||||
return getAll(urlConfigs, fetchStrategy, query);
|
||||
}
|
||||
|
||||
@Cacheable("registries")
|
||||
public List<Map<String, String>> getRegistries(String query) throws NoURLFound, HugeResultSet {
|
||||
List<UrlConfig> urlConfigs = configLoader.getExternalUrls().getRegistries().getUrls();
|
||||
public List<Map<String, String>> getRegistries(String query, String key) throws NoURLFound, HugeResultSet {
|
||||
List<UrlConfig> urlConfigs =
|
||||
key != null ? configLoader.getExternalUrls().getRegistries().getUrls().stream().filter(item -> item.getKey().equals(key)).collect(Collectors.toList())
|
||||
: configLoader.getExternalUrls().getRegistries().getUrls();
|
||||
FetchStrategy fetchStrategy = configLoader.getExternalUrls().getRegistries().getFetchMode();
|
||||
return getAll(urlConfigs, fetchStrategy, query);
|
||||
}
|
||||
|
||||
@Cacheable("services")
|
||||
public List<Map<String, String>> getServices(String query) throws NoURLFound, HugeResultSet {
|
||||
List<UrlConfig> urlConfigs = configLoader.getExternalUrls().getServices().getUrls();
|
||||
public List<Map<String, String>> getServices(String query,String key) throws NoURLFound, HugeResultSet {
|
||||
List<UrlConfig> urlConfigs =
|
||||
key != null ? configLoader.getExternalUrls().getServices().getUrls().stream().filter(item -> item.getKey().equals(key)).collect(Collectors.toList())
|
||||
: configLoader.getExternalUrls().getServices().getUrls();
|
||||
FetchStrategy fetchStrategy = configLoader.getExternalUrls().getServices().getFetchMode();
|
||||
return getAll(urlConfigs, fetchStrategy, query);
|
||||
}
|
||||
|
||||
@Cacheable("researchers")
|
||||
public List<Map<String, String>> getResearchers(String query) throws NoURLFound, HugeResultSet {
|
||||
List<UrlConfig> urlConfigs = configLoader.getExternalUrls().getResearchers().getUrls();
|
||||
public List<Map<String, String>> getResearchers(String query,String key) throws NoURLFound, HugeResultSet {
|
||||
List<UrlConfig> urlConfigs =
|
||||
key != null ? configLoader.getExternalUrls().getResearchers().getUrls().stream().filter(item -> item.getKey().equals(key)).collect(Collectors.toList())
|
||||
: configLoader.getExternalUrls().getResearchers().getUrls();
|
||||
FetchStrategy fetchStrategy = configLoader.getExternalUrls().getResearchers().getFetchMode();
|
||||
return getAll(urlConfigs, fetchStrategy, query);
|
||||
}
|
||||
|
||||
@Cacheable("datasets")
|
||||
public List<Map<String, String>> getDatasets(String query) throws NoURLFound, HugeResultSet {
|
||||
List<UrlConfig> urlConfigs = configLoader.getExternalUrls().getDatasets().getUrls();
|
||||
public List<Map<String, String>> getDatasets(String query,String key) throws NoURLFound, HugeResultSet {
|
||||
List<UrlConfig> urlConfigs =
|
||||
key != null ? configLoader.getExternalUrls().getDatasets().getUrls().stream().filter(item -> item.getKey().equals(key)).collect(Collectors.toList())
|
||||
: configLoader.getExternalUrls().getDatasets().getUrls();
|
||||
FetchStrategy fetchStrategy = configLoader.getExternalUrls().getDatasets().getFetchMode();
|
||||
return getAll(urlConfigs, fetchStrategy, query);
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@ import java.io.IOException;
|
|||
import java.security.GeneralSecurityException;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
@Component("facebookTokenValidator")
|
||||
|
@ -43,18 +44,21 @@ public class FacebookTokenValidator implements TokenValidator {
|
|||
LoginProviderUser user = new LoginProviderUser();
|
||||
if (profile.getEmail() == null)
|
||||
throw new UnauthorisedException("Cannot login user.Facebook account did not provide email");
|
||||
|
||||
user.setEmail(profile.getEmail());
|
||||
user.setId(profile.getId());
|
||||
user.setIsVerified(profile.isVerified());
|
||||
user.setName(profile.getName());
|
||||
user.setProvider(TokenValidatorFactoryImpl.LoginProvider.FACEBOOK);
|
||||
String url = (String)((Map<String,Object> )((Map<String,Object> )profile.getExtraData().get("picture")).get("data")).get("url");
|
||||
user.setAvatarUrl(url);
|
||||
user.setSecret(credentials.getTicket());
|
||||
return this.authenticationServiceImpl.Touch(user);
|
||||
}
|
||||
|
||||
|
||||
private User getFacebookUser(String accessToken) {
|
||||
String[] fields = {"id", "email", "first_name", "last_name", "name", "verified"};
|
||||
String[] fields = {"id", "email", "first_name", "last_name", "name", "verified","picture"};
|
||||
User profile = this.facebookServiceProvider.getApi(accessToken).fetchObject("me", User.class, fields);
|
||||
return profile;
|
||||
}
|
||||
|
|
|
@ -50,6 +50,7 @@ public class GoogleTokenValidator implements TokenValidator {
|
|||
GoogleIdToken idToken = this.verifyUserAndGetUser(credentials.getTicket());
|
||||
Payload payload = idToken.getPayload();
|
||||
LoginProviderUser user = new LoginProviderUser();
|
||||
user.setAvatarUrl((String) payload.get("picture"));
|
||||
user.setSecret(credentials.getTicket());
|
||||
user.setId( payload.getSubject());
|
||||
user.setProvider(TokenValidatorFactoryImpl.LoginProvider.GOOGLE);
|
||||
|
|
|
@ -49,6 +49,7 @@ public class LinkedInTokenValidator implements TokenValidator {
|
|||
user.setEmail(linkedInProfile.getEmailAddress());
|
||||
user.setId(linkedInProfile.getId());
|
||||
user.setIsVerified(true); //TODO
|
||||
user.setAvatarUrl(linkedInProfile.getProfilePictureUrl());
|
||||
user.setName(linkedInProfile.getFirstName() + " " + linkedInProfile.getLastName());
|
||||
user.setProvider(TokenValidatorFactoryImpl.LoginProvider.LINKEDIN);
|
||||
user.setSecret(accessGrant.getAccessToken());
|
||||
|
|
|
@ -53,6 +53,7 @@ public class TwitterTokenValidator implements TokenValidator {
|
|||
if (values.get("email") == null)
|
||||
throw new UnauthorisedException("Cannot login user.Twitter account did not provide email");
|
||||
user.setEmail((String) values.get("email"));
|
||||
user.setAvatarUrl(profile.getProfileImageUrl());
|
||||
user.setIsVerified(true); //TODO
|
||||
user.setId(""+profile.getId());
|
||||
user.setName(profile.getName());
|
||||
|
|
|
@ -1,14 +1,15 @@
|
|||
package eu.eudat.services.operations;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import eu.eudat.builders.entity.CredentialBuilder;
|
||||
import eu.eudat.builders.entity.UserInfoBuilder;
|
||||
import eu.eudat.builders.entity.UserTokenBuilder;
|
||||
import eu.eudat.builders.model.models.PrincipalBuilder;
|
||||
import eu.eudat.data.dao.criteria.UserInfoCriteria;
|
||||
import eu.eudat.data.entities.Credential;
|
||||
import eu.eudat.data.entities.UserInfo;
|
||||
import eu.eudat.data.entities.UserRole;
|
||||
import eu.eudat.data.entities.UserToken;
|
||||
import eu.eudat.data.dao.criteria.UserInfoCriteria;
|
||||
import eu.eudat.models.login.Credentials;
|
||||
import eu.eudat.models.loginprovider.LoginProviderUser;
|
||||
import eu.eudat.models.security.Principal;
|
||||
|
@ -20,6 +21,7 @@ import org.springframework.core.env.Environment;
|
|||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
|
||||
|
||||
|
@ -51,12 +53,17 @@ public class AuthenticationServiceImpl implements AuthenticationService {
|
|||
|
||||
UserInfo user = this.apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao().find(token.getUser().getId());
|
||||
if (user == null) return null;
|
||||
|
||||
String json;
|
||||
try {
|
||||
json = user.getAdditionalinfo() != null ? new ObjectMapper().readTree(user.getAdditionalinfo()).get("data").get("avatar").get("url").asText() : "";
|
||||
} catch (IOException e) {
|
||||
json = "";
|
||||
}
|
||||
Principal principal = this.apiContext.getOperationsContext().getBuilderFactory().getBuilder(PrincipalBuilder.class)
|
||||
.id(user.getId()).token(token.getToken())
|
||||
.expiresAt(token.getExpiresAt()).name(user.getName())
|
||||
.avatarUrl(json)
|
||||
.build();
|
||||
|
||||
List<UserRole> userRoles = apiContext.getOperationsContext().getDatabaseRepository().getUserRoleDao().getUserRoles(user);
|
||||
for (UserRole item : userRoles) {
|
||||
if (principal.getAuthz() == null) principal.setAuthorities(new HashSet<>());
|
||||
|
@ -66,7 +73,7 @@ public class AuthenticationServiceImpl implements AuthenticationService {
|
|||
}
|
||||
|
||||
public Principal Touch(Credentials credentials) {
|
||||
Credential credential = this.apiContext.getOperationsContext().getDatabaseRepository().getCredentialDao().getLoggedInCredentials(credentials.getUsername(),credentials.getSecret(), TokenValidatorFactoryImpl.LoginProvider.NATIVELOGIN.getValue());
|
||||
Credential credential = this.apiContext.getOperationsContext().getDatabaseRepository().getCredentialDao().getLoggedInCredentials(credentials.getUsername(), credentials.getSecret(), TokenValidatorFactoryImpl.LoginProvider.NATIVELOGIN.getValue());
|
||||
|
||||
if (credential == null && credentials.getUsername().equals(environment.getProperty("autouser.root.username"))) {
|
||||
try {
|
||||
|
@ -105,7 +112,7 @@ public class AuthenticationServiceImpl implements AuthenticationService {
|
|||
|
||||
final Credential credential = this.apiContext.getOperationsContext().getBuilderFactory().getBuilder(CredentialBuilder.class)
|
||||
.id(UUID.randomUUID()).creationTime(new Date()).status(1)
|
||||
.lastUpdateTime(new Date()).provider( profile.getProvider().getValue())
|
||||
.lastUpdateTime(new Date()).provider(profile.getProvider().getValue())
|
||||
.secret(profile.getSecret()).externalId(profile.getId())
|
||||
.build();
|
||||
|
||||
|
@ -113,6 +120,7 @@ public class AuthenticationServiceImpl implements AuthenticationService {
|
|||
userInfo = this.apiContext.getOperationsContext().getBuilderFactory().getBuilder(UserInfoBuilder.class)
|
||||
.name(profile.getName()).verified_email(profile.getIsVerified())
|
||||
.email(profile.getEmail()).created(new Date()).lastloggedin(new Date())
|
||||
.additionalinfo("{\"data\":{\"avatar\":{\"url\":\""+profile.getAvatarUrl()+"\"}}}")
|
||||
.authorization_level((short) 1).usertype((short) 1)
|
||||
.build();
|
||||
|
||||
|
@ -128,6 +136,7 @@ public class AuthenticationServiceImpl implements AuthenticationService {
|
|||
|
||||
} else {
|
||||
userInfo.setLastloggedin(new Date());
|
||||
userInfo.setAdditionalinfo("{\"data\":{\"avatar\":{\"url\":\""+profile.getAvatarUrl()+"\"}}}");
|
||||
Set<Credential> credentials = userInfo.getCredentials();
|
||||
if (credentials.contains(credential)) {
|
||||
Credential oldCredential = credentials.stream().filter(item -> credential.getProvider().equals(item.getProvider())).findFirst().get();
|
||||
|
|
|
@ -41,4 +41,8 @@ public interface DatabaseRepository {
|
|||
ContentDao getContentDao();
|
||||
|
||||
DMPProfileDao getDmpProfileDao();
|
||||
|
||||
DatasetExternalDatasetDao getDatasetExternalDatasetDao();
|
||||
|
||||
DatasetServiceDao getDatasetServiceDao();
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package eu.eudat.services.operations;
|
|||
import eu.eudat.data.dao.entities.*;
|
||||
import eu.eudat.data.dao.entities.security.CredentialDao;
|
||||
import eu.eudat.data.dao.entities.security.UserTokenDao;
|
||||
import eu.eudat.data.entities.DatasetService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
|
@ -30,6 +31,8 @@ public class DatabaseRepositoryImpl implements DatabaseRepository {
|
|||
private UserDmpDao userDmpDao;
|
||||
private ContentDao contentDao;
|
||||
private DMPProfileDao dmpProfileDao;
|
||||
private DatasetExternalDatasetDao datasetExternalDatasetDao;
|
||||
private DatasetServiceDao datasetServiceDao;
|
||||
|
||||
private EntityManager entityManager;
|
||||
|
||||
|
@ -217,4 +220,24 @@ public class DatabaseRepositoryImpl implements DatabaseRepository {
|
|||
public void setDmpProfileDao(DMPProfileDao dmpProfileDao) {
|
||||
this.dmpProfileDao = dmpProfileDao;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DatasetExternalDatasetDao getDatasetExternalDatasetDao() {
|
||||
return datasetExternalDatasetDao;
|
||||
}
|
||||
|
||||
@Autowired
|
||||
public void setDatasetExternalDatasetDao(DatasetExternalDatasetDao datasetExternalDatasetDao) {
|
||||
this.datasetExternalDatasetDao = datasetExternalDatasetDao;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DatasetServiceDao getDatasetServiceDao() {
|
||||
return datasetServiceDao;
|
||||
}
|
||||
|
||||
@Autowired
|
||||
public void setDatasetServiceDao(DatasetServiceDao datasetServiceDao) {
|
||||
this.datasetServiceDao = datasetServiceDao;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
package eu.eudat.types.externalsourcetype;
|
||||
|
||||
import eu.eudat.types.ApiMessageCode;
|
||||
|
||||
/**
|
||||
* Created by ikalyvas on 5/28/2018.
|
||||
*/
|
||||
public enum ExternalDatasetType{
|
||||
|
||||
SOURCE(0), OUTPUT(1) ;
|
||||
private Integer value;
|
||||
|
||||
private ExternalDatasetType(Integer value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public Integer getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public static ExternalDatasetType fromInteger(Integer value) {
|
||||
switch (value) {
|
||||
case 0:
|
||||
return SOURCE;
|
||||
case 1:
|
||||
return OUTPUT;
|
||||
default:
|
||||
throw new RuntimeException("Unsupported Api Message Code");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -68,6 +68,12 @@ public class XmlBuilder {
|
|||
}
|
||||
}
|
||||
|
||||
public static String getItemValueAsString(String xml,String name){
|
||||
Document doc = fromXml(xml);
|
||||
Element root = doc.getDocumentElement();
|
||||
return root.getElementsByTagName(name).item(0).getNodeValue();
|
||||
}
|
||||
|
||||
public static Element getNodeFromListByTagName(NodeList list, String tagName) {
|
||||
for (int temp = 0; temp < list.getLength(); temp++) {
|
||||
Node element = list.item(temp);
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue